Skip to content

Commit

Permalink
*: prepare errors for CTE (#24763)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhuang2016 committed May 19, 2021
1 parent c8c2726 commit 542da5d
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 74 deletions.
6 changes: 6 additions & 0 deletions errno/errcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,11 @@ const (
ErrGrantRole = 3523
ErrRoleNotGranted = 3530
ErrLockAcquireFailAndNoWaitSet = 3572
ErrCTERecursiveRequiresUnion = 3573
ErrCTERecursiveRequiresNonRecursiveFirst = 3574
ErrCTERecursiveForbidsAggregation = 3575
ErrCTERecursiveForbiddenJoinOrder = 3576
ErrInvalidRequiresSingleReference = 3577
ErrWindowNoSuchWindow = 3579
ErrWindowCircularityInWindowGraph = 3580
ErrWindowNoChildPartitioning = 3581
Expand All @@ -877,6 +882,7 @@ const (
ErrWindowExplainJSON = 3598
ErrWindowFunctionIgnoresFrame = 3599
ErrIllegalPrivilegeLevel = 3619
ErrCTEMaxRecursionDepth = 3636
ErrNotHintUpdatable = 3637
ErrDataTruncatedFunctionalIndex = 3751
ErrDataOutOfRangeFunctionalIndex = 3752
Expand Down
8 changes: 7 additions & 1 deletion errno/errname.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ var MySQLErrName = map[uint16]*mysql.ErrMessage{
ErrViewSelectClause: mysql.Message("View's SELECT contains a '%s' clause", nil),
ErrViewSelectVariable: mysql.Message("View's SELECT contains a variable or parameter", nil),
ErrViewSelectTmptable: mysql.Message("View's SELECT refers to a temporary table '%-.192s'", nil),
ErrViewWrongList: mysql.Message("View's SELECT and view's field list have different column counts", nil),
ErrViewWrongList: mysql.Message("In definition of view, derived table or common table expression, SELECT list and column names list have different column counts", nil),
ErrWarnViewMerge: mysql.Message("View merge algorithm can't be used here for now (assumed undefined algorithm)", nil),
ErrWarnViewWithoutKey: mysql.Message("View being updated does not have complete key of underlying table in it", nil),
ErrViewInvalid: mysql.Message("View '%-.192s.%-.192s' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them", nil),
Expand Down Expand Up @@ -902,6 +902,12 @@ var MySQLErrName = map[uint16]*mysql.ErrMessage{
ErrUnsupportedConstraintCheck: mysql.Message("%s is not supported", nil),
ErrDynamicPrivilegeNotRegistered: mysql.Message("Dynamic privilege '%s' is not registered with the server.", nil),
ErrIllegalPrivilegeLevel: mysql.Message("Illegal privilege level specified for %s", nil),
ErrCTERecursiveRequiresUnion: mysql.Message("Recursive Common Table Expression '%s' should contain a UNION", nil),
ErrCTERecursiveRequiresNonRecursiveFirst: mysql.Message("Recursive Common Table Expression '%s' should have one or more non-recursive query blocks followed by one or more recursive ones", nil),
ErrCTERecursiveForbidsAggregation: mysql.Message("Recursive Common Table Expression '%s' can contain neither aggregation nor window functions in recursive query block", nil),
ErrCTERecursiveForbiddenJoinOrder: mysql.Message("In recursive query block of Recursive Common Table Expression '%s', the recursive table must neither be in the right argument of a LEFT JOIN, nor be forced to be non-first with join order hints", nil),
ErrInvalidRequiresSingleReference: mysql.Message("In recursive query block of Recursive Common Table Expression '%s', the recursive table must be referenced only once, and not in any subquery", nil),
ErrCTEMaxRecursionDepth: mysql.Message("Recursive query aborted after %d iterations. Try increasing @@cte_max_recursion_depth to a larger value", nil),
// MariaDB errors.
ErrOnlyOneDefaultPartionAllowed: mysql.Message("Only one DEFAULT partition allowed", nil),
ErrWrongPartitionTypeExpectedSystemTime: mysql.Message("Wrong partitioning type, expected type: `SYSTEM_TIME`", nil),
Expand Down
32 changes: 31 additions & 1 deletion errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ View's SELECT contains a '%s' clause

["ddl:1353"]
error = '''
View's SELECT and view's field list have different column counts
In definition of view, derived table or common table expression, SELECT list and column names list have different column counts
'''

["ddl:1481"]
Expand Down Expand Up @@ -561,6 +561,11 @@ error = '''
Illegal privilege level specified for %s
'''

["executor:3636"]
error = '''
Recursive query aborted after %d iterations. Try increasing @@cte_max_recursion_depth to a larger value
'''

["executor:3929"]
error = '''
Dynamic privilege '%s' is not registered with the server.
Expand Down Expand Up @@ -1016,6 +1021,31 @@ error = '''
Unresolved name '%s' for %s hint
'''

["planner:3573"]
error = '''
Recursive Common Table Expression '%s' should contain a UNION
'''

["planner:3574"]
error = '''
Recursive Common Table Expression '%s' should have one or more non-recursive query blocks followed by one or more recursive ones
'''

["planner:3575"]
error = '''
Recursive Common Table Expression '%s' can contain neither aggregation nor window functions in recursive query block
'''

["planner:3576"]
error = '''
In recursive query block of Recursive Common Table Expression '%s', the recursive table must neither be in the right argument of a LEFT JOIN, nor be forced to be non-first with join order hints
'''

["planner:3577"]
error = '''
In recursive query block of Recursive Common Table Expression '%s', the recursive table must be referenced only once, and not in any subquery
'''

["planner:3579"]
error = '''
Window name '%s' is not defined.
Expand Down
9 changes: 5 additions & 4 deletions executor/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ var (
ErrIllegalPrivilegeLevel = dbterror.ClassExecutor.NewStd(mysql.ErrIllegalPrivilegeLevel)
ErrInvalidSplitRegionRanges = dbterror.ClassExecutor.NewStd(mysql.ErrInvalidSplitRegionRanges)

ErrBRIEBackupFailed = dbterror.ClassExecutor.NewStd(mysql.ErrBRIEBackupFailed)
ErrBRIERestoreFailed = dbterror.ClassExecutor.NewStd(mysql.ErrBRIERestoreFailed)
ErrBRIEImportFailed = dbterror.ClassExecutor.NewStd(mysql.ErrBRIEImportFailed)
ErrBRIEExportFailed = dbterror.ClassExecutor.NewStd(mysql.ErrBRIEExportFailed)
ErrBRIEBackupFailed = dbterror.ClassExecutor.NewStd(mysql.ErrBRIEBackupFailed)
ErrBRIERestoreFailed = dbterror.ClassExecutor.NewStd(mysql.ErrBRIERestoreFailed)
ErrBRIEImportFailed = dbterror.ClassExecutor.NewStd(mysql.ErrBRIEImportFailed)
ErrBRIEExportFailed = dbterror.ClassExecutor.NewStd(mysql.ErrBRIEExportFailed)
ErrCTEMaxRecursionDepth = dbterror.ClassExecutor.NewStd(mysql.ErrCTEMaxRecursionDepth)
)
Loading

0 comments on commit 542da5d

Please sign in to comment.