-
Notifications
You must be signed in to change notification settings - Fork 4.1k
opt: prevent Const from wrapping True and False #56253
Copy link
Copy link
Closed
Labels
A-sql-optimizerSQL logical planning and optimizations.SQL logical planning and optimizations.C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Description
There are rules, like FoldNonNullIsNull, that rely on the assumption that a Const operator never contains Null. However, there is nothing preventing such an expression from being constructed. ConstructConstVal prevents it, but anywhere that ConstructConst is called directly could create a Null wrapped in a ConstOp.
We should make it impossible to create a Null inside of a Const to prevent potential bugs. It may be worthwhile to also prevent wrapping True and False in a Const.
Related discussion: https://reviewable.io/reviews/cockroachdb/cockroach/56130#-MKqeExb46hBAPobhKiS
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-sql-optimizerSQL logical planning and optimizations.SQL logical planning and optimizations.C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)