-
-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix underspecified insert tests #961
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f5e4ca1
fix underspecified insert tests
max-hoffman edf0fcb
Merge branch 'main' into max/prep-stmt-bugs
max-hoffman 3057e76
merge main
max-hoffman 0ebcc56
zach's comments
max-hoffman 1f935f3
Merge branch 'main' into max/prep-stmt-bugs
max-hoffman 770de83
one more comment
max-hoffman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,30 @@ func resolveInsertRows(ctx *sql.Context, a *Analyzer, n sql.Node, scope *Scope, | |
}) | ||
} | ||
|
||
// resolvePreparedInsert applies post-optimization | ||
// rules to Insert.Source for prepared statements. | ||
func resolvePreparedInsert(ctx *sql.Context, a *Analyzer, n sql.Node, scope *Scope, sel RuleSelector) (sql.Node, transform.TreeIdentity, error) { | ||
return transform.Node(n, func(n sql.Node) (sql.Node, transform.TreeIdentity, error) { | ||
ins, ok := n.(*plan.InsertInto) | ||
if !ok { | ||
return n, transform.SameTree, nil | ||
} | ||
|
||
// TriggerExecutor has already been analyzed | ||
if _, ok := ins.Source.(*plan.TriggerExecutor); ok { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we don't do this if there's a pre-insert trigger? Why? Leave a comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'll copy the comment from above |
||
return n, transform.SameTree, nil | ||
} | ||
|
||
source, _, err := a.analyzeWithSelector(ctx, ins.Source, scope, SelectAllBatches, postPrepareInsertSourceRuleSelector) | ||
if err != nil { | ||
return nil, transform.SameTree, err | ||
} | ||
|
||
source = StripPassthroughNodes(source) | ||
return ins.WithSource(source), transform.NewTree, nil | ||
}) | ||
} | ||
|
||
// Ensures that the number of elements in each Value tuple is empty | ||
func existsNonZeroValueCount(values sql.Node) bool { | ||
switch node := values.(type) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
package analyzer | ||
|
||
//go:generate stringer -type=RuleId -linecomment | ||
|
||
type RuleId int | ||
|
||
const ( | ||
// once before | ||
validateOffsetAndLimitId RuleId = iota //validateOffsetAndLimit | ||
validateCreateTableId // validateCreateTable | ||
validateExprSemId // validateExprSem | ||
resolveVariablesId // resolveVariables | ||
resolveNamedWindowsId // resolveNamedWindows | ||
resolveSetVariablesId // resolveSetVariables | ||
resolveViewsId // resolveViews | ||
liftCtesId // liftCtes | ||
resolveCtesId // resolveCtes | ||
liftRecursiveCtesId // liftRecursiveCtes | ||
resolveDatabasesId // resolveDatabases | ||
resolveTablesId // resolveTables | ||
loadStoredProceduresId // loadStoredProcedures | ||
validateDropTablesId // validateDropTables | ||
setTargetSchemasId // setTargetSchemas | ||
resolveCreateLikeId // resolveCreateLike | ||
parseColumnDefaultsId // parseColumnDefaults | ||
resolveDropConstraintId // resolveDropConstraint | ||
validateDropConstraintId // validateDropConstraint | ||
loadCheckConstraintsId // loadCheckConstraints | ||
resolveCreateSelectId // resolveCreateSelect | ||
resolveSubqueriesId // resolveSubqueries | ||
resolveUnionsId // resolveUnions | ||
resolveDescribeQueryId // resolveDescribeQuery | ||
checkUniqueTableNamesId // checkUniqueTableNames | ||
resolveTableFunctionsId // resolveTableFunctions | ||
resolveDeclarationsId // resolveDeclarations | ||
validateCreateTriggerId // validateCreateTrigger | ||
validateCreateProcedureId // validateCreateProcedure | ||
loadInfoSchemaId // loadInfoSchema | ||
validateReadOnlyDatabaseId // validateReadOnlyDatabase | ||
validateReadOnlyTransactionId // validateReadOnlyTransaction | ||
validateDatabaseSetId // validateDatabaseSet | ||
validatePriviledgesId // validatePriviledges | ||
stripDecorationsId // stripDecorations | ||
unresolveTablesId // unresolveTables | ||
validateJoinComplexityId // validateJoinComplexity | ||
|
||
// default | ||
resolveNaturalJoinsId // resolveNaturalJoins | ||
resolveOrderbyLiteralsId // resolveOrderbyLiterals | ||
resolveFunctionsId // resolveFunctions | ||
flattenTableAliasesId // flattenTableAliases | ||
pushdownSortId // pushdownSort | ||
pushdownGroupbyAliasesId // pushdownGroupbyAliases | ||
pushdownSubqueryAliasFiltersId // pushdownSubqueryAliasFilters | ||
qualifyColumnsId // qualifyColumns | ||
resolveColumnsId // resolveColumns | ||
resolveColumnDefaultsId // resolveColumnDefaults | ||
validateCheckConstraintId // validateCheckConstraint | ||
resolveBarewordSetVariablesId // resolveBarewordSetVariables | ||
expandStarsId // expandStars | ||
resolveHavingId // resolveHaving | ||
mergeUnionSchemasId // mergeUnionSchemas | ||
flattenAggregationExprsId // flattenAggregationExprs | ||
reorderProjectionId // reorderProjection | ||
resolveSubqueryExprsId // resolveSubqueryExprs | ||
replaceCrossJoinsId // replaceCrossJoins | ||
moveJoinCondsToFilterId // moveJoinCondsToFilter | ||
evalFilterId // evalFilter | ||
optimizeDistinctId // optimizeDistinct | ||
|
||
// after default | ||
finalizeSubqueriesId // finalizeSubqueries | ||
finalizeUnionsId // finalizeUnions | ||
loadTriggersId // loadTriggers | ||
processTruncateId // processTruncate | ||
validateAlterColumnId // validateAlterColumn | ||
resolveGeneratorsId // resolveGenerators | ||
removeUnnecessaryConvertsId // removeUnnecessaryConverts | ||
assignCatalogId // assignCatalog | ||
pruneColumnsId // pruneColumns | ||
optimizeJoinsId // optimizeJoins | ||
pushdownFiltersId // pushdownFilters | ||
subqueryIndexesId // subqueryIndexes | ||
inSubqueryIndexesId // inSubqueryIndexes | ||
pushdownProjectionsId // pushdownProjections | ||
setJoinScopeLenId // setJoinScopeLen | ||
eraseProjectionId // eraseProjection | ||
insertTopNId // insertTopN | ||
cacheSubqueryResultsId // cacheSubqueryResults | ||
cacheSubqueryAliasesInJoinsId // cacheSubqueryAliasesInJoins | ||
applyHashLookupsId // applyHashLookups | ||
applyHashInId // applyHashIn | ||
resolveInsertRowsId // resolveInsertRows | ||
resolvePreparedInsertId // resolvePreparedInsert | ||
applyTriggersId // applyTriggers | ||
applyProceduresId // applyProcedures | ||
assignRoutinesId // assignRoutines | ||
modifyUpdateExprsForJoinId // modifyUpdateExprsForJoin | ||
applyRowUpdateAccumulatorsId // applyRowUpdateAccumulators | ||
applyFKsId // applyFKs | ||
|
||
// validate | ||
validateResolvedId // validateResolved | ||
validateOrderById // validateOrderBy | ||
validateGroupById // validateGroupBy | ||
validateSchemaSourceId // validateSchemaSource | ||
validateIndexCreationId // validateIndexCreation | ||
validateOperandsId // validateOperands | ||
validateCaseResultTypesId // validateCaseResultTypes | ||
validateIntervalUsageId // validateIntervalUsage | ||
validateExplodeUsageId // validateExplodeUsage | ||
validateSubqueryColumnsId // validateSubqueryColumns | ||
validateUnionSchemasMatchId // validateUnionSchemasMatch | ||
validateAggregationsId // validateAggregations | ||
|
||
// after all | ||
TrackProcessId // trackProcess | ||
parallelizeId // parallelize | ||
clearWarningsId // clearWarnings | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is an insert ever inside a block node? What's going on here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one also confuses me, daylon added Block last week for foreign keys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like
*sqlparser.MultiAlterDDL
is now a thing, Block wraps arbitrarily nested statements?