aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/int.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/int.c')
-rw-r--r--src/backend/utils/adt/int.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c
index 019fcaaa36f..a367421f82b 100644
--- a/src/backend/utils/adt/int.c
+++ b/src/backend/utils/adt/int.c
@@ -1382,6 +1382,10 @@ generate_series_step_int4(PG_FUNCTION_ARGS)
/* increment current in preparation for next iteration */
fctx->current += fctx->step;
+ /* if next-value computation overflows, this is the final result */
+ if (SAMESIGN(result, fctx->step) && !SAMESIGN(result, fctx->current))
+ fctx->step = 0;
+
/* do when there is more left to send */
SRF_RETURN_NEXT(funcctx, Int32GetDatum(result));
}