RE: [BUG] (firsttupleslot)==NULL is redundant or is possible nulldereference? - Mailing list pgsql-hackers

From Ranier Vilela
Subject RE: [BUG] (firsttupleslot)==NULL is redundant or is possible nulldereference?
Date
Msg-id MN2PR18MB29277475FE1330608B738C93E3480@MN2PR18MB2927.namprd18.prod.outlook.com
Whole thread Raw
In response to Re: [BUG] (firsttupleslot)==NULL is redundant or is possible nulldereference?  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-hackers
>And why do you think this is a bug? Immediately before the part of code
>you copied we have this:
>
>     /*
>      * The ScanTupleSlot holds the (copied) first tuple of each group.
>      */
>     firsttupleslot = node->ss.ss_ScanTupleSlot;
>And node->ss.ss_ScanTupleSlot is expected to be non-NULL. So the initial
>assumption that firsttupleslot is NULL is incorrect.

IMHO, the test could be improved, this way it silences the scan tool.

--- \dll\postgresql-12.0\a\backend\executor\nodeGroup.c    Mon Sep 30 17:06:55 2019
+++ nodeGroup.c    Sat Nov 23 00:23:27 2019
@@ -64,7 +64,7 @@
      * If first time through, acquire first input tuple and determine whether
      * to return it or not.
      */
-    if (TupIsNull(firsttupleslot))
+    if ((firsttupleslot != NULL) && TTS_EMPTY(firsttupleslot))
     {
         outerslot = ExecProcNode(outerPlanState(node));
         if (TupIsNull(outerslot))

best regards.
Ranier Vilela


pgsql-hackers by date:

Previous
From: Mark Dilger
Date:
Subject: Re: Assertion failing in master, predicate.c
Next
From: Amit Kapila
Date:
Subject: Re: Ordering of header file inclusion