cockroachdb / cockroachdb/cockroach
sql: extract a reusable prepared-statement testing library from the EPSC oracle
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Is your feature request related to a problem? Please describe.**
The EPSC oracle (`pkg/internal/sqlsmith/{epsc,parameterize}.go` plus its roachtest harness) implements "run one statement through the simple query protocol and the extended/prepared protocol, then compare rows + state." Several of its building blocks likely generalize to other prepared-statement testing (e.g. the in-progress local-prepared logictest config), but today they live only inside the oracle, so reusing them would mean reimplementing that logic.
**Describe the solution you'd like**
Extract the reusable pieces into a shared library consumable by both the EPSC oracle and the logictest prepared-statement path, then refactor the oracle to use it. Candidate pieces:
- `Parameterize` / placeholder lifting and server-inferred placeholder-type binding
- byte/sign literal handling
- the targeted de-lift loop for untyped placeholders (42P18 recovery)
- the scalar-exclusion / replace-probability option
As part of this, evaluate moving the "no liftable scalars" statement classification (`DoBlock`/`CreateRoutine`/`CreateTrigger`) into `tree.ReplaceScalarsWithPlaceholders`.
**Describe alternatives you've considered**
Leaving the logic in the oracle and duplicating what's needed elsewhere; rejected because it risks divergence between the two prepared-statement testing paths.
**Additional context**
Follow-up raised during review of the EPSC oracle work.
Jira issue: CRDB-66114
Contributor guide
Research direction
Start with pkg/internal/sqlsmith/epsc.go and parameterize.go, then inspect the EPSC roachtest harness and the in-progress local-prepared logictest path. Identify which placeholder-lifting, literal-handling, recovery, and scalar-exclusion pieces can form a shared library, including the possible tree.ReplaceScalarsWithPlaceholders change. Done means both prepared-statement paths consume the shared logic without duplicated behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases, testing
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100