Skip to content

Commit f16740d

Browse files
committed
sql: add some additional testing in mixed_version_bundle
This is a test-only change to add some additional testing for the version gate for the new column in system.statement_diagnostics_requests. Informs #143484 Release note: None
1 parent 76e7d25 commit f16740d

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

pkg/sql/logictest/testdata/logic_test/mixed_version_bundle

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ SELECT pg_sleep(1);
4242
statement ok
4343
EXPLAIN ANALYZE (DEBUG) SELECT * FROM t;
4444

45+
statement ok
46+
SELECT crdb_internal.request_statement_bundle('SELECT _, _, _ FROM _', 0::FLOAT, 0::INTERVAL, 0::INTERVAL);
47+
4548
upgrade 0
4649

4750
statement ok
@@ -50,10 +53,60 @@ SELECT pg_sleep(1);
5053
statement ok
5154
EXPLAIN ANALYZE (DEBUG) SELECT * FROM t;
5255

56+
statement ok
57+
GRANT SYSTEM VIEWACTIVITY TO testuser;
58+
GRANT SELECT ON t TO testuser;
59+
60+
user testuser
61+
62+
# Request a statement bundle as testuser. The user won't be captured since
63+
# the cluster setting is not yet active.
64+
statement ok
65+
SELECT crdb_internal.request_statement_bundle('SELECT _, _, _, _ FROM _', 0::FLOAT, 0::INTERVAL, 0::INTERVAL);
66+
67+
user root
68+
5369
upgrade 2
5470

71+
# Block until upgrade is complete.
72+
statement ok
73+
SET CLUSTER SETTING version = crdb_internal.node_executable_version();
74+
75+
query B retry
76+
SELECT crdb_internal.is_at_least_version('25.1-08')
77+
----
78+
true
79+
5580
statement ok
5681
SELECT pg_sleep(1);
5782

83+
user testuser
84+
85+
# Request a statement bundle as testuser. Since it's an explicit
86+
# EXPLAIN ANALYZE (DEBUG) invocation, we don't store the username in
87+
# system.statement_diagnostics_requests.
5888
statement ok
5989
EXPLAIN ANALYZE (DEBUG) SELECT * FROM t;
90+
91+
# Request a statement bundle as testuser. The user should be captured since
92+
# the cluster setting is now active.
93+
statement ok
94+
SELECT crdb_internal.request_statement_bundle('SELECT _, _, _, _, _ FROM _', 0::FLOAT, 0::INTERVAL, 0::INTERVAL);
95+
96+
user root
97+
98+
# Currently the user is not set for requests added with EXPLAIN ANALYZE (DEBUG).
99+
# For other requests, the user is only set once the cluster setting is active,
100+
# in this case for the final invocation of crdb_internal.request_statement_bundle.
101+
query TT
102+
SELECT statement_fingerprint, username FROM system.statement_diagnostics_requests
103+
ORDER BY statement_fingerprint;
104+
----
105+
EXPLAIN ANALYZE (DEBUG) SELECT * FROM t ·
106+
EXPLAIN ANALYZE (DEBUG) SELECT * FROM t ·
107+
EXPLAIN ANALYZE (DEBUG) SELECT * FROM t ·
108+
EXPLAIN ANALYZE (DEBUG) SELECT * FROM t ·
109+
SELECT _, _ FROM _ ·
110+
SELECT _, _, _ FROM _ ·
111+
SELECT _, _, _, _ FROM _ ·
112+
SELECT _, _, _, _, _ FROM _ testuser

0 commit comments

Comments
 (0)