Skip to content

Commit

Permalink
Merge pull request #12566 from jordanlewis/fix-second-interval-precision
Browse files Browse the repository at this point in the history
sql: fix parsing of second-precise intervals
  • Loading branch information
jordanlewis authored Dec 24, 2016
2 parents fd729f0 + 1bc5527 commit 0efe656
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/sql/parser/sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/sql/parser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -3466,7 +3466,7 @@ opt_interval:
}
| interval_second
{
$$.val = $1
$$.val = $1.durationField()
}
// Like Postgres, we ignore the left duration field. See explanation:
// https://www.postgresql.org/message-id/20110510040219.GD5617%40tornado.gateway.2wire.net
Expand All @@ -3484,19 +3484,19 @@ opt_interval:
}
| DAY TO interval_second
{
$$.val = $3
$$.val = $3.durationField()
}
| HOUR TO MINUTE
{
$$.val = minute
}
| HOUR TO interval_second
{
$$.val = $3
$$.val = $3.durationField()
}
| MINUTE TO interval_second
{
$$.val = $3
$$.val = $3.durationField()
}
| /* EMPTY */ {}

Expand Down
16 changes: 16 additions & 0 deletions pkg/sql/testdata/datetime
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,22 @@ SHOW TIME ZONE
----
-5

statement ok
SET TIME ZONE INTERVAL '+04:00' HOUR TO MINUTE;

query T
SELECT '2015-08-24 21:45:45.53453'::timestamptz
----
2015-08-24 21:45:45.53453 +0400 +0400

statement ok
SET TIME ZONE INTERVAL '-04:00' MINUTE TO SECOND;

query T
SELECT '2015-08-24 21:45:45.53453'::timestamptz
----
2015-08-24 21:45:45.53453 -0400 -0400

statement ok
SET TIME ZONE 0

Expand Down

0 comments on commit 0efe656

Please sign in to comment.