cockroachdb / cockroachdb/cockroach
Cluster setting prepared statements aren't generic over setting type
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
Preparing a statement to update the value of an enum-valued cluster setting fails.
**To Reproduce**
```
% ./cockroach demo
demo@127.0.0.1:26257/demoapp/movr> PREPARE change_setting AS SET CLUSTER SETTING trace.span_registry.enabled = $1;
PREPARE
Time: 2ms total (execution 2ms / network 1ms)
demo@127.0.0.1:26257/demoapp/movr> PREPARE change_enum_setting AS SET CLUSTER SETTING changefeed.default_range_distribution_strategy = $1;
ERROR: could not determine data type of placeholder $1
SQLSTATE: 42P18
HINT: consider adding explicit type casts to the placeholder arguments
```
**Expected behavior**
Enum-valued cluster settings should be supported in prepared statements.
**Additional data / screenshots**
With a type hint, the prepared statement works, as does execution. The type hint interferes with other types, such as booleans, which prevents this from being a general solution.
```
demo@127.0.0.1:26257/demoapp/movr> PREPARE change_enum_setting_hint AS SET CLUSTER SETTING changefeed.default_range_distribution_strategy = $1::STRING;
PREPARE
Time: 1ms total (execution 1ms / network 0ms)
```
**Environment:**
- CockroachDB `master` branch as of Dec 23 2024 (2df185df6495a6f2d9631a898f1da0c8b18d1efb)
- Server OS: MacOS 15.2
- Client app found with `pgx`, but reproduced in `cockroach sql`
**Additional context**
While I was able to work around the issue using the `setting_type` column from `SHOW CLUSTER SETTINGS`, this is fairly clearly an issue in the database.
Jira issue: CRDB-45953
Contributor guide
Assessment
This issue has not been assessed yet.