| From: | Tatsuo Ishii <ishii(at)postgresql(dot)org> |
|---|---|
| To: | jian(dot)universality(at)gmail(dot)com |
| Cc: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: nodeWindowAgg.c IGNORE NULLS abs overflow |
| Date: | 2026-11-04 07:24:01 |
| Message-ID: | 20261104.162401.118125790227723576.ishii@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Jian,
>> SELECT v,
>> lead(v, -2147483648) OVER w AS respect_nulls,
>> lead(v, -2147483648) IGNORE NULLS OVER w AS ignore_nulls
>> FROM (VALUES (1), (2)) AS t(v)
>> WINDOW w AS (ORDER BY v);
>>
>> should return all NULL values for column ignore_nulls.
>>
>> The fix is to replace the abs function in nodeWindowAgg.c with pg_abs_s32.
I confirmed the problem. It seems it's a corner case bug: only happens
when offset = -2147483648. Anyway, bug is a bug.
Attached is a patch which should be ready for commit IMO. I haven't
changed the C code part from yours. I have changed the regression test
part to use low case SQL statements which fits in better with
surroundings.
Regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-some-window-functions-return-wrong-results-wi.patch | text/x-patch | 4.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Langote | 2026-11-04 07:24:58 | Re: multi-row INSERT broken with a sublink in a target column subscript |
| Previous Message | Amit Langote | 2026-11-04 07:17:13 | Re: [PATCH] Fix segmentation fault caused by reentrancy in RI_Fkey_cascade_del (ri_triggers.c) |