Skip to content

sql: add database overload of information_schema.crdb_rewrite_inline_hints#164562

Open
michae2 wants to merge 3 commits intocockroachdb:masterfrom
michae2:michae2/statement-hints-database
Open

sql: add database overload of information_schema.crdb_rewrite_inline_hints#164562
michae2 wants to merge 3 commits intocockroachdb:masterfrom
michae2:michae2/statement-hints-database

Conversation

@michae2
Copy link
Collaborator

@michae2 michae2 commented Feb 27, 2026

sql: extract rewriteInlineHintsImpl from rewriteInlineHintsOverload

Factor out the shared logic from the rewriteInlineHintsOverload closure
into a standalone rewriteInlineHintsImpl function. This makes it easier
to add additional overloads that share the same core logic.

No functional change.

Epic: None

Release note: None

Co-Authored-By: roachdev-claude roachdev-claude-bot@cockroachlabs.com


sql: add database parameter to statement hint insertion

Add a 3-arg overload of crdb_internal.inject_hint and
information_schema.crdb_rewrite_inline_hints that accepts a database
name. When specified, the hint is scoped to only apply when the current
database matches.

Changes:

  • InsertHintIntoDB gains an optDatabase parameter; when non-empty and
    the cluster version supports it, includes the database in the INSERT.
  • InsertStatementHint interface and implementations updated accordingly.
  • New 3-arg overload registered for both builtin names.
  • RewriteInlineHints proto event gains a database field.

Part of: #163522

Release note: None

Co-Authored-By: roachdev-claude roachdev-claude-bot@cockroachlabs.com


sql: add tests for 3-arg overload database column in statement hints

Add test cases to statement_hint_builtins verifying that:

  • The 3-arg overload of crdb_rewrite_inline_hints sets the database
    column in system.statement_hints.
  • The 2-arg overload leaves the database column NULL.
  • The 3-arg overload of crdb_internal.inject_hint also sets the
    database column.

Part of: #163522

Release note: None

Co-Authored-By: roachdev-claude roachdev-claude-bot@cockroachlabs.com

Factor out the shared logic from the rewriteInlineHintsOverload closure
into a standalone rewriteInlineHintsImpl function. This makes it easier
to add additional overloads that share the same core logic.

No functional change.

Epic: None

Release note: None

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@trunk-io
Copy link
Contributor

trunk-io bot commented Feb 27, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

michae2 and others added 2 commits February 27, 2026 17:08
Add a 3-arg overload of crdb_internal.inject_hint and
information_schema.crdb_rewrite_inline_hints that accepts a database
name. When specified, the hint is scoped to only apply when the current
database matches.

Changes:
- InsertHintIntoDB gains an optDatabase parameter; when non-empty and
  the cluster version supports it, includes the database in the INSERT.
- InsertStatementHint interface and implementations updated accordingly.
- New 3-arg overload registered for both builtin names.
- RewriteInlineHints proto event gains a database field.

Part of: cockroachdb#163522

Release note: None

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
Add test cases to statement_hint_builtins verifying that:
- The 3-arg overload of crdb_rewrite_inline_hints sets the database
  column in system.statement_hints.
- The 2-arg overload leaves the database column NULL.
- The 3-arg overload of crdb_internal.inject_hint also sets the
  database column.

Part of: cockroachdb#163522

Release note: None

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@michae2 michae2 force-pushed the michae2/statement-hints-database branch from 357ae2b to 1af513f Compare February 28, 2026 01:08
@michae2 michae2 requested review from a team, DrewKimball and ZhouXing19 February 28, 2026 05:30
@michae2 michae2 marked this pull request as ready for review February 28, 2026 05:30
@michae2 michae2 requested review from a team as code owners February 28, 2026 05:30
@michae2 michae2 requested review from aa-joshi and dhartunian and removed request for a team, aa-joshi and dhartunian February 28, 2026 05:30
@michae2
Copy link
Collaborator Author

michae2 commented Feb 28, 2026

Here's the first part of #163522. Similar to #163891, and I will rebase this after that goes in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants