Re: [PATCH] Tiny optmization or a bug? - Mailing list pgsql-hackers

From Tomas Vondra
Subject Re: [PATCH] Tiny optmization or a bug?
Date
Msg-id 20191122232533.5getrmipxu2gtaxb@development
Whole thread Raw
In response to [PATCH] Tiny optmization or a bug?  (Ranier Vilela <ranier_gyn@hotmail.com>)
Responses RE: [PATCH] Tiny optmization or a bug?
List pgsql-hackers
On Fri, Nov 22, 2019 at 11:06:53PM +0000, Ranier Vilela wrote:
>Hi,
>Hi,
>Maybe this is a real bug.
>
>The assignment has no effect, or forget dereferencing it?
>
>Best regards.
>Ranier Vilela
>
>--- \dll\postgresql-12.0\a\backend\optimizer\plan\initsplan.c    Mon Sep 30 17:06:55 2019
>+++ initsplan.c    Fri Nov 22 19:48:42 2019
>@@ -1718,7 +1718,7 @@
>                     relids =
>                         get_relids_in_jointree((Node *) root->parse->jointree,
>                                                false);
>-                    qualscope = bms_copy(relids);
>+                    bms_copy(relids);
>                 }
>             }
>         }

Seriously, how are you searching for those "issues"?

1) We're using qualscope in an assert about 100 lines down, and as coded
we need a copy of relids because that may be mutated (and reallocated to 
a different pointer). So no, the assignment *has* effect.

2) bms_copy(relids) on it's own is nonsensical, because it allocates a
copy but just throws the pointer away (why making the copy at all).

Have you tried modifying this code and running the regression tests? If
not, try it.

   $ ./configure --enable-cassert
   $ make
   $ make check

Please, consider the suggestions from my previous response ...

regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Assertion failing in master, predicate.c
Next
From: Ranier Vilela
Date:
Subject: RE: [PATCH] Tiny optmization or a bug?