cockroachdb / cockroachdb/cockroach
workload/schemachange: extend dynamic SQL coverage to DDL and EXECUTE ... USING
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Summary:**
#172994 added dynamic SQL to the `schemachange` workload: a share of the statements
in a generated PL/pgSQL procedure body is now the workload's own DML, re-crafted
into a command string and run via `EXECUTE`. Two gaps were left out of that first
pass and are tracked here.
**Findings:**
- Only DML goes inside `EXECUTE`. `randDynamicBodyStmt` draws from `insertRow` and
`selectStmt`; the workload's DDL generators are unused. #172994 asked for a mix of
both, so this is the larger of the two gaps.
- DDL has a different error surface than DML inside a body. `dynamicProcedureExecErrors`
widens what a `CALL` of a dynamic-bodied procedure tolerates, and it is derived from
what the two DML generators can raise. Admitting DDL means re-deriving that set and
reconciling it with the schema-change error expectations the direct-execution path
already computes.
- No `EXECUTE ... USING`. Generated datums are inlined into the command string via
`quote_literal` and `format(%L)`. Binding them as placeholders instead exercises a
distinct path in the `EXECUTE` implementation.
**Code References:**
- [pkg/workload/schemachange/dynsql.go](https://github.com/cockroachdb/cockroach/blob/master/pkg/workload/schemachange/dynsql.go) — command-string crafting
- [pkg/workload/schemachange/operation_generator.go](https://github.com/cockroachdb/cockroach/blob/master/pkg/workload/schemachange/operation_generator.go) — `randProcedureBody`, `randDynamicBodyStmt`, `dynamicProcedureExecErrors`
**Next Steps:**
- [ ] Wrap generated DDL in `EXECUTE` inside procedure bodies.
- [ ] Re-derive the tolerated error set for `CALL` once bodies can run DDL.
- [ ] Generate a share of dynamic statements with `USING` placeholders rather than inlined literals.
Epic CRDB-48117
Jira issue: CRDB-67118
Contributor guide
Research direction
Read pkg/workload/schemachange/dynsql.go and operation_generator.go, starting at randProcedureBody, randDynamicBodyStmt, and dynamicProcedureExecErrors. Trace the existing DDL generators and direct-execution error expectations before changing the dynamic path. Done means procedure bodies cover DDL and some EXECUTE ... USING cases, with CALL error tolerances reconciled with the schema-change expectations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100