cockroachdb / cockroachdb/cockroach

sql: optbuilder should only be invoked once for `CREATE FUNCTION` and `CREATE PROCEDURE`

Open
#120,698 0 comments 0 reactions 0 assignees View on GitHub
C-bug E-quick-win T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

For CREATE FUNCTION and CREATE PROCEDURE statements, we are running optbuilder twice.

Once here: https://github.com/cockroachdb/cockroach/blob/09ec2c391e4fea24cf6b76bd01abc422093fd6c3/pkg/sql/reference_provider.go#L117-L118

And once here:
https://github.com/cockroachdb/cockroach/blob/21f0fafe1f1c21adcabc494891ec400a9518c543/pkg/sql/plan_opt.go#L598-L599

The first one is needed because the plan dependencies are not propogated from the `createFunctionNode` to the schema changer. But they could be in theory, which would make optbuilder obsolete here.

More context here: https://cockroachlabs.slack.com/archives/C0168LW5THS/p1710856995368039

Jira issue: CRDB-36829

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.