1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Tighten handling of "ago" in interval values

This commit Restrict the unit "ago" to only appear at the end of the
interval.  According to the documentation, a direction can only be
defined at the end of an interval, but it was possible to define it in
the middle of the string or define it multiple times.

In spirit, this is similar to the error handling improvements done in
5b3c595355 or bcc704b524.

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:
Michael Paquier
2023-08-28 13:49:55 +09:00
parent 9a0ddc39c6
commit 165d581f14
3 changed files with 20 additions and 0 deletions

View File

@@ -3578,6 +3578,13 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
break;
case AGO:
/*
* "ago" is only allowed to appear at the end of the
* interval.
*/
if (i != nf - 1)
return DTERR_BAD_FORMAT;
is_before = true;
type = uval;
break;