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: support optional INTERVAL precision #32564

Closed
knz opened this issue Nov 22, 2018 · 0 comments · Fixed by #43130
Closed

sql: support optional INTERVAL precision #32564

knz opened this issue Nov 22, 2018 · 0 comments · Fixed by #43130
Assignees
Labels
A-sql-datatypes SQL column types usable in table descriptors. A-sql-pgcompat Semantic compatibility with PostgreSQL C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) X-anchored-telemetry The issue number is anchored by telemetry references.

Comments

@knz
Copy link
Contributor

knz commented Nov 22, 2018

Is your feature request related to a problem? Please describe.

CREATE TABLE t(x INTERVAL(6)) should work

See: https://www.postgresql.org/docs/11/static/datatype-datetime.html#DATATYPE-TIMEZONES

time, timestamp, and interval accept an optional precision value p which specifies the number of fractional digits retained in the seconds field. By default, there is no explicit bound on precision. The allowed range of p is from 0 to 6.

Describe the solution you'd like

MVP: An optional precision of 6 should be recognized and ignored

Optionally: support for other precisions than 6, for example 9 as is currently done in CockroachDB.

Workaround

If the desired precision is 9, then the precision can be omitted altogether to obtain equivalent behavior.

@knz knz added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-datatypes SQL column types usable in table descriptors. X-anchored-telemetry The issue number is anchored by telemetry references. labels Nov 22, 2018
knz added a commit to knz/cockroach that referenced this issue Nov 22, 2018
knz added a commit to knz/cockroach that referenced this issue Nov 26, 2018
knz added a commit to knz/cockroach that referenced this issue Nov 28, 2018
jordanlewis added a commit to jordanlewis/cockroach that referenced this issue Oct 5, 2019
This commit lets the parser accept the type INTERVAL(6) as a no-op
equivalent to INTERVAL. This is safe and equivalent to what we do for
INTERVAL on its own.

Updates cockroachdb#32564.

Release justification: low-risk compatibility fix
Release note (sql change): support interval precision syntax when the
requested precision is exactly 6, as a syntactic sugar for intervals
without a precision specified.
jordanlewis added a commit to jordanlewis/cockroach that referenced this issue Oct 8, 2019
This commit lets the parser accept the type INTERVAL(6) as a no-op
equivalent to INTERVAL. This is safe and equivalent to what we do for
INTERVAL on its own.

Updates cockroachdb#32564.

Release justification: low-risk compatibility fix
Release note (sql change): support interval precision syntax when the
requested precision is exactly 6, as a syntactic sugar for intervals
without a precision specified.
jordanlewis added a commit to jordanlewis/cockroach that referenced this issue Oct 8, 2019
This commit lets the parser accept the type INTERVAL(6) as a no-op
equivalent to INTERVAL. This is safe and equivalent to what we do for
INTERVAL on its own.

Updates cockroachdb#32564.

Release justification: low-risk compatibility fix
Release note (sql change): support interval precision syntax when the
requested precision is exactly 6, as a syntactic sugar for intervals
without a precision specified.
jordanlewis added a commit to jordanlewis/cockroach that referenced this issue Oct 8, 2019
This commit lets the parser accept the type INTERVAL(6) as a no-op
equivalent to INTERVAL. This is safe and equivalent to what we do for
INTERVAL on its own.

Updates cockroachdb#32564.

Release justification: low-risk compatibility fix
Release note (sql change): support interval precision syntax when the
requested precision is exactly 6, as a syntactic sugar for intervals
without a precision specified.
@otan otan self-assigned this Dec 3, 2019
@craig craig bot closed this as completed in 2f1e342 Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-datatypes SQL column types usable in table descriptors. A-sql-pgcompat Semantic compatibility with PostgreSQL C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) X-anchored-telemetry The issue number is anchored by telemetry references.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants