Skip to content

opt: prevent Const from wrapping True and False #56253

@mgartner

Description

@mgartner

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

Metadata

Metadata

Assignees

Labels

A-sql-optimizerSQL logical planning and optimizations.C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions