diff options
author | Michael Paquier <michael@paquier.xyz> | 2023-08-28 13:49:55 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2023-08-28 13:49:55 +0900 |
commit | 165d581f146b09543b832513ee00fead132ba6b1 (patch) | |
tree | a43e1e15c121ed652ffc3969c9d935bc02698f16 /src/backend/utils/adt | |
parent | 9a0ddc39c64b8dddddf4f58eb137f53bf94eb098 (diff) | |
download | postgresql-165d581f146b09543b832513ee00fead132ba6b1.tar.gz postgresql-165d581f146b09543b832513ee00fead132ba6b1.zip |
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
5b3c5953553b or bcc704b524904.
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
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r-- | src/backend/utils/adt/datetime.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 2a5dddc43f3..178b3f47803 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -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; |