Skip to content

Commit

Permalink
sql: Internal sessions exempt from disallow_full_table_scans setting
Browse files Browse the repository at this point in the history
Previously, enabling the cluster setting
sql.defaults.disallow_full_table_scans.enabled prevented the creation of
indexes due to the internal table scans required during the process.
This change ensures that the setting is bypassed for internal
operations, while still applying to user queries.

Epic: None
Closes: #137404
Release note (bug fix): Internal scans are now exempt from the
sql.defaults.disallow_full_table_scans.enabled setting, allowing index
creation even when the cluster setting is active.
  • Loading branch information
spilchen committed Dec 18, 2024
1 parent 88c47ab commit 117a82b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
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
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

0 comments on commit 117a82b

Please sign in to comment.