mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Fix division by zero error in date_bin
Bauyrzhan Sakhariyev, via Github Backpatch to v14
This commit is contained in:
@@ -3843,6 +3843,11 @@ timestamp_bin(PG_FUNCTION_ARGS)
|
||||
|
||||
stride_usecs = stride->day * USECS_PER_DAY + stride->time;
|
||||
|
||||
if (stride_usecs == 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("stride cannot equal zero")));
|
||||
|
||||
tm_diff = timestamp - origin;
|
||||
tm_delta = tm_diff - tm_diff % stride_usecs;
|
||||
|
||||
@@ -4021,6 +4026,11 @@ timestamptz_bin(PG_FUNCTION_ARGS)
|
||||
|
||||
stride_usecs = stride->day * USECS_PER_DAY + stride->time;
|
||||
|
||||
if (stride_usecs == 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("stride cannot equal zero")));
|
||||
|
||||
tm_diff = timestamp - origin;
|
||||
tm_delta = tm_diff - tm_diff % stride_usecs;
|
||||
|
||||
|
Reference in New Issue
Block a user