Re: Why does array_position_common bitwise NOT an Oid type?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Subject: Re: Why does array_position_common bitwise NOT an Oid type?
Date: 2017-12-17 01:53:44
Message-ID: 23769.1513475624@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> writes:
> I was puzzled to see the following code:

> my_extra->element_type = ~element_type;

> It looks quite wrong, but if its right then I think it needs a comment
> to explain it. I don't see any in the area which mentions it. My best
> guess would be that it's using this to know if the type data has been
> cached, but then why would it not use InvalidOid for that?

If memory serves, the idea was to force the subsequent datatype-lookup
path to be taken, even if for some reason element_type is InvalidOid.
If we take the lookup path then the bogus element_type will be detected
and reported; if we don't, it won't be.

We could instead add an explicit test for element_type == InvalidOid,
but that's just more duplicative code.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2017-12-17 02:37:01 Re: Bitmap scan is undercosted? - overestimated correlation and cost_index
Previous Message David Rowley 2017-12-17 01:48:38 Why does array_position_common bitwise NOT an Oid type?