Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions sql/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,6 @@ func (a *Analyzer) PopDebugContext() {
func SelectAllBatches(string) bool { return true }

func DefaultRuleSelector(id RuleId) bool {
switch id {
// prepared statement rules are incompatible with default rules
case reresolveTablesId,
resolvePreparedInsertId:
return false
}
return true
}

Expand Down Expand Up @@ -441,13 +435,11 @@ func NewFinalizeSubquerySel(sel RuleSelector) RuleSelector {
switch id {
case
// skip recursive resolve rules
resolveSubqueryExprsId,
resolveSubqueriesId,
resolveUnionsId,
// skip redundant finalize rules
finalizeSubqueriesId,
hoistOutOfScopeFiltersId,
cacheSubqueryResultsId,
TrackProcessId,
assignExecIndexesId:
return false
Expand All @@ -461,7 +453,6 @@ func NewFinalizeUnionSel(sel RuleSelector) RuleSelector {
switch id {
case
// skip recursive resolve rules
resolveSubqueryExprsId,
resolveSubqueriesId,
resolveUnionsId,
parallelizeId:
Expand Down
4 changes: 2 additions & 2 deletions sql/analyzer/assign_update_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/dolthub/go-mysql-server/sql/transform"
)

// modifyUpdateExpressionsForJoin searches for a JOIN for UPDATE query and updates the child of the original update
// modifyUpdateExprsForJoin searches for a JOIN for UPDATE query and updates the child of the original update
// node to use a plan.UpdateJoin node as a child.
func modifyUpdateExpressionsForJoin(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Scope, sel RuleSelector, qFlags *sql.QueryFlags) (sql.Node, transform.TreeIdentity, error) {
func modifyUpdateExprsForJoin(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Scope, sel RuleSelector, qFlags *sql.QueryFlags) (sql.Node, transform.TreeIdentity, error) {
switch n := n.(type) {
case *plan.Update:
us, ok := n.Child.(*plan.UpdateSource)
Expand Down
4 changes: 2 additions & 2 deletions sql/analyzer/autocommit.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/dolthub/go-mysql-server/sql/transform"
)

// addAutocommitNode wraps each query with a TransactionCommittingNode.
func addAutocommitNode(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Scope, sel RuleSelector, qFlags *sql.QueryFlags) (sql.Node, transform.TreeIdentity, error) {
// addAutocommit wraps each query with a TransactionCommittingNode.
func addAutocommit(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Scope, sel RuleSelector, qFlags *sql.QueryFlags) (sql.Node, transform.TreeIdentity, error) {
// TODO: This is a bit of a hack. Need to figure out better relationship between new transaction node and warnings.
if FlagIsSet(qFlags, sql.QFlagShowWarnings) {
return n, transform.SameTree, nil
Expand Down
6 changes: 3 additions & 3 deletions sql/analyzer/node_batches.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func getBatchesForNode(n sql.Node, orig []*Batch) ([]*Batch, bool) {
Iterations: 1,
Rules: []Rule{
{
Id: applyFKsId,
Id: applyForeignKeysId,
Apply: applyForeignKeys,
},
{
Expand Down Expand Up @@ -71,7 +71,7 @@ func getBatchesForNode(n sql.Node, orig []*Batch) ([]*Batch, bool) {
Apply: validateReadOnlyTransaction,
},
{
Id: applyFKsId,
Id: applyForeignKeysId,
Apply: applyForeignKeys,
},
{
Expand Down Expand Up @@ -120,7 +120,7 @@ func getBatchesForNode(n sql.Node, orig []*Batch) ([]*Batch, bool) {
Apply: processTruncate,
},
{
Id: applyFKsId,
Id: applyForeignKeysId,
Apply: applyForeignKeys,
},
{
Expand Down
117 changes: 31 additions & 86 deletions sql/analyzer/rule_ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,82 +6,38 @@ type RuleId int

const (
// once before
applyDefaultSelectLimitId RuleId = iota // applyDefaultSelectLimit
validateOffsetAndLimitId // validateOffsetAndLimit
validateStarExpressionsId // validateStarExpressions
validateCreateTableId // validateCreateTable
validateAlterTableId // validateAlterTable
validateExprSemId // validateExprSem
resolveVariablesId // resolveVariables
resolveNamedWindowsId // resolveNamedWindows
resolveSetVariablesId // resolveSetVariables
resolveViewsId // resolveViews
liftCtesId // liftCtes
resolveCtesId // resolveCtes
liftRecursiveCtesId // liftRecursiveCtes
resolveDatabasesId // resolveDatabases
resolveTablesId // resolveTables
loadStoredProceduresId // loadStoredProcedures
validateDropTablesId // validateDropTables
pruneDropTablesId // pruneDropTables
setTargetSchemasId // setTargetSchemas
resolveCreateLikeId // resolveCreateLike
parseColumnDefaultsId // parseColumnDefaults
resolveDropConstraintId // resolveDropConstraint
validateDropConstraintId // validateDropConstraint
loadCheckConstraintsId // loadCheckConstraints
assignCatalogId // assignCatalog
resolveAnalyzeTablesId // resolveAnalyzeTables
resolveCreateSelectId // resolveCreateSelect
resolveSubqueriesId // resolveSubqueries
setViewTargetSchemaId // setViewTargetSchema
resolveUnionsId // resolveUnions
resolveDescribeQueryId // resolveDescribeQuery
checkUniqueTableNamesId // checkUniqueTableNames
resolveTableFunctionsId // resolveTableFunctions
resolveDeclarationsId // resolveDeclarations
resolveColumnDefaultsId // resolveColumnDefaults
ValidateColumnDefaultsId // validateColumnDefaults
validateCreateTriggerId // validateCreateTrigger
validateCreateProcedureId // validateCreateProcedure
resolveCreateProcedureId // resolveCreateProcedure
loadInfoSchemaId // loadInfoSchema
validateReadOnlyDatabaseId // validateReadOnlyDatabase
validateReadOnlyTransactionId // validateReadOnlyTransaction
validateDatabaseSetId // validateDatabaseSet
validatePrivilegesId // validatePrivileges
reresolveTablesId // reresolveTables
setInsertColumnsId // setInsertColumns
validateJoinComplexityId // validateJoinComplexity
applyBinlogReplicaControllerId // applyBinlogReplicaController
applyEventSchedulerId // applyEventScheduler
applyDefaultSelectLimitId RuleId = iota // applyDefaultSelectLimit
validateOffsetAndLimitId // validateOffsetAndLimit
validateStarExpressionsId // validateStarExpressions
validateCreateTableId // validateCreateTable
validateAlterTableId // validateAlterTable
validateExprSemId // validateExprSem
loadStoredProceduresId // loadStoredProcedures
validateDropTablesId // validateDropTables
resolveDropConstraintId // resolveDropConstraint
validateDropConstraintId // validateDropConstraint
resolveCreateSelectId // resolveCreateSelect
resolveSubqueriesId // resolveSubqueries
resolveUnionsId // resolveUnions
resolveDescribeQueryId // resolveDescribeQuery
ValidateColumnDefaultsId // validateColumnDefaults
validateCreateTriggerId // validateCreateTrigger
validateCreateProcedureId // validateCreateProcedure
validateReadOnlyDatabaseId // validateReadOnlyDatabase
validateReadOnlyTransactionId // validateReadOnlyTransaction
validateDatabaseSetId // validateDatabaseSet
validatePrivilegesId // validatePrivileges
applyEventSchedulerId // applyEventScheduler

// default
resolveUsingJoinsId // resolveUsingJoins
resolveOrderbyLiteralsId // resolveOrderbyLiterals
resolveFunctionsId // resolveFunctions
flattenTableAliasesId // flattenTableAliases
pushdownSortId // pushdownSort
pushdownGroupbyAliasesId // pushdownGroupbyAliases
pushdownSubqueryAliasFiltersId // pushdownSubqueryAliasFilters
qualifyColumnsId // qualifyColumns
resolveColumnsId // resolveColumns
validateCheckConstraintId // validateCheckConstraint
resolveBarewordSetVariablesId // resolveBarewordSetVariables
validateCheckConstraintId // validateCheckConstraints
replaceCountStarId // replaceCountStar
expandStarsId // expandStars
transposeRightJoinsId // transposeRightJoins
resolveHavingId // resolveHaving
mergeUnionSchemasId // mergeUnionSchemas
flattenAggregationExprsId // flattenAggregationExprs
reorderProjectionId // reorderProjection
resolveSubqueryExprsId // resolveSubqueryExprs
replaceCrossJoinsId // replaceCrossJoins
moveJoinCondsToFilterId // moveJoinCondsToFilter
moveFiltersToJoinCondId // moveFiltersToJoinCond
moveJoinCondsToFilterId // moveJoinConditionsToFilter
simplifyFiltersId // simplifyFilters
pushNotFiltersId // pushNotFilters
optimizeDistinctId // optimizeDistinct

// after default
hoistOutOfScopeFiltersId // hoistOutOfScopeFilters
Expand All @@ -90,38 +46,30 @@ const (
finalizeSubqueriesId // finalizeSubqueries
finalizeUnionsId // finalizeUnions
loadTriggersId // loadTriggers
loadEventsId // loadEvents
processTruncateId // processTruncate
resolveAlterColumnId // resolveAlterColumn
resolveGeneratorsId // resolveGenerators
removeUnnecessaryConvertsId // removeUnnecessaryConverts
stripTableNameInDefaultsId // stripTableNamesFromColumnDefaults
foldEmptyJoinsId // foldEmptyJoins
optimizeJoinsId // optimizeJoins
generateIndexScansId // generateIndexScans
matchAgainstId // matchAgainst
pushFiltersId // pushFilters
applyIndexesFromOuterScopeId // applyIndexesFromOuterScope
pruneTablesId // pruneTables
fixupAuxiliaryExprsId // fixupAuxiliaryExprs
assignExecIndexesId // assignExecIndexes
inlineSubqueryAliasRefsId // inlineSubqueryAliasRefs
eraseProjectionId // eraseProjection
flattenDistinctId //flattenDistinct
flattenDistinctId // flattenDistinct
replaceAggId // replaceAgg
replaceIdxSortId // replaceIdxSort
insertTopNId // insertTopN
insertTopNId // insertTopNNodes
replaceIdxOrderByDistanceId // replaceIdxOrderByDistance
applyHashInId // applyHashIn
resolveInsertRowsId // resolveInsertRows
resolvePreparedInsertId // resolvePreparedInsert
applyTriggersId // applyTriggers
applyProceduresId // applyProcedures
assignRoutinesId // assignRoutines
modifyUpdateExprsForJoinId // modifyUpdateExprsForJoin
applyRowUpdateAccumulatorsId // applyRowUpdateAccumulators
wrapWithRollbackId // rollback triggers
applyFKsId // applyFKs
applyUpdateAccumulatorsId // applyUpdateAccumulators
wrapWithRollbackId // wrapWithRollback
applyForeignKeysId // applyForeignKeys

// validate
validateResolvedId // validateResolved
Expand All @@ -130,19 +78,16 @@ const (
validateSchemaSourceId // validateSchemaSource
validateIndexCreationId // validateIndexCreation
ValidateOperandsId // validateOperands
validateCaseResultTypesId // validateCaseResultTypes
validateIntervalUsageId // validateIntervalUsage
validateExplodeUsageId // validateExplodeUsage
validateSubqueryColumnsId // validateSubqueryColumns
validateUnionSchemasMatchId // validateUnionSchemasMatch
validateAggregationsId // validateAggregations
validateDeleteFromId // validateDeleteFrom

// after all
cacheSubqueryResultsId // cacheSubqueryResults
cacheSubqueryAliasesInJoinsId // cacheSubqueryAliasesInJoins
backtickDefaulColumnValueNamesId // backtickDefaulColumnValueNames
AutocommitId // addAutocommitNode
backtickDefaulColumnValueNamesId // backtickDefaultColumnValueNames
AutocommitId // addAutocommit
TrackProcessId // trackProcess
parallelizeId // parallelize
clearWarningsId // clearWarnings
Expand Down
Loading