Re: pgsql: Add infrastructure to support EphemeralNamedRelation references.

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Kevin Grittner <kgrittn(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Kevin Grittner <kgrittn(at)postgresql(dot)org>, "pgsql-committers(at)postgresql(dot)org" <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Add infrastructure to support EphemeralNamedRelation references.
Date: 2017-04-06 22:07:53
Message-ID: CAEepm=2FcFPUOi3YkqPy2pRhw6w=2KgDXRTMQ3g03P0H5NjpQA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On Fri, Apr 7, 2017 at 10:03 AM, Kevin Grittner <kgrittn(at)gmail(dot)com> wrote:
> On Thu, Apr 6, 2017 at 4:19 PM, Andres Freund <andres(at)anarazel(dot)de> wrote:
>
>> My compiler, quite justifiedly, complains:
>>
>> /home/andres/src/postgresql/src/backend/parser/parse_relation.c: In function ‘get_rte_attribute_is_dropped’:
>> /home/andres/src/postgresql/src/backend/parser/parse_relation.c:2899:43: warning: comparison between pointer and zero character constant [-Wpointer-compare]
>> (list_nth(rte->coltypes, attnum - 1) != InvalidOid);
>> ^~
>> /home/andres/src/postgresql/src/backend/parser/parse_relation.c:2899:7: note: did you mean to dereference the pointer?
>> (list_nth(rte->coltypes, attnum - 1) != InvalidOid);
>> ^
>
> Good catch. Will push a change from list_nth() to list_nth_oid()
> for the benefit of stricter compilers. While I'm at it, I'll throw
> on another layer of parentheses to ensure people read that
> correctly. Out of curiosity, what compiler or setting catches this?

Doesn't it also have the logic backwards? According to the comment,
the attribute is dropped if the type *is* InvalidOid, so we want
result == true in that case. But I don't actually know how to reach
this code to test it.

/*
- * We checked when we loaded ctecoltypes for the tuplestore
+ * We checked when we loaded coltypes for the tuplestore
* that InvalidOid was only used for dropped columns, so it is
* safe to count on that here.
*/
result =
- (list_nth(rte->coltypes, attnum - 1) != InvalidOid);
+ (list_nth_oid(rte->coltypes, attnum - 1) == InvalidOid);
}

--
Thomas Munro
http://www.enterprisedb.com

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2017-04-06 22:16:47 Re: pgsql: Add infrastructure to support EphemeralNamedRelation references.
Previous Message Kevin Grittner 2017-04-06 22:03:20 Re: pgsql: Add infrastructure to support EphemeralNamedRelation references.