summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2025-10-19 09:29:26 +0900
committerTatsuo Ishii <ishii@postgresql.org>2025-10-19 09:29:26 +0900
commitdd766a441d69d16d1c8ab0d3a41a10649702d202 (patch)
tree364759d853bdb08f809fb72c3a99efdaccfe92c6 /src
parente533524b23b8dd504d38c09c9f84b38289ca635d (diff)
Fix Coverity issue reported in commit 2273fa32bce.HEADorigin/masterorigin/HEADmaster
Coverity complains that the return value from gettuple_eval_partition (stored in variable "datum") in a do..while loop in WinGetFuncArgInPartition is overwritten when exiting the while loop. This commit tries to fix the issue by changing the gettuple_eval_partition call to: (void) gettuple_eval_partition() explicitly stating that we discard the return value. We are just interested in whether we are inside or outside of partition, NULL or NOT NULL here. Also enhance some comments for easier code reading. Reported-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/aPCOabSE4VfJLaky%40paquier.xyz
Diffstat (limited to 'src')
-rw-r--r--src/backend/executor/nodeWindowAgg.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 47e00be7b49..aa145d4e1a9 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -3270,8 +3270,9 @@ window_gettupleslot(WindowObject winobj, int64 pos, TupleTableSlot *slot)
return true;
}
-/*
- * get tuple and evaluate in partition
+/* gettuple_eval_partition
+ * get tuple in a patition and evaluate the window function's argument
+ * expression on it.
*/
static Datum
gettuple_eval_partition(WindowObject winobj, int argno,
@@ -3790,9 +3791,15 @@ WinGetFuncArgInPartition(WindowObject winobj, int argno,
continue; /* keep on moving forward or backward */
else /* need to check NULL or not */
{
- /* get tuple and evaluate in partition */
- datum = gettuple_eval_partition(winobj, argno,
- abs_pos, isnull, &myisout);
+ /*
+ * NOT NULL info does not exist yet. Get tuple and evaluate func
+ * arg in partition. We ignore the return value from
+ * gettuple_eval_partition because we are just interested in
+ * whether we are inside or outside of partition, NULL or NOT
+ * NULL.
+ */
+ (void) gettuple_eval_partition(winobj, argno,
+ abs_pos, isnull, &myisout);
if (myisout) /* out of partition? */
break;
if (!*isnull)
@@ -3802,7 +3809,7 @@ WinGetFuncArgInPartition(WindowObject winobj, int argno,
}
} while (notnull_offset < notnull_relpos);
- /* get tuple and evaluate in partition */
+ /* get tuple and evaluate func arg in partition */
datum = gettuple_eval_partition(winobj, argno,
abs_pos, isnull, &myisout);
if (!myisout && set_mark)