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: fix bug where some session vars couldn't be set to "on" or "off" #46163

Merged
merged 1 commit into from
Mar 17, 2020

Conversation

rohany
Copy link
Contributor

@rohany rohany commented Mar 16, 2020

Session variables were incorrectly erroring out on
string inputs even though string values of "on" and
"off" are accepted.

Fixes #46161.

Release justification: bug fix
Release note (bug fix): This PR fixes a bug where various session
variables whose value would display as "on" or "off" could not be
set to the values "on" or "off", only true or false.

@rohany rohany requested a review from knz March 16, 2020 20:26
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

Sorry I don't understand the code change. Why was the previous code incorrect? Can you walk me through the analysis step by step?

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@rohany
Copy link
Contributor Author

rohany commented Mar 17, 2020

all vars that had a GetStringVal function equal to makeBoolGetStringVal would have GetStringVal called on the input datum before Set was called. makeBoolGetStringVal would call into getSingleBool on the input datum, and would error out if the input datum wasn't a DBool. That's incorrect, because we allow for DString datums in these variables, as long as they are equal to on or off, which the Set function for these vars handles.

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

Thanks. Maybe would have helped to add this explanation to the commit message.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rohany)


pkg/sql/vars.go, line 902 at r1 (raw file):

}

func makeBoolGetStringValFn(varName string) getStringValFn {

Please spell out the semantics of this function in a docstring above it.


pkg/sql/vars.go, line 1040 at r1 (raw file):

}()

func getSingleBool(name string, val tree.Datum) (*tree.DBool, error) {

ditto

@rohany
Copy link
Contributor Author

rohany commented Mar 17, 2020

Updated. I think this should be backported, what do you think?

@awoods187
Copy link
Contributor

+1 on backport

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

:lgtm: yes to backport

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm: Thanks!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @knz and @rohany)


pkg/sql/logictest/testdata/logic_test/set, line 336 at r3 (raw file):

# Ensure that we can set variables to on/off.
statement ok
SET enable_zigzag_join = 'on';

If we want true and false to work as well, we should add those tests too.

@rohany
Copy link
Contributor Author

rohany commented Mar 17, 2020

bors r+

@rohany
Copy link
Contributor Author

rohany commented Mar 17, 2020

bors r-

@craig
Copy link
Contributor

craig bot commented Mar 17, 2020

Canceled

Session variables were incorrectly erroring out on
string inputs even though string values of "on" and
"off" are accepted.

Fixes cockroachdb#46161.

Release justification: bug fix
Release note (bug fix): This PR fixes a bug where various session
variables whose value would display as "on" or "off" could not be
set to the values "on" or "off", only true or false.
@rohany
Copy link
Contributor Author

rohany commented Mar 17, 2020

bors r+

@craig
Copy link
Contributor

craig bot commented Mar 17, 2020

Build succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

experimental_enable_hash_sharded_indexes takes incorrect values
5 participants