From 239e062650fb1cccee0a54e48544dae42b1a186f Mon Sep 17 00:00:00 2001 From: Matt Spilchen Date: Wed, 18 Dec 2024 08:25:58 -0400 Subject: [PATCH] sql: Internal sessions exempt from disallow_full_table_scans setting 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. --- pkg/sql/internal.go | 1 + .../testdata/logic_test/create_index | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/pkg/sql/internal.go b/pkg/sql/internal.go index abfc04b4e7bb..6559eac363a1 100644 --- a/pkg/sql/internal.go +++ b/pkg/sql/internal.go @@ -94,6 +94,7 @@ func NewInternalSessionData( sd.SequenceState = sessiondata.NewSequenceState() sd.Location = time.UTC sd.StmtTimeout = 0 + sd.DisallowFullTableScans = false return sd } diff --git a/pkg/sql/logictest/testdata/logic_test/create_index b/pkg/sql/logictest/testdata/logic_test/create_index index ef7185151eff..d1d21e361328 100644 --- a/pkg/sql/logictest/testdata/logic_test/create_index +++ b/pkg/sql/logictest/testdata/logic_test/create_index @@ -521,3 +521,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