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

encode: fix 2400 time encoding for time/timetz #944

Merged
merged 1 commit into from
May 7, 2020

Conversation

otan
Copy link
Collaborator

@otan otan commented Feb 25, 2020

Note that Postgres supports 24:00 for both time and timetz operations.

When evaluating "24:00" for both Time and TimeTZ datatypes, the
time.Time library does not recognise 24 as a legitimate hour. This
requires special parsing for it to work. As such, work around the
problem by subtracting a day, and adding it back later when we recognize
it as 24:00 time.

@otan
Copy link
Collaborator Author

otan commented Feb 25, 2020

looks like it passes on CI, but the "PASS" is interpreted incorrectly.

var is2400Time bool
switch typ {
case oid.T_timetz, oid.T_time:
if matches := time2400Regex.FindStringSubmatch(str); matches != nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(alternative parsing suggestions welcome)

otan added a commit to otan-cockroach/cockroach that referenced this pull request Feb 25, 2020
We previously relied on golang's time.Time library to return 24:00 time
for us; however, time.Time does not parse 24:00 well, nor does it print
24:00 as on the same day (it uses the next day).

As such, when parsing or emitting time.Time, we have to be super weary
of how we output 24:00 time. Two major changes:
* update lib/pq to pick up lib/pq#944 such that
it can parse 24:00 time externally.
* update places where time.Time is parsed from a go driver or lib/pq to
correctly handle 24:00 cases.

Release note (sql change, bug fix): 24:00 time now displays correctly in
the cli, returning `0001-01-02 00:00:00`. Furthermore, backups correctly
emit and read in 24:00 time properly.
encode.go Outdated Show resolved Hide resolved
@otan otan force-pushed the attempt_2400_fix branch 2 times, most recently from 9e77527 to 564bca4 Compare May 7, 2020 21:06
go.mod Outdated
@@ -1 +1,3 @@
module github.com/lib/pq

go 1.13
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be reverted

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

running go test keeps bringing it back, urgh

Note that Postgres supports 24:00 for both time and timetz operations.

When evaluating "24:00" for both Time and TimeTZ datatypes, the
time.Time library does not recognise 24 as a legitimate hour. This
requires special parsing for it to work. As such, work around the
problem by subtracting a day, and adding it back later when we recognize
it as 24:00 time.
@maddyblue maddyblue merged commit f3b22b2 into lib:master May 7, 2020
otan added a commit to otan-cockroach/cockroach that referenced this pull request May 21, 2020
We previously relied on golang's time.Time library to return 24:00 time
for us; however, time.Time does not parse 24:00 well, nor does it print
24:00 as on the same day (it uses the next day).

As such, when parsing or emitting time.Time, we have to be super weary
of how we output 24:00 time. Two major changes:
* update lib/pq to pick up lib/pq#944 such that
it can parse 24:00 time externally.
* update places where time.Time is parsed from a go driver or lib/pq to
correctly handle 24:00 cases.

Release note (sql change, bug fix): 24:00 time now displays correctly in
the cli, returning `0001-01-02 00:00:00`. Furthermore, backups correctly
emit and read in 24:00 time properly.
craig bot pushed a commit to cockroachdb/cockroach that referenced this pull request May 21, 2020
49272: opt: add cost for executing geo functions in filters r=mjibson a=mjibson

Geo costing is now the only function that multiplies its row count by
the filters cost. The other JOINs and SELECT will be added in another
PR since it is a more complicated change due to some plans changing,
which must come with some justification.

Fixes #48214

Release note: None

49330: pgwire: transmit 24:00 correctly for Time/TimeTZ r=rohany a=otan

We previously relied on golang's time.Time library to return 24:00 time
for us; however, time.Time does not parse 24:00 well, nor does it print
24:00 as on the same day (it uses the next day).

As such, when parsing or emitting time.Time, we have to be super weary
of how we output 24:00 time. Two major changes:
* update lib/pq to pick up lib/pq#944 such that
it can parse 24:00 time externally.
* update places where time.Time is parsed from a go driver or lib/pq to
correctly handle 24:00 cases.

Resolves #44548.

Release note (sql change, bug fix): 24:00 time now displays correctly in
the cli, returning `0001-01-02 00:00:00`. Furthermore, backups correctly
emit and read in 24:00 time properly.

49372: server: Resolve default engine type in testserver r=itsbilal a=itsbilal

Previously we weren't resolving the engine type if it was
set to EngineTypeDefault in the testserver. This would silently
resolve to Pebble (and in 20.1, rocksdb) anyway, so it was
only a concern in sentry reports where it would show up as
`default`. Since `cockroach demo` uses the test server and
has sentry reports enabled, that was an oversight.

Release note (bug fix): Report engine type correctly in bug reports
when using `cockroach demo`.

Co-authored-by: Matt Jibson <matt.jibson@gmail.com>
Co-authored-by: Oliver Tan <otan@cockroachlabs.com>
Co-authored-by: Bilal Akhtar <bilal@cockroachlabs.com>
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.

2 participants