cockroachdb / cockroachdb/cockroach

sql/rls: EXPLAIN may show inaccurate policy info for empty ValuesExpr

Open
#147,691 1 comment 0 reactions 0 assignees View on GitHub
branch-release-25.2 C-bug T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

When running `EXPLAIN (plan, verbose)`, we include which RLS policies were applied to scans. If the plan includes an empty `ValuesExpr`, we currently infer one of two cases:
1. RLS was enabled, but no policies matched, so all rows were filtered out.
2. RLS was enabled, a policy was applied, but it still filtered out all rows.

This generally works because we rely on RLS metadata in the memo. However, we don’t account for empty ValuesExprs that aren't the result of RLS filtering. This can lead to misleading policy info in EXPLAIN.

This issue tracks improving EXPLAIN output by recording why an empty ValuesExpr was generated—so we can distinguish RLS-related filtering from other cases.

For context, see: https://github.com/cockroachdb/cockroach/pull/147364#pullrequestreview-2888017940

Jira issue: CRDB-51188

Epic CRDB-52152

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.