Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: don't disable rewrites for internal SQL
Casting an OID to REGNAMESPACE runs this SQL using the internal executor: ``` SELECT pg_namespace.oid, nspname FROM pg_catalog.pg_namespace WHERE oid = $1 ``` When the `GenerateConstrainedScans` rule is disabled, this returns no rows and so doesn't apply the cast. The same SQL, not run via an internal executor, but also with `GenerateConstrainedScans` disabled, behaves correctly. Disabling `GenerateConstrainedScans` all the time prevents the cluster from starting. Internal SQL is sensitive to disabled optimizer rewrite rules, and it could cause server instability to allow rules to ever be disabled for internal SQL. Also, the `testing_optimizer_disable_rule_probability` session setting is mainly meant to perturb query plans of foreground SQL in randomized tests, and enabling it for internal SQL could make these tests more noisy and create harder to debug issues. Therefore the fix is to set the `testing_optimizer_disable_rule_probability` setting to zero for internal SQL statements. Fixes cockroachdb#98322 Release note: None
- Loading branch information