| From: | Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Questionable coding in nth_value |
| Date: | 2023-05-06 08:44:16 |
| Message-ID: | 20230506.174416.957742257125695199.t-ishii@sranhm.sra.co.jp |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Currently Window function nth_value is coded as following:
nth = DatumGetInt32(WinGetFuncArgCurrent(winobj, 1, &isnull));
if (isnull)
PG_RETURN_NULL();
const_offset = get_fn_expr_arg_stable(fcinfo->flinfo, 1);
if (nth <= 0)
ereport(ERROR,
:
:
Is there any reason why argument 'nth' is not checked earlier?
IMO, it is more natural "if (nth <= 0)..." is placed right after "nth = DatumGetInt32...".
Attached is the patch which does this.
Best reagards,
--
Tatsuo Ishii
SRA OSS LLC
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
| Attachment | Content-Type | Size |
|---|---|---|
| fix_nth_value.patch | text/x-patch | 821 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Guo | 2023-05-06 09:02:49 | Re: Questionable coding in nth_value |
| Previous Message | Oliver Ford | 2023-05-06 08:41:49 | Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options |