Skip to content

sql: add alias timezone for time zone session var#19931

Merged
knz merged 1 commit intocockroachdb:masterfrom
ctkou:timezone-alias
Nov 13, 2017
Merged

sql: add alias timezone for time zone session var#19931
knz merged 1 commit intocockroachdb:masterfrom
ctkou:timezone-alias

Conversation

@ctkou
Copy link
Copy Markdown
Contributor

@ctkou ctkou commented Nov 9, 2017

Closes #19440

Release notes: the session variable previously called "time zone" (with a space) is now renamed to "timezone" (with no space), like the one in Postgres. The standard SQL statements SET TIME ZONE / SHOW TIME ZONE are still supported for compatibility, but it is now also possible to set the session timezone with SET TIMEZONE = like is standard with Postgres.

@ctkou ctkou requested a review from a team November 9, 2017 05:53
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Nov 9, 2017

CLA assistant check
All committers have signed the CLA.

@knz
Copy link
Copy Markdown
Contributor

knz commented Nov 9, 2017

Hi @ctkou! Thank you for your help and your interest in this.

Also your code looks very good. Thank you for this.

Since you now understand this code well, I have a pleading request -- could you take this opportunity to help us and remove an annoying thorn in our code?

  1. the thorn: the Postgres name for the session variable is "timezone" without a space. It's bad for compatibility that CockroachDB names this "time zone" with a space. Hence my request: instead of piling up more code around this compatibility mismatch, can you modify sql/vars.go and rename the variable?

  2. then modify sql.y so that SET TIME ZONE produces a SetVar on the "timezone" variable, not "time zone". Then modify the SET TIME ZONE tests in parse_test.go accordingly and all the logic tests that print out the list of variable names (I think there are some in pkg/sql/logictest/testdata/logic_test/pg_catalog, information_schema and perhaps elsewhere).

  3. then you can remove the new rule for SET TIMEZONE that your patch was originally added, because it will now be handled automatically by the default code path.

  4. you then don't need new tests for SET TIMEZONE in parse_test.go, however I would encourage you to add a few SET TIMEZONE tests in pkg/sql/logictest/testdata/logic_test/datetime to check that the behavior is indeed equivalent.


Reviewed 5 of 5 files at r1.
Review status: :shipit: all files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from Reviewable

@knz knz self-requested a review November 9, 2017 11:09
@knz knz added the docs-todo label Nov 9, 2017
@knz knz requested review from knz and removed request for knz November 9, 2017 11:24
@ctkou
Copy link
Copy Markdown
Contributor Author

ctkou commented Nov 9, 2017

@knz

Okay, thanks for reviewing my code. I will get that "thorn" out like you said. :)

@ctkou
Copy link
Copy Markdown
Contributor Author

ctkou commented Nov 10, 2017

Hi @knz ,

I am not familiar with parsing, but it seems to me that for Set, the TIMEZONE token is still needed after changing 'time zone' to 'timezone'. For generic_set, var_name and var_list are separated by either TO or '=', so "SET TIMEZONE = 'UTC'" and "SET TIMEZONE TO 'UTC'" works but "SET TIMEZONE 'UTC'" doesn't unless a TIMEZONE token is defined.

@knz
Copy link
Copy Markdown
Contributor

knz commented Nov 10, 2017

You are correct that supporting SET TIMEZONE 'UTC' would require a separate token and grammar rule. However, this syntax is not needed to solve #19440, and I believe is not supported by Postgres (at least I do not see it here: https://www.postgresql.org/docs/current/static/sql-set.html and psql returns an error if I use it)

@ctkou ctkou requested review from a team November 11, 2017 09:38
@knz
Copy link
Copy Markdown
Contributor

knz commented Nov 11, 2017

This patch is very good. Thank you. :lgtm:

Can you please squash the two commits together before we can merge this? Thanks!


Reviewed 5 of 5 files at r2, 9 of 9 files at r3.
Review status: :shipit: all files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from Reviewable

@knz
Copy link
Copy Markdown
Contributor

knz commented Nov 13, 2017

Reviewed 3 of 3 files at r4.
Review status: :shipit: all files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from Reviewable

@knz
Copy link
Copy Markdown
Contributor

knz commented Nov 13, 2017

Thank you again!

@knz knz merged commit 65bbf78 into cockroachdb:master Nov 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants