mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-10 09:57:34 +08:00
Tighten unit parsing in internal values
Interval values now generate an error when the user has multiple consecutive units or a unit without a value. Previously, it was possible to specify multiple units consecutively which is contrary to what the documentation allows, so it was possible to finish with confusing interval values. This is a follow-up of the work done in 165d581f146b. Author: Joseph Koshakow Reviewed-by: Jacob Champion, Gurjeet Singh, Reid Thompson Discussion: https://postgr.es/m/CAAvxfHd-yNO+XYnUxL=GaNZ1n+eE0V-oE0+-cC1jdjdU0KS3iw@mail.gmail.com
This commit is contained in:
@ -1796,3 +1796,12 @@ SELECT INTERVAL '2 minutes ago 5 days';
|
||||
ERROR: invalid input syntax for type interval: "2 minutes ago 5 days"
|
||||
LINE 1: SELECT INTERVAL '2 minutes ago 5 days';
|
||||
^
|
||||
-- consecutive and dangling units are not allowed.
|
||||
SELECT INTERVAL 'hour 5 months';
|
||||
ERROR: invalid input syntax for type interval: "hour 5 months"
|
||||
LINE 1: SELECT INTERVAL 'hour 5 months';
|
||||
^
|
||||
SELECT INTERVAL '1 year months days 5 hours';
|
||||
ERROR: invalid input syntax for type interval: "1 year months days 5 hours"
|
||||
LINE 1: SELECT INTERVAL '1 year months days 5 hours';
|
||||
^
|
||||
|
||||
@ -586,3 +586,7 @@ SELECT extract(epoch from interval '1000000000 days');
|
||||
-- "ago" can only appear once at the end of an interval.
|
||||
SELECT INTERVAL '42 days 2 seconds ago ago';
|
||||
SELECT INTERVAL '2 minutes ago 5 days';
|
||||
|
||||
-- consecutive and dangling units are not allowed.
|
||||
SELECT INTERVAL 'hour 5 months';
|
||||
SELECT INTERVAL '1 year months days 5 hours';
|
||||
|
||||
Reference in New Issue
Block a user