Skip to content

Commit

Permalink
opt: finalize reorder_joins_limit setting
Browse files Browse the repository at this point in the history
This commit removes "experimental" from the experimental_reorder_joins_limit
session setting. It also adds validation to ensure users cannot set it to
a negative value.

Fixes cockroachdb#35348

Release note (sql change): Changed the experimental_reorder_joins_limit
session setting to remove "experimental" from the name.
  • Loading branch information
rytaft committed Mar 24, 2019
1 parent 3f53398 commit e1be0b5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions pkg/sql/logictest/testdata/logic_test/pg_catalog
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,6 @@ default_transaction_read_only off NULL NULL NULL
distsql off NULL NULL NULL string
experimental_enable_zigzag_join off NULL NULL NULL string
experimental_force_split_at off NULL NULL NULL string
experimental_reorder_joins_limit 4 NULL NULL NULL string
experimental_serial_normalization rowid NULL NULL NULL string
experimental_vectorize off NULL NULL NULL string
extra_float_digits 0 NULL NULL NULL string
Expand All @@ -1444,6 +1443,7 @@ intervalstyle postgres NULL NULL NULL
lock_timeout 0 NULL NULL NULL string
max_index_keys 32 NULL NULL NULL string
node_id 1 NULL NULL NULL string
reorder_joins_limit 4 NULL NULL NULL string
results_buffer_size 16384 NULL NULL NULL string
row_security off NULL NULL NULL string
search_path public NULL NULL NULL string
Expand Down Expand Up @@ -1483,7 +1483,6 @@ default_transaction_read_only off NULL user NULL off
distsql off NULL user NULL off off
experimental_enable_zigzag_join off NULL user NULL off off
experimental_force_split_at off NULL user NULL off off
experimental_reorder_joins_limit 4 NULL user NULL 4 4
experimental_serial_normalization rowid NULL user NULL rowid rowid
experimental_vectorize off NULL user NULL off off
extra_float_digits 0 NULL user NULL 0 2
Expand All @@ -1494,6 +1493,7 @@ intervalstyle postgres NULL user NULL post
lock_timeout 0 NULL user NULL 0 0
max_index_keys 32 NULL user NULL 32 32
node_id 1 NULL user NULL 1 1
reorder_joins_limit 4 NULL user NULL 4 4
results_buffer_size 16384 NULL user NULL 16384 16384
row_security off NULL user NULL off off
search_path public NULL user NULL public public
Expand Down Expand Up @@ -1529,7 +1529,6 @@ default_transaction_read_only NULL NULL NULL NULL NULL
distsql NULL NULL NULL NULL NULL
experimental_enable_zigzag_join NULL NULL NULL NULL NULL
experimental_force_split_at NULL NULL NULL NULL NULL
experimental_reorder_joins_limit NULL NULL NULL NULL NULL
experimental_serial_normalization NULL NULL NULL NULL NULL
experimental_vectorize NULL NULL NULL NULL NULL
extra_float_digits NULL NULL NULL NULL NULL
Expand All @@ -1541,6 +1540,7 @@ lock_timeout NULL NULL NULL NULL NULL
max_index_keys NULL NULL NULL NULL NULL
node_id NULL NULL NULL NULL NULL
optimizer NULL NULL NULL NULL NULL
reorder_joins_limit NULL NULL NULL NULL NULL
results_buffer_size NULL NULL NULL NULL NULL
row_security NULL NULL NULL NULL NULL
search_path NULL NULL NULL NULL NULL
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/logictest/testdata/logic_test/show_source
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ default_transaction_read_only off
distsql off
experimental_enable_zigzag_join off
experimental_force_split_at off
experimental_reorder_joins_limit 4
experimental_serial_normalization rowid
experimental_vectorize off
extra_float_digits 0
Expand All @@ -49,6 +48,7 @@ intervalstyle postgres
lock_timeout 0
max_index_keys 32
node_id 1
reorder_joins_limit 4
results_buffer_size 16384
row_security off
search_path public
Expand Down
8 changes: 4 additions & 4 deletions pkg/sql/opt/exec/execbuilder/testdata/explain_env
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ inner-join
#

statement ok
SET experimental_reorder_joins_limit = 100
SET reorder_joins_limit = 100

query T
SELECT text FROM [
Expand All @@ -233,7 +233,7 @@ CREATE TABLE y (
·
ALTER TABLE test.public.y INJECT STATISTICS '[]';
·
SET experimental_reorder_joins_limit = 100;
SET reorder_joins_limit = 100;
·
SELECT text FROM [EXPLAIN (OPT, ENV) SELECT * FROM y WHERE u = 3] WHERE (text NOT LIKE '%Version%') OR (text LIKE '%EXPLAIN%');
----
Expand All @@ -260,7 +260,7 @@ CREATE TABLE y (
·
ALTER TABLE test.public.y INJECT STATISTICS '[]';
·
SET experimental_reorder_joins_limit = 100;
SET reorder_joins_limit = 100;
·
SET experimental_enable_zigzag_join = on;
·
Expand All @@ -270,7 +270,7 @@ scan y
└── constraint: /1: [/3 - /3]

statement ok
RESET experimental_reorder_joins_limit
RESET reorder_joins_limit

statement ok
RESET experimental_enable_zigzag_join
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/opt/exec/execbuilder/testdata/join_order
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CREATE TABLE abc (
)

statement ok
SET experimental_reorder_joins_limit = 0
SET reorder_joins_limit = 0

query TTTTT
EXPLAIN (VERBOSE) SELECT * FROM abc, bx, cy WHERE a = 1 AND abc.b = bx.b AND abc.c = cy.c
Expand Down Expand Up @@ -59,7 +59,7 @@ render · · (a, b, c, d, b, x, c
· spans /1-/1/# · ·

statement ok
SET experimental_reorder_joins_limit = 3
SET reorder_joins_limit = 3

query TTTTT
EXPLAIN (VERBOSE) SELECT * FROM abc, bx, cy WHERE a = 1 AND abc.b = bx.b AND abc.c = cy.c
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt_exec_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ FROM
// Show the values of any non-default session variables that can impact
// planning decisions.
for _, param := range []string{
"experimental_reorder_joins_limit",
"reorder_joins_limit",
"experimental_enable_zigzag_join",
} {
value, err := ef.environmentQuery(fmt.Sprintf("SHOW %s", param))
Expand Down
8 changes: 6 additions & 2 deletions pkg/sql/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,17 @@ var varGen = map[string]sessionVar{
},

// CockroachDB extension.
`experimental_reorder_joins_limit`: {
GetStringVal: makeIntGetStringValFn(`experimental_reorder_joins_limit`),
`reorder_joins_limit`: {
GetStringVal: makeIntGetStringValFn(`reorder_joins_limit`),
Set: func(_ context.Context, m *sessionDataMutator, s string) error {
b, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return err
}
if b < 0 {
return pgerror.NewErrorf(pgerror.CodeInvalidParameterValueError,
"cannot set reorder_joins_limit to a negative value: %d", b)
}
m.SetReorderJoinsLimit(int(b))
return nil
},
Expand Down

0 comments on commit e1be0b5

Please sign in to comment.