cockroachdb / cockroachdb/cockroach

sql: support deferred optbuild for trigger function

Open
#172,726 2 comments 0 reactions 0 assignees View on GitHub
A-plan-management A-sql-routine A-sql-trigger A-statement-hint branch-master C-bug docs-known-limitation T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Trigger function body statements are now eagerly optbuild. We should make it consistent with the deferred optbuild model of routines.

And it requires the same "can it mutate" check like for routines. The missing pieces are: optbuilder must read CanMutate from the trigger descriptor instead of deriving it from the eagerly built body, and propagateCanMutateToCallersDSC must also walk TriggerFunctionCall back-references, not just function back-references.

Jira issue: CRDB-65989

Epic: CRDB-66266

Contributor guide

Open the contributing guide

Research direction

Start by locating the optbuilder logic for trigger descriptors and the propagateCanMutateToCallersDSC implementation. Compare trigger-function handling with the existing deferred optbuild and mutation checks for routines, including how function back-references are traversed. Done means trigger bodies use deferred optbuild, CanMutate is read from the trigger descriptor, and TriggerFunctionCall back-references are propagated.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.