cockroachdb / cockroachdb/cockroach
sql: allow deferred optbuild for `RETURNS RECORD` routines
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
SQL routines with RETURNS RECORD (`AnyTuple`) are forced into the eager build path because the concrete return type is inferred from the last body statement's result columns at plan time.
Only the final statement is needed for type inference. We could either:
1. Build only the final statement eagerly to infer the type, then defer the rest. or
2. Persist the resolved return type on the descriptor at CREATE time (just like for `CanMutate`), so no eager build is needed at all.
Contributor guide
Research direction
Start by tracing the SQL routine handling for RETURNS RECORD (AnyTuple), focusing on how the final body statement supplies the concrete return type and why this selects the eager optbuild path. Compare the two proposed approaches and verify that nonessential statements are deferred while return-type inference remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100