Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: Internal sessions exempt from disallow_full_table_scans setting #137681

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/sql/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func NewInternalSessionData(
sd.SequenceState = sessiondata.NewSequenceState()
sd.Location = time.UTC
sd.StmtTimeout = 0
sd.DisallowFullTableScans = false
return sd
}

Expand Down
43 changes: 43 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/create_index
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,27 @@ CREATE INVERTED INDEX ON opclasses(c DESC)
statement ok
CREATE INVERTED INDEX ON opclasses(a DESC, c)

# Regression test for GH issue #137404
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these tests are great!

we could add an additional one here, similar to what we have for statement_timeout:

# Ensure that StmtTimeout for a session-independent IE cannot be overriden.
subtest stmt_timeout
statement ok
SET CLUSTER SETTING sql.defaults.statement_timeout = '36000000ms';
statement ok
SET statement_timeout = '39600000ms';
query T
SELECT crdb_internal.execute_internally('SHOW statement_timeout;');
----
0
# Ensure that a session-bound IE still inherits from session vars, if available;
# otherwise, it inherits from the cluster setting.
query T
SELECT crdb_internal.execute_internally('SHOW statement_timeout;', true);
----
39600000

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. Thanks.

subtest disallow_full_table_scans

let $disallow_full_table_scans
select value from [show cluster settings] where variable = 'sql.defaults.disallow_full_table_scans.enabled';

statement ok
SET CLUSTER SETTING sql.defaults.disallow_full_table_scans.enabled = true;

statement ok
CREATE TABLE t_disable_full_ts (id UUID PRIMARY KEY);

statement ok
CREATE INDEX ON t_disable_full_ts (id);

statement ok
SET CLUSTER SETTING sql.defaults.disallow_full_table_scans.enabled = $disallow_full_table_scans;

statement ok
DROP TABLE t_disable_full_ts

subtest create_index_on_materialized_view

statement ok
Expand Down Expand Up @@ -521,3 +542,25 @@ CREATE INDEX IF NOT EXISTS idx ON tbl_ifne (b) STORING (a)

statement ok
DROP TABLE tbl_ifne CASCADE

subtest disallow_full_table_scans

let $disallow_full_table_scans
select value from [show cluster settings] where variable = 'sql.defaults.disallow_full_table_scans.enabled';

statement ok
SET CLUSTER SETTING sql.defaults.disallow_full_table_scans.enabled = true;

statement ok
CREATE TABLE t_disable_full_ts (id UUID PRIMARY KEY);

statement ok
CREATE INDEX ON t_disable_full_ts (id);

statement ok
SET CLUSTER SETTING sql.defaults.disallow_full_table_scans.enabled = $disallow_full_table_scans;

statement ok
DROP TABLE t_disable_full_ts

subtest end
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,33 @@ SELECT crdb_internal.execute_internally('SHOW statement_timeout;', true);
statement ok
RESET CLUSTER SETTING sql.defaults.statement_timeout;

subtest disallow_full_table_scans

statement ok
SET CLUSTER SETTING sql.defaults.disallow_full_table_scans.enabled = true;

statement ok
SET disallow_full_table_scans = 'true';

query T
SELECT crdb_internal.execute_internally('SHOW disallow_full_table_scans;');
----
off

query T
SELECT crdb_internal.execute_internally('SHOW disallow_full_table_scans;', true);
----
on

statement ok
RESET CLUSTER SETTING sql.defaults.disallow_full_table_scans.enabled;

statement ok
RESET disallow_full_table_scans;

query T
SELECT crdb_internal.execute_internally('SHOW disallow_full_table_scans;', true);
----
off

subtest end
Loading