plsql

package
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Completion

func Completion(ctx context.Context, cCtx base.CompletionContext, statement string, caretLine int, caretOffset int) ([]base.Candidate, error)

func Diagnose

func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]base.Diagnostic, error)

func EquivalentType

func EquivalentType(tp parser.IDatatypeContext, text string) (bool, error)

EquivalentType returns true if the given type is equivalent to the given text.

func EraseString

func EraseString(ctx EraseContext, rule antlr.ParserRuleContext, tokens antlr.TokenStream) string

func GenerateRestoreSQL

func GenerateRestoreSQL(ctx context.Context, rCtx base.RestoreContext, statement string, backupItem *storepb.PriorBackupDetail_Item) (string, error)

func GetQuerySpan

func GetQuerySpan(ctx context.Context, gCtx base.GetQuerySpanContext, statement, database, _ string, _ bool) (*base.QuerySpan, error)

func GetStatementTypes

func GetStatementTypes(asts []base.AST) ([]string, error)

func IsOracleKeyword

func IsOracleKeyword(text string) bool

IsOracleKeyword returns true if the given text is an Oracle keyword.

func IsTopLevelStatement

func IsTopLevelStatement(ctx antlr.Tree) bool

func NormalizeColumnName

func NormalizeColumnName(columnName parser.IColumn_nameContext) (string, string, string)

NormalizeColumnName returns the normalized column name from the given context.

func NormalizeConstraintName

func NormalizeConstraintName(constraintName parser.IConstraint_nameContext) (string, string)

NormalizeConstraintName returns the normalized constraint name from the given context.

func NormalizeIDExpression

func NormalizeIDExpression(idExpression parser.IId_expressionContext) string

NormalizeIDExpression returns the normalized identifier from the given context.

func NormalizeIdentifierContext

func NormalizeIdentifierContext(identifier parser.IIdentifierContext) string

NormalizeIdentifierContext returns the normalized identifier from the given context.

func NormalizeIndexName

func NormalizeIndexName(indexName parser.IIndex_nameContext) (string, string)

NormalizeIndexName returns the normalized index name from the given context.

func NormalizeQuotedString

func NormalizeQuotedString(ctx plsql.IQuoted_stringContext) string

NormalizeQuotedString returns the string without the quotes.

func NormalizeSchemaName

func NormalizeSchemaName(schemaName parser.ISchema_nameContext) string

NormalizeSchemaName returns the normalized schema name from the given context.

func NormalizeTableAlias

func NormalizeTableAlias(ctx plsql.ITable_aliasContext) string

func NormalizeTableName

func NormalizeTableName(tableName parser.ITable_nameContext) string

NormalizeTableName returns the normalized table name from the given context.

func NormalizeTableViewName

func NormalizeTableViewName(currentSchema string, ctx parser.ITableview_nameContext) ([]string, string, string)

NormalizeTableViewName normalizes the table name and schema name. Return empty string if it's xml table.

func ParsePLSQL

func ParsePLSQL(sql string) ([]*base.ParseResult, error)

ParsePLSQL parses the given PLSQL and returns a list of parse results. It first parses the whole statement to get the AST, then splits by unit_statement and sql_plus_command nodes, and re-parses each individual statement.

func ParsePLSQLForStringsManipulation

func ParsePLSQLForStringsManipulation(sql string) (antlr.Tree, antlr.TokenStream, error)

ParsePLSQLForStringsManipulation parses the whole SQL without splitting. This is used for strings manipulation which needs to see all statements together.

func SplitSQL

func SplitSQL(statement string) ([]base.SingleSQL, error)

SplitSQL splits the given SQL statement into multiple SQL statements. TODO(zp): Consolidate with split logic in ParsePLSQL?

func SplitSQLForCompletion

func SplitSQLForCompletion(statement string) ([]base.SingleSQL, error)

func TransformDMLToSelect

func TransformDMLToSelect(_ context.Context, tCtx base.TransformContext, statement string, sourceDatabase string, targetDatabase string, tablePrefix string) ([]base.BackupStatement, error)

TransformDMLToSelect transforms DML statement to SELECT statement. For Oracle, we only consider the managed on schema mode.

Types

type AliasListener

type AliasListener struct {
	*plsql.BasePlSqlParserListener
	// contains filtered or unexported fields
}

func (*AliasListener) EnterColumn_alias

func (l *AliasListener) EnterColumn_alias(ctx *plsql.Column_aliasContext)

type CTETableListener

type CTETableListener struct {
	*plsql.BasePlSqlParserListener
	// contains filtered or unexported fields
}

func (*CTETableListener) EnterFactoring_element

func (l *CTETableListener) EnterFactoring_element(ctx *plsql.Factoring_elementContext)

type Completer

type Completer struct {
	// contains filtered or unexported fields
}

func NewStandardCompleter

func NewStandardCompleter(ctx context.Context, cCtx base.CompletionContext, statement string, caretLine int, caretOffset int) *Completer

func NewTrickyCompleter

func NewTrickyCompleter(ctx context.Context, cCtx base.CompletionContext, statement string, caretLine int, caretOffset int) *Completer

type CompletionMap

type CompletionMap map[string]base.Candidate

func (CompletionMap) Insert

func (m CompletionMap) Insert(entry base.Candidate)

type EraseContext

type EraseContext struct {
	// contains filtered or unexported fields
}

type ObjectFlags

type ObjectFlags int
const (
	ObjectFlagsShowSchemas ObjectFlags = 1 << iota
	ObjectFlagsShowTables
	ObjectFlagsShowColumns
	ObjectFlagsShowFirst
	ObjectFlagsShowSecond
)

type StatementType

type StatementType int
const (
	StatementTypeUnknown StatementType = iota
	StatementTypeUpdate
	StatementTypeInsert
	StatementTypeDelete
)

type StringsManipulator

type StringsManipulator struct {
	// contains filtered or unexported fields
}

func NewStringsManipulator

func NewStringsManipulator(tree antlr.Tree, stream antlr.TokenStream) *StringsManipulator

func (*StringsManipulator) Manipulate

func (s *StringsManipulator) Manipulate(actions ...base.StringsManipulatorAction) (string, error)

type StringsManipulatorActionAddColumn

type StringsManipulatorActionAddColumn struct {
	base.StringsManipulatorActionBase
	Table            string
	ColumnDefinition string
}

func NewAddColumnAction

func NewAddColumnAction(schemaName, tableName, columnDefinition string) *StringsManipulatorActionAddColumn

func (*StringsManipulatorActionAddColumn) GetSecondLevelNaming

func (*StringsManipulatorActionAddColumn) GetSecondLevelNaming() string

func (*StringsManipulatorActionAddColumn) GetTopLevelNaming

func (s *StringsManipulatorActionAddColumn) GetTopLevelNaming() string

type StringsManipulatorActionAddColumnOption

type StringsManipulatorActionAddColumnOption struct {
	StringsManipulatorActionColumnOptionBase
	Table           string
	Column          string
	NewOptionDefine string
}

func NewAddColumnOptionAction

func NewAddColumnOptionAction(schemaName, tableName string, columnName string, optionType base.ColumnOptionType, newOptionDefine string) *StringsManipulatorActionAddColumnOption

func (*StringsManipulatorActionAddColumnOption) GetSecondLevelNaming

func (s *StringsManipulatorActionAddColumnOption) GetSecondLevelNaming() string

func (*StringsManipulatorActionAddColumnOption) GetTopLevelNaming

func (s *StringsManipulatorActionAddColumnOption) GetTopLevelNaming() string

type StringsManipulatorActionAddIndex

type StringsManipulatorActionAddIndex struct {
	base.StringsManipulatorActionBase
	Table       string
	IndexDefine string
}

func NewAddIndexAction

func NewAddIndexAction(schemaName, tableName, indexDefine string) *StringsManipulatorActionAddIndex

func (*StringsManipulatorActionAddIndex) GetSecondLevelNaming

func (*StringsManipulatorActionAddIndex) GetSecondLevelNaming() string

func (*StringsManipulatorActionAddIndex) GetTopLevelNaming

func (s *StringsManipulatorActionAddIndex) GetTopLevelNaming() string

type StringsManipulatorActionAddTable

type StringsManipulatorActionAddTable struct {
	base.StringsManipulatorActionBase
	Table           string
	TableDefinition string
}

func NewAddTableAction

func NewAddTableAction(schemaName, tableName, tableDefinition string) *StringsManipulatorActionAddTable

func (*StringsManipulatorActionAddTable) GetSecondLevelNaming

func (*StringsManipulatorActionAddTable) GetSecondLevelNaming() string

func (*StringsManipulatorActionAddTable) GetTopLevelNaming

func (s *StringsManipulatorActionAddTable) GetTopLevelNaming() string

type StringsManipulatorActionAddTableConstraint

type StringsManipulatorActionAddTableConstraint struct {
	base.StringsManipulatorActionBase
	Table               string
	Type                base.TableConstraintType
	NewConstraintDefine string
}

func NewAddTableConstraintAction

func NewAddTableConstraintAction(schemaName, tableName string, constraintType base.TableConstraintType, newConstraintDefine string) *StringsManipulatorActionAddTableConstraint

func (*StringsManipulatorActionAddTableConstraint) GetSecondLevelNaming

func (*StringsManipulatorActionAddTableConstraint) GetSecondLevelNaming() string

func (*StringsManipulatorActionAddTableConstraint) GetTopLevelNaming

func (s *StringsManipulatorActionAddTableConstraint) GetTopLevelNaming() string

type StringsManipulatorActionColumnOptionBase

type StringsManipulatorActionColumnOptionBase struct {
	base.StringsManipulatorActionBase
	Type base.ColumnOptionType
}

func (*StringsManipulatorActionColumnOptionBase) GetOptionType

type StringsManipulatorActionDropColumn

type StringsManipulatorActionDropColumn struct {
	base.StringsManipulatorActionBase
	Table  string
	Column string
}

func NewDropColumnAction

func NewDropColumnAction(schemaName, tableName, columnName string) *StringsManipulatorActionDropColumn

func (*StringsManipulatorActionDropColumn) GetSecondLevelNaming

func (s *StringsManipulatorActionDropColumn) GetSecondLevelNaming() string

func (*StringsManipulatorActionDropColumn) GetTopLevelNaming

func (s *StringsManipulatorActionDropColumn) GetTopLevelNaming() string

type StringsManipulatorActionDropColumnOption

type StringsManipulatorActionDropColumnOption struct {
	StringsManipulatorActionColumnOptionBase
	Table  string
	Column string
}

func NewDropColumnOptionAction

func NewDropColumnOptionAction(schemaName, tableName string, columnName string, option base.ColumnOptionType) *StringsManipulatorActionDropColumnOption

func (*StringsManipulatorActionDropColumnOption) GetSecondLevelNaming

func (s *StringsManipulatorActionDropColumnOption) GetSecondLevelNaming() string

func (*StringsManipulatorActionDropColumnOption) GetTopLevelNaming

func (s *StringsManipulatorActionDropColumnOption) GetTopLevelNaming() string

type StringsManipulatorActionDropIndex

type StringsManipulatorActionDropIndex struct {
	base.StringsManipulatorActionBase
	Table string
	Index string
}

func NewDropIndexAction

func NewDropIndexAction(schemaName, tableName, indexName string) *StringsManipulatorActionDropIndex

func (*StringsManipulatorActionDropIndex) GetSecondLevelNaming

func (s *StringsManipulatorActionDropIndex) GetSecondLevelNaming() string

func (*StringsManipulatorActionDropIndex) GetTopLevelNaming

func (s *StringsManipulatorActionDropIndex) GetTopLevelNaming() string

type StringsManipulatorActionDropTable

type StringsManipulatorActionDropTable struct {
	base.StringsManipulatorActionBase
	Table string
}

func NewDropTableAction

func NewDropTableAction(schemaName, tableName string) *StringsManipulatorActionDropTable

func (*StringsManipulatorActionDropTable) GetSecondLevelNaming

func (*StringsManipulatorActionDropTable) GetSecondLevelNaming() string

func (*StringsManipulatorActionDropTable) GetTopLevelNaming

func (s *StringsManipulatorActionDropTable) GetTopLevelNaming() string

type StringsManipulatorActionDropTableConstraint

type StringsManipulatorActionDropTableConstraint struct {
	base.StringsManipulatorActionBase
	Table          string
	Constraint     base.TableConstraintType
	ConstraintName string
}

func NewDropTableConstraintAction

func NewDropTableConstraintAction(schemaName, tableName string, constraintName string) *StringsManipulatorActionDropTableConstraint

func (*StringsManipulatorActionDropTableConstraint) GetSecondLevelNaming

func (s *StringsManipulatorActionDropTableConstraint) GetSecondLevelNaming() string

func (*StringsManipulatorActionDropTableConstraint) GetTopLevelNaming

func (s *StringsManipulatorActionDropTableConstraint) GetTopLevelNaming() string

type StringsManipulatorActionModifyColumnOption

type StringsManipulatorActionModifyColumnOption struct {
	StringsManipulatorActionColumnOptionBase
	Table           string
	Column          string
	NewOptionDefine string
}

func NewModifyColumnOptionAction

func NewModifyColumnOptionAction(schemaName, tableName string, columnName string, oldOption base.ColumnOptionType, newOptionDefine string) *StringsManipulatorActionModifyColumnOption

func (*StringsManipulatorActionModifyColumnOption) GetSecondLevelNaming

func (s *StringsManipulatorActionModifyColumnOption) GetSecondLevelNaming() string

func (*StringsManipulatorActionModifyColumnOption) GetTopLevelNaming

func (s *StringsManipulatorActionModifyColumnOption) GetTopLevelNaming() string

type StringsManipulatorActionModifyColumnType

type StringsManipulatorActionModifyColumnType struct {
	base.StringsManipulatorActionBase
	Table  string
	Column string
	Type   string
}

func NewModifyColumnTypeAction

func NewModifyColumnTypeAction(schemaName, tableName, columnName, columnType string) *StringsManipulatorActionModifyColumnType

func (*StringsManipulatorActionModifyColumnType) GetSecondLevelNaming

func (s *StringsManipulatorActionModifyColumnType) GetSecondLevelNaming() string

func (*StringsManipulatorActionModifyColumnType) GetTopLevelNaming

func (s *StringsManipulatorActionModifyColumnType) GetTopLevelNaming() string

type StringsManipulatorActionModifyIndex

type StringsManipulatorActionModifyIndex struct {
	base.StringsManipulatorActionBase
	Table          string
	IndexName      string
	NewIndexDefine string
}

func NewModifyIndexAction

func NewModifyIndexAction(schemaName, tableName, indexName string, newIndexDefine string) *StringsManipulatorActionModifyIndex

func (*StringsManipulatorActionModifyIndex) GetSecondLevelNaming

func (s *StringsManipulatorActionModifyIndex) GetSecondLevelNaming() string

func (*StringsManipulatorActionModifyIndex) GetTopLevelNaming

func (s *StringsManipulatorActionModifyIndex) GetTopLevelNaming() string

type StringsManipulatorActionModifyTableConstraint

type StringsManipulatorActionModifyTableConstraint struct {
	base.StringsManipulatorActionBase
	Table               string
	OldConstraint       base.TableConstraintType
	OldConstraintName   string
	NewConstraintDefine string
}

func NewModifyTableConstraintAction

func NewModifyTableConstraintAction(schemaName, tableName string, oldConstraint base.TableConstraintType, oldConstraintName string, newConstraintDefine string) *StringsManipulatorActionModifyTableConstraint

func (*StringsManipulatorActionModifyTableConstraint) GetSecondLevelNaming

func (s *StringsManipulatorActionModifyTableConstraint) GetSecondLevelNaming() string

func (*StringsManipulatorActionModifyTableConstraint) GetTopLevelNaming

type TableRefListener

type TableRefListener struct {
	*plsql.BasePlSqlParserListener
	// contains filtered or unexported fields
}

func (*TableRefListener) ExitDml_table_expression_clause

func (l *TableRefListener) ExitDml_table_expression_clause(ctx *plsql.Dml_table_expression_clauseContext)

func (*TableRefListener) ExitTable_alias

func (l *TableRefListener) ExitTable_alias(ctx *plsql.Table_aliasContext)

type TableReference

type TableReference struct {
	Database      string
	HasSchema     bool
	Schema        string
	Table         string
	Alias         string
	StatementType StatementType
}

type Version

type Version struct {
	First  int
	Second int
}

func ParseVersion

func ParseVersion(banner string) (*Version, error)

func (*Version) GTE

func (v *Version) GTE(base *Version) bool

GTE returns true if the version is greater than or equal to the base version.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL