Re: Why does array_position_common bitwise NOT an Oid type? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Why does array_position_common bitwise NOT an Oid type?
Date
Msg-id 23769.1513475624@sss.pgh.pa.us
Whole thread Raw
In response to Why does array_position_common bitwise NOT an Oid type?  (David Rowley <david.rowley@2ndquadrant.com>)
Responses Re: Why does array_position_common bitwise NOT an Oid type?  (David Rowley <david.rowley@2ndquadrant.com>)
List pgsql-hackers
David Rowley <david.rowley@2ndquadrant.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


pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Why does array_position_common bitwise NOT an Oid type?
Next
From: Robert Haas
Date:
Subject: Re: Package version in PG_VERSION and version()