From 7b5fb52a9f64b6727eacc0f9712e61eaf3ae4b68 Mon Sep 17 00:00:00 2001 From: Azhng Date: Mon, 17 May 2021 18:50:37 -0400 Subject: [PATCH] sql: create system tables for SQL stats This PR creates two new system tables: system.sql_statement_stats and system.sql_transaction_stats per RFC #63752. This is the initial step that addresses #64743. Release note: None --- .../settings/settings-for-tenants.txt | 2 +- docs/generated/settings/settings.html | 2 +- pkg/ccl/backupccl/system_schema.go | 6 + .../streamclient/random_stream_client.go | 1 + pkg/cli/testdata/doctor/test_examine_cluster | 2 +- pkg/cli/testdata/zip/partial1 | 12 +- pkg/cli/testdata/zip/partial1_excluded | 12 +- pkg/cli/testdata/zip/partial2 | 12 +- pkg/cli/testdata/zip/specialnames | 4 +- pkg/cli/testdata/zip/testzip | 8 +- pkg/cli/testdata/zip/testzip_concurrent | 42 +- pkg/clusterversion/cockroach_versions.go | 7 + pkg/clusterversion/key_string.go | 5 +- pkg/keys/constants.go | 2 + pkg/migration/migrations/BUILD.bazel | 1 + pkg/migration/migrations/migrations.go | 10 + pkg/migration/migrations/sql_stats.go | 36 + pkg/sql/catalog/bootstrap/metadata.go | 4 + pkg/sql/catalog/descpb/privilege.go | 2 + pkg/sql/catalog/systemschema/system.go | 306 ++++- pkg/sql/catalog/tabledesc/safe_format_test.go | 9 +- .../logictest/testdata/logic_test/grant_table | 12 + .../testdata/logic_test/information_schema | 1083 +++++++++-------- .../logictest/testdata/logic_test/pg_catalog | 102 +- pkg/sql/logictest/testdata/logic_test/ranges | 8 +- .../logictest/testdata/logic_test/show_source | 4 + pkg/sql/logictest/testdata/logic_test/system | 12 + .../testdata/logic_test/system_namespace | 2 + .../testdata/autocommit_nonmetamorphic | 118 +- pkg/sql/opt/exec/execbuilder/testdata/delete | 6 +- .../testdata/show_trace_nonmetamorphic | 14 +- pkg/sql/pgwire/pgwire_test.go | 2 +- pkg/sql/table_test.go | 8 +- pkg/sql/tests/system_table_test.go | 12 + pkg/sql/tests/testdata/initial_keys | 22 +- pkg/sql/testutils.go | 18 +- pkg/sqlmigrations/migrations_test.go | 2 + 37 files changed, 1267 insertions(+), 643 deletions(-) create mode 100644 pkg/migration/migrations/sql_stats.go diff --git a/docs/generated/settings/settings-for-tenants.txt b/docs/generated/settings/settings-for-tenants.txt index c80282535001..429560ed2085 100644 --- a/docs/generated/settings/settings-for-tenants.txt +++ b/docs/generated/settings/settings-for-tenants.txt @@ -105,4 +105,4 @@ trace.datadog.project string CockroachDB the project under which traces will be trace.debug.enable boolean false if set, traces for recent requests can be seen at https:///debug/requests trace.lightstep.token string if set, traces go to Lightstep using this token trace.zipkin.collector string if set, traces go to the given Zipkin instance (example: '127.0.0.1:9411'). Only one tracer can be configured at a time. -version version 21.1-8 set the active cluster version in the format '.' +version version 21.1-10 set the active cluster version in the format '.' diff --git a/docs/generated/settings/settings.html b/docs/generated/settings/settings.html index 93461c4dbce6..55a43056673f 100644 --- a/docs/generated/settings/settings.html +++ b/docs/generated/settings/settings.html @@ -107,6 +107,6 @@ trace.debug.enablebooleanfalseif set, traces for recent requests can be seen at https:///debug/requests trace.lightstep.tokenstringif set, traces go to Lightstep using this token trace.zipkin.collectorstringif set, traces go to the given Zipkin instance (example: '127.0.0.1:9411'). Only one tracer can be configured at a time. -versionversion21.1-8set the active cluster version in the format '.' +versionversion21.1-10set the active cluster version in the format '.' diff --git a/pkg/ccl/backupccl/system_schema.go b/pkg/ccl/backupccl/system_schema.go index b0b2ea31c100..917e7b7c59ec 100644 --- a/pkg/ccl/backupccl/system_schema.go +++ b/pkg/ccl/backupccl/system_schema.go @@ -329,6 +329,12 @@ var systemTableBackupConfiguration = map[string]systemBackupConfiguration{ systemschema.JoinTokensTable.GetName(): { shouldIncludeInClusterBackup: optOutOfClusterBackup, }, + systemschema.SQLStatementStatsTable.GetName(): { + shouldIncludeInClusterBackup: optOutOfClusterBackup, + }, + systemschema.SQLTransactionStatsTable.GetName(): { + shouldIncludeInClusterBackup: optOutOfClusterBackup, + }, } // GetSystemTablesToIncludeInClusterBackup returns a set of system table names that diff --git a/pkg/ccl/streamingccl/streamclient/random_stream_client.go b/pkg/ccl/streamingccl/streamclient/random_stream_client.go index 483e9132f760..94b27bc986d2 100644 --- a/pkg/ccl/streamingccl/streamclient/random_stream_client.go +++ b/pkg/ccl/streamingccl/streamclient/random_stream_client.go @@ -244,6 +244,7 @@ func (m *randomStreamClient) getDescriptorAndNamespaceKVForTableID( tableID, fmt.Sprintf(RandomStreamSchemaPlaceholder, tableName), descpb.NewDefaultPrivilegeDescriptor(security.RootUserName()), + nil, /* sessionDataOverride */ ) if err != nil { return nil, nil, err diff --git a/pkg/cli/testdata/doctor/test_examine_cluster b/pkg/cli/testdata/doctor/test_examine_cluster index e42d3e8758c8..8cadb5ccbcf1 100644 --- a/pkg/cli/testdata/doctor/test_examine_cluster +++ b/pkg/cli/testdata/doctor/test_examine_cluster @@ -1,7 +1,7 @@ debug doctor examine cluster ---- debug doctor examine cluster -Examining 36 descriptors and 37 namespace entries... +Examining 38 descriptors and 39 namespace entries... ParentID 50, ParentSchemaID 29: relation "foo" (53): expected matching namespace entry, found none Examining 3 jobs... ERROR: validation failed diff --git a/pkg/cli/testdata/zip/partial1 b/pkg/cli/testdata/zip/partial1 index a74f0968179d..51410fa7ef3a 100644 --- a/pkg/cli/testdata/zip/partial1 +++ b/pkg/cli/testdata/zip/partial1 @@ -64,7 +64,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null [node 1] 1 log file ... [node 1] [log file ... [node 1] requesting ranges... received response... done -[node 1] 37 ranges found +[node 1] 39 ranges found [node 1] writing range 1... converting to JSON... writing binary output: debug/nodes/1/ranges/1.json... done [node 1] writing range 2... converting to JSON... writing binary output: debug/nodes/1/ranges/2.json... done [node 1] writing range 3... converting to JSON... writing binary output: debug/nodes/1/ranges/3.json... done @@ -102,6 +102,8 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null [node 1] writing range 35... converting to JSON... writing binary output: debug/nodes/1/ranges/35.json... done [node 1] writing range 36... converting to JSON... writing binary output: debug/nodes/1/ranges/36.json... done [node 1] writing range 37... converting to JSON... writing binary output: debug/nodes/1/ranges/37.json... done +[node 1] writing range 38... converting to JSON... writing binary output: debug/nodes/1/ranges/38.json... done +[node 1] writing range 39... converting to JSON... writing binary output: debug/nodes/1/ranges/39.json... done [node 2] node status... converting to JSON... writing binary output: debug/nodes/2/status.json... done [node 2] using SQL connection URL: postgresql://... [node 2] retrieving SQL data for crdb_internal.feature_usage... writing output: debug/nodes/2/crdb_internal.feature_usage.txt... @@ -220,7 +222,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null [node 3] 1 log file ... [node 3] [log file ... [node 3] requesting ranges... received response... done -[node 3] 37 ranges found +[node 3] 39 ranges found [node 3] writing range 1... converting to JSON... writing binary output: debug/nodes/3/ranges/1.json... done [node 3] writing range 2... converting to JSON... writing binary output: debug/nodes/3/ranges/2.json... done [node 3] writing range 3... converting to JSON... writing binary output: debug/nodes/3/ranges/3.json... done @@ -258,6 +260,8 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null [node 3] writing range 35... converting to JSON... writing binary output: debug/nodes/3/ranges/35.json... done [node 3] writing range 36... converting to JSON... writing binary output: debug/nodes/3/ranges/36.json... done [node 3] writing range 37... converting to JSON... writing binary output: debug/nodes/3/ranges/37.json... done +[node 3] writing range 38... converting to JSON... writing binary output: debug/nodes/3/ranges/38.json... done +[node 3] writing range 39... converting to JSON... writing binary output: debug/nodes/3/ranges/39.json... done [cluster] doctor examining cluster...... writing binary output: debug/reports/doctor.txt... done [cluster] requesting list of SQL databases... received response... done [cluster] 3 databases found @@ -266,7 +270,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null [cluster] [database: postgres] requesting database details... received response... converting to JSON... writing binary output: debug/schema/postgres@details.json... done [cluster] [database: postgres] 0 tables found [cluster] [database: system] requesting database details... received response... converting to JSON... writing binary output: debug/schema/system@details.json... done -[cluster] [database: system] 31 tables found +[cluster] [database: system] 33 tables found [cluster] [database: system] [table: public.comments] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_comments.json... done [cluster] [database: system] [table: public.descriptor] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_descriptor.json... done [cluster] [database: system] [table: public.eventlog] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_eventlog.json... done @@ -288,6 +292,8 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null [cluster] [database: system] [table: public.role_options] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_role_options.json... done [cluster] [database: system] [table: public.scheduled_jobs] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_scheduled_jobs.json... done [cluster] [database: system] [table: public.settings] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_settings.json... done +[cluster] [database: system] [table: public.sql_statement_stats] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_sql_statement_stats.json... done +[cluster] [database: system] [table: public.sql_transaction_stats] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_sql_transaction_stats.json... done [cluster] [database: system] [table: public.sqlliveness] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_sqlliveness.json... done [cluster] [database: system] [table: public.statement_bundle_chunks] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_bundle_chunks.json... done [cluster] [database: system] [table: public.statement_diagnostics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_diagnostics.json... done diff --git a/pkg/cli/testdata/zip/partial1_excluded b/pkg/cli/testdata/zip/partial1_excluded index 09422e551e08..7183abb95c95 100644 --- a/pkg/cli/testdata/zip/partial1_excluded +++ b/pkg/cli/testdata/zip/partial1_excluded @@ -64,7 +64,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0 [node 1] 1 log file ... [node 1] [log file ... [node 1] requesting ranges... received response... done -[node 1] 37 ranges found +[node 1] 39 ranges found [node 1] writing range 1... converting to JSON... writing binary output: debug/nodes/1/ranges/1.json... done [node 1] writing range 2... converting to JSON... writing binary output: debug/nodes/1/ranges/2.json... done [node 1] writing range 3... converting to JSON... writing binary output: debug/nodes/1/ranges/3.json... done @@ -102,6 +102,8 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0 [node 1] writing range 35... converting to JSON... writing binary output: debug/nodes/1/ranges/35.json... done [node 1] writing range 36... converting to JSON... writing binary output: debug/nodes/1/ranges/36.json... done [node 1] writing range 37... converting to JSON... writing binary output: debug/nodes/1/ranges/37.json... done +[node 1] writing range 38... converting to JSON... writing binary output: debug/nodes/1/ranges/38.json... done +[node 1] writing range 39... converting to JSON... writing binary output: debug/nodes/1/ranges/39.json... done [node 2] skipping node... writing binary output: debug/nodes/2.skipped... done [node 3] node status... converting to JSON... writing binary output: debug/nodes/3/status.json... done [node 3] using SQL connection URL: postgresql://... @@ -138,7 +140,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0 [node 3] 1 log file ... [node 3] [log file ... [node 3] requesting ranges... received response... done -[node 3] 37 ranges found +[node 3] 39 ranges found [node 3] writing range 1... converting to JSON... writing binary output: debug/nodes/3/ranges/1.json... done [node 3] writing range 2... converting to JSON... writing binary output: debug/nodes/3/ranges/2.json... done [node 3] writing range 3... converting to JSON... writing binary output: debug/nodes/3/ranges/3.json... done @@ -176,6 +178,8 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0 [node 3] writing range 35... converting to JSON... writing binary output: debug/nodes/3/ranges/35.json... done [node 3] writing range 36... converting to JSON... writing binary output: debug/nodes/3/ranges/36.json... done [node 3] writing range 37... converting to JSON... writing binary output: debug/nodes/3/ranges/37.json... done +[node 3] writing range 38... converting to JSON... writing binary output: debug/nodes/3/ranges/38.json... done +[node 3] writing range 39... converting to JSON... writing binary output: debug/nodes/3/ranges/39.json... done [cluster] doctor examining cluster...... writing binary output: debug/reports/doctor.txt... done [cluster] requesting list of SQL databases... received response... done [cluster] 3 databases found @@ -184,7 +188,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0 [cluster] [database: postgres] requesting database details... received response... converting to JSON... writing binary output: debug/schema/postgres@details.json... done [cluster] [database: postgres] 0 tables found [cluster] [database: system] requesting database details... received response... converting to JSON... writing binary output: debug/schema/system@details.json... done -[cluster] [database: system] 31 tables found +[cluster] [database: system] 33 tables found [cluster] [database: system] [table: public.comments] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_comments.json... done [cluster] [database: system] [table: public.descriptor] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_descriptor.json... done [cluster] [database: system] [table: public.eventlog] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_eventlog.json... done @@ -206,6 +210,8 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0 [cluster] [database: system] [table: public.role_options] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_role_options.json... done [cluster] [database: system] [table: public.scheduled_jobs] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_scheduled_jobs.json... done [cluster] [database: system] [table: public.settings] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_settings.json... done +[cluster] [database: system] [table: public.sql_statement_stats] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_sql_statement_stats.json... done +[cluster] [database: system] [table: public.sql_transaction_stats] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_sql_transaction_stats.json... done [cluster] [database: system] [table: public.sqlliveness] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_sqlliveness.json... done [cluster] [database: system] [table: public.statement_bundle_chunks] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_bundle_chunks.json... done [cluster] [database: system] [table: public.statement_diagnostics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_diagnostics.json... done diff --git a/pkg/cli/testdata/zip/partial2 b/pkg/cli/testdata/zip/partial2 index ab8dc5ebee2c..1659ee737a82 100644 --- a/pkg/cli/testdata/zip/partial2 +++ b/pkg/cli/testdata/zip/partial2 @@ -64,7 +64,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null [node 1] 1 log file ... [node 1] [log file ... [node 1] requesting ranges... received response... done -[node 1] 37 ranges found +[node 1] 39 ranges found [node 1] writing range 1... converting to JSON... writing binary output: debug/nodes/1/ranges/1.json... done [node 1] writing range 2... converting to JSON... writing binary output: debug/nodes/1/ranges/2.json... done [node 1] writing range 3... converting to JSON... writing binary output: debug/nodes/1/ranges/3.json... done @@ -102,6 +102,8 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null [node 1] writing range 35... converting to JSON... writing binary output: debug/nodes/1/ranges/35.json... done [node 1] writing range 36... converting to JSON... writing binary output: debug/nodes/1/ranges/36.json... done [node 1] writing range 37... converting to JSON... writing binary output: debug/nodes/1/ranges/37.json... done +[node 1] writing range 38... converting to JSON... writing binary output: debug/nodes/1/ranges/38.json... done +[node 1] writing range 39... converting to JSON... writing binary output: debug/nodes/1/ranges/39.json... done [node 3] node status... converting to JSON... writing binary output: debug/nodes/3/status.json... done [node 3] using SQL connection URL: postgresql://... [node 3] retrieving SQL data for crdb_internal.feature_usage... writing output: debug/nodes/3/crdb_internal.feature_usage.txt... done @@ -137,7 +139,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null [node 3] 1 log file ... [node 3] [log file ... [node 3] requesting ranges... received response... done -[node 3] 37 ranges found +[node 3] 39 ranges found [node 3] writing range 1... converting to JSON... writing binary output: debug/nodes/3/ranges/1.json... done [node 3] writing range 2... converting to JSON... writing binary output: debug/nodes/3/ranges/2.json... done [node 3] writing range 3... converting to JSON... writing binary output: debug/nodes/3/ranges/3.json... done @@ -175,6 +177,8 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null [node 3] writing range 35... converting to JSON... writing binary output: debug/nodes/3/ranges/35.json... done [node 3] writing range 36... converting to JSON... writing binary output: debug/nodes/3/ranges/36.json... done [node 3] writing range 37... converting to JSON... writing binary output: debug/nodes/3/ranges/37.json... done +[node 3] writing range 38... converting to JSON... writing binary output: debug/nodes/3/ranges/38.json... done +[node 3] writing range 39... converting to JSON... writing binary output: debug/nodes/3/ranges/39.json... done [cluster] doctor examining cluster...... writing binary output: debug/reports/doctor.txt... done [cluster] requesting list of SQL databases... received response... done [cluster] 3 databases found @@ -183,7 +187,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null [cluster] [database: postgres] requesting database details... received response... converting to JSON... writing binary output: debug/schema/postgres@details.json... done [cluster] [database: postgres] 0 tables found [cluster] [database: system] requesting database details... received response... converting to JSON... writing binary output: debug/schema/system@details.json... done -[cluster] [database: system] 31 tables found +[cluster] [database: system] 33 tables found [cluster] [database: system] [table: public.comments] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_comments.json... done [cluster] [database: system] [table: public.descriptor] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_descriptor.json... done [cluster] [database: system] [table: public.eventlog] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_eventlog.json... done @@ -205,6 +209,8 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null [cluster] [database: system] [table: public.role_options] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_role_options.json... done [cluster] [database: system] [table: public.scheduled_jobs] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_scheduled_jobs.json... done [cluster] [database: system] [table: public.settings] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_settings.json... done +[cluster] [database: system] [table: public.sql_statement_stats] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_sql_statement_stats.json... done +[cluster] [database: system] [table: public.sql_transaction_stats] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_sql_transaction_stats.json... done [cluster] [database: system] [table: public.sqlliveness] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_sqlliveness.json... done [cluster] [database: system] [table: public.statement_bundle_chunks] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_bundle_chunks.json... done [cluster] [database: system] [table: public.statement_diagnostics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_diagnostics.json... done diff --git a/pkg/cli/testdata/zip/specialnames b/pkg/cli/testdata/zip/specialnames index 08d26d14c9a6..789bf56718f5 100644 --- a/pkg/cli/testdata/zip/specialnames +++ b/pkg/cli/testdata/zip/specialnames @@ -23,7 +23,7 @@ zip [cluster] [database: postgres] requesting database details... received response... converting to JSON... writing binary output: debug/schema/postgres@details.json... done [cluster] [database: postgres] 0 tables found [cluster] [database: system] requesting database details... received response... converting to JSON... writing binary output: debug/schema/system-1@details.json... done -[cluster] [database: system] 31 tables found +[cluster] [database: system] 33 tables found [cluster] [database: system] [table: public.comments] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system-1/public_comments.json... done [cluster] [database: system] [table: public.descriptor] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system-1/public_descriptor.json... done [cluster] [database: system] [table: public.eventlog] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system-1/public_eventlog.json... done @@ -45,6 +45,8 @@ zip [cluster] [database: system] [table: public.role_options] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system-1/public_role_options.json... done [cluster] [database: system] [table: public.scheduled_jobs] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system-1/public_scheduled_jobs.json... done [cluster] [database: system] [table: public.settings] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system-1/public_settings.json... done +[cluster] [database: system] [table: public.sql_statement_stats] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system-1/public_sql_statement_stats.json... done +[cluster] [database: system] [table: public.sql_transaction_stats] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system-1/public_sql_transaction_stats.json... done [cluster] [database: system] [table: public.sqlliveness] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system-1/public_sqlliveness.json... done [cluster] [database: system] [table: public.statement_bundle_chunks] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system-1/public_statement_bundle_chunks.json... done [cluster] [database: system] [table: public.statement_diagnostics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system-1/public_statement_diagnostics.json... done diff --git a/pkg/cli/testdata/zip/testzip b/pkg/cli/testdata/zip/testzip index 221853591488..490ee31c2972 100644 --- a/pkg/cli/testdata/zip/testzip +++ b/pkg/cli/testdata/zip/testzip @@ -64,7 +64,7 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null [node 1] requesting log file ... [node 1] 0 log file ... [node 1] requesting ranges... received response... done -[node 1] 37 ranges found +[node 1] 39 ranges found [node 1] writing range 1... converting to JSON... writing binary output: debug/nodes/1/ranges/1.json... done [node 1] writing range 2... converting to JSON... writing binary output: debug/nodes/1/ranges/2.json... done [node 1] writing range 3... converting to JSON... writing binary output: debug/nodes/1/ranges/3.json... done @@ -102,6 +102,8 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null [node 1] writing range 35... converting to JSON... writing binary output: debug/nodes/1/ranges/35.json... done [node 1] writing range 36... converting to JSON... writing binary output: debug/nodes/1/ranges/36.json... done [node 1] writing range 37... converting to JSON... writing binary output: debug/nodes/1/ranges/37.json... done +[node 1] writing range 38... converting to JSON... writing binary output: debug/nodes/1/ranges/38.json... done +[node 1] writing range 39... converting to JSON... writing binary output: debug/nodes/1/ranges/39.json... done [cluster] doctor examining cluster...... writing binary output: debug/reports/doctor.txt... done [cluster] requesting list of SQL databases... received response... done [cluster] 3 databases found @@ -110,7 +112,7 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null [cluster] [database: postgres] requesting database details... received response... converting to JSON... writing binary output: debug/schema/postgres@details.json... done [cluster] [database: postgres] 0 tables found [cluster] [database: system] requesting database details... received response... converting to JSON... writing binary output: debug/schema/system@details.json... done -[cluster] [database: system] 31 tables found +[cluster] [database: system] 33 tables found [cluster] [database: system] [table: public.comments] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_comments.json... done [cluster] [database: system] [table: public.descriptor] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_descriptor.json... done [cluster] [database: system] [table: public.eventlog] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_eventlog.json... done @@ -132,6 +134,8 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null [cluster] [database: system] [table: public.role_options] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_role_options.json... done [cluster] [database: system] [table: public.scheduled_jobs] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_scheduled_jobs.json... done [cluster] [database: system] [table: public.settings] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_settings.json... done +[cluster] [database: system] [table: public.sql_statement_stats] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_sql_statement_stats.json... done +[cluster] [database: system] [table: public.sql_transaction_stats] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_sql_transaction_stats.json... done [cluster] [database: system] [table: public.sqlliveness] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_sqlliveness.json... done [cluster] [database: system] [table: public.statement_bundle_chunks] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_bundle_chunks.json... done [cluster] [database: system] [table: public.statement_diagnostics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_diagnostics.json... done diff --git a/pkg/cli/testdata/zip/testzip_concurrent b/pkg/cli/testdata/zip/testzip_concurrent index 8ee43e438295..de5c4f1a7bad 100644 --- a/pkg/cli/testdata/zip/testzip_concurrent +++ b/pkg/cli/testdata/zip/testzip_concurrent @@ -13,7 +13,7 @@ zip [cluster] [database: postgres] requesting database details: done [cluster] [database: postgres] requesting database details: received response... [cluster] [database: postgres] requesting database details: writing binary output: debug/schema/postgres@details.json... -[cluster] [database: system] 31 tables found +[cluster] [database: system] 33 tables found [cluster] [database: system] [table: public.comments] requesting table details... [cluster] [database: system] [table: public.comments] requesting table details: converting to JSON... [cluster] [database: system] [table: public.comments] requesting table details: done @@ -119,6 +119,16 @@ zip [cluster] [database: system] [table: public.settings] requesting table details: done [cluster] [database: system] [table: public.settings] requesting table details: received response... [cluster] [database: system] [table: public.settings] requesting table details: writing binary output: debug/schema/system/public_settings.json... +[cluster] [database: system] [table: public.sql_statement_stats] requesting table details... +[cluster] [database: system] [table: public.sql_statement_stats] requesting table details: converting to JSON... +[cluster] [database: system] [table: public.sql_statement_stats] requesting table details: done +[cluster] [database: system] [table: public.sql_statement_stats] requesting table details: received response... +[cluster] [database: system] [table: public.sql_statement_stats] requesting table details: writing binary output: debug/schema/system/public_sql_statement_stats.json... +[cluster] [database: system] [table: public.sql_transaction_stats] requesting table details... +[cluster] [database: system] [table: public.sql_transaction_stats] requesting table details: converting to JSON... +[cluster] [database: system] [table: public.sql_transaction_stats] requesting table details: done +[cluster] [database: system] [table: public.sql_transaction_stats] requesting table details: received response... +[cluster] [database: system] [table: public.sql_transaction_stats] requesting table details: writing binary output: debug/schema/system/public_sql_transaction_stats.json... [cluster] [database: system] [table: public.sqlliveness] requesting table details... [cluster] [database: system] [table: public.sqlliveness] requesting table details: converting to JSON... [cluster] [database: system] [table: public.sqlliveness] requesting table details: done @@ -280,7 +290,7 @@ zip [cluster] using SQL address: ... [cluster] using SQL address: ... [node 1] 1 log file ... -[node 1] 37 ranges found +[node 1] 39 ranges found [node 1] [log file ... [node 1] [log file ... [node 1] [log file ... @@ -505,6 +515,14 @@ zip [node 1] writing range 37: converting to JSON... [node 1] writing range 37: done [node 1] writing range 37: writing binary output: debug/nodes/1/ranges/37.json... +[node 1] writing range 38... +[node 1] writing range 38: converting to JSON... +[node 1] writing range 38: done +[node 1] writing range 38: writing binary output: debug/nodes/1/ranges/38.json... +[node 1] writing range 39... +[node 1] writing range 39: converting to JSON... +[node 1] writing range 39: done +[node 1] writing range 39: writing binary output: debug/nodes/1/ranges/39.json... [node 1] writing range 3: converting to JSON... [node 1] writing range 3: done [node 1] writing range 3: writing binary output: debug/nodes/1/ranges/3.json... @@ -533,7 +551,7 @@ zip [node 1] writing range 9: done [node 1] writing range 9: writing binary output: debug/nodes/1/ranges/9.json... [node 2] 1 log file ... -[node 2] 37 ranges found +[node 2] 39 ranges found [node 2] [log file ... [node 2] [log file ... [node 2] [log file ... @@ -758,6 +776,14 @@ zip [node 2] writing range 37: converting to JSON... [node 2] writing range 37: done [node 2] writing range 37: writing binary output: debug/nodes/2/ranges/37.json... +[node 2] writing range 38... +[node 2] writing range 38: converting to JSON... +[node 2] writing range 38: done +[node 2] writing range 38: writing binary output: debug/nodes/2/ranges/38.json... +[node 2] writing range 39... +[node 2] writing range 39: converting to JSON... +[node 2] writing range 39: done +[node 2] writing range 39: writing binary output: debug/nodes/2/ranges/39.json... [node 2] writing range 3: converting to JSON... [node 2] writing range 3: done [node 2] writing range 3: writing binary output: debug/nodes/2/ranges/3.json... @@ -786,7 +812,7 @@ zip [node 2] writing range 9: done [node 2] writing range 9: writing binary output: debug/nodes/2/ranges/9.json... [node 3] 1 log file ... -[node 3] 37 ranges found +[node 3] 39 ranges found [node 3] [log file ... [node 3] [log file ... [node 3] [log file ... @@ -1011,6 +1037,14 @@ zip [node 3] writing range 37: converting to JSON... [node 3] writing range 37: done [node 3] writing range 37: writing binary output: debug/nodes/3/ranges/37.json... +[node 3] writing range 38... +[node 3] writing range 38: converting to JSON... +[node 3] writing range 38: done +[node 3] writing range 38: writing binary output: debug/nodes/3/ranges/38.json... +[node 3] writing range 39... +[node 3] writing range 39: converting to JSON... +[node 3] writing range 39: done +[node 3] writing range 39: writing binary output: debug/nodes/3/ranges/39.json... [node 3] writing range 3: converting to JSON... [node 3] writing range 3: done [node 3] writing range 3: writing binary output: debug/nodes/3/ranges/3.json... diff --git a/pkg/clusterversion/cockroach_versions.go b/pkg/clusterversion/cockroach_versions.go index caaae452c758..a767788cda8e 100644 --- a/pkg/clusterversion/cockroach_versions.go +++ b/pkg/clusterversion/cockroach_versions.go @@ -334,6 +334,9 @@ const ( // SerializeViewUDTs serializes user defined types used in views to allow // for renaming of the referenced types. SerializeViewUDTs + // SQLStatsTable adds the system tables for storing persisted SQL statistics + // for statements and transactions. + SQLStatsTable // Step (1): Add new versions here. ) @@ -560,6 +563,10 @@ var versionsSingleton = keyedVersions([]keyedVersion{ Key: SerializeViewUDTs, Version: roachpb.Version{Major: 21, Minor: 1, Internal: 8}, }, + { + Key: SQLStatsTable, + Version: roachpb.Version{Major: 21, Minor: 1, Internal: 10}, + }, // Step (2): Add new versions here. }) diff --git a/pkg/clusterversion/key_string.go b/pkg/clusterversion/key_string.go index ad329e90141d..87a3c06c1ddd 100644 --- a/pkg/clusterversion/key_string.go +++ b/pkg/clusterversion/key_string.go @@ -57,11 +57,12 @@ func _() { _ = x[JoinTokensTable-46] _ = x[AcquisitionTypeInLeaseHistory-47] _ = x[SerializeViewUDTs-48] + _ = x[SQLStatsTable-49] } -const _Key_name = "NamespaceTableWithSchemasStart20_2GeospatialTypeEnumsRangefeedLeasesAlterColumnTypeGeneralAlterSystemJobsAddCreatedByColumnsAddScheduledJobsTableUserDefinedSchemasNoOriginFKIndexesNodeMembershipStatusMinPasswordLengthAbortSpanBytesAlterSystemJobsAddSqllivenessColumnsAddNewSystemSqllivenessTableMaterializedViewsBox2DTypeUpdateScheduledJobsSchemaCreateLoginPrivilegeHBAForNonTLSV20_2Start21_1EmptyArraysInInvertedIndexesUniqueWithoutIndexConstraintsVirtualComputedColumnsCPutInlineReplicaVersionsreplacedTruncatedAndRangeAppliedStateMigrationreplacedPostTruncatedAndRangeAppliedStateMigrationNewSchemaChangerLongRunningMigrationsTruncatedAndRangeAppliedStateMigrationPostTruncatedAndRangeAppliedStateMigrationSeparatedIntentsTracingVerbosityIndependentSemanticsSequencesRegclassImplicitColumnPartitioningMultiRegionFeaturesClosedTimestampsRaftTransportChangefeedsSupportPrimaryIndexChangesNamespaceTableWithSchemasMigrationForeignKeyRepresentationMigrationPriorReadSummariesNonVotingReplicasProtectedTsMetaPrivilegesMigrationV21_1Start21_2JoinTokensTableAcquisitionTypeInLeaseHistorySerializeViewUDTs" +const _Key_name = "NamespaceTableWithSchemasStart20_2GeospatialTypeEnumsRangefeedLeasesAlterColumnTypeGeneralAlterSystemJobsAddCreatedByColumnsAddScheduledJobsTableUserDefinedSchemasNoOriginFKIndexesNodeMembershipStatusMinPasswordLengthAbortSpanBytesAlterSystemJobsAddSqllivenessColumnsAddNewSystemSqllivenessTableMaterializedViewsBox2DTypeUpdateScheduledJobsSchemaCreateLoginPrivilegeHBAForNonTLSV20_2Start21_1EmptyArraysInInvertedIndexesUniqueWithoutIndexConstraintsVirtualComputedColumnsCPutInlineReplicaVersionsreplacedTruncatedAndRangeAppliedStateMigrationreplacedPostTruncatedAndRangeAppliedStateMigrationNewSchemaChangerLongRunningMigrationsTruncatedAndRangeAppliedStateMigrationPostTruncatedAndRangeAppliedStateMigrationSeparatedIntentsTracingVerbosityIndependentSemanticsSequencesRegclassImplicitColumnPartitioningMultiRegionFeaturesClosedTimestampsRaftTransportChangefeedsSupportPrimaryIndexChangesNamespaceTableWithSchemasMigrationForeignKeyRepresentationMigrationPriorReadSummariesNonVotingReplicasProtectedTsMetaPrivilegesMigrationV21_1Start21_2JoinTokensTableAcquisitionTypeInLeaseHistorySerializeViewUDTsSQLStatsTable" -var _Key_index = [...]uint16{0, 25, 34, 48, 53, 68, 90, 124, 145, 163, 180, 200, 217, 231, 295, 312, 321, 346, 366, 378, 383, 392, 420, 449, 471, 481, 496, 542, 592, 608, 629, 667, 709, 725, 761, 778, 804, 823, 852, 889, 923, 956, 974, 991, 1025, 1030, 1039, 1054, 1083, 1100} +var _Key_index = [...]uint16{0, 25, 34, 48, 53, 68, 90, 124, 145, 163, 180, 200, 217, 231, 295, 312, 321, 346, 366, 378, 383, 392, 420, 449, 471, 481, 496, 542, 592, 608, 629, 667, 709, 725, 761, 778, 804, 823, 852, 889, 923, 956, 974, 991, 1025, 1030, 1039, 1054, 1083, 1100, 1113} func (i Key) String() string { if i < 0 || i >= Key(len(_Key_index)-1) { diff --git a/pkg/keys/constants.go b/pkg/keys/constants.go index 24248f496408..739ffe8f6bce 100644 --- a/pkg/keys/constants.go +++ b/pkg/keys/constants.go @@ -404,6 +404,8 @@ const ( SqllivenessID = 39 MigrationsID = 40 JoinTokensTableID = 41 + SQLStatementStatsTableID = 42 + SQLTransactionStatsTableID = 43 // CommentType is type for system.comments DatabaseCommentType = 0 diff --git a/pkg/migration/migrations/BUILD.bazel b/pkg/migration/migrations/BUILD.bazel index b822b306f842..d87dec232d54 100644 --- a/pkg/migration/migrations/BUILD.bazel +++ b/pkg/migration/migrations/BUILD.bazel @@ -9,6 +9,7 @@ go_library( "migrations_table.go", "namespace_migration.go", "protected_ts_meta_migration.go", + "sql_stats.go", "truncated_state.go", ], importpath = "github.com/cockroachdb/cockroach/pkg/migration/migrations", diff --git a/pkg/migration/migrations/migrations.go b/pkg/migration/migrations/migrations.go index 967f0f797227..39886c173f38 100644 --- a/pkg/migration/migrations/migrations.go +++ b/pkg/migration/migrations/migrations.go @@ -67,6 +67,16 @@ var migrations = []migration.Migration{ toCV(clusterversion.JoinTokensTable), joinTokensTableMigration, ), + migration.NewTenantMigration( + "add the system.sql_statement_stats table", + toCV(clusterversion.SQLStatsTable), + sqlStatementStatsTableMigration, + ), + migration.NewTenantMigration( + "add the system.sql_transaction_stats table", + toCV(clusterversion.SQLStatsTable), + sqlTransactionStatsTableMigration, + ), } func init() { diff --git a/pkg/migration/migrations/sql_stats.go b/pkg/migration/migrations/sql_stats.go new file mode 100644 index 000000000000..a877e092399f --- /dev/null +++ b/pkg/migration/migrations/sql_stats.go @@ -0,0 +1,36 @@ +// Copyright 2021 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package migrations + +import ( + "context" + + "github.com/cockroachdb/cockroach/pkg/clusterversion" + "github.com/cockroachdb/cockroach/pkg/migration" + "github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" + "github.com/cockroachdb/cockroach/pkg/sqlmigrations" +) + +func sqlStatementStatsTableMigration( + ctx context.Context, _ clusterversion.ClusterVersion, d migration.TenantDeps, +) error { + return sqlmigrations.CreateSystemTable( + ctx, d.DB, d.Codec, d.Settings, systemschema.SQLStatementStatsTable, + ) +} + +func sqlTransactionStatsTableMigration( + ctx context.Context, _ clusterversion.ClusterVersion, d migration.TenantDeps, +) error { + return sqlmigrations.CreateSystemTable( + ctx, d.DB, d.Codec, d.Settings, systemschema.SQLTransactionStatsTable, + ) +} diff --git a/pkg/sql/catalog/bootstrap/metadata.go b/pkg/sql/catalog/bootstrap/metadata.go index 1837107832ba..1e3f52445f7f 100644 --- a/pkg/sql/catalog/bootstrap/metadata.go +++ b/pkg/sql/catalog/bootstrap/metadata.go @@ -347,6 +347,10 @@ func addSystemDescriptorsToSchema(target *MetadataSchema) { // Tables introduced in 21.1. target.AddDescriptor(keys.SystemDatabaseID, systemschema.JoinTokensTable) + + // Tables introduced in 21.2. + target.AddDescriptor(keys.SystemDatabaseID, systemschema.SQLStatementStatsTable) + target.AddDescriptor(keys.SystemDatabaseID, systemschema.SQLTransactionStatsTable) } // addSplitIDs adds a split point for each of the PseudoTableIDs to the supplied diff --git a/pkg/sql/catalog/descpb/privilege.go b/pkg/sql/catalog/descpb/privilege.go index c1a3b5c6f96c..0b1642b02b6f 100644 --- a/pkg/sql/catalog/descpb/privilege.go +++ b/pkg/sql/catalog/descpb/privilege.go @@ -490,6 +490,8 @@ var SystemAllowedPrivileges = map[ID]privilege.List{ keys.SqllivenessID: privilege.ReadWriteData, keys.MigrationsID: privilege.ReadWriteData, keys.JoinTokensTableID: privilege.ReadWriteData, + keys.SQLStatementStatsTableID: privilege.ReadData, + keys.SQLTransactionStatsTableID: privilege.ReadData, } // SetOwner sets the owner of the privilege descriptor to the provided string. diff --git a/pkg/sql/catalog/systemschema/system.go b/pkg/sql/catalog/systemschema/system.go index 464627a5c8b2..47cebd991851 100644 --- a/pkg/sql/catalog/systemschema/system.go +++ b/pkg/sql/catalog/systemschema/system.go @@ -365,6 +365,75 @@ CREATE TABLE system.join_tokens ( expiration TIMESTAMPTZ NOT NULL, FAMILY "primary" (id, secret, expiration) )` + + // TODO(azhng): Currently we choose number of bucket for hash-sharding to be + // 8 for both statement statistics table and transaction statistics table. + // This is an arbitrary choice for now. After persisted SQL Stats is fully + // implemented, we need to revisit this choice and retune the configuration. + SQLStatementStatsTableSchema = ` +CREATE TABLE system.sql_statement_stats ( + aggregated_ts TIMESTAMPTZ NOT NULL, + fingerprint_id BYTES NOT NULL, + plan_hash INT NOT NULL, + app_name STRING NOT NULL, + node_id INT NOT NULL, + + count INT NOT NULL, + agg_interval INTERVAL NOT NULL, + + metadata JSONB NOT NULL, + statistics JSONB NOT NULL, + + plan BYTES NOT NULL, + + PRIMARY KEY (aggregated_ts, fingerprint_id, plan_hash, app_name, node_id) + USING HASH WITH BUCKET_COUNT = 8, + INDEX "fingerprint_stats_idx" (fingerprint_id, aggregated_ts, plan_hash, app_name, node_id), + FAMILY "primary" ( + crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8, + aggregated_ts, + fingerprint_id, + plan_hash, + app_name, + node_id, + count, + agg_interval, + metadata, + statistics, + plan + ) +) +` + + SQLTransactionStatsTableSchema = ` +CREATE TABLE system.sql_transaction_stats ( + aggregated_ts TIMESTAMPTZ NOT NULL, + fingerprint_id BYTES NOT NULL, + app_name STRING NOT NULL, + node_id INT NOT NULL, + + count INT NOT NULL, + agg_interval INTERVAL NOT NULL, + + metadata JSONB NOT NULL, + statistics JSONB NOT NULL, + + PRIMARY KEY (aggregated_ts, fingerprint_id, app_name, node_id) + USING HASH WITH BUCKET_COUNT = 8, + INDEX "fingerprint_stats_idx" (fingerprint_id, aggregated_ts, app_name, node_id), + FAMILY "primary" ( + crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8, + aggregated_ts, + fingerprint_id, + app_name, + node_id, + count, + agg_interval, + metadata, + statistics + ) +); +` ) func pk(name string) descpb.IndexDescriptor { @@ -381,8 +450,10 @@ func pk(name string) descpb.IndexDescriptor { // Helpers used to make some of the descpb.TableDescriptor literals below more concise. var ( - singleASC = []descpb.IndexDescriptor_Direction{descpb.IndexDescriptor_ASC} - singleID1 = []descpb.ColumnID{1} + singleASC = []descpb.IndexDescriptor_Direction{descpb.IndexDescriptor_ASC} + singleID1 = []descpb.ColumnID{1} + sqlStmtHashComputeExpr = "mod(fnv32(COALESCE(CAST(aggregated_ts AS STRING), '':::STRING)) + (fnv32(COALESCE(CAST(app_name AS STRING), '':::STRING)) + (fnv32(COALESCE(CAST(fingerprint_id AS STRING), '':::STRING)) + (fnv32(COALESCE(CAST(node_id AS STRING), '':::STRING)) + fnv32(COALESCE(CAST(plan_hash AS STRING), '':::STRING))))), 8:::INT8)" + sqlTxnHashComputeExpr = "mod(fnv32(COALESCE(CAST(aggregated_ts AS STRING), '':::STRING)) + (fnv32(COALESCE(CAST(app_name AS STRING), '':::STRING)) + (fnv32(COALESCE(CAST(fingerprint_id AS STRING), '':::STRING)) + fnv32(COALESCE(CAST(node_id AS STRING), '':::STRING)))), 8:::INT8)" ) // SystemDatabaseName is the name of the system database. @@ -1807,6 +1878,237 @@ var ( FormatVersion: descpb.InterleavedFormatVersion, NextMutationID: 1, }) + + // SQLStatementStatsTable is the descriptor for the SQL statement stats table. + // It stores statistics for statement fingerprints. + SQLStatementStatsTable = makeTable(descpb.TableDescriptor{ + Name: "sql_statement_stats", + ID: keys.SQLStatementStatsTableID, + ParentID: keys.SystemDatabaseID, + UnexposedParentSchemaID: keys.PublicSchemaID, + Version: 1, + Columns: []descpb.ColumnDescriptor{ + {Name: "aggregated_ts", ID: 1, Type: types.TimestampTZ, Nullable: false}, + {Name: "fingerprint_id", ID: 2, Type: types.Bytes, Nullable: false}, + {Name: "plan_hash", ID: 3, Type: types.Int, Nullable: false}, + {Name: "app_name", ID: 4, Type: types.String, Nullable: false}, + {Name: "node_id", ID: 5, Type: types.Int, Nullable: false}, + {Name: "count", ID: 6, Type: types.Int, Nullable: false}, + {Name: "agg_interval", ID: 7, Type: types.Interval, Nullable: false}, + {Name: "metadata", ID: 8, Type: types.Jsonb, Nullable: false}, + {Name: "statistics", ID: 9, Type: types.Jsonb, Nullable: false}, + {Name: "plan", ID: 10, Type: types.Bytes, Nullable: false}, + { + Name: "crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8", + ID: 11, + Type: types.Int4, + Nullable: false, + ComputeExpr: &sqlStmtHashComputeExpr, + Hidden: true, + }, + }, + NextColumnID: 12, + Families: []descpb.ColumnFamilyDescriptor{ + { + Name: "primary", + ID: 0, + ColumnNames: []string{ + "crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8", + "aggregated_ts", "fingerprint_id", "plan_hash", "app_name", "node_id", + "count", "agg_interval", "metadata", "statistics", "plan", + }, + ColumnIDs: []descpb.ColumnID{11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, + DefaultColumnID: 0, + }, + }, + NextFamilyID: 1, + PrimaryIndex: descpb.IndexDescriptor{ + Name: tabledesc.PrimaryKeyIndexName, + ID: 1, + Unique: true, + ColumnNames: []string{ + "crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8", + "aggregated_ts", + "fingerprint_id", + "plan_hash", + "app_name", + "node_id", + }, + ColumnDirections: []descpb.IndexDescriptor_Direction{ + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + }, + ColumnIDs: []descpb.ColumnID{11, 1, 2, 3, 4, 5}, + Version: descpb.EmptyArraysInInvertedIndexesVersion, + Sharded: descpb.ShardedDescriptor{ + IsSharded: true, + Name: "crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8", + ShardBuckets: 8, + ColumnNames: []string{ + "aggregated_ts", + "app_name", + "fingerprint_id", + "node_id", + "plan_hash", + }, + }, + }, + Checks: []*descpb.TableDescriptor_CheckConstraint{ + { + Expr: "crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8)", + Name: "check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8", + Validity: descpb.ConstraintValidity_Validated, + ColumnIDs: []descpb.ColumnID{11}, + IsNonNullConstraint: false, + Hidden: true, + }, + }, + Indexes: []descpb.IndexDescriptor{ + { + Name: "fingerprint_stats_idx", + ID: 2, + Unique: false, + ColumnNames: []string{ + "fingerprint_id", + "aggregated_ts", + "plan_hash", + "app_name", + "node_id", + }, + ColumnDirections: []descpb.IndexDescriptor_Direction{ + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + }, + ColumnIDs: []descpb.ColumnID{2, 1, 3, 4, 5}, + ExtraColumnIDs: []descpb.ColumnID{11}, + Version: descpb.EmptyArraysInInvertedIndexesVersion, + }, + }, + NextIndexID: 3, + Privileges: descpb.NewCustomSuperuserPrivilegeDescriptor( + descpb.SystemAllowedPrivileges[keys.SQLStatementStatsTableID], security.NodeUserName()), + FormatVersion: descpb.InterleavedFormatVersion, + NextMutationID: 1, + }) + + // SQLTransactionStatsTable is the descriptor for the SQL transaction stats + // table. It stores statistics for transaction fingerprints. + SQLTransactionStatsTable = makeTable(descpb.TableDescriptor{ + Name: "sql_transaction_stats", + ID: keys.SQLTransactionStatsTableID, + ParentID: keys.SystemDatabaseID, + UnexposedParentSchemaID: keys.PublicSchemaID, + Version: 1, + Columns: []descpb.ColumnDescriptor{ + {Name: "aggregated_ts", ID: 1, Type: types.TimestampTZ, Nullable: false}, + {Name: "fingerprint_id", ID: 2, Type: types.Bytes, Nullable: false}, + {Name: "app_name", ID: 3, Type: types.String, Nullable: false}, + {Name: "node_id", ID: 4, Type: types.Int, Nullable: false}, + {Name: "count", ID: 5, Type: types.Int, Nullable: false}, + {Name: "agg_interval", ID: 6, Type: types.Interval, Nullable: false}, + {Name: "metadata", ID: 7, Type: types.Jsonb, Nullable: false}, + {Name: "statistics", ID: 8, Type: types.Jsonb, Nullable: false}, + { + Name: "crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8", + ID: 9, + Type: types.Int4, + Nullable: false, + ComputeExpr: &sqlTxnHashComputeExpr, + Hidden: true, + }, + }, + NextColumnID: 10, + Families: []descpb.ColumnFamilyDescriptor{ + { + Name: "primary", + ID: 0, + ColumnNames: []string{ + "crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8", + "aggregated_ts", "fingerprint_id", "app_name", "node_id", + "count", "agg_interval", "metadata", "statistics", + }, + ColumnIDs: []descpb.ColumnID{9, 1, 2, 3, 4, 5, 6, 7, 8}, + DefaultColumnID: 0, + }, + }, + NextFamilyID: 1, + PrimaryIndex: descpb.IndexDescriptor{ + Name: tabledesc.PrimaryKeyIndexName, + ID: 1, + Unique: true, + ColumnNames: []string{ + "crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8", + "aggregated_ts", + "fingerprint_id", + "app_name", + "node_id", + }, + ColumnDirections: []descpb.IndexDescriptor_Direction{ + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + }, + ColumnIDs: []descpb.ColumnID{9, 1, 2, 3, 4}, + Version: descpb.EmptyArraysInInvertedIndexesVersion, + Sharded: descpb.ShardedDescriptor{ + IsSharded: true, + Name: "crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8", + ShardBuckets: 8, + ColumnNames: []string{ + "aggregated_ts", + "app_name", + "fingerprint_id", + "node_id", + }, + }, + }, + Checks: []*descpb.TableDescriptor_CheckConstraint{ + { + Expr: "crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8)", + Name: "check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8", + Validity: descpb.ConstraintValidity_Validated, + ColumnIDs: []descpb.ColumnID{9}, + IsNonNullConstraint: false, + Hidden: true, + }, + }, + Indexes: []descpb.IndexDescriptor{ + { + Name: "fingerprint_stats_idx", + ID: 2, + Unique: false, + ColumnNames: []string{ + "fingerprint_id", + "aggregated_ts", + "app_name", + "node_id", + }, + ColumnDirections: []descpb.IndexDescriptor_Direction{ + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + descpb.IndexDescriptor_ASC, + }, + ColumnIDs: []descpb.ColumnID{2, 1, 3, 4}, + ExtraColumnIDs: []descpb.ColumnID{9}, + Version: descpb.EmptyArraysInInvertedIndexesVersion, + }, + }, + NextIndexID: 3, + Privileges: descpb.NewCustomSuperuserPrivilegeDescriptor( + descpb.SystemAllowedPrivileges[keys.SQLTransactionStatsTableID], security.NodeUserName()), + FormatVersion: descpb.InterleavedFormatVersion, + NextMutationID: 1, + }) ) // newCommentPrivilegeDescriptor returns a privilege descriptor for comment table diff --git a/pkg/sql/catalog/tabledesc/safe_format_test.go b/pkg/sql/catalog/tabledesc/safe_format_test.go index 94a7a4d6046d..14c091afe5d1 100644 --- a/pkg/sql/catalog/tabledesc/safe_format_test.go +++ b/pkg/sql/catalog/tabledesc/safe_format_test.go @@ -257,7 +257,14 @@ func TestSafeMessage(t *testing.T) { }, } { t.Run("", func(t *testing.T) { - desc, err := sql.CreateTestTableDescriptor(ctx, tc.parentID, tc.id, tc.schema, descpb.NewDefaultPrivilegeDescriptor(security.RootUserName())) + desc, err := sql.CreateTestTableDescriptor( + ctx, + tc.parentID, + tc.id, + tc.schema, + descpb.NewDefaultPrivilegeDescriptor(security.RootUserName()), + nil, /* sessionDataOverride */ + ) require.NoError(t, err) var td catalog.TableDescriptor if tc.f != nil { diff --git a/pkg/sql/logictest/testdata/logic_test/grant_table b/pkg/sql/logictest/testdata/logic_test/grant_table index de060b1f22b1..2e49bfe116c0 100644 --- a/pkg/sql/logictest/testdata/logic_test/grant_table +++ b/pkg/sql/logictest/testdata/logic_test/grant_table @@ -814,6 +814,14 @@ system public join_tokens root GRANT system public join_tokens root INSERT system public join_tokens root SELECT system public join_tokens root UPDATE +system public sql_statement_stats admin GRANT +system public sql_statement_stats admin SELECT +system public sql_statement_stats root GRANT +system public sql_statement_stats root SELECT +system public sql_transaction_stats admin GRANT +system public sql_transaction_stats admin SELECT +system public sql_transaction_stats root GRANT +system public sql_transaction_stats root SELECT a pg_extension NULL admin ALL a pg_extension NULL readwrite ALL a pg_extension NULL root ALL @@ -1265,6 +1273,10 @@ system public settings root GRA system public settings root INSERT system public settings root SELECT system public settings root UPDATE +system public sql_statement_stats root GRANT +system public sql_statement_stats root SELECT +system public sql_transaction_stats root GRANT +system public sql_transaction_stats root SELECT system public sqlliveness root DELETE system public sqlliveness root GRANT system public sqlliveness root INSERT diff --git a/pkg/sql/logictest/testdata/logic_test/information_schema b/pkg/sql/logictest/testdata/logic_test/information_schema index 92ce8901a207..37eac0a4573c 100755 --- a/pkg/sql/logictest/testdata/logic_test/information_schema +++ b/pkg/sql/logictest/testdata/logic_test/information_schema @@ -905,6 +905,8 @@ system public scheduled_jobs BASE T system public sqlliveness BASE TABLE YES 1 system public migrations BASE TABLE YES 1 system public join_tokens BASE TABLE YES 1 +system public sql_statement_stats BASE TABLE YES 1 +system public sql_transaction_stats BASE TABLE YES 1 statement ok ALTER TABLE other_db.xyz ADD COLUMN j INT @@ -961,156 +963,180 @@ SELECT * FROM system.information_schema.table_constraints ORDER BY TABLE_NAME, CONSTRAINT_TYPE, CONSTRAINT_NAME ---- -constraint_catalog constraint_schema constraint_name table_catalog table_schema table_name constraint_type is_deferrable initially_deferred -system public 630200280_24_1_not_null system public comments CHECK NO NO -system public 630200280_24_2_not_null system public comments CHECK NO NO -system public 630200280_24_3_not_null system public comments CHECK NO NO -system public 630200280_24_4_not_null system public comments CHECK NO NO -system public primary system public comments PRIMARY KEY NO NO -system public 630200280_3_1_not_null system public descriptor CHECK NO NO -system public primary system public descriptor PRIMARY KEY NO NO -system public 630200280_12_1_not_null system public eventlog CHECK NO NO -system public 630200280_12_2_not_null system public eventlog CHECK NO NO -system public 630200280_12_3_not_null system public eventlog CHECK NO NO -system public 630200280_12_4_not_null system public eventlog CHECK NO NO -system public 630200280_12_6_not_null system public eventlog CHECK NO NO -system public primary system public eventlog PRIMARY KEY NO NO -system public 630200280_15_1_not_null system public jobs CHECK NO NO -system public 630200280_15_2_not_null system public jobs CHECK NO NO -system public 630200280_15_3_not_null system public jobs CHECK NO NO -system public 630200280_15_4_not_null system public jobs CHECK NO NO -system public primary system public jobs PRIMARY KEY NO NO -system public 630200280_41_1_not_null system public join_tokens CHECK NO NO -system public 630200280_41_2_not_null system public join_tokens CHECK NO NO -system public 630200280_41_3_not_null system public join_tokens CHECK NO NO -system public primary system public join_tokens PRIMARY KEY NO NO -system public 630200280_11_1_not_null system public lease CHECK NO NO -system public 630200280_11_2_not_null system public lease CHECK NO NO -system public 630200280_11_3_not_null system public lease CHECK NO NO -system public 630200280_11_4_not_null system public lease CHECK NO NO -system public primary system public lease PRIMARY KEY NO NO -system public 630200280_21_1_not_null system public locations CHECK NO NO -system public 630200280_21_2_not_null system public locations CHECK NO NO -system public 630200280_21_3_not_null system public locations CHECK NO NO -system public 630200280_21_4_not_null system public locations CHECK NO NO -system public primary system public locations PRIMARY KEY NO NO -system public 630200280_40_1_not_null system public migrations CHECK NO NO -system public 630200280_40_2_not_null system public migrations CHECK NO NO -system public 630200280_40_3_not_null system public migrations CHECK NO NO -system public 630200280_40_4_not_null system public migrations CHECK NO NO -system public 630200280_40_5_not_null system public migrations CHECK NO NO -system public primary system public migrations PRIMARY KEY NO NO -system public 630200280_2_1_not_null system public namespace CHECK NO NO -system public 630200280_2_2_not_null system public namespace CHECK NO NO -system public primary system public namespace PRIMARY KEY NO NO -system public 630200280_30_1_not_null system public namespace2 CHECK NO NO -system public 630200280_30_2_not_null system public namespace2 CHECK NO NO -system public 630200280_30_3_not_null system public namespace2 CHECK NO NO -system public primary system public namespace2 PRIMARY KEY NO NO -system public 630200280_31_1_not_null system public protected_ts_meta CHECK NO NO -system public 630200280_31_2_not_null system public protected_ts_meta CHECK NO NO -system public 630200280_31_3_not_null system public protected_ts_meta CHECK NO NO -system public 630200280_31_4_not_null system public protected_ts_meta CHECK NO NO -system public 630200280_31_5_not_null system public protected_ts_meta CHECK NO NO -system public check_singleton system public protected_ts_meta CHECK NO NO -system public primary system public protected_ts_meta PRIMARY KEY NO NO -system public 630200280_32_1_not_null system public protected_ts_records CHECK NO NO -system public 630200280_32_2_not_null system public protected_ts_records CHECK NO NO -system public 630200280_32_3_not_null system public protected_ts_records CHECK NO NO -system public 630200280_32_5_not_null system public protected_ts_records CHECK NO NO -system public 630200280_32_6_not_null system public protected_ts_records CHECK NO NO -system public 630200280_32_7_not_null system public protected_ts_records CHECK NO NO -system public primary system public protected_ts_records PRIMARY KEY NO NO -system public 630200280_13_1_not_null system public rangelog CHECK NO NO -system public 630200280_13_2_not_null system public rangelog CHECK NO NO -system public 630200280_13_3_not_null system public rangelog CHECK NO NO -system public 630200280_13_4_not_null system public rangelog CHECK NO NO -system public 630200280_13_7_not_null system public rangelog CHECK NO NO -system public primary system public rangelog PRIMARY KEY NO NO -system public 630200280_25_1_not_null system public replication_constraint_stats CHECK NO NO -system public 630200280_25_2_not_null system public replication_constraint_stats CHECK NO NO -system public 630200280_25_3_not_null system public replication_constraint_stats CHECK NO NO -system public 630200280_25_4_not_null system public replication_constraint_stats CHECK NO NO -system public 630200280_25_5_not_null system public replication_constraint_stats CHECK NO NO -system public 630200280_25_7_not_null system public replication_constraint_stats CHECK NO NO -system public primary system public replication_constraint_stats PRIMARY KEY NO NO -system public 630200280_26_1_not_null system public replication_critical_localities CHECK NO NO -system public 630200280_26_2_not_null system public replication_critical_localities CHECK NO NO -system public 630200280_26_3_not_null system public replication_critical_localities CHECK NO NO -system public 630200280_26_4_not_null system public replication_critical_localities CHECK NO NO -system public 630200280_26_5_not_null system public replication_critical_localities CHECK NO NO -system public primary system public replication_critical_localities PRIMARY KEY NO NO -system public 630200280_27_1_not_null system public replication_stats CHECK NO NO -system public 630200280_27_2_not_null system public replication_stats CHECK NO NO -system public 630200280_27_3_not_null system public replication_stats CHECK NO NO -system public 630200280_27_4_not_null system public replication_stats CHECK NO NO -system public 630200280_27_5_not_null system public replication_stats CHECK NO NO -system public 630200280_27_6_not_null system public replication_stats CHECK NO NO -system public 630200280_27_7_not_null system public replication_stats CHECK NO NO -system public primary system public replication_stats PRIMARY KEY NO NO -system public 630200280_28_1_not_null system public reports_meta CHECK NO NO -system public 630200280_28_2_not_null system public reports_meta CHECK NO NO -system public primary system public reports_meta PRIMARY KEY NO NO -system public 630200280_23_1_not_null system public role_members CHECK NO NO -system public 630200280_23_2_not_null system public role_members CHECK NO NO -system public 630200280_23_3_not_null system public role_members CHECK NO NO -system public primary system public role_members PRIMARY KEY NO NO -system public 630200280_33_1_not_null system public role_options CHECK NO NO -system public 630200280_33_2_not_null system public role_options CHECK NO NO -system public primary system public role_options PRIMARY KEY NO NO -system public 630200280_37_10_not_null system public scheduled_jobs CHECK NO NO -system public 630200280_37_1_not_null system public scheduled_jobs CHECK NO NO -system public 630200280_37_2_not_null system public scheduled_jobs CHECK NO NO -system public 630200280_37_3_not_null system public scheduled_jobs CHECK NO NO -system public 630200280_37_4_not_null system public scheduled_jobs CHECK NO NO -system public 630200280_37_9_not_null system public scheduled_jobs CHECK NO NO -system public primary system public scheduled_jobs PRIMARY KEY NO NO -system public 630200280_6_1_not_null system public settings CHECK NO NO -system public 630200280_6_2_not_null system public settings CHECK NO NO -system public 630200280_6_3_not_null system public settings CHECK NO NO -system public primary system public settings PRIMARY KEY NO NO -system public 630200280_39_1_not_null system public sqlliveness CHECK NO NO -system public 630200280_39_2_not_null system public sqlliveness CHECK NO NO -system public primary system public sqlliveness PRIMARY KEY NO NO -system public 630200280_34_1_not_null system public statement_bundle_chunks CHECK NO NO -system public 630200280_34_3_not_null system public statement_bundle_chunks CHECK NO NO -system public primary system public statement_bundle_chunks PRIMARY KEY NO NO -system public 630200280_36_1_not_null system public statement_diagnostics CHECK NO NO -system public 630200280_36_2_not_null system public statement_diagnostics CHECK NO NO -system public 630200280_36_3_not_null system public statement_diagnostics CHECK NO NO -system public 630200280_36_4_not_null system public statement_diagnostics CHECK NO NO -system public primary system public statement_diagnostics PRIMARY KEY NO NO -system public 630200280_35_1_not_null system public statement_diagnostics_requests CHECK NO NO -system public 630200280_35_2_not_null system public statement_diagnostics_requests CHECK NO NO -system public 630200280_35_3_not_null system public statement_diagnostics_requests CHECK NO NO -system public 630200280_35_5_not_null system public statement_diagnostics_requests CHECK NO NO -system public primary system public statement_diagnostics_requests PRIMARY KEY NO NO -system public 630200280_20_1_not_null system public table_statistics CHECK NO NO -system public 630200280_20_2_not_null system public table_statistics CHECK NO NO -system public 630200280_20_4_not_null system public table_statistics CHECK NO NO -system public 630200280_20_5_not_null system public table_statistics CHECK NO NO -system public 630200280_20_6_not_null system public table_statistics CHECK NO NO -system public 630200280_20_7_not_null system public table_statistics CHECK NO NO -system public 630200280_20_8_not_null system public table_statistics CHECK NO NO -system public primary system public table_statistics PRIMARY KEY NO NO -system public 630200280_8_1_not_null system public tenants CHECK NO NO -system public 630200280_8_2_not_null system public tenants CHECK NO NO -system public primary system public tenants PRIMARY KEY NO NO -system public 630200280_14_1_not_null system public ui CHECK NO NO -system public 630200280_14_3_not_null system public ui CHECK NO NO -system public primary system public ui PRIMARY KEY NO NO -system public 630200280_4_1_not_null system public users CHECK NO NO -system public 630200280_4_3_not_null system public users CHECK NO NO -system public primary system public users PRIMARY KEY NO NO -system public 630200280_19_1_not_null system public web_sessions CHECK NO NO -system public 630200280_19_2_not_null system public web_sessions CHECK NO NO -system public 630200280_19_3_not_null system public web_sessions CHECK NO NO -system public 630200280_19_4_not_null system public web_sessions CHECK NO NO -system public 630200280_19_5_not_null system public web_sessions CHECK NO NO -system public 630200280_19_7_not_null system public web_sessions CHECK NO NO -system public primary system public web_sessions PRIMARY KEY NO NO -system public 630200280_5_1_not_null system public zones CHECK NO NO -system public primary system public zones PRIMARY KEY NO NO +constraint_catalog constraint_schema constraint_name table_catalog table_schema table_name constraint_type is_deferrable initially_deferred +system public 630200280_24_1_not_null system public comments CHECK NO NO +system public 630200280_24_2_not_null system public comments CHECK NO NO +system public 630200280_24_3_not_null system public comments CHECK NO NO +system public 630200280_24_4_not_null system public comments CHECK NO NO +system public primary system public comments PRIMARY KEY NO NO +system public 630200280_3_1_not_null system public descriptor CHECK NO NO +system public primary system public descriptor PRIMARY KEY NO NO +system public 630200280_12_1_not_null system public eventlog CHECK NO NO +system public 630200280_12_2_not_null system public eventlog CHECK NO NO +system public 630200280_12_3_not_null system public eventlog CHECK NO NO +system public 630200280_12_4_not_null system public eventlog CHECK NO NO +system public 630200280_12_6_not_null system public eventlog CHECK NO NO +system public primary system public eventlog PRIMARY KEY NO NO +system public 630200280_15_1_not_null system public jobs CHECK NO NO +system public 630200280_15_2_not_null system public jobs CHECK NO NO +system public 630200280_15_3_not_null system public jobs CHECK NO NO +system public 630200280_15_4_not_null system public jobs CHECK NO NO +system public primary system public jobs PRIMARY KEY NO NO +system public 630200280_41_1_not_null system public join_tokens CHECK NO NO +system public 630200280_41_2_not_null system public join_tokens CHECK NO NO +system public 630200280_41_3_not_null system public join_tokens CHECK NO NO +system public primary system public join_tokens PRIMARY KEY NO NO +system public 630200280_11_1_not_null system public lease CHECK NO NO +system public 630200280_11_2_not_null system public lease CHECK NO NO +system public 630200280_11_3_not_null system public lease CHECK NO NO +system public 630200280_11_4_not_null system public lease CHECK NO NO +system public primary system public lease PRIMARY KEY NO NO +system public 630200280_21_1_not_null system public locations CHECK NO NO +system public 630200280_21_2_not_null system public locations CHECK NO NO +system public 630200280_21_3_not_null system public locations CHECK NO NO +system public 630200280_21_4_not_null system public locations CHECK NO NO +system public primary system public locations PRIMARY KEY NO NO +system public 630200280_40_1_not_null system public migrations CHECK NO NO +system public 630200280_40_2_not_null system public migrations CHECK NO NO +system public 630200280_40_3_not_null system public migrations CHECK NO NO +system public 630200280_40_4_not_null system public migrations CHECK NO NO +system public 630200280_40_5_not_null system public migrations CHECK NO NO +system public primary system public migrations PRIMARY KEY NO NO +system public 630200280_2_1_not_null system public namespace CHECK NO NO +system public 630200280_2_2_not_null system public namespace CHECK NO NO +system public primary system public namespace PRIMARY KEY NO NO +system public 630200280_30_1_not_null system public namespace2 CHECK NO NO +system public 630200280_30_2_not_null system public namespace2 CHECK NO NO +system public 630200280_30_3_not_null system public namespace2 CHECK NO NO +system public primary system public namespace2 PRIMARY KEY NO NO +system public 630200280_31_1_not_null system public protected_ts_meta CHECK NO NO +system public 630200280_31_2_not_null system public protected_ts_meta CHECK NO NO +system public 630200280_31_3_not_null system public protected_ts_meta CHECK NO NO +system public 630200280_31_4_not_null system public protected_ts_meta CHECK NO NO +system public 630200280_31_5_not_null system public protected_ts_meta CHECK NO NO +system public check_singleton system public protected_ts_meta CHECK NO NO +system public primary system public protected_ts_meta PRIMARY KEY NO NO +system public 630200280_32_1_not_null system public protected_ts_records CHECK NO NO +system public 630200280_32_2_not_null system public protected_ts_records CHECK NO NO +system public 630200280_32_3_not_null system public protected_ts_records CHECK NO NO +system public 630200280_32_5_not_null system public protected_ts_records CHECK NO NO +system public 630200280_32_6_not_null system public protected_ts_records CHECK NO NO +system public 630200280_32_7_not_null system public protected_ts_records CHECK NO NO +system public primary system public protected_ts_records PRIMARY KEY NO NO +system public 630200280_13_1_not_null system public rangelog CHECK NO NO +system public 630200280_13_2_not_null system public rangelog CHECK NO NO +system public 630200280_13_3_not_null system public rangelog CHECK NO NO +system public 630200280_13_4_not_null system public rangelog CHECK NO NO +system public 630200280_13_7_not_null system public rangelog CHECK NO NO +system public primary system public rangelog PRIMARY KEY NO NO +system public 630200280_25_1_not_null system public replication_constraint_stats CHECK NO NO +system public 630200280_25_2_not_null system public replication_constraint_stats CHECK NO NO +system public 630200280_25_3_not_null system public replication_constraint_stats CHECK NO NO +system public 630200280_25_4_not_null system public replication_constraint_stats CHECK NO NO +system public 630200280_25_5_not_null system public replication_constraint_stats CHECK NO NO +system public 630200280_25_7_not_null system public replication_constraint_stats CHECK NO NO +system public primary system public replication_constraint_stats PRIMARY KEY NO NO +system public 630200280_26_1_not_null system public replication_critical_localities CHECK NO NO +system public 630200280_26_2_not_null system public replication_critical_localities CHECK NO NO +system public 630200280_26_3_not_null system public replication_critical_localities CHECK NO NO +system public 630200280_26_4_not_null system public replication_critical_localities CHECK NO NO +system public 630200280_26_5_not_null system public replication_critical_localities CHECK NO NO +system public primary system public replication_critical_localities PRIMARY KEY NO NO +system public 630200280_27_1_not_null system public replication_stats CHECK NO NO +system public 630200280_27_2_not_null system public replication_stats CHECK NO NO +system public 630200280_27_3_not_null system public replication_stats CHECK NO NO +system public 630200280_27_4_not_null system public replication_stats CHECK NO NO +system public 630200280_27_5_not_null system public replication_stats CHECK NO NO +system public 630200280_27_6_not_null system public replication_stats CHECK NO NO +system public 630200280_27_7_not_null system public replication_stats CHECK NO NO +system public primary system public replication_stats PRIMARY KEY NO NO +system public 630200280_28_1_not_null system public reports_meta CHECK NO NO +system public 630200280_28_2_not_null system public reports_meta CHECK NO NO +system public primary system public reports_meta PRIMARY KEY NO NO +system public 630200280_23_1_not_null system public role_members CHECK NO NO +system public 630200280_23_2_not_null system public role_members CHECK NO NO +system public 630200280_23_3_not_null system public role_members CHECK NO NO +system public primary system public role_members PRIMARY KEY NO NO +system public 630200280_33_1_not_null system public role_options CHECK NO NO +system public 630200280_33_2_not_null system public role_options CHECK NO NO +system public primary system public role_options PRIMARY KEY NO NO +system public 630200280_37_10_not_null system public scheduled_jobs CHECK NO NO +system public 630200280_37_1_not_null system public scheduled_jobs CHECK NO NO +system public 630200280_37_2_not_null system public scheduled_jobs CHECK NO NO +system public 630200280_37_3_not_null system public scheduled_jobs CHECK NO NO +system public 630200280_37_4_not_null system public scheduled_jobs CHECK NO NO +system public 630200280_37_9_not_null system public scheduled_jobs CHECK NO NO +system public primary system public scheduled_jobs PRIMARY KEY NO NO +system public 630200280_6_1_not_null system public settings CHECK NO NO +system public 630200280_6_2_not_null system public settings CHECK NO NO +system public 630200280_6_3_not_null system public settings CHECK NO NO +system public primary system public settings PRIMARY KEY NO NO +system public 630200280_42_10_not_null system public sql_statement_stats CHECK NO NO +system public 630200280_42_11_not_null system public sql_statement_stats CHECK NO NO +system public 630200280_42_1_not_null system public sql_statement_stats CHECK NO NO +system public 630200280_42_2_not_null system public sql_statement_stats CHECK NO NO +system public 630200280_42_3_not_null system public sql_statement_stats CHECK NO NO +system public 630200280_42_4_not_null system public sql_statement_stats CHECK NO NO +system public 630200280_42_5_not_null system public sql_statement_stats CHECK NO NO +system public 630200280_42_6_not_null system public sql_statement_stats CHECK NO NO +system public 630200280_42_7_not_null system public sql_statement_stats CHECK NO NO +system public 630200280_42_8_not_null system public sql_statement_stats CHECK NO NO +system public 630200280_42_9_not_null system public sql_statement_stats CHECK NO NO +system public check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8 system public sql_statement_stats CHECK NO NO +system public primary system public sql_statement_stats PRIMARY KEY NO NO +system public 630200280_43_1_not_null system public sql_transaction_stats CHECK NO NO +system public 630200280_43_2_not_null system public sql_transaction_stats CHECK NO NO +system public 630200280_43_3_not_null system public sql_transaction_stats CHECK NO NO +system public 630200280_43_4_not_null system public sql_transaction_stats CHECK NO NO +system public 630200280_43_5_not_null system public sql_transaction_stats CHECK NO NO +system public 630200280_43_6_not_null system public sql_transaction_stats CHECK NO NO +system public 630200280_43_7_not_null system public sql_transaction_stats CHECK NO NO +system public 630200280_43_8_not_null system public sql_transaction_stats CHECK NO NO +system public 630200280_43_9_not_null system public sql_transaction_stats CHECK NO NO +system public check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8 system public sql_transaction_stats CHECK NO NO +system public primary system public sql_transaction_stats PRIMARY KEY NO NO +system public 630200280_39_1_not_null system public sqlliveness CHECK NO NO +system public 630200280_39_2_not_null system public sqlliveness CHECK NO NO +system public primary system public sqlliveness PRIMARY KEY NO NO +system public 630200280_34_1_not_null system public statement_bundle_chunks CHECK NO NO +system public 630200280_34_3_not_null system public statement_bundle_chunks CHECK NO NO +system public primary system public statement_bundle_chunks PRIMARY KEY NO NO +system public 630200280_36_1_not_null system public statement_diagnostics CHECK NO NO +system public 630200280_36_2_not_null system public statement_diagnostics CHECK NO NO +system public 630200280_36_3_not_null system public statement_diagnostics CHECK NO NO +system public 630200280_36_4_not_null system public statement_diagnostics CHECK NO NO +system public primary system public statement_diagnostics PRIMARY KEY NO NO +system public 630200280_35_1_not_null system public statement_diagnostics_requests CHECK NO NO +system public 630200280_35_2_not_null system public statement_diagnostics_requests CHECK NO NO +system public 630200280_35_3_not_null system public statement_diagnostics_requests CHECK NO NO +system public 630200280_35_5_not_null system public statement_diagnostics_requests CHECK NO NO +system public primary system public statement_diagnostics_requests PRIMARY KEY NO NO +system public 630200280_20_1_not_null system public table_statistics CHECK NO NO +system public 630200280_20_2_not_null system public table_statistics CHECK NO NO +system public 630200280_20_4_not_null system public table_statistics CHECK NO NO +system public 630200280_20_5_not_null system public table_statistics CHECK NO NO +system public 630200280_20_6_not_null system public table_statistics CHECK NO NO +system public 630200280_20_7_not_null system public table_statistics CHECK NO NO +system public 630200280_20_8_not_null system public table_statistics CHECK NO NO +system public primary system public table_statistics PRIMARY KEY NO NO +system public 630200280_8_1_not_null system public tenants CHECK NO NO +system public 630200280_8_2_not_null system public tenants CHECK NO NO +system public primary system public tenants PRIMARY KEY NO NO +system public 630200280_14_1_not_null system public ui CHECK NO NO +system public 630200280_14_3_not_null system public ui CHECK NO NO +system public primary system public ui PRIMARY KEY NO NO +system public 630200280_4_1_not_null system public users CHECK NO NO +system public 630200280_4_3_not_null system public users CHECK NO NO +system public primary system public users PRIMARY KEY NO NO +system public 630200280_19_1_not_null system public web_sessions CHECK NO NO +system public 630200280_19_2_not_null system public web_sessions CHECK NO NO +system public 630200280_19_3_not_null system public web_sessions CHECK NO NO +system public 630200280_19_4_not_null system public web_sessions CHECK NO NO +system public 630200280_19_5_not_null system public web_sessions CHECK NO NO +system public 630200280_19_7_not_null system public web_sessions CHECK NO NO +system public primary system public web_sessions PRIMARY KEY NO NO +system public 630200280_5_1_not_null system public zones CHECK NO NO +system public primary system public zones PRIMARY KEY NO NO query TTTTTTTT colnames SELECT * @@ -1128,187 +1154,220 @@ SELECT * FROM system.information_schema.check_constraints ORDER BY CONSTRAINT_CATALOG, CONSTRAINT_NAME ---- -constraint_catalog constraint_schema constraint_name check_clause -system public 630200280_11_1_not_null descID IS NOT NULL -system public 630200280_11_2_not_null version IS NOT NULL -system public 630200280_11_3_not_null nodeID IS NOT NULL -system public 630200280_11_4_not_null expiration IS NOT NULL -system public 630200280_12_1_not_null timestamp IS NOT NULL -system public 630200280_12_2_not_null eventType IS NOT NULL -system public 630200280_12_3_not_null targetID IS NOT NULL -system public 630200280_12_4_not_null reportingID IS NOT NULL -system public 630200280_12_6_not_null uniqueID IS NOT NULL -system public 630200280_13_1_not_null timestamp IS NOT NULL -system public 630200280_13_2_not_null rangeID IS NOT NULL -system public 630200280_13_3_not_null storeID IS NOT NULL -system public 630200280_13_4_not_null eventType IS NOT NULL -system public 630200280_13_7_not_null uniqueID IS NOT NULL -system public 630200280_14_1_not_null key IS NOT NULL -system public 630200280_14_3_not_null lastUpdated IS NOT NULL -system public 630200280_15_1_not_null id IS NOT NULL -system public 630200280_15_2_not_null status IS NOT NULL -system public 630200280_15_3_not_null created IS NOT NULL -system public 630200280_15_4_not_null payload IS NOT NULL -system public 630200280_19_1_not_null id IS NOT NULL -system public 630200280_19_2_not_null hashedSecret IS NOT NULL -system public 630200280_19_3_not_null username IS NOT NULL -system public 630200280_19_4_not_null createdAt IS NOT NULL -system public 630200280_19_5_not_null expiresAt IS NOT NULL -system public 630200280_19_7_not_null lastUsedAt IS NOT NULL -system public 630200280_20_1_not_null tableID IS NOT NULL -system public 630200280_20_2_not_null statisticID IS NOT NULL -system public 630200280_20_4_not_null columnIDs IS NOT NULL -system public 630200280_20_5_not_null createdAt IS NOT NULL -system public 630200280_20_6_not_null rowCount IS NOT NULL -system public 630200280_20_7_not_null distinctCount IS NOT NULL -system public 630200280_20_8_not_null nullCount IS NOT NULL -system public 630200280_21_1_not_null localityKey IS NOT NULL -system public 630200280_21_2_not_null localityValue IS NOT NULL -system public 630200280_21_3_not_null latitude IS NOT NULL -system public 630200280_21_4_not_null longitude IS NOT NULL -system public 630200280_23_1_not_null role IS NOT NULL -system public 630200280_23_2_not_null member IS NOT NULL -system public 630200280_23_3_not_null isAdmin IS NOT NULL -system public 630200280_24_1_not_null type IS NOT NULL -system public 630200280_24_2_not_null object_id IS NOT NULL -system public 630200280_24_3_not_null sub_id IS NOT NULL -system public 630200280_24_4_not_null comment IS NOT NULL -system public 630200280_25_1_not_null zone_id IS NOT NULL -system public 630200280_25_2_not_null subzone_id IS NOT NULL -system public 630200280_25_3_not_null type IS NOT NULL -system public 630200280_25_4_not_null config IS NOT NULL -system public 630200280_25_5_not_null report_id IS NOT NULL -system public 630200280_25_7_not_null violating_ranges IS NOT NULL -system public 630200280_26_1_not_null zone_id IS NOT NULL -system public 630200280_26_2_not_null subzone_id IS NOT NULL -system public 630200280_26_3_not_null locality IS NOT NULL -system public 630200280_26_4_not_null report_id IS NOT NULL -system public 630200280_26_5_not_null at_risk_ranges IS NOT NULL -system public 630200280_27_1_not_null zone_id IS NOT NULL -system public 630200280_27_2_not_null subzone_id IS NOT NULL -system public 630200280_27_3_not_null report_id IS NOT NULL -system public 630200280_27_4_not_null total_ranges IS NOT NULL -system public 630200280_27_5_not_null unavailable_ranges IS NOT NULL -system public 630200280_27_6_not_null under_replicated_ranges IS NOT NULL -system public 630200280_27_7_not_null over_replicated_ranges IS NOT NULL -system public 630200280_28_1_not_null id IS NOT NULL -system public 630200280_28_2_not_null generated IS NOT NULL -system public 630200280_2_1_not_null parentID IS NOT NULL -system public 630200280_2_2_not_null name IS NOT NULL -system public 630200280_30_1_not_null parentID IS NOT NULL -system public 630200280_30_2_not_null parentSchemaID IS NOT NULL -system public 630200280_30_3_not_null name IS NOT NULL -system public 630200280_31_1_not_null singleton IS NOT NULL -system public 630200280_31_2_not_null version IS NOT NULL -system public 630200280_31_3_not_null num_records IS NOT NULL -system public 630200280_31_4_not_null num_spans IS NOT NULL -system public 630200280_31_5_not_null total_bytes IS NOT NULL -system public 630200280_32_1_not_null id IS NOT NULL -system public 630200280_32_2_not_null ts IS NOT NULL -system public 630200280_32_3_not_null meta_type IS NOT NULL -system public 630200280_32_5_not_null num_spans IS NOT NULL -system public 630200280_32_6_not_null spans IS NOT NULL -system public 630200280_32_7_not_null verified IS NOT NULL -system public 630200280_33_1_not_null username IS NOT NULL -system public 630200280_33_2_not_null option IS NOT NULL -system public 630200280_34_1_not_null id IS NOT NULL -system public 630200280_34_3_not_null data IS NOT NULL -system public 630200280_35_1_not_null id IS NOT NULL -system public 630200280_35_2_not_null completed IS NOT NULL -system public 630200280_35_3_not_null statement_fingerprint IS NOT NULL -system public 630200280_35_5_not_null requested_at IS NOT NULL -system public 630200280_36_1_not_null id IS NOT NULL -system public 630200280_36_2_not_null statement_fingerprint IS NOT NULL -system public 630200280_36_3_not_null statement IS NOT NULL -system public 630200280_36_4_not_null collected_at IS NOT NULL -system public 630200280_37_10_not_null execution_args IS NOT NULL -system public 630200280_37_1_not_null schedule_id IS NOT NULL -system public 630200280_37_2_not_null schedule_name IS NOT NULL -system public 630200280_37_3_not_null created IS NOT NULL -system public 630200280_37_4_not_null owner IS NOT NULL -system public 630200280_37_9_not_null executor_type IS NOT NULL -system public 630200280_39_1_not_null session_id IS NOT NULL -system public 630200280_39_2_not_null expiration IS NOT NULL -system public 630200280_3_1_not_null id IS NOT NULL -system public 630200280_40_1_not_null major IS NOT NULL -system public 630200280_40_2_not_null minor IS NOT NULL -system public 630200280_40_3_not_null patch IS NOT NULL -system public 630200280_40_4_not_null internal IS NOT NULL -system public 630200280_40_5_not_null completed_at IS NOT NULL -system public 630200280_41_1_not_null id IS NOT NULL -system public 630200280_41_2_not_null secret IS NOT NULL -system public 630200280_41_3_not_null expiration IS NOT NULL -system public 630200280_4_1_not_null username IS NOT NULL -system public 630200280_4_3_not_null isRole IS NOT NULL -system public 630200280_5_1_not_null id IS NOT NULL -system public 630200280_6_1_not_null name IS NOT NULL -system public 630200280_6_2_not_null value IS NOT NULL -system public 630200280_6_3_not_null lastUpdated IS NOT NULL -system public 630200280_8_1_not_null id IS NOT NULL -system public 630200280_8_2_not_null active IS NOT NULL -system public check_singleton ((singleton)) +constraint_catalog constraint_schema constraint_name check_clause +system public 630200280_11_1_not_null descID IS NOT NULL +system public 630200280_11_2_not_null version IS NOT NULL +system public 630200280_11_3_not_null nodeID IS NOT NULL +system public 630200280_11_4_not_null expiration IS NOT NULL +system public 630200280_12_1_not_null timestamp IS NOT NULL +system public 630200280_12_2_not_null eventType IS NOT NULL +system public 630200280_12_3_not_null targetID IS NOT NULL +system public 630200280_12_4_not_null reportingID IS NOT NULL +system public 630200280_12_6_not_null uniqueID IS NOT NULL +system public 630200280_13_1_not_null timestamp IS NOT NULL +system public 630200280_13_2_not_null rangeID IS NOT NULL +system public 630200280_13_3_not_null storeID IS NOT NULL +system public 630200280_13_4_not_null eventType IS NOT NULL +system public 630200280_13_7_not_null uniqueID IS NOT NULL +system public 630200280_14_1_not_null key IS NOT NULL +system public 630200280_14_3_not_null lastUpdated IS NOT NULL +system public 630200280_15_1_not_null id IS NOT NULL +system public 630200280_15_2_not_null status IS NOT NULL +system public 630200280_15_3_not_null created IS NOT NULL +system public 630200280_15_4_not_null payload IS NOT NULL +system public 630200280_19_1_not_null id IS NOT NULL +system public 630200280_19_2_not_null hashedSecret IS NOT NULL +system public 630200280_19_3_not_null username IS NOT NULL +system public 630200280_19_4_not_null createdAt IS NOT NULL +system public 630200280_19_5_not_null expiresAt IS NOT NULL +system public 630200280_19_7_not_null lastUsedAt IS NOT NULL +system public 630200280_20_1_not_null tableID IS NOT NULL +system public 630200280_20_2_not_null statisticID IS NOT NULL +system public 630200280_20_4_not_null columnIDs IS NOT NULL +system public 630200280_20_5_not_null createdAt IS NOT NULL +system public 630200280_20_6_not_null rowCount IS NOT NULL +system public 630200280_20_7_not_null distinctCount IS NOT NULL +system public 630200280_20_8_not_null nullCount IS NOT NULL +system public 630200280_21_1_not_null localityKey IS NOT NULL +system public 630200280_21_2_not_null localityValue IS NOT NULL +system public 630200280_21_3_not_null latitude IS NOT NULL +system public 630200280_21_4_not_null longitude IS NOT NULL +system public 630200280_23_1_not_null role IS NOT NULL +system public 630200280_23_2_not_null member IS NOT NULL +system public 630200280_23_3_not_null isAdmin IS NOT NULL +system public 630200280_24_1_not_null type IS NOT NULL +system public 630200280_24_2_not_null object_id IS NOT NULL +system public 630200280_24_3_not_null sub_id IS NOT NULL +system public 630200280_24_4_not_null comment IS NOT NULL +system public 630200280_25_1_not_null zone_id IS NOT NULL +system public 630200280_25_2_not_null subzone_id IS NOT NULL +system public 630200280_25_3_not_null type IS NOT NULL +system public 630200280_25_4_not_null config IS NOT NULL +system public 630200280_25_5_not_null report_id IS NOT NULL +system public 630200280_25_7_not_null violating_ranges IS NOT NULL +system public 630200280_26_1_not_null zone_id IS NOT NULL +system public 630200280_26_2_not_null subzone_id IS NOT NULL +system public 630200280_26_3_not_null locality IS NOT NULL +system public 630200280_26_4_not_null report_id IS NOT NULL +system public 630200280_26_5_not_null at_risk_ranges IS NOT NULL +system public 630200280_27_1_not_null zone_id IS NOT NULL +system public 630200280_27_2_not_null subzone_id IS NOT NULL +system public 630200280_27_3_not_null report_id IS NOT NULL +system public 630200280_27_4_not_null total_ranges IS NOT NULL +system public 630200280_27_5_not_null unavailable_ranges IS NOT NULL +system public 630200280_27_6_not_null under_replicated_ranges IS NOT NULL +system public 630200280_27_7_not_null over_replicated_ranges IS NOT NULL +system public 630200280_28_1_not_null id IS NOT NULL +system public 630200280_28_2_not_null generated IS NOT NULL +system public 630200280_2_1_not_null parentID IS NOT NULL +system public 630200280_2_2_not_null name IS NOT NULL +system public 630200280_30_1_not_null parentID IS NOT NULL +system public 630200280_30_2_not_null parentSchemaID IS NOT NULL +system public 630200280_30_3_not_null name IS NOT NULL +system public 630200280_31_1_not_null singleton IS NOT NULL +system public 630200280_31_2_not_null version IS NOT NULL +system public 630200280_31_3_not_null num_records IS NOT NULL +system public 630200280_31_4_not_null num_spans IS NOT NULL +system public 630200280_31_5_not_null total_bytes IS NOT NULL +system public 630200280_32_1_not_null id IS NOT NULL +system public 630200280_32_2_not_null ts IS NOT NULL +system public 630200280_32_3_not_null meta_type IS NOT NULL +system public 630200280_32_5_not_null num_spans IS NOT NULL +system public 630200280_32_6_not_null spans IS NOT NULL +system public 630200280_32_7_not_null verified IS NOT NULL +system public 630200280_33_1_not_null username IS NOT NULL +system public 630200280_33_2_not_null option IS NOT NULL +system public 630200280_34_1_not_null id IS NOT NULL +system public 630200280_34_3_not_null data IS NOT NULL +system public 630200280_35_1_not_null id IS NOT NULL +system public 630200280_35_2_not_null completed IS NOT NULL +system public 630200280_35_3_not_null statement_fingerprint IS NOT NULL +system public 630200280_35_5_not_null requested_at IS NOT NULL +system public 630200280_36_1_not_null id IS NOT NULL +system public 630200280_36_2_not_null statement_fingerprint IS NOT NULL +system public 630200280_36_3_not_null statement IS NOT NULL +system public 630200280_36_4_not_null collected_at IS NOT NULL +system public 630200280_37_10_not_null execution_args IS NOT NULL +system public 630200280_37_1_not_null schedule_id IS NOT NULL +system public 630200280_37_2_not_null schedule_name IS NOT NULL +system public 630200280_37_3_not_null created IS NOT NULL +system public 630200280_37_4_not_null owner IS NOT NULL +system public 630200280_37_9_not_null executor_type IS NOT NULL +system public 630200280_39_1_not_null session_id IS NOT NULL +system public 630200280_39_2_not_null expiration IS NOT NULL +system public 630200280_3_1_not_null id IS NOT NULL +system public 630200280_40_1_not_null major IS NOT NULL +system public 630200280_40_2_not_null minor IS NOT NULL +system public 630200280_40_3_not_null patch IS NOT NULL +system public 630200280_40_4_not_null internal IS NOT NULL +system public 630200280_40_5_not_null completed_at IS NOT NULL +system public 630200280_41_1_not_null id IS NOT NULL +system public 630200280_41_2_not_null secret IS NOT NULL +system public 630200280_41_3_not_null expiration IS NOT NULL +system public 630200280_42_10_not_null plan IS NOT NULL +system public 630200280_42_1_not_null aggregated_ts IS NOT NULL +system public 630200280_42_2_not_null fingerprint_id IS NOT NULL +system public 630200280_42_3_not_null plan_hash IS NOT NULL +system public 630200280_42_4_not_null app_name IS NOT NULL +system public 630200280_42_5_not_null node_id IS NOT NULL +system public 630200280_42_6_not_null count IS NOT NULL +system public 630200280_42_7_not_null agg_interval IS NOT NULL +system public 630200280_42_8_not_null metadata IS NOT NULL +system public 630200280_42_9_not_null statistics IS NOT NULL +system public 630200280_43_1_not_null aggregated_ts IS NOT NULL +system public 630200280_43_2_not_null fingerprint_id IS NOT NULL +system public 630200280_43_3_not_null app_name IS NOT NULL +system public 630200280_43_4_not_null node_id IS NOT NULL +system public 630200280_43_5_not_null count IS NOT NULL +system public 630200280_43_6_not_null agg_interval IS NOT NULL +system public 630200280_43_7_not_null metadata IS NOT NULL +system public 630200280_43_8_not_null statistics IS NOT NULL +system public 630200280_4_1_not_null username IS NOT NULL +system public 630200280_4_3_not_null isRole IS NOT NULL +system public 630200280_5_1_not_null id IS NOT NULL +system public 630200280_6_1_not_null name IS NOT NULL +system public 630200280_6_2_not_null value IS NOT NULL +system public 630200280_6_3_not_null lastUpdated IS NOT NULL +system public 630200280_8_1_not_null id IS NOT NULL +system public 630200280_8_2_not_null active IS NOT NULL +system public check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8 ((crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8))) +system public check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8 ((crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8))) +system public check_singleton ((singleton)) query TTTTTTT colnames SELECT * FROM system.information_schema.constraint_column_usage ORDER BY TABLE_NAME, COLUMN_NAME, CONSTRAINT_NAME ---- -table_catalog table_schema table_name column_name constraint_catalog constraint_schema constraint_name -system public comments object_id system public primary -system public comments sub_id system public primary -system public comments type system public primary -system public descriptor id system public primary -system public eventlog timestamp system public primary -system public eventlog uniqueID system public primary -system public jobs id system public primary -system public join_tokens id system public primary -system public lease descID system public primary -system public lease expiration system public primary -system public lease nodeID system public primary -system public lease version system public primary -system public locations localityKey system public primary -system public locations localityValue system public primary -system public migrations internal system public primary -system public migrations major system public primary -system public migrations minor system public primary -system public migrations patch system public primary -system public namespace name system public primary -system public namespace parentID system public primary -system public namespace2 name system public primary -system public namespace2 parentID system public primary -system public namespace2 parentSchemaID system public primary -system public protected_ts_meta singleton system public check_singleton -system public protected_ts_meta singleton system public primary -system public protected_ts_records id system public primary -system public rangelog timestamp system public primary -system public rangelog uniqueID system public primary -system public replication_constraint_stats config system public primary -system public replication_constraint_stats subzone_id system public primary -system public replication_constraint_stats type system public primary -system public replication_constraint_stats zone_id system public primary -system public replication_critical_localities locality system public primary -system public replication_critical_localities subzone_id system public primary -system public replication_critical_localities zone_id system public primary -system public replication_stats subzone_id system public primary -system public replication_stats zone_id system public primary -system public reports_meta id system public primary -system public role_members member system public primary -system public role_members role system public primary -system public role_options option system public primary -system public role_options username system public primary -system public scheduled_jobs schedule_id system public primary -system public settings name system public primary -system public sqlliveness session_id system public primary -system public statement_bundle_chunks id system public primary -system public statement_diagnostics id system public primary -system public statement_diagnostics_requests id system public primary -system public table_statistics statisticID system public primary -system public table_statistics tableID system public primary -system public tenants id system public primary -system public ui key system public primary -system public users username system public primary -system public web_sessions id system public primary -system public zones id system public primary +table_catalog table_schema table_name column_name constraint_catalog constraint_schema constraint_name +system public comments object_id system public primary +system public comments sub_id system public primary +system public comments type system public primary +system public descriptor id system public primary +system public eventlog timestamp system public primary +system public eventlog uniqueID system public primary +system public jobs id system public primary +system public join_tokens id system public primary +system public lease descID system public primary +system public lease expiration system public primary +system public lease nodeID system public primary +system public lease version system public primary +system public locations localityKey system public primary +system public locations localityValue system public primary +system public migrations internal system public primary +system public migrations major system public primary +system public migrations minor system public primary +system public migrations patch system public primary +system public namespace name system public primary +system public namespace parentID system public primary +system public namespace2 name system public primary +system public namespace2 parentID system public primary +system public namespace2 parentSchemaID system public primary +system public protected_ts_meta singleton system public check_singleton +system public protected_ts_meta singleton system public primary +system public protected_ts_records id system public primary +system public rangelog timestamp system public primary +system public rangelog uniqueID system public primary +system public replication_constraint_stats config system public primary +system public replication_constraint_stats subzone_id system public primary +system public replication_constraint_stats type system public primary +system public replication_constraint_stats zone_id system public primary +system public replication_critical_localities locality system public primary +system public replication_critical_localities subzone_id system public primary +system public replication_critical_localities zone_id system public primary +system public replication_stats subzone_id system public primary +system public replication_stats zone_id system public primary +system public reports_meta id system public primary +system public role_members member system public primary +system public role_members role system public primary +system public role_options option system public primary +system public role_options username system public primary +system public scheduled_jobs schedule_id system public primary +system public settings name system public primary +system public sql_statement_stats aggregated_ts system public primary +system public sql_statement_stats app_name system public primary +system public sql_statement_stats crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8 system public check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8 +system public sql_statement_stats crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8 system public primary +system public sql_statement_stats fingerprint_id system public primary +system public sql_statement_stats node_id system public primary +system public sql_statement_stats plan_hash system public primary +system public sql_transaction_stats aggregated_ts system public primary +system public sql_transaction_stats app_name system public primary +system public sql_transaction_stats crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8 system public check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8 +system public sql_transaction_stats crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8 system public primary +system public sql_transaction_stats fingerprint_id system public primary +system public sql_transaction_stats node_id system public primary +system public sqlliveness session_id system public primary +system public statement_bundle_chunks id system public primary +system public statement_diagnostics id system public primary +system public statement_diagnostics_requests id system public primary +system public table_statistics statisticID system public primary +system public table_statistics tableID system public primary +system public tenants id system public primary +system public ui key system public primary +system public users username system public primary +system public web_sessions id system public primary +system public zones id system public primary statement ok CREATE DATABASE constraint_db @@ -1392,175 +1451,195 @@ FROM system.information_schema.columns WHERE table_schema != 'information_schema' AND table_schema != 'pg_catalog' AND table_schema != 'crdb_internal' ORDER BY 3,4 ---- -table_catalog table_schema table_name column_name ordinal_position -system public comments comment 4 -system public comments object_id 2 -system public comments sub_id 3 -system public comments type 1 -system public descriptor descriptor 2 -system public descriptor id 1 -system public eventlog eventType 2 -system public eventlog info 5 -system public eventlog reportingID 4 -system public eventlog targetID 3 -system public eventlog timestamp 1 -system public eventlog uniqueID 6 -system pg_extension geography_columns coord_dimension 5 -system pg_extension geography_columns f_geography_column 4 -system pg_extension geography_columns f_table_catalog 1 -system pg_extension geography_columns f_table_name 3 -system pg_extension geography_columns f_table_schema 2 -system pg_extension geography_columns srid 6 -system pg_extension geography_columns type 7 -system pg_extension geometry_columns coord_dimension 5 -system pg_extension geometry_columns f_geometry_column 4 -system pg_extension geometry_columns f_table_catalog 1 -system pg_extension geometry_columns f_table_name 3 -system pg_extension geometry_columns f_table_schema 2 -system pg_extension geometry_columns srid 6 -system pg_extension geometry_columns type 7 -system public jobs claim_instance_id 9 -system public jobs claim_session_id 8 -system public jobs created 3 -system public jobs created_by_id 7 -system public jobs created_by_type 6 -system public jobs id 1 -system public jobs payload 4 -system public jobs progress 5 -system public jobs status 2 -system public join_tokens expiration 3 -system public join_tokens id 1 -system public join_tokens secret 2 -system public lease descID 1 -system public lease expiration 4 -system public lease nodeID 3 -system public lease version 2 -system public locations latitude 3 -system public locations localityKey 1 -system public locations localityValue 2 -system public locations longitude 4 -system public migrations completed_at 5 -system public migrations internal 4 -system public migrations major 1 -system public migrations minor 2 -system public migrations patch 3 -system public namespace id 3 -system public namespace name 2 -system public namespace parentID 1 -system public namespace2 id 4 -system public namespace2 name 3 -system public namespace2 parentID 1 -system public namespace2 parentSchemaID 2 -system public protected_ts_meta num_records 3 -system public protected_ts_meta num_spans 4 -system public protected_ts_meta singleton 1 -system public protected_ts_meta total_bytes 5 -system public protected_ts_meta version 2 -system public protected_ts_records id 1 -system public protected_ts_records meta 4 -system public protected_ts_records meta_type 3 -system public protected_ts_records num_spans 5 -system public protected_ts_records spans 6 -system public protected_ts_records ts 2 -system public protected_ts_records verified 7 -system public rangelog eventType 4 -system public rangelog info 6 -system public rangelog otherRangeID 5 -system public rangelog rangeID 2 -system public rangelog storeID 3 -system public rangelog timestamp 1 -system public rangelog uniqueID 7 -system public replication_constraint_stats config 4 -system public replication_constraint_stats report_id 5 -system public replication_constraint_stats subzone_id 2 -system public replication_constraint_stats type 3 -system public replication_constraint_stats violating_ranges 7 -system public replication_constraint_stats violation_start 6 -system public replication_constraint_stats zone_id 1 -system public replication_critical_localities at_risk_ranges 5 -system public replication_critical_localities locality 3 -system public replication_critical_localities report_id 4 -system public replication_critical_localities subzone_id 2 -system public replication_critical_localities zone_id 1 -system public replication_stats over_replicated_ranges 7 -system public replication_stats report_id 3 -system public replication_stats subzone_id 2 -system public replication_stats total_ranges 4 -system public replication_stats unavailable_ranges 5 -system public replication_stats under_replicated_ranges 6 -system public replication_stats zone_id 1 -system public reports_meta generated 2 -system public reports_meta id 1 -system public role_members isAdmin 3 -system public role_members member 2 -system public role_members role 1 -system public role_options option 2 -system public role_options username 1 -system public role_options value 3 -system public scheduled_jobs created 3 -system public scheduled_jobs execution_args 10 -system public scheduled_jobs executor_type 9 -system public scheduled_jobs next_run 5 -system public scheduled_jobs owner 4 -system public scheduled_jobs schedule_details 8 -system public scheduled_jobs schedule_expr 7 -system public scheduled_jobs schedule_id 1 -system public scheduled_jobs schedule_name 2 -system public scheduled_jobs schedule_state 6 -system public settings lastUpdated 3 -system public settings name 1 -system public settings value 2 -system public settings valueType 4 -system pg_extension spatial_ref_sys auth_name 2 -system pg_extension spatial_ref_sys auth_srid 3 -system pg_extension spatial_ref_sys proj4text 5 -system pg_extension spatial_ref_sys srid 1 -system pg_extension spatial_ref_sys srtext 4 -system public sqlliveness expiration 2 -system public sqlliveness session_id 1 -system public statement_bundle_chunks data 3 -system public statement_bundle_chunks description 2 -system public statement_bundle_chunks id 1 -system public statement_diagnostics bundle_chunks 6 -system public statement_diagnostics collected_at 4 -system public statement_diagnostics error 7 -system public statement_diagnostics id 1 -system public statement_diagnostics statement 3 -system public statement_diagnostics statement_fingerprint 2 -system public statement_diagnostics trace 5 -system public statement_diagnostics_requests completed 2 -system public statement_diagnostics_requests id 1 -system public statement_diagnostics_requests requested_at 5 -system public statement_diagnostics_requests statement_diagnostics_id 4 -system public statement_diagnostics_requests statement_fingerprint 3 -system public table_statistics columnIDs 4 -system public table_statistics createdAt 5 -system public table_statistics distinctCount 7 -system public table_statistics histogram 9 -system public table_statistics name 3 -system public table_statistics nullCount 8 -system public table_statistics rowCount 6 -system public table_statistics statisticID 2 -system public table_statistics tableID 1 -system public tenants active 2 -system public tenants id 1 -system public tenants info 3 -system public ui key 1 -system public ui lastUpdated 3 -system public ui value 2 -system public users hashedPassword 2 -system public users isRole 3 -system public users username 1 -system public web_sessions auditInfo 8 -system public web_sessions createdAt 4 -system public web_sessions expiresAt 5 -system public web_sessions hashedSecret 2 -system public web_sessions id 1 -system public web_sessions lastUsedAt 7 -system public web_sessions revokedAt 6 -system public web_sessions username 3 -system public zones config 2 -system public zones id 1 +table_catalog table_schema table_name column_name ordinal_position +system public comments comment 4 +system public comments object_id 2 +system public comments sub_id 3 +system public comments type 1 +system public descriptor descriptor 2 +system public descriptor id 1 +system public eventlog eventType 2 +system public eventlog info 5 +system public eventlog reportingID 4 +system public eventlog targetID 3 +system public eventlog timestamp 1 +system public eventlog uniqueID 6 +system pg_extension geography_columns coord_dimension 5 +system pg_extension geography_columns f_geography_column 4 +system pg_extension geography_columns f_table_catalog 1 +system pg_extension geography_columns f_table_name 3 +system pg_extension geography_columns f_table_schema 2 +system pg_extension geography_columns srid 6 +system pg_extension geography_columns type 7 +system pg_extension geometry_columns coord_dimension 5 +system pg_extension geometry_columns f_geometry_column 4 +system pg_extension geometry_columns f_table_catalog 1 +system pg_extension geometry_columns f_table_name 3 +system pg_extension geometry_columns f_table_schema 2 +system pg_extension geometry_columns srid 6 +system pg_extension geometry_columns type 7 +system public jobs claim_instance_id 9 +system public jobs claim_session_id 8 +system public jobs created 3 +system public jobs created_by_id 7 +system public jobs created_by_type 6 +system public jobs id 1 +system public jobs payload 4 +system public jobs progress 5 +system public jobs status 2 +system public join_tokens expiration 3 +system public join_tokens id 1 +system public join_tokens secret 2 +system public lease descID 1 +system public lease expiration 4 +system public lease nodeID 3 +system public lease version 2 +system public locations latitude 3 +system public locations localityKey 1 +system public locations localityValue 2 +system public locations longitude 4 +system public migrations completed_at 5 +system public migrations internal 4 +system public migrations major 1 +system public migrations minor 2 +system public migrations patch 3 +system public namespace id 3 +system public namespace name 2 +system public namespace parentID 1 +system public namespace2 id 4 +system public namespace2 name 3 +system public namespace2 parentID 1 +system public namespace2 parentSchemaID 2 +system public protected_ts_meta num_records 3 +system public protected_ts_meta num_spans 4 +system public protected_ts_meta singleton 1 +system public protected_ts_meta total_bytes 5 +system public protected_ts_meta version 2 +system public protected_ts_records id 1 +system public protected_ts_records meta 4 +system public protected_ts_records meta_type 3 +system public protected_ts_records num_spans 5 +system public protected_ts_records spans 6 +system public protected_ts_records ts 2 +system public protected_ts_records verified 7 +system public rangelog eventType 4 +system public rangelog info 6 +system public rangelog otherRangeID 5 +system public rangelog rangeID 2 +system public rangelog storeID 3 +system public rangelog timestamp 1 +system public rangelog uniqueID 7 +system public replication_constraint_stats config 4 +system public replication_constraint_stats report_id 5 +system public replication_constraint_stats subzone_id 2 +system public replication_constraint_stats type 3 +system public replication_constraint_stats violating_ranges 7 +system public replication_constraint_stats violation_start 6 +system public replication_constraint_stats zone_id 1 +system public replication_critical_localities at_risk_ranges 5 +system public replication_critical_localities locality 3 +system public replication_critical_localities report_id 4 +system public replication_critical_localities subzone_id 2 +system public replication_critical_localities zone_id 1 +system public replication_stats over_replicated_ranges 7 +system public replication_stats report_id 3 +system public replication_stats subzone_id 2 +system public replication_stats total_ranges 4 +system public replication_stats unavailable_ranges 5 +system public replication_stats under_replicated_ranges 6 +system public replication_stats zone_id 1 +system public reports_meta generated 2 +system public reports_meta id 1 +system public role_members isAdmin 3 +system public role_members member 2 +system public role_members role 1 +system public role_options option 2 +system public role_options username 1 +system public role_options value 3 +system public scheduled_jobs created 3 +system public scheduled_jobs execution_args 10 +system public scheduled_jobs executor_type 9 +system public scheduled_jobs next_run 5 +system public scheduled_jobs owner 4 +system public scheduled_jobs schedule_details 8 +system public scheduled_jobs schedule_expr 7 +system public scheduled_jobs schedule_id 1 +system public scheduled_jobs schedule_name 2 +system public scheduled_jobs schedule_state 6 +system public settings lastUpdated 3 +system public settings name 1 +system public settings value 2 +system public settings valueType 4 +system pg_extension spatial_ref_sys auth_name 2 +system pg_extension spatial_ref_sys auth_srid 3 +system pg_extension spatial_ref_sys proj4text 5 +system pg_extension spatial_ref_sys srid 1 +system pg_extension spatial_ref_sys srtext 4 +system public sql_statement_stats agg_interval 7 +system public sql_statement_stats aggregated_ts 1 +system public sql_statement_stats app_name 4 +system public sql_statement_stats count 6 +system public sql_statement_stats crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_shard_8 11 +system public sql_statement_stats fingerprint_id 2 +system public sql_statement_stats metadata 8 +system public sql_statement_stats node_id 5 +system public sql_statement_stats plan 10 +system public sql_statement_stats plan_hash 3 +system public sql_statement_stats statistics 9 +system public sql_transaction_stats agg_interval 6 +system public sql_transaction_stats aggregated_ts 1 +system public sql_transaction_stats app_name 3 +system public sql_transaction_stats count 5 +system public sql_transaction_stats crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8 9 +system public sql_transaction_stats fingerprint_id 2 +system public sql_transaction_stats metadata 7 +system public sql_transaction_stats node_id 4 +system public sql_transaction_stats statistics 8 +system public sqlliveness expiration 2 +system public sqlliveness session_id 1 +system public statement_bundle_chunks data 3 +system public statement_bundle_chunks description 2 +system public statement_bundle_chunks id 1 +system public statement_diagnostics bundle_chunks 6 +system public statement_diagnostics collected_at 4 +system public statement_diagnostics error 7 +system public statement_diagnostics id 1 +system public statement_diagnostics statement 3 +system public statement_diagnostics statement_fingerprint 2 +system public statement_diagnostics trace 5 +system public statement_diagnostics_requests completed 2 +system public statement_diagnostics_requests id 1 +system public statement_diagnostics_requests requested_at 5 +system public statement_diagnostics_requests statement_diagnostics_id 4 +system public statement_diagnostics_requests statement_fingerprint 3 +system public table_statistics columnIDs 4 +system public table_statistics createdAt 5 +system public table_statistics distinctCount 7 +system public table_statistics histogram 9 +system public table_statistics name 3 +system public table_statistics nullCount 8 +system public table_statistics rowCount 6 +system public table_statistics statisticID 2 +system public table_statistics tableID 1 +system public tenants active 2 +system public tenants id 1 +system public tenants info 3 +system public ui key 1 +system public ui lastUpdated 3 +system public ui value 2 +system public users hashedPassword 2 +system public users isRole 3 +system public users username 1 +system public web_sessions auditInfo 8 +system public web_sessions createdAt 4 +system public web_sessions expiresAt 5 +system public web_sessions hashedSecret 2 +system public web_sessions id 1 +system public web_sessions lastUsedAt 7 +system public web_sessions revokedAt 6 +system public web_sessions username 3 +system public zones config 2 +system public zones id 1 statement ok SET DATABASE = test @@ -2372,6 +2451,14 @@ NULL root system public settings NULL root system public settings INSERT NULL NO NULL root system public settings SELECT NULL YES NULL root system public settings UPDATE NULL NO +NULL admin system public sql_statement_stats GRANT NULL NO +NULL admin system public sql_statement_stats SELECT NULL YES +NULL root system public sql_statement_stats GRANT NULL NO +NULL root system public sql_statement_stats SELECT NULL YES +NULL admin system public sql_transaction_stats GRANT NULL NO +NULL admin system public sql_transaction_stats SELECT NULL YES +NULL root system public sql_transaction_stats GRANT NULL NO +NULL root system public sql_transaction_stats SELECT NULL YES NULL admin system public sqlliveness DELETE NULL NO NULL admin system public sqlliveness GRANT NULL NO NULL admin system public sqlliveness INSERT NULL NO @@ -2915,6 +3002,14 @@ NULL root system public join_tokens NULL root system public join_tokens INSERT NULL NO NULL root system public join_tokens SELECT NULL YES NULL root system public join_tokens UPDATE NULL NO +NULL admin system public sql_statement_stats GRANT NULL NO +NULL admin system public sql_statement_stats SELECT NULL YES +NULL root system public sql_statement_stats GRANT NULL NO +NULL root system public sql_statement_stats SELECT NULL YES +NULL admin system public sql_transaction_stats GRANT NULL NO +NULL admin system public sql_transaction_stats SELECT NULL YES +NULL root system public sql_transaction_stats GRANT NULL NO +NULL root system public sql_transaction_stats SELECT NULL YES statement ok CREATE TABLE other_db.xyz (i INT) diff --git a/pkg/sql/logictest/testdata/logic_test/pg_catalog b/pkg/sql/logictest/testdata/logic_test/pg_catalog index 448192efb342..6fa5f93ee029 100644 --- a/pkg/sql/logictest/testdata/logic_test/pg_catalog +++ b/pkg/sql/logictest/testdata/logic_test/pg_catalog @@ -856,46 +856,50 @@ SELECT * FROM pg_catalog.pg_index ORDER BY indexrelid ---- -indexrelid indrelid indnatts indisunique indisprimary indisexclusion indimmediate indisclustered indisvalid indcheckxmin indisready indislive indisreplident indkey indcollation indclass indoption indexprs indpred indnkeyatts -144368028 32 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -404104299 39 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -543291288 23 1 false false false false false true false false true false 1 3403232968 0 2 NULL NULL 1 -543291289 23 1 false false false false false true false false true false 2 3403232968 0 2 NULL NULL 1 -543291291 23 2 true true false true false true false false true false 1 2 3403232968 3403232968 0 0 2 2 NULL NULL 2 -803027558 26 3 true true false true false true false false true false 1 2 3 0 0 3403232968 0 0 0 2 2 2 NULL NULL 3 -923576837 41 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -1062763829 25 4 true true false true false true false false true false 1 2 3 4 0 0 3403232968 3403232968 0 0 0 0 2 2 2 2 NULL NULL 4 -1276104432 12 2 true true false true false true false false true false 1 6 0 0 0 0 2 2 NULL NULL 2 -1322500096 28 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -1489445036 35 3 false false false false false true false false true false 2 1 3 0 0 0 0 2 2 NULL NULL 2 -1489445039 35 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -1582236367 3 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -1628632028 19 1 false false false false false true false false true false 5 0 0 2 NULL NULL 1 -1628632029 19 1 false false false false false true false false true false 4 0 0 2 NULL NULL 1 -1628632031 19 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -1841972634 6 1 true true false true false true false false true false 1 3403232968 0 2 NULL NULL 1 -2008917577 37 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -2008917578 37 1 false false false false false true false false true false 5 0 0 2 NULL NULL 1 -2101708905 5 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -2148104569 21 2 true true false true false true false false true false 1 2 3403232968 3403232968 0 0 2 2 NULL NULL 2 -2268653844 40 4 true true false true false true false false true false 1 2 3 4 0 0 0 0 0 0 0 0 2 2 2 2 NULL NULL 4 -2361445172 8 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -2407840836 24 3 true true false true false true false false true false 1 2 3 0 0 0 0 0 0 2 2 2 NULL NULL 3 -2621181440 15 2 false false false false false true false false true false 2 3 3403232968 0 0 0 2 2 NULL NULL 2 -2621181441 15 3 false false false false false true false false true false 6 7 2 3403232968 0 0 0 2 2 NULL NULL 2 -2621181443 15 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -2667577107 31 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -2834522046 34 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -2927313374 2 2 true true false true false true false false true false 1 2 0 3403232968 0 0 2 2 NULL NULL 2 -3094258317 33 2 true true false true false true false false true false 1 2 3403232968 3403232968 0 0 2 2 NULL NULL 2 -3353994584 36 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 -3446785912 4 1 true true false true false true false false true false 1 3403232968 0 2 NULL NULL 1 -3493181576 20 2 true true false true false true false false true false 1 2 0 0 0 0 2 2 NULL NULL 2 -3706522183 11 4 true true false true false true false false true false 1 2 4 3 0 0 0 0 0 0 0 0 2 2 2 2 NULL NULL 4 -3752917847 27 2 true true false true false true false false true false 1 2 0 0 0 0 2 2 NULL NULL 2 -3966258450 14 1 true true false true false true false false true false 1 3403232968 0 2 NULL NULL 1 -4012654114 30 3 true true false true false true false false true false 1 2 3 0 0 3403232968 0 0 0 2 2 2 NULL NULL 3 -4225994721 13 2 true true false true false true false false true false 1 7 0 0 0 0 2 2 NULL NULL 2 +indexrelid indrelid indnatts indisunique indisprimary indisexclusion indimmediate indisclustered indisvalid indcheckxmin indisready indislive indisreplident indkey indcollation indclass indoption indexprs indpred indnkeyatts +144368028 32 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +404104299 39 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +543291288 23 1 false false false false false true false false true false 1 3403232968 0 2 NULL NULL 1 +543291289 23 1 false false false false false true false false true false 2 3403232968 0 2 NULL NULL 1 +543291291 23 2 true true false true false true false false true false 1 2 3403232968 3403232968 0 0 2 2 NULL NULL 2 +663840565 42 5 false false false false false true false false true false 2 1 3 4 5 0 0 0 3403232968 0 0 0 0 0 0 2 2 2 2 2 NULL NULL 5 +663840566 42 5 true true false true false true false false true false 1 2 3 4 5 0 0 0 3403232968 0 0 0 0 0 0 2 2 2 2 2 NULL NULL 5 +803027558 26 3 true true false true false true false false true false 1 2 3 0 0 3403232968 0 0 0 2 2 2 NULL NULL 3 +923576837 41 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +1062763829 25 4 true true false true false true false false true false 1 2 3 4 0 0 3403232968 3403232968 0 0 0 0 2 2 2 2 NULL NULL 4 +1276104432 12 2 true true false true false true false false true false 1 6 0 0 0 0 2 2 NULL NULL 2 +1322500096 28 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +1489445036 35 3 false false false false false true false false true false 2 1 3 0 0 0 0 2 2 NULL NULL 2 +1489445039 35 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +1582236367 3 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +1628632028 19 1 false false false false false true false false true false 5 0 0 2 NULL NULL 1 +1628632029 19 1 false false false false false true false false true false 4 0 0 2 NULL NULL 1 +1628632031 19 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +1841972634 6 1 true true false true false true false false true false 1 3403232968 0 2 NULL NULL 1 +2008917577 37 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +2008917578 37 1 false false false false false true false false true false 5 0 0 2 NULL NULL 1 +2101708905 5 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +2148104569 21 2 true true false true false true false false true false 1 2 3403232968 3403232968 0 0 2 2 NULL NULL 2 +2268653844 40 4 true true false true false true false false true false 1 2 3 4 0 0 0 0 0 0 0 0 2 2 2 2 NULL NULL 4 +2361445172 8 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +2407840836 24 3 true true false true false true false false true false 1 2 3 0 0 0 0 0 0 2 2 2 NULL NULL 3 +2621181440 15 2 false false false false false true false false true false 2 3 3403232968 0 0 0 2 2 NULL NULL 2 +2621181441 15 3 false false false false false true false false true false 6 7 2 3403232968 0 0 0 2 2 NULL NULL 2 +2621181443 15 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +2667577107 31 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +2834522046 34 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +2927313374 2 2 true true false true false true false false true false 1 2 0 3403232968 0 0 2 2 NULL NULL 2 +3094258317 33 2 true true false true false true false false true false 1 2 3403232968 3403232968 0 0 2 2 NULL NULL 2 +3353994584 36 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 +3446785912 4 1 true true false true false true false false true false 1 3403232968 0 2 NULL NULL 1 +3493181576 20 2 true true false true false true false false true false 1 2 0 0 0 0 2 2 NULL NULL 2 +3613730852 43 4 false false false false false true false false true false 2 1 3 4 0 0 3403232968 0 0 0 0 0 2 2 2 2 NULL NULL 4 +3613730855 43 4 true true false true false true false false true false 1 2 3 4 0 0 3403232968 0 0 0 0 0 2 2 2 2 NULL NULL 4 +3706522183 11 4 true true false true false true false false true false 1 2 4 3 0 0 0 0 0 0 0 0 2 2 2 2 NULL NULL 4 +3752917847 27 2 true true false true false true false false true false 1 2 0 0 0 0 2 2 NULL NULL 2 +3966258450 14 1 true true false true false true false false true false 1 3403232968 0 2 NULL NULL 1 +4012654114 30 3 true true false true false true false false true false 1 2 3 0 0 3403232968 0 0 0 2 2 2 NULL NULL 3 +4225994721 13 2 true true false true false true false false true false 1 7 0 0 0 0 2 2 NULL NULL 2 # From #26504 query OOI colnames @@ -912,6 +916,16 @@ indexrelid operator_argument_type_oid operator_argument_position 543291289 0 1 543291291 0 1 543291291 0 2 +663840565 0 1 +663840565 0 2 +663840565 0 3 +663840565 0 4 +663840565 0 5 +663840566 0 1 +663840566 0 2 +663840566 0 3 +663840566 0 4 +663840566 0 5 803027558 0 1 803027558 0 2 803027558 0 3 @@ -959,6 +973,14 @@ indexrelid operator_argument_type_oid operator_argument_position 3446785912 0 1 3493181576 0 1 3493181576 0 2 +3613730852 0 1 +3613730852 0 2 +3613730852 0 3 +3613730852 0 4 +3613730855 0 1 +3613730855 0 2 +3613730855 0 3 +3613730855 0 4 3706522183 0 1 3706522183 0 2 3706522183 0 3 diff --git a/pkg/sql/logictest/testdata/logic_test/ranges b/pkg/sql/logictest/testdata/logic_test/ranges index 1199b2ad96ca..1aa99e04751b 100644 --- a/pkg/sql/logictest/testdata/logic_test/ranges +++ b/pkg/sql/logictest/testdata/logic_test/ranges @@ -311,7 +311,9 @@ start_key start_pretty end_key [174] /Table/38 [175] /Table/39 · · · {1} 1 [175] /Table/39 [176] /Table/40 system sqlliveness · {1} 1 [176] /Table/40 [177] /Table/41 system migrations · {1} 1 -[177] /Table/41 [189 137] /Table/53/1 system join_tokens · {1} 1 +[177] /Table/41 [178] /Table/42 system join_tokens · {1} 1 +[178] /Table/42 [179] /Table/43 system sql_statement_stats · {1} 1 +[179] /Table/43 [189 137] /Table/53/1 system sql_transaction_stats · {1} 1 [189 137] /Table/53/1 [189 137 137] /Table/53/1/1 test t · {1} 1 [189 137 137] /Table/53/1/1 [189 137 141 137] /Table/53/1/5/1 test t · {3,4} 3 [189 137 141 137] /Table/53/1/5/1 [189 137 141 138] /Table/53/1/5/2 test t · {1,2,3} 1 @@ -371,7 +373,9 @@ start_key start_pretty end_key [174] /Table/38 [175] /Table/39 · · · {1} 1 [175] /Table/39 [176] /Table/40 system sqlliveness · {1} 1 [176] /Table/40 [177] /Table/41 system migrations · {1} 1 -[177] /Table/41 [189 137] /Table/53/1 system join_tokens · {1} 1 +[177] /Table/41 [178] /Table/42 system join_tokens · {1} 1 +[178] /Table/42 [179] /Table/43 system sql_statement_stats · {1} 1 +[179] /Table/43 [189 137] /Table/53/1 system sql_transaction_stats · {1} 1 [189 137] /Table/53/1 [189 137 137] /Table/53/1/1 test t · {1} 1 [189 137 137] /Table/53/1/1 [189 137 141 137] /Table/53/1/5/1 test t · {3,4} 3 [189 137 141 137] /Table/53/1/5/1 [189 137 141 138] /Table/53/1/5/2 test t · {1,2,3} 1 diff --git a/pkg/sql/logictest/testdata/logic_test/show_source b/pkg/sql/logictest/testdata/logic_test/show_source index 7a7b32c6c629..1473390cde20 100644 --- a/pkg/sql/logictest/testdata/logic_test/show_source +++ b/pkg/sql/logictest/testdata/logic_test/show_source @@ -200,6 +200,8 @@ SELECT * FROM [SHOW TABLES FROM system] ---- schema_name table_name type owner estimated_row_count locality public namespace table NULL 0 NULL +public sql_transaction_stats table NULL 0 NULL +public sql_statement_stats table NULL 0 NULL public join_tokens table NULL 0 NULL public migrations table NULL 0 NULL public sqlliveness table NULL 0 NULL @@ -236,6 +238,8 @@ SELECT * FROM [SHOW TABLES FROM system WITH COMMENT] ---- schema_name table_name type owner estimated_row_count locality comment public namespace table NULL 0 NULL · +public sql_transaction_stats table NULL 0 NULL · +public sql_statement_stats table NULL 0 NULL · public join_tokens table NULL 0 NULL · public migrations table NULL 0 NULL · public sqlliveness table NULL 0 NULL · diff --git a/pkg/sql/logictest/testdata/logic_test/system b/pkg/sql/logictest/testdata/logic_test/system index 623b4ff2cacc..d1f3434d2540 100644 --- a/pkg/sql/logictest/testdata/logic_test/system +++ b/pkg/sql/logictest/testdata/logic_test/system @@ -31,6 +31,8 @@ public role_members table NULL 0 NULL public role_options table NULL 0 NULL public scheduled_jobs table NULL 0 NULL public settings table NULL 0 NULL +public sql_statement_stats table NULL 0 NULL +public sql_transaction_stats table NULL 0 NULL public sqlliveness table NULL 0 NULL public statement_bundle_chunks table NULL 0 NULL public statement_diagnostics table NULL 0 NULL @@ -77,6 +79,8 @@ SELECT id FROM system.descriptor 39 40 41 +42 +43 50 51 52 @@ -376,6 +380,14 @@ system public settings root GRANT system public settings root INSERT system public settings root SELECT system public settings root UPDATE +system public sql_statement_stats admin GRANT +system public sql_statement_stats admin SELECT +system public sql_statement_stats root GRANT +system public sql_statement_stats root SELECT +system public sql_transaction_stats admin GRANT +system public sql_transaction_stats admin SELECT +system public sql_transaction_stats root GRANT +system public sql_transaction_stats root SELECT system public sqlliveness admin DELETE system public sqlliveness admin GRANT system public sqlliveness admin INSERT diff --git a/pkg/sql/logictest/testdata/logic_test/system_namespace b/pkg/sql/logictest/testdata/logic_test/system_namespace index 9a2b2c16a3f9..0986c201a847 100644 --- a/pkg/sql/logictest/testdata/logic_test/system_namespace +++ b/pkg/sql/logictest/testdata/logic_test/system_namespace @@ -33,6 +33,8 @@ SELECT * FROM system.namespace 1 29 role_options 33 1 29 scheduled_jobs 37 1 29 settings 6 +1 29 sql_statement_stats 42 +1 29 sql_transaction_stats 43 1 29 sqlliveness 39 1 29 statement_bundle_chunks 34 1 29 statement_diagnostics 36 diff --git a/pkg/sql/opt/exec/execbuilder/testdata/autocommit_nonmetamorphic b/pkg/sql/opt/exec/execbuilder/testdata/autocommit_nonmetamorphic index 7247dac471b6..cf0586a579f0 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/autocommit_nonmetamorphic +++ b/pkg/sql/opt/exec/execbuilder/testdata/autocommit_nonmetamorphic @@ -41,7 +41,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 # Multi-row insert should auto-commit. query B @@ -62,7 +62,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 # No auto-commit inside a transaction. statement ok @@ -86,7 +86,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 2 CPut to (n1,s1):1 +dist sender send r39: sending batch 2 CPut to (n1,s1):1 statement ok ROLLBACK @@ -110,7 +110,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 # TODO(radu): allow non-side-effecting projections. query B @@ -132,8 +132,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 2 CPut to (n1,s1):1 -dist sender send r37: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 2 CPut to (n1,s1):1 +dist sender send r39: sending batch 1 EndTxn to (n1,s1):1 # Insert with RETURNING statement with side-effects should not auto-commit. # In this case division can (in principle) error out. @@ -156,8 +156,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 2 CPut to (n1,s1):1 -dist sender send r37: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 2 CPut to (n1,s1):1 +dist sender send r39: sending batch 1 EndTxn to (n1,s1):1 # Another way to test the scenario above: generate an error and ensure that the # mutation was not committed. @@ -192,7 +192,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 1 Put, 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 Put, 1 EndTxn to (n1,s1):1 # Multi-row upsert should auto-commit. query B @@ -213,7 +213,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 2 Put, 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 2 Put, 1 EndTxn to (n1,s1):1 # No auto-commit inside a transaction. statement ok @@ -237,7 +237,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 2 Put to (n1,s1):1 +dist sender send r39: sending batch 2 Put to (n1,s1):1 statement ok ROLLBACK @@ -261,7 +261,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 2 Put, 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 2 Put, 1 EndTxn to (n1,s1):1 # TODO(radu): allow non-side-effecting projections. query B @@ -283,8 +283,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 2 Put to (n1,s1):1 -dist sender send r37: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 2 Put to (n1,s1):1 +dist sender send r39: sending batch 1 EndTxn to (n1,s1):1 # Upsert with RETURNING statement with side-effects should not auto-commit. # In this case division can (in principle) error out. @@ -307,8 +307,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 2 Put to (n1,s1):1 -dist sender send r37: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 2 Put to (n1,s1):1 +dist sender send r39: sending batch 1 EndTxn to (n1,s1):1 # Another way to test the scenario above: generate an error and ensure that the # mutation was not committed. @@ -343,8 +343,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 1 Scan to (n1,s1):1 -dist sender send r37: sending batch 2 Put, 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 Scan to (n1,s1):1 +dist sender send r39: sending batch 2 Put, 1 EndTxn to (n1,s1):1 # No auto-commit inside a transaction. statement ok @@ -368,8 +368,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 1 Scan to (n1,s1):1 -dist sender send r37: sending batch 2 Put to (n1,s1):1 +dist sender send r39: sending batch 1 Scan to (n1,s1):1 +dist sender send r39: sending batch 2 Put to (n1,s1):1 statement ok ROLLBACK @@ -393,8 +393,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 1 Scan to (n1,s1):1 -dist sender send r37: sending batch 2 Put, 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 Scan to (n1,s1):1 +dist sender send r39: sending batch 2 Put, 1 EndTxn to (n1,s1):1 # TODO(radu): allow non-side-effecting projections. query B @@ -416,9 +416,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 1 Scan to (n1,s1):1 -dist sender send r37: sending batch 2 Put to (n1,s1):1 -dist sender send r37: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 Scan to (n1,s1):1 +dist sender send r39: sending batch 2 Put to (n1,s1):1 +dist sender send r39: sending batch 1 EndTxn to (n1,s1):1 # Update with RETURNING statement with side-effects should not auto-commit. # In this case division can (in principle) error out. @@ -441,9 +441,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 1 Scan to (n1,s1):1 -dist sender send r37: sending batch 2 Put to (n1,s1):1 -dist sender send r37: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 Scan to (n1,s1):1 +dist sender send r39: sending batch 2 Put to (n1,s1):1 +dist sender send r39: sending batch 1 EndTxn to (n1,s1):1 # Another way to test the scenario above: generate an error and ensure that the # mutation was not committed. @@ -478,7 +478,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 # Multi-row delete should auto-commit. query B @@ -499,7 +499,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 # No auto-commit inside a transaction. statement ok @@ -523,7 +523,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 1 DelRng to (n1,s1):1 +dist sender send r39: sending batch 1 DelRng to (n1,s1):1 statement ok ROLLBACK @@ -547,8 +547,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r37: sending batch 1 Scan to (n1,s1):1 -dist sender send r37: sending batch 2 Del, 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 Scan to (n1,s1):1 +dist sender send r39: sending batch 2 Del, 1 EndTxn to (n1,s1):1 # TODO(radu): allow non-side-effecting projections. query B @@ -570,9 +570,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 1 Scan to (n1,s1):1 -dist sender send r37: sending batch 2 Del to (n1,s1):1 -dist sender send r37: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 Scan to (n1,s1):1 +dist sender send r39: sending batch 2 Del to (n1,s1):1 +dist sender send r39: sending batch 1 EndTxn to (n1,s1):1 # Insert with RETURNING statement with side-effects should not auto-commit. # In this case division can (in principle) error out. @@ -595,9 +595,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 1 Scan to (n1,s1):1 -dist sender send r37: sending batch 2 Del to (n1,s1):1 -dist sender send r37: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 Scan to (n1,s1):1 +dist sender send r39: sending batch 2 Del to (n1,s1):1 +dist sender send r39: sending batch 1 EndTxn to (n1,s1):1 statement ok INSERT INTO ab VALUES (12, 0); @@ -644,9 +644,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 2 CPut to (n1,s1):1 -dist sender send r37: sending batch 2 Get to (n1,s1):1 -dist sender send r37: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 2 CPut to (n1,s1):1 +dist sender send r39: sending batch 2 Get to (n1,s1):1 +dist sender send r39: sending batch 1 EndTxn to (n1,s1):1 query B SELECT count(*) > 0 FROM [ @@ -667,10 +667,10 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 1 Scan to (n1,s1):1 -dist sender send r37: sending batch 1 Put to (n1,s1):1 -dist sender send r37: sending batch 1 Scan to (n1,s1):1 -dist sender send r37: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 Scan to (n1,s1):1 +dist sender send r39: sending batch 1 Put to (n1,s1):1 +dist sender send r39: sending batch 1 Scan to (n1,s1):1 +dist sender send r39: sending batch 1 EndTxn to (n1,s1):1 query B SELECT count(*) > 0 FROM [ @@ -692,10 +692,10 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 1 Get to (n1,s1):1 -dist sender send r37: sending batch 1 Del to (n1,s1):1 -dist sender send r37: sending batch 1 Scan to (n1,s1):1 -dist sender send r37: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 Get to (n1,s1):1 +dist sender send r39: sending batch 1 Del to (n1,s1):1 +dist sender send r39: sending batch 1 Scan to (n1,s1):1 +dist sender send r39: sending batch 1 EndTxn to (n1,s1):1 # Test with a single cascade, which should use autocommit. statement ok @@ -719,9 +719,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 1 DelRng to (n1,s1):1 -dist sender send r37: sending batch 1 Scan to (n1,s1):1 -dist sender send r37: sending batch 1 Del, 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 DelRng to (n1,s1):1 +dist sender send r39: sending batch 1 Scan to (n1,s1):1 +dist sender send r39: sending batch 1 Del, 1 EndTxn to (n1,s1):1 # ----------------------- # Multiple mutation tests @@ -749,9 +749,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 2 CPut to (n1,s1):1 -dist sender send r37: sending batch 2 CPut to (n1,s1):1 -dist sender send r37: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 2 CPut to (n1,s1):1 +dist sender send r39: sending batch 2 CPut to (n1,s1):1 +dist sender send r39: sending batch 1 EndTxn to (n1,s1):1 query B SELECT count(*) > 0 FROM [ @@ -774,6 +774,6 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r37: sending batch 2 CPut to (n1,s1):1 -dist sender send r37: sending batch 2 CPut to (n1,s1):1 -dist sender send r37: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 2 CPut to (n1,s1):1 +dist sender send r39: sending batch 2 CPut to (n1,s1):1 +dist sender send r39: sending batch 1 EndTxn to (n1,s1):1 diff --git a/pkg/sql/opt/exec/execbuilder/testdata/delete b/pkg/sql/opt/exec/execbuilder/testdata/delete index 6154a6878183..2147892c692b 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/delete +++ b/pkg/sql/opt/exec/execbuilder/testdata/delete @@ -231,9 +231,9 @@ SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] WHERE message LIKE '%DelRange%' OR message LIKE '%DelRng%' ---- materializer DelRange /Table/57/1 - /Table/57/2 -dist sender send r37: sending batch 1 DelRng to (n1,s1):1 +dist sender send r39: sending batch 1 DelRng to (n1,s1):1 materializer DelRange /Table/57/1/601/0 - /Table/57/2 -dist sender send r37: sending batch 1 DelRng to (n1,s1):1 +dist sender send r39: sending batch 1 DelRng to (n1,s1):1 # Ensure that DelRange requests are autocommitted when DELETE FROM happens on a # chunk of fewer than 600 keys. @@ -249,7 +249,7 @@ SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] WHERE message LIKE '%DelRange%' OR message LIKE '%sending batch%' ---- materializer DelRange /Table/57/1/5 - /Table/57/1/5/# -dist sender send r37: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 +dist sender send r39: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 # Test use of fast path when there are interleaved tables. diff --git a/pkg/sql/opt/exec/execbuilder/testdata/show_trace_nonmetamorphic b/pkg/sql/opt/exec/execbuilder/testdata/show_trace_nonmetamorphic index e39b9b494d19..49c2c15a1c18 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/show_trace_nonmetamorphic +++ b/pkg/sql/opt/exec/execbuilder/testdata/show_trace_nonmetamorphic @@ -238,7 +238,7 @@ SET tracing = on; INSERT INTO t.kv3 (k, v) VALUES (1,1); SET tracing = off query T SELECT message FROM [SHOW TRACE FOR SESSION] WHERE message LIKE e'%1 CPut, 1 EndTxn%' AND message NOT LIKE e'%proposing command%' ---- -r38: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 +r40: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 node received request: 1 CPut, 1 EndTxn # Temporarily disabled flaky test (#58202). @@ -349,9 +349,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r38: sending batch 1 CPut to (n1,s1):1 -dist sender send r38: sending batch 1 EndTxn to (n1,s1):1 -dist sender send r38: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 +dist sender send r40: sending batch 1 CPut to (n1,s1):1 +dist sender send r40: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r40: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 # Make another session trace. statement ok @@ -380,6 +380,6 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r38: sending batch 4 CPut, 1 EndTxn to (n1,s1):1 -dist sender send r38: sending batch 5 CPut to (n1,s1):1 -dist sender send r38: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r40: sending batch 4 CPut, 1 EndTxn to (n1,s1):1 +dist sender send r40: sending batch 5 CPut to (n1,s1):1 +dist sender send r40: sending batch 1 EndTxn to (n1,s1):1 diff --git a/pkg/sql/pgwire/pgwire_test.go b/pkg/sql/pgwire/pgwire_test.go index 9e7e336347b1..6162575d279c 100644 --- a/pkg/sql/pgwire/pgwire_test.go +++ b/pkg/sql/pgwire/pgwire_test.go @@ -558,7 +558,7 @@ func TestPGPreparedQuery(t *testing.T) { baseTest.Results("users", "primary", false, 1, "username", "ASC", false, false), }}, {"SHOW TABLES FROM system", []preparedQueryTest{ - baseTest.Results("public", "comments", "table", gosql.NullString{}, 0, gosql.NullString{}).Others(30), + baseTest.Results("public", "comments", "table", gosql.NullString{}, 0, gosql.NullString{}).Others(32), }}, {"SHOW SCHEMAS FROM system", []preparedQueryTest{ baseTest.Results("crdb_internal", gosql.NullString{}).Others(4), diff --git a/pkg/sql/table_test.go b/pkg/sql/table_test.go index 69a94eb11fb4..e20955e019ef 100644 --- a/pkg/sql/table_test.go +++ b/pkg/sql/table_test.go @@ -182,7 +182,7 @@ func TestMakeTableDescColumns(t *testing.T) { for i, d := range testData { s := "CREATE TABLE foo.test (a " + d.sqlType + " PRIMARY KEY, b " + d.sqlType + ")" schema, err := CreateTestTableDescriptor(context.Background(), 1, 100, s, - descpb.NewDefaultPrivilegeDescriptor(security.AdminRoleName())) + descpb.NewDefaultPrivilegeDescriptor(security.AdminRoleName()), nil /* sessionDataOverride */) if err != nil { t.Fatalf("%d: %v", i, err) } @@ -298,7 +298,7 @@ func TestMakeTableDescIndexes(t *testing.T) { for i, d := range testData { s := "CREATE TABLE foo.test (" + d.sql + ")" schema, err := CreateTestTableDescriptor(context.Background(), 1, 100, s, - descpb.NewDefaultPrivilegeDescriptor(security.AdminRoleName())) + descpb.NewDefaultPrivilegeDescriptor(security.AdminRoleName()), nil /* sessionDataOverride */) if err != nil { t.Fatalf("%d (%s): %v", i, d.sql, err) } @@ -368,7 +368,7 @@ func TestMakeTableDescUniqueConstraints(t *testing.T) { for i, d := range testData { s := "CREATE TABLE foo.test (" + d.sql + ")" schema, err := CreateTestTableDescriptor(context.Background(), 1, 100, s, - descpb.NewDefaultPrivilegeDescriptor(security.AdminRoleName())) + descpb.NewDefaultPrivilegeDescriptor(security.AdminRoleName()), nil /* sessionDataOverride */) if err != nil { t.Fatalf("%d (%s): %v", i, d.sql, err) } @@ -387,7 +387,7 @@ func TestPrimaryKeyUnspecified(t *testing.T) { s := "CREATE TABLE foo.test (a INT, b INT, CONSTRAINT c UNIQUE (b))" ctx := context.Background() desc, err := CreateTestTableDescriptor(ctx, 1, 100, s, - descpb.NewDefaultPrivilegeDescriptor(security.AdminRoleName())) + descpb.NewDefaultPrivilegeDescriptor(security.AdminRoleName()), nil /* sessionDataOverride */) if err != nil { t.Fatal(err) } diff --git a/pkg/sql/tests/system_table_test.go b/pkg/sql/tests/system_table_test.go index 715d7b53d422..eb8991555673 100644 --- a/pkg/sql/tests/system_table_test.go +++ b/pkg/sql/tests/system_table_test.go @@ -27,6 +27,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" "github.com/cockroachdb/cockroach/pkg/sql/privilege" + "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/util/leaktest" "github.com/cockroachdb/cockroach/pkg/util/log" @@ -66,6 +67,7 @@ func TestInitialKeys(t *testing.T) { keys.MaxReservedDescID, "CREATE TABLE system.x (val INTEGER PRIMARY KEY)", descpb.NewDefaultPrivilegeDescriptor(security.NodeUserName()), + nil, /* sessionDataOverride */ ) if err != nil { t.Fatal(err) @@ -164,6 +166,13 @@ func TestSystemTableLiterals(t *testing.T) { pkg catalog.TableDescriptor } + sessionData := &sessiondata.SessionData{ + LocalOnlySessionData: sessiondata.LocalOnlySessionData{ + EnableUniqueWithoutIndexConstraints: true, + HashShardedIndexesEnabled: true, + }, + } + for _, test := range []testcase{ {keys.NamespaceTableID, systemschema.NamespaceTableSchema, systemschema.NamespaceTable}, {keys.DescriptorTableID, systemschema.DescriptorTableSchema, systemschema.DescriptorTable}, @@ -192,6 +201,8 @@ func TestSystemTableLiterals(t *testing.T) { {keys.SqllivenessID, systemschema.SqllivenessTableSchema, systemschema.SqllivenessTable}, {keys.MigrationsID, systemschema.MigrationsTableSchema, systemschema.MigrationsTable}, {keys.JoinTokensTableID, systemschema.JoinTokensTableSchema, systemschema.JoinTokensTable}, + {keys.SQLStatementStatsTableID, systemschema.SQLStatementStatsTableSchema, systemschema.SQLStatementStatsTable}, + {keys.SQLTransactionStatsTableID, systemschema.SQLTransactionStatsTableSchema, systemschema.SQLTransactionStatsTable}, } { privs := *test.pkg.GetPrivileges() gen, err := sql.CreateTestTableDescriptor( @@ -200,6 +211,7 @@ func TestSystemTableLiterals(t *testing.T) { test.id, test.schema, &privs, + sessionData, ) if err != nil { t.Fatalf("test: %+v, err: %v", test, err) diff --git a/pkg/sql/tests/testdata/initial_keys b/pkg/sql/tests/testdata/initial_keys index 017850ad88e1..2a6a78035a5c 100644 --- a/pkg/sql/tests/testdata/initial_keys +++ b/pkg/sql/tests/testdata/initial_keys @@ -1,6 +1,6 @@ initial-keys tenant=system ---- -73 keys: +77 keys: /System/"desc-idgen" /Table/3/1/1/2/1 /Table/3/1/2/2/1 @@ -34,6 +34,8 @@ initial-keys tenant=system /Table/3/1/39/2/1 /Table/3/1/40/2/1 /Table/3/1/41/2/1 + /Table/3/1/42/2/1 + /Table/3/1/43/2/1 /Table/5/1/0/2/1 /Table/5/1/1/2/1 /Table/5/1/16/2/1 @@ -64,6 +66,8 @@ initial-keys tenant=system /NamespaceTable/30/1/1/29/"role_options"/4/1 /NamespaceTable/30/1/1/29/"scheduled_jobs"/4/1 /NamespaceTable/30/1/1/29/"settings"/4/1 + /NamespaceTable/30/1/1/29/"sql_statement_stats"/4/1 + /NamespaceTable/30/1/1/29/"sql_transaction_stats"/4/1 /NamespaceTable/30/1/1/29/"sqlliveness"/4/1 /NamespaceTable/30/1/1/29/"statement_bundle_chunks"/4/1 /NamespaceTable/30/1/1/29/"statement_diagnostics"/4/1 @@ -74,7 +78,7 @@ initial-keys tenant=system /NamespaceTable/30/1/1/29/"users"/4/1 /NamespaceTable/30/1/1/29/"web_sessions"/4/1 /NamespaceTable/30/1/1/29/"zones"/4/1 -31 splits: +33 splits: /Table/11 /Table/12 /Table/13 @@ -106,10 +110,12 @@ initial-keys tenant=system /Table/39 /Table/40 /Table/41 + /Table/42 + /Table/43 initial-keys tenant=5 ---- -64 keys: +68 keys: /Tenant/5/Table/3/1/1/2/1 /Tenant/5/Table/3/1/2/2/1 /Tenant/5/Table/3/1/3/2/1 @@ -141,6 +147,8 @@ initial-keys tenant=5 /Tenant/5/Table/3/1/39/2/1 /Tenant/5/Table/3/1/40/2/1 /Tenant/5/Table/3/1/41/2/1 + /Tenant/5/Table/3/1/42/2/1 + /Tenant/5/Table/3/1/43/2/1 /Tenant/5/Table/7/1/0/0 /Tenant/5/NamespaceTable/30/1/0/0/"system"/4/1 /Tenant/5/NamespaceTable/30/1/1/0/"public"/4/1 @@ -166,6 +174,8 @@ initial-keys tenant=5 /Tenant/5/NamespaceTable/30/1/1/29/"role_options"/4/1 /Tenant/5/NamespaceTable/30/1/1/29/"scheduled_jobs"/4/1 /Tenant/5/NamespaceTable/30/1/1/29/"settings"/4/1 + /Tenant/5/NamespaceTable/30/1/1/29/"sql_statement_stats"/4/1 + /Tenant/5/NamespaceTable/30/1/1/29/"sql_transaction_stats"/4/1 /Tenant/5/NamespaceTable/30/1/1/29/"sqlliveness"/4/1 /Tenant/5/NamespaceTable/30/1/1/29/"statement_bundle_chunks"/4/1 /Tenant/5/NamespaceTable/30/1/1/29/"statement_diagnostics"/4/1 @@ -179,7 +189,7 @@ initial-keys tenant=5 initial-keys tenant=999 ---- -64 keys: +68 keys: /Tenant/999/Table/3/1/1/2/1 /Tenant/999/Table/3/1/2/2/1 /Tenant/999/Table/3/1/3/2/1 @@ -211,6 +221,8 @@ initial-keys tenant=999 /Tenant/999/Table/3/1/39/2/1 /Tenant/999/Table/3/1/40/2/1 /Tenant/999/Table/3/1/41/2/1 + /Tenant/999/Table/3/1/42/2/1 + /Tenant/999/Table/3/1/43/2/1 /Tenant/999/Table/7/1/0/0 /Tenant/999/NamespaceTable/30/1/0/0/"system"/4/1 /Tenant/999/NamespaceTable/30/1/1/0/"public"/4/1 @@ -236,6 +248,8 @@ initial-keys tenant=999 /Tenant/999/NamespaceTable/30/1/1/29/"role_options"/4/1 /Tenant/999/NamespaceTable/30/1/1/29/"scheduled_jobs"/4/1 /Tenant/999/NamespaceTable/30/1/1/29/"settings"/4/1 + /Tenant/999/NamespaceTable/30/1/1/29/"sql_statement_stats"/4/1 + /Tenant/999/NamespaceTable/30/1/1/29/"sql_transaction_stats"/4/1 /Tenant/999/NamespaceTable/30/1/1/29/"sqlliveness"/4/1 /Tenant/999/NamespaceTable/30/1/1/29/"statement_bundle_chunks"/4/1 /Tenant/999/NamespaceTable/30/1/1/29/"statement_diagnostics"/4/1 diff --git a/pkg/sql/testutils.go b/pkg/sql/testutils.go index 1856ef4a005e..b3495419590a 100644 --- a/pkg/sql/testutils.go +++ b/pkg/sql/testutils.go @@ -32,6 +32,7 @@ func CreateTestTableDescriptor( parentID, id descpb.ID, schema string, privileges *descpb.PrivilegeDescriptor, + sessionDataOverride *sessiondata.SessionData, ) (*tabledesc.Mutable, error) { st := cluster.MakeTestingClusterSettings() stmt, err := parser.ParseOne(schema) @@ -40,6 +41,17 @@ func CreateTestTableDescriptor( } semaCtx := tree.MakeSemaContext() evalCtx := tree.MakeTestingEvalContext(st) + + sessionData := &sessiondata.SessionData{ + LocalOnlySessionData: sessiondata.LocalOnlySessionData{ + EnableUniqueWithoutIndexConstraints: true, + }, + } + + if sessionDataOverride != nil { + sessionData = sessionDataOverride + } + switch n := stmt.AST.(type) { case *tree.CreateTable: desc, err := NewTableDesc( @@ -57,11 +69,7 @@ func CreateTestTableDescriptor( nil, /* affected */ &semaCtx, &evalCtx, - &sessiondata.SessionData{ - LocalOnlySessionData: sessiondata.LocalOnlySessionData{ - EnableUniqueWithoutIndexConstraints: true, - }, - }, /* sessionData */ + sessionData, tree.PersistencePermanent, ) return desc, err diff --git a/pkg/sqlmigrations/migrations_test.go b/pkg/sqlmigrations/migrations_test.go index b23fcf48cb93..af645a36d4f5 100644 --- a/pkg/sqlmigrations/migrations_test.go +++ b/pkg/sqlmigrations/migrations_test.go @@ -841,6 +841,7 @@ CREATE TABLE system.jobs ( keys.JobsTableID, oldJobsTableSchema, systemschema.JobsTable.GetPrivileges(), + nil, /* sessionDataOverride */ ) require.NoError(t, err) @@ -926,6 +927,7 @@ func TestVersionAlterSystemJobsAddSqllivenessColumnsAddNewSystemSqllivenessTable keys.JobsTableID, oldJobsTableSchema, systemschema.JobsTable.GetPrivileges(), + nil, /* sessionDataOverride */ ) require.NoError(t, err)