Skip to content

Commit 32c5577

Browse files
committed
sql: add system.statement_hints table
This patch adds a new table, `system.statement_hints`, which can be used to associate "external" hints with a statement without having to modify the statement itself. A following PR will add a per-node cache for this table, similar to the way table stats are handled. Informs #148160 Release note: None
1 parent 06f284e commit 32c5577

File tree

101 files changed

+791
-309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+791
-309
lines changed

docs/generated/settings/settings-for-tenants.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,4 +422,4 @@ trace.zipkin.collector string the address of a Zipkin instance to receive trace
422422
ui.database_locality_metadata.enabled boolean true if enabled shows extended locality data about databases and tables in DB Console which can be expensive to compute application
423423
ui.default_timezone string the default timezone used to format timestamps in the ui application
424424
ui.display_timezone enumeration etc/utc the timezone used to format timestamps in the ui. This setting is deprecatedand will be removed in a future version. Use the 'ui.default_timezone' setting instead. 'ui.default_timezone' takes precedence over this setting. [etc/utc = 0, america/new_york = 1] application
425-
version version 1000025.3-upgrading-to-1000025.4-step-012 set the active cluster version in the format '<major>.<minor>' application
425+
version version 1000025.3-upgrading-to-1000025.4-step-014 set the active cluster version in the format '<major>.<minor>' application

docs/generated/settings/settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,6 @@
380380
<tr><td><div id="setting-ui-database-locality-metadata-enabled" class="anchored"><code>ui.database_locality_metadata.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>if enabled shows extended locality data about databases and tables in DB Console which can be expensive to compute</td><td>Basic/Standard/Advanced/Self-Hosted</td></tr>
381381
<tr><td><div id="setting-ui-default-timezone" class="anchored"><code>ui.default_timezone</code></div></td><td>string</td><td><code></code></td><td>the default timezone used to format timestamps in the ui</td><td>Basic/Standard/Advanced/Self-Hosted</td></tr>
382382
<tr><td><div id="setting-ui-display-timezone" class="anchored"><code>ui.display_timezone</code></div></td><td>enumeration</td><td><code>etc/utc</code></td><td>the timezone used to format timestamps in the ui. This setting is deprecatedand will be removed in a future version. Use the &#39;ui.default_timezone&#39; setting instead. &#39;ui.default_timezone&#39; takes precedence over this setting. [etc/utc = 0, america/new_york = 1]</td><td>Basic/Standard/Advanced/Self-Hosted</td></tr>
383-
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000025.3-upgrading-to-1000025.4-step-012</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td><td>Basic/Standard/Advanced/Self-Hosted</td></tr>
383+
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000025.3-upgrading-to-1000025.4-step-014</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td><td>Basic/Standard/Advanced/Self-Hosted</td></tr>
384384
</tbody>
385385
</table>

pkg/backup/full_cluster_backup_restore_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ CREATE TABLE data2.foo (a int);
192192
sqlDB.Exec(t, `CREATE SCHEDULE FOR BACKUP data.bank INTO $1 RECURRING '@hourly' FULL BACKUP ALWAYS WITH SCHEDULE OPTIONS first_run = $2`, localFoo, firstRun)
193193
sqlDB.Exec(t, `PAUSE SCHEDULES SELECT id FROM [SHOW SCHEDULES FOR BACKUP]`)
194194

195+
// Populate system.statement_hints with a dummy row.
196+
sqlDB.Exec(t, `INSERT INTO system.statement_hints (fingerprint, hint) VALUES ('FOO BAR _', '0xDEADBEEF'::BYTES)`)
197+
195198
injectStats(t, sqlDB, "data.bank", "id")
196199
sqlDB.Exec(t, `BACKUP INTO $1`, localFoo)
197200

@@ -294,6 +297,7 @@ CREATE TABLE data2.foo (a int);
294297
systemschema.UITable.GetName(),
295298
systemschema.UsersTable.GetName(),
296299
systemschema.ScheduledJobsTable.GetName(),
300+
systemschema.StatementHintsTable.GetName(),
297301
}
298302

299303
verificationQueries := make([]string, len(systemTablesToVerify))
@@ -713,6 +717,7 @@ func TestClusterRestoreFailCleanup(t *testing.T) {
713717
{"role_options"},
714718
{"scheduled_jobs"},
715719
{"settings"},
720+
{"statement_hints"},
716721
{"tenant_settings"},
717722
{"ui"},
718723
{"users"},
@@ -807,6 +812,7 @@ func TestClusterRestoreFailCleanup(t *testing.T) {
807812
{"role_options"},
808813
{"scheduled_jobs"},
809814
{"settings"},
815+
{"statement_hints"},
810816
{"tenant_settings"},
811817
{"ui"},
812818
{"users"},

pkg/backup/system_schema.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,9 @@ var systemTableBackupConfiguration = map[string]systemBackupConfiguration{
872872
systemschema.TransactionDiagnosticsTable.GetName(): {
873873
shouldIncludeInClusterBackup: optOutOfClusterBackup,
874874
},
875+
systemschema.StatementHintsTable.GetName(): {
876+
shouldIncludeInClusterBackup: optInToClusterBackup, // No desc ID columns.
877+
},
875878
}
876879

877880
func rekeySystemTable(

pkg/backup/testdata/backup-restore/external-connections-nodelocal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ role_options table full
5151
scheduled_jobs table full
5252
schema schema full
5353
settings table full
54+
statement_hints table full
5455
system database full
5556
ui table full
5657
users table full

pkg/backup/testdata/backup-restore/external-connections-userfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ role_options table full
5151
scheduled_jobs table full
5252
schema schema full
5353
settings table full
54+
statement_hints table full
5455
system database full
5556
ui table full
5657
userfiles_root_upload_files table full

pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,12 @@ txn_id txn_fingerprint_id query implicit_txn session_id start_time end_tim
251251
query ITTI
252252
SELECT range_id, start_pretty, end_pretty, lease_holder FROM crdb_internal.ranges
253253
----
254-
78 /Tenant/10 /Tenant/11 1
254+
79 /Tenant/10 /Tenant/11 1
255255

256256
query ITT
257257
SELECT range_id, start_pretty, end_pretty FROM crdb_internal.ranges_no_leases
258258
----
259-
78 /Tenant/10 /Tenant/11
259+
79 /Tenant/10 /Tenant/11
260260

261261
query IT
262262
SELECT zone_id, target FROM crdb_internal.zones ORDER BY 1

pkg/ccl/logictestccl/testdata/logic_test/multi_region_remote_access_error

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ skipif config multiregion-9node-3region-3azs-vec-off
471471
query I retry
472472
SELECT DISTINCT range_id FROM [SHOW RANGES FROM TABLE messages_rbr]
473473
----
474-
83
474+
84
475475

476476
# Update does not fail when accessing all rows in messages_rbr because lookup
477477
# join does not error out the lookup table in phase 1.

pkg/ccl/logictestccl/testdata/logic_test/regional_by_row_insert_fast_path

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ query T rowsort
200200
SELECT message FROM [SHOW KV TRACE FOR SESSION]
201201
WHERE message LIKE '%batch%' AND message LIKE '%Scan%'
202202
----
203-
r77: sending batch 4 Scan to (n1,s1):1
203+
r78: sending batch 4 Scan to (n1,s1):1
204204

205205
# Regression test for #115377.
206206
statement ok

pkg/ccl/logictestccl/testdata/logic_test/regional_by_row_query_behavior

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ ap-southeast-2 23
266266
query TT
267267
SELECT start_key, end_key FROM [SHOW RANGE FROM TABLE regional_by_row_table FOR ROW ('ap-southeast-2', 1)]
268268
----
269-
<before:/Table/75> …
269+
<before:/Table/76> …
270270

271271
query TIIII
272272
SELECT crdb_region, pk, pk2, a, b FROM regional_by_row_table
@@ -404,7 +404,7 @@ SELECT start_key, end_key, replicas, lease_holder FROM [SHOW RANGES FROM INDEX r
404404
ORDER BY 1
405405
----
406406
start_key end_key replicas lease_holder
407-
<before:/Table/75> …/"\x80"/0 {1} 1
407+
<before:/Table/76> …/"\x80"/0 {1} 1
408408
…/"\x80"/0 …/"\xc0"/0 {4} 4
409409
…/"\xc0"/0 <after:/Table/110/5> {7} 7
410410

0 commit comments

Comments
 (0)