Skip to content

sql: add new SQL grammar for consistency checking via INSPECT command #148272

@spilchen

Description

@spilchen

This task introduces new SQL grammar for a INSPECT command that supports data consistency validation. It serves as an alternative to the existing EXPERIMENTAL SCRUB command. While SCRUB was originally framed around hardware error correction concepts (see RFC), the new INSPECT command aims to present a clearer and more intuitive interface focused on validation, not repair. Since consistency issues are expected to be rare, the emphasis is on confirming integrity.

This issue is focused on defining the grammar and plumbing. Execution will be gated behind a feature flag and initially implemented as a no-op.

Proposed SQL Syntax

INSPECT TABLE <table> [AS OF SYSTEM TIME <expr>] [WITH OPTIONS (<option> [, ...])]
INSPECT DATABASE <database> [AS OF SYSTEM TIME <expr>] [WITH OPTIONS (<option> [, ...])]

SHOW INSPECT FAILURES [FOR TABLE <name>] [FOR LATEST RUN] [WITH DETAILS]

Options:

  • INDEX ALL — Validates all indexes (default).
  • INDEX (<indexname>...) — Run an inspect against the specific indexes

These options are mutually exclusive.

Scope of This Task

  • Add grammar for INSPECT and SHOW INSPECT FAILURES.
  • Introduce a cluster setting enable_inspect_command in vars.go.
  • By default, INSPECT fails with an error message referencing the setting.
  • If enabled, INSPECT will return successfully as a no-op.
  • SHOW INSPECT FAILURES will always return successfully as a no-op
  • EXPERIMENTAL SCRUB remains available. Execution logic for INSPECT will be implemented in follow-up tasks.

Jira issue: CRDB-51507

Epic CRDB-30356

Metadata

Metadata

Assignees

Labels

A-sql-scrubC-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions