Documentation
¶
Overview ¶
Package advisor defines the interface for analyzing sql statements. The advisor could be syntax checker, index suggestion etc.
Index ¶
- Constants
- Variables
- func Check(ctx context.Context, dbType storepb.Engine, ruleType SQLReviewRuleType, ...) (adviceList []*storepb.Advice, err error)
- func DatabaseExists(ctx context.Context, checkCtx Context, database string) bool
- func GetBuiltinRules(engine storepb.Engine) []*storepb.SQLReviewRule
- func NewStatusBySQLReviewRuleLevel(level storepb.SQLReviewRuleLevel) (storepb.Advice_Status, error)
- func NormalizeStatement(statement string) string
- func Query(ctx context.Context, qCtx QueryContext, connection *sql.DB, ...) ([]any, error)
- func Register(dbType storepb.Engine, ruleType SQLReviewRuleType, f Advisor)
- func SQLReviewCheck(ctx context.Context, sm *sheet.Manager, statements string, ...) ([]*storepb.Advice, error)
- func UnmarshalNamingRulePayloadAsRegexp(payload string) (*regexp.Regexp, int, error)
- func UnmarshalNamingRulePayloadAsTemplate(ruleType SQLReviewRuleType, payload string) (string, []string, int, error)
- func UnmarshalRequiredColumnList(payload string) ([]string, error)
- type Advisor
- type CommentConventionRulePayload
- type Context
- type NamingCaseRulePayload
- type NamingRulePayload
- type NumberTypeRulePayload
- type QueryContext
- type RequiredColumnRulePayload
- type SQLReviewRuleType
- type StringArrayTypeRulePayload
- type StringTypeRulePayload
Constants ¶
const ( // SyntaxErrorTitle is the error title for syntax error. SyntaxErrorTitle string = "Syntax error" )
Variables ¶
var ( // TemplateNamingTokens is the mapping for rule type to template token. TemplateNamingTokens = map[SQLReviewRuleType]map[string]bool{ SchemaRuleIDXNaming: { TableNameTemplateToken: true, ColumnListTemplateToken: true, }, SchemaRulePKNaming: { TableNameTemplateToken: true, ColumnListTemplateToken: true, }, SchemaRuleUKNaming: { TableNameTemplateToken: true, ColumnListTemplateToken: true, }, SchemaRuleFKNaming: { ReferencingTableNameTemplateToken: true, ReferencingColumnNameTemplateToken: true, ReferencedTableNameTemplateToken: true, ReferencedColumnNameTemplateToken: true, }, } )
Functions ¶
func Check ¶
func Check(ctx context.Context, dbType storepb.Engine, ruleType SQLReviewRuleType, checkCtx Context) (adviceList []*storepb.Advice, err error)
Check runs the advisor and returns the advices.
func DatabaseExists ¶
func GetBuiltinRules ¶
func GetBuiltinRules(engine storepb.Engine) []*storepb.SQLReviewRule
func NewStatusBySQLReviewRuleLevel ¶
func NewStatusBySQLReviewRuleLevel(level storepb.SQLReviewRuleLevel) (storepb.Advice_Status, error)
NewStatusBySQLReviewRuleLevel returns status by SQLReviewRuleLevel.
func NormalizeStatement ¶
NormalizeStatement limit the max length of the statements.
func Query ¶
func Query(ctx context.Context, qCtx QueryContext, connection *sql.DB, engine storepb.Engine, statement string) ([]any, error)
Query runs the EXPLAIN or SELECT statements for advisors.
func Register ¶
func Register(dbType storepb.Engine, ruleType SQLReviewRuleType, f Advisor)
Register makes a advisor available by the provided id. If Register is called twice with the same name or if advisor is nil, it panics.
func SQLReviewCheck ¶
func SQLReviewCheck( ctx context.Context, sm *sheet.Manager, statements string, ruleList []*storepb.SQLReviewRule, checkContext Context, ) ([]*storepb.Advice, error)
SQLReviewCheck checks the statements with sql review rules.
func UnmarshalNamingRulePayloadAsRegexp ¶
UnmarshalNamingRulePayloadAsRegexp will unmarshal payload to NamingRulePayload and compile it as regular expression.
func UnmarshalNamingRulePayloadAsTemplate ¶
func UnmarshalNamingRulePayloadAsTemplate(ruleType SQLReviewRuleType, payload string) (string, []string, int, error)
UnmarshalNamingRulePayloadAsTemplate will unmarshal payload to NamingRulePayload and extract all the template keys. For example, "hard_code_{{table}}_{{column}}_end" will return "hard_code_{{table}}_{{column}}_end", ["{{table}}", "{{column}}"].
func UnmarshalRequiredColumnList ¶
UnmarshalRequiredColumnList will unmarshal payload and parse the required column list.
Types ¶
type CommentConventionRulePayload ¶
type CommentConventionRulePayload struct {
Required bool `json:"required"`
MaxLength int `json:"maxLength"`
}
CommentConventionRulePayload is the payload for comment convention rule.
func UnmarshalCommentConventionRulePayload ¶
func UnmarshalCommentConventionRulePayload(payload string) (*CommentConventionRulePayload, error)
UnmarshalCommentConventionRulePayload will unmarshal payload to CommentConventionRulePayload.
type Context ¶
type Context struct {
DBSchema *storepb.DatabaseSchemaMetadata
EnableSDL bool
EnablePriorBackup bool
EnableGhost bool
ListDatabaseNamesFunc base.ListDatabaseNamesFunc
InstanceID string
IsObjectCaseSensitive bool
// SQL review rule special fields.
AST []base.AST
Rule *storepb.SQLReviewRule
OriginalMetadata *model.DatabaseMetadata
FinalMetadata *model.DatabaseMetadata
Driver *sql.DB
// CurrentDatabase is the current database.
CurrentDatabase string
// Statement is the original statement of AST, it is used for some PostgreSQL
// advisors which need to check the token stream.
Statements string
// UsePostgresDatabaseOwner is true if the advisor should use the database owner as default role.
UsePostgresDatabaseOwner bool
// SQL review level fields.
Charset string
Collation string
DBType storepb.Engine
// Used for test only.
NoAppendBuiltin bool
}
Context is the context for advisor.
type NamingCaseRulePayload ¶
type NamingCaseRulePayload struct {
// Upper is true means the case should be upper case, otherwise lower case.
Upper bool `json:"upper"`
}
NamingCaseRulePayload is the payload for naming case rule.
func UnmarshalNamingCaseRulePayload ¶
func UnmarshalNamingCaseRulePayload(payload string) (*NamingCaseRulePayload, error)
UnmarshalNamingCaseRulePayload will unmarshal payload to NamingCaseRulePayload.
type NamingRulePayload ¶
NamingRulePayload is the payload for naming rule.
type NumberTypeRulePayload ¶
type NumberTypeRulePayload struct {
Number int `json:"number"`
}
NumberTypeRulePayload is the number type payload.
func UnmarshalNumberTypeRulePayload ¶
func UnmarshalNumberTypeRulePayload(payload string) (*NumberTypeRulePayload, error)
UnmarshalNumberTypeRulePayload will unmarshal payload to NumberTypeRulePayload.
type QueryContext ¶
type RequiredColumnRulePayload ¶
type RequiredColumnRulePayload struct {
ColumnList []string `json:"columnList"`
}
RequiredColumnRulePayload is the payload for required column rule.
type SQLReviewRuleType ¶
type SQLReviewRuleType string
SQLReviewRuleType is the type of schema rule.
const ( // SchemaRuleMySQLEngine require InnoDB as the storage engine. SchemaRuleMySQLEngine SQLReviewRuleType = "engine.mysql.use-innodb" // SchemaRuleFullyQualifiedObjectName enforces using fully qualified object name. SchemaRuleFullyQualifiedObjectName SQLReviewRuleType = "naming.fully-qualified" // SchemaRuleTableNaming enforce the table name format. SchemaRuleTableNaming SQLReviewRuleType = "naming.table" // SchemaRuleColumnNaming enforce the column name format. SchemaRuleColumnNaming SQLReviewRuleType = "naming.column" // SchemaRulePKNaming enforce the primary key name format. SchemaRulePKNaming SQLReviewRuleType = "naming.index.pk" // SchemaRuleUKNaming enforce the unique key name format. SchemaRuleUKNaming SQLReviewRuleType = "naming.index.uk" // SchemaRuleFKNaming enforce the foreign key name format. SchemaRuleFKNaming SQLReviewRuleType = "naming.index.fk" // SchemaRuleIDXNaming enforce the index name format. SchemaRuleIDXNaming SQLReviewRuleType = "naming.index.idx" // SchemaRuleAutoIncrementColumnNaming enforce the auto_increment column name format. SchemaRuleAutoIncrementColumnNaming SQLReviewRuleType = "naming.column.auto-increment" // SchemaRuleTableNameNoKeyword enforce the table name not to use keyword. SchemaRuleTableNameNoKeyword SQLReviewRuleType = "naming.table.no-keyword" // SchemaRuleIdentifierNoKeyword enforce the identifier not to use keyword. SchemaRuleIdentifierNoKeyword SQLReviewRuleType = "naming.identifier.no-keyword" // SchemaRuleIdentifierCase enforce the identifier case. SchemaRuleIdentifierCase SQLReviewRuleType = "naming.identifier.case" // SchemaRuleStatementNoSelectAll disallow 'SELECT *'. SchemaRuleStatementNoSelectAll SQLReviewRuleType = "statement.select.no-select-all" // SchemaRuleStatementRequireWhereForSelect require 'WHERE' clause for SELECT statements. SchemaRuleStatementRequireWhereForSelect SQLReviewRuleType = "statement.where.require.select" // SchemaRuleStatementRequireWhereForUpdateDelete require 'WHERE' clause for UPDATE and DELETE statements. SchemaRuleStatementRequireWhereForUpdateDelete SQLReviewRuleType = "statement.where.require.update-delete" // SchemaRuleStatementNoLeadingWildcardLike disallow leading '%' in LIKE, e.g. LIKE foo = '%x' is not allowed. SchemaRuleStatementNoLeadingWildcardLike SQLReviewRuleType = "statement.where.no-leading-wildcard-like" // SchemaRuleStatementDisallowOnDelCascade disallows ON DELETE CASCADE clauses. SchemaRuleStatementDisallowOnDelCascade SQLReviewRuleType = "statement.disallow-on-del-cascade" // SchemaRuleStatementDisallowRemoveTblCascade disallows CASCADE when removing a table. SchemaRuleStatementDisallowRemoveTblCascade SQLReviewRuleType = "statement.disallow-rm-tbl-cascade" // SchemaRuleStatementDisallowCommit disallow using commit in the issue. SchemaRuleStatementDisallowCommit SQLReviewRuleType = "statement.disallow-commit" // SchemaRuleStatementDisallowLimit disallow the LIMIT clause in INSERT, DELETE and UPDATE statements. SchemaRuleStatementDisallowLimit SQLReviewRuleType = "statement.disallow-limit" // SchemaRuleStatementDisallowOrderBy disallow the ORDER BY clause in DELETE and UPDATE statements. SchemaRuleStatementDisallowOrderBy SQLReviewRuleType = "statement.disallow-order-by" // SchemaRuleStatementMergeAlterTable disallow redundant ALTER TABLE statements. SchemaRuleStatementMergeAlterTable SQLReviewRuleType = "statement.merge-alter-table" // SchemaRuleStatementInsertRowLimit enforce the insert row limit. SchemaRuleStatementInsertRowLimit SQLReviewRuleType = "statement.insert.row-limit" // SchemaRuleStatementInsertMustSpecifyColumn enforce the insert column specified. SchemaRuleStatementInsertMustSpecifyColumn SQLReviewRuleType = "statement.insert.must-specify-column" // SchemaRuleStatementInsertDisallowOrderByRand disallow the order by rand in the INSERT statement. SchemaRuleStatementInsertDisallowOrderByRand SQLReviewRuleType = "statement.insert.disallow-order-by-rand" // SchemaRuleStatementAffectedRowLimit enforce the UPDATE/DELETE affected row limit. SchemaRuleStatementAffectedRowLimit SQLReviewRuleType = "statement.affected-row-limit" // SchemaRuleStatementDMLDryRun dry run the dml. SchemaRuleStatementDMLDryRun SQLReviewRuleType = "statement.dml-dry-run" // SchemaRuleStatementDisallowAddColumnWithDefault disallow to add column with DEFAULT. SchemaRuleStatementDisallowAddColumnWithDefault SQLReviewRuleType = "statement.disallow-add-column-with-default" // SchemaRuleStatementAddCheckNotValid require add check constraints not valid. SchemaRuleStatementAddCheckNotValid SQLReviewRuleType = "statement.add-check-not-valid" // SchemaRuleStatementAddFKNotValid require add foreign key not valid. SchemaRuleStatementAddFKNotValid SQLReviewRuleType = "statement.add-foreign-key-not-valid" // SchemaRuleStatementDisallowAddNotNull disallow to add NOT NULL. SchemaRuleStatementDisallowAddNotNull SQLReviewRuleType = "statement.disallow-add-not-null" // SchemaRuleStatementSelectFullTableScan disallow full table scan. SchemaRuleStatementSelectFullTableScan SQLReviewRuleType = "statement.select-full-table-scan" // SchemaRuleStatementCreateSpecifySchema disallow to create table without specifying schema. SchemaRuleStatementCreateSpecifySchema SQLReviewRuleType = "statement.create-specify-schema" // SchemaRuleStatementCheckSetRoleVariable require add a check for SET ROLE variable. SchemaRuleStatementCheckSetRoleVariable SQLReviewRuleType = "statement.check-set-role-variable" // SchemaRuleStatementDisallowUsingFilesort disallow using filesort in execution plan. SchemaRuleStatementDisallowUsingFilesort SQLReviewRuleType = "statement.disallow-using-filesort" // SchemaRuleStatementDisallowUsingTemporary disallow using temporary in execution plan. SchemaRuleStatementDisallowUsingTemporary SQLReviewRuleType = "statement.disallow-using-temporary" // SchemaRuleStatementWhereNoEqualNull check the WHERE clause no equal null. SchemaRuleStatementWhereNoEqualNull SQLReviewRuleType = "statement.where.no-equal-null" // SchemaRuleStatementWhereDisallowFunctionsAndCalculations disallow using function in WHERE clause. SchemaRuleStatementWhereDisallowFunctionsAndCalculations SQLReviewRuleType = "statement.where.disallow-functions-and-calculations" // SchemaRuleStatementQueryMinumumPlanLevel enforce the minimum plan level. SchemaRuleStatementQueryMinumumPlanLevel SQLReviewRuleType = "statement.query.minimum-plan-level" // SchemaRuleStatementWhereMaximumLogicalOperatorCount enforce the maximum logical operator count in WHERE clause. SchemaRuleStatementWhereMaximumLogicalOperatorCount SQLReviewRuleType = "statement.where.maximum-logical-operator-count" // SchemaRuleStatementMaximumLimitValue enforce the maximum limit value. SchemaRuleStatementMaximumLimitValue SQLReviewRuleType = "statement.maximum-limit-value" // SchemaRuleStatementMaximumJoinTableCount enforce the maximum join table count in the statement. SchemaRuleStatementMaximumJoinTableCount SQLReviewRuleType = "statement.maximum-join-table-count" // SchemaRuleStatementMaximumStatementsInTransaction enforce the maximum statements in transaction. SchemaRuleStatementMaximumStatementsInTransaction SQLReviewRuleType = "statement.maximum-statements-in-transaction" // SchemaRuleStatementJoinStrictColumnAttrs enforce the join strict column attributes. SchemaRuleStatementJoinStrictColumnAttrs SQLReviewRuleType = "statement.join-strict-column-attrs" // SchemaRuleStatementPriorBackupCheck checks for prior backup. SchemaRuleStatementPriorBackupCheck SQLReviewRuleType = "statement.prior-backup-check" // SchemaRuleStatementNonTransactional checks for non-transactional statements. SchemaRuleStatementNonTransactional SQLReviewRuleType = "statement.non-transactional" // SchemaRuleStatementAddColumnWithoutPosition check no position in ADD COLUMN clause. SchemaRuleStatementAddColumnWithoutPosition SQLReviewRuleType = "statement.add-column-without-position" // SchemaRuleStatementDisallowOfflineDDL disallow offline ddl. SchemaRuleStatementDisallowOfflineDDL SQLReviewRuleType = "statement.disallow-offline-ddl" // SchemaRuleStatementDisallowCrossDBQueries disallow cross database queries. SchemaRuleStatementDisallowCrossDBQueries SQLReviewRuleType = "statement.disallow-cross-db-queries" // SchemaRuleStatementMaxExecutionTime enforce the maximum execution time. SchemaRuleStatementMaxExecutionTime SQLReviewRuleType = "statement.max-execution-time" // SchemaRuleStatementRequireAlgorithmOption require set ALGORITHM option in ALTER TABLE statement. SchemaRuleStatementRequireAlgorithmOption SQLReviewRuleType = "statement.require-algorithm-option" // SchemaRuleStatementRequireLockOption require set LOCK option in ALTER TABLE statement. SchemaRuleStatementRequireLockOption SQLReviewRuleType = "statement.require-lock-option" // SchemaRuleStatementObjectOwnerCheck checks the object owner for the statement. SchemaRuleStatementObjectOwnerCheck SQLReviewRuleType = "statement.object-owner-check" // SchemaRuleTableRequirePK require the table to have a primary key. SchemaRuleTableRequirePK SQLReviewRuleType = "table.require-pk" // SchemaRuleTableNoFK require the table disallow the foreign key. SchemaRuleTableNoFK SQLReviewRuleType = "table.no-foreign-key" // SchemaRuleTableDropNamingConvention require only the table following the naming convention can be deleted. SchemaRuleTableDropNamingConvention SQLReviewRuleType = "table.drop-naming-convention" // SchemaRuleTableCommentConvention enforce the table comment convention. SchemaRuleTableCommentConvention SQLReviewRuleType = "table.comment" // SchemaRuleTableDisallowPartition disallow the table partition. SchemaRuleTableDisallowPartition SQLReviewRuleType = "table.disallow-partition" // SchemaRuleTableDisallowTrigger disallow the table trigger. SchemaRuleTableDisallowTrigger SQLReviewRuleType = "table.disallow-trigger" // SchemaRuleTableNoDuplicateIndex require the table no duplicate index. SchemaRuleTableNoDuplicateIndex SQLReviewRuleType = "table.no-duplicate-index" // SchemaRuleTableTextFieldsTotalLength enforce the total length of text fields. SchemaRuleTableTextFieldsTotalLength SQLReviewRuleType = "table.text-fields-total-length" // SchemaRuleTableDisallowSetCharset disallow set table charset. SchemaRuleTableDisallowSetCharset SQLReviewRuleType = "table.disallow-set-charset" // SchemaRuleTableDisallowDDL disallow executing DDL for specific tables. SchemaRuleTableDisallowDDL SQLReviewRuleType = "table.disallow-ddl" // SchemaRuleTableDisallowDML disallow executing DML on specific tables. SchemaRuleTableDisallowDML SQLReviewRuleType = "table.disallow-dml" // SchemaRuleTableLimitSize restrict access to tables based on size. SchemaRuleTableLimitSize SQLReviewRuleType = "table.limit-size" // SchemaRuleTableRequireCharset enforce the table charset. SchemaRuleTableRequireCharset SQLReviewRuleType = "table.require-charset" // SchemaRuleTableRequireCollation enforce the table collation. SchemaRuleTableRequireCollation SQLReviewRuleType = "table.require-collation" // SchemaRuleRequiredColumn enforce the required columns in each table. SchemaRuleRequiredColumn SQLReviewRuleType = "column.required" // SchemaRuleColumnNotNull enforce the columns cannot have NULL value. SchemaRuleColumnNotNull SQLReviewRuleType = "column.no-null" // SchemaRuleColumnDisallowChangeType disallow change column type. SchemaRuleColumnDisallowChangeType SQLReviewRuleType = "column.disallow-change-type" // SchemaRuleColumnSetDefaultForNotNull require the not null column to set default value. SchemaRuleColumnSetDefaultForNotNull SQLReviewRuleType = "column.set-default-for-not-null" // SchemaRuleColumnDisallowChange disallow CHANGE COLUMN statement. SchemaRuleColumnDisallowChange SQLReviewRuleType = "column.disallow-change" // SchemaRuleColumnDisallowChangingOrder disallow changing column order. SchemaRuleColumnDisallowChangingOrder SQLReviewRuleType = "column.disallow-changing-order" // SchemaRuleColumnDisallowDrop disallow drop column. SchemaRuleColumnDisallowDrop SQLReviewRuleType = "column.disallow-drop" // SchemaRuleColumnDisallowDropInIndex disallow drop index column. SchemaRuleColumnDisallowDropInIndex SQLReviewRuleType = "column.disallow-drop-in-index" // SchemaRuleColumnCommentConvention enforce the column comment convention. SchemaRuleColumnCommentConvention SQLReviewRuleType = "column.comment" // SchemaRuleColumnAutoIncrementMustInteger require the auto-increment column to be integer. SchemaRuleColumnAutoIncrementMustInteger SQLReviewRuleType = "column.auto-increment-must-integer" // SchemaRuleColumnTypeDisallowList enforce the column type disallow list. SchemaRuleColumnTypeDisallowList SQLReviewRuleType = "column.type-disallow-list" // SchemaRuleColumnDisallowSetCharset disallow set column charset. SchemaRuleColumnDisallowSetCharset SQLReviewRuleType = "column.disallow-set-charset" // SchemaRuleColumnMaximumCharacterLength enforce the maximum character length. SchemaRuleColumnMaximumCharacterLength SQLReviewRuleType = "column.maximum-character-length" // SchemaRuleColumnMaximumVarcharLength enforce the maximum varchar length. SchemaRuleColumnMaximumVarcharLength SQLReviewRuleType = "column.maximum-varchar-length" // SchemaRuleColumnAutoIncrementInitialValue enforce the initial auto-increment value. SchemaRuleColumnAutoIncrementInitialValue SQLReviewRuleType = "column.auto-increment-initial-value" // SchemaRuleColumnAutoIncrementMustUnsigned enforce the auto-increment column to be unsigned. SchemaRuleColumnAutoIncrementMustUnsigned SQLReviewRuleType = "column.auto-increment-must-unsigned" // SchemaRuleCurrentTimeColumnCountLimit enforce the current column count limit. SchemaRuleCurrentTimeColumnCountLimit SQLReviewRuleType = "column.current-time-count-limit" // SchemaRuleColumnRequireDefault enforce the column default. SchemaRuleColumnRequireDefault SQLReviewRuleType = "column.require-default" // SchemaRuleColumnDefaultDisallowVolatile enforce the column default disallow volatile. SchemaRuleColumnDefaultDisallowVolatile SQLReviewRuleType = "column.default-disallow-volatile" // SchemaRuleAddNotNullColumnRequireDefault enforce the adding not null column requires default. SchemaRuleAddNotNullColumnRequireDefault SQLReviewRuleType = "column.add-not-null-require-default" // SchemaRuleColumnRequireCharset enforce the column require charset. SchemaRuleColumnRequireCharset SQLReviewRuleType = "column.require-charset" // SchemaRuleColumnRequireCollation enforce the column require collation. SchemaRuleColumnRequireCollation SQLReviewRuleType = "column.require-collation" // SchemaRuleSchemaBackwardCompatibility enforce the MySQL and TiDB support check whether the schema change is backward compatible. SchemaRuleSchemaBackwardCompatibility SQLReviewRuleType = "schema.backward-compatibility" // SchemaRuleDropEmptyDatabase enforce the MySQL and TiDB support check if the database is empty before users drop it. SchemaRuleDropEmptyDatabase SQLReviewRuleType = "database.drop-empty-database" // SchemaRuleIndexNoDuplicateColumn require the index no duplicate column. SchemaRuleIndexNoDuplicateColumn SQLReviewRuleType = "index.no-duplicate-column" // SchemaRuleIndexKeyNumberLimit enforce the index key number limit. SchemaRuleIndexKeyNumberLimit SQLReviewRuleType = "index.key-number-limit" // SchemaRuleIndexPKTypeLimit enforce the type restriction of columns in primary key. SchemaRuleIndexPKTypeLimit SQLReviewRuleType = "index.pk-type-limit" // SchemaRuleIndexTypeNoBlob enforce the type restriction of columns in index. SchemaRuleIndexTypeNoBlob SQLReviewRuleType = "index.type-no-blob" // SchemaRuleIndexTotalNumberLimit enforce the index total number limit. SchemaRuleIndexTotalNumberLimit SQLReviewRuleType = "index.total-number-limit" // SchemaRuleIndexPrimaryKeyTypeAllowlist enforce the primary key type allowlist. SchemaRuleIndexPrimaryKeyTypeAllowlist SQLReviewRuleType = "index.primary-key-type-allowlist" // SchemaRuleCreateIndexConcurrently require creating indexes concurrently. SchemaRuleCreateIndexConcurrently SQLReviewRuleType = "index.create-concurrently" // SchemaRuleIndexTypeAllowList enforce the index type allowlist. SchemaRuleIndexTypeAllowList SQLReviewRuleType = "index.type-allow-list" // SchemaRuleIndexNotRedundant prohibits createing redundant indices. SchemaRuleIndexNotRedundant SQLReviewRuleType = "index.not-redundant" // SchemaRuleCharsetAllowlist enforce the charset allowlist. SchemaRuleCharsetAllowlist SQLReviewRuleType = "system.charset.allowlist" // SchemaRuleCollationAllowlist enforce the collation allowlist. SchemaRuleCollationAllowlist SQLReviewRuleType = "system.collation.allowlist" // SchemaRuleCommentLength limit comment length. SchemaRuleCommentLength SQLReviewRuleType = "system.comment.length" // SchemaRuleProcedureDisallowCreate disallow create procedure. SchemaRuleProcedureDisallowCreate SQLReviewRuleType = "system.procedure.disallow-create" // SchemaRuleEventDisallowCreate disallow create event. SchemaRuleEventDisallowCreate SQLReviewRuleType = "system.event.disallow-create" // SchemaRuleViewDisallowCreate disallow create view. SchemaRuleViewDisallowCreate SQLReviewRuleType = "system.view.disallow-create" // SchemaRuleFunctionDisallowCreate disallow create function. SchemaRuleFunctionDisallowCreate SQLReviewRuleType = "system.function.disallow-create" // SchemaRuleFunctionDisallowList enforce the disallowed function list. SchemaRuleFunctionDisallowList SQLReviewRuleType = "system.function.disallowed-list" // SchemaRuleOnlineMigration advises using online migration to migrate large tables. SchemaRuleOnlineMigration SQLReviewRuleType = "advice.online-migration" // TableNameTemplateToken is the token for table name. TableNameTemplateToken = "{{table}}" // ColumnListTemplateToken is the token for column name list. ColumnListTemplateToken = "{{column_list}}" // ReferencingTableNameTemplateToken is the token for referencing table name. ReferencingTableNameTemplateToken = "{{referencing_table}}" // ReferencingColumnNameTemplateToken is the token for referencing column name. ReferencingColumnNameTemplateToken = "{{referencing_column}}" // ReferencedTableNameTemplateToken is the token for referenced table name. ReferencedTableNameTemplateToken = "{{referenced_table}}" // ReferencedColumnNameTemplateToken is the token for referenced column name. ReferencedColumnNameTemplateToken = "{{referenced_column}}" )
const (
BuiltinRulePriorBackupCheck SQLReviewRuleType = "builtin.prior-backup-check"
)
type StringArrayTypeRulePayload ¶
type StringArrayTypeRulePayload struct {
List []string `json:"list"`
}
StringArrayTypeRulePayload is the payload for rules with string array value.
func UnmarshalStringArrayTypeRulePayload ¶
func UnmarshalStringArrayTypeRulePayload(payload string) (*StringArrayTypeRulePayload, error)
UnmarshalStringArrayTypeRulePayload will unmarshal payload to StringArrayTypeRulePayload.
type StringTypeRulePayload ¶
type StringTypeRulePayload struct {
String string `json:"string"`
}
StringTypeRulePayload is the string type payload.
func UnmarshalStringTypeRulePayload ¶
func UnmarshalStringTypeRulePayload(payload string) (*StringTypeRulePayload, error)
UnmarshalStringTypeRulePayload will unmarshal payload to StringTypeRulePayload.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mssql is the advisor for MSSQL database.
|
Package mssql is the advisor for MSSQL database. |
|
Package mysql implements the SQL advisor rules for MySQL.
|
Package mysql implements the SQL advisor rules for MySQL. |
|
Package oracle is the advisor for oracle database.
|
Package oracle is the advisor for oracle database. |
|
Package snowflake is the advisor for snowflake database.
|
Package snowflake is the advisor for snowflake database. |
|
package tidb implements the SQL advisor rules for MySQL.
|
package tidb implements the SQL advisor rules for MySQL. |