Re: fix side-effect in get_qual_for_list()

From: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
To: Jeevan Ladhe <jeevan(dot)ladhe(at)enterprisedb(dot)com>
Cc: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: fix side-effect in get_qual_for_list()
Date: 2017-05-26 14:32:04
Message-ID: CAFjFpRcK=-8iWvBN+zSi+A1_E+Jrndi6X0qeaoyz+QTjacywQQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, May 25, 2017 at 3:12 PM, Jeevan Ladhe
<jeevan(dot)ladhe(at)enterprisedb(dot)com> wrote:
> Hi,
>
> While working on one of the crash reported on default partition for list
> partitioning table[1] I found some strange behavior in get_qual_for_list()
> while
> I tried to call it from the new code I wrote for default partition.
>
> After debugging, I noticed that the function get_qual_for_list() is
> implicitly
> manipulating the (PartitionBoundSpec) spec->listdatums list. AFAICU, this
> manipulation is needed just to construct a list of datums to be passed to
> ArrayExpr, and this should be done without manipulating the original list.
> The function name is get_qual_for_list(), which implies that this function
> returns something and does not modify anything.
>
> I have made this change in attached patch, as I think this is useful for
> future
> developments, as there may be a need in future to call get_qual_for_list()
> from
> other places, and the caller might not expect that PartitionBoundSpec gets
> modified.
>

Thanks for catching this. For now this isn't a problem since
generate_partition_qual() is crafting PartitionBoundInfo which it
doesn't use anywhere else. But if the function gets used where the
PartitionBoundSpec is being used somewhere else as well. While you are
at it, can we use castNode() in place of
PartitionBoundSpec *spec = (PartitionBoundSpec *) bound; Or do you
think it should be done separately?

--
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-05-26 14:38:54 Re: PostgreSQL 10 changes in exclusion constraints - did something change? CASE WHEN behavior oddity
Previous Message Petr Jelinek 2017-05-26 13:59:03 Re: logical replication - still unstable after all these months