NAMEDATALEN increase because of non-latin languages
Hello dear hackers. I understand the position of the developers community
about NAMEDATALEN length - and, in fact, 63 bytes is more than enough - but
only if we speak about latin languages.
Postgresql has wonderful support for unicode in table and column names. And
it looks like very good idea to create table with names on native language
for databases across the world. But when I want to create, for example,
table with name "Catalog_Контрагенты_КонтактнаяИнформация" (that stands in
Russian for catalog of counteragent contacts) it will be auto-shrinked to
"Catalog_Контрагенты_КонтактнаяИнформ". And this is not a fictional problem
- many words in Russian are just longer than it's English counterparts and
I have many examples like this.
Although recompiling the source is not so hard, updating is hard. I know
that is not free for disk space because of storing table names and field
names but, from my point of view, in 2021 year convenience is more
important than disk space.
I ask you to consider increasing NAMEDATALEN for maybe 128 bytes in future
releases.
Sorry for wasted time for this message if this topic is not match with
direction of postgresql development (and thank you for your hard work)
On Wed, Aug 18, 2021 at 7:08 PM Денис Романенко <deromanenko@gmail.com> wrote:
Hello dear hackers. I understand the position of the developers community about NAMEDATALEN length - and, in fact, 63 bytes is more than enough - but only if we speak about latin languages.
Postgresql has wonderful support for unicode in table and column names. And it looks like very good idea to create table with names on native language for databases across the world. But when I want to create, for example, table with name "Catalog_Контрагенты_КонтактнаяИнформация" (that stands in Russian for catalog of counteragent contacts) it will be auto-shrinked to "Catalog_Контрагенты_КонтактнаяИнформ". And this is not a fictional problem - many words in Russian are just longer than it's English counterparts and I have many examples like this.
Although recompiling the source is not so hard, updating is hard. I know that is not free for disk space because of storing table names and field names but, from my point of view, in 2021 year convenience is more important than disk space.
Unfortunately, the problem isn't really the additional disk space it
would require. The problem is the additional performance hit and
memory overhead, as the catalog names are part of the internal
syscache.
I understand your frustration, but given those problems I don't think
that postgres will increase the default NAMEDATALEN value any time
soon, even though it's in contradiction with the SQL standard.
Em qua., 18 de ago. de 2021 às 08:08, Денис Романенко <deromanenko@gmail.com>
escreveu:
Hello dear hackers. I understand the position of the developers community
about NAMEDATALEN length - and, in fact, 63 bytes is more than enough - but
only if we speak about latin languages.Postgresql has wonderful support for unicode in table and column names.
And it looks like very good idea to create table with names on native
language for databases across the world. But when I want to create, for
example, table with name "Catalog_Контрагенты_КонтактнаяИнформация" (that
stands in Russian for catalog of counteragent contacts) it will be
auto-shrinked to "Catalog_Контрагенты_КонтактнаяИнформ". And this is not a
fictional problem - many words in Russian are just longer than it's English
counterparts and I have many examples like this.Although recompiling the source is not so hard, updating is hard. I know
that is not free for disk space because of storing table names and field
names but, from my point of view, in 2021 year convenience is more
important than disk space.I ask you to consider increasing NAMEDATALEN for maybe 128 bytes in future
releases.
+1 once that Oracle Database 12.2 and higher, has support for 128 bytes
names.
What possibly, in the future, could impact some migration from Oracle to
Postgres.
regards,
Ranier Vilela
On Wed, Aug 18, 2021 at 7:15 AM Julien Rouhaud <rjuju123@gmail.com> wrote:
Unfortunately, the problem isn't really the additional disk space it
would require. The problem is the additional performance hit and
memory overhead, as the catalog names are part of the internal
syscache.
Some actual numbers on recent hardware would show what kind of tradeoff is
involved. No one has done that for a long time that I recall.
--
John Naylor
EDB: http://www.enterprisedb.com
On Wed, Aug 18, 2021 at 7:27 PM John Naylor
<john.naylor@enterprisedb.com> wrote:
On Wed, Aug 18, 2021 at 7:15 AM Julien Rouhaud <rjuju123@gmail.com> wrote:
Unfortunately, the problem isn't really the additional disk space it
would require. The problem is the additional performance hit and
memory overhead, as the catalog names are part of the internal
syscache.Some actual numbers on recent hardware would show what kind of tradeoff is involved. No one has done that for a long time that I recall.
Agreed, but I don't have access to such hardware. However this won't
influence the memory overhead part, and there is already frequent
problems with that, especially since declarative partitioning, so I
don't see how we could afford that without some kind of cache TTL or
similar. AFAIR the last discussion about it a few years ago didn't
lead anywhere :(
I don't very close with PG testing methodology, but I can pay for a server
(virtual or dedicated, DO maybe) and give access to it, if anyone has time
for that.
Or if someone describes to me steps and shows where to look - I can do it
by myself.
Import Notes
Resolved by subject fallback
Could we just make the limitation to be 64 (or 128) _characters_ not _bytes_ ?
Memory sizes and processor speeds have grown by order(s) of magnitude
since the 64 byte limit was decided and supporting non-ASCII charsets
properly seems like a prudent thing to do.
Also - have we checked that at least the truncation does not cut utf-8
characters in half ?
-----
Hannu Krosing
Google Cloud - We have a long list of planned contributions and we are hiring.
Contact me if interested.
Show quoted text
On Wed, Aug 18, 2021 at 1:33 PM Julien Rouhaud <rjuju123@gmail.com> wrote:
On Wed, Aug 18, 2021 at 7:27 PM John Naylor
<john.naylor@enterprisedb.com> wrote:On Wed, Aug 18, 2021 at 7:15 AM Julien Rouhaud <rjuju123@gmail.com> wrote:
Unfortunately, the problem isn't really the additional disk space it
would require. The problem is the additional performance hit and
memory overhead, as the catalog names are part of the internal
syscache.Some actual numbers on recent hardware would show what kind of tradeoff is involved. No one has done that for a long time that I recall.
Agreed, but I don't have access to such hardware. However this won't
influence the memory overhead part, and there is already frequent
problems with that, especially since declarative partitioning, so I
don't see how we could afford that without some kind of cache TTL or
similar. AFAIR the last discussion about it a few years ago didn't
lead anywhere :(
On Wed, Aug 18, 2021 at 7:33 AM Julien Rouhaud <rjuju123@gmail.com> wrote:
Some actual numbers on recent hardware would show what kind of tradeoff
is involved. No one has done that for a long time that I recall.
Agreed, but I don't have access to such hardware. However this won't
Well, by "recent" I had in mind something more recent than 2002, which is
the time where I see a lot of hits in the archives if you search for this
topic.
influence the memory overhead part, and there is already frequent
problems with that, especially since declarative partitioning, so I
That's a fair point.
don't see how we could afford that without some kind of cache TTL or
similar. AFAIR the last discussion about it a few years ago didn't
lead anywhere :(
If you mean the thread "Protect syscache from bloating with negative cache
entries", it had activity earlier this year, so I wouldn't give up hope
just yet. Progress has been slow, so I'll see about putting some effort
into that after concluding my attempt to speed up the syscaches first [1]/messages/by-id/CAFBsxsE35VLJ3hHkjJARB3QWqJ0zWeDw-jzqrfzkzMPuD_Ctvw@mail.gmail.com.
The main thing I'm worried about is the fact that a name would no longer
fit in a Datum. The rest I think we can mitigate in some way.
[1]: /messages/by-id/CAFBsxsE35VLJ3hHkjJARB3QWqJ0zWeDw-jzqrfzkzMPuD_Ctvw@mail.gmail.com
/messages/by-id/CAFBsxsE35VLJ3hHkjJARB3QWqJ0zWeDw-jzqrfzkzMPuD_Ctvw@mail.gmail.com
--
John Naylor
EDB: http://www.enterprisedb.com
On Wed, Aug 18, 2021 at 8:03 AM Hannu Krosing <hannuk@google.com> wrote:
Could we just make the limitation to be 64 (or 128) _characters_ not
_bytes_ ?
That couldn't work because characters are variable length. The limit has to
be a fixed length in bytes so we can quickly compute offsets in the
attribute tuple.
--
John Naylor
EDB: http://www.enterprisedb.com
On Wed, Aug 18, 2021 at 8:04 PM John Naylor
<john.naylor@enterprisedb.com> wrote:
Agreed, but I don't have access to such hardware. However this won't
Well, by "recent" I had in mind something more recent than 2002, which is the time where I see a lot of hits in the archives if you search for this topic.
Yeah, but my current laptop has a tendency to crash after a few minute
if I stress it too much, so I'm still out.
If you mean the thread "Protect syscache from bloating with negative cache entries", it had activity earlier this year, so I wouldn't give up hope just yet.
Yes that's the thread I was thinking about. I'm not giving up hope
either, but I also don't see it being solved for v15.
The main thing I'm worried about is the fact that a name would no longer fit in a Datum. The rest I think we can mitigate in some way.
Agreed.
On Wed, Aug 18, 2021 at 8:03 PM Hannu Krosing <hannuk@google.com> wrote:
Also - have we checked that at least the truncation does not cut utf-8
characters in half ?
Yes, same for all other places that can truncate text (like the query
text in pg_stat_activity and similar). See usage of pg_mbcliplen() in
truncate_identifier.
On Wed, 2021-08-18 at 08:16 -0300, Ranier Vilela wrote:
Em qua., 18 de ago. de 2021 às 08:08, Денис Романенко <deromanenko@gmail.com> escreveu:
Hello dear hackers. I understand the position of the developers community about
NAMEDATALEN length - and, in fact, 63 bytes is more than enough - but only if we
speak about latin languages.Postgresql has wonderful support for unicode in table and column names. And it
looks like very good idea to create table with names on native language for
databases across the world. But when I want to create, for example, table with
name "Catalog_Контрагенты_КонтактнаяИнформация" (that stands in Russian for
catalog of counteragent contacts) it will be auto-shrinked to
"Catalog_Контрагенты_КонтактнаяИнформ". And this is not a fictional problem -
many words in Russian are just longer than it's English counterparts and I
have many examples like this.Although recompiling the source is not so hard, updating is hard. I know that
is not free for disk space because of storing table names and field names but,
from my point of view, in 2021 year convenience is more important than disk space.I ask you to consider increasing NAMEDATALEN for maybe 128 bytes in future releases.
My stance here is that you should always use ASCII only for database identifiers,
not only because of this, but also to avoid unpleasant encoding problems if
you want to do something like
pg_dump -t Catalog_Контрагенты_КонтактнаяИнформация mydb
on a shell with an encoding different from the database encoding.
So I am not too excited about this.
+1 once that Oracle Database 12.2 and higher, has support for 128 bytes names.
What possibly, in the future, could impact some migration from Oracle to Postgres.
That seems to be a better argument from my point of view.
I have no idea as to how bad the additional memory impact for the catalog
caches would be...
Yours,
Laurenz Albe
Em qua., 18 de ago. de 2021 às 09:33, Laurenz Albe <laurenz.albe@cybertec.at>
escreveu:
On Wed, 2021-08-18 at 08:16 -0300, Ranier Vilela wrote:
Em qua., 18 de ago. de 2021 às 08:08, Денис Романенко <
deromanenko@gmail.com> escreveu:
Hello dear hackers. I understand the position of the developers
community about
NAMEDATALEN length - and, in fact, 63 bytes is more than enough - but
only if we
speak about latin languages.
Postgresql has wonderful support for unicode in table and column
names. And it
looks like very good idea to create table with names on native
language for
databases across the world. But when I want to create, for example,
table with
name "Catalog_Контрагенты_КонтактнаяИнформация" (that stands in
Russian for
catalog of counteragent contacts) it will be auto-shrinked to
"Catalog_Контрагенты_КонтактнаяИнформ". And this is not a fictionalproblem -
many words in Russian are just longer than it's English counterparts
and I
have many examples like this.
Although recompiling the source is not so hard, updating is hard. I
know that
is not free for disk space because of storing table names and field
names but,
from my point of view, in 2021 year convenience is more important
than disk space.
I ask you to consider increasing NAMEDATALEN for maybe 128 bytes in
future releases.
My stance here is that you should always use ASCII only for database
identifiers,
not only because of this, but also to avoid unpleasant encoding problems if
you want to do something likepg_dump -t Catalog_Контрагенты_КонтактнаяИнформация mydb
on a shell with an encoding different from the database encoding.
So I am not too excited about this.
+1 once that Oracle Database 12.2 and higher, has support for 128 bytes
names.
What possibly, in the future, could impact some migration from Oracle to
Postgres.
That seems to be a better argument from my point of view.
I have no idea as to how bad the additional memory impact for the catalog
caches would be...
It seems to me that this is a case for macro:
HAS_SUPPORT_NAME_128_BYTES
Деnis Романенко would like and would pay the price for regression in
exchange for the convenience.
What impacts him now is the difficulty of maintaining a private tree, with
this support.
regards,
Ranier Vilela
John Naylor <john.naylor@enterprisedb.com> writes:
The main thing I'm worried about is the fact that a name would no longer
fit in a Datum. The rest I think we can mitigate in some way.
Not sure what you mean by that? name is a pass-by-ref data type.
Anyway, this whole argument could be rendered moot if we could convert
name to a variable-length type. That would satisfy *both* sides of
the argument, since those who need long names could have them, while
those who don't would see net reduction instead of growth in space usage.
Of course, this is far far easier said than done; else we would have
done it years ago. But maybe it's not entirely out of reach.
I do not think it'd be hard to change "name" to have the same on-disk
storage representation as cstring; the hard part is what about its
usage in fixed-width catalog structures. Maybe we could finesse that
by decreeing that the name column always has to be the last
non-CATALOG_VARLEN field. (This would require fixing up the couple of
places where we let some other var-width field have that distinction;
but I suspect that would be small in comparison to the other work this
implies. If there are any catalogs having two name columns, one of them
would become more difficult to reach from C code.)
Another fun thing --- and, I fear, another good argument against just
raising NAMEDATALEN --- is what about TupleDescs, which last I checked
used an array of fixed-width pg_attribute images. But maybe we could
replace that with an array of pointers. Andres already did a lot of
the heavy code churn required to hide that data structure behind
TupleDescAttr() macros, so changing the representation should be much
less painful than it would once have been.
I wonder if we'd get complaints from changing the catalog column layouts
that much. People are used to the name at the front, I think. OTOH,
I expected a lot of bleating about the OID column becoming frontmost,
but there hasn't been much.
Anyway, I have little desire to work on this myself, but I recommend that
somebody who is more affected by the name length restriction look into it.
regards, tom lane
On Wed, Aug 18, 2021 at 10:21 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Anyway, this whole argument could be rendered moot if we could convert
name to a variable-length type. That would satisfy *both* sides of
the argument, since those who need long names could have them, while
those who don't would see net reduction instead of growth in space usage.
Yeah it seems like the best way forward.
Of course, this is far far easier said than done; else we would have
done it years ago. But maybe it's not entirely out of reach.
I do not think it'd be hard to change "name" to have the same on-disk
storage representation as cstring; the hard part is what about its
usage in fixed-width catalog structures. Maybe we could finesse that
by decreeing that the name column always has to be the last
non-CATALOG_VARLEN field. (This would require fixing up the couple of
places where we let some other var-width field have that distinction;
but I suspect that would be small in comparison to the other work this
implies. If there are any catalogs having two name columns, one of them
would become more difficult to reach from C code.)
Here is the list on some recent build (as of 17707c059c):
relname | array_agg
------------------+----------------------------------
pg_collation | {collname,collctype,collcollate}
pg_database | {datctype,datcollate,datname}
pg_event_trigger | {evtevent,evtname}
pg_subscription | {subname,subslotname}
pg_trigger | {tgname,tgnewtable,tgoldtable}
(5 rows)
I wonder if we'd get complaints from changing the catalog column layouts
that much. People are used to the name at the front, I think. OTOH,
I expected a lot of bleating about the OID column becoming frontmost,
but there hasn't been much.
I don't think that would be comparable. Having an extra oid in the
1st column doesn't really make a raw SELECT * harder to read. But
having the XXXname column way behind, and not even at the end, means
that most people will have to type an extra "xxxname," for each
throwaway query run to quickly verify something. I know that I often
do that, and while I could live with it I'd rather not have to do it.
On 18.08.21 13:33, Julien Rouhaud wrote:
Agreed, but I don't have access to such hardware. However this won't
influence the memory overhead part, and there is already frequent
problems with that, especially since declarative partitioning,
On the flip side, with partitioning you need room for longer table
names, since you need room for the real name plus some partition identifier.
Julien Rouhaud <rjuju123@gmail.com> writes:
On Wed, Aug 18, 2021 at 10:21 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
I wonder if we'd get complaints from changing the catalog column layouts
that much. People are used to the name at the front, I think. OTOH,
I expected a lot of bleating about the OID column becoming frontmost,
but there hasn't been much.
I don't think that would be comparable. Having an extra oid in the
1st column doesn't really make a raw SELECT * harder to read. But
having the XXXname column way behind, and not even at the end, means
that most people will have to type an extra "xxxname," for each
throwaway query run to quickly verify something. I know that I often
do that, and while I could live with it I'd rather not have to do it.
Yeah, it would annoy the heck out of me too. Again there's a potential
technical solution, which is to decouple the user-visible column order
from the storage order. However, multiple people have tilted at that
windmill without much success, so making it a prerequisite for improving
the name-length situation doesn't seem like a smart plan.
regards, tom lane
On 8/18/21 10:53 AM, Tom Lane wrote:
Julien Rouhaud <rjuju123@gmail.com> writes:
On Wed, Aug 18, 2021 at 10:21 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
I wonder if we'd get complaints from changing the catalog column layouts
that much. People are used to the name at the front, I think. OTOH,
I expected a lot of bleating about the OID column becoming frontmost,
but there hasn't been much.I don't think that would be comparable. Having an extra oid in the
1st column doesn't really make a raw SELECT * harder to read. But
having the XXXname column way behind, and not even at the end, means
that most people will have to type an extra "xxxname," for each
throwaway query run to quickly verify something. I know that I often
do that, and while I could live with it I'd rather not have to do it.Yeah, it would annoy the heck out of me too. Again there's a potential
technical solution, which is to decouple the user-visible column order
from the storage order. However, multiple people have tilted at that
windmill without much success, so making it a prerequisite for improving
the name-length situation doesn't seem like a smart plan.
There might be other benefits, though. IIRC what we discussed years ago
was having for each attribute an immutable number (presumably attnum as
now) and a mutable display order and storage order. Previous patches
didn't implement this and so were rejected. I think part of the trouble
is that we'd have to go through roughly 1700 mentions of attnum in the
source and decide if it's really attnum they want or if it's
attnum_display_order or attnum_storage_order. So this has the potential
to be extraordinarily invasive and potentially bug-prone. And then
there's the world of extensions to consider.
I have a bit less sympathy for the argument that just moving it will
break things that use 'select *' on the catalogs. In general, if you
care about the order of columns you should name the columns you want in
the order you want. I've seen 'select *' break for people on other
changes, like adding or dropping a column. It might cause Postgres
developers a bit of pain, but it should be manageable, so I kind of like
your suggestion.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
Andrew Dunstan <andrew@dunslane.net> writes:
On 8/18/21 10:53 AM, Tom Lane wrote:
Yeah, it would annoy the heck out of me too. Again there's a potential
technical solution, which is to decouple the user-visible column order
from the storage order. However, multiple people have tilted at that
windmill without much success, so making it a prerequisite for improving
the name-length situation doesn't seem like a smart plan.
There might be other benefits, though. IIRC what we discussed years ago
was having for each attribute an immutable number (presumably attnum as
now) and a mutable display order and storage order. Previous patches
didn't implement this and so were rejected. I think part of the trouble
is that we'd have to go through roughly 1700 mentions of attnum in the
source and decide if it's really attnum they want or if it's
attnum_display_order or attnum_storage_order. So this has the potential
to be extraordinarily invasive and potentially bug-prone. And then
there's the world of extensions to consider.
Yeah, exactly: conceptually that's simple, but flushing all the bugs
out would be a years-long nightmare. It'd make all the fun we had
with missed attisdropped checks look like a walk in the park. Unless
somebody can figure out a way to mechanically check for mistakes,
I don't think I want to go there.
I wonder though if we could fix the immediate problem with something
less ambitious. The hard part of the full proposal, I think, is
separating permanent identity from physical position. If we were to
split out *only* the display order from that, the patch footprint
ought to be far far smaller --- basically, I think, we'd need to fix
star-expansion and not a lot more in the backend. Of course,
client-side code like psql's \d and pg_dump would need to be upgraded
too, but any missed things there would be cosmetic that's-not-the-
expected-column-order bugs, not core dumps. Also, at least in the v1
patch we could use this just for system catalogs without exposing it
as a feature for user tables, which would greatly restrict the set of
client-side places that really need fixed.
(I think Alvaro was the last person to mess with this issue, so I
wonder what his take is on the feasibility of such a restricted
solution.)
regards, tom lane
On 2021-Aug-18, Tom Lane wrote:
I wonder though if we could fix the immediate problem with something
less ambitious. The hard part of the full proposal, I think, is
separating permanent identity from physical position. If we were to
split out *only* the display order from that, the patch footprint
ought to be far far smaller --- basically, I think, we'd need to fix
star-expansion and not a lot more in the backend. Of course,
client-side code like psql's \d and pg_dump would need to be upgraded
too, but any missed things there would be cosmetic that's-not-the-
expected-column-order bugs, not core dumps. Also, at least in the v1
patch we could use this just for system catalogs without exposing it
as a feature for user tables, which would greatly restrict the set of
client-side places that really need fixed.(I think Alvaro was the last person to mess with this issue, so I
wonder what his take is on the feasibility of such a restricted
solution.)
Yeah, my impression is that the project of just changing star expansion
is much, much easier than splitting out attribute identity from physical
location. The former, as I recall, is a localized change in expandRTE
and friends, and you don't have to touch anything else. The other part
of the change is much more invasive and got me into territory that I
wasn't able to navigate successfully.
(I think we should consider keeping 'attnum' as the display-order
attribute, and have the physical-and-identity attribute get a new name,
say attphysnum. That's so that you don't have to change psql and the
whole world -- the change is transparent to them. This means we need a
first step that's very invasive, because every single current use of
'attnum' has to be changed to attphysnum first, followed by a functional
patch that changes a few of those back to attnum. It'd be a large
inconvenience to backend developers to ease the lives of client-side
developers.)
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
On 8/18/21 12:39 PM, Alvaro Herrera wrote:
On 2021-Aug-18, Tom Lane wrote:
I wonder though if we could fix the immediate problem with something
less ambitious. The hard part of the full proposal, I think, is
separating permanent identity from physical position. If we were to
split out *only* the display order from that, the patch footprint
ought to be far far smaller --- basically, I think, we'd need to fix
star-expansion and not a lot more in the backend. Of course,
client-side code like psql's \d and pg_dump would need to be upgraded
too, but any missed things there would be cosmetic that's-not-the-
expected-column-order bugs, not core dumps. Also, at least in the v1
patch we could use this just for system catalogs without exposing it
as a feature for user tables, which would greatly restrict the set of
client-side places that really need fixed.(I think Alvaro was the last person to mess with this issue, so I
wonder what his take is on the feasibility of such a restricted
solution.)Yeah, my impression is that the project of just changing star expansion
is much, much easier than splitting out attribute identity from physical
location. The former, as I recall, is a localized change in expandRTE
and friends, and you don't have to touch anything else. The other part
of the change is much more invasive and got me into territory that I
wasn't able to navigate successfully.(I think we should consider keeping 'attnum' as the display-order
attribute, and have the physical-and-identity attribute get a new name,
say attphysnum. That's so that you don't have to change psql and the
whole world -- the change is transparent to them. This means we need a
first step that's very invasive, because every single current use of
'attnum' has to be changed to attphysnum first, followed by a functional
patch that changes a few of those back to attnum. It'd be a large
inconvenience to backend developers to ease the lives of client-side
developers.)
Can we call it attid just in case we decide some day to break the nexus
on the other side?
I like the idea of keeping it to the catalog to start with.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
On Thu, Aug 19, 2021 at 12:12 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Yeah, exactly: conceptually that's simple, but flushing all the bugs
out would be a years-long nightmare. It'd make all the fun we had
with missed attisdropped checks look like a walk in the park. Unless
somebody can figure out a way to mechanically check for mistakes,
I don't think I want to go there.
Maybe a silly idea, but we could have some shared_preload_libraries
module with a command_utility_hook that intercept table creation and
randomize the logical column order. If we also have some GUC (assert
only if needed) to switch star expansion to physical-order rather than
logical-order, we could then use the regression test as a big hammer
to see if anything breaks. That's clearly not ideal (it would
obviously need some other hacks to avoid other breakage like \d and
other things) and not 100% coverage, but it should give some
confidence in any patch completeness.
Hi,
On 2021-08-18 10:21:03 -0400, Tom Lane wrote:
Anyway, this whole argument could be rendered moot if we could convert
name to a variable-length type. That would satisfy *both* sides of
the argument, since those who need long names could have them, while
those who don't would see net reduction instead of growth in space usage.
Yes, I think that's the best direction to go. We're loosing a fair bit
of in-memory efficiency with current NAMEDATALEN already, it'd imo be
beneficial to go for variable length encoding from that angle alone.
Of course, this is far far easier said than done; else we would have
done it years ago. But maybe it's not entirely out of reach.
I do not think it'd be hard to change "name" to have the same on-disk
storage representation as cstring; the hard part is what about its
usage in fixed-width catalog structures.
Indeed. ISTM that the hardest part of that is dealing with copying around
Form* structs?
I wonder if we're getting closer to the time where we should just give up on
the struct / ondisk layout mirroring for catalog tables, and generate explicit
transformation routines via Catalog.pm. If we have to touch places handling
Form_* structs anyway, we could make that more worthwhile by doing away with
CATALOG_VARLEN etc - the transformation routines would just make those fields
pointers which then can be accessed normally.
Maybe we could finesse that
by decreeing that the name column always has to be the last
non-CATALOG_VARLEN field. (This would require fixing up the couple of
places where we let some other var-width field have that distinction;
but I suspect that would be small in comparison to the other work this
implies. If there are any catalogs having two name columns, one of them
would become more difficult to reach from C code.)
I wish we could find a way to make "relative pointers" (i.e. a variable offset
from some base struct) work on the C level in a transparent and portable
manner. Just about any instruction set has them natively anyway, and for a lot
of tasks like variable length members it can be considerably more
efficient... It'd also make DSM using code simpler and faster. Oh well, one
can dream.
Another fun thing --- and, I fear, another good argument against just
raising NAMEDATALEN --- is what about TupleDescs, which last I checked
used an array of fixed-width pg_attribute images. But maybe we could
replace that with an array of pointers. Andres already did a lot of
the heavy code churn required to hide that data structure behind
TupleDescAttr() macros, so changing the representation should be much
less painful than it would once have been.
I was recently wondering if we shouldn't go to a completely bespoke
datastructure for TupleDesc->attrs, rather than reusing FormData_pg_attribute.
Right now every attribute uses nearly two cachelines (112 bytes). Given how
frequent a task tuple [de]forming is, and how often it's a bottleneck,
increasing the cache efficiency of tupledescs would worth quite a bit of
effort - I do see tupledesc attr cache misses in profiles. A secondary benefit
would be that we do create a lot of short-lived descs in the executor,
slimming those down obviously would be good on its own. A third benefit would
be that we could get rid of attcacheoff in pg_attribute, that always smelled
funny to me.
One possible way to structure such future tupledescs would be to have multiple
arrays in struct TupleDescData. With an array of just the data necessary for
[de]forming at the place ->attrs is, and other stuff in one or more separate
arrays. The other option could perhaps be omitted for some tupledescs or
computed lazily.
For deforming we just need attlen (2byte), attbyval (1 byte), attalign (1byte)
and optionally attcacheoff (4 byte), for forming we also need attstorage (1
byte). Naively that ends up being 12 bytes - 5 attrs / cacheline is a heck of
a lot better than ~0.5.
Greetings,
Andres Freund
On Thu, 19 Aug 2021 at 13:44, Andres Freund <andres@anarazel.de> wrote:
Another fun thing --- and, I fear, another good argument against just
raising NAMEDATALEN --- is what about TupleDescs, which last I checked
used an array of fixed-width pg_attribute images. But maybe we could
replace that with an array of pointers. Andres already did a lot of
the heavy code churn required to hide that data structure behind
TupleDescAttr() macros, so changing the representation should be much
less painful than it would once have been.I was recently wondering if we shouldn't go to a completely bespoke
datastructure for TupleDesc->attrs, rather than reusing FormData_pg_attribute.Right now every attribute uses nearly two cachelines (112 bytes). Given how
frequent a task tuple [de]forming is, and how often it's a bottleneck,
increasing the cache efficiency of tupledescs would worth quite a bit of
effort - I do see tupledesc attr cache misses in profiles. A secondary benefit
would be that we do create a lot of short-lived descs in the executor,
slimming those down obviously would be good on its own. A third benefit would
be that we could get rid of attcacheoff in pg_attribute, that always smelled
funny to me.One possible way to structure such future tupledescs would be to have multiple
arrays in struct TupleDescData. With an array of just the data necessary for
[de]forming at the place ->attrs is, and other stuff in one or more separate
arrays. The other option could perhaps be omitted for some tupledescs or
computed lazily.For deforming we just need attlen (2byte), attbyval (1 byte), attalign (1byte)
and optionally attcacheoff (4 byte), for forming we also need attstorage (1
byte). Naively that ends up being 12 bytes - 5 attrs / cacheline is a heck of
a lot better than ~0.5.
I tried to implement this 'compact attribute access descriptor' a few
months ago in my effort to improve btree index performance.
I abandoned the idea at the time as I didn't find any measurable
difference for the (limited!) tests I ran, where the workload was
mainly re-indexing, select * into, and similar items while
benchmarking reindexing in the 'pp-complete' dataset. But, seeing that
there might be interest outside this effort on a basis seperate from
just plain performance, I'll share the results.
Attached is the latest version of my patch that I could find; it might
be incorrect or fail, as this is something I sent to myself between 2
of my systems during development of the patch. Also, attached as .txt,
as I don't want any CFBot coverage on this (this is not proposed for
inclusion, it is just a show of work, and might be basis for future
work).
The patch allocates an array of 'TupleAttrAlignData'-structs at the
end of the attrs-array, fills it with the correct data upon
TupleDesc-creation, and uses this TupleAttrAlign-data for constructing
and destructing tuples.
One main difference from what you described was that I used a union
for storing attbyval and attstorage, as the latter is only applicable
to attlen < 0, and the first only for attlen >= 0. This keeps the
whole structure in 8 bytes, whilst also being useable in both tuple
forming and deforming.
I hope this can is useful, otherwise sorry for the noise.
Kind regards,
Matthias van de Meent
Attachments:
0001-Some-work-on-storing-attribute-access-fields-more-co.patch.txttext/plain; charset=US-ASCII; name=0001-Some-work-on-storing-attribute-access-fields-more-co.patch.txtDownload
From 3dd3f470ab78b8811015c9f374d0bdc44ffef531 Mon Sep 17 00:00:00 2001
From: Matthias van de Meent <boekewurm@gmail.com>
Date: Wed, 23 Jun 2021 20:38:47 +0200
Subject: [PATCH] Some work on storing attribute access fields more compactly
This would increase the amount of useful data in each cache line, potentially increasing performance. It _does_ use more memory (8 bytes / attribute extra overhead)
---
src/backend/access/common/heaptuple.c | 95 +++++++++++++-------------
src/backend/access/common/indextuple.c | 52 ++++++++------
src/backend/access/common/relation.c | 2 +
src/backend/access/common/tupdesc.c | 74 +++++++++++++++++++-
src/backend/access/spgist/spgutils.c | 3 +
src/backend/catalog/index.c | 2 +
src/backend/catalog/toasting.c | 4 ++
src/backend/utils/cache/relcache.c | 18 ++++-
src/include/access/htup_details.h | 6 +-
src/include/access/itup.h | 9 +--
src/include/access/tupdesc.h | 35 +++++++++-
src/include/access/tupmacs.h | 2 +-
src/include/catalog/pg_attribute.h | 5 ++
13 files changed, 226 insertions(+), 81 deletions(-)
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 0b56b0fa5a..3600f88b25 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -123,19 +123,18 @@ heap_compute_data_size(TupleDesc tupleDesc,
Size data_length = 0;
int i;
int numberOfAttributes = tupleDesc->natts;
+ TupleAttrAlign att;
- for (i = 0; i < numberOfAttributes; i++)
+ for (i = 0, att = TupleDescAttrAlign(tupleDesc, i); i < numberOfAttributes; i++, att++)
{
Datum val;
- Form_pg_attribute atti;
if (isnull[i])
continue;
val = values[i];
- atti = TupleDescAttr(tupleDesc, i);
- if (ATT_IS_PACKABLE(atti) &&
+ if (ATT_IS_PACKABLE(att) &&
VARATT_CAN_MAKE_SHORT(DatumGetPointer(val)))
{
/*
@@ -144,21 +143,21 @@ heap_compute_data_size(TupleDesc tupleDesc,
*/
data_length += VARATT_CONVERTED_SHORT_SIZE(DatumGetPointer(val));
}
- else if (atti->attlen == -1 &&
+ else if (att->attlen == -1 &&
VARATT_IS_EXTERNAL_EXPANDED(DatumGetPointer(val)))
{
/*
* we want to flatten the expanded value so that the constructed
* tuple doesn't depend on it
*/
- data_length = att_align_nominal(data_length, atti->attalign);
+ data_length = att_align_nominal(data_length, att->attalign);
data_length += EOH_get_flat_size(DatumGetEOHP(val));
}
else
{
- data_length = att_align_datum(data_length, atti->attalign,
- atti->attlen, val);
- data_length = att_addlength_datum(data_length, atti->attlen,
+ data_length = att_align_datum(data_length, att->attalign,
+ att->attlen, val);
+ data_length = att_addlength_datum(data_length, att->attlen,
val);
}
}
@@ -172,7 +171,7 @@ heap_compute_data_size(TupleDesc tupleDesc,
* Fill in either a data value or a bit in the null bitmask
*/
static inline void
-fill_val(Form_pg_attribute att,
+fill_val(TupleAttrAlign att,
bits8 **bit,
int *bitmask,
char **dataP,
@@ -211,7 +210,7 @@ fill_val(Form_pg_attribute att,
* XXX we use the att_align macros on the pointer value itself, not on an
* offset. This is a bit of a hack.
*/
- if (att->attbyval)
+ if (att->attbyval && att->attlen >= 0)
{
/* pass-by-value */
data = (char *) att_align_nominal(data, att->attalign);
@@ -310,6 +309,7 @@ heap_fill_tuple(TupleDesc tupleDesc,
int bitmask;
int i;
int numberOfAttributes = tupleDesc->natts;
+ TupleAttrAlign attr;
#ifdef USE_ASSERT_CHECKING
char *start = data;
@@ -329,10 +329,8 @@ heap_fill_tuple(TupleDesc tupleDesc,
*infomask &= ~(HEAP_HASNULL | HEAP_HASVARWIDTH | HEAP_HASEXTERNAL);
- for (i = 0; i < numberOfAttributes; i++)
+ for (i = 0, attr = TupleDescAttrAlign(tupleDesc, i); i < numberOfAttributes; i++, attr++)
{
- Form_pg_attribute attr = TupleDescAttr(tupleDesc, i);
-
fill_val(attr,
bitP ? &bitP : NULL,
&bitmask,
@@ -429,6 +427,7 @@ nocachegetattr(HeapTuple tuple,
bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
bool slow = false; /* do we have to walk attrs? */
int off; /* current offset within data */
+ TupleAttrAlign thisAttrAlign;
/* ----------------
* Three cases:
@@ -474,13 +473,13 @@ nocachegetattr(HeapTuple tuple,
if (!slow)
{
- Form_pg_attribute att;
+ TupleAttrAlign att;
/*
* If we get here, there are no nulls up to and including the target
* attribute. If we have a cached offset, we can use it.
*/
- att = TupleDescAttr(tupleDesc, attnum);
+ att = TupleDescAttrAlign(tupleDesc, attnum);
if (att->attcacheoff >= 0)
return fetchatt(att, tp + att->attcacheoff);
@@ -492,10 +491,11 @@ nocachegetattr(HeapTuple tuple,
if (HeapTupleHasVarWidth(tuple))
{
int j;
+ att = TupleDescAttrAlign(tupleDesc, 0);
- for (j = 0; j <= attnum; j++)
+ for (j = 0; j <= attnum; j++, att++)
{
- if (TupleDescAttr(tupleDesc, j)->attlen <= 0)
+ if (att->attlen <= 0)
{
slow = true;
break;
@@ -508,6 +508,7 @@ nocachegetattr(HeapTuple tuple,
{
int natts = tupleDesc->natts;
int j = 1;
+ TupleAttrAlign att;
/*
* If we get here, we have a tuple with no nulls or var-widths up to
@@ -518,19 +519,18 @@ nocachegetattr(HeapTuple tuple,
* fixed-width columns, in hope of avoiding future visits to this
* routine.
*/
- TupleDescAttr(tupleDesc, 0)->attcacheoff = 0;
+ att = TupleDescAttrAlign(tupleDesc, 0);
+ att->attcacheoff = 0;
+ att++;
/* we might have set some offsets in the slow path previously */
- while (j < natts && TupleDescAttr(tupleDesc, j)->attcacheoff > 0)
- j++;
+ while (j < natts && att->attcacheoff > 0)
+ j++, att++;
- off = TupleDescAttr(tupleDesc, j - 1)->attcacheoff +
- TupleDescAttr(tupleDesc, j - 1)->attlen;
+ off = (att - 1)->attcacheoff + (att - 1)->attlen;
- for (; j < natts; j++)
+ for (; j < natts; j++, att++)
{
- Form_pg_attribute att = TupleDescAttr(tupleDesc, j);
-
if (att->attlen <= 0)
break;
@@ -543,12 +543,14 @@ nocachegetattr(HeapTuple tuple,
Assert(j > attnum);
- off = TupleDescAttr(tupleDesc, attnum)->attcacheoff;
+ thisAttrAlign = TupleDescAttrAlign(tupleDesc, attnum);
+ off = thisAttrAlign->attcacheoff;
}
else
{
bool usecache = true;
int i;
+ TupleAttrAlign att = TupleDescAttrAlign(tupleDesc, 0);
/*
* Now we know that we have to walk the tuple CAREFULLY. But we still
@@ -561,10 +563,8 @@ nocachegetattr(HeapTuple tuple,
* attcacheoff until we reach either a null or a var-width attribute.
*/
off = 0;
- for (i = 0;; i++) /* loop exit is at "break" */
+ for (i = 0;; i++, att++) /* loop exit is at "break" */
{
- Form_pg_attribute att = TupleDescAttr(tupleDesc, i);
-
if (HeapTupleHasNulls(tuple) && att_isnull(i, bp))
{
usecache = false;
@@ -602,7 +602,10 @@ nocachegetattr(HeapTuple tuple,
}
if (i == attnum)
+ {
+ thisAttrAlign = att;
break;
+ }
off = att_addlength_pointer(off, att->attlen, tp + off);
@@ -611,7 +614,7 @@ nocachegetattr(HeapTuple tuple,
}
}
- return fetchatt(TupleDescAttr(tupleDesc, attnum), tp + off);
+ return fetchatt(thisAttrAlign, tp + off);
}
/* ----------------
@@ -925,7 +928,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
for (attnum = sourceNatts; attnum < natts; attnum++)
{
- Form_pg_attribute attr = TupleDescAttr(tupleDesc, attnum);
+ TupleAttrAlign attr = TupleDescAttrAlign(tupleDesc, attnum);
if (attrmiss && attrmiss[attnum].am_present)
{
@@ -1258,6 +1261,7 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
uint32 off; /* offset in tuple data */
bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
bool slow = false; /* can we use/set attcacheoff? */
+ TupleAttrAlign att;
natts = HeapTupleHeaderGetNatts(tup);
@@ -1272,10 +1276,9 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
off = 0;
- for (attnum = 0; attnum < natts; attnum++)
+ for (attnum = 0, att = TupleDescAttrAlign(tupleDesc, attnum);
+ attnum < natts; attnum++, att++)
{
- Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attnum);
-
if (hasnulls && att_isnull(attnum, bp))
{
values[attnum] = (Datum) 0;
@@ -1286,9 +1289,9 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
isnull[attnum] = false;
- if (!slow && thisatt->attcacheoff >= 0)
- off = thisatt->attcacheoff;
- else if (thisatt->attlen == -1)
+ if (!slow && att->attcacheoff >= 0)
+ off = att->attcacheoff;
+ else if (att->attlen == -1)
{
/*
* We can only cache the offset for a varlena attribute if the
@@ -1297,11 +1300,11 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
* an aligned or unaligned value.
*/
if (!slow &&
- off == att_align_nominal(off, thisatt->attalign))
- thisatt->attcacheoff = off;
+ off == att_align_nominal(off, att->attalign))
+ att->attcacheoff = off;
else
{
- off = att_align_pointer(off, thisatt->attalign, -1,
+ off = att_align_pointer(off, att->attalign, -1,
tp + off);
slow = true;
}
@@ -1309,17 +1312,17 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
else
{
/* not varlena, so safe to use att_align_nominal */
- off = att_align_nominal(off, thisatt->attalign);
+ off = att_align_nominal(off, att->attalign);
if (!slow)
- thisatt->attcacheoff = off;
+ att->attcacheoff = off;
}
- values[attnum] = fetchatt(thisatt, tp + off);
+ values[attnum] = fetchatt(att, tp + off);
- off = att_addlength_pointer(off, thisatt->attlen, tp + off);
+ off = att_addlength_pointer(off, att->attlen, tp + off);
- if (thisatt->attlen <= 0)
+ if (att->attlen <= 0)
slow = true; /* can't use attcacheoff anymore */
}
diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c
index 8df882da7a..b2c08216db 100644
--- a/src/backend/access/common/indextuple.c
+++ b/src/backend/access/common/indextuple.c
@@ -228,7 +228,7 @@ nocache_index_getattr(IndexTuple tup,
bool slow = false; /* do we have to walk attrs? */
int data_off; /* tuple data offset */
int off; /* current offset within data */
-
+ TupleAttrAlign thisAttrAlign;
/* ----------------
* Three cases:
*
@@ -242,6 +242,8 @@ nocache_index_getattr(IndexTuple tup,
attnum--;
+ Assert(TupleDescAttrAlignsIsConsistent(tupleDesc));
+
if (IndexTupleHasNulls(tup))
{
/*
@@ -284,13 +286,13 @@ nocache_index_getattr(IndexTuple tup,
if (!slow)
{
- Form_pg_attribute att;
+ TupleAttrAlign att;
/*
* If we get here, there are no nulls up to and including the target
* attribute. If we have a cached offset, we can use it.
*/
- att = TupleDescAttr(tupleDesc, attnum);
+ att = TupleDescAttrAlign(tupleDesc, attnum);
if (att->attcacheoff >= 0)
return fetchatt(att, tp + att->attcacheoff);
@@ -302,10 +304,11 @@ nocache_index_getattr(IndexTuple tup,
if (IndexTupleHasVarwidths(tup))
{
int j;
+ att = TupleDescAttrAlign(tupleDesc, 0);
- for (j = 0; j <= attnum; j++)
+ for (j = 0; j <= attnum; j++, att++)
{
- if (TupleDescAttr(tupleDesc, j)->attlen <= 0)
+ if (att->attlen <= 0)
{
slow = true;
break;
@@ -318,6 +321,7 @@ nocache_index_getattr(IndexTuple tup,
{
int natts = tupleDesc->natts;
int j = 1;
+ TupleAttrAlign att;
/*
* If we get here, we have a tuple with no nulls or var-widths up to
@@ -328,19 +332,18 @@ nocache_index_getattr(IndexTuple tup,
* fixed-width columns, in hope of avoiding future visits to this
* routine.
*/
- TupleDescAttr(tupleDesc, 0)->attcacheoff = 0;
+ att = TupleDescAttrAlign(tupleDesc, 0);
+ att->attcacheoff = 0;
+ att++;
/* we might have set some offsets in the slow path previously */
- while (j < natts && TupleDescAttr(tupleDesc, j)->attcacheoff > 0)
- j++;
+ while (j < natts && att->attcacheoff > 0)
+ j++, att++;
- off = TupleDescAttr(tupleDesc, j - 1)->attcacheoff +
- TupleDescAttr(tupleDesc, j - 1)->attlen;
+ off = (att - 1)->attcacheoff + (att - 1)->attlen;
- for (; j < natts; j++)
+ for (; j < natts; j++, att++)
{
- Form_pg_attribute att = TupleDescAttr(tupleDesc, j);
-
if (att->attlen <= 0)
break;
@@ -353,13 +356,14 @@ nocache_index_getattr(IndexTuple tup,
Assert(j > attnum);
- off = TupleDescAttr(tupleDesc, attnum)->attcacheoff;
+ thisAttrAlign = TupleDescAttrAlign(tupleDesc, attnum);
+ off = thisAttrAlign->attcacheoff;
}
else
{
bool usecache = true;
int i;
-
+ TupleAttrAlign att;
/*
* Now we know that we have to walk the tuple CAREFULLY. But we still
* might be able to cache some offsets for next time.
@@ -371,10 +375,10 @@ nocache_index_getattr(IndexTuple tup,
* attcacheoff until we reach either a null or a var-width attribute.
*/
off = 0;
- for (i = 0;; i++) /* loop exit is at "break" */
- {
- Form_pg_attribute att = TupleDescAttr(tupleDesc, i);
+ att = TupleDescAttrAlign(tupleDesc, 0);
+ for (i = 0;; i++, att++) /* loop exit is at "break" */
+ {
if (IndexTupleHasNulls(tup) && att_isnull(i, bp))
{
usecache = false;
@@ -412,7 +416,10 @@ nocache_index_getattr(IndexTuple tup,
}
if (i == attnum)
+ {
+ thisAttrAlign = att;
break;
+ }
off = att_addlength_pointer(off, att->attlen, tp + off);
@@ -421,7 +428,7 @@ nocache_index_getattr(IndexTuple tup,
}
}
- return fetchatt(TupleDescAttr(tupleDesc, attnum), tp + off);
+ return fetchatt(thisAttrAlign, tp + off);
}
/*
@@ -465,14 +472,14 @@ index_deform_tuple_internal(TupleDesc tupleDescriptor,
int attnum;
int off = 0; /* offset in tuple data */
bool slow = false; /* can we use/set attcacheoff? */
+ TupleAttrAlign thisatt;
/* Assert to protect callers who allocate fixed-size arrays */
Assert(natts <= INDEX_MAX_KEYS);
- for (attnum = 0; attnum < natts; attnum++)
+ for (attnum = 0, thisatt = TupleDescAttrAlign(tupleDescriptor, attnum);
+ attnum < natts; attnum++, thisatt++)
{
- Form_pg_attribute thisatt = TupleDescAttr(tupleDescriptor, attnum);
-
if (hasnulls && att_isnull(attnum, bp))
{
values[attnum] = (Datum) 0;
@@ -572,6 +579,7 @@ index_truncate_tuple(TupleDesc sourceDescriptor, IndexTuple source,
truncdesc = palloc(TupleDescSize(sourceDescriptor));
TupleDescCopy(truncdesc, sourceDescriptor);
truncdesc->natts = leavenatts;
+ TupleDescInitAttrAligns(truncdesc);
/* Deform, form copy of tuple with fewer attributes */
index_deform_tuple(source, truncdesc, values, isnull);
diff --git a/src/backend/access/common/relation.c b/src/backend/access/common/relation.c
index 632d13c1ea..629d60b947 100644
--- a/src/backend/access/common/relation.c
+++ b/src/backend/access/common/relation.c
@@ -61,6 +61,8 @@ relation_open(Oid relationId, LOCKMODE lockmode)
if (!RelationIsValid(r))
elog(ERROR, "could not open relation with OID %u", relationId);
+ Assert(TupleDescAttrAlignsIsConsistent(r->rd_att));
+
/*
* If we didn't get the lock ourselves, assert that caller holds one,
* except in bootstrap mode where no locks are used.
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index 4c63bd4dc6..3ee74ce9fc 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -63,8 +63,9 @@ CreateTemplateTupleDesc(int natts)
* could be less due to trailing padding, although with the current
* definition of pg_attribute there probably isn't any padding.
*/
- desc = (TupleDesc) palloc(offsetof(struct TupleDescData, attrs) +
- natts * sizeof(FormData_pg_attribute));
+ desc = (TupleDesc) palloc(MAXALIGN((offsetof(struct TupleDescData, attrs)) +
+ natts * sizeof(FormData_pg_attribute)) +
+ natts * sizeof(TupleAttrAlignData));
/*
* Initialize other fields of the tupdesc.
@@ -75,6 +76,9 @@ CreateTemplateTupleDesc(int natts)
desc->tdtypmod = -1;
desc->tdrefcount = -1; /* assume not reference-counted */
+ desc->attralignoff = MAXALIGN((offsetof(struct TupleDescData, attrs)) +
+ natts * sizeof(FormData_pg_attribute));
+
return desc;
}
@@ -97,6 +101,8 @@ CreateTupleDesc(int natts, Form_pg_attribute *attrs)
for (i = 0; i < natts; ++i)
memcpy(TupleDescAttr(desc, i), attrs[i], ATTRIBUTE_FIXED_PART_SIZE);
+ TupleDescInitAttrAligns(desc);
+
return desc;
}
@@ -135,6 +141,8 @@ CreateTupleDescCopy(TupleDesc tupdesc)
att->attgenerated = '\0';
}
+ TupleDescInitAttrAligns(desc);
+
/* We can copy the tuple type identification, too */
desc->tdtypeid = tupdesc->tdtypeid;
desc->tdtypmod = tupdesc->tdtypmod;
@@ -210,6 +218,10 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc)
desc->constr = cpy;
}
+ memcpy(TupleDescAttrAlign(desc, 0),
+ TupleDescAttrAlign(tupdesc, 0),
+ tupdesc->natts * sizeof(TupleAttrAlignData));
+
/* We can copy the tuple type identification, too */
desc->tdtypeid = tupdesc->tdtypeid;
desc->tdtypmod = tupdesc->tdtypmod;
@@ -300,6 +312,10 @@ TupleDescCopyEntry(TupleDesc dst, AttrNumber dstAttno,
dstAtt->atthasmissing = false;
dstAtt->attidentity = '\0';
dstAtt->attgenerated = '\0';
+
+ memcpy(TupleDescAttrAlign(dst, dstAttno - 1),
+ TupleDescAttrAlign(src, srcAttno - 1),
+ sizeof(TupleAttrAlignData));
}
/*
@@ -645,6 +661,8 @@ TupleDescInitEntry(TupleDesc desc,
att->attcompression = InvalidCompressionMethod;
att->attcollation = typeForm->typcollation;
+ CopyAttrToAlign(att, TupleDescAttrAlign(desc, attributeNumber - 1));
+
ReleaseSysCache(tuple);
}
@@ -742,6 +760,10 @@ TupleDescInitBuiltinEntry(TupleDesc desc,
default:
elog(ERROR, "unsupported type %u", oidtypeid);
}
+
+ TupleAttrAlign attrAlign = TupleDescAttrAlign(desc, attributeNumber - 1);
+
+ CopyAttrToAlign(att, attrAlign);
}
/*
@@ -765,6 +787,49 @@ TupleDescInitEntryCollation(TupleDesc desc,
TupleDescAttr(desc, attributeNumber - 1)->attcollation = collationid;
}
+/*
+ * TupleDescInitAttrAligns
+ *
+ * Initialize the attraligns field of the TupleDesc with data from
+ * tupledesc->attrs.
+ */
+void
+TupleDescInitAttrAligns(TupleDesc desc)
+{
+ for (int i = 0; i < desc->natts; i++)
+ {
+ Form_pg_attribute attr = TupleDescAttr(desc, i);
+ TupleAttrAlign attrAlign = TupleDescAttrAlign(desc, i);
+ CopyAttrToAlign(attr, attrAlign);
+ }
+}
+
+bool
+TupleDescAttrAlignsIsConsistent(TupleDesc desc)
+{
+ for (int i = 0; i < desc->natts; i++)
+ {
+ Form_pg_attribute attr = TupleDescAttr(desc, i);
+ TupleAttrAlign attrAlign = TupleDescAttrAlign(desc, i);
+ if (!(attrAlign->attcacheoff == attr->attcacheoff || attrAlign->attcacheoff == -1 || attr->attcacheoff == -1))
+ return false;
+ if (attrAlign->attlen != attr->attlen)
+ return false;
+ if (attrAlign->attalign != attr->attalign)
+ return false;
+ if (attrAlign->attlen < 0)
+ {
+ if (attrAlign->attstorage != attr->attstorage)
+ return false;
+ }
+ else
+ {
+ if (attrAlign->attbyval != attr->attbyval)
+ return false;
+ }
+ }
+ return true;
+}
/*
* BuildDescForRelation
@@ -801,6 +866,7 @@ BuildDescForRelation(List *schema)
ColumnDef *entry = lfirst(l);
AclResult aclresult;
Form_pg_attribute att;
+ TupleAttrAlign align;
/*
* for each entry in the list, get the name and type information from
@@ -828,11 +894,15 @@ BuildDescForRelation(List *schema)
TupleDescInitEntry(desc, attnum, attname,
atttypid, atttypmod, attdim);
att = TupleDescAttr(desc, attnum - 1);
+ align = TupleDescAttrAlign(desc, attnum - 1);
/* Override TupleDescInitEntry's settings as requested */
TupleDescInitEntryCollation(desc, attnum, attcollation);
if (entry->storage)
+ {
att->attstorage = entry->storage;
+ align->attstorage = entry->storage;
+ }
/* Fill in additional stuff not handled by TupleDescInitEntry */
att->attnotnull = entry->is_not_null;
diff --git a/src/backend/access/spgist/spgutils.c b/src/backend/access/spgist/spgutils.c
index 9ff280a252..bc46dd1b02 100644
--- a/src/backend/access/spgist/spgutils.c
+++ b/src/backend/access/spgist/spgutils.c
@@ -306,9 +306,12 @@ getSpGistTupleDesc(Relation index, SpGistTypeDesc *keyType)
/* We shouldn't need to bother with making these valid: */
att->attcompression = InvalidCompressionMethod;
att->attcollation = InvalidOid;
+
/* In case we changed typlen, we'd better reset following offsets */
for (int i = spgFirstIncludeColumn; i < outTupDesc->natts; i++)
TupleDescAttr(outTupDesc, i)->attcacheoff = -1;
+
+ TupleDescInitAttrAligns(outTupDesc);
}
return outTupDesc;
}
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 50b7a16bce..28d1a7a032 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -471,6 +471,8 @@ ConstructTupleDescriptor(Relation heapRelation,
}
}
+ TupleDescInitAttrAligns(indexTupDesc);
+
pfree(amroutine);
return indexTupDesc;
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index bf81f6ccc5..a872ce50c7 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -221,6 +221,10 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
TupleDescAttr(tupdesc, 1)->attstorage = TYPSTORAGE_PLAIN;
TupleDescAttr(tupdesc, 2)->attstorage = TYPSTORAGE_PLAIN;
+ CopyAttrToAlign(TupleDescAttr(tupdesc, 0), TupleDescAttrAlign(tupdesc, 0));
+ CopyAttrToAlign(TupleDescAttr(tupdesc, 1), TupleDescAttrAlign(tupdesc, 1));
+ CopyAttrToAlign(TupleDescAttr(tupdesc, 2), TupleDescAttrAlign(tupdesc, 2));
+
/* Toast field should not be compressed */
TupleDescAttr(tupdesc, 0)->attcompression = InvalidCompressionMethod;
TupleDescAttr(tupdesc, 1)->attcompression = InvalidCompressionMethod;
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index d55ae016d0..b1aeab6e06 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -633,6 +633,8 @@ RelationBuildTupleDesc(Relation relation)
systable_endscan(pg_attribute_scan);
table_close(pg_attribute_desc, AccessShareLock);
+ TupleDescInitAttrAligns(relation->rd_att);
+
if (need != 0)
elog(ERROR, "pg_attribute catalog is missing %d attribute(s) for relation OID %u",
need, RelationGetRelid(relation));
@@ -647,7 +649,8 @@ RelationBuildTupleDesc(Relation relation)
int i;
for (i = 0; i < RelationGetNumberOfAttributes(relation); i++)
- Assert(TupleDescAttr(relation->rd_att, i)->attcacheoff == -1);
+ Assert(TupleDescAttr(relation->rd_att, i)->attcacheoff == -1 &&
+ TupleDescAttrAlign(relation->rd_att, i)->attcacheoff == -1);
}
#endif
@@ -657,7 +660,10 @@ RelationBuildTupleDesc(Relation relation)
* for attnum=1 that used to exist in fastgetattr() and index_getattr().
*/
if (RelationGetNumberOfAttributes(relation) > 0)
+ {
TupleDescAttr(relation->rd_att, 0)->attcacheoff = 0;
+ TupleDescAttrAlign(relation->rd_att, 0)->attcacheoff = 0;
+ }
/*
* Set up constraint/default info
@@ -1901,6 +1907,8 @@ formrdesc(const char *relationName, Oid relationReltype,
/* initialize first attribute's attcacheoff, cf RelationBuildTupleDesc */
TupleDescAttr(relation->rd_att, 0)->attcacheoff = 0;
+ TupleDescInitAttrAligns(relation->rd_att);
+
/* mark not-null status */
if (has_not_null)
{
@@ -2035,6 +2043,7 @@ RelationIdGetRelation(Oid relationId)
Assert(rd->rd_isvalid ||
(rd->rd_isnailed && !criticalRelcachesBuilt));
}
+ Assert(TupleDescAttrAlignsIsConsistent(rd->rd_att));
return rd;
}
@@ -2044,7 +2053,10 @@ RelationIdGetRelation(Oid relationId)
*/
rd = RelationBuildDesc(relationId, true);
if (RelationIsValid(rd))
+ {
RelationIncrementReferenceCount(rd);
+ Assert(TupleDescAttrAlignsIsConsistent(rd->rd_att));
+ }
return rd;
}
@@ -4208,6 +4220,8 @@ BuildHardcodedDescriptor(int natts, const FormData_pg_attribute *attrs)
/* initialize first attribute's attcacheoff, cf RelationBuildTupleDesc */
TupleDescAttr(result, 0)->attcacheoff = 0;
+ TupleDescInitAttrAligns(result);
+
/* Note: we don't bother to set up a TupleConstr entry */
MemoryContextSwitchTo(oldcxt);
@@ -6088,6 +6102,8 @@ load_relcache_init_file(bool shared)
rel->rd_amcache = NULL;
MemSet(&rel->pgstat_info, 0, sizeof(rel->pgstat_info));
+ TupleDescInitAttrAligns(rel->rd_att);
+
/*
* Recompute lock and physical addressing info. This is needed in
* case the pg_internal.init file was copied from some other database
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 960772f76b..bc7892be9b 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -714,11 +714,11 @@ struct MinimalTupleData
(*(isnull) = false), \
HeapTupleNoNulls(tup) ? \
( \
- TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff >= 0 ? \
+ TupleDescAttrAlign((tupleDesc), (attnum)-1)->attcacheoff >= 0 ? \
( \
- fetchatt(TupleDescAttr((tupleDesc), (attnum)-1), \
+ fetchatt(TupleDescAttrAlign((tupleDesc), (attnum)-1), \
(char *) (tup)->t_data + (tup)->t_data->t_hoff + \
- TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff)\
+ TupleDescAttrAlign((tupleDesc), (attnum)-1)->attcacheoff)\
) \
: \
nocachegetattr((tup), (attnum), (tupleDesc)) \
diff --git a/src/include/access/itup.h b/src/include/access/itup.h
index 1917375cde..7b739dcd4f 100644
--- a/src/include/access/itup.h
+++ b/src/include/access/itup.h
@@ -99,15 +99,16 @@ typedef IndexAttributeBitMapData * IndexAttributeBitMap;
*/
#define index_getattr(tup, attnum, tupleDesc, isnull) \
( \
- AssertMacro(PointerIsValid(isnull) && (attnum) > 0), \
+ AssertMacro(PointerIsValid(isnull) && (attnum) > 0 && \
+ TupleDescAttrAlignsIsConsistent(tupleDesc)), \
*(isnull) = false, \
!IndexTupleHasNulls(tup) ? \
( \
- TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff >= 0 ? \
+ TupleDescAttrAlign((tupleDesc), (attnum)-1)->attcacheoff >= 0 ? \
( \
- fetchatt(TupleDescAttr((tupleDesc), (attnum)-1), \
+ fetchatt(TupleDescAttrAlign((tupleDesc), (attnum)-1), \
(char *) (tup) + IndexInfoFindDataOffset((tup)->t_info) \
- + TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff) \
+ + TupleDescAttrAlign((tupleDesc), (attnum)-1)->attcacheoff) \
) \
: \
nocache_index_getattr((tup), (attnum), (tupleDesc)) \
diff --git a/src/include/access/tupdesc.h b/src/include/access/tupdesc.h
index f45d47aab7..9e8ce52cf3 100644
--- a/src/include/access/tupdesc.h
+++ b/src/include/access/tupdesc.h
@@ -45,6 +45,19 @@ typedef struct TupleConstr
bool has_generated_stored;
} TupleConstr;
+typedef struct TupleAttrAlignData
+{
+ int32 attcacheoff;
+ int16 attlen;
+ char attalign;
+ union {
+ char attstorage;
+ bool attbyval;
+ };
+} TupleAttrAlignData;
+
+typedef TupleAttrAlignData *TupleAttrAlign;
+
/*
* This struct is passed around within the backend to describe the structure
* of tuples. For tuples coming from on-disk relations, the information is
@@ -82,6 +95,7 @@ typedef struct TupleDescData
Oid tdtypeid; /* composite type ID for tuple type */
int32 tdtypmod; /* typmod for tuple type */
int tdrefcount; /* reference count, or -1 if not counting */
+ int attralignoff; /* offset to a co-allocated array of TupleAttrAlignData */
TupleConstr *constr; /* constraints, or NULL if none */
/* attrs[N] is the description of Attribute Number N+1 */
FormData_pg_attribute attrs[FLEXIBLE_ARRAY_MEMBER];
@@ -90,6 +104,8 @@ typedef struct TupleDescData *TupleDesc;
/* Accessor for the i'th attribute of tupdesc. */
#define TupleDescAttr(tupdesc, i) (&(tupdesc)->attrs[(i)])
+/* Accessor for the i'th attribute of attralign. */
+#define TupleDescAttrAlign(tupdesc, i) ((TupleAttrAlign) ((char *)(tupdesc) + (tupdesc)->attralignoff + (i) * sizeof(TupleAttrAlignData)))
extern TupleDesc CreateTemplateTupleDesc(int natts);
@@ -100,8 +116,9 @@ extern TupleDesc CreateTupleDescCopy(TupleDesc tupdesc);
extern TupleDesc CreateTupleDescCopyConstr(TupleDesc tupdesc);
#define TupleDescSize(src) \
- (offsetof(struct TupleDescData, attrs) + \
- (src)->natts * sizeof(FormData_pg_attribute))
+ (MAXALIGN(offsetof(struct TupleDescData, attrs) + \
+ (src)->natts * sizeof(FormData_pg_attribute)) + \
+ (src)->natts * sizeof(TupleAttrAlignData))
extern void TupleDescCopy(TupleDesc dst, TupleDesc src);
@@ -125,6 +142,17 @@ extern void DecrTupleDescRefCount(TupleDesc tupdesc);
DecrTupleDescRefCount(tupdesc); \
} while (0)
+#define CopyAttrToAlign(att, align) \
+ do { \
+ (align)->attcacheoff = (att)->attcacheoff; \
+ (align)->attlen = (att)->attlen; \
+ (align)->attalign = (att)->attalign; \
+ if ((att)->attlen < 0) \
+ (align)->attstorage = (att)->attstorage; \
+ else \
+ (align)->attbyval = (att)->attbyval; \
+ } while (0)
+
extern bool equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2);
extern uint32 hashTupleDesc(TupleDesc tupdesc);
@@ -147,6 +175,9 @@ extern void TupleDescInitEntryCollation(TupleDesc desc,
AttrNumber attributeNumber,
Oid collationid);
+extern void TupleDescInitAttrAligns(TupleDesc desc);
+extern bool TupleDescAttrAlignsIsConsistent(TupleDesc desc);
+
extern TupleDesc BuildDescForRelation(List *schema);
extern TupleDesc BuildDescFromLists(List *names, List *types, List *typmods, List *collations);
diff --git a/src/include/access/tupmacs.h b/src/include/access/tupmacs.h
index 65ac1ef3fc..0451dd6bb8 100644
--- a/src/include/access/tupmacs.h
+++ b/src/include/access/tupmacs.h
@@ -47,7 +47,7 @@
#define fetch_att(T,attbyval,attlen) \
( \
- (attbyval) ? \
+ (attbyval && attlen >= 0) ? \
( \
(attlen) == (int) sizeof(Datum) ? \
*((Datum *)(T)) \
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index 603392fe81..d3194041ba 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -94,6 +94,11 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
* no cached value. But when we copy these tuples into a tuple
* descriptor, we may then update attcacheoff in the copies. This speeds
* up the attribute walking process.
+ *
+ * Note: Although the maximum offset encountered in stored tuples is
+ * limited to the max BLCKSZ (2**15), FormData_pg_attribute is used for
+ * all internal tuples as well, so attcacheoff may be larger for those
+ * tuples, and it is therefore not safe to use int16.
*/
int32 attcacheoff BKI_DEFAULT(-1);
--
2.20.1
Hi,
On 2021-08-19 14:47:42 +0200, Matthias van de Meent wrote:
I tried to implement this 'compact attribute access descriptor' a few
months ago in my effort to improve btree index performance.
cool
The patch allocates an array of 'TupleAttrAlignData'-structs at the
end of the attrs-array, fills it with the correct data upon
TupleDesc-creation, and uses this TupleAttrAlign-data for constructing
and destructing tuples.
One main difference from what you described was that I used a union
for storing attbyval and attstorage, as the latter is only applicable
to attlen < 0, and the first only for attlen >= 0. This keeps the
whole structure in 8 bytes, whilst also being useable in both tuple
forming and deforming.
That's why I just talked about the naive way - it's clearly possible to
do better... ;)
I hope this can is useful, otherwise sorry for the noise.
It is!
I haven't looked at your patch in detail, but I suspect that one reason
that you didn't see performance benefits is that you added overhead as
well. The computation of the "compact" memory location now will need a
few more instructions than before, and I suspect the compiler may not
even be able to optimize out some of the redundant accesses in loops.
It'd be interesting to see what you'd get if you stored the compact
array as the flexible-array and stored a pointer to the "full" attrs
array (while still keeping it allocated together).
Another reason is that it looks like you didn't touch
slot_deform_heap_tuple(), which is I think the hottest of the deforming
routines...
Greetings,
Andres Freund
On Thu, 19 Aug 2021 at 14:58, Andres Freund <andres@anarazel.de> wrote:
Hi,
On 2021-08-19 14:47:42 +0200, Matthias van de Meent wrote:
I tried to implement this 'compact attribute access descriptor' a few
months ago in my effort to improve btree index performance.cool
The patch allocates an array of 'TupleAttrAlignData'-structs at the
end of the attrs-array, fills it with the correct data upon
TupleDesc-creation, and uses this TupleAttrAlign-data for constructing
and destructing tuples.One main difference from what you described was that I used a union
for storing attbyval and attstorage, as the latter is only applicable
to attlen < 0, and the first only for attlen >= 0. This keeps the
whole structure in 8 bytes, whilst also being useable in both tuple
forming and deforming.That's why I just talked about the naive way - it's clearly possible to
do better... ;)I hope this can is useful, otherwise sorry for the noise.
It is!
Great!
I haven't looked at your patch in detail, but I suspect that one reason
that you didn't see performance benefits is that you added overhead as
well. The computation of the "compact" memory location now will need a
few more instructions than before, and I suspect the compiler may not
even be able to optimize out some of the redundant accesses in loops.It'd be interesting to see what you'd get if you stored the compact
array as the flexible-array and stored a pointer to the "full" attrs
array (while still keeping it allocated together).
Yes, I remember testing swapping the order of the compact array with the
FormData_pg_attribute array as well, with no clear results.
I think this can partially be attributed to the split access methods of the
data in the attribute descriptor: some of it is 'give me the name', some of
it is 'does this attribute exist, what type description does it have?'
(atttypid, attnum, atttypmod, , and others are only interested in the
physical representation information. Prioritizing some over the other might
work, but I think to make full use of that it'd need a lot of work.
Another reason is that it looks like you didn't touch
slot_deform_heap_tuple(), which is I think the hottest of the deforming
routines...
That might be for normal operations, but I'm not certain that code is in
the hot path for (btree) indexing workloads, due to the relatively high
number of operations on each tuple whilst sorting, or finding an insertion
point or scan start point.
Anyway, after some digging I found the final state of this patch before I
stopped working on it, and after polishing it up a bit with your
suggestions it now passes check-world on the latest head (8d2d6ec7).
Kind regards,
Matthias van de Meent
Attachments:
0001-Compact-TupleDesc-attr-access-descriptors.patch.txttext/plain; charset=US-ASCII; name=0001-Compact-TupleDesc-attr-access-descriptors.patch.txtDownload
From 9624034b6d23f7c5812b87bed705cbf2ae781d36 Mon Sep 17 00:00:00 2001
From: Matthias van de Meent <boekewurm@gmail.com>
Date: Sun, 20 Jun 2021 21:16:33 +0200
Subject: [PATCH] Compact TupleDesc->attr access descriptors
Evolved from previous iterations, and includes some further work based
on comments from Andres Freund [0]
[0] https://www.postgresql.org/message-id/20210819125756.lhcp5wlppfv2r47d%40alap3.anarazel.de
---
src/backend/access/common/heaptuple.c | 95 +++++++++++++------------
src/backend/access/common/indextuple.c | 52 ++++++++------
src/backend/access/common/relation.c | 2 +
src/backend/access/common/tupdesc.c | 73 ++++++++++++++++++-
src/backend/access/heap/heapam.c | 6 +-
src/backend/access/heap/heaptoast.c | 12 ++--
src/backend/access/nbtree/nbtutils.c | 6 +-
src/backend/access/spgist/spgdoinsert.c | 2 +-
src/backend/access/spgist/spgutils.c | 3 +
src/backend/access/table/toast_helper.c | 6 +-
src/backend/catalog/heap.c | 10 +--
src/backend/catalog/index.c | 2 +
src/backend/catalog/toasting.c | 4 ++
src/backend/executor/execTuples.c | 10 +--
src/backend/executor/nodeValuesscan.c | 4 +-
src/backend/utils/adt/expandedrecord.c | 14 ++--
src/backend/utils/adt/ri_triggers.c | 2 +-
src/backend/utils/cache/catcache.c | 6 +-
src/backend/utils/cache/relcache.c | 18 ++++-
src/include/access/htup_details.h | 54 +++++++-------
src/include/access/itup.h | 9 +--
src/include/access/tupdesc.h | 42 +++++++++--
src/include/access/tupmacs.h | 2 +-
src/include/catalog/pg_attribute.h | 5 ++
24 files changed, 297 insertions(+), 142 deletions(-)
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 0b56b0fa5a..3600f88b25 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -123,19 +123,18 @@ heap_compute_data_size(TupleDesc tupleDesc,
Size data_length = 0;
int i;
int numberOfAttributes = tupleDesc->natts;
+ TupleAttrAlign att;
- for (i = 0; i < numberOfAttributes; i++)
+ for (i = 0, att = TupleDescAttrAlign(tupleDesc, i); i < numberOfAttributes; i++, att++)
{
Datum val;
- Form_pg_attribute atti;
if (isnull[i])
continue;
val = values[i];
- atti = TupleDescAttr(tupleDesc, i);
- if (ATT_IS_PACKABLE(atti) &&
+ if (ATT_IS_PACKABLE(att) &&
VARATT_CAN_MAKE_SHORT(DatumGetPointer(val)))
{
/*
@@ -144,21 +143,21 @@ heap_compute_data_size(TupleDesc tupleDesc,
*/
data_length += VARATT_CONVERTED_SHORT_SIZE(DatumGetPointer(val));
}
- else if (atti->attlen == -1 &&
+ else if (att->attlen == -1 &&
VARATT_IS_EXTERNAL_EXPANDED(DatumGetPointer(val)))
{
/*
* we want to flatten the expanded value so that the constructed
* tuple doesn't depend on it
*/
- data_length = att_align_nominal(data_length, atti->attalign);
+ data_length = att_align_nominal(data_length, att->attalign);
data_length += EOH_get_flat_size(DatumGetEOHP(val));
}
else
{
- data_length = att_align_datum(data_length, atti->attalign,
- atti->attlen, val);
- data_length = att_addlength_datum(data_length, atti->attlen,
+ data_length = att_align_datum(data_length, att->attalign,
+ att->attlen, val);
+ data_length = att_addlength_datum(data_length, att->attlen,
val);
}
}
@@ -172,7 +171,7 @@ heap_compute_data_size(TupleDesc tupleDesc,
* Fill in either a data value or a bit in the null bitmask
*/
static inline void
-fill_val(Form_pg_attribute att,
+fill_val(TupleAttrAlign att,
bits8 **bit,
int *bitmask,
char **dataP,
@@ -211,7 +210,7 @@ fill_val(Form_pg_attribute att,
* XXX we use the att_align macros on the pointer value itself, not on an
* offset. This is a bit of a hack.
*/
- if (att->attbyval)
+ if (att->attbyval && att->attlen >= 0)
{
/* pass-by-value */
data = (char *) att_align_nominal(data, att->attalign);
@@ -310,6 +309,7 @@ heap_fill_tuple(TupleDesc tupleDesc,
int bitmask;
int i;
int numberOfAttributes = tupleDesc->natts;
+ TupleAttrAlign attr;
#ifdef USE_ASSERT_CHECKING
char *start = data;
@@ -329,10 +329,8 @@ heap_fill_tuple(TupleDesc tupleDesc,
*infomask &= ~(HEAP_HASNULL | HEAP_HASVARWIDTH | HEAP_HASEXTERNAL);
- for (i = 0; i < numberOfAttributes; i++)
+ for (i = 0, attr = TupleDescAttrAlign(tupleDesc, i); i < numberOfAttributes; i++, attr++)
{
- Form_pg_attribute attr = TupleDescAttr(tupleDesc, i);
-
fill_val(attr,
bitP ? &bitP : NULL,
&bitmask,
@@ -429,6 +427,7 @@ nocachegetattr(HeapTuple tuple,
bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
bool slow = false; /* do we have to walk attrs? */
int off; /* current offset within data */
+ TupleAttrAlign thisAttrAlign;
/* ----------------
* Three cases:
@@ -474,13 +473,13 @@ nocachegetattr(HeapTuple tuple,
if (!slow)
{
- Form_pg_attribute att;
+ TupleAttrAlign att;
/*
* If we get here, there are no nulls up to and including the target
* attribute. If we have a cached offset, we can use it.
*/
- att = TupleDescAttr(tupleDesc, attnum);
+ att = TupleDescAttrAlign(tupleDesc, attnum);
if (att->attcacheoff >= 0)
return fetchatt(att, tp + att->attcacheoff);
@@ -492,10 +491,11 @@ nocachegetattr(HeapTuple tuple,
if (HeapTupleHasVarWidth(tuple))
{
int j;
+ att = TupleDescAttrAlign(tupleDesc, 0);
- for (j = 0; j <= attnum; j++)
+ for (j = 0; j <= attnum; j++, att++)
{
- if (TupleDescAttr(tupleDesc, j)->attlen <= 0)
+ if (att->attlen <= 0)
{
slow = true;
break;
@@ -508,6 +508,7 @@ nocachegetattr(HeapTuple tuple,
{
int natts = tupleDesc->natts;
int j = 1;
+ TupleAttrAlign att;
/*
* If we get here, we have a tuple with no nulls or var-widths up to
@@ -518,19 +519,18 @@ nocachegetattr(HeapTuple tuple,
* fixed-width columns, in hope of avoiding future visits to this
* routine.
*/
- TupleDescAttr(tupleDesc, 0)->attcacheoff = 0;
+ att = TupleDescAttrAlign(tupleDesc, 0);
+ att->attcacheoff = 0;
+ att++;
/* we might have set some offsets in the slow path previously */
- while (j < natts && TupleDescAttr(tupleDesc, j)->attcacheoff > 0)
- j++;
+ while (j < natts && att->attcacheoff > 0)
+ j++, att++;
- off = TupleDescAttr(tupleDesc, j - 1)->attcacheoff +
- TupleDescAttr(tupleDesc, j - 1)->attlen;
+ off = (att - 1)->attcacheoff + (att - 1)->attlen;
- for (; j < natts; j++)
+ for (; j < natts; j++, att++)
{
- Form_pg_attribute att = TupleDescAttr(tupleDesc, j);
-
if (att->attlen <= 0)
break;
@@ -543,12 +543,14 @@ nocachegetattr(HeapTuple tuple,
Assert(j > attnum);
- off = TupleDescAttr(tupleDesc, attnum)->attcacheoff;
+ thisAttrAlign = TupleDescAttrAlign(tupleDesc, attnum);
+ off = thisAttrAlign->attcacheoff;
}
else
{
bool usecache = true;
int i;
+ TupleAttrAlign att = TupleDescAttrAlign(tupleDesc, 0);
/*
* Now we know that we have to walk the tuple CAREFULLY. But we still
@@ -561,10 +563,8 @@ nocachegetattr(HeapTuple tuple,
* attcacheoff until we reach either a null or a var-width attribute.
*/
off = 0;
- for (i = 0;; i++) /* loop exit is at "break" */
+ for (i = 0;; i++, att++) /* loop exit is at "break" */
{
- Form_pg_attribute att = TupleDescAttr(tupleDesc, i);
-
if (HeapTupleHasNulls(tuple) && att_isnull(i, bp))
{
usecache = false;
@@ -602,7 +602,10 @@ nocachegetattr(HeapTuple tuple,
}
if (i == attnum)
+ {
+ thisAttrAlign = att;
break;
+ }
off = att_addlength_pointer(off, att->attlen, tp + off);
@@ -611,7 +614,7 @@ nocachegetattr(HeapTuple tuple,
}
}
- return fetchatt(TupleDescAttr(tupleDesc, attnum), tp + off);
+ return fetchatt(thisAttrAlign, tp + off);
}
/* ----------------
@@ -925,7 +928,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
for (attnum = sourceNatts; attnum < natts; attnum++)
{
- Form_pg_attribute attr = TupleDescAttr(tupleDesc, attnum);
+ TupleAttrAlign attr = TupleDescAttrAlign(tupleDesc, attnum);
if (attrmiss && attrmiss[attnum].am_present)
{
@@ -1258,6 +1261,7 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
uint32 off; /* offset in tuple data */
bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
bool slow = false; /* can we use/set attcacheoff? */
+ TupleAttrAlign att;
natts = HeapTupleHeaderGetNatts(tup);
@@ -1272,10 +1276,9 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
off = 0;
- for (attnum = 0; attnum < natts; attnum++)
+ for (attnum = 0, att = TupleDescAttrAlign(tupleDesc, attnum);
+ attnum < natts; attnum++, att++)
{
- Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attnum);
-
if (hasnulls && att_isnull(attnum, bp))
{
values[attnum] = (Datum) 0;
@@ -1286,9 +1289,9 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
isnull[attnum] = false;
- if (!slow && thisatt->attcacheoff >= 0)
- off = thisatt->attcacheoff;
- else if (thisatt->attlen == -1)
+ if (!slow && att->attcacheoff >= 0)
+ off = att->attcacheoff;
+ else if (att->attlen == -1)
{
/*
* We can only cache the offset for a varlena attribute if the
@@ -1297,11 +1300,11 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
* an aligned or unaligned value.
*/
if (!slow &&
- off == att_align_nominal(off, thisatt->attalign))
- thisatt->attcacheoff = off;
+ off == att_align_nominal(off, att->attalign))
+ att->attcacheoff = off;
else
{
- off = att_align_pointer(off, thisatt->attalign, -1,
+ off = att_align_pointer(off, att->attalign, -1,
tp + off);
slow = true;
}
@@ -1309,17 +1312,17 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
else
{
/* not varlena, so safe to use att_align_nominal */
- off = att_align_nominal(off, thisatt->attalign);
+ off = att_align_nominal(off, att->attalign);
if (!slow)
- thisatt->attcacheoff = off;
+ att->attcacheoff = off;
}
- values[attnum] = fetchatt(thisatt, tp + off);
+ values[attnum] = fetchatt(att, tp + off);
- off = att_addlength_pointer(off, thisatt->attlen, tp + off);
+ off = att_addlength_pointer(off, att->attlen, tp + off);
- if (thisatt->attlen <= 0)
+ if (att->attlen <= 0)
slow = true; /* can't use attcacheoff anymore */
}
diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c
index 8df882da7a..b2c08216db 100644
--- a/src/backend/access/common/indextuple.c
+++ b/src/backend/access/common/indextuple.c
@@ -228,7 +228,7 @@ nocache_index_getattr(IndexTuple tup,
bool slow = false; /* do we have to walk attrs? */
int data_off; /* tuple data offset */
int off; /* current offset within data */
-
+ TupleAttrAlign thisAttrAlign;
/* ----------------
* Three cases:
*
@@ -242,6 +242,8 @@ nocache_index_getattr(IndexTuple tup,
attnum--;
+ Assert(TupleDescAttrAlignsIsConsistent(tupleDesc));
+
if (IndexTupleHasNulls(tup))
{
/*
@@ -284,13 +286,13 @@ nocache_index_getattr(IndexTuple tup,
if (!slow)
{
- Form_pg_attribute att;
+ TupleAttrAlign att;
/*
* If we get here, there are no nulls up to and including the target
* attribute. If we have a cached offset, we can use it.
*/
- att = TupleDescAttr(tupleDesc, attnum);
+ att = TupleDescAttrAlign(tupleDesc, attnum);
if (att->attcacheoff >= 0)
return fetchatt(att, tp + att->attcacheoff);
@@ -302,10 +304,11 @@ nocache_index_getattr(IndexTuple tup,
if (IndexTupleHasVarwidths(tup))
{
int j;
+ att = TupleDescAttrAlign(tupleDesc, 0);
- for (j = 0; j <= attnum; j++)
+ for (j = 0; j <= attnum; j++, att++)
{
- if (TupleDescAttr(tupleDesc, j)->attlen <= 0)
+ if (att->attlen <= 0)
{
slow = true;
break;
@@ -318,6 +321,7 @@ nocache_index_getattr(IndexTuple tup,
{
int natts = tupleDesc->natts;
int j = 1;
+ TupleAttrAlign att;
/*
* If we get here, we have a tuple with no nulls or var-widths up to
@@ -328,19 +332,18 @@ nocache_index_getattr(IndexTuple tup,
* fixed-width columns, in hope of avoiding future visits to this
* routine.
*/
- TupleDescAttr(tupleDesc, 0)->attcacheoff = 0;
+ att = TupleDescAttrAlign(tupleDesc, 0);
+ att->attcacheoff = 0;
+ att++;
/* we might have set some offsets in the slow path previously */
- while (j < natts && TupleDescAttr(tupleDesc, j)->attcacheoff > 0)
- j++;
+ while (j < natts && att->attcacheoff > 0)
+ j++, att++;
- off = TupleDescAttr(tupleDesc, j - 1)->attcacheoff +
- TupleDescAttr(tupleDesc, j - 1)->attlen;
+ off = (att - 1)->attcacheoff + (att - 1)->attlen;
- for (; j < natts; j++)
+ for (; j < natts; j++, att++)
{
- Form_pg_attribute att = TupleDescAttr(tupleDesc, j);
-
if (att->attlen <= 0)
break;
@@ -353,13 +356,14 @@ nocache_index_getattr(IndexTuple tup,
Assert(j > attnum);
- off = TupleDescAttr(tupleDesc, attnum)->attcacheoff;
+ thisAttrAlign = TupleDescAttrAlign(tupleDesc, attnum);
+ off = thisAttrAlign->attcacheoff;
}
else
{
bool usecache = true;
int i;
-
+ TupleAttrAlign att;
/*
* Now we know that we have to walk the tuple CAREFULLY. But we still
* might be able to cache some offsets for next time.
@@ -371,10 +375,10 @@ nocache_index_getattr(IndexTuple tup,
* attcacheoff until we reach either a null or a var-width attribute.
*/
off = 0;
- for (i = 0;; i++) /* loop exit is at "break" */
- {
- Form_pg_attribute att = TupleDescAttr(tupleDesc, i);
+ att = TupleDescAttrAlign(tupleDesc, 0);
+ for (i = 0;; i++, att++) /* loop exit is at "break" */
+ {
if (IndexTupleHasNulls(tup) && att_isnull(i, bp))
{
usecache = false;
@@ -412,7 +416,10 @@ nocache_index_getattr(IndexTuple tup,
}
if (i == attnum)
+ {
+ thisAttrAlign = att;
break;
+ }
off = att_addlength_pointer(off, att->attlen, tp + off);
@@ -421,7 +428,7 @@ nocache_index_getattr(IndexTuple tup,
}
}
- return fetchatt(TupleDescAttr(tupleDesc, attnum), tp + off);
+ return fetchatt(thisAttrAlign, tp + off);
}
/*
@@ -465,14 +472,14 @@ index_deform_tuple_internal(TupleDesc tupleDescriptor,
int attnum;
int off = 0; /* offset in tuple data */
bool slow = false; /* can we use/set attcacheoff? */
+ TupleAttrAlign thisatt;
/* Assert to protect callers who allocate fixed-size arrays */
Assert(natts <= INDEX_MAX_KEYS);
- for (attnum = 0; attnum < natts; attnum++)
+ for (attnum = 0, thisatt = TupleDescAttrAlign(tupleDescriptor, attnum);
+ attnum < natts; attnum++, thisatt++)
{
- Form_pg_attribute thisatt = TupleDescAttr(tupleDescriptor, attnum);
-
if (hasnulls && att_isnull(attnum, bp))
{
values[attnum] = (Datum) 0;
@@ -572,6 +579,7 @@ index_truncate_tuple(TupleDesc sourceDescriptor, IndexTuple source,
truncdesc = palloc(TupleDescSize(sourceDescriptor));
TupleDescCopy(truncdesc, sourceDescriptor);
truncdesc->natts = leavenatts;
+ TupleDescInitAttrAligns(truncdesc);
/* Deform, form copy of tuple with fewer attributes */
index_deform_tuple(source, truncdesc, values, isnull);
diff --git a/src/backend/access/common/relation.c b/src/backend/access/common/relation.c
index 632d13c1ea..629d60b947 100644
--- a/src/backend/access/common/relation.c
+++ b/src/backend/access/common/relation.c
@@ -61,6 +61,8 @@ relation_open(Oid relationId, LOCKMODE lockmode)
if (!RelationIsValid(r))
elog(ERROR, "could not open relation with OID %u", relationId);
+ Assert(TupleDescAttrAlignsIsConsistent(r->rd_att));
+
/*
* If we didn't get the lock ourselves, assert that caller holds one,
* except in bootstrap mode where no locks are used.
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index 4c63bd4dc6..ecc4160dd9 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -63,7 +63,8 @@ CreateTemplateTupleDesc(int natts)
* could be less due to trailing padding, although with the current
* definition of pg_attribute there probably isn't any padding.
*/
- desc = (TupleDesc) palloc(offsetof(struct TupleDescData, attrs) +
+ desc = (TupleDesc) palloc(MAXALIGN((offsetof(struct TupleDescData, attrs)) +
+ natts * sizeof(TupleAttrAlignData)) +
natts * sizeof(FormData_pg_attribute));
/*
@@ -75,6 +76,9 @@ CreateTemplateTupleDesc(int natts)
desc->tdtypmod = -1;
desc->tdrefcount = -1; /* assume not reference-counted */
+ desc->attroff = MAXALIGN((offsetof(struct TupleDescData, attrs)) +
+ natts * sizeof(TupleAttrAlignData));
+
return desc;
}
@@ -97,6 +101,8 @@ CreateTupleDesc(int natts, Form_pg_attribute *attrs)
for (i = 0; i < natts; ++i)
memcpy(TupleDescAttr(desc, i), attrs[i], ATTRIBUTE_FIXED_PART_SIZE);
+ TupleDescInitAttrAligns(desc);
+
return desc;
}
@@ -135,6 +141,8 @@ CreateTupleDescCopy(TupleDesc tupdesc)
att->attgenerated = '\0';
}
+ TupleDescInitAttrAligns(desc);
+
/* We can copy the tuple type identification, too */
desc->tdtypeid = tupdesc->tdtypeid;
desc->tdtypmod = tupdesc->tdtypmod;
@@ -210,6 +218,10 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc)
desc->constr = cpy;
}
+ memcpy(TupleDescAttrAlign(desc, 0),
+ TupleDescAttrAlign(tupdesc, 0),
+ tupdesc->natts * sizeof(TupleAttrAlignData));
+
/* We can copy the tuple type identification, too */
desc->tdtypeid = tupdesc->tdtypeid;
desc->tdtypmod = tupdesc->tdtypmod;
@@ -300,6 +312,10 @@ TupleDescCopyEntry(TupleDesc dst, AttrNumber dstAttno,
dstAtt->atthasmissing = false;
dstAtt->attidentity = '\0';
dstAtt->attgenerated = '\0';
+
+ memcpy(TupleDescAttrAlign(dst, dstAttno - 1),
+ TupleDescAttrAlign(src, srcAttno - 1),
+ sizeof(TupleAttrAlignData));
}
/*
@@ -645,6 +661,8 @@ TupleDescInitEntry(TupleDesc desc,
att->attcompression = InvalidCompressionMethod;
att->attcollation = typeForm->typcollation;
+ CopyAttrToAlign(att, TupleDescAttrAlign(desc, attributeNumber - 1));
+
ReleaseSysCache(tuple);
}
@@ -662,6 +680,7 @@ TupleDescInitBuiltinEntry(TupleDesc desc,
int attdim)
{
Form_pg_attribute att;
+ TupleAttrAlign attrAlign;
/* sanity checks */
AssertArg(PointerIsValid(desc));
@@ -742,6 +761,10 @@ TupleDescInitBuiltinEntry(TupleDesc desc,
default:
elog(ERROR, "unsupported type %u", oidtypeid);
}
+
+ attrAlign = TupleDescAttrAlign(desc, attributeNumber - 1);
+
+ CopyAttrToAlign(att, attrAlign);
}
/*
@@ -765,6 +788,49 @@ TupleDescInitEntryCollation(TupleDesc desc,
TupleDescAttr(desc, attributeNumber - 1)->attcollation = collationid;
}
+/*
+ * TupleDescInitAttrAligns
+ *
+ * Initialize the attraligns field of the TupleDesc with data from
+ * tupledesc->attrs.
+ */
+void
+TupleDescInitAttrAligns(TupleDesc desc)
+{
+ for (int i = 0; i < desc->natts; i++)
+ {
+ Form_pg_attribute attr = TupleDescAttr(desc, i);
+ TupleAttrAlign attrAlign = TupleDescAttrAlign(desc, i);
+ CopyAttrToAlign(attr, attrAlign);
+ }
+}
+
+bool
+TupleDescAttrAlignsIsConsistent(TupleDesc desc)
+{
+ for (int i = 0; i < desc->natts; i++)
+ {
+ Form_pg_attribute attr = TupleDescAttr(desc, i);
+ TupleAttrAlign attrAlign = TupleDescAttrAlign(desc, i);
+ if (!(attrAlign->attcacheoff == attr->attcacheoff || attrAlign->attcacheoff == -1 || attr->attcacheoff == -1))
+ return false;
+ if (attrAlign->attlen != attr->attlen)
+ return false;
+ if (attrAlign->attalign != attr->attalign)
+ return false;
+ if (attrAlign->attlen < 0)
+ {
+ if (attrAlign->attstorage != attr->attstorage)
+ return false;
+ }
+ else
+ {
+ if (attrAlign->attbyval != attr->attbyval)
+ return false;
+ }
+ }
+ return true;
+}
/*
* BuildDescForRelation
@@ -801,6 +867,7 @@ BuildDescForRelation(List *schema)
ColumnDef *entry = lfirst(l);
AclResult aclresult;
Form_pg_attribute att;
+ TupleAttrAlign align;
/*
* for each entry in the list, get the name and type information from
@@ -828,11 +895,15 @@ BuildDescForRelation(List *schema)
TupleDescInitEntry(desc, attnum, attname,
atttypid, atttypmod, attdim);
att = TupleDescAttr(desc, attnum - 1);
+ align = TupleDescAttrAlign(desc, attnum - 1);
/* Override TupleDescInitEntry's settings as requested */
TupleDescInitEntryCollation(desc, attnum, attcollation);
if (entry->storage)
+ {
att->attstorage = entry->storage;
+ align->attstorage = entry->storage;
+ }
/* Fill in additional stuff not handled by TupleDescInitEntry */
att->attnotnull = entry->is_not_null;
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 2433998f39..59f8f97697 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -1144,11 +1144,11 @@ fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
(*(isnull) = false),
HeapTupleNoNulls(tup) ?
(
- TupleDescAttr((tupleDesc), (attnum) - 1)->attcacheoff >= 0 ?
+ TupleDescAttrAlign((tupleDesc), (attnum) - 1)->attcacheoff >= 0 ?
(
- fetchatt(TupleDescAttr((tupleDesc), (attnum) - 1),
+ fetchatt(TupleDescAttrAlign((tupleDesc), (attnum) - 1),
(char *) (tup)->t_data + (tup)->t_data->t_hoff +
- TupleDescAttr((tupleDesc), (attnum) - 1)->attcacheoff)
+ TupleDescAttrAlign((tupleDesc), (attnum) - 1)->attcacheoff)
)
:
nocachegetattr((tup), (attnum), (tupleDesc))
diff --git a/src/backend/access/heap/heaptoast.c b/src/backend/access/heap/heaptoast.c
index 55bbe1d584..e5fcbe15b8 100644
--- a/src/backend/access/heap/heaptoast.c
+++ b/src/backend/access/heap/heaptoast.c
@@ -190,10 +190,14 @@ heap_toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
if (biggest_attno < 0)
break;
+ Assert(TupleDescAttrAlign(tupleDesc, biggest_attno)->attlen < 0);
+
/*
* Attempt to compress it inline, if it has attstorage EXTENDED
+ *
+ * Safe to use attstorage, attlen < 0
*/
- if (TupleDescAttr(tupleDesc, biggest_attno)->attstorage == TYPSTORAGE_EXTENDED)
+ if (TupleDescAttrAlign(tupleDesc, biggest_attno)->attstorage == TYPSTORAGE_EXTENDED)
toast_tuple_try_compression(&ttc, biggest_attno);
else
{
@@ -369,7 +373,7 @@ toast_flatten_tuple(HeapTuple tup, TupleDesc tupleDesc)
/*
* Look at non-null varlena attributes
*/
- if (!toast_isnull[i] && TupleDescAttr(tupleDesc, i)->attlen == -1)
+ if (!toast_isnull[i] && TupleDescAttrAlign(tupleDesc, i)->attlen == -1)
{
struct varlena *new_value;
@@ -483,7 +487,7 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup,
*/
if (toast_isnull[i])
has_nulls = true;
- else if (TupleDescAttr(tupleDesc, i)->attlen == -1)
+ else if (TupleDescAttrAlign(tupleDesc, i)->attlen == -1)
{
struct varlena *new_value;
@@ -584,7 +588,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
/*
* Look at non-null varlena attributes
*/
- if (!isnull[i] && TupleDescAttr(tupleDesc, i)->attlen == -1)
+ if (!isnull[i] && TupleDescAttrAlign(tupleDesc, i)->attlen == -1)
{
struct varlena *new_value;
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c
index d524310723..49611bd81f 100644
--- a/src/backend/access/nbtree/nbtutils.c
+++ b/src/backend/access/nbtree/nbtutils.c
@@ -2429,17 +2429,17 @@ _bt_keep_natts_fast(Relation rel, IndexTuple lastleft, IndexTuple firstright)
datum2;
bool isNull1,
isNull2;
- Form_pg_attribute att;
+ TupleAttrAlign att;
datum1 = index_getattr(lastleft, attnum, itupdesc, &isNull1);
datum2 = index_getattr(firstright, attnum, itupdesc, &isNull2);
- att = TupleDescAttr(itupdesc, attnum - 1);
+ att = TupleDescAttrAlign(itupdesc, attnum - 1);
if (isNull1 != isNull2)
break;
if (!isNull1 &&
- !datum_image_eq(datum1, datum2, att->attbyval, att->attlen))
+ !datum_image_eq(datum1, datum2, att->attlen >= 0 && att->attbyval, att->attlen))
break;
keepnatts++;
diff --git a/src/backend/access/spgist/spgdoinsert.c b/src/backend/access/spgist/spgdoinsert.c
index 70557bcf3d..357320073d 100644
--- a/src/backend/access/spgist/spgdoinsert.c
+++ b/src/backend/access/spgist/spgdoinsert.c
@@ -1973,7 +1973,7 @@ spgdoinsert(Relation index, SpGistState *state,
{
if (!isnulls[i])
{
- if (TupleDescAttr(leafDescriptor, i)->attlen == -1)
+ if (TupleDescAttrAlign(leafDescriptor, i)->attlen == -1)
leafDatums[i] = PointerGetDatum(PG_DETOAST_DATUM(datums[i]));
else
leafDatums[i] = datums[i];
diff --git a/src/backend/access/spgist/spgutils.c b/src/backend/access/spgist/spgutils.c
index 03a9cd36e6..190978f403 100644
--- a/src/backend/access/spgist/spgutils.c
+++ b/src/backend/access/spgist/spgutils.c
@@ -306,9 +306,12 @@ getSpGistTupleDesc(Relation index, SpGistTypeDesc *keyType)
/* We shouldn't need to bother with making these valid: */
att->attcompression = InvalidCompressionMethod;
att->attcollation = InvalidOid;
+
/* In case we changed typlen, we'd better reset following offsets */
for (int i = spgFirstIncludeColumn; i < outTupDesc->natts; i++)
TupleDescAttr(outTupDesc, i)->attcacheoff = -1;
+
+ TupleDescInitAttrAligns(outTupDesc);
}
return outTupDesc;
}
diff --git a/src/backend/access/table/toast_helper.c b/src/backend/access/table/toast_helper.c
index 53f78f9c3e..cfe2fb4260 100644
--- a/src/backend/access/table/toast_helper.c
+++ b/src/backend/access/table/toast_helper.c
@@ -193,7 +193,7 @@ toast_tuple_find_biggest_attribute(ToastTupleContext *ttc,
for (i = 0; i < numAttrs; i++)
{
- Form_pg_attribute att = TupleDescAttr(tupleDesc, i);
+ TupleAttrAlign att = TupleDescAttrAlign(tupleDesc, i);
if ((ttc->ttc_attr[i].tai_colflags & skip_colflags) != 0)
continue;
@@ -202,6 +202,8 @@ toast_tuple_find_biggest_attribute(ToastTupleContext *ttc,
if (for_compression &&
VARATT_IS_COMPRESSED(DatumGetPointer(ttc->ttc_values[i])))
continue;
+ if (att->attlen >= 0)
+ continue; /* can't compress fixed-size attributes */
if (check_main && att->attstorage != TYPSTORAGE_MAIN)
continue;
if (!check_main && att->attstorage != TYPSTORAGE_EXTENDED &&
@@ -324,7 +326,7 @@ toast_delete_external(Relation rel, Datum *values, bool *isnull,
for (i = 0; i < numAttrs; i++)
{
- if (TupleDescAttr(tupleDesc, i)->attlen == -1)
+ if (TupleDescAttrAlign(tupleDesc, i)->attlen == -1)
{
Datum value = values[i];
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 83746d3fd9..bd688e4156 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -859,7 +859,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
/* set stats detail level to a sane default */
for (int i = 0; i < natts; i++)
- tupdesc->attrs[i].attstattarget = -1;
+ TupleDescAttr(tupdesc, i)->attstattarget = -1;
InsertPgAttributeTuples(rel, tupdesc, new_rel_oid, NULL, indstate);
/* add dependencies on their datatypes and collations */
@@ -868,15 +868,15 @@ AddNewAttributeTuples(Oid new_rel_oid,
/* Add dependency info */
ObjectAddressSubSet(myself, RelationRelationId, new_rel_oid, i + 1);
ObjectAddressSet(referenced, TypeRelationId,
- tupdesc->attrs[i].atttypid);
+ TupleDescAttr(tupdesc, i)->atttypid);
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
/* The default collation is pinned, so don't bother recording it */
- if (OidIsValid(tupdesc->attrs[i].attcollation) &&
- tupdesc->attrs[i].attcollation != DEFAULT_COLLATION_OID)
+ if (OidIsValid(TupleDescAttr(tupdesc, i)->attcollation) &&
+ TupleDescAttr(tupdesc, i)->attcollation != DEFAULT_COLLATION_OID)
{
ObjectAddressSet(referenced, CollationRelationId,
- tupdesc->attrs[i].attcollation);
+ TupleDescAttr(tupdesc, i)->attcollation);
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
}
}
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 26bfa74ce7..b96a4fccf1 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -471,6 +471,8 @@ ConstructTupleDescriptor(Relation heapRelation,
}
}
+ TupleDescInitAttrAligns(indexTupDesc);
+
pfree(amroutine);
return indexTupDesc;
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index 147b5abc19..efe7b7be26 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -219,6 +219,10 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
TupleDescAttr(tupdesc, 1)->attstorage = TYPSTORAGE_PLAIN;
TupleDescAttr(tupdesc, 2)->attstorage = TYPSTORAGE_PLAIN;
+ CopyAttrToAlign(TupleDescAttr(tupdesc, 0), TupleDescAttrAlign(tupdesc, 0));
+ CopyAttrToAlign(TupleDescAttr(tupdesc, 1), TupleDescAttrAlign(tupdesc, 1));
+ CopyAttrToAlign(TupleDescAttr(tupdesc, 2), TupleDescAttrAlign(tupdesc, 2));
+
/* Toast field should not be compressed */
TupleDescAttr(tupdesc, 0)->attcompression = InvalidCompressionMethod;
TupleDescAttr(tupdesc, 1)->attcompression = InvalidCompressionMethod;
diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c
index f447802843..29e978b7d3 100644
--- a/src/backend/executor/execTuples.c
+++ b/src/backend/executor/execTuples.c
@@ -170,10 +170,10 @@ tts_virtual_materialize(TupleTableSlot *slot)
/* compute size of memory required */
for (int natt = 0; natt < desc->natts; natt++)
{
- Form_pg_attribute att = TupleDescAttr(desc, natt);
+ TupleAttrAlign att = TupleDescAttrAlign(desc, natt);
Datum val;
- if (att->attbyval || slot->tts_isnull[natt])
+ if ((att->attlen >= 0 && att->attbyval) || slot->tts_isnull[natt])
continue;
val = slot->tts_values[natt];
@@ -206,10 +206,10 @@ tts_virtual_materialize(TupleTableSlot *slot)
/* and copy all attributes into the pre-allocated space */
for (int natt = 0; natt < desc->natts; natt++)
{
- Form_pg_attribute att = TupleDescAttr(desc, natt);
+ TupleAttrAlign att = TupleDescAttrAlign(desc, natt);
Datum val;
- if (att->attbyval || slot->tts_isnull[natt])
+ if ((att->attlen >= 0 && att->attbyval) || slot->tts_isnull[natt])
continue;
val = slot->tts_values[natt];
@@ -961,7 +961,7 @@ slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
for (; attnum < natts; attnum++)
{
- Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attnum);
+ TupleAttrAlign thisatt = TupleDescAttrAlign(tupleDesc, attnum);
if (hasnulls && att_isnull(attnum, bp))
{
diff --git a/src/backend/executor/nodeValuesscan.c b/src/backend/executor/nodeValuesscan.c
index 00bd1271e4..b1cb02da07 100644
--- a/src/backend/executor/nodeValuesscan.c
+++ b/src/backend/executor/nodeValuesscan.c
@@ -143,8 +143,8 @@ ValuesNext(ValuesScanState *node)
foreach(lc, exprstatelist)
{
ExprState *estate = (ExprState *) lfirst(lc);
- Form_pg_attribute attr = TupleDescAttr(slot->tts_tupleDescriptor,
- resind);
+ TupleAttrAlign attr = TupleDescAttrAlign(slot->tts_tupleDescriptor,
+ resind);
values[resind] = ExecEvalExpr(estate,
econtext,
diff --git a/src/backend/utils/adt/expandedrecord.c b/src/backend/utils/adt/expandedrecord.c
index e19491ecf7..c17f4580b9 100644
--- a/src/backend/utils/adt/expandedrecord.c
+++ b/src/backend/utils/adt/expandedrecord.c
@@ -546,8 +546,10 @@ expanded_record_set_tuple(ExpandedRecordHeader *erh,
for (i = 0; i < erh->nfields; i++)
{
+ TupleAttrAlign align = TupleDescAttrAlign(tupdesc, i);
+
if (!erh->dnulls[i] &&
- !(TupleDescAttr(tupdesc, i)->attbyval))
+ !(align->attlen >= 0 && align->attbyval))
{
char *oldValue = (char *) DatumGetPointer(erh->dvalues[i]);
@@ -699,7 +701,7 @@ ER_get_flat_size(ExpandedObjectHeader *eohptr)
{
for (i = 0; i < erh->nfields; i++)
{
- Form_pg_attribute attr = TupleDescAttr(tupdesc, i);
+ TupleAttrAlign attr = TupleDescAttrAlign(tupdesc, i);
if (!erh->dnulls[i] &&
!attr->attbyval && attr->attlen == -1 &&
@@ -1115,7 +1117,7 @@ expanded_record_set_field_internal(ExpandedRecordHeader *erh, int fnumber,
bool check_constraints)
{
TupleDesc tupdesc;
- Form_pg_attribute attr;
+ TupleAttrAlign attr;
Datum *dvalues;
bool *dnulls;
char *oldValue;
@@ -1146,8 +1148,8 @@ expanded_record_set_field_internal(ExpandedRecordHeader *erh, int fnumber,
* Copy new field value into record's context, and deal with detoasting,
* if needed.
*/
- attr = TupleDescAttr(tupdesc, fnumber - 1);
- if (!isnull && !attr->attbyval)
+ attr = TupleDescAttrAlign(tupdesc, fnumber - 1);
+ if (!isnull && !(attr->attlen >= 0 && attr->attbyval))
{
MemoryContext oldcxt;
@@ -1541,7 +1543,7 @@ check_domain_for_new_field(ExpandedRecordHeader *erh, int fnumber,
*/
if (!isnull)
{
- Form_pg_attribute attr = TupleDescAttr(erh->er_tupdesc, fnumber - 1);
+ TupleAttrAlign attr = TupleDescAttrAlign(erh->er_tupdesc, fnumber - 1);
if (!attr->attbyval && attr->attlen == -1 &&
VARATT_IS_EXTERNAL(DatumGetPointer(newValue)))
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index 96269fc2ad..a18d662262 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -2762,7 +2762,7 @@ ri_KeysEqual(Relation rel, TupleTableSlot *oldslot, TupleTableSlot *newslot,
* difference for ON UPDATE CASCADE, but for consistency we treat
* all changes to the PK the same.
*/
- Form_pg_attribute att = TupleDescAttr(oldslot->tts_tupleDescriptor, attnums[i] - 1);
+ TupleAttrAlign att = TupleDescAttrAlign(oldslot->tts_tupleDescriptor, attnums[i] - 1);
if (!datum_image_eq(oldvalue, newvalue, att->attbyval, att->attlen))
return false;
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index 4fbdc62d8c..add24fa06c 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -1917,14 +1917,14 @@ CatCacheFreeKeys(TupleDesc tupdesc, int nkeys, int *attnos, Datum *keys)
for (i = 0; i < nkeys; i++)
{
int attnum = attnos[i];
- Form_pg_attribute att;
+ TupleAttrAlign att;
/* system attribute are not supported in caches */
Assert(attnum > 0);
- att = TupleDescAttr(tupdesc, attnum - 1);
+ att = TupleDescAttrAlign(tupdesc, attnum - 1);
- if (!att->attbyval)
+ if (att->attlen < 0 || !att->attbyval)
pfree(DatumGetPointer(keys[i]));
}
}
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 13d9994af3..070762a027 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -633,6 +633,8 @@ RelationBuildTupleDesc(Relation relation)
systable_endscan(pg_attribute_scan);
table_close(pg_attribute_desc, AccessShareLock);
+ TupleDescInitAttrAligns(relation->rd_att);
+
if (need != 0)
elog(ERROR, "pg_attribute catalog is missing %d attribute(s) for relation OID %u",
need, RelationGetRelid(relation));
@@ -647,7 +649,8 @@ RelationBuildTupleDesc(Relation relation)
int i;
for (i = 0; i < RelationGetNumberOfAttributes(relation); i++)
- Assert(TupleDescAttr(relation->rd_att, i)->attcacheoff == -1);
+ Assert(TupleDescAttr(relation->rd_att, i)->attcacheoff == -1 &&
+ TupleDescAttrAlign(relation->rd_att, i)->attcacheoff == -1);
}
#endif
@@ -657,7 +660,10 @@ RelationBuildTupleDesc(Relation relation)
* for attnum=1 that used to exist in fastgetattr() and index_getattr().
*/
if (RelationGetNumberOfAttributes(relation) > 0)
+ {
TupleDescAttr(relation->rd_att, 0)->attcacheoff = 0;
+ TupleDescAttrAlign(relation->rd_att, 0)->attcacheoff = 0;
+ }
/*
* Set up constraint/default info
@@ -1904,6 +1910,8 @@ formrdesc(const char *relationName, Oid relationReltype,
/* initialize first attribute's attcacheoff, cf RelationBuildTupleDesc */
TupleDescAttr(relation->rd_att, 0)->attcacheoff = 0;
+ TupleDescInitAttrAligns(relation->rd_att);
+
/* mark not-null status */
if (has_not_null)
{
@@ -2038,6 +2046,7 @@ RelationIdGetRelation(Oid relationId)
Assert(rd->rd_isvalid ||
(rd->rd_isnailed && !criticalRelcachesBuilt));
}
+ Assert(TupleDescAttrAlignsIsConsistent(rd->rd_att));
return rd;
}
@@ -2047,7 +2056,10 @@ RelationIdGetRelation(Oid relationId)
*/
rd = RelationBuildDesc(relationId, true);
if (RelationIsValid(rd))
+ {
RelationIncrementReferenceCount(rd);
+ Assert(TupleDescAttrAlignsIsConsistent(rd->rd_att));
+ }
return rd;
}
@@ -4211,6 +4223,8 @@ BuildHardcodedDescriptor(int natts, const FormData_pg_attribute *attrs)
/* initialize first attribute's attcacheoff, cf RelationBuildTupleDesc */
TupleDescAttr(result, 0)->attcacheoff = 0;
+ TupleDescInitAttrAligns(result);
+
/* Note: we don't bother to set up a TupleConstr entry */
MemoryContextSwitchTo(oldcxt);
@@ -6086,6 +6100,8 @@ load_relcache_init_file(bool shared)
rel->rd_amcache = NULL;
MemSet(&rel->pgstat_info, 0, sizeof(rel->pgstat_info));
+ TupleDescInitAttrAligns(rel->rd_att);
+
/*
* Recompute lock and physical addressing info. This is needed in
* case the pg_internal.init file was copied from some other database
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 960772f76b..92c1ac72e4 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -708,33 +708,33 @@ struct MinimalTupleData
#if !defined(DISABLE_COMPLEX_MACRO)
-#define fastgetattr(tup, attnum, tupleDesc, isnull) \
-( \
- AssertMacro((attnum) > 0), \
- (*(isnull) = false), \
- HeapTupleNoNulls(tup) ? \
- ( \
- TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff >= 0 ? \
- ( \
- fetchatt(TupleDescAttr((tupleDesc), (attnum)-1), \
- (char *) (tup)->t_data + (tup)->t_data->t_hoff + \
- TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff)\
- ) \
- : \
- nocachegetattr((tup), (attnum), (tupleDesc)) \
- ) \
- : \
- ( \
- att_isnull((attnum)-1, (tup)->t_data->t_bits) ? \
- ( \
- (*(isnull) = true), \
- (Datum)NULL \
- ) \
- : \
- ( \
- nocachegetattr((tup), (attnum), (tupleDesc)) \
- ) \
- ) \
+#define fastgetattr(tup, attnum, tupleDesc, isnull) \
+( \
+ AssertMacro((attnum) > 0), \
+ (*(isnull) = false), \
+ HeapTupleNoNulls(tup) ? \
+ ( \
+ TupleDescAttrAlign((tupleDesc), (attnum)-1)->attcacheoff >= 0 ? \
+ ( \
+ fetchatt(TupleDescAttrAlign((tupleDesc), (attnum)-1), \
+ (char *) (tup)->t_data + (tup)->t_data->t_hoff + \
+ TupleDescAttrAlign((tupleDesc), (attnum)-1)->attcacheoff) \
+ ) \
+ : \
+ nocachegetattr((tup), (attnum), (tupleDesc)) \
+ ) \
+ : \
+ ( \
+ att_isnull((attnum)-1, (tup)->t_data->t_bits) ? \
+ ( \
+ (*(isnull) = true), \
+ (Datum)NULL \
+ ) \
+ : \
+ ( \
+ nocachegetattr((tup), (attnum), (tupleDesc)) \
+ ) \
+ ) \
)
#else /* defined(DISABLE_COMPLEX_MACRO) */
diff --git a/src/include/access/itup.h b/src/include/access/itup.h
index 1917375cde..7b739dcd4f 100644
--- a/src/include/access/itup.h
+++ b/src/include/access/itup.h
@@ -99,15 +99,16 @@ typedef IndexAttributeBitMapData * IndexAttributeBitMap;
*/
#define index_getattr(tup, attnum, tupleDesc, isnull) \
( \
- AssertMacro(PointerIsValid(isnull) && (attnum) > 0), \
+ AssertMacro(PointerIsValid(isnull) && (attnum) > 0 && \
+ TupleDescAttrAlignsIsConsistent(tupleDesc)), \
*(isnull) = false, \
!IndexTupleHasNulls(tup) ? \
( \
- TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff >= 0 ? \
+ TupleDescAttrAlign((tupleDesc), (attnum)-1)->attcacheoff >= 0 ? \
( \
- fetchatt(TupleDescAttr((tupleDesc), (attnum)-1), \
+ fetchatt(TupleDescAttrAlign((tupleDesc), (attnum)-1), \
(char *) (tup) + IndexInfoFindDataOffset((tup)->t_info) \
- + TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff) \
+ + TupleDescAttrAlign((tupleDesc), (attnum)-1)->attcacheoff) \
) \
: \
nocache_index_getattr((tup), (attnum), (tupleDesc)) \
diff --git a/src/include/access/tupdesc.h b/src/include/access/tupdesc.h
index f45d47aab7..0e0cdc16cf 100644
--- a/src/include/access/tupdesc.h
+++ b/src/include/access/tupdesc.h
@@ -45,6 +45,19 @@ typedef struct TupleConstr
bool has_generated_stored;
} TupleConstr;
+typedef struct TupleAttrAlignData
+{
+ int32 attcacheoff;
+ int16 attlen;
+ char attalign;
+ union {
+ char attstorage;
+ bool attbyval;
+ };
+} TupleAttrAlignData;
+
+typedef TupleAttrAlignData *TupleAttrAlign;
+
/*
* This struct is passed around within the backend to describe the structure
* of tuples. For tuples coming from on-disk relations, the information is
@@ -82,14 +95,18 @@ typedef struct TupleDescData
Oid tdtypeid; /* composite type ID for tuple type */
int32 tdtypmod; /* typmod for tuple type */
int tdrefcount; /* reference count, or -1 if not counting */
+ int attroff; /* offset to a co-allocated array of FormData_pg_attribute */
TupleConstr *constr; /* constraints, or NULL if none */
- /* attrs[N] is the description of Attribute Number N+1 */
- FormData_pg_attribute attrs[FLEXIBLE_ARRAY_MEMBER];
+ /* attrs[N] is the alignment data of Attribute Number N+1 */
+ TupleAttrAlignData attrs[FLEXIBLE_ARRAY_MEMBER];
} TupleDescData;
typedef struct TupleDescData *TupleDesc;
/* Accessor for the i'th attribute of tupdesc. */
-#define TupleDescAttr(tupdesc, i) (&(tupdesc)->attrs[(i)])
+//#define TupleDescAttr(tupdesc, i) (&(tupdesc)->attrs[(i)])
+#define TupleDescAttr(tupdesc, i) ((FormData_pg_attribute *) ((char *)(tupdesc) + (tupdesc)->attroff + (i) * sizeof(FormData_pg_attribute)))
+/* Accessor for the i'th attribute of attralign. */
+#define TupleDescAttrAlign(tupdesc, i) (&(tupdesc)->attrs[(i)])
extern TupleDesc CreateTemplateTupleDesc(int natts);
@@ -100,8 +117,9 @@ extern TupleDesc CreateTupleDescCopy(TupleDesc tupdesc);
extern TupleDesc CreateTupleDescCopyConstr(TupleDesc tupdesc);
#define TupleDescSize(src) \
- (offsetof(struct TupleDescData, attrs) + \
- (src)->natts * sizeof(FormData_pg_attribute))
+ (MAXALIGN(offsetof(struct TupleDescData, attrs) + \
+ (src)->natts * sizeof(TupleAttrAlignData)) + \
+ MAXALIGN((src)->natts * sizeof(FormData_pg_attribute)))
extern void TupleDescCopy(TupleDesc dst, TupleDesc src);
@@ -125,6 +143,17 @@ extern void DecrTupleDescRefCount(TupleDesc tupdesc);
DecrTupleDescRefCount(tupdesc); \
} while (0)
+#define CopyAttrToAlign(att, align) \
+ do { \
+ (align)->attcacheoff = (att)->attcacheoff; \
+ (align)->attlen = (att)->attlen; \
+ (align)->attalign = (att)->attalign; \
+ if ((att)->attlen < 0) \
+ (align)->attstorage = (att)->attstorage; \
+ else \
+ (align)->attbyval = (att)->attbyval; \
+ } while (0)
+
extern bool equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2);
extern uint32 hashTupleDesc(TupleDesc tupdesc);
@@ -147,6 +176,9 @@ extern void TupleDescInitEntryCollation(TupleDesc desc,
AttrNumber attributeNumber,
Oid collationid);
+extern void TupleDescInitAttrAligns(TupleDesc desc);
+extern bool TupleDescAttrAlignsIsConsistent(TupleDesc desc);
+
extern TupleDesc BuildDescForRelation(List *schema);
extern TupleDesc BuildDescFromLists(List *names, List *types, List *typmods, List *collations);
diff --git a/src/include/access/tupmacs.h b/src/include/access/tupmacs.h
index 65ac1ef3fc..0451dd6bb8 100644
--- a/src/include/access/tupmacs.h
+++ b/src/include/access/tupmacs.h
@@ -47,7 +47,7 @@
#define fetch_att(T,attbyval,attlen) \
( \
- (attbyval) ? \
+ (attbyval && attlen >= 0) ? \
( \
(attlen) == (int) sizeof(Datum) ? \
*((Datum *)(T)) \
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index 5c1ec9313e..0bfb573c41 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -94,6 +94,11 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
* no cached value. But when we copy these tuples into a tuple
* descriptor, we may then update attcacheoff in the copies. This speeds
* up the attribute walking process.
+ *
+ * Note: Although the maximum offset encountered in stored tuples is
+ * limited to the max BLCKSZ (2**15), FormData_pg_attribute is used for
+ * all internal tuples as well, so attcacheoff may be larger for those
+ * tuples, and it is therefore not safe to use int16.
*/
int32 attcacheoff BKI_DEFAULT(-1);
--
2.20.1
Hi,
I wanted to revive this thread to summarize what was discussed and get
a sense of next steps we could take.
The idea that gained the most traction is to make identifiers
variable-length in the catalogs, which has the added benefit of
reducing memory in syscaches in the common case. That presented two
challenges:
1. That would require putting the name physically closer to the end of
the column list. To make this less annoying for users, we'd need to
separate physical order from display order (at least/at first only for
system catalogs). This would require:
- changing star expansion in SELECTs (expandRTE etc)
- adjusting pg_dump, \d, etc
That much seems clear and agreed upon.
2. We'd need to change how TupleDescs are stored and accessed.
For this point, Matthias shared a prototype patch for a 'compact
attribute access descriptor' and Andres wondered if we should "give up
on the struct / ondisk layout mirroring for catalog tables, and
generate explicit transformation routines via Catalog.pm".
After this discussion dropped off, and it's not quite clear to me what
the first logical step is to make progress on the thread subject, and
what's nice to have for other reasons. Is Matthias's patch or
something like it a good next step?
--
John Naylor
EDB: http://www.enterprisedb.com
Hi,
On Fri, Jun 03, 2022 at 01:28:16PM +0700, John Naylor wrote:
I wanted to revive this thread to summarize what was discussed and get
a sense of next steps we could take.
Thanks for reviving this topic!
The idea that gained the most traction is to make identifiers
variable-length in the catalogs, which has the added benefit of
reducing memory in syscaches in the common case. That presented two
challenges:1. That would require putting the name physically closer to the end of
the column list. To make this less annoying for users, we'd need to
separate physical order from display order (at least/at first only for
system catalogs). This would require:- changing star expansion in SELECTs (expandRTE etc)
- adjusting pg_dump, \d, etc
I tried to work on a physical / logical attribute position patch (more at the
end of the mail). I based it on �lvaro's feedback at [1]/messages/by-id/202108181639.xjuovrpwgkr2@alvherre.pgsql, which is:
- rename current pg_attribute.attnum to attphysnum
- add a new pg_attribute.attnum for the now logical position
- tweak a few places to use attnum rather than attphysnum (which however isn't
what I did)
The idea, IIUC, is to make a physical position reordering entirely transparent
to clients.
However, once you change the star expansion, things start to subtly break in a
lot of places. I try to dig in a bit to see if things could be made to work
the same but it opened a whole can of worms. So before spending too much time
on something that could be a non-starter I'd like to get some feedback on the
general approach.
While some problem wouldn't happen if we restricted the feature to system
catalogs only (e.g. with renamed / dropped attributes, inheritance...), a lot
would still exist and would have to be dealt with initially. However I'm not
sure what behavior would be wanted or acceptable, especially if we want
something that can eventually be used for user relations too, with possibly
dynamic positions.
I'll describe some of those problems, and just to make things easier I will use
a normal table "ab" with 2 attributes, a and b, with their physical / logical
position reversed.
Obviously
SELECT * FROM ab
should return a and b in that order. The aliases should also probably match
the logical position, as in:
SELECT * FROM ab ab(aa, bb)
should probably map aa to a and bb to b.
But should COPY FROM / COPY TO / INSERT INTO use the logical position too if
not column list is provided? I'd think so, but it goes further from the
original "only handle star expansion" idea.
And should record_in / record_out use the logical position, as in:
SELECT ab::text FROM ab / SELECT (a, b)::ab;
I would think not, as relying on a possibly dynamic order could break things if
you store the results somewhere, but YMMV.
Note that there a variations of that, like
SELECT ab::ab FROM (SELECT * FROM ab) ab;
But those should probably work as intended (for now it doesn't) as you can't
store a bare record, and storing a plain "ab" type wouldn't be problematic with
dynamic changes.
Then, what about joinrels expansion? I learned that the column ordering rules
are far from being obvious, and I didn't find those in the documentation (note
that I don't know if that something actually described in the SQL standard).
So for instance, if a join is using an explicit USING clause rather than an ON
clause, the merged columns are expanded first, so:
SELECT * FROM ab ab1 JOIN ab ab2 USING (b)
should unexpectedly expand to (b, a, a). Is this order a strict requirement?
For now I sort the expanded columns by (varno, attnum) but that's clearly a
noticeable change.
Another problem (that probably wouldn't be a problem for system catalogs) is
that defaults are evaluated in the physical position. This example from the
regression test will clearly have a different behavior if the columns are in a
different physical order:
CREATE TABLE INSERT_TBL (
x INT DEFAULT nextval('insert_seq'),
y TEXT DEFAULT '-NULL-',
z INT DEFAULT -1 * currval('insert_seq'),
CONSTRAINT INSERT_TBL_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8),
CHECK (x + z = 0));
But changing the behavior to rely on the logical position seems quite
dangerous.
I'm also attaching some few patches as a basis for an implementation
discussion. Those are just POC level prototypes with the bare minimum changes
to try to have a behavior based on the logical position, and absolutely no
effort to optimize anything. I'm also not familiar with all the impacted
places, so I'm definitely not claiming that this is a good approach. Any
suggestion on a better approach is welcome.
0001 is the s/attphysnum/attnum/ suggested by �lvaro. Here again it's the bare
minimum to make the code compile, a lot of the code still reference attnum in
some ways (attnameAttnum(), variables like attnums and so on) that would need
to be cleaned up.
0002 is the addition of the new pg_attribute.attnum with some changes trying to
make things work, but no infrastructure to change it anywhere.
The relevant changes are there. In expandNSItemAttrs and some other places,
the difference is that the used TupleDesc is first copied and sorted by logical
position, and then the attphysnum attributes are used rather than a loop
counter, or the targetlist are sorted and then the resno" are computed . Other
places (only the relation columns aliases I think for now) also builds an array
for the physical / logical mappings,.
I also changed psql to display the column in logical position, and emit an
extra line with the physical position in the verbose mode, but that's a clearly
poor design which would need a lot more thoughts. No changes in pg_dump or any
other tool.
0003 adds some infrastructure to specify the logical position for system
catalogs. It also moves relname and attname near the end of the non-varlena
part of pg_class / pg_attribute (just before the end so no change is needed in
the *_FIXED_PART_SIZE macros)
I also added some patches I used for testing:
0004 automatically reverses relation attributes order and preserves the
original logical position, so you can run the whole regression tests and see
what breaks.
0005 adds an ORDER (column_name, [...]) clause in the simplest CREATE TABLE
command form to declare the logical order and manually test things, something
like:
CREATE TABLE ab (b int, a int) ORDER (a, b);
[1]: /messages/by-id/202108181639.xjuovrpwgkr2@alvherre.pgsql
Attachments:
v1-0001-WIP-Rename-attnum-to-attphysnum.patchtext/plain; charset=us-asciiDownload
From 5e5a45cb14cadc03c1dec75d9a68474ba04972ec Mon Sep 17 00:00:00 2001
From: Julien Rouhaud <julien.rouhaud@free.fr>
Date: Sat, 4 Jun 2022 01:50:14 +0800
Subject: [PATCH v1 1/5] WIP: Rename attnum to attphysnum
This is the bare minimum to make the code compile, a lot more effort is
required for a proper patch.
A lot of things would need to be renamed accordingly, for instance
attnameAttNum() and similar, and a lot of variables name attnums, pk_attnums
and so on.
Author: Julien Rouhaud
Reviewed-by: FIXME
Discussion: FIXME
---
contrib/amcheck/amcheck--1.2--1.3.sql | 2 +-
contrib/amcheck/expected/check_heap.out | 92 ++---
contrib/amcheck/verify_heapam.c | 30 +-
contrib/amcheck/verify_nbtree.c | 2 +-
contrib/dblink/dblink.c | 14 +-
contrib/file_fdw/file_fdw.c | 22 +-
contrib/lo/lo.c | 14 +-
contrib/pageinspect/expected/brin.out | 8 +-
contrib/pageinspect/pageinspect--1.2--1.3.sql | 2 +-
contrib/pageinspect/pageinspect--1.5.sql | 2 +-
contrib/pageinspect/pageinspect--1.8--1.9.sql | 2 +-
contrib/pageinspect/sql/brin.sql | 2 +-
contrib/postgres_fdw/deparse.c | 22 +-
contrib/postgres_fdw/postgres_fdw.c | 38 +-
contrib/sepgsql/dml.c | 10 +-
contrib/sepgsql/label.c | 2 +-
contrib/sepgsql/relation.c | 32 +-
contrib/sepgsql/sepgsql.h | 8 +-
contrib/spi/autoinc.c | 10 +-
contrib/spi/insert_username.c | 10 +-
contrib/spi/moddatetime.c | 10 +-
contrib/test_decoding/test_decoding.c | 2 +-
contrib/vacuumlo/vacuumlo.c | 2 +-
doc/src/sgml/amcheck.sgml | 4 +-
doc/src/sgml/fdwhandler.sgml | 2 +-
doc/src/sgml/pageinspect.sgml | 4 +-
doc/src/sgml/ref/psql-ref.sgml | 2 +-
doc/src/sgml/sources.sgml | 2 +-
doc/src/sgml/trigger.sgml | 2 +-
doc/src/sgml/xaggr.sgml | 4 +-
src/backend/access/brin/brin_tuple.c | 18 +-
src/backend/access/common/attmap.c | 2 +-
src/backend/access/common/heaptuple.c | 108 +++---
src/backend/access/common/indextuple.c | 36 +-
src/backend/access/common/printsimple.c | 2 +-
src/backend/access/common/tupdesc.c | 30 +-
src/backend/access/gin/ginbulk.c | 24 +-
src/backend/access/gin/ginentrypage.c | 30 +-
src/backend/access/gin/ginfast.c | 18 +-
src/backend/access/gin/ginget.c | 42 +--
src/backend/access/gin/gininsert.c | 46 +--
src/backend/access/gin/ginlogic.c | 10 +-
src/backend/access/gin/ginscan.c | 22 +-
src/backend/access/gin/ginutil.c | 16 +-
src/backend/access/gin/ginvacuum.c | 6 +-
src/backend/access/index/genam.c | 8 +-
src/backend/access/index/indexam.c | 20 +-
src/backend/access/nbtree/nbtutils.c | 14 +-
src/backend/bootstrap/bootstrap.c | 78 ++--
src/backend/catalog/aclchk.c | 70 ++--
src/backend/catalog/catalog.c | 2 +-
src/backend/catalog/genbki.pl | 20 +-
src/backend/catalog/heap.c | 76 ++--
src/backend/catalog/index.c | 18 +-
src/backend/catalog/indexing.c | 6 +-
src/backend/catalog/information_schema.sql | 68 ++--
src/backend/catalog/objectaddress.c | 24 +-
src/backend/catalog/pg_attrdef.c | 32 +-
src/backend/catalog/pg_depend.c | 12 +-
src/backend/catalog/pg_publication.c | 14 +-
src/backend/catalog/system_views.sql | 18 +-
src/backend/commands/analyze.c | 28 +-
src/backend/commands/copy.c | 12 +-
src/backend/commands/copyfrom.c | 42 +--
src/backend/commands/copyfromparse.c | 12 +-
src/backend/commands/copyto.c | 46 +--
src/backend/commands/createas.c | 6 +-
src/backend/commands/event_trigger.c | 14 +-
src/backend/commands/indexcmds.c | 2 +-
src/backend/commands/matview.c | 12 +-
src/backend/commands/publicationcmds.c | 22 +-
src/backend/commands/sequence.c | 10 +-
src/backend/commands/statscmds.c | 8 +-
src/backend/commands/tablecmds.c | 342 +++++++++---------
src/backend/commands/trigger.c | 10 +-
src/backend/commands/tsearchcmds.c | 16 +-
src/backend/commands/typecmds.c | 16 +-
src/backend/executor/execExpr.c | 52 +--
src/backend/executor/execExprInterp.c | 110 +++---
src/backend/executor/execMain.c | 4 +-
src/backend/executor/execPartition.c | 6 +-
src/backend/executor/execTuples.c | 52 +--
src/backend/executor/execUtils.c | 2 +-
src/backend/executor/nodeAgg.c | 12 +-
src/backend/executor/spi.c | 14 +-
src/backend/foreign/foreign.c | 10 +-
src/backend/jit/llvm/llvmjit_deform.c | 104 +++---
src/backend/jit/llvm/llvmjit_expr.c | 4 +-
src/backend/optimizer/util/appendinfo.c | 2 +-
src/backend/parser/analyze.c | 6 +-
src/backend/parser/parse_clause.c | 16 +-
src/backend/parser/parse_relation.c | 122 +++----
src/backend/parser/parse_target.c | 52 +--
src/backend/parser/parse_type.c | 8 +-
src/backend/parser/parse_utilcmd.c | 64 ++--
src/backend/replication/basebackup_copy.c | 6 +-
src/backend/replication/logical/proto.c | 14 +-
src/backend/replication/logical/relation.c | 20 +-
.../replication/logical/reorderbuffer.c | 2 +-
src/backend/replication/logical/tablesync.c | 14 +-
src/backend/replication/logical/worker.c | 20 +-
src/backend/replication/pgoutput/pgoutput.c | 2 +-
src/backend/replication/walsender.c | 4 +-
src/backend/statistics/dependencies.c | 116 +++---
src/backend/statistics/extended_stats.c | 40 +-
src/backend/statistics/mvdistinct.c | 4 +-
src/backend/utils/adt/acl.c | 34 +-
src/backend/utils/adt/expandedrecord.c | 4 +-
src/backend/utils/adt/misc.c | 6 +-
src/backend/utils/adt/ri_triggers.c | 6 +-
src/backend/utils/adt/ruleutils.c | 90 ++---
src/backend/utils/adt/selfuncs.c | 60 +--
src/backend/utils/cache/attoptcache.c | 16 +-
src/backend/utils/cache/catcache.c | 10 +-
src/backend/utils/cache/lsyscache.c | 58 +--
src/backend/utils/cache/relcache.c | 42 +--
src/backend/utils/cache/syscache.c | 18 +-
src/bin/initdb/initdb.c | 2 +-
src/bin/pg_amcheck/pg_amcheck.c | 4 +-
src/bin/pg_amcheck/t/003_check.pl | 2 +-
src/bin/pg_dump/pg_dump.c | 26 +-
src/bin/psql/describe.c | 158 ++++++--
src/bin/psql/tab-complete.c | 4 +-
src/include/access/genam.h | 6 +-
src/include/access/gin_private.h | 24 +-
src/include/access/htup_details.h | 36 +-
src/include/access/itup.h | 18 +-
src/include/bootstrap/bootstrap.h | 2 +-
src/include/catalog/dependency.h | 2 +-
src/include/catalog/heap.h | 8 +-
src/include/catalog/pg_attrdef.h | 10 +-
src/include/catalog/pg_attribute.h | 8 +-
src/include/catalog/pg_constraint.h | 4 +-
src/include/catalog/pg_index.h | 2 +-
src/include/catalog/pg_partitioned_table.h | 2 +-
src/include/catalog/pg_statistic.h | 2 +-
src/include/catalog/pg_statistic_ext.h | 2 +-
src/include/catalog/pg_trigger.h | 2 +-
src/include/executor/execExpr.h | 6 +-
src/include/executor/spi.h | 2 +-
src/include/executor/tuptable.h | 42 +--
src/include/foreign/foreign.h | 2 +-
src/include/parser/parsetree.h | 4 +-
src/include/utils/acl.h | 8 +-
src/include/utils/attoptcache.h | 2 +-
src/include/utils/lsyscache.h | 18 +-
src/include/utils/relcache.h | 2 +-
src/include/utils/selfuncs.h | 2 +-
src/include/utils/syscache.h | 6 +-
src/pl/plpgsql/src/plpgsql.h | 2 +-
...summarization-and-inprogress-insertion.out | 28 +-
.../test_misc/t/001_constraint_validation.pl | 2 +-
src/test/regress/expected/alter_table.out | 32 +-
src/test/regress/expected/create_index.out | 14 +-
src/test/regress/expected/create_table.out | 4 +-
src/test/regress/expected/create_type.out | 2 +-
src/test/regress/expected/foreign_key.out | 2 +-
src/test/regress/expected/indexing.out | 48 +--
src/test/regress/expected/inherit.out | 2 +-
src/test/regress/expected/insert.out | 14 +-
src/test/regress/expected/join.out | 4 +-
src/test/regress/expected/oidjoins.out | 16 +-
src/test/regress/expected/opr_sanity.out | 4 +-
src/test/regress/expected/psql.out | 4 +-
src/test/regress/expected/rules.out | 18 +-
src/test/regress/expected/sanity_check.out | 6 +-
src/test/regress/expected/type_sanity.out | 10 +-
src/test/regress/regress.c | 30 +-
src/test/regress/sql/alter_table.sql | 22 +-
src/test/regress/sql/create_index.sql | 4 +-
src/test/regress/sql/create_table.sql | 4 +-
src/test/regress/sql/create_type.sql | 2 +-
src/test/regress/sql/foreign_key.sql | 2 +-
src/test/regress/sql/indexing.sql | 12 +-
src/test/regress/sql/inherit.sql | 2 +-
src/test/regress/sql/insert.sql | 4 +-
src/test/regress/sql/join.sql | 4 +-
src/test/regress/sql/opr_sanity.sql | 4 +-
src/test/regress/sql/psql.sql | 4 +-
src/test/regress/sql/sanity_check.sql | 6 +-
src/test/regress/sql/type_sanity.sql | 10 +-
src/tutorial/syscat.source | 4 +-
182 files changed, 1959 insertions(+), 1857 deletions(-)
diff --git a/contrib/amcheck/amcheck--1.2--1.3.sql b/contrib/amcheck/amcheck--1.2--1.3.sql
index 7237ab738c..5c49ddde17 100644
--- a/contrib/amcheck/amcheck--1.2--1.3.sql
+++ b/contrib/amcheck/amcheck--1.2--1.3.sql
@@ -14,7 +14,7 @@ CREATE FUNCTION verify_heapam(relation regclass,
endblock bigint default null,
blkno OUT bigint,
offnum OUT integer,
- attnum OUT integer,
+ attphysnum OUT integer,
msg OUT text)
RETURNS SETOF record
AS 'MODULE_PATHNAME', 'verify_heapam'
diff --git a/contrib/amcheck/expected/check_heap.out b/contrib/amcheck/expected/check_heap.out
index c010361025..d8267d0578 100644
--- a/contrib/amcheck/expected/check_heap.out
+++ b/contrib/amcheck/expected/check_heap.out
@@ -6,60 +6,60 @@ ERROR: invalid skip option
HINT: Valid skip options are "all-visible", "all-frozen", and "none".
-- Check specifying invalid block ranges when verifying an empty table
SELECT * FROM verify_heapam(relation := 'heaptest', startblock := 0, endblock := 0);
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', startblock := 5, endblock := 8);
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
-- Check that valid options are not rejected nor corruption reported
-- for an empty table, and that skip enum-like parameter is case-insensitive
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'none');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'all-frozen');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'all-visible');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'None');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'All-Frozen');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'All-Visible');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'NONE');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'ALL-FROZEN');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'ALL-VISIBLE');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
-- Add some data so subsequent tests are not entirely trivial
@@ -69,23 +69,23 @@ INSERT INTO heaptest (a, b)
-- Check that valid options are not rejected nor corruption reported
-- for a non-empty table
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'none');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'all-frozen');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'all-visible');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', startblock := 0, endblock := 0);
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
CREATE ROLE regress_heaptest_role;
@@ -98,8 +98,8 @@ GRANT EXECUTE ON FUNCTION verify_heapam(regclass, boolean, boolean, text, bigint
-- verify permissions are now sufficient
SET ROLE regress_heaptest_role;
SELECT * FROM verify_heapam(relation := 'heaptest');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
RESET ROLE;
@@ -113,23 +113,23 @@ VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) heaptest;
-- Check that valid options are not rejected nor corruption reported
-- for a non-empty frozen table
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'none');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'all-frozen');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'all-visible');
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
SELECT * FROM verify_heapam(relation := 'heaptest', startblock := 0, endblock := 0);
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
-- Check that partitioned tables (the parent ones) which don't have visibility
@@ -147,8 +147,8 @@ CREATE TABLE test_partition partition OF test_partitioned FOR VALUES IN (1);
SELECT * FROM verify_heapam('test_partition',
startblock := NULL,
endblock := NULL);
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
-- Check that valid options are not rejected nor corruption reported
@@ -157,8 +157,8 @@ INSERT INTO test_partitioned (a) (SELECT 1 FROM generate_series(1,1000) gs);
SELECT * FROM verify_heapam('test_partition',
startblock := NULL,
endblock := NULL);
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
-- Check that indexes are rejected
@@ -180,8 +180,8 @@ CREATE SEQUENCE test_sequence;
SELECT * FROM verify_heapam('test_sequence',
startblock := NULL,
endblock := NULL);
- blkno | offnum | attnum | msg
--------+--------+--------+-----
+ blkno | offnum | attphysnum | msg
+-------+--------+------------+-----
(0 rows)
-- Check that foreign tables are rejected
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e488f5e234..89d69ab394 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -71,7 +71,7 @@ typedef struct ToastedAttribute
struct varatt_external toast_pointer;
BlockNumber blkno; /* block in main table */
OffsetNumber offnum; /* offset in main table */
- AttrNumber attnum; /* attribute in main table */
+ AttrNumber attphysnum; /* attribute in main table */
} ToastedAttribute;
/*
@@ -130,7 +130,7 @@ typedef struct HeapCheckContext
/* Values for iterating over attributes within the tuple */
uint32 offset; /* offset in tuple data */
- AttrNumber attnum;
+ AttrNumber attphysnum;
/* True if tuple's xmax makes it eligible for pruning */
bool tuple_could_be_pruned;
@@ -272,10 +272,10 @@ verify_heapam(PG_FUNCTION_ARGS)
/*
* If we report corruption when not examining some individual attribute,
- * we need attnum to be reported as NULL. Set that up before any
+ * we need attphysnum to be reported as NULL. Set that up before any
* corruption reporting might happen.
*/
- ctx.attnum = -1;
+ ctx.attphysnum = -1;
/* Construct the tuplestore and tuple descriptor */
SetSingleFuncCall(fcinfo, 0);
@@ -552,7 +552,7 @@ verify_heapam(PG_FUNCTION_ARGS)
static void
report_corruption_internal(Tuplestorestate *tupstore, TupleDesc tupdesc,
BlockNumber blkno, OffsetNumber offnum,
- AttrNumber attnum, char *msg)
+ AttrNumber attphysnum, char *msg)
{
Datum values[HEAPCHECK_RELATION_COLS];
bool nulls[HEAPCHECK_RELATION_COLS];
@@ -562,8 +562,8 @@ report_corruption_internal(Tuplestorestate *tupstore, TupleDesc tupdesc,
MemSet(nulls, 0, sizeof(nulls));
values[0] = Int64GetDatum(blkno);
values[1] = Int32GetDatum(offnum);
- values[2] = Int32GetDatum(attnum);
- nulls[2] = (attnum < 0);
+ values[2] = Int32GetDatum(attphysnum);
+ nulls[2] = (attphysnum < 0);
values[3] = CStringGetTextDatum(msg);
/*
@@ -591,7 +591,7 @@ static void
report_corruption(HeapCheckContext *ctx, char *msg)
{
report_corruption_internal(ctx->tupstore, ctx->tupdesc, ctx->blkno,
- ctx->offnum, ctx->attnum, msg);
+ ctx->offnum, ctx->attphysnum, msg);
ctx->is_corrupt = true;
}
@@ -608,7 +608,7 @@ report_toast_corruption(HeapCheckContext *ctx, ToastedAttribute *ta,
char *msg)
{
report_corruption_internal(ctx->tupstore, ctx->tupdesc, ta->blkno,
- ta->offnum, ta->attnum, msg);
+ ta->offnum, ta->attphysnum, msg);
ctx->is_corrupt = true;
}
@@ -1272,7 +1272,7 @@ check_tuple_attribute(HeapCheckContext *ctx)
struct varatt_external toast_pointer;
infomask = ctx->tuphdr->t_infomask;
- thisatt = TupleDescAttr(RelationGetDescr(ctx->rel), ctx->attnum);
+ thisatt = TupleDescAttr(RelationGetDescr(ctx->rel), ctx->attphysnum);
tp = (char *) ctx->tuphdr + ctx->tuphdr->t_hoff;
@@ -1287,7 +1287,7 @@ check_tuple_attribute(HeapCheckContext *ctx)
}
/* Skip null values */
- if (infomask & HEAP_HASNULL && att_isnull(ctx->attnum, ctx->tuphdr->t_bits))
+ if (infomask & HEAP_HASNULL && att_isnull(ctx->attphysnum, ctx->tuphdr->t_bits))
return true;
/* Skip non-varlena values, but update offset first */
@@ -1448,7 +1448,7 @@ check_tuple_attribute(HeapCheckContext *ctx)
VARATT_EXTERNAL_GET_POINTER(ta->toast_pointer, attr);
ta->blkno = ctx->blkno;
ta->offnum = ctx->offnum;
- ta->attnum = ctx->attnum;
+ ta->attphysnum = ctx->attphysnum;
ctx->toasted_attributes = lappend(ctx->toasted_attributes, ta);
}
@@ -1560,12 +1560,12 @@ check_tuple(HeapCheckContext *ctx)
* attributes collected from the page.
*/
ctx->offset = 0;
- for (ctx->attnum = 0; ctx->attnum < ctx->natts; ctx->attnum++)
+ for (ctx->attphysnum = 0; ctx->attphysnum < ctx->natts; ctx->attphysnum++)
if (!check_tuple_attribute(ctx))
break; /* cannot continue */
- /* revert attnum to -1 until we again examine individual attributes */
- ctx->attnum = -1;
+ /* revert attphysnum to -1 until we again examine individual attributes */
+ ctx->attphysnum = -1;
}
/*
diff --git a/contrib/amcheck/verify_nbtree.c b/contrib/amcheck/verify_nbtree.c
index 2beeebb163..f1d935a538 100644
--- a/contrib/amcheck/verify_nbtree.c
+++ b/contrib/amcheck/verify_nbtree.c
@@ -2575,7 +2575,7 @@ bt_normalize_tuple(BtreeCheckState *state, IndexTuple itup)
/* Assume untoasted/already normalized datum initially */
toast_free[i] = false;
- normalized[i] = index_getattr(itup, att->attnum,
+ normalized[i] = index_getattr(itup, att->attphysnum,
tupleDescriptor,
&isnull[i]);
if (att->attbyval || att->attlen != -1 || isnull[i])
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index a561d1d652..306d5ec054 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -1694,7 +1694,7 @@ dblink_build_sql_insert(PG_FUNCTION_ARGS)
src_pkattvals = get_text_array_contents(src_pkattvals_arry, &src_nitems);
/*
- * There should be one source array key value for each key attnum
+ * There should be one source array key value for each key attphysnum
*/
if (src_nitems != pknumatts)
ereport(ERROR,
@@ -1708,7 +1708,7 @@ dblink_build_sql_insert(PG_FUNCTION_ARGS)
tgt_pkattvals = get_text_array_contents(tgt_pkattvals_arry, &tgt_nitems);
/*
- * There should be one target array key value for each key attnum
+ * There should be one target array key value for each key attphysnum
*/
if (tgt_nitems != pknumatts)
ereport(ERROR,
@@ -1780,7 +1780,7 @@ dblink_build_sql_delete(PG_FUNCTION_ARGS)
tgt_pkattvals = get_text_array_contents(tgt_pkattvals_arry, &tgt_nitems);
/*
- * There should be one target array key value for each key attnum
+ * There should be one target array key value for each key attphysnum
*/
if (tgt_nitems != pknumatts)
ereport(ERROR,
@@ -1859,7 +1859,7 @@ dblink_build_sql_update(PG_FUNCTION_ARGS)
src_pkattvals = get_text_array_contents(src_pkattvals_arry, &src_nitems);
/*
- * There should be one source array key value for each key attnum
+ * There should be one source array key value for each key attphysnum
*/
if (src_nitems != pknumatts)
ereport(ERROR,
@@ -1873,7 +1873,7 @@ dblink_build_sql_update(PG_FUNCTION_ARGS)
tgt_pkattvals = get_text_array_contents(tgt_pkattvals_arry, &tgt_nitems);
/*
- * There should be one target array key value for each key attnum
+ * There should be one target array key value for each key attphysnum
*/
if (tgt_nitems != pknumatts)
ereport(ERROR,
@@ -2902,7 +2902,7 @@ escape_param_str(const char *str)
*
* The user supplies an int2vector of 1-based logical attnums, plus a count
* argument (the need for the separate count argument is historical, but we
- * still check it). We check that each attnum corresponds to a valid,
+ * still check it). We check that each attphysnum corresponds to a valid,
* non-dropped attribute of the rel. We do *not* prevent attnums from being
* listed twice, though the actual use-case for such things is dubious.
* Note that before Postgres 9.0, the user's attnums were interpreted as
@@ -2923,7 +2923,7 @@ validate_pkattnums(Relation rel,
/* Don't take more array elements than there are */
pknumatts_arg = Min(pknumatts_arg, pkattnums_arg->dim1);
- /* Must have at least one pk attnum selected */
+ /* Must have at least one pk attphysnum selected */
if (pknumatts_arg <= 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c
index 4773cadec0..7980f67a14 100644
--- a/contrib/file_fdw/file_fdw.c
+++ b/contrib/file_fdw/file_fdw.c
@@ -430,7 +430,7 @@ get_file_fdw_attribute_options(Oid relid)
Relation rel;
TupleDesc tupleDesc;
AttrNumber natts;
- AttrNumber attnum;
+ AttrNumber attphysnum;
List *fnncolumns = NIL;
List *fncolumns = NIL;
@@ -441,9 +441,9 @@ get_file_fdw_attribute_options(Oid relid)
natts = tupleDesc->natts;
/* Retrieve FDW options for all user-defined attributes. */
- for (attnum = 1; attnum <= natts; attnum++)
+ for (attphysnum = 1; attphysnum <= natts; attphysnum++)
{
- Form_pg_attribute attr = TupleDescAttr(tupleDesc, attnum - 1);
+ Form_pg_attribute attr = TupleDescAttr(tupleDesc, attphysnum - 1);
List *options;
ListCell *lc;
@@ -451,7 +451,7 @@ get_file_fdw_attribute_options(Oid relid)
if (attr->attisdropped)
continue;
- options = GetForeignColumnOptions(relid, attnum);
+ options = GetForeignColumnOptions(relid, attphysnum);
foreach(lc, options)
{
DefElem *def = (DefElem *) lfirst(lc);
@@ -852,7 +852,7 @@ check_selective_binary_conversion(RelOptInfo *baserel,
ListCell *lc;
Relation rel;
TupleDesc tupleDesc;
- AttrNumber attnum;
+ AttrNumber attphysnum;
Bitmapset *attrs_used = NULL;
bool has_wholerow = false;
int numattrs;
@@ -895,25 +895,25 @@ check_selective_binary_conversion(RelOptInfo *baserel,
rel = table_open(foreigntableid, AccessShareLock);
tupleDesc = RelationGetDescr(rel);
- while ((attnum = bms_first_member(attrs_used)) >= 0)
+ while ((attphysnum = bms_first_member(attrs_used)) >= 0)
{
/* Adjust for system attributes. */
- attnum += FirstLowInvalidHeapAttributeNumber;
+ attphysnum += FirstLowInvalidHeapAttributeNumber;
- if (attnum == 0)
+ if (attphysnum == 0)
{
has_wholerow = true;
break;
}
/* Ignore system attributes. */
- if (attnum < 0)
+ if (attphysnum < 0)
continue;
/* Get user attributes. */
- if (attnum > 0)
+ if (attphysnum > 0)
{
- Form_pg_attribute attr = TupleDescAttr(tupleDesc, attnum - 1);
+ Form_pg_attribute attr = TupleDescAttr(tupleDesc, attphysnum - 1);
char *attname = NameStr(attr->attname);
/* Skip dropped attributes (probably shouldn't see any here). */
diff --git a/contrib/lo/lo.c b/contrib/lo/lo.c
index 457be26c4e..367e2fb866 100644
--- a/contrib/lo/lo.c
+++ b/contrib/lo/lo.c
@@ -24,7 +24,7 @@ Datum
lo_manage(PG_FUNCTION_ARGS)
{
TriggerData *trigdata = (TriggerData *) fcinfo->context;
- int attnum; /* attribute number to monitor */
+ int attphysnum; /* attribute number to monitor */
char **args; /* Args containing attr name */
TupleDesc tupdesc; /* Tuple Descriptor */
HeapTuple rettuple; /* Tuple to be returned */
@@ -61,9 +61,9 @@ lo_manage(PG_FUNCTION_ARGS)
isdelete = TRIGGER_FIRED_BY_DELETE(trigdata->tg_event);
/* Get the column we're interested in */
- attnum = SPI_fnumber(tupdesc, args[0]);
+ attphysnum = SPI_fnumber(tupdesc, args[0]);
- if (attnum <= 0)
+ if (attphysnum <= 0)
elog(ERROR, "%s: column \"%s\" does not exist",
trigdata->tg_trigger->tgname, args[0]);
@@ -74,10 +74,10 @@ lo_manage(PG_FUNCTION_ARGS)
* object associated with the original value is unlinked.
*/
if (newtuple != NULL &&
- bms_is_member(attnum - FirstLowInvalidHeapAttributeNumber, trigdata->tg_updatedcols))
+ bms_is_member(attphysnum - FirstLowInvalidHeapAttributeNumber, trigdata->tg_updatedcols))
{
- char *orig = SPI_getvalue(trigtuple, tupdesc, attnum);
- char *newv = SPI_getvalue(newtuple, tupdesc, attnum);
+ char *orig = SPI_getvalue(trigtuple, tupdesc, attphysnum);
+ char *newv = SPI_getvalue(newtuple, tupdesc, attphysnum);
if (orig != NULL && (newv == NULL || strcmp(orig, newv) != 0))
DirectFunctionCall1(be_lo_unlink,
@@ -96,7 +96,7 @@ lo_manage(PG_FUNCTION_ARGS)
*/
if (isdelete)
{
- char *orig = SPI_getvalue(trigtuple, tupdesc, attnum);
+ char *orig = SPI_getvalue(trigtuple, tupdesc, attphysnum);
if (orig != NULL)
{
diff --git a/contrib/pageinspect/expected/brin.out b/contrib/pageinspect/expected/brin.out
index d19cdc3b95..832117b565 100644
--- a/contrib/pageinspect/expected/brin.out
+++ b/contrib/pageinspect/expected/brin.out
@@ -42,10 +42,10 @@ SELECT * FROM brin_revmap_data(get_raw_page('test1_a_idx', 1)) LIMIT 5;
(5 rows)
SELECT * FROM brin_page_items(get_raw_page('test1_a_idx', 2), 'test1_a_idx')
- ORDER BY blknum, attnum LIMIT 5;
- itemoffset | blknum | attnum | allnulls | hasnulls | placeholder | value
-------------+--------+--------+----------+----------+-------------+----------
- 1 | 0 | 1 | f | f | f | {1 .. 1}
+ ORDER BY blknum, attphysnum LIMIT 5;
+ itemoffset | blknum | attphysnum | allnulls | hasnulls | placeholder | value
+------------+--------+------------+----------+----------+-------------+----------
+ 1 | 0 | 1 | f | f | f | {1 .. 1}
(1 row)
-- Failure for non-BRIN index.
diff --git a/contrib/pageinspect/pageinspect--1.2--1.3.sql b/contrib/pageinspect/pageinspect--1.2--1.3.sql
index 9c55a6e598..9d3af061b6 100644
--- a/contrib/pageinspect/pageinspect--1.2--1.3.sql
+++ b/contrib/pageinspect/pageinspect--1.2--1.3.sql
@@ -34,7 +34,7 @@ LANGUAGE C STRICT;
CREATE FUNCTION brin_page_items(IN page bytea, IN index_oid regclass,
OUT itemoffset int,
OUT blknum int,
- OUT attnum int,
+ OUT attphysnum int,
OUT allnulls bool,
OUT hasnulls bool,
OUT placeholder bool,
diff --git a/contrib/pageinspect/pageinspect--1.5.sql b/contrib/pageinspect/pageinspect--1.5.sql
index 1e40c3c97e..1e759b504d 100644
--- a/contrib/pageinspect/pageinspect--1.5.sql
+++ b/contrib/pageinspect/pageinspect--1.5.sql
@@ -219,7 +219,7 @@ LANGUAGE C STRICT PARALLEL SAFE;
CREATE FUNCTION brin_page_items(IN page bytea, IN index_oid regclass,
OUT itemoffset int,
OUT blknum int,
- OUT attnum int,
+ OUT attphysnum int,
OUT allnulls bool,
OUT hasnulls bool,
OUT placeholder bool,
diff --git a/contrib/pageinspect/pageinspect--1.8--1.9.sql b/contrib/pageinspect/pageinspect--1.8--1.9.sql
index be89a64ca1..389d981f82 100644
--- a/contrib/pageinspect/pageinspect--1.8--1.9.sql
+++ b/contrib/pageinspect/pageinspect--1.8--1.9.sql
@@ -127,7 +127,7 @@ DROP FUNCTION brin_page_items(IN page bytea, IN index_oid regclass);
CREATE FUNCTION brin_page_items(IN page bytea, IN index_oid regclass,
OUT itemoffset int,
OUT blknum int8,
- OUT attnum int,
+ OUT attphysnum int,
OUT allnulls bool,
OUT hasnulls bool,
OUT placeholder bool,
diff --git a/contrib/pageinspect/sql/brin.sql b/contrib/pageinspect/sql/brin.sql
index 45098c1ef5..555e83f98a 100644
--- a/contrib/pageinspect/sql/brin.sql
+++ b/contrib/pageinspect/sql/brin.sql
@@ -13,7 +13,7 @@ SELECT * FROM brin_revmap_data(get_raw_page('test1_a_idx', 0)) LIMIT 5;
SELECT * FROM brin_revmap_data(get_raw_page('test1_a_idx', 1)) LIMIT 5;
SELECT * FROM brin_page_items(get_raw_page('test1_a_idx', 2), 'test1_a_idx')
- ORDER BY blknum, attnum LIMIT 5;
+ ORDER BY blknum, attphysnum LIMIT 5;
-- Failure for non-BRIN index.
CREATE INDEX test1_a_btree ON test1 (a);
diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c
index 8f4d8a5022..5cd519511e 100644
--- a/contrib/postgres_fdw/deparse.c
+++ b/contrib/postgres_fdw/deparse.c
@@ -1890,13 +1890,13 @@ deparseInsertSql(StringInfo buf, RangeTblEntry *rte,
first = true;
foreach(lc, targetAttrs)
{
- int attnum = lfirst_int(lc);
+ int attphysnum = lfirst_int(lc);
if (!first)
appendStringInfoString(buf, ", ");
first = false;
- deparseColumnRef(buf, rtindex, attnum, rte, false);
+ deparseColumnRef(buf, rtindex, attphysnum, rte, false);
}
appendStringInfoString(buf, ") VALUES (");
@@ -1905,8 +1905,8 @@ deparseInsertSql(StringInfo buf, RangeTblEntry *rte,
first = true;
foreach(lc, targetAttrs)
{
- int attnum = lfirst_int(lc);
- Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1);
+ int attphysnum = lfirst_int(lc);
+ Form_pg_attribute attr = TupleDescAttr(tupdesc, attphysnum - 1);
if (!first)
appendStringInfoString(buf, ", ");
@@ -1971,8 +1971,8 @@ rebuildInsertSql(StringInfo buf, Relation rel,
first = true;
foreach(lc, target_attrs)
{
- int attnum = lfirst_int(lc);
- Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1);
+ int attphysnum = lfirst_int(lc);
+ Form_pg_attribute attr = TupleDescAttr(tupdesc, attphysnum - 1);
if (!first)
appendStringInfoString(buf, ", ");
@@ -2021,14 +2021,14 @@ deparseUpdateSql(StringInfo buf, RangeTblEntry *rte,
first = true;
foreach(lc, targetAttrs)
{
- int attnum = lfirst_int(lc);
- Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1);
+ int attphysnum = lfirst_int(lc);
+ Form_pg_attribute attr = TupleDescAttr(tupdesc, attphysnum - 1);
if (!first)
appendStringInfoString(buf, ", ");
first = false;
- deparseColumnRef(buf, rtindex, attnum, rte, false);
+ deparseColumnRef(buf, rtindex, attphysnum, rte, false);
if (attr->attgenerated)
appendStringInfoString(buf, " = DEFAULT");
else
@@ -2099,7 +2099,7 @@ deparseDirectUpdateSql(StringInfo buf, PlannerInfo *root,
forboth(lc, targetlist, lc2, targetAttrs)
{
TargetEntry *tle = lfirst_node(TargetEntry, lc);
- int attnum = lfirst_int(lc2);
+ int attphysnum = lfirst_int(lc2);
/* update's new-value expressions shouldn't be resjunk */
Assert(!tle->resjunk);
@@ -2108,7 +2108,7 @@ deparseDirectUpdateSql(StringInfo buf, PlannerInfo *root,
appendStringInfoString(buf, ", ");
first = false;
- deparseColumnRef(buf, rtindex, attnum, rte, false);
+ deparseColumnRef(buf, rtindex, attphysnum, rte, false);
appendStringInfoString(buf, " = ");
deparseExpr((Expr *) tle->expr, &context);
}
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index d56951153b..10effe7387 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -197,7 +197,7 @@ typedef struct PgFdwModifyState
List *retrieved_attrs; /* attr numbers retrieved by RETURNING */
/* info about parameters for prepared statement */
- AttrNumber ctidAttno; /* attnum of input resjunk ctid column */
+ AttrNumber ctidAttno; /* attphysnum of input resjunk ctid column */
int p_nums; /* number of parameters to transmit */
FmgrInfo *p_flinfo; /* output conversion functions for them */
@@ -240,8 +240,8 @@ typedef struct PgFdwDirectModifyState
int next_tuple; /* index of next one to return */
Relation resultRel; /* relcache entry for the target relation */
AttrNumber *attnoMap; /* array of attnums of input user columns */
- AttrNumber ctidAttno; /* attnum of input ctid column */
- AttrNumber oidAttno; /* attnum of input oid column */
+ AttrNumber ctidAttno; /* attphysnum of input ctid column */
+ AttrNumber oidAttno; /* attphysnum of input oid column */
bool hasSystemCols; /* are there system columns of resultRel? */
/* working memory context */
@@ -1800,14 +1800,14 @@ postgresPlanForeignModify(PlannerInfo *root,
rel->trigdesc->trig_update_before_row))
{
TupleDesc tupdesc = RelationGetDescr(rel);
- int attnum;
+ int attphysnum;
- for (attnum = 1; attnum <= tupdesc->natts; attnum++)
+ for (attphysnum = 1; attphysnum <= tupdesc->natts; attphysnum++)
{
- Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1);
+ Form_pg_attribute attr = TupleDescAttr(tupdesc, attphysnum - 1);
if (!attr->attisdropped)
- targetAttrs = lappend_int(targetAttrs, attnum);
+ targetAttrs = lappend_int(targetAttrs, attphysnum);
}
}
else if (operation == CMD_UPDATE)
@@ -2139,7 +2139,7 @@ postgresBeginForeignInsert(ModifyTableState *mtstate,
Relation rel = resultRelInfo->ri_RelationDesc;
RangeTblEntry *rte;
TupleDesc tupdesc = RelationGetDescr(rel);
- int attnum;
+ int attphysnum;
int values_end_len;
StringInfoData sql;
List *targetAttrs = NIL;
@@ -2164,12 +2164,12 @@ postgresBeginForeignInsert(ModifyTableState *mtstate,
initStringInfo(&sql);
/* We transmit all columns that are defined in the foreign table. */
- for (attnum = 1; attnum <= tupdesc->natts; attnum++)
+ for (attphysnum = 1; attphysnum <= tupdesc->natts; attphysnum++)
{
- Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1);
+ Form_pg_attribute attr = TupleDescAttr(tupdesc, attphysnum - 1);
if (!attr->attisdropped)
- targetAttrs = lappend_int(targetAttrs, attnum);
+ targetAttrs = lappend_int(targetAttrs, attphysnum);
}
/* Check if we add the ON CONFLICT clause to the remote query. */
@@ -4026,8 +4026,8 @@ create_foreign_modify(EState *estate,
/* Set up for remaining transmittable parameters */
foreach(lc, fmstate->target_attrs)
{
- int attnum = lfirst_int(lc);
- Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1);
+ int attphysnum = lfirst_int(lc);
+ Form_pg_attribute attr = TupleDescAttr(tupdesc, attphysnum - 1);
Assert(!attr->attisdropped);
@@ -4279,15 +4279,15 @@ convert_prep_stmt_params(PgFdwModifyState *fmstate,
j = (tupleid != NULL) ? 1 : 0;
foreach(lc, fmstate->target_attrs)
{
- int attnum = lfirst_int(lc);
- Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1);
+ int attphysnum = lfirst_int(lc);
+ Form_pg_attribute attr = TupleDescAttr(tupdesc, attphysnum - 1);
Datum value;
bool isnull;
/* Ignore generated columns; they are set to DEFAULT */
if (attr->attgenerated)
continue;
- value = slot_getattr(slots[i], attnum, &isnull);
+ value = slot_getattr(slots[i], attphysnum, &isnull);
if (isnull)
p_values[pindex] = NULL;
else
@@ -5330,10 +5330,10 @@ postgresImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid)
" JOIN pg_namespace n ON "
" relnamespace = n.oid "
" LEFT JOIN pg_attribute a ON "
- " attrelid = c.oid AND attnum > 0 "
+ " attrelid = c.oid AND attphysnum > 0 "
" AND NOT attisdropped "
" LEFT JOIN pg_attrdef ad ON "
- " adrelid = c.oid AND adnum = attnum ");
+ " adrelid = c.oid AND adnum = attphysnum ");
if (import_collate)
appendStringInfoString(&buf,
@@ -5383,7 +5383,7 @@ postgresImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid)
}
/* Append ORDER BY at the end of query to ensure output ordering */
- appendStringInfoString(&buf, " ORDER BY c.relname, a.attnum");
+ appendStringInfoString(&buf, " ORDER BY c.relname, a.attphysnum");
/* Fetch the data */
res = pgfdw_exec_query(conn, buf.data, NULL);
diff --git a/contrib/sepgsql/dml.c b/contrib/sepgsql/dml.c
index 3bb98dfb06..4f43665f70 100644
--- a/contrib/sepgsql/dml.c
+++ b/contrib/sepgsql/dml.c
@@ -61,7 +61,7 @@ fixup_whole_row_references(Oid relOid, Bitmapset *columns)
for (attno = 1; attno <= natts; attno++)
{
- tuple = SearchSysCache2(ATTNUM,
+ tuple = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(relOid),
Int16GetDatum(attno));
if (!HeapTupleIsValid(tuple))
@@ -117,7 +117,7 @@ fixup_inherited_columns(Oid parentId, Oid childId, Bitmapset *columns)
}
attname = get_attname(parentId, attno, false);
- attno = get_attnum(childId, attname);
+ attno = get_attphysnum(childId, attname);
if (attno == InvalidAttrNumber)
elog(ERROR, "cache lookup failed for attribute %s of relation %u",
attname, childId);
@@ -232,7 +232,7 @@ check_relation_privileges(Oid relOid,
while ((index = bms_first_member(columns)) >= 0)
{
- AttrNumber attnum;
+ AttrNumber attphysnum;
uint32 column_perms = 0;
if (bms_is_member(index, selected))
@@ -251,11 +251,11 @@ check_relation_privileges(Oid relOid,
continue;
/* obtain column's permission */
- attnum = index + FirstLowInvalidHeapAttributeNumber;
+ attphysnum = index + FirstLowInvalidHeapAttributeNumber;
object.classId = RelationRelationId;
object.objectId = relOid;
- object.objectSubId = attnum;
+ object.objectSubId = attphysnum;
audit_name = getObjectDescription(&object, false);
result = sepgsql_avc_check_perms(&object,
diff --git a/contrib/sepgsql/label.c b/contrib/sepgsql/label.c
index e4c98b7eae..97dccf385f 100644
--- a/contrib/sepgsql/label.c
+++ b/contrib/sepgsql/label.c
@@ -805,7 +805,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
object.classId = RelationRelationId;
object.objectId = attForm->attrelid;
- object.objectSubId = attForm->attnum;
+ object.objectSubId = attForm->attphysnum;
break;
case ProcedureRelationId:
diff --git a/contrib/sepgsql/relation.c b/contrib/sepgsql/relation.c
index 8767988c4d..b1ad4a6636 100644
--- a/contrib/sepgsql/relation.c
+++ b/contrib/sepgsql/relation.c
@@ -40,7 +40,7 @@ static void sepgsql_index_modify(Oid indexOid);
* although it also defines columns in addition to table.
*/
void
-sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
+sepgsql_attribute_post_create(Oid relOid, AttrNumber attphysnum)
{
Relation rel;
ScanKeyData skey[2];
@@ -72,17 +72,17 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relOid));
ScanKeyInit(&skey[1],
- Anum_pg_attribute_attnum,
+ Anum_pg_attribute_attphysnum,
BTEqualStrategyNumber, F_INT2EQ,
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
- sscan = systable_beginscan(rel, AttributeRelidNumIndexId, true,
+ sscan = systable_beginscan(rel, AttributeRelidPhysNumIndexId, true,
SnapshotSelf, 2, &skey[0]);
tuple = systable_getnext(sscan);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for column %d of relation %u",
- attnum, relOid);
+ attphysnum, relOid);
attForm = (Form_pg_attribute) GETSTRUCT(tuple);
@@ -114,7 +114,7 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
*/
object.classId = RelationRelationId;
object.objectId = relOid;
- object.objectSubId = attnum;
+ object.objectSubId = attphysnum;
SetSecurityLabel(&object, SEPGSQL_LABEL_TAG, ncontext);
systable_endscan(sscan);
@@ -130,7 +130,7 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
* It checks privileges to drop the supplied column.
*/
void
-sepgsql_attribute_drop(Oid relOid, AttrNumber attnum)
+sepgsql_attribute_drop(Oid relOid, AttrNumber attphysnum)
{
ObjectAddress object;
char *audit_name;
@@ -144,7 +144,7 @@ sepgsql_attribute_drop(Oid relOid, AttrNumber attnum)
*/
object.classId = RelationRelationId;
object.objectId = relOid;
- object.objectSubId = attnum;
+ object.objectSubId = attphysnum;
audit_name = getObjectIdentity(&object, false);
sepgsql_avc_check_perms(&object,
@@ -162,7 +162,7 @@ sepgsql_attribute_drop(Oid relOid, AttrNumber attnum)
* by the `seclabel'.
*/
void
-sepgsql_attribute_relabel(Oid relOid, AttrNumber attnum,
+sepgsql_attribute_relabel(Oid relOid, AttrNumber attphysnum,
const char *seclabel)
{
ObjectAddress object;
@@ -176,7 +176,7 @@ sepgsql_attribute_relabel(Oid relOid, AttrNumber attnum,
object.classId = RelationRelationId;
object.objectId = relOid;
- object.objectSubId = attnum;
+ object.objectSubId = attphysnum;
audit_name = getObjectIdentity(&object, false);
/*
@@ -206,7 +206,7 @@ sepgsql_attribute_relabel(Oid relOid, AttrNumber attnum,
* It checks privileges to alter the supplied column.
*/
void
-sepgsql_attribute_setattr(Oid relOid, AttrNumber attnum)
+sepgsql_attribute_setattr(Oid relOid, AttrNumber attphysnum)
{
ObjectAddress object;
char *audit_name;
@@ -220,7 +220,7 @@ sepgsql_attribute_setattr(Oid relOid, AttrNumber attnum)
*/
object.classId = RelationRelationId;
object.objectId = relOid;
- object.objectSubId = attnum;
+ object.objectSubId = attphysnum;
audit_name = getObjectIdentity(&object, false);
sepgsql_avc_check_perms(&object,
@@ -363,7 +363,7 @@ sepgsql_relation_post_create(Oid relOid)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relOid));
- ascan = systable_beginscan(arel, AttributeRelidNumIndexId, true,
+ ascan = systable_beginscan(arel, AttributeRelidPhysNumIndexId, true,
SnapshotSelf, 1, &akey);
while (HeapTupleIsValid(atup = systable_getnext(ascan)))
@@ -392,7 +392,7 @@ sepgsql_relation_post_create(Oid relOid)
object.classId = RelationRelationId;
object.objectId = relOid;
- object.objectSubId = attForm->attnum;
+ object.objectSubId = attForm->attphysnum;
SetSecurityLabel(&object, SEPGSQL_LABEL_TAG, ccontext);
pfree(ccontext);
@@ -490,7 +490,7 @@ sepgsql_relation_drop(Oid relOid)
HeapTuple atttup;
int i;
- attrList = SearchSysCacheList1(ATTNUM, ObjectIdGetDatum(relOid));
+ attrList = SearchSysCacheList1(ATTPHYSNUM, ObjectIdGetDatum(relOid));
for (i = 0; i < attrList->n_members; i++)
{
atttup = &attrList->members[i]->tuple;
@@ -501,7 +501,7 @@ sepgsql_relation_drop(Oid relOid)
object.classId = RelationRelationId;
object.objectId = relOid;
- object.objectSubId = attForm->attnum;
+ object.objectSubId = attForm->attphysnum;
audit_name = getObjectIdentity(&object, false);
sepgsql_avc_check_perms(&object,
diff --git a/contrib/sepgsql/sepgsql.h b/contrib/sepgsql/sepgsql.h
index 70f6203496..86e1562630 100644
--- a/contrib/sepgsql/sepgsql.h
+++ b/contrib/sepgsql/sepgsql.h
@@ -307,11 +307,11 @@ extern void sepgsql_schema_rename(Oid namespaceId);
/*
* relation.c
*/
-extern void sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum);
-extern void sepgsql_attribute_drop(Oid relOid, AttrNumber attnum);
-extern void sepgsql_attribute_relabel(Oid relOid, AttrNumber attnum,
+extern void sepgsql_attribute_post_create(Oid relOid, AttrNumber attphysnum);
+extern void sepgsql_attribute_drop(Oid relOid, AttrNumber attphysnum);
+extern void sepgsql_attribute_relabel(Oid relOid, AttrNumber attphysnum,
const char *seclabel);
-extern void sepgsql_attribute_setattr(Oid relOid, AttrNumber attnum);
+extern void sepgsql_attribute_setattr(Oid relOid, AttrNumber attphysnum);
extern void sepgsql_relation_post_create(Oid relOid);
extern void sepgsql_relation_drop(Oid relOid);
extern void sepgsql_relation_truncate(Oid relOid);
diff --git a/contrib/spi/autoinc.c b/contrib/spi/autoinc.c
index 8bf742230e..1b82c2ae29 100644
--- a/contrib/spi/autoinc.c
+++ b/contrib/spi/autoinc.c
@@ -70,23 +70,23 @@ autoinc(PG_FUNCTION_ARGS)
for (i = 0; i < nargs;)
{
- int attnum = SPI_fnumber(tupdesc, args[i]);
+ int attphysnum = SPI_fnumber(tupdesc, args[i]);
int32 val;
Datum seqname;
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
errmsg("\"%s\" has no attribute \"%s\"",
relname, args[i])));
- if (SPI_gettypeid(tupdesc, attnum) != INT4OID)
+ if (SPI_gettypeid(tupdesc, attphysnum) != INT4OID)
ereport(ERROR,
(errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
errmsg("attribute \"%s\" of \"%s\" must be type INT4",
args[i], relname)));
- val = DatumGetInt32(SPI_getbinval(rettuple, tupdesc, attnum, &isnull));
+ val = DatumGetInt32(SPI_getbinval(rettuple, tupdesc, attphysnum, &isnull));
if (!isnull && val != 0)
{
@@ -95,7 +95,7 @@ autoinc(PG_FUNCTION_ARGS)
}
i++;
- chattrs[chnattrs] = attnum;
+ chattrs[chnattrs] = attphysnum;
seqname = CStringGetTextDatum(args[i]);
newvals[chnattrs] = DirectFunctionCall1(nextval, seqname);
/* nextval now returns int64; coerce down to int32 */
diff --git a/contrib/spi/insert_username.c b/contrib/spi/insert_username.c
index a2e1747ff7..fbf3514942 100644
--- a/contrib/spi/insert_username.c
+++ b/contrib/spi/insert_username.c
@@ -31,7 +31,7 @@ insert_username(PG_FUNCTION_ARGS)
Relation rel; /* triggered relation */
HeapTuple rettuple = NULL;
TupleDesc tupdesc; /* tuple description */
- int attnum;
+ int attphysnum;
/* sanity checks from autoinc.c */
if (!CALLED_AS_TRIGGER(fcinfo))
@@ -65,14 +65,14 @@ insert_username(PG_FUNCTION_ARGS)
args = trigger->tgargs;
tupdesc = rel->rd_att;
- attnum = SPI_fnumber(tupdesc, args[0]);
+ attphysnum = SPI_fnumber(tupdesc, args[0]);
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
errmsg("\"%s\" has no attribute \"%s\"", relname, args[0])));
- if (SPI_gettypeid(tupdesc, attnum) != TEXTOID)
+ if (SPI_gettypeid(tupdesc, attphysnum) != TEXTOID)
ereport(ERROR,
(errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
errmsg("attribute \"%s\" of \"%s\" must be type TEXT",
@@ -84,7 +84,7 @@ insert_username(PG_FUNCTION_ARGS)
/* construct new tuple */
rettuple = heap_modify_tuple_by_cols(rettuple, tupdesc,
- 1, &attnum, &newval, &newnull);
+ 1, &attphysnum, &newval, &newnull);
pfree(relname);
diff --git a/contrib/spi/moddatetime.c b/contrib/spi/moddatetime.c
index 3eb7004de9..6291ca4816 100644
--- a/contrib/spi/moddatetime.c
+++ b/contrib/spi/moddatetime.c
@@ -32,7 +32,7 @@ moddatetime(PG_FUNCTION_ARGS)
TriggerData *trigdata = (TriggerData *) fcinfo->context;
Trigger *trigger; /* to get trigger name */
int nargs; /* # of arguments */
- int attnum; /* positional number of field to change */
+ int attphysnum; /* positional number of field to change */
Oid atttypid; /* type OID of field to change */
Datum newdt; /* The current datetime. */
bool newdtnull; /* null flag for it */
@@ -82,13 +82,13 @@ moddatetime(PG_FUNCTION_ARGS)
* This gets the position in the tuple of the field we want. args[0] being
* the name of the field to update, as passed in from the trigger.
*/
- attnum = SPI_fnumber(tupdesc, args[0]);
+ attphysnum = SPI_fnumber(tupdesc, args[0]);
/*
* This is where we check to see if the field we are supposed to update
* even exists.
*/
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
errmsg("\"%s\" has no attribute \"%s\"",
@@ -98,7 +98,7 @@ moddatetime(PG_FUNCTION_ARGS)
* Check the target field has an allowed type, and get the current
* datetime as a value of that type.
*/
- atttypid = SPI_gettypeid(tupdesc, attnum);
+ atttypid = SPI_gettypeid(tupdesc, attphysnum);
if (atttypid == TIMESTAMPOID)
newdt = DirectFunctionCall3(timestamp_in,
CStringGetDatum("now"),
@@ -121,7 +121,7 @@ moddatetime(PG_FUNCTION_ARGS)
/* Replace the attnum'th column with newdt */
rettuple = heap_modify_tuple_by_cols(rettuple, tupdesc,
- 1, &attnum, &newdt, &newdtnull);
+ 1, &attphysnum, &newdt, &newdtnull);
/* Clean up */
pfree(relname);
diff --git a/contrib/test_decoding/test_decoding.c b/contrib/test_decoding/test_decoding.c
index 3736da6784..3954427214 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -554,7 +554,7 @@ tuple_to_stringinfo(StringInfo s, TupleDesc tupdesc, HeapTuple tuple, bool skip_
* Don't print system columns, oid will already have been printed if
* present.
*/
- if (attr->attnum < 0)
+ if (attr->attphysnum < 0)
continue;
typid = attr->atttypid;
diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c
index b7c8f2c805..6a86c8cec8 100644
--- a/contrib/vacuumlo/vacuumlo.c
+++ b/contrib/vacuumlo/vacuumlo.c
@@ -193,7 +193,7 @@ vacuumlo(const char *database, const struct _param *param)
buf[0] = '\0';
strcat(buf, "SELECT s.nspname, c.relname, a.attname ");
strcat(buf, "FROM pg_class c, pg_attribute a, pg_namespace s, pg_type t ");
- strcat(buf, "WHERE a.attnum > 0 AND NOT a.attisdropped ");
+ strcat(buf, "WHERE a.attphysnum > 0 AND NOT a.attisdropped ");
strcat(buf, " AND a.attrelid = c.oid ");
strcat(buf, " AND a.atttypid = t.oid ");
strcat(buf, " AND c.relnamespace = s.oid ");
diff --git a/doc/src/sgml/amcheck.sgml b/doc/src/sgml/amcheck.sgml
index 5d61a33936..bd6e7ef77f 100644
--- a/doc/src/sgml/amcheck.sgml
+++ b/doc/src/sgml/amcheck.sgml
@@ -91,7 +91,7 @@ ORDER BY c.relpages DESC LIMIT 10;
| pg_description_o_c_o_index | 21
| pg_attribute_relid_attnam_index | 14
| pg_proc_oid_index | 10
- | pg_attribute_relid_attnum_index | 9
+ | pg_attribute_relid_attphysnum_index | 9
| pg_amproc_fam_proc_index | 5
| pg_amop_opr_fam_index | 5
| pg_amop_fam_strat_index | 5
@@ -213,7 +213,7 @@ SET client_min_messages = DEBUG1;
endblock bigint,
blkno OUT bigint,
offnum OUT integer,
- attnum OUT integer,
+ attphysnum OUT integer,
msg OUT text)
returns setof record
</function>
diff --git a/doc/src/sgml/fdwhandler.sgml b/doc/src/sgml/fdwhandler.sgml
index d0b5951019..e0f95fcfd4 100644
--- a/doc/src/sgml/fdwhandler.sgml
+++ b/doc/src/sgml/fdwhandler.sgml
@@ -1759,7 +1759,7 @@ GetForeignTable(Oid relid);
<para>
<programlisting>
List *
-GetForeignColumnOptions(Oid relid, AttrNumber attnum);
+GetForeignColumnOptions(Oid relid, AttrNumber attphysnum);
</programlisting>
This function returns the per-column FDW options for the column with the
diff --git a/doc/src/sgml/pageinspect.sgml b/doc/src/sgml/pageinspect.sgml
index d4ee34ee0f..4bfcf3c56d 100644
--- a/doc/src/sgml/pageinspect.sgml
+++ b/doc/src/sgml/pageinspect.sgml
@@ -564,8 +564,8 @@ test=# SELECT * FROM brin_revmap_data(get_raw_page('brinidx', 2)) LIMIT 5;
<screen>
test=# SELECT * FROM brin_page_items(get_raw_page('brinidx', 5),
'brinidx')
- ORDER BY blknum, attnum LIMIT 6;
- itemoffset | blknum | attnum | allnulls | hasnulls | placeholder | value
+ ORDER BY blknum, attphysnum LIMIT 6;
+ itemoffset | blknum | attphysnum | allnulls | hasnulls | placeholder | value
------------+--------+--------+----------+----------+-------------+--------------
137 | 0 | 1 | t | f | f |
137 | 0 | 2 | f | f | f | {1 .. 88}
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 65bb0a6a3f..b029355b50 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -2289,7 +2289,7 @@ Tue Oct 26 21:40:57 CEST 1999
<programlisting>
=> <userinput>SELECT format('create index on my_table(%I)', attname)</userinput>
-> <userinput>FROM pg_attribute</userinput>
--> <userinput>WHERE attrelid = 'my_table'::regclass AND attnum > 0</userinput>
+-> <userinput>WHERE attrelid = 'my_table'::regclass AND attphysnum > 0</userinput>
-> <userinput>ORDER BY attnum</userinput>
-> <userinput>\gexec</userinput>
CREATE INDEX
diff --git a/doc/src/sgml/sources.sgml b/doc/src/sgml/sources.sgml
index 5186d75d61..b6dab7ff47 100644
--- a/doc/src/sgml/sources.sgml
+++ b/doc/src/sgml/sources.sgml
@@ -326,7 +326,7 @@ ereport(ERROR,
</listitem>
<listitem>
<para>
- <function>errtablecol(Relation rel, int attnum)</function> specifies
+ <function>errtablecol(Relation rel, int attphysnum)</function> specifies
a column whose name, table name, and schema name should be included as
auxiliary fields in the error report.
</para>
diff --git a/doc/src/sgml/trigger.sgml b/doc/src/sgml/trigger.sgml
index 04e702a795..6234edbc12 100644
--- a/doc/src/sgml/trigger.sgml
+++ b/doc/src/sgml/trigger.sgml
@@ -803,7 +803,7 @@ typedef struct Trigger
<para>
As an example, to determine whether a column with attribute number
<varname>attnum</varname> (1-based) is a member of this bitmap set,
- call <literal>bms_is_member(attnum -
+ call <literal>bms_is_member(attphysnum -
FirstLowInvalidHeapAttributeNumber,
trigdata->tg_updatedcols))</literal>.
</para>
diff --git a/doc/src/sgml/xaggr.sgml b/doc/src/sgml/xaggr.sgml
index bdad8d3dc2..b983149059 100644
--- a/doc/src/sgml/xaggr.sgml
+++ b/doc/src/sgml/xaggr.sgml
@@ -319,7 +319,7 @@ CREATE AGGREGATE array_accum (anycompatible)
<programlisting>
SELECT attrelid::regclass, array_accum(attname)
FROM pg_attribute
- WHERE attnum > 0 AND attrelid = 'pg_tablespace'::regclass
+ WHERE attphysnum > 0 AND attrelid = 'pg_tablespace'::regclass
GROUP BY attrelid;
attrelid | array_accum
@@ -329,7 +329,7 @@ SELECT attrelid::regclass, array_accum(attname)
SELECT attrelid::regclass, array_accum(atttypid::regtype)
FROM pg_attribute
- WHERE attnum > 0 AND attrelid = 'pg_tablespace'::regclass
+ WHERE attphysnum > 0 AND attrelid = 'pg_tablespace'::regclass
GROUP BY attrelid;
attrelid | array_accum
diff --git a/src/backend/access/brin/brin_tuple.c b/src/backend/access/brin/brin_tuple.c
index c0e2dbd23b..f79840a357 100644
--- a/src/backend/access/brin/brin_tuple.c
+++ b/src/backend/access/brin/brin_tuple.c
@@ -634,7 +634,7 @@ brin_deconstruct_tuple(BrinDesc *brdesc,
char *tp, bits8 *nullbits, bool nulls,
Datum *values, bool *allnulls, bool *hasnulls)
{
- int attnum;
+ int attphysnum;
int stored;
TupleDesc diskdsc;
long off;
@@ -645,14 +645,14 @@ brin_deconstruct_tuple(BrinDesc *brdesc,
* 1 for a null value (rather than a 1 for a not null value as is the
* att_isnull convention used elsewhere.) See brin_form_tuple.
*/
- for (attnum = 0; attnum < brdesc->bd_tupdesc->natts; attnum++)
+ for (attphysnum = 0; attphysnum < brdesc->bd_tupdesc->natts; attphysnum++)
{
/*
* the "all nulls" bit means that all values in the page range for
* this column are nulls. Therefore there are no values in the tuple
* data area.
*/
- allnulls[attnum] = nulls && !att_isnull(attnum, nullbits);
+ allnulls[attphysnum] = nulls && !att_isnull(attphysnum, nullbits);
/*
* the "has nulls" bit means that some tuples have nulls, but others
@@ -661,8 +661,8 @@ brin_deconstruct_tuple(BrinDesc *brdesc,
*
* The hasnulls bits follow the allnulls bits in the same bitmask.
*/
- hasnulls[attnum] =
- nulls && !att_isnull(brdesc->bd_tupdesc->natts + attnum, nullbits);
+ hasnulls[attphysnum] =
+ nulls && !att_isnull(brdesc->bd_tupdesc->natts + attphysnum, nullbits);
}
/*
@@ -673,18 +673,18 @@ brin_deconstruct_tuple(BrinDesc *brdesc,
diskdsc = brtuple_disk_tupdesc(brdesc);
stored = 0;
off = 0;
- for (attnum = 0; attnum < brdesc->bd_tupdesc->natts; attnum++)
+ for (attphysnum = 0; attphysnum < brdesc->bd_tupdesc->natts; attphysnum++)
{
int datumno;
- if (allnulls[attnum])
+ if (allnulls[attphysnum])
{
- stored += brdesc->bd_info[attnum]->oi_nstored;
+ stored += brdesc->bd_info[attphysnum]->oi_nstored;
continue;
}
for (datumno = 0;
- datumno < brdesc->bd_info[attnum]->oi_nstored;
+ datumno < brdesc->bd_info[attphysnum]->oi_nstored;
datumno++)
{
Form_pg_attribute thisatt = TupleDescAttr(diskdsc, stored);
diff --git a/src/backend/access/common/attmap.c b/src/backend/access/common/attmap.c
index 896f82a22b..d84b1bcdc4 100644
--- a/src/backend/access/common/attmap.c
+++ b/src/backend/access/common/attmap.c
@@ -231,7 +231,7 @@ build_attrmap_by_name(TupleDesc indesc,
attname,
format_type_be(outdesc->tdtypeid),
format_type_be(indesc->tdtypeid))));
- attrMap->attnums[i] = inatt->attnum;
+ attrMap->attnums[i] = inatt->attphysnum;
break;
}
}
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 503cda46ef..4e61b6b372 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -82,14 +82,14 @@
*/
Datum
getmissingattr(TupleDesc tupleDesc,
- int attnum, bool *isnull)
+ int attphysnum, bool *isnull)
{
Form_pg_attribute att;
- Assert(attnum <= tupleDesc->natts);
- Assert(attnum > 0);
+ Assert(attphysnum <= tupleDesc->natts);
+ Assert(attphysnum > 0);
- att = TupleDescAttr(tupleDesc, attnum - 1);
+ att = TupleDescAttr(tupleDesc, attphysnum - 1);
if (att->atthasmissing)
{
@@ -98,7 +98,7 @@ getmissingattr(TupleDesc tupleDesc,
Assert(tupleDesc->constr);
Assert(tupleDesc->constr->missing);
- attrmiss = tupleDesc->constr->missing + (attnum - 1);
+ attrmiss = tupleDesc->constr->missing + (attphysnum - 1);
if (attrmiss->am_present)
{
@@ -356,29 +356,29 @@ heap_fill_tuple(TupleDesc tupleDesc,
* ----------------
*/
bool
-heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
+heap_attisnull(HeapTuple tup, int attphysnum, TupleDesc tupleDesc)
{
/*
* We allow a NULL tupledesc for relations not expected to have missing
* values, such as catalog relations and indexes.
*/
- Assert(!tupleDesc || attnum <= tupleDesc->natts);
- if (attnum > (int) HeapTupleHeaderGetNatts(tup->t_data))
+ Assert(!tupleDesc || attphysnum <= tupleDesc->natts);
+ if (attphysnum > (int) HeapTupleHeaderGetNatts(tup->t_data))
{
- if (tupleDesc && TupleDescAttr(tupleDesc, attnum - 1)->atthasmissing)
+ if (tupleDesc && TupleDescAttr(tupleDesc, attphysnum - 1)->atthasmissing)
return false;
else
return true;
}
- if (attnum > 0)
+ if (attphysnum > 0)
{
if (HeapTupleNoNulls(tup))
return false;
- return att_isnull(attnum - 1, tup->t_data->t_bits);
+ return att_isnull(attphysnum - 1, tup->t_data->t_bits);
}
- switch (attnum)
+ switch (attphysnum)
{
case TableOidAttributeNumber:
case SelfItemPointerAttributeNumber:
@@ -390,7 +390,7 @@ heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
break;
default:
- elog(ERROR, "invalid attnum: %d", attnum);
+ elog(ERROR, "invalid attphysnum: %d", attphysnum);
}
return false;
@@ -421,7 +421,7 @@ heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
*/
Datum
nocachegetattr(HeapTuple tuple,
- int attnum,
+ int attphysnum,
TupleDesc tupleDesc)
{
HeapTupleHeader tup = tuple->t_data;
@@ -439,7 +439,7 @@ nocachegetattr(HeapTuple tuple,
* ----------------
*/
- attnum--;
+ attphysnum--;
if (!HeapTupleNoNulls(tuple))
{
@@ -448,8 +448,8 @@ nocachegetattr(HeapTuple tuple,
*
* check to see if any preceding bits are null...
*/
- int byte = attnum >> 3;
- int finalbit = attnum & 0x07;
+ int byte = attphysnum >> 3;
+ int finalbit = attphysnum & 0x07;
/* check for nulls "before" final bit of last byte */
if ((~bp[byte]) & ((1 << finalbit) - 1))
@@ -480,7 +480,7 @@ nocachegetattr(HeapTuple tuple,
* If we get here, there are no nulls up to and including the target
* attribute. If we have a cached offset, we can use it.
*/
- att = TupleDescAttr(tupleDesc, attnum);
+ att = TupleDescAttr(tupleDesc, attphysnum);
if (att->attcacheoff >= 0)
return fetchatt(att, tp + att->attcacheoff);
@@ -493,7 +493,7 @@ nocachegetattr(HeapTuple tuple,
{
int j;
- for (j = 0; j <= attnum; j++)
+ for (j = 0; j <= attphysnum; j++)
{
if (TupleDescAttr(tupleDesc, j)->attlen <= 0)
{
@@ -541,9 +541,9 @@ nocachegetattr(HeapTuple tuple,
off += att->attlen;
}
- Assert(j > attnum);
+ Assert(j > attphysnum);
- off = TupleDescAttr(tupleDesc, attnum)->attcacheoff;
+ off = TupleDescAttr(tupleDesc, attphysnum)->attcacheoff;
}
else
{
@@ -601,7 +601,7 @@ nocachegetattr(HeapTuple tuple,
att->attcacheoff = off;
}
- if (i == attnum)
+ if (i == attphysnum)
break;
off = att_addlength_pointer(off, att->attlen, tp + off);
@@ -611,7 +611,7 @@ nocachegetattr(HeapTuple tuple,
}
}
- return fetchatt(TupleDescAttr(tupleDesc, attnum), tp + off);
+ return fetchatt(TupleDescAttr(tupleDesc, attphysnum), tp + off);
}
/* ----------------
@@ -620,11 +620,11 @@ nocachegetattr(HeapTuple tuple,
* Fetch the value of a system attribute for a tuple.
*
* This is a support routine for the heap_getattr macro. The macro
- * has already determined that the attnum refers to a system attribute.
+ * has already determined that the attphysnum refers to a system attribute.
* ----------------
*/
Datum
-heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
+heap_getsysattr(HeapTuple tup, int attphysnum, TupleDesc tupleDesc, bool *isnull)
{
Datum result;
@@ -633,7 +633,7 @@ heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
/* Currently, no sys attribute ever reads as NULL. */
*isnull = false;
- switch (attnum)
+ switch (attphysnum)
{
case SelfItemPointerAttributeNumber:
/* pass-by-reference datatype */
@@ -660,7 +660,7 @@ heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
result = ObjectIdGetDatum(tup->t_tableOid);
break;
default:
- elog(ERROR, "invalid attnum: %d", attnum);
+ elog(ERROR, "invalid attphysnum: %d", attphysnum);
result = 0; /* keep compiler quiet */
break;
}
@@ -735,7 +735,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
TupleDesc tupleDesc)
{
AttrMissing *attrmiss = NULL;
- int attnum;
+ int attphysnum;
int firstmissingnum;
bool hasNulls = HeapTupleHasNulls(sourceTuple);
HeapTupleHeader targetTHeader;
@@ -790,22 +790,22 @@ expand_tuple(HeapTuple *targetHeapTuple,
* Now walk the missing attributes. If there is a missing value make
* space for it. Otherwise, it's going to be NULL.
*/
- for (attnum = firstmissingnum;
- attnum < natts;
- attnum++)
+ for (attphysnum = firstmissingnum;
+ attphysnum < natts;
+ attphysnum++)
{
- if (attrmiss[attnum].am_present)
+ if (attrmiss[attphysnum].am_present)
{
- Form_pg_attribute att = TupleDescAttr(tupleDesc, attnum);
+ Form_pg_attribute att = TupleDescAttr(tupleDesc, attphysnum);
targetDataLen = att_align_datum(targetDataLen,
att->attalign,
att->attlen,
- attrmiss[attnum].am_value);
+ attrmiss[attphysnum].am_value);
targetDataLen = att_addlength_pointer(targetDataLen,
att->attlen,
- attrmiss[attnum].am_value);
+ attrmiss[attphysnum].am_value);
}
else
{
@@ -922,19 +922,19 @@ expand_tuple(HeapTuple *targetHeapTuple,
targetData += sourceDataLen;
/* Now fill in the missing values */
- for (attnum = sourceNatts; attnum < natts; attnum++)
+ for (attphysnum = sourceNatts; attphysnum < natts; attphysnum++)
{
- Form_pg_attribute attr = TupleDescAttr(tupleDesc, attnum);
+ Form_pg_attribute attr = TupleDescAttr(tupleDesc, attphysnum);
- if (attrmiss && attrmiss[attnum].am_present)
+ if (attrmiss && attrmiss[attphysnum].am_present)
{
fill_val(attr,
nullBits ? &nullBits : NULL,
&bitMask,
&targetData,
infoMask,
- attrmiss[attnum].am_value,
+ attrmiss[attphysnum].am_value,
false);
}
else
@@ -1202,12 +1202,12 @@ heap_modify_tuple_by_cols(HeapTuple tuple,
for (i = 0; i < nCols; i++)
{
- int attnum = replCols[i];
+ int attphysnum = replCols[i];
- if (attnum <= 0 || attnum > numberOfAttributes)
- elog(ERROR, "invalid column number %d", attnum);
- values[attnum - 1] = replValues[i];
- isnull[attnum - 1] = replIsnull[i];
+ if (attphysnum <= 0 || attphysnum > numberOfAttributes)
+ elog(ERROR, "invalid column number %d", attphysnum);
+ values[attphysnum - 1] = replValues[i];
+ isnull[attphysnum - 1] = replIsnull[i];
}
/*
@@ -1253,7 +1253,7 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
bool hasnulls = HeapTupleHasNulls(tuple);
int tdesc_natts = tupleDesc->natts;
int natts; /* number of atts to extract */
- int attnum;
+ int attphysnum;
char *tp; /* ptr to tuple data */
uint32 off; /* offset in tuple data */
bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
@@ -1272,19 +1272,19 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
off = 0;
- for (attnum = 0; attnum < natts; attnum++)
+ for (attphysnum = 0; attphysnum < natts; attphysnum++)
{
- Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attnum);
+ Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attphysnum);
- if (hasnulls && att_isnull(attnum, bp))
+ if (hasnulls && att_isnull(attphysnum, bp))
{
- values[attnum] = (Datum) 0;
- isnull[attnum] = true;
+ values[attphysnum] = (Datum) 0;
+ isnull[attphysnum] = true;
slow = true; /* can't use attcacheoff anymore */
continue;
}
- isnull[attnum] = false;
+ isnull[attphysnum] = false;
if (!slow && thisatt->attcacheoff >= 0)
off = thisatt->attcacheoff;
@@ -1315,7 +1315,7 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
thisatt->attcacheoff = off;
}
- values[attnum] = fetchatt(thisatt, tp + off);
+ values[attphysnum] = fetchatt(thisatt, tp + off);
off = att_addlength_pointer(off, thisatt->attlen, tp + off);
@@ -1327,8 +1327,8 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
* If tuple doesn't have all the atts indicated by tupleDesc, read the
* rest as nulls or missing values as appropriate.
*/
- for (; attnum < tdesc_natts; attnum++)
- values[attnum] = getmissingattr(tupleDesc, attnum + 1, &isnull[attnum]);
+ for (; attphysnum < tdesc_natts; attphysnum++)
+ values[attphysnum] = getmissingattr(tupleDesc, attphysnum + 1, &isnull[attphysnum]);
}
/*
diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c
index 3065730bae..126bc93e1c 100644
--- a/src/backend/access/common/indextuple.c
+++ b/src/backend/access/common/indextuple.c
@@ -220,7 +220,7 @@ index_form_tuple(TupleDesc tupleDescriptor,
*/
Datum
nocache_index_getattr(IndexTuple tup,
- int attnum,
+ int attphysnum,
TupleDesc tupleDesc)
{
char *tp; /* ptr to data part of tuple */
@@ -240,7 +240,7 @@ nocache_index_getattr(IndexTuple tup,
data_off = IndexInfoFindDataOffset(tup->t_info);
- attnum--;
+ attphysnum--;
if (IndexTupleHasNulls(tup))
{
@@ -257,8 +257,8 @@ nocache_index_getattr(IndexTuple tup,
* Now check to see if any preceding bits are null...
*/
{
- int byte = attnum >> 3;
- int finalbit = attnum & 0x07;
+ int byte = attphysnum >> 3;
+ int finalbit = attphysnum & 0x07;
/* check for nulls "before" final bit of last byte */
if ((~bp[byte]) & ((1 << finalbit) - 1))
@@ -290,7 +290,7 @@ nocache_index_getattr(IndexTuple tup,
* If we get here, there are no nulls up to and including the target
* attribute. If we have a cached offset, we can use it.
*/
- att = TupleDescAttr(tupleDesc, attnum);
+ att = TupleDescAttr(tupleDesc, attphysnum);
if (att->attcacheoff >= 0)
return fetchatt(att, tp + att->attcacheoff);
@@ -303,7 +303,7 @@ nocache_index_getattr(IndexTuple tup,
{
int j;
- for (j = 0; j <= attnum; j++)
+ for (j = 0; j <= attphysnum; j++)
{
if (TupleDescAttr(tupleDesc, j)->attlen <= 0)
{
@@ -351,9 +351,9 @@ nocache_index_getattr(IndexTuple tup,
off += att->attlen;
}
- Assert(j > attnum);
+ Assert(j > attphysnum);
- off = TupleDescAttr(tupleDesc, attnum)->attcacheoff;
+ off = TupleDescAttr(tupleDesc, attphysnum)->attcacheoff;
}
else
{
@@ -411,7 +411,7 @@ nocache_index_getattr(IndexTuple tup,
att->attcacheoff = off;
}
- if (i == attnum)
+ if (i == attphysnum)
break;
off = att_addlength_pointer(off, att->attlen, tp + off);
@@ -421,7 +421,7 @@ nocache_index_getattr(IndexTuple tup,
}
}
- return fetchatt(TupleDescAttr(tupleDesc, attnum), tp + off);
+ return fetchatt(TupleDescAttr(tupleDesc, attphysnum), tp + off);
}
/*
@@ -462,26 +462,26 @@ index_deform_tuple_internal(TupleDesc tupleDescriptor,
char *tp, bits8 *bp, int hasnulls)
{
int natts = tupleDescriptor->natts; /* number of atts to extract */
- int attnum;
+ int attphysnum;
int off = 0; /* offset in tuple data */
bool slow = false; /* can we use/set attcacheoff? */
/* Assert to protect callers who allocate fixed-size arrays */
Assert(natts <= INDEX_MAX_KEYS);
- for (attnum = 0; attnum < natts; attnum++)
+ for (attphysnum = 0; attphysnum < natts; attphysnum++)
{
- Form_pg_attribute thisatt = TupleDescAttr(tupleDescriptor, attnum);
+ Form_pg_attribute thisatt = TupleDescAttr(tupleDescriptor, attphysnum);
- if (hasnulls && att_isnull(attnum, bp))
+ if (hasnulls && att_isnull(attphysnum, bp))
{
- values[attnum] = (Datum) 0;
- isnull[attnum] = true;
+ values[attphysnum] = (Datum) 0;
+ isnull[attphysnum] = true;
slow = true; /* can't use attcacheoff anymore */
continue;
}
- isnull[attnum] = false;
+ isnull[attphysnum] = false;
if (!slow && thisatt->attcacheoff >= 0)
off = thisatt->attcacheoff;
@@ -512,7 +512,7 @@ index_deform_tuple_internal(TupleDesc tupleDescriptor,
thisatt->attcacheoff = off;
}
- values[attnum] = fetchatt(thisatt, tp + off);
+ values[attphysnum] = fetchatt(thisatt, tp + off);
off = att_addlength_pointer(off, thisatt->attlen, tp + off);
diff --git a/src/backend/access/common/printsimple.c b/src/backend/access/common/printsimple.c
index e99aa279f6..8c8b85ed63 100644
--- a/src/backend/access/common/printsimple.c
+++ b/src/backend/access/common/printsimple.c
@@ -41,7 +41,7 @@ printsimple_startup(DestReceiver *self, int operation, TupleDesc tupdesc)
pq_sendstring(&buf, NameStr(attr->attname));
pq_sendint32(&buf, 0); /* table oid */
- pq_sendint16(&buf, 0); /* attnum */
+ pq_sendint16(&buf, 0); /* attphysnum */
pq_sendint32(&buf, (int) attr->atttypid);
pq_sendint16(&buf, attr->attlen);
pq_sendint32(&buf, attr->atttypmod);
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index 9f41b1e854..409a93ccdf 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -291,7 +291,7 @@ TupleDescCopyEntry(TupleDesc dst, AttrNumber dstAttno,
* by other uses of this function or TupleDescInitEntry. So we cheat a
* bit to avoid a useless O(N^2) penalty.
*/
- dstAtt->attnum = dstAttno;
+ dstAtt->attphysnum = dstAttno;
dstAtt->attcacheoff = -1;
/* since we're not copying constraints or defaults, clear these */
@@ -416,7 +416,7 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
/*
* We do not need to check every single field here: we can disregard
- * attrelid and attnum (which were used to place the row in the attrs
+ * attrelid and attphysnum (which were used to place the row in the attrs
* array in the first place). It might look like we could dispense
* with checking attlen/attbyval/attalign, since these are derived
* from atttypid; but in the case of dropped columns we must check
@@ -619,7 +619,7 @@ TupleDescInitEntry(TupleDesc desc,
att->attcacheoff = -1;
att->atttypmod = typmod;
- att->attnum = attributeNumber;
+ att->attphysnum = attributeNumber;
att->attndims = attdim;
att->attnotnull = false;
@@ -680,7 +680,7 @@ TupleDescInitBuiltinEntry(TupleDesc desc,
att->attcacheoff = -1;
att->atttypmod = typmod;
- att->attnum = attributeNumber;
+ att->attphysnum = attributeNumber;
att->attndims = attdim;
att->attnotnull = false;
@@ -777,7 +777,7 @@ TupleDesc
BuildDescForRelation(List *schema)
{
int natts;
- AttrNumber attnum;
+ AttrNumber attphysnum;
ListCell *l;
TupleDesc desc;
bool has_not_null;
@@ -794,7 +794,7 @@ BuildDescForRelation(List *schema)
desc = CreateTemplateTupleDesc(natts);
has_not_null = false;
- attnum = 0;
+ attphysnum = 0;
foreach(l, schema)
{
@@ -807,7 +807,7 @@ BuildDescForRelation(List *schema)
* the list and have TupleDescInitEntry fill in the attribute
* information we need.
*/
- attnum++;
+ attphysnum++;
attname = entry->colname;
typenameTypeIdAndMod(NULL, entry->typeName, &atttypid, &atttypmod);
@@ -825,12 +825,12 @@ BuildDescForRelation(List *schema)
errmsg("column \"%s\" cannot be declared SETOF",
attname)));
- TupleDescInitEntry(desc, attnum, attname,
+ TupleDescInitEntry(desc, attphysnum, attname,
atttypid, atttypmod, attdim);
- att = TupleDescAttr(desc, attnum - 1);
+ att = TupleDescAttr(desc, attphysnum - 1);
/* Override TupleDescInitEntry's settings as requested */
- TupleDescInitEntryCollation(desc, attnum, attcollation);
+ TupleDescInitEntryCollation(desc, attphysnum, attcollation);
if (entry->storage)
att->attstorage = entry->storage;
@@ -877,7 +877,7 @@ TupleDesc
BuildDescFromLists(List *names, List *types, List *typmods, List *collations)
{
int natts;
- AttrNumber attnum;
+ AttrNumber attphysnum;
ListCell *l1;
ListCell *l2;
ListCell *l3;
@@ -894,7 +894,7 @@ BuildDescFromLists(List *names, List *types, List *typmods, List *collations)
*/
desc = CreateTemplateTupleDesc(natts);
- attnum = 0;
+ attphysnum = 0;
forfour(l1, names, l2, types, l3, typmods, l4, collations)
{
char *attname = strVal(lfirst(l1));
@@ -902,10 +902,10 @@ BuildDescFromLists(List *names, List *types, List *typmods, List *collations)
int32 atttypmod = lfirst_int(l3);
Oid attcollation = lfirst_oid(l4);
- attnum++;
+ attphysnum++;
- TupleDescInitEntry(desc, attnum, attname, atttypid, atttypmod, 0);
- TupleDescInitEntryCollation(desc, attnum, attcollation);
+ TupleDescInitEntry(desc, attphysnum, attname, atttypid, atttypmod, 0);
+ TupleDescInitEntryCollation(desc, attphysnum, attcollation);
}
return desc;
diff --git a/src/backend/access/gin/ginbulk.c b/src/backend/access/gin/ginbulk.c
index 0d0da44694..2ce4301250 100644
--- a/src/backend/access/gin/ginbulk.c
+++ b/src/backend/access/gin/ginbulk.c
@@ -76,8 +76,8 @@ cmpEntryAccumulator(const RBTNode *a, const RBTNode *b, void *arg)
BuildAccumulator *accum = (BuildAccumulator *) arg;
return ginCompareAttEntries(accum->ginstate,
- ea->attnum, ea->key, ea->category,
- eb->attnum, eb->key, eb->category);
+ ea->attphysnum, ea->key, ea->category,
+ eb->attphysnum, eb->key, eb->category);
}
/* Allocator function for rbtree.c */
@@ -125,12 +125,12 @@ ginInitBA(BuildAccumulator *accum)
* palloc'd space in accum->allocatedMemory.
*/
static Datum
-getDatumCopy(BuildAccumulator *accum, OffsetNumber attnum, Datum value)
+getDatumCopy(BuildAccumulator *accum, OffsetNumber attphysnum, Datum value)
{
Form_pg_attribute att;
Datum res;
- att = TupleDescAttr(accum->ginstate->origTupdesc, attnum - 1);
+ att = TupleDescAttr(accum->ginstate->origTupdesc, attphysnum - 1);
if (att->attbyval)
res = value;
else
@@ -146,7 +146,7 @@ getDatumCopy(BuildAccumulator *accum, OffsetNumber attnum, Datum value)
*/
static void
ginInsertBAEntry(BuildAccumulator *accum,
- ItemPointer heapptr, OffsetNumber attnum,
+ ItemPointer heapptr, OffsetNumber attphysnum,
Datum key, GinNullCategory category)
{
GinEntryAccumulator eatmp;
@@ -157,7 +157,7 @@ ginInsertBAEntry(BuildAccumulator *accum,
* For the moment, fill only the fields of eatmp that will be looked at by
* cmpEntryAccumulator or ginCombineData.
*/
- eatmp.attnum = attnum;
+ eatmp.attphysnum = attphysnum;
eatmp.key = key;
eatmp.category = category;
/* temporarily set up single-entry itempointer list */
@@ -173,7 +173,7 @@ ginInsertBAEntry(BuildAccumulator *accum,
* copies of the datum (if it's not null) and itempointer.
*/
if (category == GIN_CAT_NORM_KEY)
- ea->key = getDatumCopy(accum, attnum, key);
+ ea->key = getDatumCopy(accum, attphysnum, key);
ea->maxcount = DEF_NPTR;
ea->count = 1;
ea->shouldSort = false;
@@ -208,7 +208,7 @@ ginInsertBAEntry(BuildAccumulator *accum,
*/
void
ginInsertBAEntries(BuildAccumulator *accum,
- ItemPointer heapptr, OffsetNumber attnum,
+ ItemPointer heapptr, OffsetNumber attphysnum,
Datum *entries, GinNullCategory *categories,
int32 nentries)
{
@@ -217,7 +217,7 @@ ginInsertBAEntries(BuildAccumulator *accum,
if (nentries <= 0)
return;
- Assert(ItemPointerIsValid(heapptr) && attnum >= FirstOffsetNumber);
+ Assert(ItemPointerIsValid(heapptr) && attphysnum >= FirstOffsetNumber);
/*
* step will contain largest power of 2 and <= nentries
@@ -235,7 +235,7 @@ ginInsertBAEntries(BuildAccumulator *accum,
int i;
for (i = step - 1; i < nentries && i >= 0; i += step << 1 /* *2 */ )
- ginInsertBAEntry(accum, heapptr, attnum,
+ ginInsertBAEntry(accum, heapptr, attphysnum,
entries[i], categories[i]);
step >>= 1; /* /2 */
@@ -266,7 +266,7 @@ ginBeginBAScan(BuildAccumulator *accum)
*/
ItemPointerData *
ginGetBAEntry(BuildAccumulator *accum,
- OffsetNumber *attnum, Datum *key, GinNullCategory *category,
+ OffsetNumber *attphysnum, Datum *key, GinNullCategory *category,
uint32 *n)
{
GinEntryAccumulator *entry;
@@ -277,7 +277,7 @@ ginGetBAEntry(BuildAccumulator *accum,
if (entry == NULL)
return NULL; /* no more entries */
- *attnum = entry->attnum;
+ *attphysnum = entry->attphysnum;
*key = entry->key;
*category = entry->category;
list = entry->list;
diff --git a/src/backend/access/gin/ginentrypage.c b/src/backend/access/gin/ginentrypage.c
index 382f8bb4d6..3b6c2300a3 100644
--- a/src/backend/access/gin/ginentrypage.c
+++ b/src/backend/access/gin/ginentrypage.c
@@ -43,7 +43,7 @@ static void entrySplitPage(GinBtree btree, Buffer origbuf,
*/
IndexTuple
GinFormTuple(GinState *ginstate,
- OffsetNumber attnum, Datum key, GinNullCategory category,
+ OffsetNumber attphysnum, Datum key, GinNullCategory category,
Pointer data, Size dataSize, int nipd,
bool errorTooBig)
{
@@ -60,13 +60,13 @@ GinFormTuple(GinState *ginstate,
}
else
{
- datums[0] = UInt16GetDatum(attnum);
+ datums[0] = UInt16GetDatum(attphysnum);
isnull[0] = false;
datums[1] = key;
isnull[1] = (category != GIN_CAT_NORM_KEY);
}
- itup = index_form_tuple(ginstate->tupdesc[attnum - 1], datums, isnull);
+ itup = index_form_tuple(ginstate->tupdesc[attphysnum - 1], datums, isnull);
/*
* Determine and store offset to the posting list, making sure there is
@@ -160,7 +160,7 @@ GinFormTuple(GinState *ginstate,
* in *nitems.
*/
ItemPointer
-ginReadTuple(GinState *ginstate, OffsetNumber attnum, IndexTuple itup,
+ginReadTuple(GinState *ginstate, OffsetNumber attphysnum, IndexTuple itup,
int *nitems)
{
Pointer ptr = GinGetPosting(itup);
@@ -244,7 +244,7 @@ static bool
entryIsMoveRight(GinBtree btree, Page page)
{
IndexTuple itup;
- OffsetNumber attnum;
+ OffsetNumber attphysnum;
Datum key;
GinNullCategory category;
@@ -252,12 +252,12 @@ entryIsMoveRight(GinBtree btree, Page page)
return false;
itup = getRightMostTuple(page);
- attnum = gintuple_get_attrnum(btree->ginstate, itup);
+ attphysnum = gintuple_get_attrnum(btree->ginstate, itup);
key = gintuple_get_key(btree->ginstate, itup, &category);
if (ginCompareAttEntries(btree->ginstate,
btree->entryAttnum, btree->entryKey, btree->entryCategory,
- attnum, key, category) > 0)
+ attphysnum, key, category) > 0)
return true;
return false;
@@ -304,18 +304,18 @@ entryLocateEntry(GinBtree btree, GinBtreeStack *stack)
}
else
{
- OffsetNumber attnum;
+ OffsetNumber attphysnum;
Datum key;
GinNullCategory category;
itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, mid));
- attnum = gintuple_get_attrnum(btree->ginstate, itup);
+ attphysnum = gintuple_get_attrnum(btree->ginstate, itup);
key = gintuple_get_key(btree->ginstate, itup, &category);
result = ginCompareAttEntries(btree->ginstate,
btree->entryAttnum,
btree->entryKey,
btree->entryCategory,
- attnum, key, category);
+ attphysnum, key, category);
}
if (result == 0)
@@ -374,19 +374,19 @@ entryLocateLeafEntry(GinBtree btree, GinBtreeStack *stack)
{
OffsetNumber mid = low + ((high - low) / 2);
IndexTuple itup;
- OffsetNumber attnum;
+ OffsetNumber attphysnum;
Datum key;
GinNullCategory category;
int result;
itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, mid));
- attnum = gintuple_get_attrnum(btree->ginstate, itup);
+ attphysnum = gintuple_get_attrnum(btree->ginstate, itup);
key = gintuple_get_key(btree->ginstate, itup, &category);
result = ginCompareAttEntries(btree->ginstate,
btree->entryAttnum,
btree->entryKey,
btree->entryCategory,
- attnum, key, category);
+ attphysnum, key, category);
if (result == 0)
{
stack->off = mid;
@@ -742,7 +742,7 @@ ginEntryFillRoot(GinBtree btree, Page root,
* other than a faked-up Relation pointer; the key datum is bogus too.
*/
void
-ginPrepareEntryScan(GinBtree btree, OffsetNumber attnum,
+ginPrepareEntryScan(GinBtree btree, OffsetNumber attphysnum,
Datum key, GinNullCategory category,
GinState *ginstate)
{
@@ -766,7 +766,7 @@ ginPrepareEntryScan(GinBtree btree, OffsetNumber attnum,
btree->fullScan = false;
btree->isBuild = false;
- btree->entryAttnum = attnum;
+ btree->entryAttnum = attphysnum;
btree->entryKey = key;
btree->entryCategory = category;
}
diff --git a/src/backend/access/gin/ginfast.c b/src/backend/access/gin/ginfast.c
index 7409fdc165..2a50a55fbc 100644
--- a/src/backend/access/gin/ginfast.c
+++ b/src/backend/access/gin/ginfast.c
@@ -473,7 +473,7 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector)
void
ginHeapTupleFastCollect(GinState *ginstate,
GinTupleCollector *collector,
- OffsetNumber attnum, Datum value, bool isNull,
+ OffsetNumber attphysnum, Datum value, bool isNull,
ItemPointer ht_ctid)
{
Datum *entries;
@@ -484,7 +484,7 @@ ginHeapTupleFastCollect(GinState *ginstate,
/*
* Extract the key values that need to be inserted in the index
*/
- entries = ginExtractEntries(ginstate, attnum, value, isNull,
+ entries = ginExtractEntries(ginstate, attphysnum, value, isNull,
&nentries, &categories);
/*
@@ -527,7 +527,7 @@ ginHeapTupleFastCollect(GinState *ginstate,
{
IndexTuple itup;
- itup = GinFormTuple(ginstate, attnum, entries[i], categories[i],
+ itup = GinFormTuple(ginstate, attphysnum, entries[i], categories[i],
NULL, 0, 0, true);
itup->t_tid = *ht_ctid;
collector->tuples[collector->ntuples++] = itup;
@@ -723,7 +723,7 @@ processPendingPage(BuildAccumulator *accum, KeyArray *ka,
Datum curkey;
GinNullCategory curcategory;
- /* Check for change of heap TID or attnum */
+ /* Check for change of heap TID or attphysnum */
curattnum = gintuple_get_attrnum(accum->ginstate, itup);
if (!ItemPointerIsValid(&heapptr))
@@ -902,7 +902,7 @@ ginInsertCleanup(GinState *ginstate, bool full_clean,
Datum key;
GinNullCategory category;
OffsetNumber maxoff,
- attnum;
+ attphysnum;
/*
* Unlock current page to increase performance. Changes of page
@@ -919,9 +919,9 @@ ginInsertCleanup(GinState *ginstate, bool full_clean,
*/
ginBeginBAScan(&accum);
while ((list = ginGetBAEntry(&accum,
- &attnum, &key, &category, &nlist)) != NULL)
+ &attphysnum, &key, &category, &nlist)) != NULL)
{
- ginEntryInsert(ginstate, attnum, key, category,
+ ginEntryInsert(ginstate, attphysnum, key, category,
list, nlist, NULL);
vacuum_delay_point();
}
@@ -949,8 +949,8 @@ ginInsertCleanup(GinState *ginstate, bool full_clean,
ginBeginBAScan(&accum);
while ((list = ginGetBAEntry(&accum,
- &attnum, &key, &category, &nlist)) != NULL)
- ginEntryInsert(ginstate, attnum, key, category,
+ &attphysnum, &key, &category, &nlist)) != NULL)
+ ginEntryInsert(ginstate, attphysnum, key, category,
list, nlist, NULL);
}
diff --git a/src/backend/access/gin/ginget.c b/src/backend/access/gin/ginget.c
index fc85ba99ac..55f05eb65d 100644
--- a/src/backend/access/gin/ginget.c
+++ b/src/backend/access/gin/ginget.c
@@ -111,9 +111,9 @@ scanPostingTree(Relation index, GinScanEntry scanEntry,
* 1. Partial-match support: scan from current point until the
* comparePartialFn says we're done.
* 2. SEARCH_MODE_ALL: scan from current point (which should be first
- * key for the current attnum) until we hit null items or end of attnum
+ * key for the current attphysnum) until we hit null items or end of attphysnum
* 3. SEARCH_MODE_EVERYTHING: scan from current point (which should be first
- * key for the current attnum) until we hit end of attnum
+ * key for the current attphysnum) until we hit end of attphysnum
*
* Returns true if done, false if it's necessary to restart scan from scratch
*/
@@ -121,7 +121,7 @@ static bool
collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack,
GinScanEntry scanEntry, Snapshot snapshot)
{
- OffsetNumber attnum;
+ OffsetNumber attphysnum;
Form_pg_attribute attr;
/* Initialize empty bitmap result */
@@ -133,8 +133,8 @@ collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack,
return true;
/* Locate tupdesc entry for key column (for attbyval/attlen data) */
- attnum = scanEntry->attnum;
- attr = TupleDescAttr(btree->ginstate->origTupdesc, attnum - 1);
+ attphysnum = scanEntry->attphysnum;
+ attr = TupleDescAttr(btree->ginstate->origTupdesc, attphysnum - 1);
/*
* Predicate lock entry leaf page, following pages will be locked by
@@ -162,7 +162,7 @@ collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack,
/*
* If tuple stores another attribute then stop scan
*/
- if (gintuple_get_attrnum(btree->ginstate, itup) != attnum)
+ if (gintuple_get_attrnum(btree->ginstate, itup) != attphysnum)
return true;
/* Safe to fetch attribute value */
@@ -189,8 +189,8 @@ collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack,
* case cmp < 0 => not match and continue scan
*----------
*/
- cmp = DatumGetInt32(FunctionCall4Coll(&btree->ginstate->comparePartialFn[attnum - 1],
- btree->ginstate->supportCollation[attnum - 1],
+ cmp = DatumGetInt32(FunctionCall4Coll(&btree->ginstate->comparePartialFn[attphysnum - 1],
+ btree->ginstate->supportCollation[attphysnum - 1],
scanEntry->queryKey,
idatum,
UInt16GetDatum(scanEntry->strategy),
@@ -209,7 +209,7 @@ collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack,
/*
* In ALL mode, we are not interested in null items, so we can
* stop if we get to a null-item placeholder (which will be the
- * last entry for a given attnum). We do want to include NULL_KEY
+ * last entry for a given attphysnum). We do want to include NULL_KEY
* and EMPTY_ITEM entries, though.
*/
if (icategory == GIN_CAT_NULL_ITEM)
@@ -274,7 +274,7 @@ collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack,
page = BufferGetPage(stack->buffer);
itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, stack->off));
- if (gintuple_get_attrnum(btree->ginstate, itup) == attnum)
+ if (gintuple_get_attrnum(btree->ginstate, itup) == attphysnum)
{
Datum newDatum;
GinNullCategory newCategory;
@@ -282,7 +282,7 @@ collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack,
newDatum = gintuple_get_key(btree->ginstate, itup,
&newCategory);
- if (ginCompareEntries(btree->ginstate, attnum,
+ if (ginCompareEntries(btree->ginstate, attphysnum,
newDatum, newCategory,
idatum, icategory) == 0)
break; /* Found! */
@@ -299,7 +299,7 @@ collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack,
ItemPointer ipd;
int nipd;
- ipd = ginReadTuple(btree->ginstate, scanEntry->attnum, itup, &nipd);
+ ipd = ginReadTuple(btree->ginstate, scanEntry->attphysnum, itup, &nipd);
tbm_add_tuples(scanEntry->matchBitmap, ipd, nipd, false);
scanEntry->predictNumberResult += GinGetNPosting(itup);
pfree(ipd);
@@ -340,7 +340,7 @@ restartScanEntry:
* we should find entry, and begin scan of posting tree or just store
* posting list in memory
*/
- ginPrepareEntryScan(&btreeEntry, entry->attnum,
+ ginPrepareEntryScan(&btreeEntry, entry->attphysnum,
entry->queryKey, entry->queryCategory,
ginstate);
stackEntry = ginFindLeafPage(&btreeEntry, true, false, snapshot);
@@ -457,7 +457,7 @@ restartScanEntry:
snapshot);
if (GinGetNPosting(itup) > 0)
{
- entry->list = ginReadTuple(ginstate, entry->attnum, itup,
+ entry->list = ginReadTuple(ginstate, entry->attphysnum, itup,
&entry->nlist);
entry->predictNumberResult = entry->nlist;
@@ -1553,7 +1553,7 @@ matchPartialInPendingList(GinState *ginstate, Page page,
{
itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, off));
- if (gintuple_get_attrnum(ginstate, itup) != entry->attnum)
+ if (gintuple_get_attrnum(ginstate, itup) != entry->attphysnum)
return false;
if (datumExtracted[off - 1] == false)
@@ -1574,8 +1574,8 @@ matchPartialInPendingList(GinState *ginstate, Page page,
* case cmp < 0 => not match and continue scan
*----------
*/
- cmp = DatumGetInt32(FunctionCall4Coll(&ginstate->comparePartialFn[entry->attnum - 1],
- ginstate->supportCollation[entry->attnum - 1],
+ cmp = DatumGetInt32(FunctionCall4Coll(&ginstate->comparePartialFn[entry->attphysnum - 1],
+ ginstate->supportCollation[entry->attphysnum - 1],
entry->queryKey,
datum[off - 1],
UInt16GetDatum(entry->strategy),
@@ -1658,7 +1658,7 @@ collectMatchesForHeapRow(IndexScanDesc scan, pendingPosition *pos)
/*
* Interesting tuples are from pos->firstOffset to
- * pos->lastOffset and they are ordered by (attnum, Datum) as
+ * pos->lastOffset and they are ordered by (attphysnum, Datum) as
* it's done in entry tree. So we can use binary search to
* avoid linear scanning.
*/
@@ -1672,12 +1672,12 @@ collectMatchesForHeapRow(IndexScanDesc scan, pendingPosition *pos)
attrnum = gintuple_get_attrnum(&so->ginstate, itup);
- if (key->attnum < attrnum)
+ if (key->attphysnum < attrnum)
{
StopHigh = StopMiddle;
continue;
}
- if (key->attnum > attrnum)
+ if (key->attphysnum > attrnum)
{
StopLow = StopMiddle + 1;
continue;
@@ -1711,7 +1711,7 @@ collectMatchesForHeapRow(IndexScanDesc scan, pendingPosition *pos)
else
{
res = ginCompareEntries(&so->ginstate,
- entry->attnum,
+ entry->attphysnum,
entry->queryKey,
entry->queryCategory,
datum[StopMiddle - 1],
diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c
index ea1c4184fb..a25ee278a5 100644
--- a/src/backend/access/gin/gininsert.c
+++ b/src/backend/access/gin/gininsert.c
@@ -51,7 +51,7 @@ addItemPointersToLeafTuple(GinState *ginstate,
ItemPointerData *items, uint32 nitem,
GinStatsData *buildStats, Buffer buffer)
{
- OffsetNumber attnum;
+ OffsetNumber attphysnum;
Datum key;
GinNullCategory category;
IndexTuple res;
@@ -63,11 +63,11 @@ addItemPointersToLeafTuple(GinState *ginstate,
Assert(!GinIsPostingTree(old));
- attnum = gintuple_get_attrnum(ginstate, old);
+ attphysnum = gintuple_get_attrnum(ginstate, old);
key = gintuple_get_key(ginstate, old, &category);
/* merge the old and new posting lists */
- oldItems = ginReadTuple(ginstate, attnum, old, &oldNPosting);
+ oldItems = ginReadTuple(ginstate, attphysnum, old, &oldNPosting);
newItems = ginMergeItemPointers(items, nitem,
oldItems, oldNPosting,
@@ -80,7 +80,7 @@ addItemPointersToLeafTuple(GinState *ginstate,
pfree(newItems);
if (compressedList)
{
- res = GinFormTuple(ginstate, attnum, key, category,
+ res = GinFormTuple(ginstate, attphysnum, key, category,
(char *) compressedList,
SizeOfGinPostingList(compressedList),
newNPosting,
@@ -109,7 +109,7 @@ addItemPointersToLeafTuple(GinState *ginstate,
buildStats);
/* And build a new posting-tree-only result tuple */
- res = GinFormTuple(ginstate, attnum, key, category, NULL, 0, 0, true);
+ res = GinFormTuple(ginstate, attphysnum, key, category, NULL, 0, 0, true);
GinSetPostingTree(res, postingRoot);
}
pfree(oldItems);
@@ -127,7 +127,7 @@ addItemPointersToLeafTuple(GinState *ginstate,
*/
static IndexTuple
buildFreshLeafTuple(GinState *ginstate,
- OffsetNumber attnum, Datum key, GinNullCategory category,
+ OffsetNumber attphysnum, Datum key, GinNullCategory category,
ItemPointerData *items, uint32 nitem,
GinStatsData *buildStats, Buffer buffer)
{
@@ -138,7 +138,7 @@ buildFreshLeafTuple(GinState *ginstate,
compressedList = ginCompressPostingList(items, nitem, GinMaxItemSize, NULL);
if (compressedList)
{
- res = GinFormTuple(ginstate, attnum, key, category,
+ res = GinFormTuple(ginstate, attphysnum, key, category,
(char *) compressedList,
SizeOfGinPostingList(compressedList),
nitem, false);
@@ -153,7 +153,7 @@ buildFreshLeafTuple(GinState *ginstate,
* Build posting-tree-only result tuple. We do this first so as to
* fail quickly if the key is too big.
*/
- res = GinFormTuple(ginstate, attnum, key, category, NULL, 0, 0, true);
+ res = GinFormTuple(ginstate, attphysnum, key, category, NULL, 0, 0, true);
/*
* Initialize a new posting tree with the TIDs.
@@ -177,7 +177,7 @@ buildFreshLeafTuple(GinState *ginstate,
*/
void
ginEntryInsert(GinState *ginstate,
- OffsetNumber attnum, Datum key, GinNullCategory category,
+ OffsetNumber attphysnum, Datum key, GinNullCategory category,
ItemPointerData *items, uint32 nitem,
GinStatsData *buildStats)
{
@@ -189,7 +189,7 @@ ginEntryInsert(GinState *ginstate,
insertdata.isDelete = false;
- ginPrepareEntryScan(&btree, attnum, key, category, ginstate);
+ ginPrepareEntryScan(&btree, attphysnum, key, category, ginstate);
btree.isBuild = (buildStats != NULL);
stack = ginFindLeafPage(&btree, false, false, NULL);
@@ -229,7 +229,7 @@ ginEntryInsert(GinState *ginstate,
CheckForSerializableConflictIn(ginstate->index, NULL,
BufferGetBlockNumber(stack->buffer));
/* no match, so construct a new leaf entry */
- itup = buildFreshLeafTuple(ginstate, attnum, key, category,
+ itup = buildFreshLeafTuple(ginstate, attphysnum, key, category,
items, nitem, buildStats, stack->buffer);
/*
@@ -253,7 +253,7 @@ ginEntryInsert(GinState *ginstate,
* This function is used only during initial index creation.
*/
static void
-ginHeapTupleBulkInsert(GinBuildState *buildstate, OffsetNumber attnum,
+ginHeapTupleBulkInsert(GinBuildState *buildstate, OffsetNumber attphysnum,
Datum value, bool isNull,
ItemPointer heapptr)
{
@@ -263,12 +263,12 @@ ginHeapTupleBulkInsert(GinBuildState *buildstate, OffsetNumber attnum,
MemoryContext oldCtx;
oldCtx = MemoryContextSwitchTo(buildstate->funcCtx);
- entries = ginExtractEntries(buildstate->accum.ginstate, attnum,
+ entries = ginExtractEntries(buildstate->accum.ginstate, attphysnum,
value, isNull,
&nentries, &categories);
MemoryContextSwitchTo(oldCtx);
- ginInsertBAEntries(&buildstate->accum, heapptr, attnum,
+ ginInsertBAEntries(&buildstate->accum, heapptr, attphysnum,
entries, categories, nentries);
buildstate->indtuples += nentries;
@@ -297,15 +297,15 @@ ginBuildCallback(Relation index, ItemPointer tid, Datum *values,
Datum key;
GinNullCategory category;
uint32 nlist;
- OffsetNumber attnum;
+ OffsetNumber attphysnum;
ginBeginBAScan(&buildstate->accum);
while ((list = ginGetBAEntry(&buildstate->accum,
- &attnum, &key, &category, &nlist)) != NULL)
+ &attphysnum, &key, &category, &nlist)) != NULL)
{
/* there could be many entries, so be willing to abort here */
CHECK_FOR_INTERRUPTS();
- ginEntryInsert(&buildstate->ginstate, attnum, key, category,
+ ginEntryInsert(&buildstate->ginstate, attphysnum, key, category,
list, nlist, &buildstate->buildStats);
}
@@ -329,7 +329,7 @@ ginbuild(Relation heap, Relation index, IndexInfo *indexInfo)
GinNullCategory category;
uint32 nlist;
MemoryContext oldCtx;
- OffsetNumber attnum;
+ OffsetNumber attphysnum;
if (RelationGetNumberOfBlocks(index) != 0)
elog(ERROR, "index \"%s\" already contains data",
@@ -390,11 +390,11 @@ ginbuild(Relation heap, Relation index, IndexInfo *indexInfo)
oldCtx = MemoryContextSwitchTo(buildstate.tmpCtx);
ginBeginBAScan(&buildstate.accum);
while ((list = ginGetBAEntry(&buildstate.accum,
- &attnum, &key, &category, &nlist)) != NULL)
+ &attphysnum, &key, &category, &nlist)) != NULL)
{
/* there could be many entries, so be willing to abort here */
CHECK_FOR_INTERRUPTS();
- ginEntryInsert(&buildstate.ginstate, attnum, key, category,
+ ginEntryInsert(&buildstate.ginstate, attphysnum, key, category,
list, nlist, &buildstate.buildStats);
}
MemoryContextSwitchTo(oldCtx);
@@ -467,7 +467,7 @@ ginbuildempty(Relation index)
* (non-fast-update) insertion
*/
static void
-ginHeapTupleInsert(GinState *ginstate, OffsetNumber attnum,
+ginHeapTupleInsert(GinState *ginstate, OffsetNumber attphysnum,
Datum value, bool isNull,
ItemPointer item)
{
@@ -476,11 +476,11 @@ ginHeapTupleInsert(GinState *ginstate, OffsetNumber attnum,
int32 i,
nentries;
- entries = ginExtractEntries(ginstate, attnum, value, isNull,
+ entries = ginExtractEntries(ginstate, attphysnum, value, isNull,
&nentries, &categories);
for (i = 0; i < nentries; i++)
- ginEntryInsert(ginstate, attnum, entries[i], categories[i],
+ ginEntryInsert(ginstate, attphysnum, entries[i], categories[i],
item, 1, NULL);
}
diff --git a/src/backend/access/gin/ginlogic.c b/src/backend/access/gin/ginlogic.c
index c38c27fbae..442c338631 100644
--- a/src/backend/access/gin/ginlogic.c
+++ b/src/backend/access/gin/ginlogic.c
@@ -229,16 +229,16 @@ ginInitConsistentFunction(GinState *ginstate, GinScanKey key)
}
else
{
- key->consistentFmgrInfo = &ginstate->consistentFn[key->attnum - 1];
- key->triConsistentFmgrInfo = &ginstate->triConsistentFn[key->attnum - 1];
- key->collation = ginstate->supportCollation[key->attnum - 1];
+ key->consistentFmgrInfo = &ginstate->consistentFn[key->attphysnum - 1];
+ key->triConsistentFmgrInfo = &ginstate->triConsistentFn[key->attphysnum - 1];
+ key->collation = ginstate->supportCollation[key->attphysnum - 1];
- if (OidIsValid(ginstate->consistentFn[key->attnum - 1].fn_oid))
+ if (OidIsValid(ginstate->consistentFn[key->attphysnum - 1].fn_oid))
key->boolConsistentFn = directBoolConsistentFn;
else
key->boolConsistentFn = shimBoolConsistentFn;
- if (OidIsValid(ginstate->triConsistentFn[key->attnum - 1].fn_oid))
+ if (OidIsValid(ginstate->triConsistentFn[key->attphysnum - 1].fn_oid))
key->triConsistentFn = directTriConsistentFn;
else
key->triConsistentFn = shimTriConsistentFn;
diff --git a/src/backend/access/gin/ginscan.c b/src/backend/access/gin/ginscan.c
index b776d04459..8bf5cfe7f7 100644
--- a/src/backend/access/gin/ginscan.c
+++ b/src/backend/access/gin/ginscan.c
@@ -54,7 +54,7 @@ ginbeginscan(Relation rel, int nkeys, int norderbys)
* in which case just return it
*/
static GinScanEntry
-ginFillScanEntry(GinScanOpaque so, OffsetNumber attnum,
+ginFillScanEntry(GinScanOpaque so, OffsetNumber attphysnum,
StrategyNumber strategy, int32 searchMode,
Datum queryKey, GinNullCategory queryCategory,
bool isPartialMatch, Pointer extra_data)
@@ -79,8 +79,8 @@ ginFillScanEntry(GinScanOpaque so, OffsetNumber attnum,
prevEntry->isPartialMatch == isPartialMatch &&
prevEntry->strategy == strategy &&
prevEntry->searchMode == searchMode &&
- prevEntry->attnum == attnum &&
- ginCompareEntries(ginstate, attnum,
+ prevEntry->attphysnum == attphysnum &&
+ ginCompareEntries(ginstate, attphysnum,
prevEntry->queryKey,
prevEntry->queryCategory,
queryKey,
@@ -100,7 +100,7 @@ ginFillScanEntry(GinScanOpaque so, OffsetNumber attnum,
scanEntry->extra_data = extra_data;
scanEntry->strategy = strategy;
scanEntry->searchMode = searchMode;
- scanEntry->attnum = attnum;
+ scanEntry->attphysnum = attphysnum;
scanEntry->buffer = InvalidBuffer;
ItemPointerSetMin(&scanEntry->curItem);
@@ -140,7 +140,7 @@ ginScanKeyAddHiddenEntry(GinScanOpaque so, GinScanKey key,
int i = key->nentries++;
/* strategy is of no interest because this is not a partial-match item */
- key->scanEntry[i] = ginFillScanEntry(so, key->attnum,
+ key->scanEntry[i] = ginFillScanEntry(so, key->attphysnum,
InvalidStrategy, key->searchMode,
(Datum) 0, queryCategory,
false, NULL);
@@ -150,7 +150,7 @@ ginScanKeyAddHiddenEntry(GinScanOpaque so, GinScanKey key,
* Initialize the next GinScanKey using the output from the extractQueryFn
*/
static void
-ginFillScanKey(GinScanOpaque so, OffsetNumber attnum,
+ginFillScanKey(GinScanOpaque so, OffsetNumber attphysnum,
StrategyNumber strategy, int32 searchMode,
Datum query, uint32 nQueryValues,
Datum *queryValues, GinNullCategory *queryCategories,
@@ -175,7 +175,7 @@ ginFillScanKey(GinScanOpaque so, OffsetNumber attnum,
key->extra_data = extra_data;
key->strategy = strategy;
key->searchMode = searchMode;
- key->attnum = attnum;
+ key->attphysnum = attphysnum;
/*
* Initially, scan keys of GIN_SEARCH_MODE_ALL mode are marked
@@ -205,11 +205,11 @@ ginFillScanKey(GinScanOpaque so, OffsetNumber attnum,
queryKey = queryValues[i];
queryCategory = queryCategories[i];
isPartialMatch =
- (ginstate->canPartialMatch[attnum - 1] && partial_matches)
+ (ginstate->canPartialMatch[attphysnum - 1] && partial_matches)
? partial_matches[i] : false;
this_extra = (extra_data) ? extra_data[i] : NULL;
- key->scanEntry[i] = ginFillScanEntry(so, attnum,
+ key->scanEntry[i] = ginFillScanEntry(so, attphysnum,
strategy, searchMode,
queryKey, queryCategory,
isPartialMatch, this_extra);
@@ -394,11 +394,11 @@ ginNewScanKey(IndexScanDesc scan)
if (key->searchMode != GIN_SEARCH_MODE_ALL)
continue;
- if (!attrHasNormalScan[key->attnum - 1])
+ if (!attrHasNormalScan[key->attphysnum - 1])
{
key->excludeOnly = false;
ginScanKeyAddHiddenEntry(so, key, GIN_CAT_EMPTY_QUERY);
- attrHasNormalScan[key->attnum - 1] = true;
+ attrHasNormalScan[key->attphysnum - 1] = true;
}
}
diff --git a/src/backend/access/gin/ginutil.c b/src/backend/access/gin/ginutil.c
index 20f470648b..caca0c4de4 100644
--- a/src/backend/access/gin/ginutil.c
+++ b/src/backend/access/gin/ginutil.c
@@ -391,7 +391,7 @@ GinInitMetabuffer(Buffer b)
* Compare two keys of the same index column
*/
int
-ginCompareEntries(GinState *ginstate, OffsetNumber attnum,
+ginCompareEntries(GinState *ginstate, OffsetNumber attphysnum,
Datum a, GinNullCategory categorya,
Datum b, GinNullCategory categoryb)
{
@@ -404,8 +404,8 @@ ginCompareEntries(GinState *ginstate, OffsetNumber attnum,
return 0;
/* both not null, so safe to call the compareFn */
- return DatumGetInt32(FunctionCall2Coll(&ginstate->compareFn[attnum - 1],
- ginstate->supportCollation[attnum - 1],
+ return DatumGetInt32(FunctionCall2Coll(&ginstate->compareFn[attphysnum - 1],
+ ginstate->supportCollation[attphysnum - 1],
a, b));
}
@@ -486,7 +486,7 @@ cmpEntries(const void *a, const void *b, void *arg)
* This avoids generating redundant index entries.
*/
Datum *
-ginExtractEntries(GinState *ginstate, OffsetNumber attnum,
+ginExtractEntries(GinState *ginstate, OffsetNumber attphysnum,
Datum value, bool isNull,
int32 *nentries, GinNullCategory **categories)
{
@@ -511,8 +511,8 @@ ginExtractEntries(GinState *ginstate, OffsetNumber attnum,
/* OK, call the opclass's extractValueFn */
nullFlags = NULL; /* in case extractValue doesn't set it */
entries = (Datum *)
- DatumGetPointer(FunctionCall3Coll(&ginstate->extractValueFn[attnum - 1],
- ginstate->supportCollation[attnum - 1],
+ DatumGetPointer(FunctionCall3Coll(&ginstate->extractValueFn[attphysnum - 1],
+ ginstate->supportCollation[attphysnum - 1],
value,
PointerGetDatum(nentries),
PointerGetDatum(&nullFlags)));
@@ -556,8 +556,8 @@ ginExtractEntries(GinState *ginstate, OffsetNumber attnum,
keydata[i].isnull = nullFlags[i];
}
- arg.cmpDatumFunc = &ginstate->compareFn[attnum - 1];
- arg.collation = ginstate->supportCollation[attnum - 1];
+ arg.cmpDatumFunc = &ginstate->compareFn[attphysnum - 1];
+ arg.collation = ginstate->supportCollation[attphysnum - 1];
arg.haveDups = false;
qsort_arg(keydata, *nentries, sizeof(keyEntryData),
cmpEntries, (void *) &arg);
diff --git a/src/backend/access/gin/ginvacuum.c b/src/backend/access/gin/ginvacuum.c
index b4fa5f6bf8..67293adee3 100644
--- a/src/backend/access/gin/ginvacuum.c
+++ b/src/backend/access/gin/ginvacuum.c
@@ -506,7 +506,7 @@ ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint3
/* If any item pointers were removed, recreate the tuple. */
if (items)
{
- OffsetNumber attnum;
+ OffsetNumber attphysnum;
Datum key;
GinNullCategory category;
GinPostingList *plist;
@@ -539,9 +539,9 @@ ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint3
itup = (IndexTuple) PageGetItem(tmppage, PageGetItemId(tmppage, i));
}
- attnum = gintuple_get_attrnum(&gvs->ginstate, itup);
+ attphysnum = gintuple_get_attrnum(&gvs->ginstate, itup);
key = gintuple_get_key(&gvs->ginstate, itup, &category);
- itup = GinFormTuple(&gvs->ginstate, attnum, key, category,
+ itup = GinFormTuple(&gvs->ginstate, attphysnum, key, category,
(char *) plist, plistsize,
nitems, true);
if (plist)
diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c
index 98af5347b9..46cce23c46 100644
--- a/src/backend/access/index/genam.c
+++ b/src/backend/access/index/genam.c
@@ -216,16 +216,16 @@ BuildIndexValueDescription(Relation indexRelation,
*/
for (keyno = 0; keyno < indnkeyatts; keyno++)
{
- AttrNumber attnum = idxrec->indkey.values[keyno];
+ AttrNumber attphysnum = idxrec->indkey.values[keyno];
/*
- * Note that if attnum == InvalidAttrNumber, then this is an index
+ * Note that if attphysnum == InvalidAttrNumber, then this is an index
* based on an expression and we return no detail rather than try
* to figure out what column(s) the expression includes and if the
* user has SELECT rights on them.
*/
- if (attnum == InvalidAttrNumber ||
- pg_attribute_aclcheck(indrelid, attnum, GetUserId(),
+ if (attphysnum == InvalidAttrNumber ||
+ pg_attribute_aclcheck(indrelid, attphysnum, GetUserId(),
ACL_SELECT) != ACLCHECK_OK)
{
/* No access, so clean up and return */
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
index fe80b8b0ba..e6e8ddafea 100644
--- a/src/backend/access/index/indexam.c
+++ b/src/backend/access/index/indexam.c
@@ -767,7 +767,7 @@ index_can_return(Relation indexRelation, int attno)
*/
RegProcedure
index_getprocid(Relation irel,
- AttrNumber attnum,
+ AttrNumber attphysnum,
uint16 procnum)
{
RegProcedure *loc;
@@ -778,7 +778,7 @@ index_getprocid(Relation irel,
Assert(procnum > 0 && procnum <= (uint16) nproc);
- procindex = (nproc * (attnum - 1)) + (procnum - 1);
+ procindex = (nproc * (attphysnum - 1)) + (procnum - 1);
loc = irel->rd_support;
@@ -801,7 +801,7 @@ index_getprocid(Relation irel,
*/
FmgrInfo *
index_getprocinfo(Relation irel,
- AttrNumber attnum,
+ AttrNumber attphysnum,
uint16 procnum)
{
FmgrInfo *locinfo;
@@ -814,7 +814,7 @@ index_getprocinfo(Relation irel,
Assert(procnum > 0 && procnum <= (uint16) nproc);
- procindex = (nproc * (attnum - 1)) + (procnum - 1);
+ procindex = (nproc * (attphysnum - 1)) + (procnum - 1);
locinfo = irel->rd_supportinfo;
@@ -840,7 +840,7 @@ index_getprocinfo(Relation irel,
*/
if (!RegProcedureIsValid(procId))
elog(ERROR, "missing support function %d for attribute %d of index \"%s\"",
- procnum, attnum, RelationGetRelationName(irel));
+ procnum, attphysnum, RelationGetRelationName(irel));
fmgr_info_cxt(procId, locinfo, irel->rd_indexcxt);
@@ -850,7 +850,7 @@ index_getprocinfo(Relation irel,
bytea **attoptions = RelationGetIndexAttOptions(irel, false);
MemoryContext oldcxt = MemoryContextSwitchTo(irel->rd_indexcxt);
- set_fn_opclass_options(locinfo, attoptions[attnum - 1]);
+ set_fn_opclass_options(locinfo, attoptions[attphysnum - 1]);
MemoryContextSwitchTo(oldcxt);
}
@@ -936,7 +936,7 @@ index_store_float8_orderby_distances(IndexScanDesc scan, Oid *orderByTypes,
* ----------------
*/
bytea *
-index_opclass_options(Relation indrel, AttrNumber attnum, Datum attoptions,
+index_opclass_options(Relation indrel, AttrNumber attphysnum, Datum attoptions,
bool validate)
{
int amoptsprocnum = indrel->rd_indam->amoptsprocnum;
@@ -946,7 +946,7 @@ index_opclass_options(Relation indrel, AttrNumber attnum, Datum attoptions,
/* fetch options support procedure if specified */
if (amoptsprocnum != 0)
- procid = index_getprocid(indrel, attnum, amoptsprocnum);
+ procid = index_getprocid(indrel, attphysnum, amoptsprocnum);
if (!OidIsValid(procid))
{
@@ -966,7 +966,7 @@ index_opclass_options(Relation indrel, AttrNumber attnum, Datum attoptions,
Anum_pg_index_indclass, &isnull);
Assert(!isnull);
indclass = (oidvector *) DatumGetPointer(indclassDatum);
- opclass = indclass->values[attnum - 1];
+ opclass = indclass->values[attphysnum - 1];
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@@ -976,7 +976,7 @@ index_opclass_options(Relation indrel, AttrNumber attnum, Datum attoptions,
init_local_reloptions(&relopts, 0);
- procinfo = index_getprocinfo(indrel, attnum, amoptsprocnum);
+ procinfo = index_getprocinfo(indrel, attphysnum, amoptsprocnum);
(void) FunctionCall1(procinfo, PointerGetDatum(&relopts));
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c
index ff260c393a..9c5f50f84f 100644
--- a/src/backend/access/nbtree/nbtutils.c
+++ b/src/backend/access/nbtree/nbtutils.c
@@ -2365,15 +2365,15 @@ _bt_keep_natts(Relation rel, IndexTuple lastleft, IndexTuple firstright,
scankey = itup_key->scankeys;
keepnatts = 1;
- for (int attnum = 1; attnum <= nkeyatts; attnum++, scankey++)
+ for (int attphysnum = 1; attphysnum <= nkeyatts; attphysnum++, scankey++)
{
Datum datum1,
datum2;
bool isNull1,
isNull2;
- datum1 = index_getattr(lastleft, attnum, itupdesc, &isNull1);
- datum2 = index_getattr(firstright, attnum, itupdesc, &isNull2);
+ datum1 = index_getattr(lastleft, attphysnum, itupdesc, &isNull1);
+ datum2 = index_getattr(firstright, attphysnum, itupdesc, &isNull2);
if (isNull1 != isNull2)
break;
@@ -2428,7 +2428,7 @@ _bt_keep_natts_fast(Relation rel, IndexTuple lastleft, IndexTuple firstright)
int keepnatts;
keepnatts = 1;
- for (int attnum = 1; attnum <= keysz; attnum++)
+ for (int attphysnum = 1; attphysnum <= keysz; attphysnum++)
{
Datum datum1,
datum2;
@@ -2436,9 +2436,9 @@ _bt_keep_natts_fast(Relation rel, IndexTuple lastleft, IndexTuple firstright)
isNull2;
Form_pg_attribute att;
- datum1 = index_getattr(lastleft, attnum, itupdesc, &isNull1);
- datum2 = index_getattr(firstright, attnum, itupdesc, &isNull2);
- att = TupleDescAttr(itupdesc, attnum - 1);
+ datum1 = index_getattr(lastleft, attphysnum, itupdesc, &isNull1);
+ datum2 = index_getattr(firstright, attphysnum, itupdesc, &isNull2);
+ att = TupleDescAttr(itupdesc, attphysnum - 1);
if (isNull1 != isNull2)
break;
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 9a610d41ad..37107dc12b 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -453,7 +453,7 @@ boot_openrel(char *relname)
Form_pg_attribute at = attrtypes[i];
elog(DEBUG4, "create attribute %d name %s len %d num %d type %u",
- i, NameStr(at->attname), at->attlen, at->attnum,
+ i, NameStr(at->attname), at->attlen, at->attphysnum,
at->atttypid);
}
}
@@ -501,7 +501,7 @@ closerel(char *name)
* ----------------
*/
void
-DefineAttr(char *name, char *type, int attnum, int nullness)
+DefineAttr(char *name, char *type, int attphysnum, int nullness)
{
Oid typeoid;
@@ -511,46 +511,46 @@ DefineAttr(char *name, char *type, int attnum, int nullness)
closerel(NULL);
}
- if (attrtypes[attnum] == NULL)
- attrtypes[attnum] = AllocateAttribute();
- MemSet(attrtypes[attnum], 0, ATTRIBUTE_FIXED_PART_SIZE);
+ if (attrtypes[attphysnum] == NULL)
+ attrtypes[attphysnum] = AllocateAttribute();
+ MemSet(attrtypes[attphysnum], 0, ATTRIBUTE_FIXED_PART_SIZE);
- namestrcpy(&attrtypes[attnum]->attname, name);
- elog(DEBUG4, "column %s %s", NameStr(attrtypes[attnum]->attname), type);
- attrtypes[attnum]->attnum = attnum + 1;
+ namestrcpy(&attrtypes[attphysnum]->attname, name);
+ elog(DEBUG4, "column %s %s", NameStr(attrtypes[attphysnum]->attname), type);
+ attrtypes[attphysnum]->attphysnum = attphysnum + 1;
typeoid = gettype(type);
if (Typ != NIL)
{
- attrtypes[attnum]->atttypid = Ap->am_oid;
- attrtypes[attnum]->attlen = Ap->am_typ.typlen;
- attrtypes[attnum]->attbyval = Ap->am_typ.typbyval;
- attrtypes[attnum]->attalign = Ap->am_typ.typalign;
- attrtypes[attnum]->attstorage = Ap->am_typ.typstorage;
- attrtypes[attnum]->attcompression = InvalidCompressionMethod;
- attrtypes[attnum]->attcollation = Ap->am_typ.typcollation;
+ attrtypes[attphysnum]->atttypid = Ap->am_oid;
+ attrtypes[attphysnum]->attlen = Ap->am_typ.typlen;
+ attrtypes[attphysnum]->attbyval = Ap->am_typ.typbyval;
+ attrtypes[attphysnum]->attalign = Ap->am_typ.typalign;
+ attrtypes[attphysnum]->attstorage = Ap->am_typ.typstorage;
+ attrtypes[attphysnum]->attcompression = InvalidCompressionMethod;
+ attrtypes[attphysnum]->attcollation = Ap->am_typ.typcollation;
/* if an array type, assume 1-dimensional attribute */
if (Ap->am_typ.typelem != InvalidOid && Ap->am_typ.typlen < 0)
- attrtypes[attnum]->attndims = 1;
+ attrtypes[attphysnum]->attndims = 1;
else
- attrtypes[attnum]->attndims = 0;
+ attrtypes[attphysnum]->attndims = 0;
}
else
{
- attrtypes[attnum]->atttypid = TypInfo[typeoid].oid;
- attrtypes[attnum]->attlen = TypInfo[typeoid].len;
- attrtypes[attnum]->attbyval = TypInfo[typeoid].byval;
- attrtypes[attnum]->attalign = TypInfo[typeoid].align;
- attrtypes[attnum]->attstorage = TypInfo[typeoid].storage;
- attrtypes[attnum]->attcompression = InvalidCompressionMethod;
- attrtypes[attnum]->attcollation = TypInfo[typeoid].collation;
+ attrtypes[attphysnum]->atttypid = TypInfo[typeoid].oid;
+ attrtypes[attphysnum]->attlen = TypInfo[typeoid].len;
+ attrtypes[attphysnum]->attbyval = TypInfo[typeoid].byval;
+ attrtypes[attphysnum]->attalign = TypInfo[typeoid].align;
+ attrtypes[attphysnum]->attstorage = TypInfo[typeoid].storage;
+ attrtypes[attphysnum]->attcompression = InvalidCompressionMethod;
+ attrtypes[attphysnum]->attcollation = TypInfo[typeoid].collation;
/* if an array type, assume 1-dimensional attribute */
if (TypInfo[typeoid].elem != InvalidOid &&
- attrtypes[attnum]->attlen < 0)
- attrtypes[attnum]->attndims = 1;
+ attrtypes[attphysnum]->attlen < 0)
+ attrtypes[attphysnum]->attndims = 1;
else
- attrtypes[attnum]->attndims = 0;
+ attrtypes[attphysnum]->attndims = 0;
}
/*
@@ -559,21 +559,21 @@ DefineAttr(char *name, char *type, int attnum, int nullness)
* collation. This is essential to allow template0 to be cloned with a
* different database collation.
*/
- if (OidIsValid(attrtypes[attnum]->attcollation))
- attrtypes[attnum]->attcollation = C_COLLATION_OID;
+ if (OidIsValid(attrtypes[attphysnum]->attcollation))
+ attrtypes[attphysnum]->attcollation = C_COLLATION_OID;
- attrtypes[attnum]->attstattarget = -1;
- attrtypes[attnum]->attcacheoff = -1;
- attrtypes[attnum]->atttypmod = -1;
- attrtypes[attnum]->attislocal = true;
+ attrtypes[attphysnum]->attstattarget = -1;
+ attrtypes[attphysnum]->attcacheoff = -1;
+ attrtypes[attphysnum]->atttypmod = -1;
+ attrtypes[attphysnum]->attislocal = true;
if (nullness == BOOTCOL_NULL_FORCE_NOT_NULL)
{
- attrtypes[attnum]->attnotnull = true;
+ attrtypes[attphysnum]->attnotnull = true;
}
else if (nullness == BOOTCOL_NULL_FORCE_NULL)
{
- attrtypes[attnum]->attnotnull = false;
+ attrtypes[attphysnum]->attnotnull = false;
}
else
{
@@ -584,19 +584,19 @@ DefineAttr(char *name, char *type, int attnum, int nullness)
* likewise fixed-width and not-null. This corresponds to case where
* column can be accessed directly via C struct declaration.
*/
- if (attrtypes[attnum]->attlen > 0)
+ if (attrtypes[attphysnum]->attlen > 0)
{
int i;
/* check earlier attributes */
- for (i = 0; i < attnum; i++)
+ for (i = 0; i < attphysnum; i++)
{
if (attrtypes[i]->attlen <= 0 ||
!attrtypes[i]->attnotnull)
break;
}
- if (i == attnum)
- attrtypes[attnum]->attnotnull = true;
+ if (i == attphysnum)
+ attrtypes[attphysnum]->attnotnull = true;
}
}
}
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index 5f1726c095..3f5cbebcbc 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -137,7 +137,7 @@ static AclMode restrict_and_check_grant(bool is_grant, AclMode avail_goptions,
Oid objectId, Oid grantorId,
ObjectType objtype, const char *objname,
AttrNumber att_number, const char *colname);
-static AclMode pg_aclmask(ObjectType objtype, Oid table_oid, AttrNumber attnum,
+static AclMode pg_aclmask(ObjectType objtype, Oid table_oid, AttrNumber attphysnum,
Oid roleid, AclMode mask, AclMaskHow how);
static void recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid,
Acl *new_acl);
@@ -1578,18 +1578,18 @@ expand_col_privileges(List *colnames, Oid table_oid,
foreach(cell, colnames)
{
char *colname = strVal(lfirst(cell));
- AttrNumber attnum;
+ AttrNumber attphysnum;
- attnum = get_attnum(table_oid, colname);
- if (attnum == InvalidAttrNumber)
+ attphysnum = get_attphysnum(table_oid, colname);
+ if (attphysnum == InvalidAttrNumber)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colname, get_rel_name(table_oid))));
- attnum -= FirstLowInvalidHeapAttributeNumber;
- if (attnum <= 0 || attnum >= num_col_privileges)
+ attphysnum -= FirstLowInvalidHeapAttributeNumber;
+ if (attphysnum <= 0 || attphysnum >= num_col_privileges)
elog(ERROR, "column number out of range"); /* safety check */
- col_privileges[attnum] |= this_privileges;
+ col_privileges[attphysnum] |= this_privileges;
}
}
@@ -1623,7 +1623,7 @@ expand_all_col_privileges(Oid table_oid, Form_pg_class classForm,
if (classForm->relkind == RELKIND_VIEW && curr_att < 0)
continue;
- attTuple = SearchSysCache2(ATTNUM,
+ attTuple = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(table_oid),
Int16GetDatum(curr_att));
if (!HeapTupleIsValid(attTuple))
@@ -1648,7 +1648,7 @@ expand_all_col_privileges(Oid table_oid, Form_pg_class classForm,
*/
static void
ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname,
- AttrNumber attnum, Oid ownerId, AclMode col_privileges,
+ AttrNumber attphysnum, Oid ownerId, AclMode col_privileges,
Relation attRelation, const Acl *old_rel_acl)
{
HeapTuple attr_tuple;
@@ -1670,20 +1670,20 @@ ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname,
Oid *oldmembers;
Oid *newmembers;
- attr_tuple = SearchSysCache2(ATTNUM,
+ attr_tuple = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(relOid),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (!HeapTupleIsValid(attr_tuple))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
- attnum, relOid);
+ attphysnum, relOid);
pg_attribute_tuple = (Form_pg_attribute) GETSTRUCT(attr_tuple);
/*
* Get working copy of existing ACL. If there's no ACL, substitute the
* proper default.
*/
- aclDatum = SysCacheGetAttr(ATTNUM, attr_tuple, Anum_pg_attribute_attacl,
- &isNull);
+ aclDatum = SysCacheGetAttr(ATTPHYSNUM, attr_tuple,
+ Anum_pg_attribute_attacl, &isNull);
if (isNull)
{
old_acl = acldefault(OBJECT_COLUMN, ownerId);
@@ -1726,7 +1726,7 @@ ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname,
(col_privileges == ACL_ALL_RIGHTS_COLUMN),
col_privileges,
relOid, grantorId, OBJECT_COLUMN,
- relname, attnum,
+ relname, attphysnum,
NameStr(pg_attribute_tuple->attname));
/*
@@ -1776,11 +1776,11 @@ ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname,
CatalogTupleUpdate(attRelation, &newtuple->t_self, newtuple);
/* Update initial privileges for extensions */
- recordExtensionInitPriv(relOid, RelationRelationId, attnum,
+ recordExtensionInitPriv(relOid, RelationRelationId, attphysnum,
ACL_NUM(new_acl) > 0 ? new_acl : NULL);
/* Update the shared dependency ACL info */
- updateAclDependencies(RelationRelationId, relOid, attnum,
+ updateAclDependencies(RelationRelationId, relOid, attphysnum,
ownerId,
noldmembers, oldmembers,
nnewmembers, newmembers);
@@ -3840,7 +3840,7 @@ aclcheck_error_type(AclResult aclerr, Oid typeOid)
* Relay for the various pg_*_mask routines depending on object kind
*/
static AclMode
-pg_aclmask(ObjectType objtype, Oid table_oid, AttrNumber attnum, Oid roleid,
+pg_aclmask(ObjectType objtype, Oid table_oid, AttrNumber attphysnum, Oid roleid,
AclMode mask, AclMaskHow how)
{
switch (objtype)
@@ -3848,7 +3848,7 @@ pg_aclmask(ObjectType objtype, Oid table_oid, AttrNumber attnum, Oid roleid,
case OBJECT_COLUMN:
return
pg_class_aclmask(table_oid, roleid, mask, how) |
- pg_attribute_aclmask(table_oid, attnum, roleid, mask, how);
+ pg_attribute_aclmask(table_oid, attphysnum, roleid, mask, how);
case OBJECT_TABLE:
case OBJECT_SEQUENCE:
return pg_class_aclmask(table_oid, roleid, mask, how);
@@ -3910,10 +3910,10 @@ pg_aclmask(ObjectType objtype, Oid table_oid, AttrNumber attnum, Oid roleid,
* superuser-ness here.)
*/
AclMode
-pg_attribute_aclmask(Oid table_oid, AttrNumber attnum, Oid roleid,
+pg_attribute_aclmask(Oid table_oid, AttrNumber attphysnum, Oid roleid,
AclMode mask, AclMaskHow how)
{
- return pg_attribute_aclmask_ext(table_oid, attnum, roleid,
+ return pg_attribute_aclmask_ext(table_oid, attphysnum, roleid,
mask, how, NULL);
}
@@ -3924,7 +3924,7 @@ pg_attribute_aclmask(Oid table_oid, AttrNumber attnum, Oid roleid,
* callers to avoid the missing attribute ERROR when is_missing is non-NULL.
*/
AclMode
-pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
+pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attphysnum, Oid roleid,
AclMode mask, AclMaskHow how, bool *is_missing)
{
AclMode result;
@@ -3940,9 +3940,9 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
/*
* First, get the column's ACL from its pg_attribute entry
*/
- attTuple = SearchSysCache2(ATTNUM,
+ attTuple = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(table_oid),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (!HeapTupleIsValid(attTuple))
{
if (is_missing != NULL)
@@ -3955,7 +3955,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("attribute %d of relation with OID %u does not exist",
- attnum, table_oid)));
+ attphysnum, table_oid)));
}
attributeForm = (Form_pg_attribute) GETSTRUCT(attTuple);
@@ -3974,10 +3974,10 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("attribute %d of relation with OID %u does not exist",
- attnum, table_oid)));
+ attphysnum, table_oid)));
}
- aclDatum = SysCacheGetAttr(ATTNUM, attTuple, Anum_pg_attribute_attacl,
+ aclDatum = SysCacheGetAttr(ATTPHYSNUM, attTuple, Anum_pg_attribute_attacl,
&isNull);
/*
@@ -4875,10 +4875,10 @@ pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how)
* column are considered here.
*/
AclResult
-pg_attribute_aclcheck(Oid table_oid, AttrNumber attnum,
+pg_attribute_aclcheck(Oid table_oid, AttrNumber attphysnum,
Oid roleid, AclMode mode)
{
- return pg_attribute_aclcheck_ext(table_oid, attnum, roleid, mode, NULL);
+ return pg_attribute_aclcheck_ext(table_oid, attphysnum, roleid, mode, NULL);
}
@@ -4889,10 +4889,10 @@ pg_attribute_aclcheck(Oid table_oid, AttrNumber attnum,
* callers to avoid the missing attribute ERROR when is_missing is non-NULL.
*/
AclResult
-pg_attribute_aclcheck_ext(Oid table_oid, AttrNumber attnum,
+pg_attribute_aclcheck_ext(Oid table_oid, AttrNumber attphysnum,
Oid roleid, AclMode mode, bool *is_missing)
{
- if (pg_attribute_aclmask_ext(table_oid, attnum, roleid, mode,
+ if (pg_attribute_aclmask_ext(table_oid, attphysnum, roleid, mode,
ACLMASK_ANY, is_missing) != 0)
return ACLCHECK_OK;
else
@@ -4953,7 +4953,7 @@ pg_attribute_aclcheck_all(Oid table_oid, Oid roleid, AclMode mode,
HeapTuple attTuple;
AclMode attmask;
- attTuple = SearchSysCache2(ATTNUM,
+ attTuple = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(table_oid),
Int16GetDatum(curr_att));
if (!HeapTupleIsValid(attTuple))
@@ -6025,7 +6025,7 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
HeapTuple attTuple;
Datum attaclDatum;
- attTuple = SearchSysCache2(ATTNUM,
+ attTuple = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(objoid),
Int16GetDatum(curr_att));
@@ -6039,7 +6039,7 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
continue;
}
- attaclDatum = SysCacheGetAttr(ATTNUM, attTuple,
+ attaclDatum = SysCacheGetAttr(ATTPHYSNUM, attTuple,
Anum_pg_attribute_attacl,
&isNull);
@@ -6318,7 +6318,7 @@ removeExtObjInitPriv(Oid objoid, Oid classoid)
{
HeapTuple attTuple;
- attTuple = SearchSysCache2(ATTNUM,
+ attTuple = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(objoid),
Int16GetDatum(curr_att));
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index e784538aae..44b4b03cac 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -628,7 +628,7 @@ pg_nextoid(PG_FUNCTION_ARGS)
NameStr(*attname), RelationGetRelationName(rel))));
attform = ((Form_pg_attribute) GETSTRUCT(atttuple));
- attno = attform->attnum;
+ attno = attform->attphysnum;
if (attform->atttypid != OIDOID)
ereport(ERROR,
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index 17b2c5e3f3..f1d33dd949 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -508,10 +508,10 @@ EOM
print $bki "\n (\n";
my $schema = $catalog->{columns};
my %attnames;
- my $attnum = 0;
+ my $attphysnum = 0;
foreach my $column (@$schema)
{
- $attnum++;
+ $attphysnum++;
my $attname = $column->{name};
my $atttype = $column->{type};
@@ -537,12 +537,12 @@ EOM
}
# Emit Anum_* constants
- printf $def "#define Anum_%s_%s %s\n", $catname, $attname, $attnum;
+ printf $def "#define Anum_%s_%s %s\n", $catname, $attname, $attphysnum;
}
print $bki "\n )\n";
# Emit Natts_* constant
- print $def "\n#define Natts_$catname $attnum\n\n";
+ print $def "\n#define Natts_$catname $attphysnum\n\n";
# Emit client code copied from source header
foreach my $line (@{ $catalog->{client_code} })
@@ -845,13 +845,13 @@ sub gen_pg_attribute
push @tables_needing_macros, $table_name;
# Generate entries for user attributes.
- my $attnum = 0;
+ my $attphysnum = 0;
my $priorfixedwidth = 1;
foreach my $attr (@{ $table->{columns} })
{
- $attnum++;
+ $attphysnum++;
my %row;
- $row{attnum} = $attnum;
+ $row{attphysnum} = $attphysnum;
$row{attrelid} = $table->{relation_oid};
morph_row_for_pgattr(\%row, $schema, $attr, $priorfixedwidth);
@@ -875,7 +875,7 @@ sub gen_pg_attribute
# We only need postgres.bki entries, not schemapg.h entries.
if ($table->{bootstrap})
{
- $attnum = 0;
+ $attphysnum = 0;
my @SYS_ATTRS = (
{ name => 'ctid', type => 'tid' },
{ name => 'xmin', type => 'xid' },
@@ -885,9 +885,9 @@ sub gen_pg_attribute
{ name => 'tableoid', type => 'oid' });
foreach my $attr (@SYS_ATTRS)
{
- $attnum--;
+ $attphysnum--;
my %row;
- $row{attnum} = $attnum;
+ $row{attphysnum} = $attphysnum;
$row{attrelid} = $table->{relation_oid};
$row{attstattarget} = '0';
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 1803194db9..ed9929e67a 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -142,7 +142,7 @@ static const FormData_pg_attribute a1 = {
.attname = {"ctid"},
.atttypid = TIDOID,
.attlen = sizeof(ItemPointerData),
- .attnum = SelfItemPointerAttributeNumber,
+ .attphysnum = SelfItemPointerAttributeNumber,
.attcacheoff = -1,
.atttypmod = -1,
.attbyval = false,
@@ -156,7 +156,7 @@ static const FormData_pg_attribute a2 = {
.attname = {"xmin"},
.atttypid = XIDOID,
.attlen = sizeof(TransactionId),
- .attnum = MinTransactionIdAttributeNumber,
+ .attphysnum = MinTransactionIdAttributeNumber,
.attcacheoff = -1,
.atttypmod = -1,
.attbyval = true,
@@ -170,7 +170,7 @@ static const FormData_pg_attribute a3 = {
.attname = {"cmin"},
.atttypid = CIDOID,
.attlen = sizeof(CommandId),
- .attnum = MinCommandIdAttributeNumber,
+ .attphysnum = MinCommandIdAttributeNumber,
.attcacheoff = -1,
.atttypmod = -1,
.attbyval = true,
@@ -184,7 +184,7 @@ static const FormData_pg_attribute a4 = {
.attname = {"xmax"},
.atttypid = XIDOID,
.attlen = sizeof(TransactionId),
- .attnum = MaxTransactionIdAttributeNumber,
+ .attphysnum = MaxTransactionIdAttributeNumber,
.attcacheoff = -1,
.atttypmod = -1,
.attbyval = true,
@@ -198,7 +198,7 @@ static const FormData_pg_attribute a5 = {
.attname = {"cmax"},
.atttypid = CIDOID,
.attlen = sizeof(CommandId),
- .attnum = MaxCommandIdAttributeNumber,
+ .attphysnum = MaxCommandIdAttributeNumber,
.attcacheoff = -1,
.atttypmod = -1,
.attbyval = true,
@@ -218,7 +218,7 @@ static const FormData_pg_attribute a6 = {
.attname = {"tableoid"},
.atttypid = OIDOID,
.attlen = sizeof(Oid),
- .attnum = TableOidAttributeNumber,
+ .attphysnum = TableOidAttributeNumber,
.attcacheoff = -1,
.atttypmod = -1,
.attbyval = true,
@@ -731,7 +731,7 @@ InsertPgAttributeTuples(Relation pg_attribute_rel,
slot[slotCount]->tts_values[Anum_pg_attribute_atttypid - 1] = ObjectIdGetDatum(attrs->atttypid);
slot[slotCount]->tts_values[Anum_pg_attribute_attstattarget - 1] = Int32GetDatum(attrs->attstattarget);
slot[slotCount]->tts_values[Anum_pg_attribute_attlen - 1] = Int16GetDatum(attrs->attlen);
- slot[slotCount]->tts_values[Anum_pg_attribute_attnum - 1] = Int16GetDatum(attrs->attnum);
+ slot[slotCount]->tts_values[Anum_pg_attribute_attphysnum - 1] = Int16GetDatum(attrs->attphysnum);
slot[slotCount]->tts_values[Anum_pg_attribute_attndims - 1] = Int32GetDatum(attrs->attndims);
slot[slotCount]->tts_values[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(-1);
slot[slotCount]->tts_values[Anum_pg_attribute_atttypmod - 1] = Int32GetDatum(attrs->atttypmod);
@@ -1578,7 +1578,7 @@ DeleteAttributeTuples(Oid relid)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
- scan = systable_beginscan(attrel, AttributeRelidNumIndexId, true,
+ scan = systable_beginscan(attrel, AttributeRelidPhysNumIndexId, true,
NULL, 1, key);
/* Delete all the matching tuples */
@@ -1615,11 +1615,11 @@ DeleteSystemAttributeTuples(Oid relid)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
ScanKeyInit(&key[1],
- Anum_pg_attribute_attnum,
+ Anum_pg_attribute_attphysnum,
BTLessEqualStrategyNumber, F_INT2LE,
Int16GetDatum(0));
- scan = systable_beginscan(attrel, AttributeRelidNumIndexId, true,
+ scan = systable_beginscan(attrel, AttributeRelidPhysNumIndexId, true,
NULL, 2, key);
/* Delete all the matching tuples */
@@ -1640,7 +1640,7 @@ DeleteSystemAttributeTuples(Oid relid)
* is handled by dependency.c.)
*/
void
-RemoveAttributeById(Oid relid, AttrNumber attnum)
+RemoveAttributeById(Oid relid, AttrNumber attphysnum)
{
Relation rel;
Relation attr_rel;
@@ -1658,15 +1658,15 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
- tuple = SearchSysCacheCopy2(ATTNUM,
+ tuple = SearchSysCacheCopy2(ATTPHYSNUM,
ObjectIdGetDatum(relid),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
- attnum, relid);
+ attphysnum, relid);
attStruct = (Form_pg_attribute) GETSTRUCT(tuple);
- if (attnum < 0)
+ if (attphysnum < 0)
{
/* System attribute (probably OID) ... just delete the row */
@@ -1703,7 +1703,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
* Change the column name to something that isn't likely to conflict
*/
snprintf(newattname, sizeof(newattname),
- "........pg.dropped.%d........", attnum);
+ "........pg.dropped.%d........", attphysnum);
namestrcpy(&(attStruct->attname), newattname);
/* clear the missing value if any */
@@ -1740,8 +1740,8 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
table_close(attr_rel, RowExclusiveLock);
- if (attnum > 0)
- RemoveStatistics(relid, attnum);
+ if (attphysnum > 0)
+ RemoveStatistics(relid, attphysnum);
relation_close(rel, NoLock);
}
@@ -1941,7 +1941,7 @@ RelationClearMissing(Relation rel)
Relation attr_rel;
Oid relid = RelationGetRelid(rel);
int natts = RelationGetNumberOfAttributes(rel);
- int attnum;
+ int attphysnum;
Datum repl_val[Natts_pg_attribute];
bool repl_null[Natts_pg_attribute];
bool repl_repl[Natts_pg_attribute];
@@ -1964,14 +1964,14 @@ RelationClearMissing(Relation rel)
attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
/* process each non-system attribute, including any dropped columns */
- for (attnum = 1; attnum <= natts; attnum++)
+ for (attphysnum = 1; attphysnum <= natts; attphysnum++)
{
- tuple = SearchSysCache2(ATTNUM,
+ tuple = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(relid),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
- attnum, relid);
+ attphysnum, relid);
attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
@@ -2201,7 +2201,7 @@ StoreConstraints(Relation rel, List *cooked_constraints, bool is_internal)
switch (con->contype)
{
case CONSTR_DEFAULT:
- con->conoid = StoreAttrDefault(rel, con->attnum, con->expr,
+ con->conoid = StoreAttrDefault(rel, con->attphysnum, con->expr,
is_internal, false);
break;
case CONSTR_CHECK:
@@ -2301,7 +2301,7 @@ AddRelationNewConstraints(Relation rel,
foreach(cell, newColDefaults)
{
RawColumnDefault *colDef = (RawColumnDefault *) lfirst(cell);
- Form_pg_attribute atp = TupleDescAttr(rel->rd_att, colDef->attnum - 1);
+ Form_pg_attribute atp = TupleDescAttr(rel->rd_att, colDef->attphysnum - 1);
Oid defOid;
expr = cookDefault(pstate, colDef->raw_default,
@@ -2331,14 +2331,14 @@ AddRelationNewConstraints(Relation rel,
if (colDef->missingMode && contain_volatile_functions((Node *) expr))
colDef->missingMode = false;
- defOid = StoreAttrDefault(rel, colDef->attnum, expr, is_internal,
+ defOid = StoreAttrDefault(rel, colDef->attphysnum, expr, is_internal,
colDef->missingMode);
cooked = (CookedConstraint *) palloc(sizeof(CookedConstraint));
cooked->contype = CONSTR_DEFAULT;
cooked->conoid = defOid;
cooked->name = NULL;
- cooked->attnum = colDef->attnum;
+ cooked->attphysnum = colDef->attphysnum;
cooked->expr = expr;
cooked->skip_validation = false;
cooked->is_local = is_local;
@@ -2469,7 +2469,7 @@ AddRelationNewConstraints(Relation rel,
cooked->contype = CONSTR_CHECK;
cooked->conoid = constrOid;
cooked->name = ccname;
- cooked->attnum = 0;
+ cooked->attphysnum = 0;
cooked->expr = expr;
cooked->skip_validation = cdef->skip_validation;
cooked->is_local = is_local;
@@ -2695,23 +2695,23 @@ check_nested_generated_walker(Node *node, void *context)
{
Var *var = (Var *) node;
Oid relid;
- AttrNumber attnum;
+ AttrNumber attphysnum;
relid = rt_fetch(var->varno, pstate->p_rtable)->relid;
if (!OidIsValid(relid))
return false; /* XXX shouldn't we raise an error? */
- attnum = var->varattno;
+ attphysnum = var->varattno;
- if (attnum > 0 && get_attgenerated(relid, attnum))
+ if (attphysnum > 0 && get_attgenerated(relid, attphysnum))
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("cannot use generated column \"%s\" in column generation expression",
- get_attname(relid, attnum, false)),
+ get_attname(relid, attphysnum, false)),
errdetail("A generated column cannot reference another generated column."),
parser_errposition(pstate, var->location)));
/* A whole-row Var is necessarily self-referential, so forbid it */
- if (attnum == 0)
+ if (attphysnum == 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("cannot use whole-row variable in column generation expression"),
@@ -2899,11 +2899,11 @@ CopyStatistics(Oid fromrelid, Oid torelid)
/*
* RemoveStatistics --- remove entries in pg_statistic for a rel or column
*
- * If attnum is zero, remove all entries for rel; else remove only the one(s)
+ * If attphysnum is zero, remove all entries for rel; else remove only the one(s)
* for that column.
*/
void
-RemoveStatistics(Oid relid, AttrNumber attnum)
+RemoveStatistics(Oid relid, AttrNumber attphysnum)
{
Relation pgstatistic;
SysScanDesc scan;
@@ -2918,21 +2918,21 @@ RemoveStatistics(Oid relid, AttrNumber attnum)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
- if (attnum == 0)
+ if (attphysnum == 0)
nkeys = 1;
else
{
ScanKeyInit(&key[1],
Anum_pg_statistic_staattnum,
BTEqualStrategyNumber, F_INT2EQ,
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
nkeys = 2;
}
scan = systable_beginscan(pgstatistic, StatisticRelidAttnumInhIndexId, true,
NULL, nkeys, key);
- /* we must loop even when attnum != 0, in case of inherited stats */
+ /* we must loop even when attphysnum != 0, in case of inherited stats */
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
CatalogTupleDelete(pgstatistic, &tuple->t_self);
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index bdd3c34841..c514e3b622 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -231,25 +231,25 @@ index_check_primary_key(Relation heapRel,
*/
for (i = 0; i < indexInfo->ii_NumIndexKeyAttrs; i++)
{
- AttrNumber attnum = indexInfo->ii_IndexAttrNumbers[i];
+ AttrNumber attphysnum = indexInfo->ii_IndexAttrNumbers[i];
HeapTuple atttuple;
Form_pg_attribute attform;
- if (attnum == 0)
+ if (attphysnum == 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("primary keys cannot be expressions")));
/* System attributes are never null, so no need to check */
- if (attnum < 0)
+ if (attphysnum < 0)
continue;
- atttuple = SearchSysCache2(ATTNUM,
+ atttuple = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(RelationGetRelid(heapRel)),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (!HeapTupleIsValid(atttuple))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
- attnum, RelationGetRelid(heapRel));
+ attphysnum, RelationGetRelid(heapRel));
attform = (Form_pg_attribute) GETSTRUCT(atttuple);
if (!attform->attnotnull)
@@ -310,7 +310,7 @@ ConstructTupleDescriptor(Relation heapRelation,
Oid keyType;
MemSet(to, 0, ATTRIBUTE_FIXED_PART_SIZE);
- to->attnum = i + 1;
+ to->attphysnum = i + 1;
to->attstattarget = -1;
to->attcacheoff = -1;
to->attislocal = true;
@@ -1770,7 +1770,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
Anum_pg_attribute_attrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(newIndexId));
- scan = systable_beginscan(pg_attribute, AttributeRelidNumIndexId,
+ scan = systable_beginscan(pg_attribute, AttributeRelidPhysNumIndexId,
true, NULL, 1, key);
while (HeapTupleIsValid((attrTuple = systable_getnext(scan))))
@@ -1789,7 +1789,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
/*
* Get attstattarget from the old index and refresh the new value.
*/
- attstattarget = get_attstattarget(oldIndexId, att->attnum);
+ attstattarget = get_attstattarget(oldIndexId, att->attphysnum);
/* no need for a refresh if both match */
if (attstattarget == att->attstattarget)
diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
index 0b92093322..6c5052c0de 100644
--- a/src/backend/catalog/indexing.c
+++ b/src/backend/catalog/indexing.c
@@ -191,11 +191,11 @@ CatalogTupleCheckConstraints(Relation heapRel, HeapTuple tup)
TupleDesc tupdesc = RelationGetDescr(heapRel);
bits8 *bp = tup->t_data->t_bits;
- for (int attnum = 0; attnum < tupdesc->natts; attnum++)
+ for (int attphysnum = 0; attphysnum < tupdesc->natts; attphysnum++)
{
- Form_pg_attribute thisatt = TupleDescAttr(tupdesc, attnum);
+ Form_pg_attribute thisatt = TupleDescAttr(tupdesc, attphysnum);
- Assert(!(thisatt->attnotnull && att_isnull(attnum, bp)));
+ Assert(!(thisatt->attnotnull && att_isnull(attphysnum, bp)));
}
}
}
diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql
index 18725a02d1..90004ea3bc 100644
--- a/src/backend/catalog/information_schema.sql
+++ b/src/backend/catalog/information_schema.sql
@@ -293,7 +293,7 @@ CREATE VIEW attributes AS
CAST(nc.nspname AS sql_identifier) AS udt_schema,
CAST(c.relname AS sql_identifier) AS udt_name,
CAST(a.attname AS sql_identifier) AS attribute_name,
- CAST(a.attnum AS cardinal_number) AS ordinal_position,
+ CAST(a.attphysnum AS cardinal_number) AS ordinal_position,
CAST(pg_get_expr(ad.adbin, ad.adrelid) AS character_data) AS attribute_default,
CAST(CASE WHEN a.attnotnull OR (t.typtype = 'd' AND t.typnotnull) THEN 'NO' ELSE 'YES' END
AS yes_or_no)
@@ -359,16 +359,16 @@ CREATE VIEW attributes AS
CAST(null AS sql_identifier) AS scope_name,
CAST(null AS cardinal_number) AS maximum_cardinality,
- CAST(a.attnum AS sql_identifier) AS dtd_identifier,
+ CAST(a.attphysnum AS sql_identifier) AS dtd_identifier,
CAST('NO' AS yes_or_no) AS is_derived_reference_attribute
- FROM (pg_attribute a LEFT JOIN pg_attrdef ad ON attrelid = adrelid AND attnum = adnum)
+ FROM (pg_attribute a LEFT JOIN pg_attrdef ad ON attrelid = adrelid AND attphysnum = adnum)
JOIN (pg_class c JOIN pg_namespace nc ON (c.relnamespace = nc.oid)) ON a.attrelid = c.oid
JOIN (pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid)) ON a.atttypid = t.oid
LEFT JOIN (pg_collation co JOIN pg_namespace nco ON (co.collnamespace = nco.oid))
ON a.attcollation = co.oid AND (nco.nspname, co.collname) <> ('pg_catalog', 'default')
- WHERE a.attnum > 0 AND NOT a.attisdropped
+ WHERE a.attphysnum > 0 AND NOT a.attisdropped
AND c.relkind IN ('c')
AND (pg_has_role(c.relowner, 'USAGE')
OR has_type_privilege(c.reltype, 'USAGE'));
@@ -449,13 +449,13 @@ CREATE VIEW check_constraints AS
SELECT CAST(current_database() AS sql_identifier) AS constraint_catalog,
CAST(n.nspname AS sql_identifier) AS constraint_schema,
- CAST(CAST(n.oid AS text) || '_' || CAST(r.oid AS text) || '_' || CAST(a.attnum AS text) || '_not_null' AS sql_identifier) AS constraint_name, -- XXX
+ CAST(CAST(n.oid AS text) || '_' || CAST(r.oid AS text) || '_' || CAST(a.attphysnum AS text) || '_not_null' AS sql_identifier) AS constraint_name, -- XXX
CAST(a.attname || ' IS NOT NULL' AS character_data)
AS check_clause
FROM pg_namespace n, pg_class r, pg_attribute a
WHERE n.oid = r.relnamespace
AND r.oid = a.attrelid
- AND a.attnum > 0
+ AND a.attphysnum > 0
AND NOT a.attisdropped
AND a.attnotnull
AND r.relkind IN ('r', 'p')
@@ -519,14 +519,14 @@ CREATE VIEW column_column_usage AS
WHERE n.oid = c.relnamespace
AND c.oid = ac.attrelid
AND c.oid = ad.attrelid
- AND ac.attnum <> ad.attnum
+ AND ac.attphysnum <> ad.attphysnum
AND ad.attrelid = atd.adrelid
- AND ad.attnum = atd.adnum
+ AND ad.attphysnum = atd.adnum
AND d.classid = 'pg_catalog.pg_attrdef'::regclass
AND d.refclassid = 'pg_catalog.pg_class'::regclass
AND d.objid = atd.oid
AND d.refobjid = ac.attrelid
- AND d.refobjsubid = ac.attnum
+ AND d.refobjsubid = ac.attphysnum
AND ad.attgenerated <> ''
AND pg_has_role(c.relowner, 'USAGE');
@@ -556,7 +556,7 @@ CREATE VIEW column_domain_usage AS
AND a.atttypid = t.oid
AND t.typtype = 'd'
AND c.relkind IN ('r', 'v', 'f', 'p')
- AND a.attnum > 0
+ AND a.attphysnum > 0
AND NOT a.attisdropped
AND pg_has_role(t.typowner, 'USAGE');
@@ -598,7 +598,7 @@ CREATE VIEW column_privileges AS
) pr_c (oid, relname, relnamespace, relowner, grantor, grantee, prtype, grantable),
pg_attribute a
WHERE a.attrelid = pr_c.oid
- AND a.attnum > 0
+ AND a.attphysnum > 0
AND NOT a.attisdropped
UNION
SELECT pr_a.grantor,
@@ -611,7 +611,7 @@ CREATE VIEW column_privileges AS
c.relowner
FROM (SELECT attrelid, attname, (aclexplode(coalesce(attacl, acldefault('c', relowner)))).*
FROM pg_attribute a JOIN pg_class cc ON (a.attrelid = cc.oid)
- WHERE attnum > 0
+ WHERE attphysnum > 0
AND NOT attisdropped
) pr_a (attrelid, attname, grantor, grantee, prtype, grantable),
pg_class c
@@ -659,7 +659,7 @@ CREATE VIEW column_udt_usage AS
WHERE a.attrelid = c.oid
AND a.atttypid = t.oid
AND nc.oid = c.relnamespace
- AND a.attnum > 0 AND NOT a.attisdropped
+ AND a.attphysnum > 0 AND NOT a.attisdropped
AND c.relkind in ('r', 'v', 'f', 'p')
AND pg_has_role(coalesce(bt.typowner, t.typowner), 'USAGE');
@@ -676,7 +676,7 @@ CREATE VIEW columns AS
CAST(nc.nspname AS sql_identifier) AS table_schema,
CAST(c.relname AS sql_identifier) AS table_name,
CAST(a.attname AS sql_identifier) AS column_name,
- CAST(a.attnum AS cardinal_number) AS ordinal_position,
+ CAST(a.attphysnum AS cardinal_number) AS ordinal_position,
CAST(CASE WHEN a.attgenerated = '' THEN pg_get_expr(ad.adbin, ad.adrelid) END AS character_data) AS column_default,
CAST(CASE WHEN a.attnotnull OR (t.typtype = 'd' AND t.typnotnull) THEN 'NO' ELSE 'YES' END
AS yes_or_no)
@@ -755,7 +755,7 @@ CREATE VIEW columns AS
CAST(null AS sql_identifier) AS scope_name,
CAST(null AS cardinal_number) AS maximum_cardinality,
- CAST(a.attnum AS sql_identifier) AS dtd_identifier,
+ CAST(a.attphysnum AS sql_identifier) AS dtd_identifier,
CAST('NO' AS yes_or_no) AS is_self_referencing,
CAST(CASE WHEN a.attidentity IN ('a', 'd') THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_identity,
@@ -771,10 +771,10 @@ CREATE VIEW columns AS
CAST(CASE WHEN c.relkind IN ('r', 'p') OR
(c.relkind IN ('v', 'f') AND
- pg_column_is_updatable(c.oid, a.attnum, false))
+ pg_column_is_updatable(c.oid, a.attphysnum, false))
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_updatable
- FROM (pg_attribute a LEFT JOIN pg_attrdef ad ON attrelid = adrelid AND attnum = adnum)
+ FROM (pg_attribute a LEFT JOIN pg_attrdef ad ON attrelid = adrelid AND attphysnum = adnum)
JOIN (pg_class c JOIN pg_namespace nc ON (c.relnamespace = nc.oid)) ON a.attrelid = c.oid
JOIN (pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid)) ON a.atttypid = t.oid
LEFT JOIN (pg_type bt JOIN pg_namespace nbt ON (bt.typnamespace = nbt.oid))
@@ -782,15 +782,15 @@ CREATE VIEW columns AS
LEFT JOIN (pg_collation co JOIN pg_namespace nco ON (co.collnamespace = nco.oid))
ON a.attcollation = co.oid AND (nco.nspname, co.collname) <> ('pg_catalog', 'default')
LEFT JOIN (pg_depend dep JOIN pg_sequence seq ON (dep.classid = 'pg_class'::regclass AND dep.objid = seq.seqrelid AND dep.deptype = 'i'))
- ON (dep.refclassid = 'pg_class'::regclass AND dep.refobjid = c.oid AND dep.refobjsubid = a.attnum)
+ ON (dep.refclassid = 'pg_class'::regclass AND dep.refobjid = c.oid AND dep.refobjsubid = a.attphysnum)
WHERE (NOT pg_is_other_temp_schema(nc.oid))
- AND a.attnum > 0 AND NOT a.attisdropped
+ AND a.attphysnum > 0 AND NOT a.attisdropped
AND c.relkind IN ('r', 'v', 'f', 'p')
AND (pg_has_role(c.relowner, 'USAGE')
- OR has_column_privilege(c.oid, a.attnum,
+ OR has_column_privilege(c.oid, a.attphysnum,
'SELECT, INSERT, UPDATE, REFERENCES'));
GRANT SELECT ON columns TO PUBLIC;
@@ -818,7 +818,7 @@ CREATE VIEW constraint_column_usage AS
AND r.oid = a.attrelid
AND d.refclassid = 'pg_catalog.pg_class'::regclass
AND d.refobjid = r.oid
- AND d.refobjsubid = a.attnum
+ AND d.refobjsubid = a.attphysnum
AND d.classid = 'pg_catalog.pg_constraint'::regclass
AND d.objid = c.oid
AND c.connamespace = nc.oid
@@ -836,7 +836,7 @@ CREATE VIEW constraint_column_usage AS
AND r.oid = a.attrelid
AND nc.oid = c.connamespace
AND r.oid = CASE c.contype WHEN 'f' THEN c.confrelid ELSE c.conrelid END
- AND a.attnum = ANY (CASE c.contype WHEN 'f' THEN c.confkey ELSE c.conkey END)
+ AND a.attphysnum = ANY (CASE c.contype WHEN 'f' THEN c.confkey ELSE c.conkey END)
AND NOT a.attisdropped
AND c.contype IN ('p', 'u', 'f')
AND r.relkind IN ('r', 'p')
@@ -1095,10 +1095,10 @@ CREATE VIEW key_column_usage AS
AND r.relkind IN ('r', 'p')
AND (NOT pg_is_other_temp_schema(nr.oid)) ) AS ss
WHERE ss.roid = a.attrelid
- AND a.attnum = (ss.x).x
+ AND a.attphysnum = (ss.x).x
AND NOT a.attisdropped
AND (pg_has_role(relowner, 'USAGE')
- OR has_column_privilege(roid, a.attnum,
+ OR has_column_privilege(roid, a.attphysnum,
'SELECT, INSERT, UPDATE, REFERENCES'));
GRANT SELECT ON key_column_usage TO PUBLIC;
@@ -1352,7 +1352,7 @@ CREATE VIEW routine_column_usage AS
AND t.relnamespace = nt.oid
AND t.relkind IN ('r', 'v', 'f', 'p')
AND t.oid = a.attrelid
- AND d.refobjsubid = a.attnum
+ AND d.refobjsubid = a.attphysnum
AND pg_has_role(t.relowner, 'USAGE');
GRANT SELECT ON routine_column_usage TO PUBLIC;
@@ -1867,7 +1867,7 @@ CREATE VIEW table_constraints AS
SELECT CAST(current_database() AS sql_identifier) AS constraint_catalog,
CAST(nr.nspname AS sql_identifier) AS constraint_schema,
- CAST(CAST(nr.oid AS text) || '_' || CAST(r.oid AS text) || '_' || CAST(a.attnum AS text) || '_not_null' AS sql_identifier) AS constraint_name, -- XXX
+ CAST(CAST(nr.oid AS text) || '_' || CAST(r.oid AS text) || '_' || CAST(a.attphysnum AS text) || '_not_null' AS sql_identifier) AS constraint_name, -- XXX
CAST(current_database() AS sql_identifier) AS table_catalog,
CAST(nr.nspname AS sql_identifier) AS table_schema,
CAST(r.relname AS sql_identifier) AS table_name,
@@ -1884,7 +1884,7 @@ CREATE VIEW table_constraints AS
WHERE nr.oid = r.relnamespace
AND r.oid = a.attrelid
AND a.attnotnull
- AND a.attnum > 0
+ AND a.attphysnum > 0
AND NOT a.attisdropped
AND r.relkind IN ('r', 'p')
AND (NOT pg_is_other_temp_schema(nr.oid))
@@ -2084,12 +2084,12 @@ CREATE VIEW triggered_update_columns AS
WHERE n.oid = c.relnamespace
AND c.oid = t.tgrelid
AND t.oid = ta.tgoid
- AND (a.attrelid, a.attnum) = (t.tgrelid, ta.tgattnum)
+ AND (a.attrelid, a.attphysnum) = (t.tgrelid, ta.tgattnum)
AND NOT t.tgisinternal
AND (NOT pg_is_other_temp_schema(n.oid))
AND (pg_has_role(c.relowner, 'USAGE')
-- SELECT privilege omitted, per SQL standard
- OR has_column_privilege(c.oid, a.attnum, 'INSERT, UPDATE, REFERENCES') );
+ OR has_column_privilege(c.oid, a.attphysnum, 'INSERT, UPDATE, REFERENCES') );
GRANT SELECT ON triggered_update_columns TO PUBLIC;
@@ -2537,7 +2537,7 @@ CREATE VIEW view_column_usage AS
AND t.relnamespace = nt.oid
AND t.relkind IN ('r', 'v', 'f', 'p')
AND t.oid = a.attrelid
- AND dt.refobjsubid = a.attnum
+ AND dt.refobjsubid = a.attphysnum
AND pg_has_role(t.relowner, 'USAGE');
GRANT SELECT ON view_column_usage TO PUBLIC;
@@ -2763,11 +2763,11 @@ CREATE VIEW element_types AS
/* columns, attributes */
SELECT c.relnamespace, CAST(c.relname AS sql_identifier),
CASE WHEN c.relkind = 'c' THEN 'USER-DEFINED TYPE'::text ELSE 'TABLE'::text END,
- a.attnum, a.atttypid, a.attcollation
+ a.attphysnum, a.atttypid, a.attcollation
FROM pg_class c, pg_attribute a
WHERE c.oid = a.attrelid
AND c.relkind IN ('r', 'v', 'f', 'c', 'p')
- AND attnum > 0 AND NOT attisdropped
+ AND attphysnum > 0 AND NOT attisdropped
UNION ALL
@@ -2824,12 +2824,12 @@ CREATE VIEW _pg_foreign_table_columns AS
pg_attribute a
WHERE u.oid = c.relowner
AND (pg_has_role(c.relowner, 'USAGE')
- OR has_column_privilege(c.oid, a.attnum, 'SELECT, INSERT, UPDATE, REFERENCES'))
+ OR has_column_privilege(c.oid, a.attphysnum, 'SELECT, INSERT, UPDATE, REFERENCES'))
AND n.oid = c.relnamespace
AND c.oid = t.ftrelid
AND c.relkind = 'f'
AND a.attrelid = c.oid
- AND a.attnum > 0;
+ AND a.attphysnum > 0;
/*
* 24.2
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 8377b4f7d4..e373637651 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -107,10 +107,10 @@ typedef struct
* (name) if the object does not live in a
* namespace */
AttrNumber attnum_oid; /* attribute number of oid column */
- AttrNumber attnum_name; /* attnum of name field */
- AttrNumber attnum_namespace; /* attnum of namespace field */
- AttrNumber attnum_owner; /* attnum of owner field */
- AttrNumber attnum_acl; /* attnum of acl field */
+ AttrNumber attnum_name; /* attphysnum of name field */
+ AttrNumber attnum_namespace; /* attphysnum of namespace field */
+ AttrNumber attnum_owner; /* attphysnum of owner field */
+ AttrNumber attnum_acl; /* attphysnum of acl field */
ObjectType objtype; /* OBJECT_* of this object type */
bool is_nsp_name_unique; /* can the nsp/name combination (or name
* alone, if there's no namespace) be
@@ -1520,7 +1520,7 @@ get_object_address_attribute(ObjectType objtype, List *object,
Oid reloid;
Relation relation;
const char *attname;
- AttrNumber attnum;
+ AttrNumber attphysnum;
/* Extract relation name and open relation. */
if (list_length(object) < 2)
@@ -1534,8 +1534,8 @@ get_object_address_attribute(ObjectType objtype, List *object,
reloid = RelationGetRelid(relation);
/* Look up attribute and construct return value. */
- attnum = get_attnum(reloid, attname);
- if (attnum == InvalidAttrNumber)
+ attphysnum = get_attphysnum(reloid, attname);
+ if (attphysnum == InvalidAttrNumber)
{
if (!missing_ok)
ereport(ERROR,
@@ -1552,7 +1552,7 @@ get_object_address_attribute(ObjectType objtype, List *object,
address.classId = RelationRelationId;
address.objectId = reloid;
- address.objectSubId = attnum;
+ address.objectSubId = attphysnum;
*relp = relation;
return address;
@@ -1571,7 +1571,7 @@ get_object_address_attrdef(ObjectType objtype, List *object,
Oid reloid;
Relation relation;
const char *attname;
- AttrNumber attnum;
+ AttrNumber attphysnum;
TupleDesc tupdesc;
Oid defoid;
@@ -1589,10 +1589,10 @@ get_object_address_attrdef(ObjectType objtype, List *object,
tupdesc = RelationGetDescr(relation);
/* Look up attribute number and fetch the pg_attrdef OID */
- attnum = get_attnum(reloid, attname);
+ attphysnum = get_attphysnum(reloid, attname);
defoid = InvalidOid;
- if (attnum != InvalidAttrNumber && tupdesc->constr != NULL)
- defoid = GetAttrDefaultOid(reloid, attnum);
+ if (attphysnum != InvalidAttrNumber && tupdesc->constr != NULL)
+ defoid = GetAttrDefaultOid(reloid, attphysnum);
if (!OidIsValid(defoid))
{
if (!missing_ok)
diff --git a/src/backend/catalog/pg_attrdef.c b/src/backend/catalog/pg_attrdef.c
index c5d4a9912e..8587796e0b 100644
--- a/src/backend/catalog/pg_attrdef.c
+++ b/src/backend/catalog/pg_attrdef.c
@@ -32,7 +32,7 @@
/*
- * Store a default expression for column attnum of relation rel.
+ * Store a default expression for column attphysnum of relation rel.
*
* Returns the OID of the new pg_attrdef tuple.
*
@@ -43,7 +43,7 @@
* in effect be changing existing tuples.
*/
Oid
-StoreAttrDefault(Relation rel, AttrNumber attnum,
+StoreAttrDefault(Relation rel, AttrNumber attphysnum,
Node *expr, bool is_internal, bool add_column_mode)
{
char *adbin;
@@ -73,7 +73,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
Anum_pg_attrdef_oid);
values[Anum_pg_attrdef_oid - 1] = ObjectIdGetDatum(attrdefOid);
values[Anum_pg_attrdef_adrelid - 1] = RelationGetRelid(rel);
- values[Anum_pg_attrdef_adnum - 1] = attnum;
+ values[Anum_pg_attrdef_adnum - 1] = attphysnum;
values[Anum_pg_attrdef_adbin - 1] = CStringGetTextDatum(adbin);
tuple = heap_form_tuple(adrel->rd_att, values, nulls);
@@ -95,12 +95,12 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
* exists.
*/
attrrel = table_open(AttributeRelationId, RowExclusiveLock);
- atttup = SearchSysCacheCopy2(ATTNUM,
+ atttup = SearchSysCacheCopy2(ATTPHYSNUM,
ObjectIdGetDatum(RelationGetRelid(rel)),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (!HeapTupleIsValid(atttup))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
- attnum, RelationGetRelid(rel));
+ attphysnum, RelationGetRelid(rel));
attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
attgenerated = attStruct->attgenerated;
if (!attStruct->atthasdef)
@@ -136,7 +136,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
FreeExecutorState(estate);
- defAttStruct = TupleDescAttr(rel->rd_att, attnum - 1);
+ defAttStruct = TupleDescAttr(rel->rd_att, attphysnum - 1);
if (missingIsNull)
{
@@ -179,7 +179,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
*/
colobject.classId = RelationRelationId;
colobject.objectId = RelationGetRelid(rel);
- colobject.objectSubId = attnum;
+ colobject.objectSubId = attphysnum;
recordDependencyOn(&defobject, &colobject,
attgenerated ? DEPENDENCY_INTERNAL : DEPENDENCY_AUTO);
@@ -200,7 +200,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
* needs to distinguish.
*/
InvokeObjectPostCreateHookArg(AttrDefaultRelationId,
- RelationGetRelid(rel), attnum, is_internal);
+ RelationGetRelid(rel), attphysnum, is_internal);
return attrdefOid;
}
@@ -213,7 +213,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
* (If no default, raise error if complain is true, else return quietly.)
*/
void
-RemoveAttrDefault(Oid relid, AttrNumber attnum,
+RemoveAttrDefault(Oid relid, AttrNumber attphysnum,
DropBehavior behavior, bool complain, bool internal)
{
Relation attrdef_rel;
@@ -231,7 +231,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
ScanKeyInit(&scankeys[1],
Anum_pg_attrdef_adnum,
BTEqualStrategyNumber, F_INT2EQ,
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
scan = systable_beginscan(attrdef_rel, AttrDefaultIndexId, true,
NULL, 2, scankeys);
@@ -256,8 +256,8 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
table_close(attrdef_rel, RowExclusiveLock);
if (complain && !found)
- elog(ERROR, "could not find attrdef tuple for relation %u attnum %d",
- relid, attnum);
+ elog(ERROR, "could not find attrdef tuple for relation %u attphysnum %d",
+ relid, attphysnum);
}
/*
@@ -310,7 +310,7 @@ RemoveAttrDefaultById(Oid attrdefId)
/* Fix the pg_attribute row */
attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
- tuple = SearchSysCacheCopy2(ATTNUM,
+ tuple = SearchSysCacheCopy2(ATTPHYSNUM,
ObjectIdGetDatum(myrelid),
Int16GetDatum(myattnum));
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
@@ -339,7 +339,7 @@ RemoveAttrDefaultById(Oid attrdefId)
* Returns InvalidOid if there is no such pg_attrdef entry.
*/
Oid
-GetAttrDefaultOid(Oid relid, AttrNumber attnum)
+GetAttrDefaultOid(Oid relid, AttrNumber attphysnum)
{
Oid result = InvalidOid;
Relation attrdef;
@@ -357,7 +357,7 @@ GetAttrDefaultOid(Oid relid, AttrNumber attnum)
Anum_pg_attrdef_adnum,
BTEqualStrategyNumber,
F_INT2EQ,
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
scan = systable_beginscan(attrdef, AttrDefaultIndexId, true,
NULL, 2, keys);
diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c
index e86e5e6898..e8a2be6fc7 100644
--- a/src/backend/catalog/pg_depend.c
+++ b/src/backend/catalog/pg_depend.c
@@ -816,7 +816,7 @@ sequenceIsOwned(Oid seqId, char deptype, Oid *tableId, int32 *colId)
* with the specified dependency type.
*/
static List *
-getOwnedSequences_internal(Oid relid, AttrNumber attnum, char deptype)
+getOwnedSequences_internal(Oid relid, AttrNumber attphysnum, char deptype)
{
List *result = NIL;
Relation depRel;
@@ -834,14 +834,14 @@ getOwnedSequences_internal(Oid relid, AttrNumber attnum, char deptype)
Anum_pg_depend_refobjid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
- if (attnum)
+ if (attphysnum)
ScanKeyInit(&key[2],
Anum_pg_depend_refobjsubid,
BTEqualStrategyNumber, F_INT4EQ,
- Int32GetDatum(attnum));
+ Int32GetDatum(attphysnum));
scan = systable_beginscan(depRel, DependReferenceIndexId, true,
- NULL, attnum ? 3 : 2, key);
+ NULL, attphysnum ? 3 : 2, key);
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
@@ -884,9 +884,9 @@ getOwnedSequences(Oid relid)
* Get owned identity sequence, error if not exactly one.
*/
Oid
-getIdentitySequence(Oid relid, AttrNumber attnum, bool missing_ok)
+getIdentitySequence(Oid relid, AttrNumber attphysnum, bool missing_ok)
{
- List *seqlist = getOwnedSequences_internal(relid, attnum, DEPENDENCY_INTERNAL);
+ List *seqlist = getOwnedSequences_internal(relid, attphysnum, DEPENDENCY_INTERNAL);
if (list_length(seqlist) > 1)
elog(ERROR, "more than one owned sequence found");
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index c365de3a72..0a8cefe637 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -502,34 +502,34 @@ publication_translate_columns(Relation targetrel, List *columns,
foreach(lc, columns)
{
char *colname = strVal(lfirst(lc));
- AttrNumber attnum = get_attnum(RelationGetRelid(targetrel), colname);
+ AttrNumber attphysnum = get_attphysnum(RelationGetRelid(targetrel), colname);
- if (attnum == InvalidAttrNumber)
+ if (attphysnum == InvalidAttrNumber)
ereport(ERROR,
errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colname, RelationGetRelationName(targetrel)));
- if (!AttrNumberIsForUserDefinedAttr(attnum))
+ if (!AttrNumberIsForUserDefinedAttr(attphysnum))
ereport(ERROR,
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("cannot reference system column \"%s\" in publication column list",
colname));
- if (TupleDescAttr(tupdesc, attnum - 1)->attgenerated)
+ if (TupleDescAttr(tupdesc, attphysnum - 1)->attgenerated)
ereport(ERROR,
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("cannot reference generated column \"%s\" in publication column list",
colname));
- if (bms_is_member(attnum, set))
+ if (bms_is_member(attphysnum, set))
ereport(ERROR,
errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("duplicate column \"%s\" in publication column list",
colname));
- set = bms_add_member(set, attnum);
- attarray[n++] = attnum;
+ set = bms_add_member(set, attphysnum);
+ attarray[n++] = attphysnum;
}
/* Be tidy, so that the catalog representation is always sorted */
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index fedaed533b..37b7edc2db 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -245,10 +245,10 @@ CREATE VIEW pg_stats WITH (security_barrier) AS
WHEN stakind5 = 5 THEN stanumbers5
END AS elem_count_histogram
FROM pg_statistic s JOIN pg_class c ON (c.oid = s.starelid)
- JOIN pg_attribute a ON (c.oid = attrelid AND attnum = s.staattnum)
+ JOIN pg_attribute a ON (c.oid = attrelid AND attphysnum = s.staattnum)
LEFT JOIN pg_namespace n ON (n.oid = c.relnamespace)
WHERE NOT attisdropped
- AND has_column_privilege(c.oid, a.attnum, 'select')
+ AND has_column_privilege(c.oid, a.attphysnum, 'select')
AND (c.relrowsecurity = false OR NOT row_security_active(c.oid));
REVOKE ALL ON pg_statistic FROM public;
@@ -259,10 +259,10 @@ CREATE VIEW pg_stats_ext WITH (security_barrier) AS
sn.nspname AS statistics_schemaname,
s.stxname AS statistics_name,
pg_get_userbyid(s.stxowner) AS statistics_owner,
- ( SELECT array_agg(a.attname ORDER BY a.attnum)
+ ( SELECT array_agg(a.attname ORDER BY a.attphysnum)
FROM unnest(s.stxkeys) k
JOIN pg_attribute a
- ON (a.attrelid = s.stxrelid AND a.attnum = k)
+ ON (a.attrelid = s.stxrelid AND a.attphysnum = k)
) AS attnames,
pg_get_statisticsobjdef_expressions(s.oid) as exprs,
s.stxkind AS kinds,
@@ -288,8 +288,8 @@ CREATE VIEW pg_stats_ext WITH (security_barrier) AS
( SELECT 1
FROM unnest(stxkeys) k
JOIN pg_attribute a
- ON (a.attrelid = s.stxrelid AND a.attnum = k)
- WHERE NOT has_column_privilege(c.oid, a.attnum, 'select') )
+ ON (a.attrelid = s.stxrelid AND a.attphysnum = k)
+ WHERE NOT has_column_privilege(c.oid, a.attphysnum, 'select') )
AND (c.relrowsecurity = false OR NOT row_security_active(c.oid));
CREATE VIEW pg_stats_ext_exprs WITH (security_barrier) AS
@@ -369,12 +369,12 @@ CREATE VIEW pg_publication_tables AS
P.pubname AS pubname,
N.nspname AS schemaname,
C.relname AS tablename,
- ( SELECT array_agg(a.attname ORDER BY a.attnum)
+ ( SELECT array_agg(a.attname ORDER BY a.attphysnum)
FROM unnest(CASE WHEN GPT.attrs IS NOT NULL THEN GPT.attrs
ELSE (SELECT array_agg(g) FROM generate_series(1, C.relnatts) g)
END) k
JOIN pg_attribute a
- ON (a.attrelid = GPT.relid AND a.attnum = k)
+ ON (a.attrelid = GPT.relid AND a.attphysnum = k)
) AS attnames,
pg_get_expr(GPT.qual, GPT.relid) AS rowfilter
FROM pg_publication P,
@@ -446,7 +446,7 @@ FROM
pg_seclabel l
JOIN pg_class rel ON l.classoid = rel.tableoid AND l.objoid = rel.oid
JOIN pg_attribute att
- ON rel.oid = att.attrelid AND l.objsubid = att.attnum
+ ON rel.oid = att.attrelid AND l.objsubid = att.attphysnum
JOIN pg_namespace nsp ON rel.relnamespace = nsp.oid
WHERE
l.objsubid != 0
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 2da6b75a15..fe0b81d99e 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -95,7 +95,7 @@ static void compute_index_stats(Relation onerel, double totalrows,
AnlIndexData *indexdata, int nindexes,
HeapTuple *rows, int numrows,
MemoryContext col_context);
-static VacAttrStats *examine_attribute(Relation onerel, int attnum,
+static VacAttrStats *examine_attribute(Relation onerel, int attphysnum,
Node *index_expr);
static int acquire_sample_rows(Relation onerel, int elevel,
HeapTuple *rows, int targrows,
@@ -574,7 +574,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
* If the appropriate flavor of the n_distinct option is
* specified, override with the corresponding value.
*/
- aopt = get_attribute_options(onerel->rd_id, stats->attr->attnum);
+ aopt = get_attribute_options(onerel->rd_id, stats->attr->attphysnum);
if (aopt != NULL)
{
float8 n_distinct;
@@ -928,16 +928,16 @@ compute_index_stats(Relation onerel, double totalrows,
for (i = 0; i < attr_cnt; i++)
{
VacAttrStats *stats = thisdata->vacattrstats[i];
- int attnum = stats->attr->attnum;
+ int attphysnum = stats->attr->attphysnum;
- if (isnull[attnum - 1])
+ if (isnull[attphysnum - 1])
{
exprvals[tcnt] = (Datum) 0;
exprnulls[tcnt] = true;
}
else
{
- exprvals[tcnt] = datumCopy(values[attnum - 1],
+ exprvals[tcnt] = datumCopy(values[attphysnum - 1],
stats->attrtype->typbyval,
stats->attrtype->typlen);
exprnulls[tcnt] = false;
@@ -998,9 +998,9 @@ compute_index_stats(Relation onerel, double totalrows,
* and index_expr is the expression tree representing the column's data.
*/
static VacAttrStats *
-examine_attribute(Relation onerel, int attnum, Node *index_expr)
+examine_attribute(Relation onerel, int attphysnum, Node *index_expr)
{
- Form_pg_attribute attr = TupleDescAttr(onerel->rd_att, attnum - 1);
+ Form_pg_attribute attr = TupleDescAttr(onerel->rd_att, attphysnum - 1);
HeapTuple typtuple;
VacAttrStats *stats;
int i;
@@ -1041,8 +1041,8 @@ examine_attribute(Relation onerel, int attnum, Node *index_expr)
* preference to anything else; but if not, fall back to whatever we
* can get from the expression.
*/
- if (OidIsValid(onerel->rd_indcollation[attnum - 1]))
- stats->attrcollid = onerel->rd_indcollation[attnum - 1];
+ if (OidIsValid(onerel->rd_indcollation[attphysnum - 1]))
+ stats->attrcollid = onerel->rd_indcollation[attphysnum - 1];
else
stats->attrcollid = exprCollation(index_expr);
}
@@ -1059,7 +1059,7 @@ examine_attribute(Relation onerel, int attnum, Node *index_expr)
elog(ERROR, "cache lookup failed for type %u", stats->attrtypid);
stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple);
stats->anl_context = anl_context;
- stats->tupattnum = attnum;
+ stats->tupattnum = attphysnum;
/*
* The fields describing the stats->stavalues[n] element types default to
@@ -1656,7 +1656,7 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
}
values[Anum_pg_statistic_starelid - 1] = ObjectIdGetDatum(relid);
- values[Anum_pg_statistic_staattnum - 1] = Int16GetDatum(stats->attr->attnum);
+ values[Anum_pg_statistic_staattnum - 1] = Int16GetDatum(stats->attr->attphysnum);
values[Anum_pg_statistic_stainherit - 1] = BoolGetDatum(inh);
values[Anum_pg_statistic_stanullfrac - 1] = Float4GetDatum(stats->stanullfrac);
values[Anum_pg_statistic_stawidth - 1] = Int32GetDatum(stats->stawidth);
@@ -1725,7 +1725,7 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
/* Is there already a pg_statistic tuple for this attribute? */
oldtup = SearchSysCache3(STATRELATTINH,
ObjectIdGetDatum(relid),
- Int16GetDatum(stats->attr->attnum),
+ Int16GetDatum(stats->attr->attphysnum),
BoolGetDatum(inh));
if (HeapTupleIsValid(oldtup))
@@ -1761,11 +1761,11 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
static Datum
std_fetch_func(VacAttrStatsP stats, int rownum, bool *isNull)
{
- int attnum = stats->tupattnum;
+ int attphysnum = stats->tupattnum;
HeapTuple tuple = stats->rows[rownum];
TupleDesc tupDesc = stats->tupDesc;
- return heap_getattr(tuple, attnum, tupDesc, isNull);
+ return heap_getattr(tuple, attphysnum, tupDesc, isNull);
}
/*
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index e2870e3c11..6b15837dba 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -739,11 +739,11 @@ CopyGetAttnums(TupleDesc tupDesc, Relation rel, List *attnamelist)
foreach(l, attnamelist)
{
char *name = strVal(lfirst(l));
- int attnum;
+ int attphysnum;
int i;
/* Lookup column name */
- attnum = InvalidAttrNumber;
+ attphysnum = InvalidAttrNumber;
for (i = 0; i < tupDesc->natts; i++)
{
Form_pg_attribute att = TupleDescAttr(tupDesc, i);
@@ -758,11 +758,11 @@ CopyGetAttnums(TupleDesc tupDesc, Relation rel, List *attnamelist)
errmsg("column \"%s\" is a generated column",
name),
errdetail("Generated columns cannot be used in COPY.")));
- attnum = att->attnum;
+ attphysnum = att->attphysnum;
break;
}
}
- if (attnum == InvalidAttrNumber)
+ if (attphysnum == InvalidAttrNumber)
{
if (rel != NULL)
ereport(ERROR,
@@ -776,12 +776,12 @@ CopyGetAttnums(TupleDesc tupDesc, Relation rel, List *attnamelist)
name)));
}
/* Check for duplicates */
- if (list_member_int(attnums, attnum))
+ if (list_member_int(attnums, attphysnum))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column \"%s\" specified more than once",
name)));
- attnums = lappend_int(attnums, attnum);
+ attnums = lappend_int(attnums, attphysnum);
}
}
diff --git a/src/backend/commands/copyfrom.c b/src/backend/commands/copyfrom.c
index 35a1d3a774..ca44d12b11 100644
--- a/src/backend/commands/copyfrom.c
+++ b/src/backend/commands/copyfrom.c
@@ -1202,7 +1202,7 @@ BeginCopyFrom(ParseState *pstate,
num_defaults;
FmgrInfo *in_functions;
Oid *typioparams;
- int attnum;
+ int attphysnum;
Oid in_func_oid;
int *defmap;
ExprState **defexprs;
@@ -1258,15 +1258,15 @@ BeginCopyFrom(ParseState *pstate,
foreach(cur, attnums)
{
- int attnum = lfirst_int(cur);
- Form_pg_attribute attr = TupleDescAttr(tupDesc, attnum - 1);
+ int attphysnum = lfirst_int(cur);
+ Form_pg_attribute attr = TupleDescAttr(tupDesc, attphysnum - 1);
- if (!list_member_int(cstate->attnumlist, attnum))
+ if (!list_member_int(cstate->attnumlist, attphysnum))
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("FORCE_NOT_NULL column \"%s\" not referenced by COPY",
NameStr(attr->attname))));
- cstate->opts.force_notnull_flags[attnum - 1] = true;
+ cstate->opts.force_notnull_flags[attphysnum - 1] = true;
}
}
@@ -1281,15 +1281,15 @@ BeginCopyFrom(ParseState *pstate,
foreach(cur, attnums)
{
- int attnum = lfirst_int(cur);
- Form_pg_attribute attr = TupleDescAttr(tupDesc, attnum - 1);
+ int attphysnum = lfirst_int(cur);
+ Form_pg_attribute attr = TupleDescAttr(tupDesc, attphysnum - 1);
- if (!list_member_int(cstate->attnumlist, attnum))
+ if (!list_member_int(cstate->attnumlist, attphysnum))
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("FORCE_NULL column \"%s\" not referenced by COPY",
NameStr(attr->attname))));
- cstate->opts.force_null_flags[attnum - 1] = true;
+ cstate->opts.force_null_flags[attphysnum - 1] = true;
}
}
@@ -1305,15 +1305,15 @@ BeginCopyFrom(ParseState *pstate,
foreach(cur, attnums)
{
- int attnum = lfirst_int(cur);
- Form_pg_attribute attr = TupleDescAttr(tupDesc, attnum - 1);
+ int attphysnum = lfirst_int(cur);
+ Form_pg_attribute attr = TupleDescAttr(tupDesc, attphysnum - 1);
- if (!list_member_int(cstate->attnumlist, attnum))
+ if (!list_member_int(cstate->attnumlist, attphysnum))
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg_internal("selected column \"%s\" not referenced by COPY",
NameStr(attr->attname))));
- cstate->convert_select_flags[attnum - 1] = true;
+ cstate->convert_select_flags[attphysnum - 1] = true;
}
}
@@ -1401,9 +1401,9 @@ BeginCopyFrom(ParseState *pstate,
defmap = (int *) palloc(num_phys_attrs * sizeof(int));
defexprs = (ExprState **) palloc(num_phys_attrs * sizeof(ExprState *));
- for (attnum = 1; attnum <= num_phys_attrs; attnum++)
+ for (attphysnum = 1; attphysnum <= num_phys_attrs; attphysnum++)
{
- Form_pg_attribute att = TupleDescAttr(tupDesc, attnum - 1);
+ Form_pg_attribute att = TupleDescAttr(tupDesc, attphysnum - 1);
/* We don't need info for dropped attributes */
if (att->attisdropped)
@@ -1412,19 +1412,19 @@ BeginCopyFrom(ParseState *pstate,
/* Fetch the input function and typioparam info */
if (cstate->opts.binary)
getTypeBinaryInputInfo(att->atttypid,
- &in_func_oid, &typioparams[attnum - 1]);
+ &in_func_oid, &typioparams[attphysnum - 1]);
else
getTypeInputInfo(att->atttypid,
- &in_func_oid, &typioparams[attnum - 1]);
- fmgr_info(in_func_oid, &in_functions[attnum - 1]);
+ &in_func_oid, &typioparams[attphysnum - 1]);
+ fmgr_info(in_func_oid, &in_functions[attphysnum - 1]);
/* Get default info if needed */
- if (!list_member_int(cstate->attnumlist, attnum) && !att->attgenerated)
+ if (!list_member_int(cstate->attnumlist, attphysnum) && !att->attgenerated)
{
/* attribute is NOT to be copied from input */
/* use default value if one exists */
Expr *defexpr = (Expr *) build_column_default(cstate->rel,
- attnum);
+ attphysnum);
if (defexpr != NULL)
{
@@ -1433,7 +1433,7 @@ BeginCopyFrom(ParseState *pstate,
/* Initialize executable expression in copycontext */
defexprs[num_defaults] = ExecInitExpr(defexpr, NULL);
- defmap[num_defaults] = attnum - 1;
+ defmap[num_defaults] = attphysnum - 1;
num_defaults++;
/*
diff --git a/src/backend/commands/copyfromparse.c b/src/backend/commands/copyfromparse.c
index 57813b3458..e9b0b294e9 100644
--- a/src/backend/commands/copyfromparse.c
+++ b/src/backend/commands/copyfromparse.c
@@ -788,9 +788,9 @@ NextCopyFromRawFields(CopyFromState cstate, char ***fields, int *nfields)
fldnum = 0;
foreach(cur, cstate->attnumlist)
{
- int attnum = lfirst_int(cur);
+ int attphysnum = lfirst_int(cur);
char *colName;
- Form_pg_attribute attr = TupleDescAttr(tupDesc, attnum - 1);
+ Form_pg_attribute attr = TupleDescAttr(tupDesc, attphysnum - 1);
Assert(fldnum < cstate->max_fields);
@@ -894,8 +894,8 @@ NextCopyFrom(CopyFromState cstate, ExprContext *econtext,
/* Loop to read the user attributes on the line. */
foreach(cur, cstate->attnumlist)
{
- int attnum = lfirst_int(cur);
- int m = attnum - 1;
+ int attphysnum = lfirst_int(cur);
+ int m = attphysnum - 1;
Form_pg_attribute att = TupleDescAttr(tupDesc, m);
if (fieldno >= fldct)
@@ -991,8 +991,8 @@ NextCopyFrom(CopyFromState cstate, ExprContext *econtext,
foreach(cur, cstate->attnumlist)
{
- int attnum = lfirst_int(cur);
- int m = attnum - 1;
+ int attphysnum = lfirst_int(cur);
+ int m = attphysnum - 1;
Form_pg_attribute att = TupleDescAttr(tupDesc, m);
cstate->cur_attname = NameStr(att->attname);
diff --git a/src/backend/commands/copyto.c b/src/backend/commands/copyto.c
index fca29a9a10..e0306cc11b 100644
--- a/src/backend/commands/copyto.c
+++ b/src/backend/commands/copyto.c
@@ -579,15 +579,15 @@ BeginCopyTo(ParseState *pstate,
foreach(cur, attnums)
{
- int attnum = lfirst_int(cur);
- Form_pg_attribute attr = TupleDescAttr(tupDesc, attnum - 1);
+ int attphysnum = lfirst_int(cur);
+ Form_pg_attribute attr = TupleDescAttr(tupDesc, attphysnum - 1);
- if (!list_member_int(cstate->attnumlist, attnum))
+ if (!list_member_int(cstate->attnumlist, attphysnum))
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("FORCE_QUOTE column \"%s\" not referenced by COPY",
NameStr(attr->attname))));
- cstate->opts.force_quote_flags[attnum - 1] = true;
+ cstate->opts.force_quote_flags[attphysnum - 1] = true;
}
}
@@ -602,15 +602,15 @@ BeginCopyTo(ParseState *pstate,
foreach(cur, attnums)
{
- int attnum = lfirst_int(cur);
- Form_pg_attribute attr = TupleDescAttr(tupDesc, attnum - 1);
+ int attphysnum = lfirst_int(cur);
+ Form_pg_attribute attr = TupleDescAttr(tupDesc, attphysnum - 1);
- if (!list_member_int(cstate->attnumlist, attnum))
+ if (!list_member_int(cstate->attnumlist, attphysnum))
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("FORCE_NOT_NULL column \"%s\" not referenced by COPY",
NameStr(attr->attname))));
- cstate->opts.force_notnull_flags[attnum - 1] = true;
+ cstate->opts.force_notnull_flags[attphysnum - 1] = true;
}
}
@@ -625,15 +625,15 @@ BeginCopyTo(ParseState *pstate,
foreach(cur, attnums)
{
- int attnum = lfirst_int(cur);
- Form_pg_attribute attr = TupleDescAttr(tupDesc, attnum - 1);
+ int attphysnum = lfirst_int(cur);
+ Form_pg_attribute attr = TupleDescAttr(tupDesc, attphysnum - 1);
- if (!list_member_int(cstate->attnumlist, attnum))
+ if (!list_member_int(cstate->attnumlist, attphysnum))
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("FORCE_NULL column \"%s\" not referenced by COPY",
NameStr(attr->attname))));
- cstate->opts.force_null_flags[attnum - 1] = true;
+ cstate->opts.force_null_flags[attphysnum - 1] = true;
}
}
@@ -793,10 +793,10 @@ DoCopyTo(CopyToState cstate)
cstate->out_functions = (FmgrInfo *) palloc(num_phys_attrs * sizeof(FmgrInfo));
foreach(cur, cstate->attnumlist)
{
- int attnum = lfirst_int(cur);
+ int attphysnum = lfirst_int(cur);
Oid out_func_oid;
bool isvarlena;
- Form_pg_attribute attr = TupleDescAttr(tupDesc, attnum - 1);
+ Form_pg_attribute attr = TupleDescAttr(tupDesc, attphysnum - 1);
if (cstate->opts.binary)
getTypeBinaryOutputInfo(attr->atttypid,
@@ -806,7 +806,7 @@ DoCopyTo(CopyToState cstate)
getTypeOutputInfo(attr->atttypid,
&out_func_oid,
&isvarlena);
- fmgr_info(out_func_oid, &cstate->out_functions[attnum - 1]);
+ fmgr_info(out_func_oid, &cstate->out_functions[attphysnum - 1]);
}
/*
@@ -851,14 +851,14 @@ DoCopyTo(CopyToState cstate)
foreach(cur, cstate->attnumlist)
{
- int attnum = lfirst_int(cur);
+ int attphysnum = lfirst_int(cur);
char *colname;
if (hdr_delim)
CopySendChar(cstate, cstate->opts.delim[0]);
hdr_delim = true;
- colname = NameStr(TupleDescAttr(tupDesc, attnum - 1)->attname);
+ colname = NameStr(TupleDescAttr(tupDesc, attphysnum - 1)->attname);
if (cstate->opts.csv_mode)
CopyAttributeOutCSV(cstate, colname, false,
@@ -950,9 +950,9 @@ CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot)
foreach(cur, cstate->attnumlist)
{
- int attnum = lfirst_int(cur);
- Datum value = slot->tts_values[attnum - 1];
- bool isnull = slot->tts_isnull[attnum - 1];
+ int attphysnum = lfirst_int(cur);
+ Datum value = slot->tts_values[attphysnum - 1];
+ bool isnull = slot->tts_isnull[attphysnum - 1];
if (!cstate->opts.binary)
{
@@ -972,11 +972,11 @@ CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot)
{
if (!cstate->opts.binary)
{
- string = OutputFunctionCall(&out_functions[attnum - 1],
+ string = OutputFunctionCall(&out_functions[attphysnum - 1],
value);
if (cstate->opts.csv_mode)
CopyAttributeOutCSV(cstate, string,
- cstate->opts.force_quote_flags[attnum - 1],
+ cstate->opts.force_quote_flags[attphysnum - 1],
list_length(cstate->attnumlist) == 1);
else
CopyAttributeOutText(cstate, string);
@@ -985,7 +985,7 @@ CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot)
{
bytea *outputbytes;
- outputbytes = SendFunctionCall(&out_functions[attnum - 1],
+ outputbytes = SendFunctionCall(&out_functions[attphysnum - 1],
value);
CopySendInt32(cstate, VARSIZE(outputbytes) - VARHDRSZ);
CopySendData(cstate, VARDATA(outputbytes),
diff --git a/src/backend/commands/createas.c b/src/backend/commands/createas.c
index 9abbb6b555..ec046d77cf 100644
--- a/src/backend/commands/createas.c
+++ b/src/backend/commands/createas.c
@@ -453,7 +453,7 @@ intorel_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
ObjectAddress intoRelationAddr;
Relation intoRelationDesc;
ListCell *lc;
- int attnum;
+ int attphysnum;
Assert(into != NULL); /* else somebody forgot to set it */
@@ -468,9 +468,9 @@ intorel_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
*/
attrList = NIL;
lc = list_head(into->colNames);
- for (attnum = 0; attnum < typeinfo->natts; attnum++)
+ for (attphysnum = 0; attphysnum < typeinfo->natts; attphysnum++)
{
- Form_pg_attribute attribute = TupleDescAttr(typeinfo, attnum);
+ Form_pg_attribute attribute = TupleDescAttr(typeinfo, attphysnum);
ColumnDef *col;
char *colname;
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index 4642527881..2b3dbfbcb1 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -1211,14 +1211,14 @@ EventTriggerSQLDropAddObject(const ObjectAddress *object, bool original, bool no
if (tuple)
{
- AttrNumber attnum;
+ AttrNumber attphysnum;
Datum datum;
bool isnull;
- attnum = get_object_attnum_namespace(obj->address.classId);
- if (attnum != InvalidAttrNumber)
+ attphysnum = get_object_attnum_namespace(obj->address.classId);
+ if (attphysnum != InvalidAttrNumber)
{
- datum = heap_getattr(tuple, attnum,
+ datum = heap_getattr(tuple, attphysnum,
RelationGetDescr(catalog), &isnull);
if (!isnull)
{
@@ -1249,10 +1249,10 @@ EventTriggerSQLDropAddObject(const ObjectAddress *object, bool original, bool no
if (get_object_namensp_unique(obj->address.classId) &&
obj->address.objectSubId == 0)
{
- attnum = get_object_attnum_name(obj->address.classId);
- if (attnum != InvalidAttrNumber)
+ attphysnum = get_object_attnum_name(obj->address.classId);
+ if (attphysnum != InvalidAttrNumber)
{
- datum = heap_getattr(tuple, attnum,
+ datum = heap_getattr(tuple, attphysnum,
RelationGetDescr(catalog), &isnull);
if (!isnull)
obj->objname = pstrdup(NameStr(*DatumGetName(datum)));
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index eac13ac0b7..52e2aa87c6 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -1798,7 +1798,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
attribute->name)));
}
attform = (Form_pg_attribute) GETSTRUCT(atttuple);
- indexInfo->ii_IndexAttrNumbers[attn] = attform->attnum;
+ indexInfo->ii_IndexAttrNumbers[attn] = attform->attphysnum;
atttype = attform->atttypid;
attcollation = attform->attcollation;
ReleaseSysCache(atttuple);
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c
index d1ee106465..47ea6f6246 100644
--- a/src/backend/commands/matview.c
+++ b/src/backend/commands/matview.c
@@ -705,9 +705,9 @@ refresh_by_match_merge(Oid matviewOid, Oid tempOid, Oid relowner,
/* Add quals for all columns from this index. */
for (i = 0; i < indnkeyatts; i++)
{
- int attnum = indexStruct->indkey.values[i];
+ int attphysnum = indexStruct->indkey.values[i];
Oid opclass = indclass->values[i];
- Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1);
+ Form_pg_attribute attr = TupleDescAttr(tupdesc, attphysnum - 1);
Oid attrtype = attr->atttypid;
HeapTuple cla_ht;
Form_pg_opclass cla_tup;
@@ -747,9 +747,9 @@ refresh_by_match_merge(Oid matviewOid, Oid tempOid, Oid relowner,
* that's so unlikely it doesn't seem worth spending extra
* code to avoid.
*/
- if (opUsedForQual[attnum - 1] == op)
+ if (opUsedForQual[attphysnum - 1] == op)
continue;
- opUsedForQual[attnum - 1] = op;
+ opUsedForQual[attphysnum - 1] = op;
/*
* Actually add the qual, ANDed with any others.
@@ -894,9 +894,9 @@ is_usable_unique_index(Relation indexRel)
for (i = 0; i < numatts; i++)
{
- int attnum = indexStruct->indkey.values[i];
+ int attphysnum = indexStruct->indkey.values[i];
- if (attnum <= 0)
+ if (attphysnum <= 0)
return false;
}
return true;
diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index 8e645741e4..4a4c6ffac5 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -265,7 +265,7 @@ contain_invalid_rfcolumn_walker(Node *node, rf_context *context)
if (IsA(node, Var))
{
Var *var = (Var *) node;
- AttrNumber attnum = var->varattno;
+ AttrNumber attphysnum = var->varattno;
/*
* If pubviaroot is true, we are validating the row filter of the
@@ -275,12 +275,12 @@ contain_invalid_rfcolumn_walker(Node *node, rf_context *context)
*/
if (context->pubviaroot)
{
- char *colname = get_attname(context->parentid, attnum, false);
+ char *colname = get_attname(context->parentid, attphysnum, false);
- attnum = get_attnum(context->relid, colname);
+ attphysnum = get_attphysnum(context->relid, colname);
}
- if (!bms_is_member(attnum - FirstLowInvalidHeapAttributeNumber,
+ if (!bms_is_member(attphysnum - FirstLowInvalidHeapAttributeNumber,
context->bms_replident))
return true;
}
@@ -436,7 +436,7 @@ pub_collist_contains_invalid_column(Oid pubid, Relation relation, List *ancestor
x = -1;
while ((x = bms_next_member(idattrs, x)) >= 0)
{
- AttrNumber attnum = (x + FirstLowInvalidHeapAttributeNumber);
+ AttrNumber attphysnum = (x + FirstLowInvalidHeapAttributeNumber);
/*
* If pubviaroot is true, we are validating the column list of the
@@ -448,17 +448,17 @@ pub_collist_contains_invalid_column(Oid pubid, Relation relation, List *ancestor
if (pubviaroot)
{
/* attribute name in the child table */
- char *colname = get_attname(relid, attnum, false);
+ char *colname = get_attname(relid, attphysnum, false);
/*
- * Determine the attnum for the attribute name in parent (we
+ * Determine the attphysnum for the attribute name in parent (we
* are using the column list defined on the parent).
*/
- attnum = get_attnum(publish_as_relid, colname);
+ attphysnum = get_attphysnum(publish_as_relid, colname);
}
/* replica identity column, not covered by the column list */
- if (!bms_is_member(attnum, columns))
+ if (!bms_is_member(attphysnum, columns))
{
result = true;
break;
@@ -1228,9 +1228,9 @@ AlterPublicationTables(AlterPublicationStmt *stmt, HeapTuple tup,
foreach(lc, newpubrel->columns)
{
char *colname = strVal(lfirst(lc));
- AttrNumber attnum = get_attnum(newrelid, colname);
+ AttrNumber attphysnum = get_attphysnum(newrelid, colname);
- newcolumns = bms_add_member(newcolumns, attnum);
+ newcolumns = bms_add_member(newcolumns, attphysnum);
}
}
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index ddf219b21f..0fb47c6d81 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -1595,7 +1595,7 @@ process_owned_by(Relation seqrel, List *owned_by, bool for_identity)
DependencyType deptype;
int nnames;
Relation tablerel;
- AttrNumber attnum;
+ AttrNumber attphysnum;
deptype = for_identity ? DEPENDENCY_INTERNAL : DEPENDENCY_AUTO;
@@ -1610,7 +1610,7 @@ process_owned_by(Relation seqrel, List *owned_by, bool for_identity)
errmsg("invalid OWNED BY option"),
errhint("Specify OWNED BY table.column or OWNED BY NONE.")));
tablerel = NULL;
- attnum = 0;
+ attphysnum = 0;
}
else
{
@@ -1648,8 +1648,8 @@ process_owned_by(Relation seqrel, List *owned_by, bool for_identity)
errmsg("sequence must be in same schema as table it is linked to")));
/* Now, fetch the attribute number from the system cache */
- attnum = get_attnum(RelationGetRelid(tablerel), attrname);
- if (attnum == InvalidAttrNumber)
+ attphysnum = get_attphysnum(RelationGetRelid(tablerel), attrname);
+ if (attphysnum == InvalidAttrNumber)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
@@ -1687,7 +1687,7 @@ process_owned_by(Relation seqrel, List *owned_by, bool for_identity)
refobject.classId = RelationRelationId;
refobject.objectId = RelationGetRelid(tablerel);
- refobject.objectSubId = attnum;
+ refobject.objectSubId = attphysnum;
depobject.classId = RelationRelationId;
depobject.objectId = RelationGetRelid(seqrel);
depobject.objectSubId = 0;
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index 2e716743dd..737ee30e64 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -241,7 +241,7 @@ CreateStatistics(CreateStatsStmt *stmt)
attForm = (Form_pg_attribute) GETSTRUCT(atttuple);
/* Disallow use of system attributes in extended stats */
- if (attForm->attnum <= 0)
+ if (attForm->attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("statistics creation on system columns is not supported")));
@@ -254,7 +254,7 @@ CreateStatistics(CreateStatsStmt *stmt)
errmsg("column \"%s\" cannot be used in statistics because its type %s has no default btree operator class",
attname, format_type_be(attForm->atttypid))));
- attnums[nattnums] = attForm->attnum;
+ attnums[nattnums] = attForm->attphysnum;
nattnums++;
ReleaseSysCache(atttuple);
}
@@ -296,9 +296,9 @@ CreateStatistics(CreateStatsStmt *stmt)
k = -1;
while ((k = bms_next_member(attnums, k)) >= 0)
{
- AttrNumber attnum = k + FirstLowInvalidHeapAttributeNumber;
+ AttrNumber attphysnum = k + FirstLowInvalidHeapAttributeNumber;
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("statistics creation on system columns is not supported")));
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 2de0ebacec..ff9a9fc911 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -219,7 +219,7 @@ typedef struct NewConstraint
*/
typedef struct NewColumnValue
{
- AttrNumber attnum; /* which column */
+ AttrNumber attphysnum; /* which column */
Expr *expr; /* expression to compute */
ExprState *exprstate; /* execution state */
bool is_generated; /* is it a GENERATED expression? */
@@ -427,8 +427,8 @@ static ObjectAddress ATExecAddColumn(List **wqueue, AlteredTableInfo *tab,
AlterTableUtilityContext *context);
static bool check_for_column_name_collision(Relation rel, const char *colname,
bool if_not_exists);
-static void add_column_datatype_dependency(Oid relid, int32 attnum, Oid typid);
-static void add_column_collation_dependency(Oid relid, int32 attnum, Oid collid);
+static void add_column_datatype_dependency(Oid relid, int32 attphysnum, Oid typid);
+static void add_column_collation_dependency(Oid relid, int32 attphysnum, Oid collid);
static void ATPrepDropNotNull(Relation rel, bool recurse, bool recursing);
static ObjectAddress ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode);
static void ATPrepSetNotNull(List **wqueue, Relation rel,
@@ -444,7 +444,7 @@ static bool ConstraintImpliedByRelConstraint(Relation scanrel,
List *testConstraint, List *provenConstraint);
static ObjectAddress ATExecColumnDefault(Relation rel, const char *colName,
Node *newDefault, LOCKMODE lockmode);
-static ObjectAddress ATExecCookedColumnDefault(Relation rel, AttrNumber attnum,
+static ObjectAddress ATExecCookedColumnDefault(Relation rel, AttrNumber attphysnum,
Node *newDefault);
static ObjectAddress ATExecAddIdentity(Relation rel, const char *colName,
Node *def, LOCKMODE lockmode);
@@ -670,7 +670,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
List *cookedDefaults;
Datum reloptions;
ListCell *listptr;
- AttrNumber attnum;
+ AttrNumber attphysnum;
bool partitioned;
static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
Oid ofTypeId;
@@ -880,15 +880,15 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
*/
rawDefaults = NIL;
cookedDefaults = NIL;
- attnum = 0;
+ attphysnum = 0;
foreach(listptr, stmt->tableElts)
{
ColumnDef *colDef = lfirst(listptr);
Form_pg_attribute attr;
- attnum++;
- attr = TupleDescAttr(descriptor, attnum - 1);
+ attphysnum++;
+ attr = TupleDescAttr(descriptor, attphysnum - 1);
if (colDef->raw_default != NULL)
{
@@ -897,7 +897,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
Assert(colDef->cooked_default == NULL);
rawEnt = (RawColumnDefault *) palloc(sizeof(RawColumnDefault));
- rawEnt->attnum = attnum;
+ rawEnt->attphysnum = attphysnum;
rawEnt->raw_default = colDef->raw_default;
rawEnt->missingMode = false;
rawEnt->generated = colDef->generated;
@@ -912,7 +912,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
cooked->contype = CONSTR_DEFAULT;
cooked->conoid = InvalidOid; /* until created */
cooked->name = NULL;
- cooked->attnum = attnum;
+ cooked->attphysnum = attphysnum;
cooked->expr = colDef->cooked_default;
cooked->skip_validation = false;
cooked->is_local = true; /* not used for defaults */
@@ -2774,7 +2774,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
cooked->contype = CONSTR_CHECK;
cooked->conoid = InvalidOid; /* until created */
cooked->name = pstrdup(name);
- cooked->attnum = 0; /* not used for constraints */
+ cooked->attphysnum = 0; /* not used for constraints */
cooked->expr = expr;
cooked->skip_validation = false;
cooked->is_local = false;
@@ -3432,7 +3432,7 @@ renameatt_internal(Oid myrelid,
Relation attrelation;
HeapTuple atttup;
Form_pg_attribute attform;
- AttrNumber attnum;
+ AttrNumber attphysnum;
/*
* Grab an exclusive lock on the target table, which we will NOT release
@@ -3520,8 +3520,8 @@ renameatt_internal(Oid myrelid,
oldattname)));
attform = (Form_pg_attribute) GETSTRUCT(atttup);
- attnum = attform->attnum;
- if (attnum <= 0)
+ attphysnum = attform->attphysnum;
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot rename system column \"%s\"",
@@ -3550,7 +3550,7 @@ renameatt_internal(Oid myrelid,
CatalogTupleUpdate(attrelation, &atttup->t_self, atttup);
- InvokeObjectPostAlterHook(RelationRelationId, myrelid, attnum);
+ InvokeObjectPostAlterHook(RelationRelationId, myrelid, attphysnum);
heap_freetuple(atttup);
@@ -3558,7 +3558,7 @@ renameatt_internal(Oid myrelid,
relation_close(targetrelation, NoLock); /* close rel but keep lock */
- return attnum;
+ return attphysnum;
}
/*
@@ -3588,7 +3588,7 @@ ObjectAddress
renameatt(RenameStmt *stmt)
{
Oid relid;
- AttrNumber attnum;
+ AttrNumber attphysnum;
ObjectAddress address;
/* lock level taken here should match renameatt_internal */
@@ -3605,7 +3605,7 @@ renameatt(RenameStmt *stmt)
return InvalidObjectAddress;
}
- attnum =
+ attphysnum =
renameatt_internal(relid,
stmt->subname, /* old att name */
stmt->newname, /* new att name */
@@ -3614,7 +3614,7 @@ renameatt(RenameStmt *stmt)
0, /* expected inhcount */
stmt->behavior);
- ObjectAddressSubSet(address, RelationRelationId, relid, attnum);
+ ObjectAddressSubSet(address, RelationRelationId, relid, attphysnum);
return address;
}
@@ -5899,10 +5899,10 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
if (ex->is_generated)
continue;
- newslot->tts_values[ex->attnum - 1]
+ newslot->tts_values[ex->attphysnum - 1]
= ExecEvalExpr(ex->exprstate,
econtext,
- &newslot->tts_isnull[ex->attnum - 1]);
+ &newslot->tts_isnull[ex->attphysnum - 1]);
}
ExecStoreVirtualTuple(newslot);
@@ -5921,10 +5921,10 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
if (!ex->is_generated)
continue;
- newslot->tts_values[ex->attnum - 1]
+ newslot->tts_values[ex->attphysnum - 1]
= ExecEvalExpr(ex->exprstate,
econtext,
- &newslot->tts_isnull[ex->attnum - 1]);
+ &newslot->tts_isnull[ex->attphysnum - 1]);
}
insertslot = newslot;
@@ -6814,7 +6814,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
attribute.atttypid = typeOid;
attribute.attstattarget = (newattnum > 0) ? -1 : 0;
attribute.attlen = tform->typlen;
- attribute.attnum = newattnum;
+ attribute.attphysnum = newattnum;
attribute.attndims = list_length(colDef->typeName->arrayBounds);
attribute.atttypmod = typmod;
attribute.attbyval = tform->typbyval;
@@ -6865,7 +6865,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
RawColumnDefault *rawEnt;
rawEnt = (RawColumnDefault *) palloc(sizeof(RawColumnDefault));
- rawEnt->attnum = attribute.attnum;
+ rawEnt->attphysnum = attribute.attphysnum;
rawEnt->raw_default = copyObject(colDef->raw_default);
/*
@@ -6900,7 +6900,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
*
* If there is no default, Phase 3 doesn't have to do anything, because
* that effectively means that the default is NULL. The heap tuple access
- * routines always check for attnum > # of attributes in tuple, and return
+ * routines always check for attphysnum > # of attributes in tuple, and return
* NULL if so, so without any modification of the tuple data we will get
* the effect of NULL values in the new column.
*
@@ -6928,7 +6928,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
* is certainly not going to touch them. System attributes don't have
* interesting defaults, either.
*/
- if (RELKIND_HAS_STORAGE(relkind) && attribute.attnum > 0)
+ if (RELKIND_HAS_STORAGE(relkind) && attribute.attphysnum > 0)
{
/*
* For an identity column, we can't use build_column_default(),
@@ -6947,7 +6947,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
tab->rewrite |= AT_REWRITE_DEFAULT_VAL;
}
else
- defval = (Expr *) build_column_default(rel, attribute.attnum);
+ defval = (Expr *) build_column_default(rel, attribute.attphysnum);
if (!defval && DomainHasConstraints(typeOid))
{
@@ -6976,7 +6976,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
NewColumnValue *newval;
newval = (NewColumnValue *) palloc0(sizeof(NewColumnValue));
- newval->attnum = attribute.attnum;
+ newval->attphysnum = attribute.attphysnum;
newval->expr = expression_planner(defval);
newval->is_generated = (colDef->generated != '\0');
@@ -6986,7 +6986,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
if (DomainHasConstraints(typeOid))
tab->rewrite |= AT_REWRITE_DEFAULT_VAL;
- if (!TupleDescAttr(rel->rd_att, attribute.attnum - 1)->atthasmissing)
+ if (!TupleDescAttr(rel->rd_att, attribute.attphysnum - 1)->atthasmissing)
{
/*
* If the new column is NOT NULL, and there is no missing value,
@@ -7064,7 +7064,7 @@ check_for_column_name_collision(Relation rel, const char *colname,
bool if_not_exists)
{
HeapTuple attTuple;
- int attnum;
+ int attphysnum;
/*
* this test is deliberately not attisdropped-aware, since if one tries to
@@ -7076,7 +7076,7 @@ check_for_column_name_collision(Relation rel, const char *colname,
if (!HeapTupleIsValid(attTuple))
return true;
- attnum = ((Form_pg_attribute) GETSTRUCT(attTuple))->attnum;
+ attphysnum = ((Form_pg_attribute) GETSTRUCT(attTuple))->attphysnum;
ReleaseSysCache(attTuple);
/*
@@ -7084,7 +7084,7 @@ check_for_column_name_collision(Relation rel, const char *colname,
* names, since they are normally not shown and the user might otherwise
* be confused about the reason for the conflict.
*/
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column name \"%s\" conflicts with a system column name",
@@ -7113,14 +7113,14 @@ check_for_column_name_collision(Relation rel, const char *colname,
* Install a column's dependency on its datatype.
*/
static void
-add_column_datatype_dependency(Oid relid, int32 attnum, Oid typid)
+add_column_datatype_dependency(Oid relid, int32 attphysnum, Oid typid)
{
ObjectAddress myself,
referenced;
myself.classId = RelationRelationId;
myself.objectId = relid;
- myself.objectSubId = attnum;
+ myself.objectSubId = attphysnum;
referenced.classId = TypeRelationId;
referenced.objectId = typid;
referenced.objectSubId = 0;
@@ -7131,7 +7131,7 @@ add_column_datatype_dependency(Oid relid, int32 attnum, Oid typid)
* Install a column's dependency on its collation.
*/
static void
-add_column_collation_dependency(Oid relid, int32 attnum, Oid collid)
+add_column_collation_dependency(Oid relid, int32 attphysnum, Oid collid)
{
ObjectAddress myself,
referenced;
@@ -7141,7 +7141,7 @@ add_column_collation_dependency(Oid relid, int32 attnum, Oid collid)
{
myself.classId = RelationRelationId;
myself.objectId = relid;
- myself.objectSubId = attnum;
+ myself.objectSubId = attphysnum;
referenced.classId = CollationRelationId;
referenced.objectId = collid;
referenced.objectSubId = 0;
@@ -7182,7 +7182,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
{
HeapTuple tuple;
Form_pg_attribute attTup;
- AttrNumber attnum;
+ AttrNumber attphysnum;
Relation attr_rel;
List *indexoidlist;
ListCell *indexoidscan;
@@ -7200,10 +7200,10 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
attTup = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = attTup->attnum;
+ attphysnum = attTup->attphysnum;
/* Prevent them from altering a system attribute */
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter system column \"%s\"",
@@ -7250,7 +7250,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
*/
for (i = 0; i < indexStruct->indnkeyatts; i++)
{
- if (indexStruct->indkey.values[i] == attnum)
+ if (indexStruct->indkey.values[i] == attphysnum)
{
if (indexStruct->indisprimary)
ereport(ERROR,
@@ -7279,7 +7279,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
TupleDesc tupDesc = RelationGetDescr(parent);
AttrNumber parent_attnum;
- parent_attnum = get_attnum(parentId, colName);
+ parent_attnum = get_attphysnum(parentId, colName);
if (TupleDescAttr(tupDesc, parent_attnum - 1)->attnotnull)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -7298,13 +7298,13 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple);
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
}
else
address = InvalidObjectAddress;
InvokeObjectPostAlterHook(RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
table_close(attr_rel, RowExclusiveLock);
@@ -7389,7 +7389,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
const char *colName, LOCKMODE lockmode)
{
HeapTuple tuple;
- AttrNumber attnum;
+ AttrNumber attphysnum;
Relation attr_rel;
ObjectAddress address;
@@ -7406,10 +7406,10 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attnum;
+ attphysnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attphysnum;
/* Prevent them from altering a system attribute */
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter system column \"%s\"",
@@ -7438,13 +7438,13 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
}
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
}
else
address = InvalidObjectAddress;
InvokeObjectPostAlterHook(RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
table_close(attr_rel, RowExclusiveLock);
@@ -7501,7 +7501,7 @@ NotNullImpliedByRelConstraints(Relation rel, Form_pg_attribute attr)
NullTest *nnulltest = makeNode(NullTest);
nnulltest->arg = (Expr *) makeVar(1,
- attr->attnum,
+ attr->attphysnum,
attr->atttypid,
attr->atttypmod,
attr->attcollation,
@@ -7537,39 +7537,39 @@ ATExecColumnDefault(Relation rel, const char *colName,
Node *newDefault, LOCKMODE lockmode)
{
TupleDesc tupdesc = RelationGetDescr(rel);
- AttrNumber attnum;
+ AttrNumber attphysnum;
ObjectAddress address;
/*
* get the number of the attribute
*/
- attnum = get_attnum(RelationGetRelid(rel), colName);
- if (attnum == InvalidAttrNumber)
+ attphysnum = get_attphysnum(RelationGetRelid(rel), colName);
+ if (attphysnum == InvalidAttrNumber)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
/* Prevent them from altering a system attribute */
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter system column \"%s\"",
colName)));
- if (TupleDescAttr(tupdesc, attnum - 1)->attidentity)
+ if (TupleDescAttr(tupdesc, attphysnum - 1)->attidentity)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("column \"%s\" of relation \"%s\" is an identity column",
colName, RelationGetRelationName(rel)),
newDefault ? 0 : errhint("Use ALTER TABLE ... ALTER COLUMN ... DROP IDENTITY instead.")));
- if (TupleDescAttr(tupdesc, attnum - 1)->attgenerated)
+ if (TupleDescAttr(tupdesc, attphysnum - 1)->attgenerated)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("column \"%s\" of relation \"%s\" is a generated column",
colName, RelationGetRelationName(rel)),
- newDefault || TupleDescAttr(tupdesc, attnum - 1)->attgenerated != ATTRIBUTE_GENERATED_STORED ? 0 :
+ newDefault || TupleDescAttr(tupdesc, attphysnum - 1)->attgenerated != ATTRIBUTE_GENERATED_STORED ? 0 :
errhint("Use ALTER TABLE ... ALTER COLUMN ... DROP EXPRESSION instead.")));
/*
@@ -7581,7 +7581,7 @@ ATExecColumnDefault(Relation rel, const char *colName,
* is preparatory to adding a new default, but as a user-initiated
* operation when the user asked for a drop.
*/
- RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, false,
+ RemoveAttrDefault(RelationGetRelid(rel), attphysnum, DROP_RESTRICT, false,
newDefault != NULL);
if (newDefault)
@@ -7590,7 +7590,7 @@ ATExecColumnDefault(Relation rel, const char *colName,
RawColumnDefault *rawEnt;
rawEnt = (RawColumnDefault *) palloc(sizeof(RawColumnDefault));
- rawEnt->attnum = attnum;
+ rawEnt->attphysnum = attphysnum;
rawEnt->raw_default = newDefault;
rawEnt->missingMode = false;
rawEnt->generated = '\0';
@@ -7604,7 +7604,7 @@ ATExecColumnDefault(Relation rel, const char *colName,
}
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
return address;
}
@@ -7614,7 +7614,7 @@ ATExecColumnDefault(Relation rel, const char *colName,
* Return the address of the affected column.
*/
static ObjectAddress
-ATExecCookedColumnDefault(Relation rel, AttrNumber attnum,
+ATExecCookedColumnDefault(Relation rel, AttrNumber attphysnum,
Node *newDefault)
{
ObjectAddress address;
@@ -7627,13 +7627,13 @@ ATExecCookedColumnDefault(Relation rel, AttrNumber attnum,
* default. (In ordinary cases, there could not be a default in place
* anyway, but it's possible when combining LIKE with inheritance.)
*/
- RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, false,
+ RemoveAttrDefault(RelationGetRelid(rel), attphysnum, DROP_RESTRICT, false,
true);
- (void) StoreAttrDefault(rel, attnum, newDefault, true, false);
+ (void) StoreAttrDefault(rel, attphysnum, newDefault, true, false);
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
return address;
}
@@ -7649,7 +7649,7 @@ ATExecAddIdentity(Relation rel, const char *colName,
Relation attrelation;
HeapTuple tuple;
Form_pg_attribute attTup;
- AttrNumber attnum;
+ AttrNumber attphysnum;
ObjectAddress address;
ColumnDef *cdef = castNode(ColumnDef, def);
@@ -7662,10 +7662,10 @@ ATExecAddIdentity(Relation rel, const char *colName,
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
attTup = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = attTup->attnum;
+ attphysnum = attTup->attphysnum;
/* Can't alter a system attribute */
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter system column \"%s\"",
@@ -7699,9 +7699,9 @@ ATExecAddIdentity(Relation rel, const char *colName,
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel),
- attTup->attnum);
+ attTup->attphysnum);
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
heap_freetuple(tuple);
table_close(attrelation, RowExclusiveLock);
@@ -7721,7 +7721,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
DefElem *generatedEl = NULL;
HeapTuple tuple;
Form_pg_attribute attTup;
- AttrNumber attnum;
+ AttrNumber attphysnum;
Relation attrelation;
ObjectAddress address;
@@ -7757,9 +7757,9 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
colName, RelationGetRelationName(rel))));
attTup = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = attTup->attnum;
+ attphysnum = attTup->attphysnum;
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter system column \"%s\"",
@@ -7778,9 +7778,9 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel),
- attTup->attnum);
+ attTup->attphysnum);
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
}
else
address = InvalidObjectAddress;
@@ -7801,7 +7801,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
{
HeapTuple tuple;
Form_pg_attribute attTup;
- AttrNumber attnum;
+ AttrNumber attphysnum;
Relation attrelation;
ObjectAddress address;
Oid seqid;
@@ -7816,9 +7816,9 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
colName, RelationGetRelationName(rel))));
attTup = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = attTup->attnum;
+ attphysnum = attTup->attphysnum;
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter system column \"%s\"",
@@ -7847,15 +7847,15 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel),
- attTup->attnum);
+ attTup->attphysnum);
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
heap_freetuple(tuple);
table_close(attrelation, RowExclusiveLock);
/* drop the internal sequence */
- seqid = getIdentitySequence(RelationGetRelid(rel), attnum, false);
+ seqid = getIdentitySequence(RelationGetRelid(rel), attphysnum, false);
deleteDependencyRecordsForClass(RelationRelationId, seqid,
RelationRelationId, DEPENDENCY_INTERNAL);
CommandCounterIncrement();
@@ -7921,7 +7921,7 @@ ATExecDropExpression(Relation rel, const char *colName, bool missing_ok, LOCKMOD
{
HeapTuple tuple;
Form_pg_attribute attTup;
- AttrNumber attnum;
+ AttrNumber attphysnum;
Relation attrelation;
Oid attrdefoid;
ObjectAddress address;
@@ -7935,9 +7935,9 @@ ATExecDropExpression(Relation rel, const char *colName, bool missing_ok, LOCKMOD
colName, RelationGetRelationName(rel))));
attTup = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = attTup->attnum;
+ attphysnum = attTup->attphysnum;
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter system column \"%s\"",
@@ -7970,7 +7970,7 @@ ATExecDropExpression(Relation rel, const char *colName, bool missing_ok, LOCKMOD
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel),
- attnum);
+ attphysnum);
heap_freetuple(tuple);
table_close(attrelation, RowExclusiveLock);
@@ -7980,10 +7980,10 @@ ATExecDropExpression(Relation rel, const char *colName, bool missing_ok, LOCKMOD
* its INTERNAL dependency on the column, which would otherwise cause
* dependency.c to refuse to perform the deletion.
*/
- attrdefoid = GetAttrDefaultOid(RelationGetRelid(rel), attnum);
+ attrdefoid = GetAttrDefaultOid(RelationGetRelid(rel), attphysnum);
if (!OidIsValid(attrdefoid))
- elog(ERROR, "could not find attrdef tuple for relation %u attnum %d",
- RelationGetRelid(rel), attnum);
+ elog(ERROR, "could not find attrdef tuple for relation %u attphysnum %d",
+ RelationGetRelid(rel), attphysnum);
(void) deleteDependencyRecordsFor(AttrDefaultRelationId, attrdefoid, false);
/* Make above changes visible */
@@ -7994,11 +7994,11 @@ ATExecDropExpression(Relation rel, const char *colName, bool missing_ok, LOCKMOD
* safety, but at present we do not expect anything to depend on the
* default.
*/
- RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT,
+ RemoveAttrDefault(RelationGetRelid(rel), attphysnum, DROP_RESTRICT,
false, false);
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
return address;
}
@@ -8014,7 +8014,7 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa
Relation attrelation;
HeapTuple tuple;
Form_pg_attribute attrtuple;
- AttrNumber attnum;
+ AttrNumber attphysnum;
ObjectAddress address;
/*
@@ -8075,8 +8075,8 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa
attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = attrtuple->attnum;
- if (attnum <= 0)
+ attphysnum = attrtuple->attphysnum;
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter system column \"%s\"",
@@ -8085,12 +8085,12 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa
if (rel->rd_rel->relkind == RELKIND_INDEX ||
rel->rd_rel->relkind == RELKIND_PARTITIONED_INDEX)
{
- if (attnum > rel->rd_index->indnkeyatts)
+ if (attphysnum > rel->rd_index->indnkeyatts)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter statistics on included column \"%s\" of index \"%s\"",
NameStr(attrtuple->attname), RelationGetRelationName(rel))));
- else if (rel->rd_index->indkey.values[attnum - 1] != 0)
+ else if (rel->rd_index->indkey.values[attphysnum - 1] != 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter statistics on non-expression column \"%s\" of index \"%s\"",
@@ -8104,9 +8104,9 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel),
- attrtuple->attnum);
+ attrtuple->attphysnum);
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
heap_freetuple(tuple);
table_close(attrelation, RowExclusiveLock);
@@ -8125,7 +8125,7 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
HeapTuple tuple,
newtuple;
Form_pg_attribute attrtuple;
- AttrNumber attnum;
+ AttrNumber attphysnum;
Datum datum,
newOptions;
bool isnull;
@@ -8145,8 +8145,8 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
colName, RelationGetRelationName(rel))));
attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = attrtuple->attnum;
- if (attnum <= 0)
+ attphysnum = attrtuple->attphysnum;
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter system column \"%s\"",
@@ -8177,9 +8177,9 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel),
- attrtuple->attnum);
+ attrtuple->attphysnum);
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
heap_freetuple(newtuple);
@@ -8198,7 +8198,7 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
*/
static void
SetIndexStorageProperties(Relation rel, Relation attrelation,
- AttrNumber attnum,
+ AttrNumber attphysnum,
bool setstorage, char newstorage,
bool setcompression, char newcompression,
LOCKMODE lockmode)
@@ -8216,7 +8216,7 @@ SetIndexStorageProperties(Relation rel, Relation attrelation,
for (int i = 0; i < indrel->rd_index->indnatts; i++)
{
- if (indrel->rd_index->indkey.values[i] == attnum)
+ if (indrel->rd_index->indkey.values[i] == attphysnum)
{
indattnum = i + 1;
break;
@@ -8245,7 +8245,7 @@ SetIndexStorageProperties(Relation rel, Relation attrelation,
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel),
- attrtuple->attnum);
+ attrtuple->attphysnum);
heap_freetuple(tuple);
}
@@ -8267,7 +8267,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
Relation attrelation;
HeapTuple tuple;
Form_pg_attribute attrtuple;
- AttrNumber attnum;
+ AttrNumber attphysnum;
ObjectAddress address;
Assert(IsA(newValue, String));
@@ -8301,8 +8301,8 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
colName, RelationGetRelationName(rel))));
attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = attrtuple->attnum;
- if (attnum <= 0)
+ attphysnum = attrtuple->attphysnum;
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter system column \"%s\"",
@@ -8324,7 +8324,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel),
- attrtuple->attnum);
+ attrtuple->attphysnum);
heap_freetuple(tuple);
@@ -8332,7 +8332,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
* Apply the change to indexes as well (only for simple index columns,
* matching behavior of index.c ConstructTupleDescriptor()).
*/
- SetIndexStorageProperties(rel, attrelation, attnum,
+ SetIndexStorageProperties(rel, attrelation, attphysnum,
true, newstorage,
false, 0,
lockmode);
@@ -8340,7 +8340,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
table_close(attrelation, RowExclusiveLock);
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
return address;
}
@@ -8391,7 +8391,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
{
HeapTuple tuple;
Form_pg_attribute targetatt;
- AttrNumber attnum;
+ AttrNumber attphysnum;
List *children;
ObjectAddress object;
bool is_expr;
@@ -8428,10 +8428,10 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
}
targetatt = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = targetatt->attnum;
+ attphysnum = targetatt->attphysnum;
/* Can't drop a system attribute */
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot drop system column \"%s\"",
@@ -8453,7 +8453,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
* of the whole table, which is surely not what the user expected.)
*/
if (has_partition_attrs(rel,
- bms_make_singleton(attnum - FirstLowInvalidHeapAttributeNumber),
+ bms_make_singleton(attphysnum - FirstLowInvalidHeapAttributeNumber),
&is_expr))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -8557,7 +8557,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
/* Add object to delete */
object.classId = RelationRelationId;
object.objectId = RelationGetRelid(rel);
- object.objectSubId = attnum;
+ object.objectSubId = attphysnum;
add_exact_object_address(&object, addrs);
if (!recursing)
@@ -9490,11 +9490,11 @@ validateFkOnDeleteSetColumns(int numfks, const int16 *fkattnums,
* parentConstr is the OID of a parent constraint; InvalidOid if this is a
* top-level constraint.
* numfks is the number of columns in the foreign key
- * pkattnum is the attnum array of referenced attributes.
- * fkattnum is the attnum array of referencing attributes.
+ * pkattnum is the attphysnum array of referenced attributes.
+ * fkattnum is the attphysnum array of referencing attributes.
* numfkdelsetcols is the number of columns in the ON DELETE SET NULL/DELETE
* (...) clause
- * fkdelsetcols is the attnum array of the columns in the ON DELETE SET
+ * fkdelsetcols is the attphysnum array of the columns in the ON DELETE SET
* NULL/DELETE clause
* pf/pp/ffeqoperators are OID array of operators between columns.
* old_check_ok signals that this constraint replaces an existing one that
@@ -9708,12 +9708,12 @@ addFkRecurseReferenced(List **wqueue, Constraint *fkconstraint, Relation rel,
* indexOid is the OID of the index (on pkrel) implementing this constraint.
* parentConstr is the OID of the parent constraint (there is always one).
* numfks is the number of columns in the foreign key
- * pkattnum is the attnum array of referenced attributes.
- * fkattnum is the attnum array of referencing attributes.
+ * pkattnum is the attphysnum array of referenced attributes.
+ * fkattnum is the attphysnum array of referencing attributes.
* pf/pp/ffeqoperators are OID array of operators between columns.
* numfkdelsetcols is the number of columns in the ON DELETE SET NULL/DELETE
* (...) clause
- * fkdelsetcols is the attnum array of the columns in the ON DELETE SET
+ * fkdelsetcols is the attphysnum array of the columns in the ON DELETE SET
* NULL/DELETE clause
* old_check_ok signals that this constraint replaces an existing one that
* was already validated (thus this one doesn't need validation).
@@ -11144,16 +11144,16 @@ ATExecValidateConstraint(List **wqueue, Relation rel, char *constrName,
/*
* transformColumnNameList - transform list of column names
*
- * Lookup each name and return its attnum and, optionally, type OID
+ * Lookup each name and return its attphysnum and, optionally, type OID
*/
static int
transformColumnNameList(Oid relId, List *colList,
int16 *attnums, Oid *atttypids)
{
ListCell *l;
- int attnum;
+ int attphysnum;
- attnum = 0;
+ attphysnum = 0;
foreach(l, colList)
{
char *attname = strVal(lfirst(l));
@@ -11165,19 +11165,19 @@ transformColumnNameList(Oid relId, List *colList,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" referenced in foreign key constraint does not exist",
attname)));
- if (attnum >= INDEX_MAX_KEYS)
+ if (attphysnum >= INDEX_MAX_KEYS)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_COLUMNS),
errmsg("cannot have more than %d keys in a foreign key",
INDEX_MAX_KEYS)));
- attnums[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->attnum;
+ attnums[attphysnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->attphysnum;
if (atttypids != NULL)
- atttypids[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->atttypid;
+ atttypids[attphysnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->atttypid;
ReleaseSysCache(atttuple);
- attnum++;
+ attphysnum++;
}
- return attnum;
+ return attphysnum;
}
/*
@@ -11360,7 +11360,7 @@ transformFkeyCheckAttrs(Relation pkrel,
indclass = (oidvector *) DatumGetPointer(indclassDatum);
/*
- * The given attnum list may match the index columns in any order.
+ * The given attphysnum list may match the index columns in any order.
* Check for a match, and extract the appropriate opclasses while
* we're at it.
*
@@ -12070,7 +12070,7 @@ ATPrepAlterColumnType(List **wqueue,
Node *transform = def->cooked_default;
HeapTuple tuple;
Form_pg_attribute attTup;
- AttrNumber attnum;
+ AttrNumber attphysnum;
Oid targettype;
int32 targettypmod;
Oid targetcollid;
@@ -12092,10 +12092,10 @@ ATPrepAlterColumnType(List **wqueue,
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
attTup = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = attTup->attnum;
+ attphysnum = attTup->attphysnum;
/* Can't alter a system attribute */
- if (attnum <= 0)
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter system column \"%s\"",
@@ -12114,7 +12114,7 @@ ATPrepAlterColumnType(List **wqueue,
/* Don't alter columns used in the partition key */
if (has_partition_attrs(rel,
- bms_make_singleton(attnum - FirstLowInvalidHeapAttributeNumber),
+ bms_make_singleton(attphysnum - FirstLowInvalidHeapAttributeNumber),
&is_expr))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -12150,7 +12150,7 @@ ATPrepAlterColumnType(List **wqueue,
*/
if (!transform)
{
- transform = (Node *) makeVar(1, attnum,
+ transform = (Node *) makeVar(1, attphysnum,
attTup->atttypid, attTup->atttypmod,
attTup->attcollation,
0);
@@ -12195,12 +12195,12 @@ ATPrepAlterColumnType(List **wqueue,
* contents.
*/
newval = (NewColumnValue *) palloc0(sizeof(NewColumnValue));
- newval->attnum = attnum;
+ newval->attphysnum = attphysnum;
newval->expr = (Expr *) transform;
newval->is_generated = false;
tab->newvals = lappend(tab->newvals, newval);
- if (ATColumnChangeRequiresRewrite(transform, attnum))
+ if (ATColumnChangeRequiresRewrite(transform, attphysnum))
tab->rewrite |= AT_REWRITE_COLUMN_REWRITE;
}
else if (transform)
@@ -12394,7 +12394,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
HeapTuple heapTup;
Form_pg_attribute attTup,
attOldTup;
- AttrNumber attnum;
+ AttrNumber attphysnum;
HeapTuple typeTuple;
Form_pg_type tform;
Oid targettype;
@@ -12433,8 +12433,8 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
attTup = (Form_pg_attribute) GETSTRUCT(heapTup);
- attnum = attTup->attnum;
- attOldTup = TupleDescAttr(tab->oldDesc, attnum - 1);
+ attphysnum = attTup->attphysnum;
+ attOldTup = TupleDescAttr(tab->oldDesc, attphysnum - 1);
/* Check for multiple ALTER TYPE on same column --- can't cope */
if (attTup->atttypid != attOldTup->atttypid ||
@@ -12465,7 +12465,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
*/
if (attTup->atthasdef)
{
- defaultexpr = build_column_default(rel, attnum);
+ defaultexpr = build_column_default(rel, attphysnum);
Assert(defaultexpr);
defaultexpr = strip_implicit_coercions(defaultexpr);
defaultexpr = coerce_to_target_type(NULL, /* no UNKNOWN params */
@@ -12513,7 +12513,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
ScanKeyInit(&key[2],
Anum_pg_depend_refobjsubid,
BTEqualStrategyNumber, F_INT4EQ,
- Int32GetDatum((int32) attnum));
+ Int32GetDatum((int32) attphysnum));
scan = systable_beginscan(depRel, DependReferenceIndexId, true,
NULL, 3, key);
@@ -12613,7 +12613,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
ObjectAddress col = GetAttrDefaultColumnAddress(foundObject.objectId);
if (col.objectId == RelationGetRelid(rel) &&
- col.objectSubId == attnum)
+ col.objectSubId == attphysnum)
{
/*
* Ignore the column's own default expression, which
@@ -12719,7 +12719,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
ScanKeyInit(&key[2],
Anum_pg_depend_objsubid,
BTEqualStrategyNumber, F_INT4EQ,
- Int32GetDatum((int32) attnum));
+ Int32GetDatum((int32) attphysnum));
scan = systable_beginscan(depRel, DependDependerIndexId, true,
NULL, 3, key);
@@ -12835,16 +12835,16 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
table_close(attrelation, RowExclusiveLock);
/* Install dependencies on new datatype and collation */
- add_column_datatype_dependency(RelationGetRelid(rel), attnum, targettype);
- add_column_collation_dependency(RelationGetRelid(rel), attnum, targetcollid);
+ add_column_datatype_dependency(RelationGetRelid(rel), attphysnum, targettype);
+ add_column_collation_dependency(RelationGetRelid(rel), attphysnum, targetcollid);
/*
* Drop any pg_statistic entry for the column, since it's now wrong type
*/
- RemoveStatistics(RelationGetRelid(rel), attnum);
+ RemoveStatistics(RelationGetRelid(rel), attphysnum);
InvokeObjectPostAlterHook(RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
/*
* Update the default, if present, by brute force --- remove and re-add
@@ -12862,11 +12862,11 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
*/
if (attTup->attgenerated)
{
- Oid attrdefoid = GetAttrDefaultOid(RelationGetRelid(rel), attnum);
+ Oid attrdefoid = GetAttrDefaultOid(RelationGetRelid(rel), attphysnum);
if (!OidIsValid(attrdefoid))
- elog(ERROR, "could not find attrdef tuple for relation %u attnum %d",
- RelationGetRelid(rel), attnum);
+ elog(ERROR, "could not find attrdef tuple for relation %u attphysnum %d",
+ RelationGetRelid(rel), attphysnum);
(void) deleteDependencyRecordsFor(AttrDefaultRelationId, attrdefoid, false);
}
@@ -12880,14 +12880,14 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
* We use RESTRICT here for safety, but at present we do not expect
* anything to depend on the default.
*/
- RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, true,
+ RemoveAttrDefault(RelationGetRelid(rel), attphysnum, DROP_RESTRICT, true,
true);
- StoreAttrDefault(rel, attnum, defaultexpr, true, false);
+ StoreAttrDefault(rel, attphysnum, defaultexpr, true, false);
}
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
/* Cleanup */
heap_freetuple(heapTup);
@@ -13568,7 +13568,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
Datum datum;
Form_pg_foreign_table fttableform;
Form_pg_attribute atttableform;
- AttrNumber attnum;
+ AttrNumber attphysnum;
ObjectAddress address;
if (options == NIL)
@@ -13599,8 +13599,8 @@ ATExecAlterColumnGenericOptions(Relation rel,
/* Prevent them from altering a system attribute */
atttableform = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = atttableform->attnum;
- if (attnum <= 0)
+ attphysnum = atttableform->attphysnum;
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter system column \"%s\"", colName)));
@@ -13641,9 +13641,9 @@ ATExecAlterColumnGenericOptions(Relation rel,
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel),
- atttableform->attnum);
+ atttableform->attphysnum);
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
ReleaseSysCache(tuple);
@@ -13918,7 +13918,7 @@ change_owner_fix_column_acls(Oid relationOid, Oid oldOwnerId, Oid newOwnerId)
Anum_pg_attribute_attrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relationOid));
- scan = systable_beginscan(attRelation, AttributeRelidNumIndexId,
+ scan = systable_beginscan(attRelation, AttributeRelidPhysNumIndexId,
true, NULL, 1, key);
while (HeapTupleIsValid(attributeTuple = systable_getnext(scan)))
{
@@ -15062,7 +15062,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
for (int i = 0; i < child_constr->num_defval; i++)
{
- if (child_constr->defval[i].adnum == childatt->attnum)
+ if (child_constr->defval[i].adnum == childatt->attphysnum)
{
child_expr =
TextDatumGetCString(DirectFunctionCall2(pg_get_expr,
@@ -15075,7 +15075,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
for (int i = 0; i < parent_constr->num_defval; i++)
{
- if (parent_constr->defval[i].adnum == attribute->attnum)
+ if (parent_constr->defval[i].adnum == attribute->attphysnum)
{
parent_expr =
TextDatumGetCString(DirectFunctionCall2(pg_get_expr,
@@ -15441,7 +15441,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
Anum_pg_attribute_attrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(child_rel)));
- scan = systable_beginscan(catalogRelation, AttributeRelidNumIndexId,
+ scan = systable_beginscan(catalogRelation, AttributeRelidPhysNumIndexId,
true, NULL, 1, key);
while (HeapTupleIsValid(attributeTuple = systable_getnext(scan)))
{
@@ -16165,7 +16165,7 @@ ATExecSetCompression(AlteredTableInfo *tab,
Relation attrel;
HeapTuple tuple;
Form_pg_attribute atttableform;
- AttrNumber attnum;
+ AttrNumber attphysnum;
char *compression;
char cmethod;
ObjectAddress address;
@@ -16185,8 +16185,8 @@ ATExecSetCompression(AlteredTableInfo *tab,
/* prevent them from altering a system attribute */
atttableform = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = atttableform->attnum;
- if (attnum <= 0)
+ attphysnum = atttableform->attphysnum;
+ if (attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter system column \"%s\"", column)));
@@ -16203,13 +16203,13 @@ ATExecSetCompression(AlteredTableInfo *tab,
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel),
- attnum);
+ attphysnum);
/*
* Apply the change to indexes as well (only for simple index columns,
* matching behavior of index.c ConstructTupleDescriptor()).
*/
- SetIndexStorageProperties(rel, attrel, attnum,
+ SetIndexStorageProperties(rel, attrel, attphysnum,
false, 0,
true, cmethod,
lockmode);
@@ -16222,7 +16222,7 @@ ATExecSetCompression(AlteredTableInfo *tab,
CommandCounterIncrement();
ObjectAddressSubSet(address, RelationRelationId,
- RelationGetRelid(rel), attnum);
+ RelationGetRelid(rel), attphysnum);
return address;
}
@@ -17247,7 +17247,7 @@ ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNu
parser_errposition(pstate, pelem->location)));
attform = (Form_pg_attribute) GETSTRUCT(atttuple);
- if (attform->attnum <= 0)
+ if (attform->attphysnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("cannot use system column \"%s\" in partition key",
@@ -17266,7 +17266,7 @@ ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNu
pelem->name),
parser_errposition(pstate, pelem->location)));
- partattrs[attn] = attform->attnum;
+ partattrs[attn] = attform->attphysnum;
atttype = attform->atttypid;
attcollation = attform->attcollation;
ReleaseSysCache(atttuple);
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 13cb516752..b67128e9fe 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -947,12 +947,12 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
foreach(cell, stmt->columns)
{
char *name = strVal(lfirst(cell));
- int16 attnum;
+ int16 attphysnum;
int j;
/* Lookup column name. System columns are not allowed */
- attnum = attnameAttNum(rel, name, false);
- if (attnum == InvalidAttrNumber)
+ attphysnum = attnameAttNum(rel, name, false);
+ if (attphysnum == InvalidAttrNumber)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
@@ -961,14 +961,14 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
/* Check for duplicates */
for (j = i - 1; j >= 0; j--)
{
- if (columns[j] == attnum)
+ if (columns[j] == attphysnum)
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column \"%s\" specified more than once",
name)));
}
- columns[i++] = attnum;
+ columns[i++] = attphysnum;
}
}
tgattr = buildint2vector(columns, ncolumns);
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index 4cc4e3c00f..0797ee67f7 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -62,10 +62,10 @@ static DefElem *buildDefItem(const char *name, const char *val,
/*
* lookup a parser support function and return its OID (as a Datum)
*
- * attnum is the pg_ts_parser column the function will go into
+ * attphysnum is the pg_ts_parser column the function will go into
*/
static Datum
-get_ts_parser_func(DefElem *defel, int attnum)
+get_ts_parser_func(DefElem *defel, int attphysnum)
{
List *funcName = defGetQualifiedName(defel);
Oid typeId[3];
@@ -75,7 +75,7 @@ get_ts_parser_func(DefElem *defel, int attnum)
retTypeId = INTERNALOID; /* correct for most */
typeId[0] = INTERNALOID;
- switch (attnum)
+ switch (attphysnum)
{
case Anum_pg_ts_parser_prsstart:
nargs = 2;
@@ -107,7 +107,7 @@ get_ts_parser_func(DefElem *defel, int attnum)
default:
/* should not be here */
elog(ERROR, "unrecognized attribute for text search parser: %d",
- attnum);
+ attphysnum);
nargs = 0; /* keep compiler quiet */
}
@@ -597,10 +597,10 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
/*
* lookup a template support function and return its OID (as a Datum)
*
- * attnum is the pg_ts_template column the function will go into
+ * attphysnum is the pg_ts_template column the function will go into
*/
static Datum
-get_ts_template_func(DefElem *defel, int attnum)
+get_ts_template_func(DefElem *defel, int attphysnum)
{
List *funcName = defGetQualifiedName(defel);
Oid typeId[4];
@@ -613,7 +613,7 @@ get_ts_template_func(DefElem *defel, int attnum)
typeId[1] = INTERNALOID;
typeId[2] = INTERNALOID;
typeId[3] = INTERNALOID;
- switch (attnum)
+ switch (attphysnum)
{
case Anum_pg_ts_template_tmplinit:
nargs = 1;
@@ -624,7 +624,7 @@ get_ts_template_func(DefElem *defel, int attnum)
default:
/* should not be here */
elog(ERROR, "unrecognized attribute for text search template: %d",
- attnum);
+ attphysnum);
nargs = 0; /* keep compiler quiet */
}
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 9b92b04242..e59afbe7cd 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -2758,10 +2758,10 @@ AlterDomainNotNull(List *names, bool notNull)
/* Test attributes that are of the domain */
for (i = 0; i < rtc->natts; i++)
{
- int attnum = rtc->atts[i];
- Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1);
+ int attphysnum = rtc->atts[i];
+ Form_pg_attribute attr = TupleDescAttr(tupdesc, attphysnum - 1);
- if (slot_attisnull(slot, attnum))
+ if (slot_attisnull(slot, attphysnum))
{
/*
* In principle the auxiliary information for this
@@ -2776,7 +2776,7 @@ AlterDomainNotNull(List *names, bool notNull)
errmsg("column \"%s\" of table \"%s\" contains null values",
NameStr(attr->attname),
RelationGetRelationName(testrel)),
- errtablecol(testrel, attnum)));
+ errtablecol(testrel, attphysnum)));
}
}
}
@@ -3174,13 +3174,13 @@ validateDomainConstraint(Oid domainoid, char *ccbin)
/* Test attributes that are of the domain */
for (i = 0; i < rtc->natts; i++)
{
- int attnum = rtc->atts[i];
+ int attphysnum = rtc->atts[i];
Datum d;
bool isNull;
Datum conResult;
- Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1);
+ Form_pg_attribute attr = TupleDescAttr(tupdesc, attphysnum - 1);
- d = slot_getattr(slot, attnum, &isNull);
+ d = slot_getattr(slot, attphysnum, &isNull);
econtext->domainValue_datum = d;
econtext->domainValue_isNull = isNull;
@@ -3204,7 +3204,7 @@ validateDomainConstraint(Oid domainoid, char *ccbin)
errmsg("column \"%s\" of table \"%s\" contains values that violate the new constraint",
NameStr(attr->attname),
RelationGetRelationName(testrel)),
- errtablecol(testrel, attnum)));
+ errtablecol(testrel, attphysnum)));
}
}
diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c
index 2831e7978b..63e0617430 100644
--- a/src/backend/executor/execExpr.c
+++ b/src/backend/executor/execExpr.c
@@ -379,7 +379,7 @@ ExecBuildProjectionInfo(List *targetList,
{
TargetEntry *tle = lfirst_node(TargetEntry, lc);
Var *variable = NULL;
- AttrNumber attnum = 0;
+ AttrNumber attphysnum = 0;
bool isSafeVar = false;
/*
@@ -396,13 +396,13 @@ ExecBuildProjectionInfo(List *targetList,
{
/* Non-system Var, but how safe is it? */
variable = (Var *) tle->expr;
- attnum = variable->varattno;
+ attphysnum = variable->varattno;
if (inputDesc == NULL)
isSafeVar = true; /* can't check, just assume OK */
- else if (attnum <= inputDesc->natts)
+ else if (attphysnum <= inputDesc->natts)
{
- Form_pg_attribute attr = TupleDescAttr(inputDesc, attnum - 1);
+ Form_pg_attribute attr = TupleDescAttr(inputDesc, attphysnum - 1);
/*
* If user attribute is dropped or has a type mismatch, don't
@@ -439,7 +439,7 @@ ExecBuildProjectionInfo(List *targetList,
break;
}
- scratch.d.assign_var.attnum = attnum - 1;
+ scratch.d.assign_var.attphysnum = attphysnum - 1;
scratch.d.assign_var.resultnum = tle->resno - 1;
ExprEvalPushStep(state, &scratch);
}
@@ -584,15 +584,15 @@ ExecBuildUpdateProjection(List *targetList,
* sufficiently deconstructed. The scan tuple must be deconstructed at
* least as far as the last old column we need.
*/
- for (int attnum = relDesc->natts; attnum > 0; attnum--)
+ for (int attphysnum = relDesc->natts; attphysnum > 0; attphysnum--)
{
- Form_pg_attribute attr = TupleDescAttr(relDesc, attnum - 1);
+ Form_pg_attribute attr = TupleDescAttr(relDesc, attphysnum - 1);
if (attr->attisdropped)
continue;
- if (bms_is_member(attnum, assignedCols))
+ if (bms_is_member(attphysnum, assignedCols))
continue;
- deform.last_scan = attnum;
+ deform.last_scan = attphysnum;
break;
}
@@ -668,7 +668,7 @@ ExecBuildUpdateProjection(List *targetList,
{
/* Just assign from the outer tuple. */
scratch.opcode = EEOP_ASSIGN_OUTER_VAR;
- scratch.d.assign_var.attnum = outerattnum;
+ scratch.d.assign_var.attphysnum = outerattnum;
scratch.d.assign_var.resultnum = targetattnum - 1;
ExprEvalPushStep(state, &scratch);
}
@@ -695,9 +695,9 @@ ExecBuildUpdateProjection(List *targetList,
* Now generate code to copy over any old columns that were not assigned
* to, and to ensure that dropped columns are set to NULL.
*/
- for (int attnum = 1; attnum <= relDesc->natts; attnum++)
+ for (int attphysnum = 1; attphysnum <= relDesc->natts; attphysnum++)
{
- Form_pg_attribute attr = TupleDescAttr(relDesc, attnum - 1);
+ Form_pg_attribute attr = TupleDescAttr(relDesc, attphysnum - 1);
if (attr->attisdropped)
{
@@ -710,15 +710,15 @@ ExecBuildUpdateProjection(List *targetList,
ExprEvalPushStep(state, &scratch);
/* ... then assign it to the result slot */
scratch.opcode = EEOP_ASSIGN_TMP;
- scratch.d.assign_tmp.resultnum = attnum - 1;
+ scratch.d.assign_tmp.resultnum = attphysnum - 1;
ExprEvalPushStep(state, &scratch);
}
- else if (!bms_is_member(attnum, assignedCols))
+ else if (!bms_is_member(attphysnum, assignedCols))
{
/* Certainly the right type, so needn't check */
scratch.opcode = EEOP_ASSIGN_SCAN_VAR;
- scratch.d.assign_var.attnum = attnum - 1;
- scratch.d.assign_var.resultnum = attnum - 1;
+ scratch.d.assign_var.attphysnum = attphysnum - 1;
+ scratch.d.assign_var.resultnum = attphysnum - 1;
ExprEvalPushStep(state, &scratch);
}
}
@@ -925,7 +925,7 @@ ExecInitExprRec(Expr *node, ExprState *state,
else if (variable->varattno <= 0)
{
/* system column */
- scratch.d.var.attnum = variable->varattno;
+ scratch.d.var.attphysnum = variable->varattno;
scratch.d.var.vartype = variable->vartype;
switch (variable->varno)
{
@@ -946,7 +946,7 @@ ExecInitExprRec(Expr *node, ExprState *state,
else
{
/* regular user column */
- scratch.d.var.attnum = variable->varattno - 1;
+ scratch.d.var.attphysnum = variable->varattno - 1;
scratch.d.var.vartype = variable->vartype;
switch (variable->varno)
{
@@ -2890,22 +2890,22 @@ get_last_attnums_walker(Node *node, LastAttnumInfo *info)
if (IsA(node, Var))
{
Var *variable = (Var *) node;
- AttrNumber attnum = variable->varattno;
+ AttrNumber attphysnum = variable->varattno;
switch (variable->varno)
{
case INNER_VAR:
- info->last_inner = Max(info->last_inner, attnum);
+ info->last_inner = Max(info->last_inner, attphysnum);
break;
case OUTER_VAR:
- info->last_outer = Max(info->last_outer, attnum);
+ info->last_outer = Max(info->last_outer, attphysnum);
break;
/* INDEX_VAR is handled by default case */
default:
- info->last_scan = Max(info->last_scan, attnum);
+ info->last_scan = Max(info->last_scan, attphysnum);
break;
}
return false;
@@ -4040,7 +4040,7 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
/* left arg */
scratch.opcode = EEOP_INNER_VAR;
- scratch.d.var.attnum = attno - 1;
+ scratch.d.var.attphysnum = attno - 1;
scratch.d.var.vartype = latt->atttypid;
scratch.resvalue = &fcinfo->args[0].value;
scratch.resnull = &fcinfo->args[0].isnull;
@@ -4048,7 +4048,7 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
/* right arg */
scratch.opcode = EEOP_OUTER_VAR;
- scratch.d.var.attnum = attno - 1;
+ scratch.d.var.attphysnum = attno - 1;
scratch.d.var.vartype = ratt->atttypid;
scratch.resvalue = &fcinfo->args[1].value;
scratch.resnull = &fcinfo->args[1].isnull;
@@ -4174,7 +4174,7 @@ ExecBuildParamSetEqual(TupleDesc desc,
/* left arg */
scratch.opcode = EEOP_INNER_VAR;
- scratch.d.var.attnum = attno;
+ scratch.d.var.attphysnum = attno;
scratch.d.var.vartype = att->atttypid;
scratch.resvalue = &fcinfo->args[0].value;
scratch.resnull = &fcinfo->args[0].isnull;
@@ -4182,7 +4182,7 @@ ExecBuildParamSetEqual(TupleDesc desc,
/* right arg */
scratch.opcode = EEOP_OUTER_VAR;
- scratch.d.var.attnum = attno;
+ scratch.d.var.attphysnum = attno;
scratch.d.var.vartype = att->atttypid;
scratch.resvalue = &fcinfo->args[1].value;
scratch.resnull = &fcinfo->args[1].isnull;
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index eaec697bb3..fcc2f346bf 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -151,7 +151,7 @@ static Datum ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnul
static void ExecInitInterpreter(void);
/* support functions */
-static void CheckVarSlotCompatibility(TupleTableSlot *slot, int attnum, Oid vartype);
+static void CheckVarSlotCompatibility(TupleTableSlot *slot, int attphysnum, Oid vartype);
static void CheckOpSlotCompatibility(ExprEvalStep *op, TupleTableSlot *slot);
static TupleDesc get_cached_rowtype(Oid type_id, int32 typmod,
ExprEvalRowtypeCache *rowcache,
@@ -561,7 +561,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
EEO_CASE(EEOP_INNER_VAR)
{
- int attnum = op->d.var.attnum;
+ int attphysnum = op->d.var.attphysnum;
/*
* Since we already extracted all referenced columns from the
@@ -569,35 +569,35 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
* directly out of the slot's decomposed-data arrays. But let's
* have an Assert to check that that did happen.
*/
- Assert(attnum >= 0 && attnum < innerslot->tts_nvalid);
- *op->resvalue = innerslot->tts_values[attnum];
- *op->resnull = innerslot->tts_isnull[attnum];
+ Assert(attphysnum >= 0 && attphysnum < innerslot->tts_nvalid);
+ *op->resvalue = innerslot->tts_values[attphysnum];
+ *op->resnull = innerslot->tts_isnull[attphysnum];
EEO_NEXT();
}
EEO_CASE(EEOP_OUTER_VAR)
{
- int attnum = op->d.var.attnum;
+ int attphysnum = op->d.var.attphysnum;
/* See EEOP_INNER_VAR comments */
- Assert(attnum >= 0 && attnum < outerslot->tts_nvalid);
- *op->resvalue = outerslot->tts_values[attnum];
- *op->resnull = outerslot->tts_isnull[attnum];
+ Assert(attphysnum >= 0 && attphysnum < outerslot->tts_nvalid);
+ *op->resvalue = outerslot->tts_values[attphysnum];
+ *op->resnull = outerslot->tts_isnull[attphysnum];
EEO_NEXT();
}
EEO_CASE(EEOP_SCAN_VAR)
{
- int attnum = op->d.var.attnum;
+ int attphysnum = op->d.var.attphysnum;
/* See EEOP_INNER_VAR comments */
- Assert(attnum >= 0 && attnum < scanslot->tts_nvalid);
- *op->resvalue = scanslot->tts_values[attnum];
- *op->resnull = scanslot->tts_isnull[attnum];
+ Assert(attphysnum >= 0 && attphysnum < scanslot->tts_nvalid);
+ *op->resvalue = scanslot->tts_values[attphysnum];
+ *op->resnull = scanslot->tts_isnull[attphysnum];
EEO_NEXT();
}
@@ -631,16 +631,16 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
EEO_CASE(EEOP_ASSIGN_INNER_VAR)
{
int resultnum = op->d.assign_var.resultnum;
- int attnum = op->d.assign_var.attnum;
+ int attphysnum = op->d.assign_var.attphysnum;
/*
* We do not need CheckVarSlotCompatibility here; that was taken
* care of at compilation time. But see EEOP_INNER_VAR comments.
*/
- Assert(attnum >= 0 && attnum < innerslot->tts_nvalid);
+ Assert(attphysnum >= 0 && attphysnum < innerslot->tts_nvalid);
Assert(resultnum >= 0 && resultnum < resultslot->tts_tupleDescriptor->natts);
- resultslot->tts_values[resultnum] = innerslot->tts_values[attnum];
- resultslot->tts_isnull[resultnum] = innerslot->tts_isnull[attnum];
+ resultslot->tts_values[resultnum] = innerslot->tts_values[attphysnum];
+ resultslot->tts_isnull[resultnum] = innerslot->tts_isnull[attphysnum];
EEO_NEXT();
}
@@ -648,16 +648,16 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
EEO_CASE(EEOP_ASSIGN_OUTER_VAR)
{
int resultnum = op->d.assign_var.resultnum;
- int attnum = op->d.assign_var.attnum;
+ int attphysnum = op->d.assign_var.attphysnum;
/*
* We do not need CheckVarSlotCompatibility here; that was taken
* care of at compilation time. But see EEOP_INNER_VAR comments.
*/
- Assert(attnum >= 0 && attnum < outerslot->tts_nvalid);
+ Assert(attphysnum >= 0 && attphysnum < outerslot->tts_nvalid);
Assert(resultnum >= 0 && resultnum < resultslot->tts_tupleDescriptor->natts);
- resultslot->tts_values[resultnum] = outerslot->tts_values[attnum];
- resultslot->tts_isnull[resultnum] = outerslot->tts_isnull[attnum];
+ resultslot->tts_values[resultnum] = outerslot->tts_values[attphysnum];
+ resultslot->tts_isnull[resultnum] = outerslot->tts_isnull[attphysnum];
EEO_NEXT();
}
@@ -665,16 +665,16 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
EEO_CASE(EEOP_ASSIGN_SCAN_VAR)
{
int resultnum = op->d.assign_var.resultnum;
- int attnum = op->d.assign_var.attnum;
+ int attphysnum = op->d.assign_var.attphysnum;
/*
* We do not need CheckVarSlotCompatibility here; that was taken
* care of at compilation time. But see EEOP_INNER_VAR comments.
*/
- Assert(attnum >= 0 && attnum < scanslot->tts_nvalid);
+ Assert(attphysnum >= 0 && attphysnum < scanslot->tts_nvalid);
Assert(resultnum >= 0 && resultnum < resultslot->tts_tupleDescriptor->natts);
- resultslot->tts_values[resultnum] = scanslot->tts_values[attnum];
- resultslot->tts_isnull[resultnum] = scanslot->tts_isnull[attnum];
+ resultslot->tts_values[resultnum] = scanslot->tts_values[attphysnum];
+ resultslot->tts_isnull[resultnum] = scanslot->tts_isnull[attphysnum];
EEO_NEXT();
}
@@ -1879,25 +1879,25 @@ CheckExprStillValid(ExprState *state, ExprContext *econtext)
{
case EEOP_INNER_VAR:
{
- int attnum = op->d.var.attnum;
+ int attphysnum = op->d.var.attphysnum;
- CheckVarSlotCompatibility(innerslot, attnum + 1, op->d.var.vartype);
+ CheckVarSlotCompatibility(innerslot, attphysnum + 1, op->d.var.vartype);
break;
}
case EEOP_OUTER_VAR:
{
- int attnum = op->d.var.attnum;
+ int attphysnum = op->d.var.attphysnum;
- CheckVarSlotCompatibility(outerslot, attnum + 1, op->d.var.vartype);
+ CheckVarSlotCompatibility(outerslot, attphysnum + 1, op->d.var.vartype);
break;
}
case EEOP_SCAN_VAR:
{
- int attnum = op->d.var.attnum;
+ int attphysnum = op->d.var.attphysnum;
- CheckVarSlotCompatibility(scanslot, attnum + 1, op->d.var.vartype);
+ CheckVarSlotCompatibility(scanslot, attphysnum + 1, op->d.var.vartype);
break;
}
default:
@@ -1912,7 +1912,7 @@ CheckExprStillValid(ExprState *state, ExprContext *econtext)
* since the expression tree has been created.
*/
static void
-CheckVarSlotCompatibility(TupleTableSlot *slot, int attnum, Oid vartype)
+CheckVarSlotCompatibility(TupleTableSlot *slot, int attphysnum, Oid vartype)
{
/*
* What we have to check for here is the possibility of an attribute
@@ -1931,28 +1931,28 @@ CheckVarSlotCompatibility(TupleTableSlot *slot, int attnum, Oid vartype)
* System attributes don't require checking since their types never
* change.
*/
- if (attnum > 0)
+ if (attphysnum > 0)
{
TupleDesc slot_tupdesc = slot->tts_tupleDescriptor;
Form_pg_attribute attr;
- if (attnum > slot_tupdesc->natts) /* should never happen */
+ if (attphysnum > slot_tupdesc->natts) /* should never happen */
elog(ERROR, "attribute number %d exceeds number of columns %d",
- attnum, slot_tupdesc->natts);
+ attphysnum, slot_tupdesc->natts);
- attr = TupleDescAttr(slot_tupdesc, attnum - 1);
+ attr = TupleDescAttr(slot_tupdesc, attphysnum - 1);
if (attr->attisdropped)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("attribute %d of type %s has been dropped",
- attnum, format_type_be(slot_tupdesc->tdtypeid))));
+ attphysnum, format_type_be(slot_tupdesc->tdtypeid))));
if (vartype != attr->atttypid)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("attribute %d of type %s has wrong type",
- attnum, format_type_be(slot_tupdesc->tdtypeid)),
+ attphysnum, format_type_be(slot_tupdesc->tdtypeid)),
errdetail("Table has type %s, but query expects %s.",
format_type_be(attr->atttypid),
format_type_be(vartype))));
@@ -2078,16 +2078,16 @@ static pg_attribute_always_inline Datum
ExecJustVarImpl(ExprState *state, TupleTableSlot *slot, bool *isnull)
{
ExprEvalStep *op = &state->steps[1];
- int attnum = op->d.var.attnum + 1;
+ int attphysnum = op->d.var.attphysnum + 1;
CheckOpSlotCompatibility(&state->steps[0], slot);
/*
* Since we use slot_getattr(), we don't need to implement the FETCHSOME
- * step explicitly, and we also needn't Assert that the attnum is in range
+ * step explicitly, and we also needn't Assert that the attphysnum is in range
* --- slot_getattr() will take care of any problems.
*/
- return slot_getattr(slot, attnum, isnull);
+ return slot_getattr(slot, attphysnum, isnull);
}
/* Simple reference to inner Var */
@@ -2116,7 +2116,7 @@ static pg_attribute_always_inline Datum
ExecJustAssignVarImpl(ExprState *state, TupleTableSlot *inslot, bool *isnull)
{
ExprEvalStep *op = &state->steps[1];
- int attnum = op->d.assign_var.attnum + 1;
+ int attphysnum = op->d.assign_var.attphysnum + 1;
int resultnum = op->d.assign_var.resultnum;
TupleTableSlot *outslot = state->resultslot;
@@ -2127,13 +2127,13 @@ ExecJustAssignVarImpl(ExprState *state, TupleTableSlot *inslot, bool *isnull)
* at compilation time.
*
* Since we use slot_getattr(), we don't need to implement the FETCHSOME
- * step explicitly, and we also needn't Assert that the attnum is in range
+ * step explicitly, and we also needn't Assert that the attphysnum is in range
* --- slot_getattr() will take care of any problems. Nonetheless, check
* that resultnum is in range.
*/
Assert(resultnum >= 0 && resultnum < outslot->tts_tupleDescriptor->natts);
outslot->tts_values[resultnum] =
- slot_getattr(inslot, attnum, &outslot->tts_isnull[resultnum]);
+ slot_getattr(inslot, attphysnum, &outslot->tts_isnull[resultnum]);
return 0;
}
@@ -2211,7 +2211,7 @@ static pg_attribute_always_inline Datum
ExecJustVarVirtImpl(ExprState *state, TupleTableSlot *slot, bool *isnull)
{
ExprEvalStep *op = &state->steps[0];
- int attnum = op->d.var.attnum;
+ int attphysnum = op->d.var.attphysnum;
/*
* As it is guaranteed that a virtual slot is used, there never is a need
@@ -2221,11 +2221,11 @@ ExecJustVarVirtImpl(ExprState *state, TupleTableSlot *slot, bool *isnull)
*/
Assert(TTS_IS_VIRTUAL(slot));
Assert(TTS_FIXED(slot));
- Assert(attnum >= 0 && attnum < slot->tts_nvalid);
+ Assert(attphysnum >= 0 && attphysnum < slot->tts_nvalid);
- *isnull = slot->tts_isnull[attnum];
+ *isnull = slot->tts_isnull[attphysnum];
- return slot->tts_values[attnum];
+ return slot->tts_values[attphysnum];
}
/* Like ExecJustInnerVar, optimized for virtual slots */
@@ -2254,7 +2254,7 @@ static pg_attribute_always_inline Datum
ExecJustAssignVarVirtImpl(ExprState *state, TupleTableSlot *inslot, bool *isnull)
{
ExprEvalStep *op = &state->steps[0];
- int attnum = op->d.assign_var.attnum;
+ int attphysnum = op->d.assign_var.attphysnum;
int resultnum = op->d.assign_var.resultnum;
TupleTableSlot *outslot = state->resultslot;
@@ -2262,11 +2262,11 @@ ExecJustAssignVarVirtImpl(ExprState *state, TupleTableSlot *inslot, bool *isnull
Assert(TTS_IS_VIRTUAL(inslot));
Assert(TTS_FIXED(inslot));
- Assert(attnum >= 0 && attnum < inslot->tts_nvalid);
+ Assert(attphysnum >= 0 && attphysnum < inslot->tts_nvalid);
Assert(resultnum >= 0 && resultnum < outslot->tts_tupleDescriptor->natts);
- outslot->tts_values[resultnum] = inslot->tts_values[attnum];
- outslot->tts_isnull[resultnum] = inslot->tts_isnull[attnum];
+ outslot->tts_values[resultnum] = inslot->tts_values[attphysnum];
+ outslot->tts_isnull[resultnum] = inslot->tts_isnull[attphysnum];
return 0;
}
@@ -4036,11 +4036,11 @@ ExecEvalGroupingFunc(ExprState *state, ExprEvalStep *op)
foreach(lc, op->d.grouping_func.clauses)
{
- int attnum = lfirst_int(lc);
+ int attphysnum = lfirst_int(lc);
result <<= 1;
- if (!bms_is_member(attnum, grouped_cols))
+ if (!bms_is_member(attphysnum, grouped_cols))
result |= 1;
}
@@ -4303,7 +4303,7 @@ ExecEvalSysVar(ExprState *state, ExprEvalStep *op, ExprContext *econtext,
/* slot_getsysattr has sufficient defenses against bad attnums */
d = slot_getsysattr(slot,
- op->d.var.attnum,
+ op->d.var.attphysnum,
op->resnull);
*op->resvalue = d;
/* this ought to be unreachable, but it's cheap enough to check */
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index ef2fd46092..045c25e634 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -2264,9 +2264,9 @@ ExecBuildSlotValueDescription(Oid reloid,
* for the column. If not, omit this column from the error
* message.
*/
- aclresult = pg_attribute_aclcheck(reloid, att->attnum,
+ aclresult = pg_attribute_aclcheck(reloid, att->attphysnum,
GetUserId(), ACL_SELECT);
- if (bms_is_member(att->attnum - FirstLowInvalidHeapAttributeNumber,
+ if (bms_is_member(att->attphysnum - FirstLowInvalidHeapAttributeNumber,
modifiedCols) || aclresult == ACLCHECK_OK)
{
column_perm = any_perm = true;
diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c
index e03ea27299..507212a9a8 100644
--- a/src/backend/executor/execPartition.c
+++ b/src/backend/executor/execPartition.c
@@ -1471,15 +1471,15 @@ ExecBuildSlotPartitionKeyDescription(Relation rel,
*/
for (i = 0; i < partnatts; i++)
{
- AttrNumber attnum = get_partition_col_attnum(key, i);
+ AttrNumber attphysnum = get_partition_col_attnum(key, i);
/*
* If this partition key column is an expression, we return no
* detail rather than try to figure out what column(s) the
* expression includes and if the user has SELECT rights on them.
*/
- if (attnum == InvalidAttrNumber ||
- pg_attribute_aclcheck(relid, attnum, GetUserId(),
+ if (attphysnum == InvalidAttrNumber ||
+ pg_attribute_aclcheck(relid, attphysnum, GetUserId(),
ACL_SELECT) != ACLCHECK_OK)
return NULL;
}
diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c
index 06ac253ea0..c94f45491f 100644
--- a/src/backend/executor/execTuples.c
+++ b/src/backend/executor/execTuples.c
@@ -137,7 +137,7 @@ tts_virtual_getsomeattrs(TupleTableSlot *slot, int natts)
* here, but provide a user-friendly message if we do.
*/
static Datum
-tts_virtual_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
+tts_virtual_getsysattr(TupleTableSlot *slot, int attphysnum, bool *isnull)
{
Assert(!TTS_EMPTY(slot));
@@ -337,7 +337,7 @@ tts_heap_getsomeattrs(TupleTableSlot *slot, int natts)
}
static Datum
-tts_heap_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
+tts_heap_getsysattr(TupleTableSlot *slot, int attphysnum, bool *isnull)
{
HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
@@ -352,7 +352,7 @@ tts_heap_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot retrieve a system column in this context")));
- return heap_getsysattr(hslot->tuple, attnum,
+ return heap_getsysattr(hslot->tuple, attphysnum,
slot->tts_tupleDescriptor, isnull);
}
@@ -512,7 +512,7 @@ tts_minimal_getsomeattrs(TupleTableSlot *slot, int natts)
}
static Datum
-tts_minimal_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
+tts_minimal_getsysattr(TupleTableSlot *slot, int attphysnum, bool *isnull)
{
Assert(!TTS_EMPTY(slot));
@@ -696,7 +696,7 @@ tts_buffer_heap_getsomeattrs(TupleTableSlot *slot, int natts)
}
static Datum
-tts_buffer_heap_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
+tts_buffer_heap_getsysattr(TupleTableSlot *slot, int attphysnum, bool *isnull)
{
BufferHeapTupleTableSlot *bslot = (BufferHeapTupleTableSlot *) slot;
@@ -711,7 +711,7 @@ tts_buffer_heap_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot retrieve a system column in this context")));
- return heap_getsysattr(bslot->base.tuple, attnum,
+ return heap_getsysattr(bslot->base.tuple, attphysnum,
slot->tts_tupleDescriptor, isnull);
}
@@ -930,7 +930,7 @@ slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
bool *isnull = slot->tts_isnull;
HeapTupleHeader tup = tuple->t_data;
bool hasnulls = HeapTupleHasNulls(tuple);
- int attnum;
+ int attphysnum;
char *tp; /* ptr to tuple data */
uint32 off; /* offset in tuple data */
bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
@@ -943,8 +943,8 @@ slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
* Check whether the first call for this tuple, and initialize or restore
* loop state.
*/
- attnum = slot->tts_nvalid;
- if (attnum == 0)
+ attphysnum = slot->tts_nvalid;
+ if (attphysnum == 0)
{
/* Start from the first attribute */
off = 0;
@@ -959,19 +959,19 @@ slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
tp = (char *) tup + tup->t_hoff;
- for (; attnum < natts; attnum++)
+ for (; attphysnum < natts; attphysnum++)
{
- Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attnum);
+ Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attphysnum);
- if (hasnulls && att_isnull(attnum, bp))
+ if (hasnulls && att_isnull(attphysnum, bp))
{
- values[attnum] = (Datum) 0;
- isnull[attnum] = true;
+ values[attphysnum] = (Datum) 0;
+ isnull[attphysnum] = true;
slow = true; /* can't use attcacheoff anymore */
continue;
}
- isnull[attnum] = false;
+ isnull[attphysnum] = false;
if (!slow && thisatt->attcacheoff >= 0)
off = thisatt->attcacheoff;
@@ -1002,7 +1002,7 @@ slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
thisatt->attcacheoff = off;
}
- values[attnum] = fetchatt(thisatt, tp + off);
+ values[attphysnum] = fetchatt(thisatt, tp + off);
off = att_addlength_pointer(off, thisatt->attlen, tp + off);
@@ -1013,7 +1013,7 @@ slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
/*
* Save state for next execution
*/
- slot->tts_nvalid = attnum;
+ slot->tts_nvalid = attphysnum;
*offp = off;
if (slow)
slot->tts_flags |= TTS_FLAG_SLOW;
@@ -1899,26 +1899,26 @@ slot_getmissingattrs(TupleTableSlot *slot, int startAttNum, int lastAttNum)
* slot_getsomeattrs_int - workhorse for slot_getsomeattrs()
*/
void
-slot_getsomeattrs_int(TupleTableSlot *slot, int attnum)
+slot_getsomeattrs_int(TupleTableSlot *slot, int attphysnum)
{
/* Check for caller errors */
- Assert(slot->tts_nvalid < attnum); /* checked in slot_getsomeattrs */
- Assert(attnum > 0);
+ Assert(slot->tts_nvalid < attphysnum); /* checked in slot_getsomeattrs */
+ Assert(attphysnum > 0);
- if (unlikely(attnum > slot->tts_tupleDescriptor->natts))
- elog(ERROR, "invalid attribute number %d", attnum);
+ if (unlikely(attphysnum > slot->tts_tupleDescriptor->natts))
+ elog(ERROR, "invalid attribute number %d", attphysnum);
/* Fetch as many attributes as possible from the underlying tuple. */
- slot->tts_ops->getsomeattrs(slot, attnum);
+ slot->tts_ops->getsomeattrs(slot, attphysnum);
/*
* If the underlying tuple doesn't have enough attributes, tuple
* descriptor must have the missing attributes.
*/
- if (unlikely(slot->tts_nvalid < attnum))
+ if (unlikely(slot->tts_nvalid < attphysnum))
{
- slot_getmissingattrs(slot, slot->tts_nvalid, attnum);
- slot->tts_nvalid = attnum;
+ slot_getmissingattrs(slot, slot->tts_nvalid, attphysnum);
+ slot->tts_nvalid = attphysnum;
}
}
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index 9df1f81ea8..c5caa4e20b 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -1054,7 +1054,7 @@ GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
if (namestrcmp(&(att->attname), attname) == 0)
{
- attrno = att->attnum;
+ attrno = att->attphysnum;
break;
}
}
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 139b2bd5f9..c94b3ca7cd 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -1269,10 +1269,10 @@ prepare_projection_slot(AggState *aggstate, TupleTableSlot *slot, int currentSet
foreach(lc, aggstate->all_grouped_cols)
{
- int attnum = lfirst_int(lc);
+ int attphysnum = lfirst_int(lc);
- if (!bms_is_member(attnum, grouped_cols))
- slot->tts_isnull[attnum - 1] = true;
+ if (!bms_is_member(attphysnum, grouped_cols))
+ slot->tts_isnull[attphysnum - 1] = true;
}
}
}
@@ -1595,10 +1595,10 @@ find_hash_columns(AggState *aggstate)
foreach(lc, aggstate->all_grouped_cols)
{
- int attnum = lfirst_int(lc);
+ int attphysnum = lfirst_int(lc);
- if (!bms_is_member(attnum, grouped_cols))
- colnos = bms_del_member(colnos, attnum);
+ if (!bms_is_member(attphysnum, grouped_cols))
+ colnos = bms_del_member(colnos, attphysnum);
}
}
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 29bc26669b..bdc61e8925 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -1101,7 +1101,7 @@ SPI_returntuple(HeapTuple tuple, TupleDesc tupdesc)
}
HeapTuple
-SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum,
+SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attphysnum,
Datum *Values, const char *Nulls)
{
MemoryContext oldcxt;
@@ -1111,7 +1111,7 @@ SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum,
bool *n;
int i;
- if (rel == NULL || tuple == NULL || natts < 0 || attnum == NULL || Values == NULL)
+ if (rel == NULL || tuple == NULL || natts < 0 || attphysnum == NULL || Values == NULL)
{
SPI_result = SPI_ERROR_ARGUMENT;
return NULL;
@@ -1137,13 +1137,13 @@ SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum,
/* replace values and nulls */
for (i = 0; i < natts; i++)
{
- if (attnum[i] <= 0 || attnum[i] > numberOfAttributes)
+ if (attphysnum[i] <= 0 || attphysnum[i] > numberOfAttributes)
break;
- v[attnum[i] - 1] = Values[i];
- n[attnum[i] - 1] = (Nulls && Nulls[i] == 'n');
+ v[attphysnum[i] - 1] = Values[i];
+ n[attphysnum[i] - 1] = (Nulls && Nulls[i] == 'n');
}
- if (i == natts) /* no errors in *attnum */
+ if (i == natts) /* no errors in *attphysnum */
{
mtuple = heap_form_tuple(rel->rd_att, v, n);
@@ -1186,7 +1186,7 @@ SPI_fnumber(TupleDesc tupdesc, const char *fname)
sysatt = SystemAttributeByName(fname);
if (sysatt != NULL)
- return sysatt->attnum;
+ return sysatt->attphysnum;
/* SPI_ERROR_NOATTRIBUTE is different from all sys column numbers */
return SPI_ERROR_NOATTRIBUTE;
diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c
index cf222fc3e9..c064fe50cd 100644
--- a/src/backend/foreign/foreign.c
+++ b/src/backend/foreign/foreign.c
@@ -284,20 +284,20 @@ GetForeignTable(Oid relid)
* as list of DefElem.
*/
List *
-GetForeignColumnOptions(Oid relid, AttrNumber attnum)
+GetForeignColumnOptions(Oid relid, AttrNumber attphysnum)
{
List *options;
HeapTuple tp;
Datum datum;
bool isnull;
- tp = SearchSysCache2(ATTNUM,
+ tp = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(relid),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
- attnum, relid);
- datum = SysCacheGetAttr(ATTNUM,
+ attphysnum, relid);
+ datum = SysCacheGetAttr(ATTPHYSNUM,
tp,
Anum_pg_attribute_attfdwoptions,
&isnull);
diff --git a/src/backend/jit/llvm/llvmjit_deform.c b/src/backend/jit/llvm/llvmjit_deform.c
index 661f15272b..67e958a58a 100644
--- a/src/backend/jit/llvm/llvmjit_deform.c
+++ b/src/backend/jit/llvm/llvmjit_deform.c
@@ -87,7 +87,7 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
/* if true, known_alignment describes definite offset of column */
bool attguaranteedalign = true;
- int attnum;
+ int attphysnum;
/* virtual tuples never need deforming, so don't generate code */
if (ops == &TTSOpsVirtual)
@@ -106,9 +106,9 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
* Check which columns have to exist, so we don't have to check the row's
* natts unnecessarily.
*/
- for (attnum = 0; attnum < desc->natts; attnum++)
+ for (attphysnum = 0; attphysnum < desc->natts; attphysnum++)
{
- Form_pg_attribute att = TupleDescAttr(desc, attnum);
+ Form_pg_attribute att = TupleDescAttr(desc, attphysnum);
/*
* If the column is declared NOT NULL then it must be present in every
@@ -124,7 +124,7 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
if (att->attnotnull &&
!att->atthasmissing &&
!att->attisdropped)
- guaranteed_column_number = attnum;
+ guaranteed_column_number = attphysnum;
}
/* Create the signature and function */
@@ -280,20 +280,20 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
}
/* build the basic block for each attribute, need them as jump target */
- for (attnum = 0; attnum < natts; attnum++)
+ for (attphysnum = 0; attphysnum < natts; attphysnum++)
{
- attcheckattnoblocks[attnum] =
- l_bb_append_v(v_deform_fn, "block.attr.%d.attcheckattno", attnum);
- attstartblocks[attnum] =
- l_bb_append_v(v_deform_fn, "block.attr.%d.start", attnum);
- attisnullblocks[attnum] =
- l_bb_append_v(v_deform_fn, "block.attr.%d.attisnull", attnum);
- attcheckalignblocks[attnum] =
- l_bb_append_v(v_deform_fn, "block.attr.%d.attcheckalign", attnum);
- attalignblocks[attnum] =
- l_bb_append_v(v_deform_fn, "block.attr.%d.align", attnum);
- attstoreblocks[attnum] =
- l_bb_append_v(v_deform_fn, "block.attr.%d.store", attnum);
+ attcheckattnoblocks[attphysnum] =
+ l_bb_append_v(v_deform_fn, "block.attr.%d.attcheckattno", attphysnum);
+ attstartblocks[attphysnum] =
+ l_bb_append_v(v_deform_fn, "block.attr.%d.start", attphysnum);
+ attisnullblocks[attphysnum] =
+ l_bb_append_v(v_deform_fn, "block.attr.%d.attisnull", attphysnum);
+ attcheckalignblocks[attphysnum] =
+ l_bb_append_v(v_deform_fn, "block.attr.%d.attcheckalign", attphysnum);
+ attalignblocks[attphysnum] =
+ l_bb_append_v(v_deform_fn, "block.attr.%d.align", attphysnum);
+ attstoreblocks[attphysnum] =
+ l_bb_append_v(v_deform_fn, "block.attr.%d.store", attphysnum);
}
/*
@@ -350,11 +350,11 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
LLVMValueRef v_switch = LLVMBuildSwitch(b, v_nvalid,
b_dead, natts);
- for (attnum = 0; attnum < natts; attnum++)
+ for (attphysnum = 0; attphysnum < natts; attphysnum++)
{
- LLVMValueRef v_attno = l_int16_const(attnum);
+ LLVMValueRef v_attno = l_int16_const(attphysnum);
- LLVMAddCase(v_switch, v_attno, attcheckattnoblocks[attnum]);
+ LLVMAddCase(v_switch, v_attno, attcheckattnoblocks[attphysnum]);
}
}
else
@@ -370,23 +370,23 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
* Iterate over each attribute that needs to be deformed, build code to
* deform it.
*/
- for (attnum = 0; attnum < natts; attnum++)
+ for (attphysnum = 0; attphysnum < natts; attphysnum++)
{
- Form_pg_attribute att = TupleDescAttr(desc, attnum);
+ Form_pg_attribute att = TupleDescAttr(desc, attphysnum);
LLVMValueRef v_incby;
int alignto;
- LLVMValueRef l_attno = l_int16_const(attnum);
+ LLVMValueRef l_attno = l_int16_const(attphysnum);
LLVMValueRef v_attdatap;
LLVMValueRef v_resultp;
/* build block checking whether we did all the necessary attributes */
- LLVMPositionBuilderAtEnd(b, attcheckattnoblocks[attnum]);
+ LLVMPositionBuilderAtEnd(b, attcheckattnoblocks[attphysnum]);
/*
* If this is the first attribute, slot->tts_nvalid was 0. Therefore
* also reset offset to 0, it may be from a previous execution.
*/
- if (attnum == 0)
+ if (attphysnum == 0)
{
LLVMBuildStore(b, l_sizet_const(0), v_offp);
}
@@ -396,9 +396,9 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
* that many columns stored). We can avoid the branch if we know
* there's a subsequent NOT NULL column.
*/
- if (attnum <= guaranteed_column_number)
+ if (attphysnum <= guaranteed_column_number)
{
- LLVMBuildBr(b, attstartblocks[attnum]);
+ LLVMBuildBr(b, attstartblocks[attphysnum]);
}
else
{
@@ -408,9 +408,9 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
l_attno,
v_maxatt,
"heap_natts");
- LLVMBuildCondBr(b, v_islast, b_out, attstartblocks[attnum]);
+ LLVMBuildCondBr(b, v_islast, b_out, attstartblocks[attphysnum]);
}
- LLVMPositionBuilderAtEnd(b, attstartblocks[attnum]);
+ LLVMPositionBuilderAtEnd(b, attstartblocks[attphysnum]);
/*
* Check for nulls if necessary. No need to take missing attributes
@@ -428,16 +428,16 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
LLVMValueRef v_nullbyte;
LLVMValueRef v_nullbit;
- b_ifnotnull = attcheckalignblocks[attnum];
- b_ifnull = attisnullblocks[attnum];
+ b_ifnotnull = attcheckalignblocks[attphysnum];
+ b_ifnull = attisnullblocks[attphysnum];
- if (attnum + 1 == natts)
+ if (attphysnum + 1 == natts)
b_next = b_out;
else
- b_next = attcheckattnoblocks[attnum + 1];
+ b_next = attcheckattnoblocks[attphysnum + 1];
- v_nullbyteno = l_int32_const(attnum >> 3);
- v_nullbytemask = l_int8_const(1 << ((attnum) & 0x07));
+ v_nullbyteno = l_int32_const(attphysnum >> 3);
+ v_nullbytemask = l_int8_const(1 << ((attphysnum) & 0x07));
v_nullbyte = l_load_gep1(b, v_bits, v_nullbyteno, "attnullbyte");
v_nullbit = LLVMBuildICmp(b,
@@ -467,11 +467,11 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
else
{
/* nothing to do */
- LLVMBuildBr(b, attcheckalignblocks[attnum]);
- LLVMPositionBuilderAtEnd(b, attisnullblocks[attnum]);
- LLVMBuildBr(b, attcheckalignblocks[attnum]);
+ LLVMBuildBr(b, attcheckalignblocks[attphysnum]);
+ LLVMPositionBuilderAtEnd(b, attisnullblocks[attphysnum]);
+ LLVMBuildBr(b, attcheckalignblocks[attphysnum]);
}
- LLVMPositionBuilderAtEnd(b, attcheckalignblocks[attnum]);
+ LLVMPositionBuilderAtEnd(b, attcheckalignblocks[attphysnum]);
/* determine required alignment */
if (att->attalign == TYPALIGN_INT)
@@ -527,15 +527,15 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
v_possible_padbyte, l_int8_const(0),
"ispadbyte");
LLVMBuildCondBr(b, v_ispad,
- attalignblocks[attnum],
- attstoreblocks[attnum]);
+ attalignblocks[attphysnum],
+ attstoreblocks[attphysnum]);
}
else
{
- LLVMBuildBr(b, attalignblocks[attnum]);
+ LLVMBuildBr(b, attalignblocks[attphysnum]);
}
- LLVMPositionBuilderAtEnd(b, attalignblocks[attnum]);
+ LLVMPositionBuilderAtEnd(b, attalignblocks[attphysnum]);
/* translation of alignment code (cf TYPEALIGN()) */
{
@@ -567,17 +567,17 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
known_alignment = TYPEALIGN(alignto, known_alignment);
}
- LLVMBuildBr(b, attstoreblocks[attnum]);
- LLVMPositionBuilderAtEnd(b, attstoreblocks[attnum]);
+ LLVMBuildBr(b, attstoreblocks[attphysnum]);
+ LLVMPositionBuilderAtEnd(b, attstoreblocks[attphysnum]);
}
else
{
- LLVMPositionBuilderAtEnd(b, attcheckalignblocks[attnum]);
- LLVMBuildBr(b, attalignblocks[attnum]);
- LLVMPositionBuilderAtEnd(b, attalignblocks[attnum]);
- LLVMBuildBr(b, attstoreblocks[attnum]);
+ LLVMPositionBuilderAtEnd(b, attcheckalignblocks[attphysnum]);
+ LLVMBuildBr(b, attalignblocks[attphysnum]);
+ LLVMPositionBuilderAtEnd(b, attalignblocks[attphysnum]);
+ LLVMBuildBr(b, attstoreblocks[attphysnum]);
}
- LLVMPositionBuilderAtEnd(b, attstoreblocks[attnum]);
+ LLVMPositionBuilderAtEnd(b, attstoreblocks[attphysnum]);
/*
* Store the current offset if known to be constant. That allows LLVM
@@ -720,14 +720,14 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
* jump to next block, unless last possible column, or all desired
* (available) attributes have been fetched.
*/
- if (attnum + 1 == natts)
+ if (attphysnum + 1 == natts)
{
/* jump out */
LLVMBuildBr(b, b_out);
}
else
{
- LLVMBuildBr(b, attcheckattnoblocks[attnum + 1]);
+ LLVMBuildBr(b, attcheckattnoblocks[attphysnum + 1]);
}
}
diff --git a/src/backend/jit/llvm/llvmjit_expr.c b/src/backend/jit/llvm/llvmjit_expr.c
index b6b6512ef1..f12bff8103 100644
--- a/src/backend/jit/llvm/llvmjit_expr.c
+++ b/src/backend/jit/llvm/llvmjit_expr.c
@@ -372,7 +372,7 @@ llvm_compile_expr(ExprState *state)
v_nulls = v_scannulls;
}
- v_attnum = l_int32_const(op->d.var.attnum);
+ v_attnum = l_int32_const(op->d.var.attphysnum);
value = l_load_gep1(b, v_values, v_attnum, "");
isnull = l_load_gep1(b, v_nulls, v_attnum, "");
LLVMBuildStore(b, value, v_resvaluep);
@@ -438,7 +438,7 @@ llvm_compile_expr(ExprState *state)
}
/* load data */
- v_attnum = l_int32_const(op->d.assign_var.attnum);
+ v_attnum = l_int32_const(op->d.assign_var.attphysnum);
v_value = l_load_gep1(b, v_values, v_attnum, "");
v_isnull = l_load_gep1(b, v_nulls, v_attnum, "");
diff --git a/src/backend/optimizer/util/appendinfo.c b/src/backend/optimizer/util/appendinfo.c
index 9d4bb47027..ca83ecb997 100644
--- a/src/backend/optimizer/util/appendinfo.c
+++ b/src/backend/optimizer/util/appendinfo.c
@@ -150,7 +150,7 @@ make_inh_translation_list(Relation oldrelation, Relation newrelation,
if (!HeapTupleIsValid(newtup))
elog(ERROR, "could not find inherited attribute \"%s\" of relation \"%s\"",
attname, RelationGetRelationName(newrelation));
- new_attno = ((Form_pg_attribute) GETSTRUCT(newtup))->attnum - 1;
+ new_attno = ((Form_pg_attribute) GETSTRUCT(newtup))->attphysnum - 1;
Assert(new_attno >= 0 && new_attno < newnatts);
ReleaseSysCache(newtup);
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 1bcb875507..5ced631957 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -1246,9 +1246,9 @@ count_rowexpr_columns(ParseState *pstate, Node *expr)
if (IsA(expr, Var))
{
Var *var = (Var *) expr;
- AttrNumber attnum = var->varattno;
+ AttrNumber attphysnum = var->varattno;
- if (attnum > 0 && var->vartype == RECORDOID)
+ if (attphysnum > 0 && var->vartype == RECORDOID)
{
RangeTblEntry *rte;
@@ -1257,7 +1257,7 @@ count_rowexpr_columns(ParseState *pstate, Node *expr)
{
/* Subselect-in-FROM: examine sub-select's output expr */
TargetEntry *ste = get_tle_by_resno(rte->subquery->targetList,
- attnum);
+ attphysnum);
if (ste == NULL || ste->resjunk)
return -1;
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index c655d188c7..d1b0080268 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -257,11 +257,11 @@ extractRemainingColumns(ParseNamespaceColumn *src_nscolumns,
{
int colcount = 0;
Bitmapset *prevcols;
- int attnum;
+ int attphysnum;
ListCell *lc;
/*
- * While we could just test "list_member_int(*src_colnos, attnum)" to
+ * While we could just test "list_member_int(*src_colnos, attphysnum)" to
* detect already-merged columns in the loop below, that would be O(N^2)
* for a wide input table. Instead build a bitmapset of just the merged
* USING columns, which we won't add to within the main loop.
@@ -272,22 +272,22 @@ extractRemainingColumns(ParseNamespaceColumn *src_nscolumns,
prevcols = bms_add_member(prevcols, lfirst_int(lc));
}
- attnum = 0;
+ attphysnum = 0;
foreach(lc, src_colnames)
{
char *colname = strVal(lfirst(lc));
- attnum++;
+ attphysnum++;
/* Non-dropped and not already merged? */
- if (colname[0] != '\0' && !bms_is_member(attnum, prevcols))
+ if (colname[0] != '\0' && !bms_is_member(attphysnum, prevcols))
{
/* Yes, so emit it as next output column */
- *src_colnos = lappend_int(*src_colnos, attnum);
+ *src_colnos = lappend_int(*src_colnos, attphysnum);
*res_colnames = lappend(*res_colnames, lfirst(lc));
*res_colvars = lappend(*res_colvars,
- buildVarFromNSColumn(src_nscolumns + attnum - 1));
+ buildVarFromNSColumn(src_nscolumns + attphysnum - 1));
/* Copy the input relation's nscolumn data for this column */
- res_nscolumns[colcount] = src_nscolumns[attnum - 1];
+ res_nscolumns[colcount] = src_nscolumns[attphysnum - 1];
colcount++;
}
}
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 926dcbf30e..27c3abb7ec 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -566,7 +566,7 @@ GetCTEForRTE(ParseState *pstate, RangeTblEntry *rte, int rtelevelsup)
static void
updateFuzzyAttrMatchState(int fuzzy_rte_penalty,
FuzzyAttrMatchState *fuzzystate, RangeTblEntry *rte,
- const char *actual, const char *match, int attnum)
+ const char *actual, const char *match, int attphysnum)
{
int columndistance;
int matchlen;
@@ -613,7 +613,7 @@ updateFuzzyAttrMatchState(int fuzzy_rte_penalty,
/* Store new lowest observed distance for RTE */
fuzzystate->distance = columndistance;
fuzzystate->rfirst = rte;
- fuzzystate->first = attnum;
+ fuzzystate->first = attphysnum;
fuzzystate->rsecond = NULL;
fuzzystate->second = InvalidAttrNumber;
}
@@ -640,7 +640,7 @@ updateFuzzyAttrMatchState(int fuzzy_rte_penalty,
{
/* Record as provisional second match for RTE */
fuzzystate->rsecond = rte;
- fuzzystate->second = attnum;
+ fuzzystate->second = attphysnum;
}
else if (fuzzystate->distance <= MAX_FUZZY_DISTANCE)
{
@@ -650,7 +650,7 @@ updateFuzzyAttrMatchState(int fuzzy_rte_penalty,
* than being associated with a real match)
*/
fuzzystate->rfirst = rte;
- fuzzystate->first = attnum;
+ fuzzystate->first = attphysnum;
}
}
}
@@ -669,23 +669,23 @@ scanNSItemForColumn(ParseState *pstate, ParseNamespaceItem *nsitem,
int sublevels_up, const char *colname, int location)
{
RangeTblEntry *rte = nsitem->p_rte;
- int attnum;
+ int attphysnum;
Var *var;
/*
* Scan the nsitem's column names (or aliases) for a match. Complain if
* multiple matches.
*/
- attnum = scanRTEForColumn(pstate, rte, nsitem->p_names,
+ attphysnum = scanRTEForColumn(pstate, rte, nsitem->p_names,
colname, location,
0, NULL);
- if (attnum == InvalidAttrNumber)
+ if (attphysnum == InvalidAttrNumber)
return NULL; /* Return NULL if no match */
/* In constraint check, no system column is allowed except tableOid */
if (pstate->p_expr_kind == EXPR_KIND_CHECK_CONSTRAINT &&
- attnum < InvalidAttrNumber && attnum != TableOidAttributeNumber)
+ attphysnum < InvalidAttrNumber && attphysnum != TableOidAttributeNumber)
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("system column \"%s\" reference in check constraint is invalid",
@@ -694,7 +694,7 @@ scanNSItemForColumn(ParseState *pstate, ParseNamespaceItem *nsitem,
/* In generated column, no system column is allowed except tableOid */
if (pstate->p_expr_kind == EXPR_KIND_GENERATED_COLUMN &&
- attnum < InvalidAttrNumber && attnum != TableOidAttributeNumber)
+ attphysnum < InvalidAttrNumber && attphysnum != TableOidAttributeNumber)
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("cannot use system column \"%s\" in column generation expression",
@@ -705,7 +705,7 @@ scanNSItemForColumn(ParseState *pstate, ParseNamespaceItem *nsitem,
* In a MERGE WHEN condition, no system column is allowed except tableOid
*/
if (pstate->p_expr_kind == EXPR_KIND_MERGE_WHEN &&
- attnum < InvalidAttrNumber && attnum != TableOidAttributeNumber)
+ attphysnum < InvalidAttrNumber && attphysnum != TableOidAttributeNumber)
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("cannot use system column \"%s\" in MERGE WHEN condition",
@@ -713,10 +713,10 @@ scanNSItemForColumn(ParseState *pstate, ParseNamespaceItem *nsitem,
parser_errposition(pstate, location)));
/* Found a valid match, so build a Var */
- if (attnum > InvalidAttrNumber)
+ if (attphysnum > InvalidAttrNumber)
{
/* Get attribute data from the ParseNamespaceColumn array */
- ParseNamespaceColumn *nscol = &nsitem->p_nscolumns[attnum - 1];
+ ParseNamespaceColumn *nscol = &nsitem->p_nscolumns[attphysnum - 1];
/* Complain if dropped column. See notes in scanRTEForColumn. */
if (nscol->p_varno == 0)
@@ -741,9 +741,9 @@ scanNSItemForColumn(ParseState *pstate, ParseNamespaceItem *nsitem,
/* System column, so use predetermined type data */
const FormData_pg_attribute *sysatt;
- sysatt = SystemAttributeDefinition(attnum);
+ sysatt = SystemAttributeDefinition(attphysnum);
var = makeVar(nsitem->p_rtindex,
- attnum,
+ attphysnum,
sysatt->atttypid,
sysatt->atttypmod,
sysatt->attcollation,
@@ -760,7 +760,7 @@ scanNSItemForColumn(ParseState *pstate, ParseNamespaceItem *nsitem,
/*
* scanRTEForColumn
* Search the column names of a single RTE for the given name.
- * If found, return the attnum (possibly negative, for a system column);
+ * If found, return the attphysnum (possibly negative, for a system column);
* else return InvalidAttrNumber.
* If the name proves ambiguous within this RTE, raise error.
*
@@ -789,7 +789,7 @@ scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte,
FuzzyAttrMatchState *fuzzystate)
{
int result = InvalidAttrNumber;
- int attnum = 0;
+ int attphysnum = 0;
ListCell *c;
/*
@@ -809,7 +809,7 @@ scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte,
{
const char *attcolname = strVal(lfirst(c));
- attnum++;
+ attphysnum++;
if (strcmp(attcolname, colname) == 0)
{
if (result)
@@ -818,13 +818,13 @@ scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte,
errmsg("column reference \"%s\" is ambiguous",
colname),
parser_errposition(pstate, location)));
- result = attnum;
+ result = attphysnum;
}
/* Update fuzzy match state, if provided. */
if (fuzzystate != NULL)
updateFuzzyAttrMatchState(fuzzy_rte_penalty, fuzzystate,
- rte, attcolname, colname, attnum);
+ rte, attcolname, colname, attphysnum);
}
/*
@@ -843,14 +843,14 @@ scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte,
rte->relkind != RELKIND_COMPOSITE_TYPE)
{
/* quick check to see if name could be a system column */
- attnum = specialAttNum(colname);
- if (attnum != InvalidAttrNumber)
+ attphysnum = specialAttNum(colname);
+ if (attphysnum != InvalidAttrNumber)
{
/* now check to see if column actually is defined */
- if (SearchSysCacheExists2(ATTNUM,
+ if (SearchSysCacheExists2(ATTPHYSNUM,
ObjectIdGetDatum(rte->relid),
- Int16GetDatum(attnum)))
- result = attnum;
+ Int16GetDatum(attphysnum)))
+ result = attphysnum;
}
}
@@ -1023,7 +1023,7 @@ markRTEForSelectPriv(ParseState *pstate, int rtindex, AttrNumber col)
{
/* Make sure the rel as a whole is marked for SELECT access */
rte->requiredPerms |= ACL_SELECT;
- /* Must offset the attnum to fit in a bitmapset */
+ /* Must offset the attphysnum to fit in a bitmapset */
rte->selectedCols = bms_add_member(rte->selectedCols,
col - FirstLowInvalidHeapAttributeNumber);
}
@@ -2746,7 +2746,7 @@ expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
ListCell *l1;
ListCell *l2;
ListCell *l3;
- int attnum = atts_done;
+ int attphysnum = atts_done;
forthree(l1, rtfunc->funccoltypes,
l2, rtfunc->funccoltypmods,
@@ -2757,9 +2757,9 @@ expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
Oid attrcollation = lfirst_oid(l3);
Var *varnode;
- attnum++;
+ attphysnum++;
varnode = makeVar(rtindex,
- attnum,
+ attphysnum,
attrtype,
attrtypmod,
attrcollation,
@@ -3181,21 +3181,21 @@ expandNSItemAttrs(ParseState *pstate, ParseNamespaceItem *nsitem,
* In particular, it will work on an RTE for a subselect or join, whereas
* get_attname() only works on real relations.
*
- * "*" is returned if the given attnum is InvalidAttrNumber --- this case
+ * "*" is returned if the given attphysnum is InvalidAttrNumber --- this case
* occurs when a Var represents a whole tuple of a relation.
*/
char *
-get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
+get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attphysnum)
{
- if (attnum == InvalidAttrNumber)
+ if (attphysnum == InvalidAttrNumber)
return "*";
/*
* If there is a user-written column alias, use it.
*/
if (rte->alias &&
- attnum > 0 && attnum <= list_length(rte->alias->colnames))
- return strVal(list_nth(rte->alias->colnames, attnum - 1));
+ attphysnum > 0 && attphysnum <= list_length(rte->alias->colnames))
+ return strVal(list_nth(rte->alias->colnames, attphysnum - 1));
/*
* If the RTE is a relation, go to the system catalogs not the
@@ -3204,17 +3204,17 @@ get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
* built (which can easily happen for rules).
*/
if (rte->rtekind == RTE_RELATION)
- return get_attname(rte->relid, attnum, false);
+ return get_attname(rte->relid, attphysnum, false);
/*
* Otherwise use the column name from eref. There should always be one.
*/
- if (attnum > 0 && attnum <= list_length(rte->eref->colnames))
- return strVal(list_nth(rte->eref->colnames, attnum - 1));
+ if (attphysnum > 0 && attphysnum <= list_length(rte->eref->colnames))
+ return strVal(list_nth(rte->eref->colnames, attphysnum - 1));
- /* else caller gave us a bogus attnum */
- elog(ERROR, "invalid attnum %d for rangetable entry %s",
- attnum, rte->eref->aliasname);
+ /* else caller gave us a bogus attphysnum */
+ elog(ERROR, "invalid attphysnum %d for rangetable entry %s",
+ attphysnum, rte->eref->aliasname);
return NULL; /* keep compiler quiet */
}
@@ -3223,7 +3223,7 @@ get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
* Check whether attempted attribute ref is to a dropped column
*/
bool
-get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
+get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attphysnum)
{
bool result;
@@ -3237,12 +3237,12 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
HeapTuple tp;
Form_pg_attribute att_tup;
- tp = SearchSysCache2(ATTNUM,
+ tp = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(rte->relid),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
- attnum, rte->relid);
+ attphysnum, rte->relid);
att_tup = (Form_pg_attribute) GETSTRUCT(tp);
result = att_tup->attisdropped;
ReleaseSysCache(tp);
@@ -3262,10 +3262,10 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
case RTE_NAMEDTUPLESTORE:
{
/* Check dropped-ness by testing for valid coltype */
- if (attnum <= 0 ||
- attnum > list_length(rte->coltypes))
- elog(ERROR, "invalid varattno %d", attnum);
- result = !OidIsValid((list_nth_oid(rte->coltypes, attnum - 1)));
+ if (attphysnum <= 0 ||
+ attphysnum > list_length(rte->coltypes))
+ elog(ERROR, "invalid varattno %d", attphysnum);
+ result = !OidIsValid((list_nth_oid(rte->coltypes, attphysnum - 1)));
}
break;
case RTE_JOIN:
@@ -3279,10 +3279,10 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
*/
Var *aliasvar;
- if (attnum <= 0 ||
- attnum > list_length(rte->joinaliasvars))
- elog(ERROR, "invalid varattno %d", attnum);
- aliasvar = (Var *) list_nth(rte->joinaliasvars, attnum - 1);
+ if (attphysnum <= 0 ||
+ attphysnum > list_length(rte->joinaliasvars))
+ elog(ERROR, "invalid varattno %d", attphysnum);
+ aliasvar = (Var *) list_nth(rte->joinaliasvars, attphysnum - 1);
result = (aliasvar == NULL);
}
@@ -3304,8 +3304,8 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
{
RangeTblFunction *rtfunc = (RangeTblFunction *) lfirst(lc);
- if (attnum > atts_done &&
- attnum <= atts_done + rtfunc->funccolcount)
+ if (attphysnum > atts_done &&
+ attphysnum <= atts_done + rtfunc->funccolcount)
{
TupleDesc tupdesc;
@@ -3317,9 +3317,9 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
Form_pg_attribute att_tup;
Assert(tupdesc);
- Assert(attnum - atts_done <= tupdesc->natts);
+ Assert(attphysnum - atts_done <= tupdesc->natts);
att_tup = TupleDescAttr(tupdesc,
- attnum - atts_done - 1);
+ attphysnum - atts_done - 1);
return att_tup->attisdropped;
}
/* Otherwise, it can't have any dropped columns */
@@ -3329,14 +3329,14 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
}
/* If we get here, must be looking for the ordinality column */
- if (rte->funcordinality && attnum == atts_done + 1)
+ if (rte->funcordinality && attphysnum == atts_done + 1)
return false;
/* this probably can't happen ... */
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column %d of relation \"%s\" does not exist",
- attnum,
+ attphysnum,
rte->eref->aliasname)));
result = false; /* keep compiler quiet */
}
@@ -3346,7 +3346,7 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column %d of relation \"%s\" does not exist",
- attnum,
+ attphysnum,
rte->eref->aliasname)));
result = false; /* keep compiler quiet */
break;
@@ -3402,12 +3402,12 @@ get_parse_rowmark(Query *qry, Index rtindex)
}
/*
- * given relation and att name, return attnum of variable
+ * given relation and att name, return attphysnum of variable
*
* Returns InvalidAttrNumber if the attr doesn't exist (or is dropped).
*
* This should only be used if the relation is already
- * table_open()'ed. Use the cache version get_attnum()
+ * table_open()'ed. Use the cache version get_attphysnum()
* for access to non-opened relations.
*/
int
@@ -3448,7 +3448,7 @@ specialAttNum(const char *attname)
sysatt = SystemAttributeByName(attname);
if (sysatt != NULL)
- return sysatt->attnum;
+ return sysatt->attphysnum;
return InvalidAttrNumber;
}
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index 2a1d44b813..cff1cda48d 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -347,31 +347,31 @@ markTargetListOrigin(ParseState *pstate, TargetEntry *tle,
{
int netlevelsup;
RangeTblEntry *rte;
- AttrNumber attnum;
+ AttrNumber attphysnum;
if (var == NULL || !IsA(var, Var))
return;
netlevelsup = var->varlevelsup + levelsup;
rte = GetRTEByRangeTablePosn(pstate, var->varno, netlevelsup);
- attnum = var->varattno;
+ attphysnum = var->varattno;
switch (rte->rtekind)
{
case RTE_RELATION:
/* It's a table or view, report it */
tle->resorigtbl = rte->relid;
- tle->resorigcol = attnum;
+ tle->resorigcol = attphysnum;
break;
case RTE_SUBQUERY:
/* Subselect-in-FROM: copy up from the subselect */
- if (attnum != InvalidAttrNumber)
+ if (attphysnum != InvalidAttrNumber)
{
TargetEntry *ste = get_tle_by_resno(rte->subquery->targetList,
- attnum);
+ attphysnum);
if (ste == NULL || ste->resjunk)
elog(ERROR, "subquery %s does not have attribute %d",
- rte->eref->aliasname, attnum);
+ rte->eref->aliasname, attphysnum);
tle->resorigtbl = ste->resorigtbl;
tle->resorigcol = ste->resorigcol;
}
@@ -394,7 +394,7 @@ markTargetListOrigin(ParseState *pstate, TargetEntry *tle,
* recursive CTE, and so any markings on the current targetlist
* are not going to affect the results anyway.
*/
- if (attnum != InvalidAttrNumber && !rte->self_reference)
+ if (attphysnum != InvalidAttrNumber && !rte->self_reference)
{
CommonTableExpr *cte = GetCTEForRTE(pstate, rte, netlevelsup);
TargetEntry *ste;
@@ -410,14 +410,14 @@ markTargetListOrigin(ParseState *pstate, TargetEntry *tle,
if (cte->cycle_clause)
extra_cols += 2;
if (extra_cols &&
- attnum > list_length(tl) &&
- attnum <= list_length(tl) + extra_cols)
+ attphysnum > list_length(tl) &&
+ attphysnum <= list_length(tl) + extra_cols)
break;
- ste = get_tle_by_resno(tl, attnum);
+ ste = get_tle_by_resno(tl, attphysnum);
if (ste == NULL || ste->resjunk)
elog(ERROR, "CTE %s does not have attribute %d",
- rte->eref->aliasname, attnum);
+ rte->eref->aliasname, attphysnum);
tle->resorigtbl = ste->resorigtbl;
tle->resorigcol = ste->resorigcol;
}
@@ -745,7 +745,7 @@ transformAssignmentIndirection(ParseState *pstate,
Oid baseTypeId;
int32 baseTypeMod;
Oid typrelid;
- AttrNumber attnum;
+ AttrNumber attphysnum;
Oid fieldTypeId;
int32 fieldTypMod;
Oid fieldCollation;
@@ -789,22 +789,22 @@ transformAssignmentIndirection(ParseState *pstate,
format_type_be(targetTypeId)),
parser_errposition(pstate, location)));
- attnum = get_attnum(typrelid, strVal(n));
- if (attnum == InvalidAttrNumber)
+ attphysnum = get_attphysnum(typrelid, strVal(n));
+ if (attphysnum == InvalidAttrNumber)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("cannot assign to field \"%s\" of column \"%s\" because there is no such column in data type %s",
strVal(n), targetName,
format_type_be(targetTypeId)),
parser_errposition(pstate, location)));
- if (attnum < 0)
+ if (attphysnum < 0)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("cannot assign to system column \"%s\"",
strVal(n)),
parser_errposition(pstate, location)));
- get_atttypetypmodcoll(typrelid, attnum,
+ get_atttypetypmodcoll(typrelid, attphysnum,
&fieldTypeId, &fieldTypMod, &fieldCollation);
/* recurse to create appropriate RHS for field assign */
@@ -825,7 +825,7 @@ transformAssignmentIndirection(ParseState *pstate,
fstore = makeNode(FieldStore);
fstore->arg = (Expr *) basenode;
fstore->newvals = list_make1(rhs);
- fstore->fieldnums = list_make1_int(attnum);
+ fstore->fieldnums = list_make1_int(attphysnum);
fstore->resulttype = baseTypeId;
/* If target is a domain, apply constraints */
@@ -1512,7 +1512,7 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
TupleDesc tupleDesc;
int netlevelsup;
RangeTblEntry *rte;
- AttrNumber attnum;
+ AttrNumber attphysnum;
Node *expr;
/* Check my caller didn't mess up */
@@ -1527,9 +1527,9 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
*/
netlevelsup = var->varlevelsup + levelsup;
rte = GetRTEByRangeTablePosn(pstate, var->varno, netlevelsup);
- attnum = var->varattno;
+ attphysnum = var->varattno;
- if (attnum == InvalidAttrNumber)
+ if (attphysnum == InvalidAttrNumber)
{
/* Whole-row reference to an RTE, so expand the known fields */
List *names,
@@ -1581,11 +1581,11 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
{
/* Subselect-in-FROM: examine sub-select's output expr */
TargetEntry *ste = get_tle_by_resno(rte->subquery->targetList,
- attnum);
+ attphysnum);
if (ste == NULL || ste->resjunk)
elog(ERROR, "subquery %s does not have attribute %d",
- rte->eref->aliasname, attnum);
+ rte->eref->aliasname, attphysnum);
expr = (Node *) ste->expr;
if (IsA(expr, Var))
{
@@ -1608,8 +1608,8 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
break;
case RTE_JOIN:
/* Join RTE --- recursively inspect the alias variable */
- Assert(attnum > 0 && attnum <= list_length(rte->joinaliasvars));
- expr = (Node *) list_nth(rte->joinaliasvars, attnum - 1);
+ Assert(attphysnum > 0 && attphysnum <= list_length(rte->joinaliasvars));
+ expr = (Node *) list_nth(rte->joinaliasvars, attphysnum - 1);
Assert(expr != NULL);
/* We intentionally don't strip implicit coercions here */
if (IsA(expr, Var))
@@ -1636,10 +1636,10 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
CommonTableExpr *cte = GetCTEForRTE(pstate, rte, netlevelsup);
TargetEntry *ste;
- ste = get_tle_by_resno(GetCTETargetList(cte), attnum);
+ ste = get_tle_by_resno(GetCTETargetList(cte), attphysnum);
if (ste == NULL || ste->resjunk)
elog(ERROR, "CTE %s does not have attribute %d",
- rte->eref->aliasname, attnum);
+ rte->eref->aliasname, attphysnum);
expr = (Node *) ste->expr;
if (IsA(expr, Var))
{
diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c
index 307114a30d..1959ef3bc1 100644
--- a/src/backend/parser/parse_type.c
+++ b/src/backend/parser/parse_type.c
@@ -89,7 +89,7 @@ LookupTypeNameExtended(ParseState *pstate,
RangeVar *rel = makeRangeVar(NULL, NULL, typeName->location);
char *field = NULL;
Oid relid;
- AttrNumber attnum;
+ AttrNumber attphysnum;
/* deconstruct the name list */
switch (list_length(typeName->names))
@@ -133,8 +133,8 @@ LookupTypeNameExtended(ParseState *pstate,
* penalty and would also require a permissions check.
*/
relid = RangeVarGetRelid(rel, NoLock, missing_ok);
- attnum = get_attnum(relid, field);
- if (attnum == InvalidAttrNumber)
+ attphysnum = get_attphysnum(relid, field);
+ if (attphysnum == InvalidAttrNumber)
{
if (missing_ok)
typoid = InvalidOid;
@@ -147,7 +147,7 @@ LookupTypeNameExtended(ParseState *pstate,
}
else
{
- typoid = get_atttype(relid, attnum);
+ typoid = get_atttype(relid, attphysnum);
/* this construct should never have an array indicator */
Assert(typeName->arrayBounds == NIL);
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 1a64a52279..69132f729d 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -487,7 +487,7 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column,
* owned by this column, and add it to the appropriate list of things to
* be done along with this CREATE/ALTER TABLE. In a CREATE or ALTER ADD
* COLUMN, it must be done after the statement because we don't know the
- * column's attnum yet. But if we do have the attnum (in AT_AddIdentity),
+ * column's attphysnum yet. But if we do have the attphysnum (in AT_AddIdentity),
* we can do the marking immediately, which improves some ALTER TABLE
* behaviors.
*/
@@ -1070,7 +1070,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
* find sequence owned by old column; extract sequence parameters;
* build new create sequence command
*/
- seq_relid = getIdentitySequence(RelationGetRelid(relation), attribute->attnum, false);
+ seq_relid = getIdentitySequence(RelationGetRelid(relation), attribute->attphysnum, false);
seq_options = sequence_options(seq_relid);
generateSerialExtraStmts(cxt, def,
InvalidOid, seq_options,
@@ -1097,7 +1097,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
if ((table_like_clause->options & CREATE_TABLE_LIKE_COMMENTS) &&
(comment = GetComment(attribute->attrelid,
RelationRelationId,
- attribute->attnum)) != NULL)
+ attribute->attphysnum)) != NULL)
{
CommentStmt *stmt = makeNode(CommentStmt);
@@ -1701,20 +1701,20 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
for (keyno = 0; keyno < idxrec->indnkeyatts; keyno++)
{
IndexElem *iparam;
- AttrNumber attnum = idxrec->indkey.values[keyno];
+ AttrNumber attphysnum = idxrec->indkey.values[keyno];
Form_pg_attribute attr = TupleDescAttr(RelationGetDescr(source_idx),
keyno);
int16 opt = source_idx->rd_indoption[keyno];
iparam = makeNode(IndexElem);
- if (AttributeNumberIsValid(attnum))
+ if (AttributeNumberIsValid(attphysnum))
{
/* Simple index column */
char *attname;
- attname = get_attname(indrelid, attnum, false);
- keycoltype = get_atttype(indrelid, attnum);
+ attname = get_attname(indrelid, attphysnum, false);
+ keycoltype = get_atttype(indrelid, attphysnum);
iparam->name = attname;
iparam->expr = NULL;
@@ -1793,18 +1793,18 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
for (keyno = idxrec->indnkeyatts; keyno < idxrec->indnatts; keyno++)
{
IndexElem *iparam;
- AttrNumber attnum = idxrec->indkey.values[keyno];
+ AttrNumber attphysnum = idxrec->indkey.values[keyno];
Form_pg_attribute attr = TupleDescAttr(RelationGetDescr(source_idx),
keyno);
iparam = makeNode(IndexElem);
- if (AttributeNumberIsValid(attnum))
+ if (AttributeNumberIsValid(attphysnum))
{
/* Simple index column */
char *attname;
- attname = get_attname(indrelid, attnum, false);
+ attname = get_attname(indrelid, attphysnum, false);
iparam->name = attname;
iparam->expr = NULL;
@@ -1922,9 +1922,9 @@ generateClonedExtStatsStmt(RangeVar *heapRel, Oid heapRelid,
for (i = 0; i < statsrec->stxkeys.dim1; i++)
{
StatsElem *selem = makeNode(StatsElem);
- AttrNumber attnum = statsrec->stxkeys.values[i];
+ AttrNumber attphysnum = statsrec->stxkeys.values[i];
- selem->name = get_attname(heapRelid, attnum, false);
+ selem->name = get_attname(heapRelid, attphysnum, false);
selem->expr = NULL;
def_names = lappend(def_names, selem);
@@ -2330,23 +2330,23 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
for (i = 0; i < index_form->indnatts; i++)
{
- int16 attnum = index_form->indkey.values[i];
+ int16 attphysnum = index_form->indkey.values[i];
const FormData_pg_attribute *attform;
char *attname;
Oid defopclass;
/*
- * We shouldn't see attnum == 0 here, since we already rejected
+ * We shouldn't see attphysnum == 0 here, since we already rejected
* expression indexes. If we do, SystemAttributeDefinition will
* throw an error.
*/
- if (attnum > 0)
+ if (attphysnum > 0)
{
- Assert(attnum <= heap_rel->rd_att->natts);
- attform = TupleDescAttr(heap_rel->rd_att, attnum - 1);
+ Assert(attphysnum <= heap_rel->rd_att->natts);
+ attform = TupleDescAttr(heap_rel->rd_att, attphysnum - 1);
}
else
- attform = SystemAttributeDefinition(attnum);
+ attform = SystemAttributeDefinition(attphysnum);
attname = pstrdup(NameStr(attform->attname));
if (i < index_form->indnkeyatts)
@@ -3400,7 +3400,7 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
case AT_AlterColumnType:
{
ColumnDef *def = castNode(ColumnDef, cmd->def);
- AttrNumber attnum;
+ AttrNumber attphysnum;
/*
* For ALTER COLUMN TYPE, transform the USING clause if
@@ -3417,17 +3417,17 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
* For identity column, create ALTER SEQUENCE command to
* change the data type of the sequence.
*/
- attnum = get_attnum(relid, cmd->name);
- if (attnum == InvalidAttrNumber)
+ attphysnum = get_attphysnum(relid, cmd->name);
+ if (attphysnum == InvalidAttrNumber)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
cmd->name, RelationGetRelationName(rel))));
- if (attnum > 0 &&
- TupleDescAttr(tupdesc, attnum - 1)->attidentity)
+ if (attphysnum > 0 &&
+ TupleDescAttr(tupdesc, attphysnum - 1)->attidentity)
{
- Oid seq_relid = getIdentitySequence(relid, attnum, false);
+ Oid seq_relid = getIdentitySequence(relid, attphysnum, false);
Oid typeOid = typenameTypeId(pstate, def->typeName);
AlterSeqStmt *altseqstmt = makeNode(AlterSeqStmt);
@@ -3447,21 +3447,21 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
{
Constraint *def = castNode(Constraint, cmd->def);
ColumnDef *newdef = makeNode(ColumnDef);
- AttrNumber attnum;
+ AttrNumber attphysnum;
newdef->colname = cmd->name;
newdef->identity = def->generated_when;
cmd->def = (Node *) newdef;
- attnum = get_attnum(relid, cmd->name);
- if (attnum == InvalidAttrNumber)
+ attphysnum = get_attphysnum(relid, cmd->name);
+ if (attphysnum == InvalidAttrNumber)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
cmd->name, RelationGetRelationName(rel))));
generateSerialExtraStmts(&cxt, newdef,
- get_atttype(relid, attnum),
+ get_atttype(relid, attphysnum),
def->options, true, true,
NULL, NULL);
@@ -3478,7 +3478,7 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
ListCell *lc;
List *newseqopts = NIL;
List *newdef = NIL;
- AttrNumber attnum;
+ AttrNumber attphysnum;
Oid seq_relid;
/*
@@ -3495,14 +3495,14 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
newseqopts = lappend(newseqopts, def);
}
- attnum = get_attnum(relid, cmd->name);
- if (attnum == InvalidAttrNumber)
+ attphysnum = get_attphysnum(relid, cmd->name);
+ if (attphysnum == InvalidAttrNumber)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
cmd->name, RelationGetRelationName(rel))));
- seq_relid = getIdentitySequence(relid, attnum, true);
+ seq_relid = getIdentitySequence(relid, attphysnum, true);
if (seq_relid)
{
diff --git a/src/backend/replication/basebackup_copy.c b/src/backend/replication/basebackup_copy.c
index cabb077240..38d792884e 100644
--- a/src/backend/replication/basebackup_copy.c
+++ b/src/backend/replication/basebackup_copy.c
@@ -346,7 +346,7 @@ SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli)
/* Field headers */
pq_sendstring(&buf, "recptr");
pq_sendint32(&buf, 0); /* table oid */
- pq_sendint16(&buf, 0); /* attnum */
+ pq_sendint16(&buf, 0); /* attphysnum */
pq_sendint32(&buf, TEXTOID); /* type oid */
pq_sendint16(&buf, -1);
pq_sendint32(&buf, 0);
@@ -354,7 +354,7 @@ SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli)
pq_sendstring(&buf, "tli");
pq_sendint32(&buf, 0); /* table oid */
- pq_sendint16(&buf, 0); /* attnum */
+ pq_sendint16(&buf, 0); /* attphysnum */
/*
* int8 may seem like a surprising data type for this, but in theory int4
@@ -401,7 +401,7 @@ SendTablespaceList(List *tablespaces)
/* First field - spcoid */
pq_sendstring(&buf, "spcoid");
pq_sendint32(&buf, 0); /* table oid */
- pq_sendint16(&buf, 0); /* attnum */
+ pq_sendint16(&buf, 0); /* attphysnum */
pq_sendint32(&buf, OIDOID); /* type oid */
pq_sendint16(&buf, 4); /* typlen */
pq_sendint32(&buf, 0); /* typmod */
diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c
index ff8513e2d2..0e68aa0d9d 100644
--- a/src/backend/replication/logical/proto.c
+++ b/src/backend/replication/logical/proto.c
@@ -47,9 +47,9 @@ static const char *logicalrep_read_namespace(StringInfo in);
* all columns.
*/
static bool
-column_in_column_list(int attnum, Bitmapset *columns)
+column_in_column_list(int attphysnum, Bitmapset *columns)
{
- return (columns == NULL || bms_is_member(attnum, columns));
+ return (columns == NULL || bms_is_member(attphysnum, columns));
}
@@ -783,7 +783,7 @@ logicalrep_write_tuple(StringInfo out, Relation rel, TupleTableSlot *slot,
if (att->attisdropped || att->attgenerated)
continue;
- if (!column_in_column_list(att->attnum, columns))
+ if (!column_in_column_list(att->attphysnum, columns))
continue;
nliveatts++;
@@ -804,7 +804,7 @@ logicalrep_write_tuple(StringInfo out, Relation rel, TupleTableSlot *slot,
if (att->attisdropped || att->attgenerated)
continue;
- if (!column_in_column_list(att->attnum, columns))
+ if (!column_in_column_list(att->attphysnum, columns))
continue;
if (isnull[i])
@@ -946,7 +946,7 @@ logicalrep_write_attrs(StringInfo out, Relation rel, Bitmapset *columns)
if (att->attisdropped || att->attgenerated)
continue;
- if (!column_in_column_list(att->attnum, columns))
+ if (!column_in_column_list(att->attphysnum, columns))
continue;
nliveatts++;
@@ -967,12 +967,12 @@ logicalrep_write_attrs(StringInfo out, Relation rel, Bitmapset *columns)
if (att->attisdropped || att->attgenerated)
continue;
- if (!column_in_column_list(att->attnum, columns))
+ if (!column_in_column_list(att->attphysnum, columns))
continue;
/* REPLICA IDENTITY FULL means all columns are sent as part of key. */
if (replidentfull ||
- bms_is_member(att->attnum - FirstLowInvalidHeapAttributeNumber,
+ bms_is_member(att->attphysnum - FirstLowInvalidHeapAttributeNumber,
idattrs))
flags |= LOGICALREP_IS_REPLICA_IDENTITY;
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index e989047681..a067446379 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -290,19 +290,19 @@ logicalrep_rel_mark_updatable(LogicalRepRelMapEntry *entry)
i = -1;
while ((i = bms_next_member(idkey, i)) >= 0)
{
- int attnum = i + FirstLowInvalidHeapAttributeNumber;
+ int attphysnum = i + FirstLowInvalidHeapAttributeNumber;
- if (!AttrNumberIsForUserDefinedAttr(attnum))
+ if (!AttrNumberIsForUserDefinedAttr(attphysnum))
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("logical replication target relation \"%s.%s\" uses "
"system columns in REPLICA IDENTITY index",
remoterel->nspname, remoterel->relname)));
- attnum = AttrNumberGetAttrOffset(attnum);
+ attphysnum = AttrNumberGetAttrOffset(attphysnum);
- if (entry->attrmap->attnums[attnum] < 0 ||
- !bms_is_member(entry->attrmap->attnums[attnum], remoterel->attkeys))
+ if (entry->attrmap->attnums[attphysnum] < 0 ||
+ !bms_is_member(entry->attrmap->attnums[attphysnum], remoterel->attkeys))
{
entry->updatable = false;
break;
@@ -410,7 +410,7 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
missingatts = bms_add_range(NULL, 0, remoterel->natts - 1);
for (i = 0; i < desc->natts; i++)
{
- int attnum;
+ int attphysnum;
Form_pg_attribute attr = TupleDescAttr(desc, i);
if (attr->attisdropped || attr->attgenerated)
@@ -419,12 +419,12 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
continue;
}
- attnum = logicalrep_rel_att_by_name(remoterel,
+ attphysnum = logicalrep_rel_att_by_name(remoterel,
NameStr(attr->attname));
- entry->attrmap->attnums[i] = attnum;
- if (attnum >= 0)
- missingatts = bms_del_member(missingatts, attnum);
+ entry->attrmap->attnums[i] = attphysnum;
+ if (attphysnum >= 0)
+ missingatts = bms_del_member(missingatts, attphysnum);
}
logicalrep_report_missing_attrs(remoterel, missingatts);
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 8da5f9089c..2dc47f8e02 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -4668,7 +4668,7 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,
Size data_done = 0;
/* system columns aren't toasted */
- if (attr->attnum < 0)
+ if (attr->attphysnum < 0)
continue;
if (attr->attisdropped)
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index 670c6fcada..ed527173fa 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -852,17 +852,17 @@ fetch_remote_table_info(char *nspname, char *relname,
*/
resetStringInfo(&cmd);
appendStringInfo(&cmd,
- "SELECT a.attnum,"
+ "SELECT a.attphysnum,"
" a.attname,"
" a.atttypid,"
- " a.attnum = ANY(i.indkey)"
+ " a.attphysnum = ANY(i.indkey)"
" FROM pg_catalog.pg_attribute a"
" LEFT JOIN pg_catalog.pg_index i"
" ON (i.indexrelid = pg_get_replica_identity_index(%u))"
- " WHERE a.attnum > 0::pg_catalog.int2"
+ " WHERE a.attphysnum > 0::pg_catalog.int2"
" AND NOT a.attisdropped %s"
" AND a.attrelid = %u"
- " ORDER BY a.attnum",
+ " ORDER BY a.attphysnum",
lrel->remoteid,
(walrcv_server_version(LogRepWorkerWalRcvConn) >= 120000 ?
"AND a.attgenerated = ''" : ""),
@@ -890,13 +890,13 @@ fetch_remote_table_info(char *nspname, char *relname,
while (tuplestore_gettupleslot(res->tuplestore, true, false, slot))
{
char *rel_colname;
- AttrNumber attnum;
+ AttrNumber attphysnum;
- attnum = DatumGetInt16(slot_getattr(slot, 1, &isnull));
+ attphysnum = DatumGetInt16(slot_getattr(slot, 1, &isnull));
Assert(!isnull);
/* If the column is not in the column list, skip it. */
- if (included_cols != NULL && !bms_is_member(attnum, included_cols))
+ if (included_cols != NULL && !bms_is_member(attphysnum, included_cols))
{
ExecClearTuple(slot);
continue;
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 38e3b1c1b3..89da19e43f 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -562,7 +562,7 @@ slot_fill_defaults(LogicalRepRelMapEntry *rel, EState *estate,
TupleDesc desc = RelationGetDescr(rel->localrel);
int num_phys_attrs = desc->natts;
int i;
- int attnum,
+ int attphysnum,
num_defaults = 0;
int *defmap;
ExprState **defexprs;
@@ -578,17 +578,17 @@ slot_fill_defaults(LogicalRepRelMapEntry *rel, EState *estate,
defexprs = (ExprState **) palloc(num_phys_attrs * sizeof(ExprState *));
Assert(rel->attrmap->maplen == num_phys_attrs);
- for (attnum = 0; attnum < num_phys_attrs; attnum++)
+ for (attphysnum = 0; attphysnum < num_phys_attrs; attphysnum++)
{
Expr *defexpr;
- if (TupleDescAttr(desc, attnum)->attisdropped || TupleDescAttr(desc, attnum)->attgenerated)
+ if (TupleDescAttr(desc, attphysnum)->attisdropped || TupleDescAttr(desc, attphysnum)->attgenerated)
continue;
- if (rel->attrmap->attnums[attnum] >= 0)
+ if (rel->attrmap->attnums[attphysnum] >= 0)
continue;
- defexpr = (Expr *) build_column_default(rel->localrel, attnum + 1);
+ defexpr = (Expr *) build_column_default(rel->localrel, attphysnum + 1);
if (defexpr != NULL)
{
@@ -597,7 +597,7 @@ slot_fill_defaults(LogicalRepRelMapEntry *rel, EState *estate,
/* Initialize executable expression in copycontext */
defexprs[num_defaults] = ExecInitExpr(defexpr, NULL);
- defmap[num_defaults] = attnum;
+ defmap[num_defaults] = attphysnum;
num_defaults++;
}
}
@@ -634,7 +634,7 @@ slot_store_data(TupleTableSlot *slot, LogicalRepRelMapEntry *rel,
Assert(remoteattnum < tupleData->ncols);
- /* Set attnum for error callback */
+ /* Set attphysnum for error callback */
apply_error_callback_arg.remote_attnum = remoteattnum;
if (tupleData->colstatus[remoteattnum] == LOGICALREP_COLUMN_TEXT)
@@ -683,7 +683,7 @@ slot_store_data(TupleTableSlot *slot, LogicalRepRelMapEntry *rel,
slot->tts_isnull[i] = true;
}
- /* Reset attnum for error callback */
+ /* Reset attphysnum for error callback */
apply_error_callback_arg.remote_attnum = -1;
}
else
@@ -749,7 +749,7 @@ slot_modify_data(TupleTableSlot *slot, TupleTableSlot *srcslot,
{
StringInfo colvalue = &tupleData->colvalues[remoteattnum];
- /* Set attnum for error callback */
+ /* Set attphysnum for error callback */
apply_error_callback_arg.remote_attnum = remoteattnum;
if (tupleData->colstatus[remoteattnum] == LOGICALREP_COLUMN_TEXT)
@@ -794,7 +794,7 @@ slot_modify_data(TupleTableSlot *slot, TupleTableSlot *srcslot,
slot->tts_isnull[i] = true;
}
- /* Reset attnum for error callback */
+ /* Reset attphysnum for error callback */
apply_error_callback_arg.remote_attnum = -1;
}
}
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c
index 8deae57143..caa4b4e9e2 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -737,7 +737,7 @@ send_relation_and_attrs(Relation relation, TransactionId xid,
continue;
/* Skip this attribute if it's not present in the column list */
- if (columns != NULL && !bms_is_member(att->attnum, columns))
+ if (columns != NULL && !bms_is_member(att->attphysnum, columns))
continue;
OutputPluginPrepareWrite(ctx, false);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index e42671722a..6b6430f941 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -602,7 +602,7 @@ SendTimeLineHistory(TimeLineHistoryCmd *cmd)
/* first field */
pq_sendstring(&buf, "filename"); /* col name */
pq_sendint32(&buf, 0); /* table oid */
- pq_sendint16(&buf, 0); /* attnum */
+ pq_sendint16(&buf, 0); /* attphysnum */
pq_sendint32(&buf, TEXTOID); /* type oid */
pq_sendint16(&buf, -1); /* typlen */
pq_sendint32(&buf, 0); /* typmod */
@@ -611,7 +611,7 @@ SendTimeLineHistory(TimeLineHistoryCmd *cmd)
/* second field */
pq_sendstring(&buf, "content"); /* col name */
pq_sendint32(&buf, 0); /* table oid */
- pq_sendint16(&buf, 0); /* attnum */
+ pq_sendint16(&buf, 0); /* attphysnum */
pq_sendint32(&buf, TEXTOID); /* type oid */
pq_sendint16(&buf, -1); /* typlen */
pq_sendint32(&buf, 0); /* typmod */
diff --git a/src/backend/statistics/dependencies.c b/src/backend/statistics/dependencies.c
index c1c27e67d4..db14e35c86 100644
--- a/src/backend/statistics/dependencies.c
+++ b/src/backend/statistics/dependencies.c
@@ -76,7 +76,7 @@ static double dependency_degree(StatsBuildData *data, int k, AttrNumber *depende
static bool dependency_is_fully_matched(MVDependency *dependency,
Bitmapset *attnums);
static bool dependency_is_compatible_clause(Node *clause, Index relid,
- AttrNumber *attnum);
+ AttrNumber *attphysnum);
static bool dependency_is_compatible_expression(Node *clause, Index relid,
List *statlist, Node **expr);
static MVDependency *find_strongest_dependency(MVDependencies **dependencies,
@@ -604,9 +604,9 @@ dependency_is_fully_matched(MVDependency *dependency, Bitmapset *attnums)
*/
for (j = 0; j < dependency->nattributes; j++)
{
- int attnum = dependency->attributes[j];
+ int attphysnum = dependency->attributes[j];
- if (!bms_is_member(attnum, attnums))
+ if (!bms_is_member(attphysnum, attnums))
return false;
}
@@ -737,10 +737,10 @@ pg_dependencies_send(PG_FUNCTION_ARGS)
* Only clauses that have the form of equality to a pseudoconstant, or can be
* interpreted that way, are currently accepted. Furthermore the variable
* part of the clause must be a simple Var belonging to the specified
- * relation, whose attribute number we return in *attnum on success.
+ * relation, whose attribute number we return in *attphysnum on success.
*/
static bool
-dependency_is_compatible_clause(Node *clause, Index relid, AttrNumber *attnum)
+dependency_is_compatible_clause(Node *clause, Index relid, AttrNumber *attphysnum)
{
Var *var;
Node *clause_expr;
@@ -839,7 +839,7 @@ dependency_is_compatible_clause(Node *clause, Index relid, AttrNumber *attnum)
ListCell *lc;
/* start with no attribute number */
- *attnum = InvalidAttrNumber;
+ *attphysnum = InvalidAttrNumber;
foreach(lc, bool_expr->args)
{
@@ -853,11 +853,11 @@ dependency_is_compatible_clause(Node *clause, Index relid, AttrNumber *attnum)
relid, &clause_attnum))
return false;
- if (*attnum == InvalidAttrNumber)
- *attnum = clause_attnum;
+ if (*attphysnum == InvalidAttrNumber)
+ *attphysnum = clause_attnum;
- /* ensure all the variables are the same (same attnum) */
- if (*attnum != clause_attnum)
+ /* ensure all the variables are the same (same attphysnum) */
+ if (*attphysnum != clause_attnum)
return false;
}
@@ -907,7 +907,7 @@ dependency_is_compatible_clause(Node *clause, Index relid, AttrNumber *attnum)
if (!AttrNumberIsForUserDefinedAttr(var->varattno))
return false;
- *attnum = var->varattno;
+ *attphysnum = var->varattno;
return true;
}
@@ -1041,9 +1041,9 @@ clauselist_apply_dependencies(PlannerInfo *root, List *clauses,
{
for (j = 0; j < dependencies[i]->nattributes; j++)
{
- AttrNumber attnum = dependencies[i]->attributes[j];
+ AttrNumber attphysnum = dependencies[i]->attributes[j];
- attnums = bms_add_member(attnums, attnum);
+ attnums = bms_add_member(attnums, attphysnum);
}
}
@@ -1106,7 +1106,7 @@ clauselist_apply_dependencies(PlannerInfo *root, List *clauses,
for (i = ndependencies - 1; i >= 0; i--)
{
MVDependency *dependency = dependencies[i];
- AttrNumber attnum;
+ AttrNumber attphysnum;
Selectivity s2;
double f;
@@ -1114,14 +1114,14 @@ clauselist_apply_dependencies(PlannerInfo *root, List *clauses,
s1 = 1.0;
for (j = 0; j < dependency->nattributes - 1; j++)
{
- attnum = dependency->attributes[j];
- attidx = bms_member_index(attnums, attnum);
+ attphysnum = dependency->attributes[j];
+ attidx = bms_member_index(attnums, attphysnum);
s1 *= attr_sel[attidx];
}
/* Original selectivity of the implied attribute */
- attnum = dependency->attributes[j];
- attidx = bms_member_index(attnums, attnum);
+ attphysnum = dependency->attributes[j];
+ attidx = bms_member_index(attnums, attphysnum);
s2 = attr_sel[attidx];
/*
@@ -1454,7 +1454,7 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
foreach(l, clauses)
{
Node *clause = (Node *) lfirst(l);
- AttrNumber attnum;
+ AttrNumber attphysnum;
Node *expr = NULL;
/* ignore clause by default */
@@ -1464,19 +1464,19 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
{
/*
* If it's a simple column reference, just extract the attnum. If
- * it's an expression, assign a negative attnum as if it was a
+ * it's an expression, assign a negative attphysnum as if it was a
* system attribute.
*/
- if (dependency_is_compatible_clause(clause, rel->relid, &attnum))
+ if (dependency_is_compatible_clause(clause, rel->relid, &attphysnum))
{
- list_attnums[listidx] = attnum;
+ list_attnums[listidx] = attphysnum;
}
else if (dependency_is_compatible_expression(clause, rel->relid,
rel->statlist,
&expr))
{
- /* special attnum assigned to this expression */
- attnum = InvalidAttrNumber;
+ /* special attphysnum assigned to this expression */
+ attphysnum = InvalidAttrNumber;
Assert(expr != NULL);
@@ -1486,22 +1486,22 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
if (equal(unique_exprs[i], expr))
{
/* negative attribute number to expression */
- attnum = -(i + 1);
+ attphysnum = -(i + 1);
break;
}
}
/* not found in the list, so add it */
- if (attnum == InvalidAttrNumber)
+ if (attphysnum == InvalidAttrNumber)
{
unique_exprs[unique_exprs_cnt++] = expr;
/* after incrementing the value, to get -1, -2, ... */
- attnum = (-unique_exprs_cnt);
+ attphysnum = (-unique_exprs_cnt);
}
- /* remember which attnum was assigned to this clause */
- list_attnums[listidx] = attnum;
+ /* remember which attphysnum was assigned to this clause */
+ list_attnums[listidx] = attphysnum;
}
}
@@ -1526,39 +1526,39 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
*/
for (i = 0; i < list_length(clauses); i++)
{
- AttrNumber attnum;
+ AttrNumber attphysnum;
/* ignore incompatible or already estimated clauses */
if (list_attnums[i] == InvalidAttrNumber)
continue;
- /* make sure the attnum is in the expected range */
+ /* make sure the attphysnum is in the expected range */
Assert(list_attnums[i] >= (-unique_exprs_cnt));
Assert(list_attnums[i] <= MaxHeapAttributeNumber);
- /* make sure the attnum is positive (valid AttrNumber) */
- attnum = list_attnums[i] + attnum_offset;
+ /* make sure the attphysnum is positive (valid AttrNumber) */
+ attphysnum = list_attnums[i] + attnum_offset;
/*
* Either it's a regular attribute, or it's an expression, in which
* case we must not have seen it before (expressions are unique).
*
* XXX Check whether it's a regular attribute has to be done using the
- * original attnum, while the second check has to use the value with
+ * original attphysnum, while the second check has to use the value with
* an offset.
*/
Assert(AttrNumberIsForUserDefinedAttr(list_attnums[i]) ||
- !bms_is_member(attnum, clauses_attnums));
+ !bms_is_member(attphysnum, clauses_attnums));
/*
- * Remember the offset attnum, both for attributes and expressions.
+ * Remember the offset attphysnum, both for attributes and expressions.
* We'll pass list_attnums to clauselist_apply_dependencies, which
* uses it to identify clauses in a bitmap. We could also pass the
* offset, but this is more convenient.
*/
- list_attnums[i] = attnum;
+ list_attnums[i] = attphysnum;
- clauses_attnums = bms_add_member(clauses_attnums, attnum);
+ clauses_attnums = bms_add_member(clauses_attnums, attphysnum);
}
/*
@@ -1606,7 +1606,7 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
continue;
/*
- * Count matching attributes - we have to undo the attnum offsets. The
+ * Count matching attributes - we have to undo the attphysnum offsets. The
* input attribute numbers are not offset (expressions are not
* included in stat->keys, so it's not necessary). But we need to
* offset it before checking against clauses_attnums.
@@ -1615,16 +1615,16 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
k = -1;
while ((k = bms_next_member(stat->keys, k)) >= 0)
{
- AttrNumber attnum = (AttrNumber) k;
+ AttrNumber attphysnum = (AttrNumber) k;
/* skip expressions */
- if (!AttrNumberIsForUserDefinedAttr(attnum))
+ if (!AttrNumberIsForUserDefinedAttr(attphysnum))
continue;
/* apply the same offset as above */
- attnum += attnum_offset;
+ attphysnum += attnum_offset;
- if (bms_is_member(attnum, clauses_attnums))
+ if (bms_is_member(attphysnum, clauses_attnums))
nmatched++;
}
@@ -1695,20 +1695,20 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
Node *expr;
int k;
AttrNumber unique_attnum = InvalidAttrNumber;
- AttrNumber attnum;
+ AttrNumber attphysnum;
/* undo the per-statistics offset */
- attnum = dep->attributes[j];
+ attphysnum = dep->attributes[j];
/*
* For regular attributes we can simply check if it
* matches any clause. If there's no matching clause, we
- * can just ignore it. We need to offset the attnum
+ * can just ignore it. We need to offset the attphysnum
* though.
*/
- if (AttrNumberIsForUserDefinedAttr(attnum))
+ if (AttrNumberIsForUserDefinedAttr(attphysnum))
{
- dep->attributes[j] = attnum + attnum_offset;
+ dep->attributes[j] = attphysnum + attnum_offset;
if (!bms_is_member(dep->attributes[j], clauses_attnums))
{
@@ -1720,20 +1720,20 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
}
/*
- * the attnum should be a valid system attnum (-1, -2,
+ * the attphysnum should be a valid system attphysnum (-1, -2,
* ...)
*/
- Assert(AttributeNumberIsValid(attnum));
+ Assert(AttributeNumberIsValid(attphysnum));
/*
* For expressions, we need to do two translations. First
- * we have to translate the negative attnum to index in
+ * we have to translate the negative attphysnum to index in
* the list of expressions (in the statistics object).
* Then we need to see if there's a matching clause. The
- * index of the unique expression determines the attnum
+ * index of the unique expression determines the attphysnum
* (and we offset it).
*/
- idx = -(1 + attnum);
+ idx = -(1 + attphysnum);
/* Is the expression index is valid? */
Assert((idx >= 0) && (idx < list_length(stat->exprs)));
@@ -1744,7 +1744,7 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
for (k = 0; k < unique_exprs_cnt; k++)
{
/*
- * found a matching unique expression, use the attnum
+ * found a matching unique expression, use the attphysnum
* (derived from index of the unique expression)
*/
if (equal(unique_exprs[k], expr))
@@ -1765,7 +1765,7 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
break;
}
- /* otherwise remap it to the new attnum */
+ /* otherwise remap it to the new attphysnum */
dep->attributes[j] = unique_attnum;
}
@@ -1816,7 +1816,7 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
while (true)
{
MVDependency *dependency;
- AttrNumber attnum;
+ AttrNumber attphysnum;
/* the widest/strongest dependency, fully matched by clauses */
dependency = find_strongest_dependency(func_dependencies,
@@ -1828,8 +1828,8 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
dependencies[ndependencies++] = dependency;
/* Ignore dependencies using this implied attribute in later loops */
- attnum = dependency->attributes[dependency->nattributes - 1];
- clauses_attnums = bms_del_member(clauses_attnums, attnum);
+ attphysnum = dependency->attributes[dependency->nattributes - 1];
+ clauses_attnums = bms_del_member(clauses_attnums, attphysnum);
}
/*
diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index ca48395d5c..b11db27812 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -391,31 +391,31 @@ statext_compute_stattarget(int stattarget, int nattrs, VacAttrStats **stats)
bool
statext_is_kind_built(HeapTuple htup, char type)
{
- AttrNumber attnum;
+ AttrNumber attphysnum;
switch (type)
{
case STATS_EXT_NDISTINCT:
- attnum = Anum_pg_statistic_ext_data_stxdndistinct;
+ attphysnum = Anum_pg_statistic_ext_data_stxdndistinct;
break;
case STATS_EXT_DEPENDENCIES:
- attnum = Anum_pg_statistic_ext_data_stxddependencies;
+ attphysnum = Anum_pg_statistic_ext_data_stxddependencies;
break;
case STATS_EXT_MCV:
- attnum = Anum_pg_statistic_ext_data_stxdmcv;
+ attphysnum = Anum_pg_statistic_ext_data_stxdmcv;
break;
case STATS_EXT_EXPRESSIONS:
- attnum = Anum_pg_statistic_ext_data_stxdexpr;
+ attphysnum = Anum_pg_statistic_ext_data_stxdexpr;
break;
default:
elog(ERROR, "unexpected statistics type requested: %d", type);
}
- return !heap_attisnull(htup, attnum, NULL);
+ return !heap_attisnull(htup, attphysnum, NULL);
}
/*
@@ -655,7 +655,7 @@ examine_expression(Node *expr, int stattarget)
/* initialize some basic fields */
stats->attr->attrelid = InvalidOid;
- stats->attr->attnum = InvalidAttrNumber;
+ stats->attr->attphysnum = InvalidAttrNumber;
stats->attr->atttypid = stats->attrtypid;
typtuple = SearchSysCacheCopy1(TYPEOID,
@@ -722,7 +722,7 @@ lookup_var_attr_stats(Relation rel, Bitmapset *attrs, List *exprs,
stats = (VacAttrStats **) palloc(natts * sizeof(VacAttrStats *));
- /* lookup VacAttrStats info for the requested columns (same attnum) */
+ /* lookup VacAttrStats info for the requested columns (same attphysnum) */
while ((x = bms_next_member(attrs, x)) >= 0)
{
int j;
@@ -979,7 +979,7 @@ build_attnums_array(Bitmapset *attrs, int nexprs, int *numattrs)
j = -1;
while ((j = bms_next_member(attrs, j)) >= 0)
{
- int attnum = (j - nexprs);
+ int attphysnum = (j - nexprs);
/*
* Make sure the bitmap contains only user-defined attributes. As
@@ -987,11 +987,11 @@ build_attnums_array(Bitmapset *attrs, int nexprs, int *numattrs)
* ways. Firstly, the bitmap might contain 0 as a member, and secondly
* the integer value might be larger than MaxAttrNumber.
*/
- Assert(AttributeNumberIsValid(attnum));
- Assert(attnum <= MaxAttrNumber);
- Assert(attnum >= (-nexprs));
+ Assert(AttributeNumberIsValid(attphysnum));
+ Assert(attphysnum <= MaxAttrNumber);
+ Assert(attphysnum >= (-nexprs));
- attnums[i++] = (AttrNumber) attnum;
+ attnums[i++] = (AttrNumber) attphysnum;
/* protect against overflows */
Assert(i <= num);
@@ -1070,14 +1070,14 @@ build_sorted_items(StatsBuildData *data, int *nitems,
Datum value;
bool isnull;
int attlen;
- AttrNumber attnum = attnums[j];
+ AttrNumber attphysnum = attnums[j];
int idx;
- /* match attnum to the pre-calculated data */
+ /* match attphysnum to the pre-calculated data */
for (idx = 0; idx < data->nattnums; idx++)
{
- if (attnum == data->attnums[idx])
+ if (attphysnum == data->attnums[idx])
break;
}
@@ -1635,11 +1635,11 @@ statext_is_compatible_clause(PlannerInfo *root, Node *clause, Index relid,
else
{
/* Check the columns referenced by the clause */
- int attnum = -1;
+ int attphysnum = -1;
- while ((attnum = bms_next_member(clause_attnums, attnum)) >= 0)
+ while ((attphysnum = bms_next_member(clause_attnums, attphysnum)) >= 0)
{
- if (pg_attribute_aclcheck(rte->relid, attnum, userid,
+ if (pg_attribute_aclcheck(rte->relid, attphysnum, userid,
ACL_SELECT) != ACLCHECK_OK)
return false;
}
@@ -2186,7 +2186,7 @@ compute_expr_stats(Relation onerel, double totalrows,
{
AttributeOpts *aopt =
get_attribute_options(stats->attr->attrelid,
- stats->attr->attnum);
+ stats->attr->attphysnum);
stats->exprvals = exprvals;
stats->exprnulls = exprnulls;
diff --git a/src/backend/statistics/mvdistinct.c b/src/backend/statistics/mvdistinct.c
index 6ade5eff78..e8e8682c8a 100644
--- a/src/backend/statistics/mvdistinct.c
+++ b/src/backend/statistics/mvdistinct.c
@@ -373,9 +373,9 @@ pg_ndistinct_out(PG_FUNCTION_ARGS)
for (j = 0; j < item.nattributes; j++)
{
- AttrNumber attnum = item.attributes[j];
+ AttrNumber attphysnum = item.attributes[j];
- appendStringInfo(&str, "%s%d", (j == 0) ? "\"" : ", ", attnum);
+ appendStringInfo(&str, "%s%d", (j == 0) ? "\"" : ", ", attphysnum);
}
appendStringInfo(&str, "\": %d", (int) item.ndistinct);
}
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c
index 772c04155c..0659109257 100644
--- a/src/backend/utils/adt/acl.c
+++ b/src/backend/utils/adt/acl.c
@@ -2444,13 +2444,13 @@ has_any_column_privilege_id_id(PG_FUNCTION_ARGS)
* has_column_privilege variants
* These are all named "has_column_privilege" at the SQL level.
* They take various combinations of relation name, relation OID,
- * column name, column attnum, user name, user OID, or
+ * column name, column attphysnum, user name, user OID, or
* implicit user = current_user.
*
* The result is a boolean value: true if user has the indicated
* privilege, false if not. The variants that take a relation OID
* return NULL (rather than throwing an error) if that relation OID
- * doesn't exist. Likewise, the variants that take an integer attnum
+ * doesn't exist. Likewise, the variants that take an integer attphysnum
* return NULL (rather than throwing an error) if there is no such
* pg_attribute entry. All variants return NULL if an attisdropped
* column is selected. These rules are meant to avoid unnecessary
@@ -2464,7 +2464,7 @@ has_any_column_privilege_id_id(PG_FUNCTION_ARGS)
* Returns 1 if have the privilege, 0 if not, -1 if dropped column/table.
*/
static int
-column_privilege_check(Oid tableoid, AttrNumber attnum,
+column_privilege_check(Oid tableoid, AttrNumber attphysnum,
Oid roleid, AclMode mode)
{
AclResult aclresult;
@@ -2473,7 +2473,7 @@ column_privilege_check(Oid tableoid, AttrNumber attnum,
/*
* If convert_column_name failed, we can just return -1 immediately.
*/
- if (attnum == InvalidAttrNumber)
+ if (attphysnum == InvalidAttrNumber)
return -1;
/*
@@ -2481,7 +2481,7 @@ column_privilege_check(Oid tableoid, AttrNumber attnum,
* on whether the column even exists, so we need to do it before checking
* table-level privilege.
*/
- aclresult = pg_attribute_aclcheck_ext(tableoid, attnum, roleid,
+ aclresult = pg_attribute_aclcheck_ext(tableoid, attphysnum, roleid,
mode, &is_missing);
if (aclresult == ACLCHECK_OK)
return 1;
@@ -2530,7 +2530,7 @@ has_column_privilege_name_name_name(PG_FUNCTION_ARGS)
/*
* has_column_privilege_name_name_attnum
* Check user privileges on a column given
- * name username, text tablename, int attnum, and text priv name.
+ * name username, text tablename, int attphysnum, and text priv name.
*/
Datum
has_column_privilege_name_name_attnum(PG_FUNCTION_ARGS)
@@ -2584,7 +2584,7 @@ has_column_privilege_name_id_name(PG_FUNCTION_ARGS)
/*
* has_column_privilege_name_id_attnum
* Check user privileges on a column given
- * name username, table oid, int attnum, and text priv name.
+ * name username, table oid, int attphysnum, and text priv name.
*/
Datum
has_column_privilege_name_id_attnum(PG_FUNCTION_ARGS)
@@ -2636,7 +2636,7 @@ has_column_privilege_id_name_name(PG_FUNCTION_ARGS)
/*
* has_column_privilege_id_name_attnum
* Check user privileges on a column given
- * oid roleid, text tablename, int attnum, and text priv name.
+ * oid roleid, text tablename, int attphysnum, and text priv name.
*/
Datum
has_column_privilege_id_name_attnum(PG_FUNCTION_ARGS)
@@ -2686,7 +2686,7 @@ has_column_privilege_id_id_name(PG_FUNCTION_ARGS)
/*
* has_column_privilege_id_id_attnum
* Check user privileges on a column given
- * oid roleid, table oid, int attnum, and text priv name.
+ * oid roleid, table oid, int attphysnum, and text priv name.
*/
Datum
has_column_privilege_id_id_attnum(PG_FUNCTION_ARGS)
@@ -2738,7 +2738,7 @@ has_column_privilege_name_name(PG_FUNCTION_ARGS)
/*
* has_column_privilege_name_attnum
* Check user privileges on a column given
- * text tablename, int attnum, and text priv name.
+ * text tablename, int attphysnum, and text priv name.
* current_user is assumed
*/
Datum
@@ -2792,7 +2792,7 @@ has_column_privilege_id_name(PG_FUNCTION_ARGS)
/*
* has_column_privilege_id_attnum
* Check user privileges on a column given
- * table oid, int attnum, and text priv name.
+ * table oid, int attphysnum, and text priv name.
* current_user is assumed
*/
Datum
@@ -2828,12 +2828,12 @@ convert_column_name(Oid tableoid, text *column)
{
char *colname;
HeapTuple attTuple;
- AttrNumber attnum;
+ AttrNumber attphysnum;
colname = text_to_cstring(column);
/*
- * We don't use get_attnum() here because it will report that dropped
+ * We don't use get_attphysnum() here because it will report that dropped
* columns don't exist. We need to treat dropped columns differently from
* nonexistent columns.
*/
@@ -2847,9 +2847,9 @@ convert_column_name(Oid tableoid, text *column)
attributeForm = (Form_pg_attribute) GETSTRUCT(attTuple);
/* We want to return NULL for dropped columns */
if (attributeForm->attisdropped)
- attnum = InvalidAttrNumber;
+ attphysnum = InvalidAttrNumber;
else
- attnum = attributeForm->attnum;
+ attphysnum = attributeForm->attphysnum;
ReleaseSysCache(attTuple);
}
else
@@ -2870,11 +2870,11 @@ convert_column_name(Oid tableoid, text *column)
colname, tablename)));
}
/* tableoid doesn't exist, so act like attisdropped case */
- attnum = InvalidAttrNumber;
+ attphysnum = InvalidAttrNumber;
}
pfree(colname);
- return attnum;
+ return attphysnum;
}
/*
diff --git a/src/backend/utils/adt/expandedrecord.c b/src/backend/utils/adt/expandedrecord.c
index 3b3e0a9106..18951a40ce 100644
--- a/src/backend/utils/adt/expandedrecord.c
+++ b/src/backend/utils/adt/expandedrecord.c
@@ -1031,7 +1031,7 @@ expanded_record_lookup_field(ExpandedRecordHeader *erh, const char *fieldname,
if (namestrcmp(&attr->attname, fieldname) == 0 &&
!attr->attisdropped)
{
- finfo->fnumber = attr->attnum;
+ finfo->fnumber = attr->attphysnum;
finfo->ftypeid = attr->atttypid;
finfo->ftypmod = attr->atttypmod;
finfo->fcollation = attr->attcollation;
@@ -1043,7 +1043,7 @@ expanded_record_lookup_field(ExpandedRecordHeader *erh, const char *fieldname,
sysattr = SystemAttributeByName(fieldname);
if (sysattr != NULL)
{
- finfo->fnumber = sysattr->attnum;
+ finfo->fnumber = sysattr->attphysnum;
finfo->ftypeid = sysattr->atttypid;
finfo->ftypmod = sysattr->atttypmod;
finfo->fcollation = sysattr->attcollation;
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 89690be2ed..5ad1cdc905 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -636,13 +636,13 @@ Datum
pg_column_is_updatable(PG_FUNCTION_ARGS)
{
Oid reloid = PG_GETARG_OID(0);
- AttrNumber attnum = PG_GETARG_INT16(1);
- AttrNumber col = attnum - FirstLowInvalidHeapAttributeNumber;
+ AttrNumber attphysnum = PG_GETARG_INT16(1);
+ AttrNumber col = attphysnum - FirstLowInvalidHeapAttributeNumber;
bool include_triggers = PG_GETARG_BOOL(2);
int events;
/* System columns are never updatable */
- if (attnum <= 0)
+ if (attphysnum <= 0)
PG_RETURN_BOOL(false);
events = relation_is_updatable(reloid, NIL, include_triggers,
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index 51b3fdc9a0..cb28faa420 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -85,9 +85,9 @@
#define MAX_QUOTED_NAME_LEN (NAMEDATALEN*2+3)
#define MAX_QUOTED_REL_NAME_LEN (MAX_QUOTED_NAME_LEN*2)
-#define RIAttName(rel, attnum) NameStr(*attnumAttName(rel, attnum))
-#define RIAttType(rel, attnum) attnumTypeId(rel, attnum)
-#define RIAttCollation(rel, attnum) attnumCollationId(rel, attnum)
+#define RIAttName(rel, attphysnum) NameStr(*attnumAttName(rel, attphysnum))
+#define RIAttType(rel, attphysnum) attnumTypeId(rel, attphysnum)
+#define RIAttCollation(rel, attphysnum) attnumCollationId(rel, attphysnum)
#define RI_TRIGTYPE_INSERT 1
#define RI_TRIGTYPE_UPDATE 2
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index c3937a60fd..837dc6b20d 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1348,7 +1348,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
sep = "";
for (keyno = 0; keyno < idxrec->indnatts; keyno++)
{
- AttrNumber attnum = idxrec->indkey.values[keyno];
+ AttrNumber attphysnum = idxrec->indkey.values[keyno];
Oid keycoltype;
Oid keycolcollation;
@@ -1369,16 +1369,16 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
appendStringInfoString(&buf, sep);
sep = ", ";
- if (attnum != 0)
+ if (attphysnum != 0)
{
/* Simple index column */
char *attname;
int32 keycoltypmod;
- attname = get_attname(indrelid, attnum, false);
+ attname = get_attname(indrelid, attphysnum, false);
if (!colno || colno == keyno + 1)
appendStringInfoString(&buf, quote_identifier(attname));
- get_atttypetypmodcoll(indrelid, attnum,
+ get_atttypetypmodcoll(indrelid, attphysnum,
&keycoltype, &keycoltypmod,
&keycolcollation);
}
@@ -1744,13 +1744,13 @@ pg_get_statisticsobj_worker(Oid statextid, bool columns_only, bool missing_ok)
/* decode simple column references */
for (colno = 0; colno < statextrec->stxkeys.dim1; colno++)
{
- AttrNumber attnum = statextrec->stxkeys.values[colno];
+ AttrNumber attphysnum = statextrec->stxkeys.values[colno];
char *attname;
if (colno > 0)
appendStringInfoString(&buf, ", ");
- attname = get_attname(statextrec->stxrelid, attnum, false);
+ attname = get_attname(statextrec->stxrelid, attphysnum, false);
appendStringInfoString(&buf, quote_identifier(attname));
}
@@ -1990,22 +1990,22 @@ pg_get_partkeydef_worker(Oid relid, int prettyFlags,
sep = "";
for (keyno = 0; keyno < form->partnatts; keyno++)
{
- AttrNumber attnum = form->partattrs.values[keyno];
+ AttrNumber attphysnum = form->partattrs.values[keyno];
Oid keycoltype;
Oid keycolcollation;
Oid partcoll;
appendStringInfoString(&buf, sep);
sep = ", ";
- if (attnum != 0)
+ if (attphysnum != 0)
{
/* Simple attribute reference */
char *attname;
int32 keycoltypmod;
- attname = get_attname(relid, attnum, false);
+ attname = get_attname(relid, attphysnum, false);
appendStringInfoString(&buf, quote_identifier(attname));
- get_atttypetypmodcoll(relid, attnum,
+ get_atttypetypmodcoll(relid, attphysnum,
&keycoltype, &keycoltypmod,
&keycolcollation);
}
@@ -2798,7 +2798,7 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
RangeVar *tablerv;
Oid tableOid;
char *column;
- AttrNumber attnum;
+ AttrNumber attphysnum;
Oid sequenceId = InvalidOid;
Relation depRel;
ScanKeyData key[3];
@@ -2812,8 +2812,8 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
/* Get the number of the column */
column = text_to_cstring(columnname);
- attnum = get_attnum(tableOid, column);
- if (attnum == InvalidAttrNumber)
+ attphysnum = get_attphysnum(tableOid, column);
+ if (attphysnum == InvalidAttrNumber)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
@@ -2833,7 +2833,7 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
ScanKeyInit(&key[2],
Anum_pg_depend_refobjsubid,
BTEqualStrategyNumber, F_INT4EQ,
- Int32GetDatum(attnum));
+ Int32GetDatum(attphysnum));
scan = systable_beginscan(depRel, DependReferenceIndexId, true,
NULL, 3, key);
@@ -4595,7 +4595,7 @@ set_join_column_names(deparse_namespace *dpns, RangeTblEntry *rte,
* added since parse time must be inserted in the right places. This code
* must match the parser, which will order a join's columns as merged
* columns first (in USING-clause order), then non-merged columns from the
- * left input (in attnum order), then non-merged columns from the right
+ * left input (in attphysnum order), then non-merged columns from the right
* input (ditto). If one of the inputs is itself a join, its columns will
* be ordered according to the same rule, which means newly-added columns
* might not be at the end. We can figure out what's what by consulting
@@ -7118,7 +7118,7 @@ get_variable(Var *var, int levelsup, bool istoplevel, deparse_context *context)
{
StringInfo buf = context->buf;
RangeTblEntry *rte;
- AttrNumber attnum;
+ AttrNumber attphysnum;
int netlevelsup;
deparse_namespace *dpns;
int varno;
@@ -7209,7 +7209,7 @@ get_variable(Var *var, int levelsup, bool istoplevel, deparse_context *context)
rte = rt_fetch(varno, dpns->rtable);
refname = (char *) list_nth(dpns->rtable_names, varno - 1);
colinfo = deparse_columns_fetch(varno, dpns);
- attnum = varattno;
+ attphysnum = varattno;
}
else
{
@@ -7230,16 +7230,16 @@ get_variable(Var *var, int levelsup, bool istoplevel, deparse_context *context)
* we'll have set dpns->inner_plan to reference the child plan node.
*/
if ((rte->rtekind == RTE_SUBQUERY || rte->rtekind == RTE_CTE) &&
- attnum > list_length(rte->eref->colnames) &&
+ attphysnum > list_length(rte->eref->colnames) &&
dpns->inner_plan)
{
TargetEntry *tle;
deparse_namespace save_dpns;
- tle = get_tle_by_resno(dpns->inner_tlist, attnum);
+ tle = get_tle_by_resno(dpns->inner_tlist, attphysnum);
if (!tle)
- elog(ERROR, "invalid attnum %d for relation \"%s\"",
- attnum, rte->eref->aliasname);
+ elog(ERROR, "invalid attphysnum %d for relation \"%s\"",
+ attphysnum, rte->eref->aliasname);
Assert(netlevelsup == 0);
push_child_plan(dpns, dpns->inner_plan, &save_dpns);
@@ -7274,11 +7274,11 @@ get_variable(Var *var, int levelsup, bool istoplevel, deparse_context *context)
{
if (rte->joinaliasvars == NIL)
elog(ERROR, "cannot decompile join alias var in plan tree");
- if (attnum > 0)
+ if (attphysnum > 0)
{
Var *aliasvar;
- aliasvar = (Var *) list_nth(rte->joinaliasvars, attnum - 1);
+ aliasvar = (Var *) list_nth(rte->joinaliasvars, attphysnum - 1);
/* we intentionally don't strip implicit coercions here */
if (aliasvar && IsA(aliasvar, Var))
{
@@ -7295,23 +7295,23 @@ get_variable(Var *var, int levelsup, bool istoplevel, deparse_context *context)
Assert(refname == NULL);
}
- if (attnum == InvalidAttrNumber)
+ if (attphysnum == InvalidAttrNumber)
attname = NULL;
- else if (attnum > 0)
+ else if (attphysnum > 0)
{
/* Get column name to use from the colinfo struct */
- if (attnum > colinfo->num_cols)
- elog(ERROR, "invalid attnum %d for relation \"%s\"",
- attnum, rte->eref->aliasname);
- attname = colinfo->colnames[attnum - 1];
+ if (attphysnum > colinfo->num_cols)
+ elog(ERROR, "invalid attphysnum %d for relation \"%s\"",
+ attphysnum, rte->eref->aliasname);
+ attname = colinfo->colnames[attphysnum - 1];
if (attname == NULL) /* dropped column? */
- elog(ERROR, "invalid attnum %d for relation \"%s\"",
- attnum, rte->eref->aliasname);
+ elog(ERROR, "invalid attphysnum %d for relation \"%s\"",
+ attphysnum, rte->eref->aliasname);
}
else
{
/* System column - name is fixed, get it from the catalog */
- attname = get_rte_attribute_name(rte, attnum);
+ attname = get_rte_attribute_name(rte, attphysnum);
}
if (refname && (context->varprefix || attname == NULL))
@@ -7474,7 +7474,7 @@ get_name_for_var_field(Var *var, int fieldno,
int levelsup, deparse_context *context)
{
RangeTblEntry *rte;
- AttrNumber attnum;
+ AttrNumber attphysnum;
int netlevelsup;
deparse_namespace *dpns;
int varno;
@@ -7566,7 +7566,7 @@ get_name_for_var_field(Var *var, int fieldno,
if (varno >= 1 && varno <= list_length(dpns->rtable))
{
rte = rt_fetch(varno, dpns->rtable);
- attnum = varattno;
+ attphysnum = varattno;
}
else if (varno == OUTER_VAR && dpns->outer_tlist)
{
@@ -7628,7 +7628,7 @@ get_name_for_var_field(Var *var, int fieldno,
return NULL; /* keep compiler quiet */
}
- if (attnum == InvalidAttrNumber)
+ if (attphysnum == InvalidAttrNumber)
{
/* Var is whole-row reference to RTE, so select the right field */
return get_rte_attribute_name(rte, fieldno);
@@ -7662,11 +7662,11 @@ get_name_for_var_field(Var *var, int fieldno,
if (rte->subquery)
{
TargetEntry *ste = get_tle_by_resno(rte->subquery->targetList,
- attnum);
+ attphysnum);
if (ste == NULL || ste->resjunk)
elog(ERROR, "subquery %s does not have attribute %d",
- rte->eref->aliasname, attnum);
+ rte->eref->aliasname, attphysnum);
expr = (Node *) ste->expr;
if (IsA(expr, Var))
{
@@ -7711,10 +7711,10 @@ get_name_for_var_field(Var *var, int fieldno,
if (!dpns->inner_plan)
elog(ERROR, "failed to find plan for subquery %s",
rte->eref->aliasname);
- tle = get_tle_by_resno(dpns->inner_tlist, attnum);
+ tle = get_tle_by_resno(dpns->inner_tlist, attphysnum);
if (!tle)
elog(ERROR, "bogus varattno for subquery var: %d",
- attnum);
+ attphysnum);
Assert(netlevelsup == 0);
push_child_plan(dpns, dpns->inner_plan, &save_dpns);
@@ -7730,8 +7730,8 @@ get_name_for_var_field(Var *var, int fieldno,
/* Join RTE --- recursively inspect the alias variable */
if (rte->joinaliasvars == NIL)
elog(ERROR, "cannot decompile join alias var in plan tree");
- Assert(attnum > 0 && attnum <= list_length(rte->joinaliasvars));
- expr = (Node *) list_nth(rte->joinaliasvars, attnum - 1);
+ Assert(attphysnum > 0 && attphysnum <= list_length(rte->joinaliasvars));
+ expr = (Node *) list_nth(rte->joinaliasvars, attphysnum - 1);
Assert(expr != NULL);
/* we intentionally don't strip implicit coercions here */
if (IsA(expr, Var))
@@ -7778,11 +7778,11 @@ get_name_for_var_field(Var *var, int fieldno,
{
Query *ctequery = (Query *) cte->ctequery;
TargetEntry *ste = get_tle_by_resno(GetCTETargetList(cte),
- attnum);
+ attphysnum);
if (ste == NULL || ste->resjunk)
elog(ERROR, "subquery %s does not have attribute %d",
- rte->eref->aliasname, attnum);
+ rte->eref->aliasname, attphysnum);
expr = (Node *) ste->expr;
if (IsA(expr, Var))
{
@@ -7832,10 +7832,10 @@ get_name_for_var_field(Var *var, int fieldno,
if (!dpns->inner_plan)
elog(ERROR, "failed to find plan for CTE %s",
rte->eref->aliasname);
- tle = get_tle_by_resno(dpns->inner_tlist, attnum);
+ tle = get_tle_by_resno(dpns->inner_tlist, attphysnum);
if (!tle)
elog(ERROR, "bogus varattno for subquery var: %d",
- attnum);
+ attphysnum);
Assert(netlevelsup == 0);
push_child_plan(dpns, dpns->inner_plan, &save_dpns);
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index fa1f589fad..04702b3ccc 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -3973,24 +3973,24 @@ estimate_multivariate_ndistinct(PlannerInfo *root, RelOptInfo *rel,
{
ListCell *lc3;
GroupVarInfo *varinfo = (GroupVarInfo *) lfirst(lc2);
- AttrNumber attnum;
+ AttrNumber attphysnum;
Assert(varinfo->rel == rel);
/* simple Var, search in statistics keys directly */
if (IsA(varinfo->var, Var))
{
- attnum = ((Var *) varinfo->var)->varattno;
+ attphysnum = ((Var *) varinfo->var)->varattno;
/*
* Ignore system attributes - we don't support statistics on
* them, so can't match them (and it'd fail as the values are
* negative).
*/
- if (!AttrNumberIsForUserDefinedAttr(attnum))
+ if (!AttrNumberIsForUserDefinedAttr(attphysnum))
continue;
- if (bms_is_member(attnum, info->keys))
+ if (bms_is_member(attphysnum, info->keys))
nshared_vars++;
continue;
@@ -4077,25 +4077,25 @@ estimate_multivariate_ndistinct(PlannerInfo *root, RelOptInfo *rel,
*/
if (IsA(varinfo->var, Var))
{
- AttrNumber attnum = ((Var *) varinfo->var)->varattno;
+ AttrNumber attphysnum = ((Var *) varinfo->var)->varattno;
/*
* Ignore expressions on system attributes. Can't rely on the
* bms check for negative values.
*/
- if (!AttrNumberIsForUserDefinedAttr(attnum))
+ if (!AttrNumberIsForUserDefinedAttr(attphysnum))
continue;
/* Is the variable covered by the statistics object? */
- if (!bms_is_member(attnum, matched_info->keys))
+ if (!bms_is_member(attphysnum, matched_info->keys))
continue;
- attnum = attnum + attnum_offset;
+ attphysnum = attphysnum + attnum_offset;
/* ensure sufficient offset */
- Assert(AttrNumberIsForUserDefinedAttr(attnum));
+ Assert(AttrNumberIsForUserDefinedAttr(attphysnum));
- matched = bms_add_member(matched, attnum);
+ matched = bms_add_member(matched, attphysnum);
found = true;
}
@@ -4116,14 +4116,14 @@ estimate_multivariate_ndistinct(PlannerInfo *root, RelOptInfo *rel,
if (equal(varinfo->var, expr))
{
- AttrNumber attnum = -(idx + 1);
+ AttrNumber attphysnum = -(idx + 1);
- attnum = attnum + attnum_offset;
+ attphysnum = attphysnum + attnum_offset;
/* ensure sufficient offset */
- Assert(AttrNumberIsForUserDefinedAttr(attnum));
+ Assert(AttrNumberIsForUserDefinedAttr(attphysnum));
- matched = bms_add_member(matched, attnum);
+ matched = bms_add_member(matched, attphysnum);
/* there should be just one matching expression */
break;
@@ -4148,15 +4148,15 @@ estimate_multivariate_ndistinct(PlannerInfo *root, RelOptInfo *rel,
/* check that all item attributes/expressions fit the match */
for (j = 0; j < tmpitem->nattributes; j++)
{
- AttrNumber attnum = tmpitem->attributes[j];
+ AttrNumber attphysnum = tmpitem->attributes[j];
/*
* Thanks to how we constructed the matched bitmap above, we
* can just offset all attnums the same way.
*/
- attnum = attnum + attnum_offset;
+ attphysnum = attphysnum + attnum_offset;
- if (!bms_is_member(attnum, matched))
+ if (!bms_is_member(attphysnum, matched))
{
/* nah, it's not this item */
item = NULL;
@@ -4189,28 +4189,28 @@ estimate_multivariate_ndistinct(PlannerInfo *root, RelOptInfo *rel,
/*
* Let's look at plain variables first, because it's the most
* common case and the check is quite cheap. We can simply get the
- * attnum and check (with an offset) matched bitmap.
+ * attphysnum and check (with an offset) matched bitmap.
*/
if (IsA(varinfo->var, Var))
{
- AttrNumber attnum = ((Var *) varinfo->var)->varattno;
+ AttrNumber attphysnum = ((Var *) varinfo->var)->varattno;
/*
* If it's a system attribute, we're done. We don't support
* extended statistics on system attributes, so it's clearly
* not matched. Just keep the expression and continue.
*/
- if (!AttrNumberIsForUserDefinedAttr(attnum))
+ if (!AttrNumberIsForUserDefinedAttr(attphysnum))
{
newlist = lappend(newlist, varinfo);
continue;
}
/* apply the same offset as above */
- attnum += attnum_offset;
+ attphysnum += attnum_offset;
/* if it's not matched, keep the varinfo */
- if (!bms_is_member(attnum, matched))
+ if (!bms_is_member(attphysnum, matched))
newlist = lappend(newlist, varinfo);
/* The rest of the loop deals with complex expressions. */
@@ -7804,14 +7804,14 @@ brincostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
foreach(l, path->indexclauses)
{
IndexClause *iclause = lfirst_node(IndexClause, l);
- AttrNumber attnum = index->indexkeys[iclause->indexcol];
+ AttrNumber attphysnum = index->indexkeys[iclause->indexcol];
/* attempt to lookup stats in relation for this index column */
- if (attnum != 0)
+ if (attphysnum != 0)
{
/* Simple variable -- look to stats for the underlying table */
if (get_relation_stats_hook &&
- (*get_relation_stats_hook) (root, rte, attnum, &vardata))
+ (*get_relation_stats_hook) (root, rte, attphysnum, &vardata))
{
/*
* The hook took control of acquiring a stats tuple. If it
@@ -7826,7 +7826,7 @@ brincostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
vardata.statsTuple =
SearchSysCache3(STATRELATTINH,
ObjectIdGetDatum(rte->relid),
- Int16GetDatum(attnum),
+ Int16GetDatum(attphysnum),
BoolGetDatum(false));
vardata.freefunc = ReleaseSysCache;
}
@@ -7838,11 +7838,11 @@ brincostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
* see if there's any stats for it.
*/
- /* get the attnum from the 0-based index. */
- attnum = iclause->indexcol + 1;
+ /* get the attphysnum from the 0-based index. */
+ attphysnum = iclause->indexcol + 1;
if (get_index_stats_hook &&
- (*get_index_stats_hook) (root, index->indexoid, attnum, &vardata))
+ (*get_index_stats_hook) (root, index->indexoid, attphysnum, &vardata))
{
/*
* The hook took control of acquiring a stats tuple. If it
@@ -7856,7 +7856,7 @@ brincostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
{
vardata.statsTuple = SearchSysCache3(STATRELATTINH,
ObjectIdGetDatum(index->indexoid),
- Int16GetDatum(attnum),
+ Int16GetDatum(attphysnum),
BoolGetDatum(false));
vardata.freefunc = ReleaseSysCache;
}
diff --git a/src/backend/utils/cache/attoptcache.c b/src/backend/utils/cache/attoptcache.c
index 9e252a0891..0c9893ca95 100644
--- a/src/backend/utils/cache/attoptcache.c
+++ b/src/backend/utils/cache/attoptcache.c
@@ -27,11 +27,11 @@
/* Hash table for information about each attribute's options */
static HTAB *AttoptCacheHash = NULL;
-/* attrelid and attnum form the lookup key, and must appear first */
+/* attrelid and attphysnum form the lookup key, and must appear first */
typedef struct
{
Oid attrelid;
- int attnum;
+ int attphysnum;
} AttoptCacheKey;
typedef struct
@@ -90,7 +90,7 @@ InitializeAttoptCache(void)
CreateCacheMemoryContext();
/* Watch for invalidation events. */
- CacheRegisterSyscacheCallback(ATTNUM,
+ CacheRegisterSyscacheCallback(ATTPHYSNUM,
InvalidateAttoptCacheCallback,
(Datum) 0);
}
@@ -100,7 +100,7 @@ InitializeAttoptCache(void)
* Fetch attribute options for a specified table OID.
*/
AttributeOpts *
-get_attribute_options(Oid attrelid, int attnum)
+get_attribute_options(Oid attrelid, int attphysnum)
{
AttoptCacheKey key;
AttoptCacheEntry *attopt;
@@ -112,7 +112,7 @@ get_attribute_options(Oid attrelid, int attnum)
InitializeAttoptCache();
memset(&key, 0, sizeof(key)); /* make sure any padding bits are unset */
key.attrelid = attrelid;
- key.attnum = attnum;
+ key.attphysnum = attphysnum;
attopt =
(AttoptCacheEntry *) hash_search(AttoptCacheHash,
(void *) &key,
@@ -124,9 +124,9 @@ get_attribute_options(Oid attrelid, int attnum)
{
AttributeOpts *opts;
- tp = SearchSysCache2(ATTNUM,
+ tp = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(attrelid),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
/*
* If we don't find a valid HeapTuple, it must mean someone has
@@ -140,7 +140,7 @@ get_attribute_options(Oid attrelid, int attnum)
Datum datum;
bool isNull;
- datum = SysCacheGetAttr(ATTNUM,
+ datum = SysCacheGetAttr(ATTPHYSNUM,
tp,
Anum_pg_attribute_attoptions,
&isNull);
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index 6ae7c1f50b..9bf99c113b 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -1909,13 +1909,13 @@ CatCacheFreeKeys(TupleDesc tupdesc, int nkeys, int *attnos, Datum *keys)
for (i = 0; i < nkeys; i++)
{
- int attnum = attnos[i];
+ int attphysnum = attnos[i];
Form_pg_attribute att;
/* system attribute are not supported in caches */
- Assert(attnum > 0);
+ Assert(attphysnum > 0);
- att = TupleDescAttr(tupdesc, attnum - 1);
+ att = TupleDescAttr(tupdesc, attphysnum - 1);
if (!att->attbyval)
pfree(DatumGetPointer(keys[i]));
@@ -1940,8 +1940,8 @@ CatCacheCopyKeys(TupleDesc tupdesc, int nkeys, int *attnos,
for (i = 0; i < nkeys; i++)
{
- int attnum = attnos[i];
- Form_pg_attribute att = TupleDescAttr(tupdesc, attnum - 1);
+ int attphysnum = attnos[i];
+ Form_pg_attribute att = TupleDescAttr(tupdesc, attphysnum - 1);
Datum src = srckeys[i];
NameData srcname;
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 1b7e11b93e..721fb194e7 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -822,12 +822,12 @@ get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
* otherwise a not-intended-for-user-consumption error is thrown.
*/
char *
-get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
+get_attname(Oid relid, AttrNumber attphysnum, bool missing_ok)
{
HeapTuple tp;
- tp = SearchSysCache2(ATTNUM,
- ObjectIdGetDatum(relid), Int16GetDatum(attnum));
+ tp = SearchSysCache2(ATTPHYSNUM,
+ ObjectIdGetDatum(relid), Int16GetDatum(attphysnum));
if (HeapTupleIsValid(tp))
{
Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
@@ -840,7 +840,7 @@ get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
if (!missing_ok)
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
- attnum, relid);
+ attphysnum, relid);
return NULL;
}
@@ -848,12 +848,12 @@ get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
* get_attnum
*
* Given the relation id and the attribute name,
- * return the "attnum" field from the attribute relation.
+ * return the "attphysnum" field from the attribute relation.
*
* Returns InvalidAttrNumber if the attr doesn't exist (or is dropped).
*/
AttrNumber
-get_attnum(Oid relid, const char *attname)
+get_attphysnum(Oid relid, const char *attname)
{
HeapTuple tp;
@@ -863,7 +863,7 @@ get_attnum(Oid relid, const char *attname)
Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
AttrNumber result;
- result = att_tup->attnum;
+ result = att_tup->attphysnum;
ReleaseSysCache(tp);
return result;
}
@@ -880,18 +880,18 @@ get_attnum(Oid relid, const char *attname)
* Errors if not found.
*/
int
-get_attstattarget(Oid relid, AttrNumber attnum)
+get_attstattarget(Oid relid, AttrNumber attphysnum)
{
HeapTuple tp;
Form_pg_attribute att_tup;
int result;
- tp = SearchSysCache2(ATTNUM,
+ tp = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(relid),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
- attnum, relid);
+ attphysnum, relid);
att_tup = (Form_pg_attribute) GETSTRUCT(tp);
result = att_tup->attstattarget;
ReleaseSysCache(tp);
@@ -910,18 +910,18 @@ get_attstattarget(Oid relid, AttrNumber attnum)
* Boolean test.
*/
char
-get_attgenerated(Oid relid, AttrNumber attnum)
+get_attgenerated(Oid relid, AttrNumber attphysnum)
{
HeapTuple tp;
Form_pg_attribute att_tup;
char result;
- tp = SearchSysCache2(ATTNUM,
+ tp = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(relid),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
- attnum, relid);
+ attphysnum, relid);
att_tup = (Form_pg_attribute) GETSTRUCT(tp);
result = att_tup->attgenerated;
ReleaseSysCache(tp);
@@ -935,13 +935,13 @@ get_attgenerated(Oid relid, AttrNumber attnum)
* return the attribute type OID.
*/
Oid
-get_atttype(Oid relid, AttrNumber attnum)
+get_atttype(Oid relid, AttrNumber attphysnum)
{
HeapTuple tp;
- tp = SearchSysCache2(ATTNUM,
+ tp = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(relid),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (HeapTupleIsValid(tp))
{
Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
@@ -965,18 +965,18 @@ get_atttype(Oid relid, AttrNumber attnum)
* raises an error if it can't obtain the information.
*/
void
-get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
+get_atttypetypmodcoll(Oid relid, AttrNumber attphysnum,
Oid *typid, int32 *typmod, Oid *collid)
{
HeapTuple tp;
Form_pg_attribute att_tup;
- tp = SearchSysCache2(ATTNUM,
+ tp = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(relid),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
- attnum, relid);
+ attphysnum, relid);
att_tup = (Form_pg_attribute) GETSTRUCT(tp);
*typid = att_tup->atttypid;
@@ -992,20 +992,20 @@ get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
* return the attribute options text[] datum, if any.
*/
Datum
-get_attoptions(Oid relid, int16 attnum)
+get_attoptions(Oid relid, int16 attphysnum)
{
HeapTuple tuple;
Datum attopts;
Datum result;
bool isnull;
- tuple = SearchSysCache2(ATTNUM,
+ tuple = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(relid),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
- attnum, relid);
+ attphysnum, relid);
attopts = SysCacheGetAttr(ATTNAME, tuple, Anum_pg_attribute_attoptions,
&isnull);
@@ -3112,20 +3112,20 @@ getSubscriptingRoutines(Oid typid, Oid *typelemp)
* plug-ins to control the result.
*/
int32
-get_attavgwidth(Oid relid, AttrNumber attnum)
+get_attavgwidth(Oid relid, AttrNumber attphysnum)
{
HeapTuple tp;
int32 stawidth;
if (get_attavgwidth_hook)
{
- stawidth = (*get_attavgwidth_hook) (relid, attnum);
+ stawidth = (*get_attavgwidth_hook) (relid, attphysnum);
if (stawidth > 0)
return stawidth;
}
tp = SearchSysCache3(STATRELATTINH,
ObjectIdGetDatum(relid),
- Int16GetDatum(attnum),
+ Int16GetDatum(attphysnum),
BoolGetDatum(false));
if (HeapTupleIsValid(tp))
{
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 0e8fda97f8..8a98060956 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -537,7 +537,7 @@ RelationBuildTupleDesc(Relation relation)
constr->has_generated_stored = false;
/*
- * Form a scan key that selects only user attributes (attnum > 0).
+ * Form a scan key that selects only user attributes (attphysnum > 0).
* (Eliminating system attribute rows at the index level is lots faster
* than fetching them.)
*/
@@ -546,7 +546,7 @@ RelationBuildTupleDesc(Relation relation)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
ScanKeyInit(&skey[1],
- Anum_pg_attribute_attnum,
+ Anum_pg_attribute_attphysnum,
BTGreaterStrategyNumber, F_INT2GT,
Int16GetDatum(0));
@@ -557,7 +557,7 @@ RelationBuildTupleDesc(Relation relation)
*/
pg_attribute_desc = table_open(AttributeRelationId, AccessShareLock);
pg_attribute_scan = systable_beginscan(pg_attribute_desc,
- AttributeRelidNumIndexId,
+ AttributeRelidPhysNumIndexId,
criticalRelcachesBuilt,
NULL,
2, skey);
@@ -570,16 +570,16 @@ RelationBuildTupleDesc(Relation relation)
while (HeapTupleIsValid(pg_attribute_tuple = systable_getnext(pg_attribute_scan)))
{
Form_pg_attribute attp;
- int attnum;
+ int attphysnum;
attp = (Form_pg_attribute) GETSTRUCT(pg_attribute_tuple);
- attnum = attp->attnum;
- if (attnum <= 0 || attnum > RelationGetNumberOfAttributes(relation))
+ attphysnum = attp->attphysnum;
+ if (attphysnum <= 0 || attphysnum > RelationGetNumberOfAttributes(relation))
elog(ERROR, "invalid attribute number %d for relation \"%s\"",
- attp->attnum, RelationGetRelationName(relation));
+ attp->attphysnum, RelationGetRelationName(relation));
- memcpy(TupleDescAttr(relation->rd_att, attnum - 1),
+ memcpy(TupleDescAttr(relation->rd_att, attphysnum - 1),
attp,
ATTRIBUTE_FIXED_PART_SIZE);
@@ -628,18 +628,18 @@ RelationBuildTupleDesc(Relation relation)
if (attp->attbyval)
{
/* for copy by val just copy the datum direct */
- attrmiss[attnum - 1].am_value = missval;
+ attrmiss[attphysnum - 1].am_value = missval;
}
else
{
/* otherwise copy in the correct context */
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
- attrmiss[attnum - 1].am_value = datumCopy(missval,
+ attrmiss[attphysnum - 1].am_value = datumCopy(missval,
attp->attbyval,
attp->attlen);
MemoryContextSwitchTo(oldcxt);
}
- attrmiss[attnum - 1].am_present = true;
+ attrmiss[attphysnum - 1].am_present = true;
}
}
need--;
@@ -4046,7 +4046,7 @@ RelationCacheInitializePhase3(void)
{
load_critical_index(ClassOidIndexId,
RelationRelationId);
- load_critical_index(AttributeRelidNumIndexId,
+ load_critical_index(AttributeRelidPhysNumIndexId,
AttributeRelationId);
load_critical_index(IndexRelidIndexId,
IndexRelationId);
@@ -5708,21 +5708,21 @@ RelationGetIndexRawAttOptions(Relation indexrel)
Oid indexrelid = RelationGetRelid(indexrel);
int16 natts = RelationGetNumberOfAttributes(indexrel);
Datum *options = NULL;
- int16 attnum;
+ int16 attphysnum;
- for (attnum = 1; attnum <= natts; attnum++)
+ for (attphysnum = 1; attphysnum <= natts; attphysnum++)
{
if (indexrel->rd_indam->amoptsprocnum == 0)
continue;
- if (!OidIsValid(index_getprocid(indexrel, attnum,
+ if (!OidIsValid(index_getprocid(indexrel, attphysnum,
indexrel->rd_indam->amoptsprocnum)))
continue;
if (!options)
options = palloc0(sizeof(Datum) * natts);
- options[attnum - 1] = get_attoptions(indexrelid, attnum);
+ options[attphysnum - 1] = get_attoptions(indexrelid, attphysnum);
}
return options;
@@ -5767,7 +5767,7 @@ RelationGetIndexAttOptions(Relation relation, bool copy)
for (i = 0; i < natts; i++)
{
- if (criticalRelcachesBuilt && relid != AttributeRelidNumIndexId)
+ if (criticalRelcachesBuilt && relid != AttributeRelidPhysNumIndexId)
{
Datum attoptions = get_attoptions(relid, i + 1);
@@ -5827,16 +5827,16 @@ errtable(Relation rel)
* easier and less error-prone than getting the column name for themselves.
*/
int
-errtablecol(Relation rel, int attnum)
+errtablecol(Relation rel, int attphysnum)
{
TupleDesc reldesc = RelationGetDescr(rel);
const char *colname;
/* Use reldesc if it's a user attribute, else consult the catalogs */
- if (attnum > 0 && attnum <= reldesc->natts)
- colname = NameStr(TupleDescAttr(reldesc, attnum - 1)->attname);
+ if (attphysnum > 0 && attphysnum <= reldesc->natts)
+ colname = NameStr(TupleDescAttr(reldesc, attphysnum - 1)->attname);
else
- colname = get_attname(RelationGetRelid(rel), attnum, false);
+ colname = get_attname(RelationGetRelid(rel), attphysnum, false);
return errtablecolname(rel, colname);
}
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index 1912b12146..9751ad6a22 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -200,12 +200,12 @@ static const struct cachedesc cacheinfo[] = {
},
32
},
- {AttributeRelationId, /* ATTNUM */
- AttributeRelidNumIndexId,
+ {AttributeRelationId, /* ATTPHYSNUM */
+ AttributeRelidPhysNumIndexId,
2,
{
Anum_pg_attribute_attrelid,
- Anum_pg_attribute_attnum,
+ Anum_pg_attribute_attphysnum,
0,
0
},
@@ -1368,19 +1368,19 @@ SearchSysCacheExistsAttName(Oid relid, const char *attname)
/*
* SearchSysCacheAttNum
*
- * This routine is equivalent to SearchSysCache on the ATTNUM cache,
+ * This routine is equivalent to SearchSysCache on the ATTPHYSNUM cache,
* except that it will return NULL if the found attribute is marked
* attisdropped. This is convenient for callers that want to act as
* though dropped attributes don't exist.
*/
HeapTuple
-SearchSysCacheAttNum(Oid relid, int16 attnum)
+SearchSysCacheAttNum(Oid relid, int16 attphysnum)
{
HeapTuple tuple;
- tuple = SearchSysCache2(ATTNUM,
+ tuple = SearchSysCache2(ATTPHYSNUM,
ObjectIdGetDatum(relid),
- Int16GetDatum(attnum));
+ Int16GetDatum(attphysnum));
if (!HeapTupleIsValid(tuple))
return NULL;
if (((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
@@ -1397,12 +1397,12 @@ SearchSysCacheAttNum(Oid relid, int16 attnum)
* As above, an attisdropped-aware version of SearchSysCacheCopy.
*/
HeapTuple
-SearchSysCacheCopyAttNum(Oid relid, int16 attnum)
+SearchSysCacheCopyAttNum(Oid relid, int16 attphysnum)
{
HeapTuple tuple,
newtuple;
- tuple = SearchSysCacheAttNum(relid, attnum);
+ tuple = SearchSysCacheAttNum(relid, attphysnum);
if (!HeapTupleIsValid(tuple))
return NULL;
newtuple = heap_copytuple(tuple);
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index ed6de7ca94..b6fb9391e7 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -1612,7 +1612,7 @@ setup_privileges(FILE *cmdfd)
" SELECT"
" pg_class.oid,"
" (SELECT oid FROM pg_class WHERE relname = 'pg_class'),"
- " pg_attribute.attnum,"
+ " pg_attribute.attphysnum,"
" pg_attribute.attacl,"
" 'i'"
" FROM"
diff --git a/src/bin/pg_amcheck/pg_amcheck.c b/src/bin/pg_amcheck/pg_amcheck.c
index 3cff319f02..dc043f73ae 100644
--- a/src/bin/pg_amcheck/pg_amcheck.c
+++ b/src/bin/pg_amcheck/pg_amcheck.c
@@ -802,7 +802,7 @@ prepare_heap_command(PQExpBuffer sql, RelationInfo *rel, PGconn *conn)
{
resetPQExpBuffer(sql);
appendPQExpBuffer(sql,
- "SELECT v.blkno, v.offnum, v.attnum, v.msg "
+ "SELECT v.blkno, v.offnum, v.attphysnum, v.msg "
"FROM pg_catalog.pg_class c, %s.verify_heapam("
"\nrelation := c.oid, on_error_stop := %s, check_toast := %s, skip := '%s'",
rel->datinfo->amcheck_schema,
@@ -1016,7 +1016,7 @@ verify_heap_slot_handler(PGresult *res, PGconn *conn, void *context)
rel->datinfo->datname, rel->nspname, rel->relname,
PQgetvalue(res, i, 0), /* blkno */
PQgetvalue(res, i, 1), /* offnum */
- PQgetvalue(res, i, 2)); /* attnum */
+ PQgetvalue(res, i, 2)); /* attphysnum */
else if (!PQgetisnull(res, i, 1))
printf(_("heap table \"%s.%s.%s\", block %s, offset %s:\n"),
diff --git a/src/bin/pg_amcheck/t/003_check.pl b/src/bin/pg_amcheck/t/003_check.pl
index 0cf67065d6..224287e6f5 100644
--- a/src/bin/pg_amcheck/t/003_check.pl
+++ b/src/bin/pg_amcheck/t/003_check.pl
@@ -172,7 +172,7 @@ for my $dbname (qw(db1 db2 db3))
endblock bigint default null,
blkno OUT bigint,
offnum OUT integer,
- attnum OUT integer,
+ attphysnum OUT integer,
msg OUT text)
RETURNS SETOF record AS $$
BEGIN
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 7cc9c72e49..58e07f008c 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -4171,7 +4171,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
" FROM\n"
" pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
" pg_catalog.pg_attribute\n"
- " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
+ " WHERE attrelid = pr.prrelid AND attphysnum = prattrs[s])\n"
" ELSE NULL END) prattrs "
"FROM pg_catalog.pg_publication_rel pr");
else
@@ -6719,11 +6719,11 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"inh.inhparent AS parentidx, "
"i.indnkeyatts AS indnkeyatts, "
"i.indnatts AS indnatts, "
- "(SELECT pg_catalog.array_agg(attnum ORDER BY attnum) "
+ "(SELECT pg_catalog.array_agg(attphysnum ORDER BY attphysnum) "
" FROM pg_catalog.pg_attribute "
" WHERE attrelid = i.indexrelid AND "
" attstattarget >= 0) AS indstatcols, "
- "(SELECT pg_catalog.array_agg(attstattarget ORDER BY attnum) "
+ "(SELECT pg_catalog.array_agg(attstattarget ORDER BY attphysnum) "
" FROM pg_catalog.pg_attribute "
" WHERE attrelid = i.indexrelid AND "
" attstattarget >= 0) AS indstatvals, ");
@@ -8130,7 +8130,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"SELECT\n"
"a.attrelid,\n"
- "a.attnum,\n"
+ "a.attphysnum,\n"
"a.attname,\n"
"a.atttypmod,\n"
"a.attstattarget,\n"
@@ -8188,8 +8188,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
"JOIN pg_catalog.pg_attribute a ON (src.tbloid = a.attrelid) "
"LEFT JOIN pg_catalog.pg_type t "
"ON (a.atttypid = t.oid)\n"
- "WHERE a.attnum > 0::pg_catalog.int2\n"
- "ORDER BY a.attrelid, a.attnum",
+ "WHERE a.attphysnum > 0::pg_catalog.int2\n"
+ "ORDER BY a.attrelid, a.attphysnum",
tbloids->data);
res = ExecuteSqlQuery(fout, q->data, PGRES_TUPLES_OK);
@@ -8197,7 +8197,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
ntups = PQntuples(res);
i_attrelid = PQfnumber(res, "attrelid");
- i_attnum = PQfnumber(res, "attnum");
+ i_attnum = PQfnumber(res, "attphysnum");
i_attname = PQfnumber(res, "attname");
i_atttypname = PQfnumber(res, "atttypname");
i_atttypmod = PQfnumber(res, "atttypmod");
@@ -11010,7 +11010,7 @@ dumpCompositeType(Archive *fout, const TypeInfo *tyinfo)
*/
appendPQExpBufferStr(query,
"PREPARE dumpCompositeType(pg_catalog.oid) AS\n"
- "SELECT a.attname, a.attnum, "
+ "SELECT a.attname, a.attphysnum, "
"pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
"a.attlen, a.attalign, a.attisdropped, "
"CASE WHEN a.attcollation <> at.typcollation "
@@ -11019,7 +11019,7 @@ dumpCompositeType(Archive *fout, const TypeInfo *tyinfo)
"JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
"LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
"WHERE ct.oid = $1 "
- "ORDER BY a.attnum");
+ "ORDER BY a.attphysnum");
ExecuteSqlStatement(fout, query->data);
@@ -11214,7 +11214,7 @@ dumpCompositeTypeColComments(Archive *fout, const TypeInfo *tyinfo,
target = createPQExpBuffer();
ntups = PQntuples(res);
- i_attnum = PQfnumber(res, "attnum");
+ i_attnum = PQfnumber(res, "attphysnum");
i_attname = PQfnumber(res, "attname");
i_attisdropped = PQfnumber(res, "attisdropped");
while (ncomments > 0)
@@ -14869,11 +14869,11 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
"LEFT JOIN pg_catalog.pg_init_privs pip ON "
"(at.attrelid = pip.objoid "
"AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
- "AND at.attnum = pip.objsubid) "
+ "AND at.attphysnum = pip.objsubid) "
"WHERE at.attrelid = $1 AND "
"NOT at.attisdropped "
"AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
- "ORDER BY at.attnum");
+ "ORDER BY at.attphysnum");
}
else
{
@@ -14883,7 +14883,7 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
"FROM pg_catalog.pg_attribute "
"WHERE attrelid = $1 AND NOT attisdropped "
"AND attacl IS NOT NULL "
- "ORDER BY attnum");
+ "ORDER BY attphysnum");
}
ExecuteSqlStatement(fout, query->data);
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index d1ae699171..a25ec298fd 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -1731,21 +1731,42 @@ describeOneTableDetails(const char *schemaname,
goto error_return;
/* Get the column that owns this sequence */
- printfPQExpBuffer(&buf, "SELECT pg_catalog.quote_ident(nspname) || '.' ||"
- "\n pg_catalog.quote_ident(relname) || '.' ||"
- "\n pg_catalog.quote_ident(attname),"
- "\n d.deptype"
- "\nFROM pg_catalog.pg_class c"
- "\nINNER JOIN pg_catalog.pg_depend d ON c.oid=d.refobjid"
- "\nINNER JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace"
- "\nINNER JOIN pg_catalog.pg_attribute a ON ("
- "\n a.attrelid=c.oid AND"
- "\n a.attnum=d.refobjsubid)"
- "\nWHERE d.classid='pg_catalog.pg_class'::pg_catalog.regclass"
- "\n AND d.refclassid='pg_catalog.pg_class'::pg_catalog.regclass"
- "\n AND d.objid='%s'"
- "\n AND d.deptype IN ('a', 'i')",
- oid);
+ if (pset.sversion >= 150000) /* FIXME - bump me when pg15 branched */
+ {
+ printfPQExpBuffer(&buf, "SELECT pg_catalog.quote_ident(nspname) || '.' ||"
+ "\n pg_catalog.quote_ident(relname) || '.' ||"
+ "\n pg_catalog.quote_ident(attname),"
+ "\n d.deptype"
+ "\nFROM pg_catalog.pg_class c"
+ "\nINNER JOIN pg_catalog.pg_depend d ON c.oid=d.refobjid"
+ "\nINNER JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace"
+ "\nINNER JOIN pg_catalog.pg_attribute a ON ("
+ "\n a.attrelid=c.oid AND"
+ "\n a.attphysnum=d.refobjsubid)"
+ "\nWHERE d.classid='pg_catalog.pg_class'::pg_catalog.regclass"
+ "\n AND d.refclassid='pg_catalog.pg_class'::pg_catalog.regclass"
+ "\n AND d.objid='%s'"
+ "\n AND d.deptype IN ('a', 'i')",
+ oid);
+ }
+ else
+ {
+ printfPQExpBuffer(&buf, "SELECT pg_catalog.quote_ident(nspname) || '.' ||"
+ "\n pg_catalog.quote_ident(relname) || '.' ||"
+ "\n pg_catalog.quote_ident(attname),"
+ "\n d.deptype"
+ "\nFROM pg_catalog.pg_class c"
+ "\nINNER JOIN pg_catalog.pg_depend d ON c.oid=d.refobjid"
+ "\nINNER JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace"
+ "\nINNER JOIN pg_catalog.pg_attribute a ON ("
+ "\n a.attrelid=c.oid AND"
+ "\n a.attnum=d.refobjsubid)"
+ "\nWHERE d.classid='pg_catalog.pg_class'::pg_catalog.regclass"
+ "\n AND d.refclassid='pg_catalog.pg_class'::pg_catalog.regclass"
+ "\n AND d.objid='%s'"
+ "\n AND d.deptype IN ('a', 'i')",
+ oid);
+ }
result = PSQLexec(buf.data);
@@ -1819,11 +1840,23 @@ describeOneTableDetails(const char *schemaname,
if (show_column_details)
{
/* use "pretty" mode for expression to avoid excessive parentheses */
- appendPQExpBufferStr(&buf,
- ",\n (SELECT pg_catalog.pg_get_expr(d.adbin, d.adrelid, true)"
- "\n FROM pg_catalog.pg_attrdef d"
- "\n WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef)"
- ",\n a.attnotnull");
+ if (pset.sversion >= 150000) /* FIXME - bump me when pg15 branched */
+ {
+ appendPQExpBufferStr(&buf,
+ ",\n (SELECT pg_catalog.pg_get_expr(d.adbin, d.adrelid, true)"
+ "\n FROM pg_catalog.pg_attrdef d"
+ "\n WHERE d.adrelid = a.attrelid AND d.adnum = a.attphysnum AND a.atthasdef)"
+ ",\n a.attnotnull");
+ }
+ else
+ {
+ appendPQExpBufferStr(&buf,
+ ",\n (SELECT pg_catalog.pg_get_expr(d.adbin, d.adrelid, true)"
+ "\n FROM pg_catalog.pg_attrdef d"
+ "\n WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef)"
+ ",\n a.attnotnull");
+ }
+
attrdef_col = cols++;
attnotnull_col = cols++;
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
@@ -1843,7 +1876,15 @@ describeOneTableDetails(const char *schemaname,
if (tableinfo.relkind == RELKIND_INDEX ||
tableinfo.relkind == RELKIND_PARTITIONED_INDEX)
{
- if (pset.sversion >= 110000)
+ if (pset.sversion >= 150000) /* FIXME - bump me when pg15 branched */
+ {
+ appendPQExpBuffer(&buf, ",\n CASE WHEN a.attphysnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key",
+ oid,
+ gettext_noop("yes"),
+ gettext_noop("no"));
+ isindexkey_col = cols++;
+ }
+ else if (pset.sversion >= 110000)
{
appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key",
oid,
@@ -1851,7 +1892,11 @@ describeOneTableDetails(const char *schemaname,
gettext_noop("no"));
isindexkey_col = cols++;
}
- appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef");
+
+ if (pset.sversion >= 150000) /* FIXME - bump me when pg15 branched */
+ appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attphysnum, TRUE) AS indexdef");
+ else
+ appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef");
indexdef_col = cols++;
}
/* FDW options for foreign table column */
@@ -1901,14 +1946,25 @@ describeOneTableDetails(const char *schemaname,
tableinfo.relkind == RELKIND_COMPOSITE_TYPE ||
tableinfo.relkind == RELKIND_PARTITIONED_TABLE)
{
- appendPQExpBufferStr(&buf, ",\n pg_catalog.col_description(a.attrelid, a.attnum)");
+ if (pset.sversion >= 150000) /* FIXME - bump me when pg15 branched */
+ appendPQExpBufferStr(&buf, ",\n pg_catalog.col_description(a.attrelid, a.attphysnum)");
+ else
+ appendPQExpBufferStr(&buf, ",\n pg_catalog.col_description(a.attrelid, a.attnum)");
attdescr_col = cols++;
}
}
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_attribute a");
- appendPQExpBuffer(&buf, "\nWHERE a.attrelid = '%s' AND a.attnum > 0 AND NOT a.attisdropped", oid);
- appendPQExpBufferStr(&buf, "\nORDER BY a.attnum;");
+ if (pset.sversion >= 150000) /* FIXME - bump me when pg15 branched */
+ {
+ appendPQExpBuffer(&buf, "\nWHERE a.attrelid = '%s' AND a.attphysnum > 0 AND NOT a.attisdropped", oid);
+ appendPQExpBufferStr(&buf, "\nORDER BY a.attphysnum;");
+ }
+ else
+ {
+ appendPQExpBuffer(&buf, "\nWHERE a.attrelid = '%s' AND a.attnum > 0 AND NOT a.attisdropped", oid);
+ appendPQExpBufferStr(&buf, "\nORDER BY a.attnum;");
+ }
res = PSQLexec(buf.data);
if (!res)
@@ -2930,7 +2986,39 @@ describeOneTableDetails(const char *schemaname,
/* print any publications */
if (pset.sversion >= 100000)
{
- if (pset.sversion >= 150000)
+ if (pset.sversion >= 150000) /* FIXME - bump me when pg15 branched */
+ {
+ printfPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
+ " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
+ "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , pg_get_expr(pr.prqual, c.oid)\n"
+ " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " (SELECT string_agg(attname, ', ')\n"
+ " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = pr.prrelid AND attphysnum = prattrs[s])\n"
+ " ELSE NULL END) "
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
+ "WHERE pr.prrelid = '%s'\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ "ORDER BY 1;",
+ oid, oid, oid, oid);
+ }
+ else if (pset.sversion >= 150000)
{
printfPQExpBuffer(&buf,
"SELECT pubname\n"
@@ -4609,7 +4697,7 @@ listExtendedStats(const char *pattern)
" FROM pg_catalog.unnest(es.stxkeys) s(attnum) \n"
" JOIN pg_catalog.pg_attribute a \n"
" ON (es.stxrelid = a.attrelid \n"
- " AND a.attnum = s.attnum \n"
+ " AND a.attnum = s.attsnum \n"
" AND NOT a.attisdropped)), \n"
"es.stxrelid::pg_catalog.regclass) AS \"%s\"",
gettext_noop("Definition"));
@@ -6279,7 +6367,21 @@ describePublications(const char *pattern)
/* Get the tables for the specified publication */
printfPQExpBuffer(&buf,
"SELECT n.nspname, c.relname");
- if (pset.sversion >= 150000)
+ if (pset.sversion >= 150000) /* FIXME - bump me when pg15 branched */
+ {
+ appendPQExpBufferStr(&buf,
+ ", pg_get_expr(pr.prqual, c.oid)");
+ appendPQExpBufferStr(&buf,
+ ", (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " pg_catalog.array_to_string("
+ " ARRAY(SELECT attname\n"
+ " FROM\n"
+ " pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = c.oid AND attphysnum = prattrs[s]), ', ')\n"
+ " ELSE NULL END)");
+ }
+ else if (pset.sversion >= 150000)
{
appendPQExpBufferStr(&buf,
", pg_get_expr(pr.prqual, c.oid)");
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index bd44a1d55d..df5df475b8 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -516,7 +516,7 @@ static const SchemaQuery Query_for_list_of_arguments = {
static const SchemaQuery Query_for_list_of_attributes = {
.catname = "pg_catalog.pg_attribute a, pg_catalog.pg_class c",
- .selcondition = "c.oid = a.attrelid and a.attnum > 0 and not a.attisdropped",
+ .selcondition = "c.oid = a.attrelid and a.attphysnum > 0 and not a.attisdropped",
.result = "a.attname",
.refname = "c.relname",
.refviscondition = "pg_catalog.pg_table_is_visible(c.oid)",
@@ -525,7 +525,7 @@ static const SchemaQuery Query_for_list_of_attributes = {
static const SchemaQuery Query_for_list_of_attribute_numbers = {
.catname = "pg_catalog.pg_attribute a, pg_catalog.pg_class c",
- .selcondition = "c.oid = a.attrelid and a.attnum > 0 and not a.attisdropped",
+ .selcondition = "c.oid = a.attrelid and a.attphysnum > 0 and not a.attisdropped",
.result = "a.attnum::pg_catalog.text",
.refname = "c.relname",
.refviscondition = "pg_catalog.pg_table_is_visible(c.oid)",
diff --git a/src/include/access/genam.h b/src/include/access/genam.h
index 134b20f1e6..4d95e2801a 100644
--- a/src/include/access/genam.h
+++ b/src/include/access/genam.h
@@ -183,15 +183,15 @@ extern IndexBulkDeleteResult *index_bulk_delete(IndexVacuumInfo *info,
extern IndexBulkDeleteResult *index_vacuum_cleanup(IndexVacuumInfo *info,
IndexBulkDeleteResult *istat);
extern bool index_can_return(Relation indexRelation, int attno);
-extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum,
+extern RegProcedure index_getprocid(Relation irel, AttrNumber attphysnum,
uint16 procnum);
-extern FmgrInfo *index_getprocinfo(Relation irel, AttrNumber attnum,
+extern FmgrInfo *index_getprocinfo(Relation irel, AttrNumber attphysnum,
uint16 procnum);
extern void index_store_float8_orderby_distances(IndexScanDesc scan,
Oid *orderByTypes,
IndexOrderByDistance *distances,
bool recheckOrderBy);
-extern bytea *index_opclass_options(Relation relation, AttrNumber attnum,
+extern bytea *index_opclass_options(Relation relation, AttrNumber attphysnum,
Datum attoptions, bool validate);
diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h
index 2935d2f353..733686d724 100644
--- a/src/include/access/gin_private.h
+++ b/src/include/access/gin_private.h
@@ -95,13 +95,13 @@ extern Buffer GinNewBuffer(Relation index);
extern void GinInitBuffer(Buffer b, uint32 f);
extern void GinInitPage(Page page, uint32 f, Size pageSize);
extern void GinInitMetabuffer(Buffer b);
-extern int ginCompareEntries(GinState *ginstate, OffsetNumber attnum,
+extern int ginCompareEntries(GinState *ginstate, OffsetNumber attphysnum,
Datum a, GinNullCategory categorya,
Datum b, GinNullCategory categoryb);
extern int ginCompareAttEntries(GinState *ginstate,
OffsetNumber attnuma, Datum a, GinNullCategory categorya,
OffsetNumber attnumb, Datum b, GinNullCategory categoryb);
-extern Datum *ginExtractEntries(GinState *ginstate, OffsetNumber attnum,
+extern Datum *ginExtractEntries(GinState *ginstate, OffsetNumber attphysnum,
Datum value, bool isNull,
int32 *nentries, GinNullCategory **categories);
@@ -119,7 +119,7 @@ extern bool gininsert(Relation index, Datum *values, bool *isnull,
bool indexUnchanged,
struct IndexInfo *indexInfo);
extern void ginEntryInsert(GinState *ginstate,
- OffsetNumber attnum, Datum key, GinNullCategory category,
+ OffsetNumber attphysnum, Datum key, GinNullCategory category,
ItemPointerData *items, uint32 nitem,
GinStatsData *buildStats);
@@ -210,13 +210,13 @@ extern void ginInsertValue(GinBtree btree, GinBtreeStack *stack,
/* ginentrypage.c */
extern IndexTuple GinFormTuple(GinState *ginstate,
- OffsetNumber attnum, Datum key, GinNullCategory category,
+ OffsetNumber attphysnum, Datum key, GinNullCategory category,
Pointer data, Size dataSize, int nipd, bool errorTooBig);
-extern void ginPrepareEntryScan(GinBtree btree, OffsetNumber attnum,
+extern void ginPrepareEntryScan(GinBtree btree, OffsetNumber attphysnum,
Datum key, GinNullCategory category,
GinState *ginstate);
extern void ginEntryFillRoot(GinBtree btree, Page root, BlockNumber lblkno, Page lpage, BlockNumber rblkno, Page rpage);
-extern ItemPointer ginReadTuple(GinState *ginstate, OffsetNumber attnum,
+extern ItemPointer ginReadTuple(GinState *ginstate, OffsetNumber attphysnum,
IndexTuple itup, int *nitems);
/* gindatapage.c */
@@ -302,7 +302,7 @@ typedef struct GinScanKeyData
Pointer *extra_data;
StrategyNumber strategy;
int32 searchMode;
- OffsetNumber attnum;
+ OffsetNumber attphysnum;
/*
* An excludeOnly scan key is not able to enumerate all matching tuples.
@@ -340,7 +340,7 @@ typedef struct GinScanEntryData
Pointer extra_data;
StrategyNumber strategy;
int32 searchMode;
- OffsetNumber attnum;
+ OffsetNumber attphysnum;
/* Current page in posting tree */
Buffer buffer;
@@ -419,7 +419,7 @@ typedef struct GinEntryAccumulator
RBTNode rbtnode;
Datum key;
GinNullCategory category;
- OffsetNumber attnum;
+ OffsetNumber attphysnum;
bool shouldSort;
ItemPointerData *list;
uint32 maxcount; /* allocated size of list[] */
@@ -438,12 +438,12 @@ typedef struct
extern void ginInitBA(BuildAccumulator *accum);
extern void ginInsertBAEntries(BuildAccumulator *accum,
- ItemPointer heapptr, OffsetNumber attnum,
+ ItemPointer heapptr, OffsetNumber attphysnum,
Datum *entries, GinNullCategory *categories,
int32 nentries);
extern void ginBeginBAScan(BuildAccumulator *accum);
extern ItemPointerData *ginGetBAEntry(BuildAccumulator *accum,
- OffsetNumber *attnum, Datum *key, GinNullCategory *category,
+ OffsetNumber *attphysnum, Datum *key, GinNullCategory *category,
uint32 *n);
/* ginfast.c */
@@ -460,7 +460,7 @@ extern void ginHeapTupleFastInsert(GinState *ginstate,
GinTupleCollector *collector);
extern void ginHeapTupleFastCollect(GinState *ginstate,
GinTupleCollector *collector,
- OffsetNumber attnum, Datum value, bool isNull,
+ OffsetNumber attphysnum, Datum value, bool isNull,
ItemPointer ht_ctid);
extern void ginInsertCleanup(GinState *ginstate, bool full_clean,
bool fill_fsm, bool forceCleanup, IndexBulkDeleteResult *stats);
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 51a60eda08..a04c5df02e 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -697,13 +697,13 @@ extern void heap_fill_tuple(TupleDesc tupleDesc,
Datum *values, bool *isnull,
char *data, Size data_size,
uint16 *infomask, bits8 *bit);
-extern bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc);
-extern Datum nocachegetattr(HeapTuple tup, int attnum,
+extern bool heap_attisnull(HeapTuple tup, int attphysnum, TupleDesc tupleDesc);
+extern Datum nocachegetattr(HeapTuple tup, int attphysnum,
TupleDesc att);
-extern Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
+extern Datum heap_getsysattr(HeapTuple tup, int attphysnum, TupleDesc tupleDesc,
bool *isnull);
extern Datum getmissingattr(TupleDesc tupleDesc,
- int attnum, bool *isnull);
+ int attphysnum, bool *isnull);
extern HeapTuple heap_copytuple(HeapTuple tuple);
extern void heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest);
extern Datum heap_copy_tuple_as_datum(HeapTuple tuple, TupleDesc tupleDesc);
@@ -740,45 +740,45 @@ extern MinimalTuple minimal_expand_tuple(HeapTuple sourceTuple, TupleDesc tupleD
* value, or a pointer into the data area of the tuple).
*
* This must not be used when a system attribute might be requested.
- * Furthermore, the passed attnum MUST be valid. Use heap_getattr()
+ * Furthermore, the passed attphysnum MUST be valid. Use heap_getattr()
* instead, if in doubt.
*
* This gets called many times, so we macro the cacheable and NULL
* lookups, and call nocachegetattr() for the rest.
*/
static inline Datum
-fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
+fastgetattr(HeapTuple tup, int attphysnum, TupleDesc tupleDesc, bool *isnull)
{
- Assert(attnum > 0);
+ Assert(attphysnum > 0);
*isnull = false;
if (HeapTupleNoNulls(tup))
{
Form_pg_attribute att;
- att = TupleDescAttr(tupleDesc, attnum - 1);
+ att = TupleDescAttr(tupleDesc, attphysnum - 1);
if (att->attcacheoff >= 0)
return fetchatt(att, (char *) tup->t_data + tup->t_data->t_hoff +
att->attcacheoff);
else
- return nocachegetattr(tup, attnum, tupleDesc);
+ return nocachegetattr(tup, attphysnum, tupleDesc);
}
else
{
- if (att_isnull(attnum - 1, tup->t_data->t_bits))
+ if (att_isnull(attphysnum - 1, tup->t_data->t_bits))
{
*isnull = true;
return (Datum) NULL;
}
else
- return nocachegetattr(tup, attnum, tupleDesc);
+ return nocachegetattr(tup, attphysnum, tupleDesc);
}
}
/*
* heap_getattr
* Extract an attribute of a heap tuple and return it as a Datum.
- * This works for either system or user attributes. The given attnum
+ * This works for either system or user attributes. The given attphysnum
* is properly range-checked.
*
* If the field in question has a NULL value, we return a zero Datum
@@ -790,17 +790,17 @@ fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
*
*/
static inline Datum
-heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
+heap_getattr(HeapTuple tup, int attphysnum, TupleDesc tupleDesc, bool *isnull)
{
- if (attnum > 0)
+ if (attphysnum > 0)
{
- if (attnum > (int) HeapTupleHeaderGetNatts(tup->t_data))
- return getmissingattr(tupleDesc, attnum, isnull);
+ if (attphysnum > (int) HeapTupleHeaderGetNatts(tup->t_data))
+ return getmissingattr(tupleDesc, attphysnum, isnull);
else
- return fastgetattr(tup, attnum, tupleDesc, isnull);
+ return fastgetattr(tup, attphysnum, tupleDesc, isnull);
}
else
- return heap_getsysattr(tup, attnum, tupleDesc, isnull);
+ return heap_getsysattr(tup, attphysnum, tupleDesc, isnull);
}
#endif /* FRONTEND */
diff --git a/src/include/access/itup.h b/src/include/access/itup.h
index 2c8877e991..c31a20d53f 100644
--- a/src/include/access/itup.h
+++ b/src/include/access/itup.h
@@ -97,31 +97,31 @@ typedef IndexAttributeBitMapData * IndexAttributeBitMap;
*
* ----------------
*/
-#define index_getattr(tup, attnum, tupleDesc, isnull) \
+#define index_getattr(tup, attphysnum, tupleDesc, isnull) \
( \
- AssertMacro(PointerIsValid(isnull) && (attnum) > 0), \
+ AssertMacro(PointerIsValid(isnull) && (attphysnum) > 0), \
*(isnull) = false, \
!IndexTupleHasNulls(tup) ? \
( \
- TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff >= 0 ? \
+ TupleDescAttr((tupleDesc), (attphysnum)-1)->attcacheoff >= 0 ? \
( \
- fetchatt(TupleDescAttr((tupleDesc), (attnum)-1), \
+ fetchatt(TupleDescAttr((tupleDesc), (attphysnum)-1), \
(char *) (tup) + IndexInfoFindDataOffset((tup)->t_info) \
- + TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff) \
+ + TupleDescAttr((tupleDesc), (attphysnum)-1)->attcacheoff) \
) \
: \
- nocache_index_getattr((tup), (attnum), (tupleDesc)) \
+ nocache_index_getattr((tup), (attphysnum), (tupleDesc)) \
) \
: \
( \
- (att_isnull((attnum)-1, (char *)(tup) + sizeof(IndexTupleData))) ? \
+ (att_isnull((attphysnum)-1, (char *)(tup) + sizeof(IndexTupleData))) ? \
( \
*(isnull) = true, \
(Datum)NULL \
) \
: \
( \
- nocache_index_getattr((tup), (attnum), (tupleDesc)) \
+ nocache_index_getattr((tup), (attphysnum), (tupleDesc)) \
) \
) \
)
@@ -150,7 +150,7 @@ typedef IndexAttributeBitMapData * IndexAttributeBitMap;
/* routines in indextuple.c */
extern IndexTuple index_form_tuple(TupleDesc tupleDescriptor,
Datum *values, bool *isnull);
-extern Datum nocache_index_getattr(IndexTuple tup, int attnum,
+extern Datum nocache_index_getattr(IndexTuple tup, int attphysnum,
TupleDesc tupleDesc);
extern void index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor,
Datum *values, bool *isnull);
diff --git a/src/include/bootstrap/bootstrap.h b/src/include/bootstrap/bootstrap.h
index 49d4ad560f..cd4c2590f3 100644
--- a/src/include/bootstrap/bootstrap.h
+++ b/src/include/bootstrap/bootstrap.h
@@ -37,7 +37,7 @@ extern void BootstrapModeMain(int argc, char *argv[], bool check_only) pg_attrib
extern void closerel(char *name);
extern void boot_openrel(char *name);
-extern void DefineAttr(char *name, char *type, int attnum, int nullness);
+extern void DefineAttr(char *name, char *type, int attphysnum, int nullness);
extern void InsertOneTuple(void);
extern void InsertOneValue(char *value, int i);
extern void InsertOneNull(int i);
diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h
index d027075a4c..076fe7ff28 100644
--- a/src/include/catalog/dependency.h
+++ b/src/include/catalog/dependency.h
@@ -220,7 +220,7 @@ extern List *getAutoExtensionsOfObject(Oid classId, Oid objectId);
extern bool sequenceIsOwned(Oid seqId, char deptype, Oid *tableId, int32 *colId);
extern List *getOwnedSequences(Oid relid);
-extern Oid getIdentitySequence(Oid relid, AttrNumber attnum, bool missing_ok);
+extern Oid getIdentitySequence(Oid relid, AttrNumber attphysnum, bool missing_ok);
extern Oid get_index_constraint(Oid indexId);
diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h
index 07c5b88f0e..69d226dfd6 100644
--- a/src/include/catalog/heap.h
+++ b/src/include/catalog/heap.h
@@ -26,7 +26,7 @@
typedef struct RawColumnDefault
{
- AttrNumber attnum; /* attribute to attach default to */
+ AttrNumber attphysnum; /* attribute to attach default to */
Node *raw_default; /* default value (untransformed parse tree) */
bool missingMode; /* true if part of add column processing */
char generated; /* attgenerated setting */
@@ -37,7 +37,7 @@ typedef struct CookedConstraint
ConstrType contype; /* CONSTR_DEFAULT or CONSTR_CHECK */
Oid conoid; /* constr OID if created, otherwise Invalid */
char *name; /* name, or NULL if none */
- AttrNumber attnum; /* which attr (only for DEFAULT) */
+ AttrNumber attphysnum; /* which attr (only for DEFAULT) */
Node *expr; /* transformed default or check expr */
bool skip_validation; /* skip validation? (only for CHECK) */
bool is_local; /* constraint has local (non-inherited) def */
@@ -127,10 +127,10 @@ extern Node *cookDefault(ParseState *pstate,
extern void DeleteRelationTuple(Oid relid);
extern void DeleteAttributeTuples(Oid relid);
extern void DeleteSystemAttributeTuples(Oid relid);
-extern void RemoveAttributeById(Oid relid, AttrNumber attnum);
+extern void RemoveAttributeById(Oid relid, AttrNumber attphysnum);
extern void CopyStatistics(Oid fromrelid, Oid torelid);
-extern void RemoveStatistics(Oid relid, AttrNumber attnum);
+extern void RemoveStatistics(Oid relid, AttrNumber attphysnum);
extern const FormData_pg_attribute *SystemAttributeDefinition(AttrNumber attno);
diff --git a/src/include/catalog/pg_attrdef.h b/src/include/catalog/pg_attrdef.h
index a21dd3812b..53373c4d63 100644
--- a/src/include/catalog/pg_attrdef.h
+++ b/src/include/catalog/pg_attrdef.h
@@ -33,7 +33,7 @@ CATALOG(pg_attrdef,2604,AttrDefaultRelationId)
Oid adrelid BKI_LOOKUP(pg_class); /* OID of table containing
* attribute */
- int16 adnum; /* attnum of attribute */
+ int16 adnum; /* attphysnum of attribute */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
pg_node_tree adbin BKI_FORCE_NOT_NULL; /* nodeToString representation of
@@ -53,18 +53,18 @@ DECLARE_TOAST(pg_attrdef, 2830, 2831);
DECLARE_UNIQUE_INDEX(pg_attrdef_adrelid_adnum_index, 2656, AttrDefaultIndexId, on pg_attrdef using btree(adrelid oid_ops, adnum int2_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_attrdef_oid_index, 2657, AttrDefaultOidIndexId, on pg_attrdef using btree(oid oid_ops));
-DECLARE_FOREIGN_KEY((adrelid, adnum), pg_attribute, (attrelid, attnum));
+DECLARE_FOREIGN_KEY((adrelid, adnum), pg_attribute, (attrelid, attphysnum));
-extern Oid StoreAttrDefault(Relation rel, AttrNumber attnum,
+extern Oid StoreAttrDefault(Relation rel, AttrNumber attphysnum,
Node *expr, bool is_internal,
bool add_column_mode);
-extern void RemoveAttrDefault(Oid relid, AttrNumber attnum,
+extern void RemoveAttrDefault(Oid relid, AttrNumber attphysnum,
DropBehavior behavior,
bool complain, bool internal);
extern void RemoveAttrDefaultById(Oid attrdefId);
-extern Oid GetAttrDefaultOid(Oid relid, AttrNumber attnum);
+extern Oid GetAttrDefaultOid(Oid relid, AttrNumber attphysnum);
extern ObjectAddress GetAttrDefaultColumnAddress(Oid attrdefoid);
#endif /* PG_ATTRDEF_H */
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index 053294c99f..746566eb8d 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -68,7 +68,7 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
int16 attlen;
/*
- * attnum is the "attribute number" for the attribute: A value that
+ * attphysnum is the "attribute number" for the attribute: A value that
* uniquely identifies this attribute within its class. For user
* attributes, Attribute numbers are greater than 0 and not greater than
* the number of attributes in the class. I.e. if the Class pg_class says
@@ -78,9 +78,9 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
* System attributes have attribute numbers less than 0 that are unique
* within the class, but not constrained to any particular range.
*
- * Note that (attnum - 1) is often used as the index to an array.
+ * Note that (attphysnum - 1) is often used as the index to an array.
*/
- int16 attnum;
+ int16 attphysnum;
/*
* attndims is the declared number of dimensions, if an array type,
@@ -207,7 +207,7 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
typedef FormData_pg_attribute *Form_pg_attribute;
DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index, 2658, AttributeRelidNameIndexId, on pg_attribute using btree(attrelid oid_ops, attname name_ops));
-DECLARE_UNIQUE_INDEX_PKEY(pg_attribute_relid_attnum_index, 2659, AttributeRelidNumIndexId, on pg_attribute using btree(attrelid oid_ops, attnum int2_ops));
+DECLARE_UNIQUE_INDEX_PKEY(pg_attribute_relid_attphysnum_index, 2659, AttributeRelidPhysNumIndexId, on pg_attribute using btree(attrelid oid_ops, attphysnum int2_ops));
#ifdef EXPOSE_TO_CLIENT_CODE
diff --git a/src/include/catalog/pg_constraint.h b/src/include/catalog/pg_constraint.h
index e7d967f137..39c5c23095 100644
--- a/src/include/catalog/pg_constraint.h
+++ b/src/include/catalog/pg_constraint.h
@@ -173,8 +173,8 @@ DECLARE_UNIQUE_INDEX_PKEY(pg_constraint_oid_index, 2667, ConstraintOidIndexId, o
DECLARE_INDEX(pg_constraint_conparentid_index, 2579, ConstraintParentIndexId, on pg_constraint using btree(conparentid oid_ops));
/* conkey can contain zero (InvalidAttrNumber) if a whole-row Var is used */
-DECLARE_ARRAY_FOREIGN_KEY_OPT((conrelid, conkey), pg_attribute, (attrelid, attnum));
-DECLARE_ARRAY_FOREIGN_KEY((confrelid, confkey), pg_attribute, (attrelid, attnum));
+DECLARE_ARRAY_FOREIGN_KEY_OPT((conrelid, conkey), pg_attribute, (attrelid, attphysnum));
+DECLARE_ARRAY_FOREIGN_KEY((confrelid, confkey), pg_attribute, (attrelid, attphysnum));
#ifdef EXPOSE_TO_CLIENT_CODE
diff --git a/src/include/catalog/pg_index.h b/src/include/catalog/pg_index.h
index f853846ee1..13d4fcb805 100644
--- a/src/include/catalog/pg_index.h
+++ b/src/include/catalog/pg_index.h
@@ -73,7 +73,7 @@ DECLARE_INDEX(pg_index_indrelid_index, 2678, IndexIndrelidIndexId, on pg_index u
DECLARE_UNIQUE_INDEX_PKEY(pg_index_indexrelid_index, 2679, IndexRelidIndexId, on pg_index using btree(indexrelid oid_ops));
/* indkey can contain zero (InvalidAttrNumber) to represent expressions */
-DECLARE_ARRAY_FOREIGN_KEY_OPT((indrelid, indkey), pg_attribute, (attrelid, attnum));
+DECLARE_ARRAY_FOREIGN_KEY_OPT((indrelid, indkey), pg_attribute, (attrelid, attphysnum));
#ifdef EXPOSE_TO_CLIENT_CODE
diff --git a/src/include/catalog/pg_partitioned_table.h b/src/include/catalog/pg_partitioned_table.h
index 9b78f84cd5..c6da704bf4 100644
--- a/src/include/catalog/pg_partitioned_table.h
+++ b/src/include/catalog/pg_partitioned_table.h
@@ -69,6 +69,6 @@ DECLARE_TOAST(pg_partitioned_table, 4165, 4166);
DECLARE_UNIQUE_INDEX_PKEY(pg_partitioned_table_partrelid_index, 3351, PartitionedRelidIndexId, on pg_partitioned_table using btree(partrelid oid_ops));
/* partattrs can contain zero (InvalidAttrNumber) to represent expressions */
-DECLARE_ARRAY_FOREIGN_KEY_OPT((partrelid, partattrs), pg_attribute, (attrelid, attnum));
+DECLARE_ARRAY_FOREIGN_KEY_OPT((partrelid, partattrs), pg_attribute, (attrelid, attphysnum));
#endif /* PG_PARTITIONED_TABLE_H */
diff --git a/src/include/catalog/pg_statistic.h b/src/include/catalog/pg_statistic.h
index cdf7448139..d63b8dd30f 100644
--- a/src/include/catalog/pg_statistic.h
+++ b/src/include/catalog/pg_statistic.h
@@ -138,7 +138,7 @@ DECLARE_TOAST(pg_statistic, 2840, 2841);
DECLARE_UNIQUE_INDEX_PKEY(pg_statistic_relid_att_inh_index, 2696, StatisticRelidAttnumInhIndexId, on pg_statistic using btree(starelid oid_ops, staattnum int2_ops, stainherit bool_ops));
-DECLARE_FOREIGN_KEY((starelid, staattnum), pg_attribute, (attrelid, attnum));
+DECLARE_FOREIGN_KEY((starelid, staattnum), pg_attribute, (attrelid, attphysnum));
#ifdef EXPOSE_TO_CLIENT_CODE
diff --git a/src/include/catalog/pg_statistic_ext.h b/src/include/catalog/pg_statistic_ext.h
index b8520ba923..96b260e34d 100644
--- a/src/include/catalog/pg_statistic_ext.h
+++ b/src/include/catalog/pg_statistic_ext.h
@@ -74,7 +74,7 @@ DECLARE_UNIQUE_INDEX_PKEY(pg_statistic_ext_oid_index, 3380, StatisticExtOidIndex
DECLARE_UNIQUE_INDEX(pg_statistic_ext_name_index, 3997, StatisticExtNameIndexId, on pg_statistic_ext using btree(stxname name_ops, stxnamespace oid_ops));
DECLARE_INDEX(pg_statistic_ext_relid_index, 3379, StatisticExtRelidIndexId, on pg_statistic_ext using btree(stxrelid oid_ops));
-DECLARE_ARRAY_FOREIGN_KEY((stxrelid, stxkeys), pg_attribute, (attrelid, attnum));
+DECLARE_ARRAY_FOREIGN_KEY((stxrelid, stxkeys), pg_attribute, (attrelid, attphysnum));
#ifdef EXPOSE_TO_CLIENT_CODE
diff --git a/src/include/catalog/pg_trigger.h b/src/include/catalog/pg_trigger.h
index 194277bca5..7036916879 100644
--- a/src/include/catalog/pg_trigger.h
+++ b/src/include/catalog/pg_trigger.h
@@ -85,7 +85,7 @@ DECLARE_INDEX(pg_trigger_tgconstraint_index, 2699, TriggerConstraintIndexId, on
DECLARE_UNIQUE_INDEX(pg_trigger_tgrelid_tgname_index, 2701, TriggerRelidNameIndexId, on pg_trigger using btree(tgrelid oid_ops, tgname name_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_trigger_oid_index, 2702, TriggerOidIndexId, on pg_trigger using btree(oid oid_ops));
-DECLARE_ARRAY_FOREIGN_KEY((tgrelid, tgattr), pg_attribute, (attrelid, attnum));
+DECLARE_ARRAY_FOREIGN_KEY((tgrelid, tgattr), pg_attribute, (attrelid, attphysnum));
#ifdef EXPOSE_TO_CLIENT_CODE
diff --git a/src/include/executor/execExpr.h b/src/include/executor/execExpr.h
index e34db8c93c..709b84bd79 100644
--- a/src/include/executor/execExpr.h
+++ b/src/include/executor/execExpr.h
@@ -301,9 +301,9 @@ typedef struct ExprEvalStep
/* for EEOP_INNER/OUTER/SCAN_[SYS]VAR[_FIRST] */
struct
{
- /* attnum is attr number - 1 for regular VAR ... */
+ /* attphysnum is attr number - 1 for regular VAR ... */
/* but it's just the normal (negative) attr number for SYSVAR */
- int attnum;
+ int attphysnum;
Oid vartype; /* type OID of variable */
} var;
@@ -323,7 +323,7 @@ typedef struct ExprEvalStep
/* target index in ExprState->resultslot->tts_values/nulls */
int resultnum;
/* source attribute number - 1 */
- int attnum;
+ int attphysnum;
} assign_var;
/* for EEOP_ASSIGN_TMP[_MAKE_RO] */
diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h
index b2c0c7486c..a49ea6cfef 100644
--- a/src/include/executor/spi.h
+++ b/src/include/executor/spi.h
@@ -161,7 +161,7 @@ extern CachedPlan *SPI_plan_get_cached_plan(SPIPlanPtr plan);
extern HeapTuple SPI_copytuple(HeapTuple tuple);
extern HeapTupleHeader SPI_returntuple(HeapTuple tuple, TupleDesc tupdesc);
extern HeapTuple SPI_modifytuple(Relation rel, HeapTuple tuple, int natts,
- int *attnum, Datum *Values, const char *Nulls);
+ int *attphysnum, Datum *Values, const char *Nulls);
extern int SPI_fnumber(TupleDesc tupdesc, const char *fname);
extern char *SPI_fname(TupleDesc tupdesc, int fnumber);
extern char *SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber);
diff --git a/src/include/executor/tuptable.h b/src/include/executor/tuptable.h
index 6306bb6fc6..3b8f0607a0 100644
--- a/src/include/executor/tuptable.h
+++ b/src/include/executor/tuptable.h
@@ -165,7 +165,7 @@ struct TupleTableSlotOps
* to false, if it's not NULL. Throws an error if the slot type does not
* support system attributes.
*/
- Datum (*getsysattr) (TupleTableSlot *slot, int attnum, bool *isnull);
+ Datum (*getsysattr) (TupleTableSlot *slot, int attphysnum, bool *isnull);
/*
* Make the contents of the slot solely depend on the slot, and not on
@@ -328,7 +328,7 @@ extern MinimalTuple ExecFetchSlotMinimalTuple(TupleTableSlot *slot,
extern Datum ExecFetchSlotHeapTupleDatum(TupleTableSlot *slot);
extern void slot_getmissingattrs(TupleTableSlot *slot, int startAttNum,
int lastAttNum);
-extern void slot_getsomeattrs_int(TupleTableSlot *slot, int attnum);
+extern void slot_getsomeattrs_int(TupleTableSlot *slot, int attphysnum);
#ifndef FRONTEND
@@ -338,10 +338,10 @@ extern void slot_getsomeattrs_int(TupleTableSlot *slot, int attnum);
* valid at least up through the attnum'th entry.
*/
static inline void
-slot_getsomeattrs(TupleTableSlot *slot, int attnum)
+slot_getsomeattrs(TupleTableSlot *slot, int attphysnum)
{
- if (slot->tts_nvalid < attnum)
- slot_getsomeattrs_int(slot, attnum);
+ if (slot->tts_nvalid < attphysnum)
+ slot_getsomeattrs_int(slot, attphysnum);
}
/*
@@ -364,31 +364,31 @@ slot_getallattrs(TupleTableSlot *slot)
* it.
*/
static inline bool
-slot_attisnull(TupleTableSlot *slot, int attnum)
+slot_attisnull(TupleTableSlot *slot, int attphysnum)
{
- AssertArg(attnum > 0);
+ AssertArg(attphysnum > 0);
- if (attnum > slot->tts_nvalid)
- slot_getsomeattrs(slot, attnum);
+ if (attphysnum > slot->tts_nvalid)
+ slot_getsomeattrs(slot, attphysnum);
- return slot->tts_isnull[attnum - 1];
+ return slot->tts_isnull[attphysnum - 1];
}
/*
* slot_getattr - fetch one attribute of the slot's contents.
*/
static inline Datum
-slot_getattr(TupleTableSlot *slot, int attnum,
+slot_getattr(TupleTableSlot *slot, int attphysnum,
bool *isnull)
{
- AssertArg(attnum > 0);
+ AssertArg(attphysnum > 0);
- if (attnum > slot->tts_nvalid)
- slot_getsomeattrs(slot, attnum);
+ if (attphysnum > slot->tts_nvalid)
+ slot_getsomeattrs(slot, attphysnum);
- *isnull = slot->tts_isnull[attnum - 1];
+ *isnull = slot->tts_isnull[attphysnum - 1];
- return slot->tts_values[attnum - 1];
+ return slot->tts_values[attphysnum - 1];
}
/*
@@ -399,23 +399,23 @@ slot_getattr(TupleTableSlot *slot, int attnum,
* the slot type is the one that supports system attributes.
*/
static inline Datum
-slot_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
+slot_getsysattr(TupleTableSlot *slot, int attphysnum, bool *isnull)
{
- AssertArg(attnum < 0); /* caller error */
+ AssertArg(attphysnum < 0); /* caller error */
- if (attnum == TableOidAttributeNumber)
+ if (attphysnum == TableOidAttributeNumber)
{
*isnull = false;
return ObjectIdGetDatum(slot->tts_tableOid);
}
- else if (attnum == SelfItemPointerAttributeNumber)
+ else if (attphysnum == SelfItemPointerAttributeNumber)
{
*isnull = false;
return PointerGetDatum(&slot->tts_tid);
}
/* Fetch the system attribute from the underlying tuple. */
- return slot->tts_ops->getsysattr(slot, attnum, isnull);
+ return slot->tts_ops->getsysattr(slot, attphysnum, isnull);
}
/*
diff --git a/src/include/foreign/foreign.h b/src/include/foreign/foreign.h
index 75538110fc..0e28214a86 100644
--- a/src/include/foreign/foreign.h
+++ b/src/include/foreign/foreign.h
@@ -76,7 +76,7 @@ extern ForeignDataWrapper *GetForeignDataWrapperByName(const char *name,
bool missing_ok);
extern ForeignTable *GetForeignTable(Oid relid);
-extern List *GetForeignColumnOptions(Oid relid, AttrNumber attnum);
+extern List *GetForeignColumnOptions(Oid relid, AttrNumber attphysnum);
extern Oid get_foreign_data_wrapper_oid(const char *fdwname, bool missing_ok);
extern Oid get_foreign_server_oid(const char *servername, bool missing_ok);
diff --git a/src/include/parser/parsetree.h b/src/include/parser/parsetree.h
index 3a1afffd18..0aa6de3247 100644
--- a/src/include/parser/parsetree.h
+++ b/src/include/parser/parsetree.h
@@ -35,13 +35,13 @@
* Given an RTE and an attribute number, return the appropriate
* variable name or alias for that attribute of that RTE.
*/
-extern char *get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum);
+extern char *get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attphysnum);
/*
* Check whether an attribute of an RTE has been dropped
*/
extern bool get_rte_attribute_is_dropped(RangeTblEntry *rte,
- AttrNumber attnum);
+ AttrNumber attphysnum);
/* ----------------
diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h
index 48f7d72add..a51586f473 100644
--- a/src/include/utils/acl.h
+++ b/src/include/utils/acl.h
@@ -234,9 +234,9 @@ extern void ExecAlterDefaultPrivilegesStmt(ParseState *pstate, AlterDefaultPrivi
extern void RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid);
-extern AclMode pg_attribute_aclmask(Oid table_oid, AttrNumber attnum,
+extern AclMode pg_attribute_aclmask(Oid table_oid, AttrNumber attphysnum,
Oid roleid, AclMode mask, AclMaskHow how);
-extern AclMode pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum,
+extern AclMode pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attphysnum,
Oid roleid, AclMode mask,
AclMaskHow how, bool *is_missing);
extern AclMode pg_class_aclmask(Oid table_oid, Oid roleid,
@@ -267,9 +267,9 @@ extern AclMode pg_foreign_server_aclmask(Oid srv_oid, Oid roleid,
extern AclMode pg_type_aclmask(Oid type_oid, Oid roleid,
AclMode mask, AclMaskHow how);
-extern AclResult pg_attribute_aclcheck(Oid table_oid, AttrNumber attnum,
+extern AclResult pg_attribute_aclcheck(Oid table_oid, AttrNumber attphysnum,
Oid roleid, AclMode mode);
-extern AclResult pg_attribute_aclcheck_ext(Oid table_oid, AttrNumber attnum,
+extern AclResult pg_attribute_aclcheck_ext(Oid table_oid, AttrNumber attphysnum,
Oid roleid, AclMode mode,
bool *is_missing);
extern AclResult pg_attribute_aclcheck_all(Oid table_oid, Oid roleid,
diff --git a/src/include/utils/attoptcache.h b/src/include/utils/attoptcache.h
index ee37af9500..1042d41503 100644
--- a/src/include/utils/attoptcache.h
+++ b/src/include/utils/attoptcache.h
@@ -23,6 +23,6 @@ typedef struct AttributeOpts
float8 n_distinct_inherited;
} AttributeOpts;
-extern AttributeOpts *get_attribute_options(Oid spcid, int attnum);
+extern AttributeOpts *get_attribute_options(Oid spcid, int attphysnum);
#endif /* ATTOPTCACHE_H */
diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h
index b8dd27d4a9..3f90894219 100644
--- a/src/include/utils/lsyscache.h
+++ b/src/include/utils/lsyscache.h
@@ -62,7 +62,7 @@ typedef struct AttStatsSlot
} AttStatsSlot;
/* Hook for plugins to get control in get_attavgwidth() */
-typedef int32 (*get_attavgwidth_hook_type) (Oid relid, AttrNumber attnum);
+typedef int32 (*get_attavgwidth_hook_type) (Oid relid, AttrNumber attphysnum);
extern PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook;
extern bool op_in_opfamily(Oid opno, Oid opfamily);
@@ -88,14 +88,14 @@ extern bool equality_ops_are_compatible(Oid opno1, Oid opno2);
extern bool comparison_ops_are_compatible(Oid opno1, Oid opno2);
extern Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype,
int16 procnum);
-extern char *get_attname(Oid relid, AttrNumber attnum, bool missing_ok);
-extern AttrNumber get_attnum(Oid relid, const char *attname);
-extern int get_attstattarget(Oid relid, AttrNumber attnum);
-extern char get_attgenerated(Oid relid, AttrNumber attnum);
-extern Oid get_atttype(Oid relid, AttrNumber attnum);
-extern void get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
+extern char *get_attname(Oid relid, AttrNumber attphysnum, bool missing_ok);
+extern AttrNumber get_attphysnum(Oid relid, const char *attname);
+extern int get_attstattarget(Oid relid, AttrNumber attphysnum);
+extern char get_attgenerated(Oid relid, AttrNumber attphysnum);
+extern Oid get_atttype(Oid relid, AttrNumber attphysnum);
+extern void get_atttypetypmodcoll(Oid relid, AttrNumber attphysnum,
Oid *typid, int32 *typmod, Oid *collid);
-extern Datum get_attoptions(Oid relid, int16 attnum);
+extern Datum get_attoptions(Oid relid, int16 attphysnum);
extern Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok);
extern char *get_collation_name(Oid colloid);
extern bool get_collation_isdeterministic(Oid colloid);
@@ -184,7 +184,7 @@ extern const struct SubscriptRoutines *getSubscriptingRoutines(Oid typid,
extern Oid getBaseType(Oid typid);
extern Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod);
extern int32 get_typavgwidth(Oid typid, int32 typmod);
-extern int32 get_attavgwidth(Oid relid, AttrNumber attnum);
+extern int32 get_attavgwidth(Oid relid, AttrNumber attphysnum);
extern bool get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple,
int reqkind, Oid reqop, int flags);
extern void free_attstatsslot(AttStatsSlot *sslot);
diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h
index c93d8654bb..4733e06849 100644
--- a/src/include/utils/relcache.h
+++ b/src/include/utils/relcache.h
@@ -84,7 +84,7 @@ extern void RelationInitTableAccessMethod(Relation relation);
* Routines to support ereport() reports of relation-related errors
*/
extern int errtable(Relation rel);
-extern int errtablecol(Relation rel, int attnum);
+extern int errtablecol(Relation rel, int attphysnum);
extern int errtablecolname(Relation rel, const char *colname);
extern int errtableconstraint(Relation rel, const char *conname);
diff --git a/src/include/utils/selfuncs.h b/src/include/utils/selfuncs.h
index d485b9bfcd..e7afaa14fc 100644
--- a/src/include/utils/selfuncs.h
+++ b/src/include/utils/selfuncs.h
@@ -136,7 +136,7 @@ typedef struct
/* Hooks for plugins to get control when we ask for stats */
typedef bool (*get_relation_stats_hook_type) (PlannerInfo *root,
RangeTblEntry *rte,
- AttrNumber attnum,
+ AttrNumber attphysnum,
VariableStatData *vardata);
extern PGDLLIMPORT get_relation_stats_hook_type get_relation_stats_hook;
typedef bool (*get_index_stats_hook_type) (PlannerInfo *root,
diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h
index 4463ea66be..a7c817a72f 100644
--- a/src/include/utils/syscache.h
+++ b/src/include/utils/syscache.h
@@ -38,7 +38,7 @@ enum SysCacheIdentifier
AMOPSTRATEGY,
AMPROCNUM,
ATTNAME,
- ATTNUM,
+ ATTPHYSNUM,
AUTHMEMMEMROLE,
AUTHMEMROLEMEM,
AUTHNAME,
@@ -151,8 +151,8 @@ extern HeapTuple SearchSysCacheAttName(Oid relid, const char *attname);
extern HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname);
extern bool SearchSysCacheExistsAttName(Oid relid, const char *attname);
-extern HeapTuple SearchSysCacheAttNum(Oid relid, int16 attnum);
-extern HeapTuple SearchSysCacheCopyAttNum(Oid relid, int16 attnum);
+extern HeapTuple SearchSysCacheAttNum(Oid relid, int16 attphysnum);
+extern HeapTuple SearchSysCacheCopyAttNum(Oid relid, int16 attphysnum);
extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
AttrNumber attributeNumber, bool *isNull);
diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h
index 4e6ee1c619..1a09017356 100644
--- a/src/pl/plpgsql/src/plpgsql.h
+++ b/src/pl/plpgsql/src/plpgsql.h
@@ -426,7 +426,7 @@ typedef struct PLpgSQL_recfield
int recparentno; /* dno of parent record */
int nextfield; /* dno of next child, or -1 if none */
uint64 rectupledescid; /* record's tupledesc ID as of last lookup */
- ExpandedRecordFieldInfo finfo; /* field's attnum and type info */
+ ExpandedRecordFieldInfo finfo; /* field's attphysnum and type info */
/* if rectupledescid == INVALID_TUPLEDESC_IDENTIFIER, finfo isn't valid */
} PLpgSQL_recfield;
diff --git a/src/test/modules/brin/expected/summarization-and-inprogress-insertion.out b/src/test/modules/brin/expected/summarization-and-inprogress-insertion.out
index 2a4755d099..92efe0b6ea 100644
--- a/src/test/modules/brin/expected/summarization-and-inprogress-insertion.out
+++ b/src/test/modules/brin/expected/summarization-and-inprogress-insertion.out
@@ -2,9 +2,9 @@ Parsed test spec with 2 sessions
starting permutation: s2check s1b s2b s1i s2summ s1c s2c s2check
step s2check: SELECT * FROM brin_page_items(get_raw_page('brinidx', 2), 'brinidx'::regclass);
-itemoffset|blknum|attnum|allnulls|hasnulls|placeholder|value
-----------+------+------+--------+--------+-----------+--------
- 1| 0| 1|f |f |f |{1 .. 1}
+itemoffset|blknum|attphysnum|allnulls|hasnulls|placeholder|value
+----------+------+----------+--------+--------+-----------+--------
+ 1| 0| 1|f |f |f |{1 .. 1}
(1 row)
step s1b: BEGIN ISOLATION LEVEL REPEATABLE READ;
@@ -24,18 +24,18 @@ brin_summarize_new_values
step s1c: COMMIT;
step s2c: COMMIT;
step s2check: SELECT * FROM brin_page_items(get_raw_page('brinidx', 2), 'brinidx'::regclass);
-itemoffset|blknum|attnum|allnulls|hasnulls|placeholder|value
-----------+------+------+--------+--------+-----------+-----------
- 1| 0| 1|f |f |f |{1 .. 1}
- 2| 1| 1|f |f |f |{1 .. 1000}
+itemoffset|blknum|attphysnum|allnulls|hasnulls|placeholder|value
+----------+------+----------+--------+--------+-----------+-----------
+ 1| 0| 1|f |f |f |{1 .. 1}
+ 2| 1| 1|f |f |f |{1 .. 1000}
(2 rows)
starting permutation: s2check s1b s1i s2vacuum s1c s2check
step s2check: SELECT * FROM brin_page_items(get_raw_page('brinidx', 2), 'brinidx'::regclass);
-itemoffset|blknum|attnum|allnulls|hasnulls|placeholder|value
-----------+------+------+--------+--------+-----------+--------
- 1| 0| 1|f |f |f |{1 .. 1}
+itemoffset|blknum|attphysnum|allnulls|hasnulls|placeholder|value
+----------+------+----------+--------+--------+-----------+--------
+ 1| 0| 1|f |f |f |{1 .. 1}
(1 row)
step s1b: BEGIN ISOLATION LEVEL REPEATABLE READ;
@@ -43,9 +43,9 @@ step s1i: INSERT INTO brin_iso VALUES (1000);
step s2vacuum: VACUUM brin_iso;
step s1c: COMMIT;
step s2check: SELECT * FROM brin_page_items(get_raw_page('brinidx', 2), 'brinidx'::regclass);
-itemoffset|blknum|attnum|allnulls|hasnulls|placeholder|value
-----------+------+------+--------+--------+-----------+-----------
- 1| 0| 1|f |f |f |{1 .. 1}
- 2| 1| 1|f |f |f |{1 .. 1000}
+itemoffset|blknum|attphysnum|allnulls|hasnulls|placeholder|value
+----------+------+----------+--------+--------+-----------+-----------
+ 1| 0| 1|f |f |f |{1 .. 1}
+ 2| 1| 1|f |f |f |{1 .. 1000}
(2 rows)
diff --git a/src/test/modules/test_misc/t/001_constraint_validation.pl b/src/test/modules/test_misc/t/001_constraint_validation.pl
index 3b9fc66b8e..62ef05dd08 100644
--- a/src/test/modules/test_misc/t/001_constraint_validation.pl
+++ b/src/test/modules/test_misc/t/001_constraint_validation.pl
@@ -209,7 +209,7 @@ run_sql_command(
c int,
d int,
e int,
- LIKE list_parted2, -- a will have attnum = 4
+ LIKE list_parted2, -- a will have attphysnum = 4
CONSTRAINT check_b CHECK (b IS NULL OR b = \'a\'),
CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 7)
);
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 5ede56d9b5..777de22333 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -1746,8 +1746,8 @@ NOTICE: merging multiple inherited definitions of column "name"
create table gc1() inherits (c1);
select relname, attname, attinhcount, attislocal
from pg_class join pg_attribute on (pg_class.oid = pg_attribute.attrelid)
-where relname in ('p1','p2','c1','gc1') and attnum > 0 and not attisdropped
-order by relname, attnum;
+where relname in ('p1','p2','c1','gc1') and attphysnum > 0 and not attisdropped
+order by relname, attphysnum;
relname | attname | attinhcount | attislocal
---------+---------+-------------+------------
c1 | id | 1 | f
@@ -1789,8 +1789,8 @@ alter table dropColumnExists drop column if exists non_existing; --succeed
NOTICE: column "non_existing" of relation "dropcolumnexists" does not exist, skipping
select relname, attname, attinhcount, attislocal
from pg_class join pg_attribute on (pg_class.oid = pg_attribute.attrelid)
-where relname in ('p1','p2','c1','gc1') and attnum > 0 and not attisdropped
-order by relname, attnum;
+where relname in ('p1','p2','c1','gc1') and attphysnum > 0 and not attisdropped
+order by relname, attphysnum;
relname | attname | attinhcount | attislocal
---------+---------+-------------+------------
c1 | id | 1 | f
@@ -1815,8 +1815,8 @@ alter table depth0 add c text;
NOTICE: merging definition of column "c" for child "depth1"
select attrelid::regclass, attname, attinhcount, attislocal
from pg_attribute
-where attnum > 0 and attrelid::regclass in ('depth0', 'depth1', 'depth2')
-order by attrelid::regclass::text, attnum;
+where attphysnum > 0 and attrelid::regclass in ('depth0', 'depth1', 'depth2')
+order by attrelid::regclass::text, attphysnum;
attrelid | attname | attinhcount | attislocal
----------+---------+-------------+------------
depth0 | c | 0 | t
@@ -3915,7 +3915,7 @@ CREATE TABLE part_1 (
);
ALTER TABLE list_parted ATTACH PARTITION part_1 FOR VALUES IN (1);
-- attislocal and conislocal are always false for merged attributes and constraints respectively.
-SELECT attislocal, attinhcount FROM pg_attribute WHERE attrelid = 'part_1'::regclass AND attnum > 0;
+SELECT attislocal, attinhcount FROM pg_attribute WHERE attrelid = 'part_1'::regclass AND attphysnum > 0;
attislocal | attinhcount
------------+-------------
f | 1
@@ -4063,7 +4063,7 @@ CREATE TABLE part_7_a_null (
c int,
d int,
e int,
- LIKE list_parted2, -- 'a' will have attnum = 4
+ LIKE list_parted2, -- 'a' will have attphysnum = 4
CONSTRAINT check_b CHECK (b IS NULL OR b = 'a'),
CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 7)
);
@@ -4200,7 +4200,7 @@ DROP TABLE not_a_part;
-- check that, after being detached, attinhcount/coninhcount is dropped to 0 and
-- attislocal/conislocal is set to true
ALTER TABLE list_parted2 DETACH PARTITION part_3_4;
-SELECT attinhcount, attislocal FROM pg_attribute WHERE attrelid = 'part_3_4'::regclass AND attnum > 0;
+SELECT attinhcount, attislocal FROM pg_attribute WHERE attrelid = 'part_3_4'::regclass AND attphysnum > 0;
attinhcount | attislocal
-------------+------------
0 | t
@@ -4359,19 +4359,19 @@ alter table p11 drop a;
alter table p11 add a int;
alter table p11 drop a;
alter table p11 add a int not null;
--- attnum for key attribute 'a' is different in p, p1, and p11
-select attrelid::regclass, attname, attnum
+-- attphysnum for key attribute 'a' is different in p, p1, and p11
+select attrelid::regclass, attname, attphysnum
from pg_attribute
where attname = 'a'
and (attrelid = 'p'::regclass
or attrelid = 'p1'::regclass
or attrelid = 'p11'::regclass)
order by attrelid::regclass::text;
- attrelid | attname | attnum
-----------+---------+--------
- p | a | 1
- p1 | a | 2
- p11 | a | 4
+ attrelid | attname | attphysnum
+----------+---------+------------
+ p | a | 1
+ p1 | a | 2
+ p11 | a | 4
(3 rows)
alter table p1 attach partition p11 for values from (2) to (5);
diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out
index d55aec3a1d..aef80b4c36 100644
--- a/src/test/regress/expected/create_index.out
+++ b/src/test/regress/expected/create_index.out
@@ -2684,17 +2684,17 @@ SELECT starelid::regclass, count(*) FROM pg_statistic WHERE starelid IN (
(1 row)
-- attstattarget should remain intact
-SELECT attrelid::regclass, attnum, attstattarget
+SELECT attrelid::regclass, attphysnum, attstattarget
FROM pg_attribute WHERE attrelid IN (
'concur_exprs_index_expr'::regclass,
'concur_exprs_index_pred'::regclass,
'concur_exprs_index_pred_2'::regclass)
- ORDER BY attrelid::regclass::text, attnum;
- attrelid | attnum | attstattarget
----------------------------+--------+---------------
- concur_exprs_index_expr | 1 | 100
- concur_exprs_index_pred | 1 | -1
- concur_exprs_index_pred_2 | 1 | -1
+ ORDER BY attrelid::regclass::text, attphysnum;
+ attrelid | attphysnum | attstattarget
+---------------------------+------------+---------------
+ concur_exprs_index_expr | 1 | 100
+ concur_exprs_index_pred | 1 | -1
+ concur_exprs_index_pred_2 | 1 | -1
(3 rows)
DROP TABLE concur_exprs_tab;
diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out
index 4407a017a9..0d93f2c5bb 100644
--- a/src/test/regress/expected/create_table.out
+++ b/src/test/regress/expected/create_table.out
@@ -742,8 +742,8 @@ CREATE TABLE parted (
CREATE TABLE part_a PARTITION OF parted FOR VALUES IN ('a');
-- only inherited attributes (never local ones)
SELECT attname, attislocal, attinhcount FROM pg_attribute
- WHERE attrelid = 'part_a'::regclass and attnum > 0
- ORDER BY attnum;
+ WHERE attrelid = 'part_a'::regclass and attphysnum > 0
+ ORDER BY attphysnum;
attname | attislocal | attinhcount
---------+------------+-------------
a | f | 1
diff --git a/src/test/regress/expected/create_type.out b/src/test/regress/expected/create_type.out
index 0dfc88c1c8..53b998b33f 100644
--- a/src/test/regress/expected/create_type.out
+++ b/src/test/regress/expected/create_type.out
@@ -214,7 +214,7 @@ LINE 1: CREATE TEMP TABLE mytab (foo widget(42,13,7));
^
CREATE TEMP TABLE mytab (foo widget(42,13));
SELECT format_type(atttypid,atttypmod) FROM pg_attribute
-WHERE attrelid = 'mytab'::regclass AND attnum > 0;
+WHERE attrelid = 'mytab'::regclass AND attphysnum > 0;
format_type
---------------
widget(42,13)
diff --git a/src/test/regress/expected/foreign_key.out b/src/test/regress/expected/foreign_key.out
index da26f083bc..584630b8a7 100644
--- a/src/test/regress/expected/foreign_key.out
+++ b/src/test/regress/expected/foreign_key.out
@@ -1466,7 +1466,7 @@ explain (costs off) delete from t1 where a = 1;
(10 rows)
delete from t1 where a = 1;
--- Test a primary key with attributes located in later attnum positions
+-- Test a primary key with attributes located in later attphysnum positions
-- compared to the fk attributes.
create table pktable2 (a int, b int, c int, d int, e int, primary key (d, e));
create table fktable2 (d int, e int, foreign key (d, e) references pktable2);
diff --git a/src/test/regress/expected/indexing.out b/src/test/regress/expected/indexing.out
index 193f780191..d0d117a5c7 100644
--- a/src/test/regress/expected/indexing.out
+++ b/src/test/regress/expected/indexing.out
@@ -815,18 +815,18 @@ Partition of: idxpart FOR VALUES FROM (0) TO (1000)
Indexes:
"idxpart1_col_keep_idx" btree (col_keep)
-select attrelid::regclass, attname, attnum from pg_attribute
- where attrelid::regclass::text like 'idxpart%' and attnum > 0
- order by attrelid::regclass, attnum;
- attrelid | attname | attnum
------------------------+------------------------------+--------
- idxpart1 | ........pg.dropped.1........ | 1
- idxpart1 | ........pg.dropped.2........ | 2
- idxpart1 | col_keep | 3
- idxpart1 | ........pg.dropped.4........ | 4
- idxpart1_col_keep_idx | col_keep | 1
- idxpart | col_keep | 1
- idxpart_col_keep_idx | col_keep | 1
+select attrelid::regclass, attname, attphysnum from pg_attribute
+ where attrelid::regclass::text like 'idxpart%' and attphysnum > 0
+ order by attrelid::regclass, attphysnum;
+ attrelid | attname | attphysnum
+-----------------------+------------------------------+------------
+ idxpart1 | ........pg.dropped.1........ | 1
+ idxpart1 | ........pg.dropped.2........ | 2
+ idxpart1 | col_keep | 3
+ idxpart1 | ........pg.dropped.4........ | 4
+ idxpart1_col_keep_idx | col_keep | 1
+ idxpart | col_keep | 1
+ idxpart_col_keep_idx | col_keep | 1
(7 rows)
drop table idxpart;
@@ -858,18 +858,18 @@ Partition of: idxpart FOR VALUES FROM (0) TO (1000)
Indexes:
"idxpart1_col_keep_idx" btree (col_keep)
-select attrelid::regclass, attname, attnum from pg_attribute
- where attrelid::regclass::text like 'idxpart%' and attnum > 0
- order by attrelid::regclass, attnum;
- attrelid | attname | attnum
------------------------+------------------------------+--------
- idxpart | ........pg.dropped.1........ | 1
- idxpart | ........pg.dropped.2........ | 2
- idxpart | col_keep | 3
- idxpart | ........pg.dropped.4........ | 4
- idxpart1 | col_keep | 1
- idxpart1_col_keep_idx | col_keep | 1
- idxpart_col_keep_idx | col_keep | 1
+select attrelid::regclass, attname, attphysnum from pg_attribute
+ where attrelid::regclass::text like 'idxpart%' and attphysnum > 0
+ order by attrelid::regclass, attphysnum;
+ attrelid | attname | attphysnum
+-----------------------+------------------------------+------------
+ idxpart | ........pg.dropped.1........ | 1
+ idxpart | ........pg.dropped.2........ | 2
+ idxpart | col_keep | 3
+ idxpart | ........pg.dropped.4........ | 4
+ idxpart1 | col_keep | 1
+ idxpart1_col_keep_idx | col_keep | 1
+ idxpart_col_keep_idx | col_keep | 1
(7 rows)
drop table idxpart;
diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out
index 2d49e765de..84bc012f30 100644
--- a/src/test/regress/expected/inherit.out
+++ b/src/test/regress/expected/inherit.out
@@ -1106,7 +1106,7 @@ SELECT a.attrelid::regclass, a.attname, a.attinhcount, e.expected
FROM (SELECT inhrelid, count(*) AS expected FROM pg_inherits
WHERE inhparent IN (SELECT inhrelid FROM r) GROUP BY inhrelid) e
JOIN pg_attribute a ON e.inhrelid = a.attrelid WHERE NOT attislocal
- ORDER BY a.attrelid::regclass::name, a.attnum;
+ ORDER BY a.attrelid::regclass::name, a.attphysnum;
attrelid | attname | attinhcount | expected
----------+---------+-------------+----------
inht2 | aaaa | 1 | 1
diff --git a/src/test/regress/expected/insert.out b/src/test/regress/expected/insert.out
index dd4354fc7d..491d7ff28e 100644
--- a/src/test/regress/expected/insert.out
+++ b/src/test/regress/expected/insert.out
@@ -497,19 +497,19 @@ alter table mlparted11 drop a;
alter table mlparted11 add a int;
alter table mlparted11 drop a;
alter table mlparted11 add a int not null;
--- attnum for key attribute 'a' is different in mlparted, mlparted1, and mlparted11
-select attrelid::regclass, attname, attnum
+-- attphysnum for key attribute 'a' is different in mlparted, mlparted1, and mlparted11
+select attrelid::regclass, attname, attphysnum
from pg_attribute
where attname = 'a'
and (attrelid = 'mlparted'::regclass
or attrelid = 'mlparted1'::regclass
or attrelid = 'mlparted11'::regclass)
order by attrelid::regclass::text;
- attrelid | attname | attnum
-------------+---------+--------
- mlparted | a | 1
- mlparted1 | a | 2
- mlparted11 | a | 4
+ attrelid | attname | attphysnum
+------------+---------+------------
+ mlparted | a | 1
+ mlparted1 | a | 2
+ mlparted11 | a | 4
(3 rows)
alter table mlparted1 attach partition mlparted11 for values from (2) to (5);
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out
index 2538bd6a79..cab82b3093 100644
--- a/src/test/regress/expected/join.out
+++ b/src/test/regress/expected/join.out
@@ -4944,8 +4944,8 @@ HINT: Perhaps you meant to reference the column "t1.unique1" or the column "t2.
--
select atts.relid::regclass, s.* from pg_stats s join
pg_attribute a on s.attname = a.attname and s.tablename =
- a.attrelid::regclass::text join (select unnest(indkey) attnum,
- indexrelid from pg_index i) atts on atts.attnum = a.attnum where
+ a.attrelid::regclass::text join (select unnest(indkey) attphysnum,
+ indexrelid from pg_index i) atts on atts.attphysnum = a.attphysnum where
schemaname != 'pg_catalog';
ERROR: column atts.relid does not exist
LINE 1: select atts.relid::regclass, s.* from pg_stats s join
diff --git a/src/test/regress/expected/oidjoins.out b/src/test/regress/expected/oidjoins.out
index 215eb899be..5acd051618 100644
--- a/src/test/regress/expected/oidjoins.out
+++ b/src/test/regress/expected/oidjoins.out
@@ -83,7 +83,7 @@ NOTICE: checking pg_class {reltablespace} => pg_tablespace {oid}
NOTICE: checking pg_class {reltoastrelid} => pg_class {oid}
NOTICE: checking pg_class {relrewrite} => pg_class {oid}
NOTICE: checking pg_attrdef {adrelid} => pg_class {oid}
-NOTICE: checking pg_attrdef {adrelid,adnum} => pg_attribute {attrelid,attnum}
+NOTICE: checking pg_attrdef {adrelid,adnum} => pg_attribute {attrelid,attphysnum}
NOTICE: checking pg_constraint {connamespace} => pg_namespace {oid}
NOTICE: checking pg_constraint {conrelid} => pg_class {oid}
NOTICE: checking pg_constraint {contypid} => pg_type {oid}
@@ -94,15 +94,15 @@ NOTICE: checking pg_constraint {conpfeqop} => pg_operator {oid}
NOTICE: checking pg_constraint {conppeqop} => pg_operator {oid}
NOTICE: checking pg_constraint {conffeqop} => pg_operator {oid}
NOTICE: checking pg_constraint {conexclop} => pg_operator {oid}
-NOTICE: checking pg_constraint {conrelid,conkey} => pg_attribute {attrelid,attnum}
-NOTICE: checking pg_constraint {confrelid,confkey} => pg_attribute {attrelid,attnum}
+NOTICE: checking pg_constraint {conrelid,conkey} => pg_attribute {attrelid,attphysnum}
+NOTICE: checking pg_constraint {confrelid,confkey} => pg_attribute {attrelid,attphysnum}
NOTICE: checking pg_inherits {inhrelid} => pg_class {oid}
NOTICE: checking pg_inherits {inhparent} => pg_class {oid}
NOTICE: checking pg_index {indexrelid} => pg_class {oid}
NOTICE: checking pg_index {indrelid} => pg_class {oid}
NOTICE: checking pg_index {indcollation} => pg_collation {oid}
NOTICE: checking pg_index {indclass} => pg_opclass {oid}
-NOTICE: checking pg_index {indrelid,indkey} => pg_attribute {attrelid,attnum}
+NOTICE: checking pg_index {indrelid,indkey} => pg_attribute {attrelid,attphysnum}
NOTICE: checking pg_operator {oprnamespace} => pg_namespace {oid}
NOTICE: checking pg_operator {oprowner} => pg_authid {oid}
NOTICE: checking pg_operator {oprleft} => pg_type {oid}
@@ -162,11 +162,11 @@ NOTICE: checking pg_statistic {stacoll2} => pg_collation {oid}
NOTICE: checking pg_statistic {stacoll3} => pg_collation {oid}
NOTICE: checking pg_statistic {stacoll4} => pg_collation {oid}
NOTICE: checking pg_statistic {stacoll5} => pg_collation {oid}
-NOTICE: checking pg_statistic {starelid,staattnum} => pg_attribute {attrelid,attnum}
+NOTICE: checking pg_statistic {starelid,staattnum} => pg_attribute {attrelid,attphysnum}
NOTICE: checking pg_statistic_ext {stxrelid} => pg_class {oid}
NOTICE: checking pg_statistic_ext {stxnamespace} => pg_namespace {oid}
NOTICE: checking pg_statistic_ext {stxowner} => pg_authid {oid}
-NOTICE: checking pg_statistic_ext {stxrelid,stxkeys} => pg_attribute {attrelid,attnum}
+NOTICE: checking pg_statistic_ext {stxrelid,stxkeys} => pg_attribute {attrelid,attphysnum}
NOTICE: checking pg_statistic_ext_data {stxoid} => pg_statistic_ext {oid}
NOTICE: checking pg_rewrite {ev_class} => pg_class {oid}
NOTICE: checking pg_trigger {tgrelid} => pg_class {oid}
@@ -175,7 +175,7 @@ NOTICE: checking pg_trigger {tgfoid} => pg_proc {oid}
NOTICE: checking pg_trigger {tgconstrrelid} => pg_class {oid}
NOTICE: checking pg_trigger {tgconstrindid} => pg_class {oid}
NOTICE: checking pg_trigger {tgconstraint} => pg_constraint {oid}
-NOTICE: checking pg_trigger {tgrelid,tgattr} => pg_attribute {attrelid,attnum}
+NOTICE: checking pg_trigger {tgrelid,tgattr} => pg_attribute {attrelid,attphysnum}
NOTICE: checking pg_event_trigger {evtowner} => pg_authid {oid}
NOTICE: checking pg_event_trigger {evtfoid} => pg_proc {oid}
NOTICE: checking pg_description {classoid} => pg_class {oid}
@@ -243,7 +243,7 @@ NOTICE: checking pg_partitioned_table {partrelid} => pg_class {oid}
NOTICE: checking pg_partitioned_table {partdefid} => pg_class {oid}
NOTICE: checking pg_partitioned_table {partclass} => pg_opclass {oid}
NOTICE: checking pg_partitioned_table {partcollation} => pg_collation {oid}
-NOTICE: checking pg_partitioned_table {partrelid,partattrs} => pg_attribute {attrelid,attnum}
+NOTICE: checking pg_partitioned_table {partrelid,partattrs} => pg_attribute {attrelid,attphysnum}
NOTICE: checking pg_range {rngtypid} => pg_type {oid}
NOTICE: checking pg_range {rngsubtype} => pg_type {oid}
NOTICE: checking pg_range {rngmultitypid} => pg_type {oid}
diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out
index 86d755aa44..12e883ff79 100644
--- a/src/test/regress/expected/opr_sanity.out
+++ b/src/test/regress/expected/opr_sanity.out
@@ -2216,7 +2216,7 @@ FROM (SELECT indexrelid, indrelid, unnest(indkey) as ikey,
FROM pg_index) ss,
pg_attribute a,
pg_opclass opc
-WHERE a.attrelid = indrelid AND a.attnum = ikey AND opc.oid = iclass AND
+WHERE a.attrelid = indrelid AND a.attphysnum = ikey AND opc.oid = iclass AND
(NOT binary_coercible(atttypid, opcintype) OR icoll != attcollation);
indexrelid | indrelid | attname | atttypid | opcname
------------+----------+---------+----------+---------
@@ -2232,7 +2232,7 @@ FROM (SELECT indexrelid, indrelid, unnest(indkey) as ikey,
WHERE indrelid < 16384) ss,
pg_attribute a,
pg_opclass opc
-WHERE a.attrelid = indrelid AND a.attnum = ikey AND opc.oid = iclass AND
+WHERE a.attrelid = indrelid AND a.attphysnum = ikey AND opc.oid = iclass AND
(opcintype != atttypid OR icoll != attcollation)
ORDER BY 1;
indexrelid | indrelid | attname | atttypid | opcname
diff --git a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out
index 60acbd1241..195fa9f287 100644
--- a/src/test/regress/expected/psql.out
+++ b/src/test/regress/expected/psql.out
@@ -241,8 +241,8 @@ SELECT 3 AS x, 'Hello', 4 AS y, true AS "dirty\name" \gdesc \g
create temporary table gexec_test(a int, b text, c date, d float);
select format('create index on gexec_test(%I)', attname)
from pg_attribute
-where attrelid = 'gexec_test'::regclass and attnum > 0
-order by attnum
+where attrelid = 'gexec_test'::regclass and attphysnum > 0
+order by attphysnum
\gexec
create index on gexec_test(a)
create index on gexec_test(b)
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index fc3cde3226..fcf522dad8 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -1438,14 +1438,14 @@ pg_prepared_xacts| SELECT p.transaction,
pg_publication_tables| SELECT p.pubname,
n.nspname AS schemaname,
c.relname AS tablename,
- ( SELECT array_agg(a.attname ORDER BY a.attnum) AS array_agg
+ ( SELECT array_agg(a.attname ORDER BY a.attphysnum) AS array_agg
FROM (unnest(
CASE
WHEN (gpt.attrs IS NOT NULL) THEN (gpt.attrs)::integer[]
ELSE ( SELECT array_agg(g.g) AS array_agg
FROM generate_series(1, (c.relnatts)::integer) g(g))
END) k(k)
- JOIN pg_attribute a ON (((a.attrelid = gpt.relid) AND (a.attnum = k.k))))) AS attnames,
+ JOIN pg_attribute a ON (((a.attrelid = gpt.relid) AND (a.attphysnum = k.k))))) AS attnames,
pg_get_expr(gpt.qual, gpt.relid) AS rowfilter
FROM pg_publication p,
LATERAL pg_get_publication_tables((p.pubname)::text) gpt(relid, attrs, qual),
@@ -1534,7 +1534,7 @@ UNION ALL
l.label
FROM (((pg_seclabel l
JOIN pg_class rel ON (((l.classoid = rel.tableoid) AND (l.objoid = rel.oid))))
- JOIN pg_attribute att ON (((rel.oid = att.attrelid) AND (l.objsubid = att.attnum))))
+ JOIN pg_attribute att ON (((rel.oid = att.attrelid) AND (l.objsubid = att.attphysnum))))
JOIN pg_namespace nsp ON ((rel.relnamespace = nsp.oid)))
WHERE (l.objsubid <> 0)
UNION ALL
@@ -2428,17 +2428,17 @@ pg_stats| SELECT n.nspname AS schemaname,
END AS elem_count_histogram
FROM (((pg_statistic s
JOIN pg_class c ON ((c.oid = s.starelid)))
- JOIN pg_attribute a ON (((c.oid = a.attrelid) AND (a.attnum = s.staattnum))))
+ JOIN pg_attribute a ON (((c.oid = a.attrelid) AND (a.attphysnum = s.staattnum))))
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
- WHERE ((NOT a.attisdropped) AND has_column_privilege(c.oid, a.attnum, 'select'::text) AND ((c.relrowsecurity = false) OR (NOT row_security_active(c.oid))));
+ WHERE ((NOT a.attisdropped) AND has_column_privilege(c.oid, a.attphysnum, 'select'::text) AND ((c.relrowsecurity = false) OR (NOT row_security_active(c.oid))));
pg_stats_ext| SELECT cn.nspname AS schemaname,
c.relname AS tablename,
sn.nspname AS statistics_schemaname,
s.stxname AS statistics_name,
pg_get_userbyid(s.stxowner) AS statistics_owner,
- ( SELECT array_agg(a.attname ORDER BY a.attnum) AS array_agg
+ ( SELECT array_agg(a.attname ORDER BY a.attphysnum) AS array_agg
FROM (unnest(s.stxkeys) k(k)
- JOIN pg_attribute a ON (((a.attrelid = s.stxrelid) AND (a.attnum = k.k))))) AS attnames,
+ JOIN pg_attribute a ON (((a.attrelid = s.stxrelid) AND (a.attphysnum = k.k))))) AS attnames,
pg_get_statisticsobjdef_expressions(s.oid) AS exprs,
s.stxkind AS kinds,
sd.stxdinherit AS inherited,
@@ -2460,8 +2460,8 @@ pg_stats_ext| SELECT cn.nspname AS schemaname,
FROM pg_mcv_list_items(sd.stxdmcv) pg_mcv_list_items(index, "values", nulls, frequency, base_frequency)) m ON ((sd.stxdmcv IS NOT NULL)))
WHERE ((NOT (EXISTS ( SELECT 1
FROM (unnest(s.stxkeys) k(k)
- JOIN pg_attribute a ON (((a.attrelid = s.stxrelid) AND (a.attnum = k.k))))
- WHERE (NOT has_column_privilege(c.oid, a.attnum, 'select'::text))))) AND ((c.relrowsecurity = false) OR (NOT row_security_active(c.oid))));
+ JOIN pg_attribute a ON (((a.attrelid = s.stxrelid) AND (a.attphysnum = k.k))))
+ WHERE (NOT has_column_privilege(c.oid, a.attphysnum, 'select'::text))))) AND ((c.relrowsecurity = false) OR (NOT row_security_active(c.oid))));
pg_stats_ext_exprs| SELECT cn.nspname AS schemaname,
c.relname AS tablename,
sn.nspname AS statistics_schemaname,
diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out
index c5c675b750..7714c49e2f 100644
--- a/src/test/regress/expected/sanity_check.out
+++ b/src/test/regress/expected/sanity_check.out
@@ -10,7 +10,7 @@ SELECT relname, nspname
WHERE relkind = 'r' and c.oid < 16384
AND ((nspname ~ '^pg_') IS NOT FALSE)
AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid
- AND indkey[0] = a.attnum AND indnatts = 1
+ AND indkey[0] = a.attphysnum AND indnatts = 1
AND indisunique AND indimmediate);
relname | nspname
---------+---------
@@ -39,8 +39,8 @@ WITH check_columns AS (
SELECT t.oid
FROM pg_type t JOIN pg_attribute pa ON t.oid = pa.atttypid
WHERE pa.attrelid = a.attrelid AND
- pa.attnum > 0 AND pa.attnum < a.attnum
- ORDER BY pa.attnum) AS coltypes
+ pa.attphysnum > 0 AND pa.attphysnum < a.attphysnum
+ ORDER BY pa.attphysnum) AS coltypes
FROM pg_attribute a JOIN pg_class c ON c.oid = attrelid
JOIN pg_namespace n ON c.relnamespace = n.oid
WHERE attalign = 'd' AND relkind = 'r' AND
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index d3ac08c9ee..51fcda3e6f 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -578,17 +578,17 @@ WHERE pc.relkind IN ('r', 't', 'm') and
-- Look for illegal values in pg_attribute fields
SELECT a1.attrelid, a1.attname
FROM pg_attribute as a1
-WHERE a1.attrelid = 0 OR a1.atttypid = 0 OR a1.attnum = 0 OR
+WHERE a1.attrelid = 0 OR a1.atttypid = 0 OR a1.attphysnum = 0 OR
a1.attcacheoff != -1 OR a1.attinhcount < 0 OR
(a1.attinhcount = 0 AND NOT a1.attislocal);
attrelid | attname
----------+---------
(0 rows)
--- Cross-check attnum against parent relation
+-- Cross-check attphysnum against parent relation
SELECT a1.attrelid, a1.attname, c1.oid, c1.relname
FROM pg_attribute AS a1, pg_class AS c1
-WHERE a1.attrelid = c1.oid AND a1.attnum > c1.relnatts;
+WHERE a1.attrelid = c1.oid AND a1.attphysnum > c1.relnatts;
attrelid | attname | oid | relname
----------+---------+-----+---------
(0 rows)
@@ -598,7 +598,7 @@ WHERE a1.attrelid = c1.oid AND a1.attnum > c1.relnatts;
SELECT c1.oid, c1.relname
FROM pg_class AS c1
WHERE c1.relnatts != (SELECT count(*) FROM pg_attribute AS a1
- WHERE a1.attrelid = c1.oid AND a1.attnum > 0);
+ WHERE a1.attrelid = c1.oid AND a1.attphysnum > 0);
oid | relname
-----+---------
(0 rows)
@@ -765,7 +765,7 @@ SELECT oid, typname, typtype, typelem, typarray
AND NOT EXISTS (SELECT 1
FROM pg_attribute a
WHERE a.atttypid=t.oid AND
- a.attnum > 0 AND
+ a.attphysnum > 0 AND
a.attrelid='tab_core_types'::regclass);
oid | typname | typtype | typelem | typarray
-----+---------+---------+---------+----------
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index ba3532a51e..f34c8474b4 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -272,7 +272,7 @@ ttdummy(PG_FUNCTION_ARGS)
TriggerData *trigdata = (TriggerData *) fcinfo->context;
Trigger *trigger; /* to get trigger name */
char **args; /* arguments */
- int attnum[2]; /* fnumbers of start/stop columns */
+ int attphysnum[2]; /* fnumbers of start/stop columns */
Datum oldon,
oldoff;
Datum newon,
@@ -325,29 +325,29 @@ ttdummy(PG_FUNCTION_ARGS)
for (i = 0; i < 2; i++)
{
- attnum[i] = SPI_fnumber(tupdesc, args[i]);
- if (attnum[i] <= 0)
+ attphysnum[i] = SPI_fnumber(tupdesc, args[i]);
+ if (attphysnum[i] <= 0)
elog(ERROR, "ttdummy (%s): there is no attribute %s",
relname, args[i]);
- if (SPI_gettypeid(tupdesc, attnum[i]) != INT4OID)
+ if (SPI_gettypeid(tupdesc, attphysnum[i]) != INT4OID)
elog(ERROR, "ttdummy (%s): attribute %s must be of integer type",
relname, args[i]);
}
- oldon = SPI_getbinval(trigtuple, tupdesc, attnum[0], &isnull);
+ oldon = SPI_getbinval(trigtuple, tupdesc, attphysnum[0], &isnull);
if (isnull)
elog(ERROR, "ttdummy (%s): %s must be NOT NULL", relname, args[0]);
- oldoff = SPI_getbinval(trigtuple, tupdesc, attnum[1], &isnull);
+ oldoff = SPI_getbinval(trigtuple, tupdesc, attphysnum[1], &isnull);
if (isnull)
elog(ERROR, "ttdummy (%s): %s must be NOT NULL", relname, args[1]);
if (newtuple != NULL) /* UPDATE */
{
- newon = SPI_getbinval(newtuple, tupdesc, attnum[0], &isnull);
+ newon = SPI_getbinval(newtuple, tupdesc, attphysnum[0], &isnull);
if (isnull)
elog(ERROR, "ttdummy (%s): %s must be NOT NULL", relname, args[0]);
- newoff = SPI_getbinval(newtuple, tupdesc, attnum[1], &isnull);
+ newoff = SPI_getbinval(newtuple, tupdesc, attphysnum[1], &isnull);
if (isnull)
elog(ERROR, "ttdummy (%s): %s must be NOT NULL", relname, args[1]);
@@ -390,16 +390,16 @@ ttdummy(PG_FUNCTION_ARGS)
/* change date column(s) */
if (newtuple) /* UPDATE */
{
- cvals[attnum[0] - 1] = newoff; /* start_date eq current date */
- cnulls[attnum[0] - 1] = ' ';
- cvals[attnum[1] - 1] = TTDUMMY_INFINITY; /* stop_date eq INFINITY */
- cnulls[attnum[1] - 1] = ' ';
+ cvals[attphysnum[0] - 1] = newoff; /* start_date eq current date */
+ cnulls[attphysnum[0] - 1] = ' ';
+ cvals[attphysnum[1] - 1] = TTDUMMY_INFINITY; /* stop_date eq INFINITY */
+ cnulls[attphysnum[1] - 1] = ' ';
}
else
/* DELETE */
{
- cvals[attnum[1] - 1] = newoff; /* stop_date eq current date */
- cnulls[attnum[1] - 1] = ' ';
+ cvals[attphysnum[1] - 1] = newoff; /* stop_date eq current date */
+ cnulls[attphysnum[1] - 1] = ' ';
}
/* if there is no plan ... */
@@ -442,7 +442,7 @@ ttdummy(PG_FUNCTION_ARGS)
/* Tuple to return to upper Executor ... */
if (newtuple) /* UPDATE */
- rettuple = SPI_modifytuple(rel, trigtuple, 1, &(attnum[1]), &newoff, NULL);
+ rettuple = SPI_modifytuple(rel, trigtuple, 1, &(attphysnum[1]), &newoff, NULL);
else /* DELETE */
rettuple = trigtuple;
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql
index 52001e3135..6784da0f4c 100644
--- a/src/test/regress/sql/alter_table.sql
+++ b/src/test/regress/sql/alter_table.sql
@@ -1250,8 +1250,8 @@ create table gc1() inherits (c1);
select relname, attname, attinhcount, attislocal
from pg_class join pg_attribute on (pg_class.oid = pg_attribute.attrelid)
-where relname in ('p1','p2','c1','gc1') and attnum > 0 and not attisdropped
-order by relname, attnum;
+where relname in ('p1','p2','c1','gc1') and attphysnum > 0 and not attisdropped
+order by relname, attphysnum;
-- should work
alter table only p1 drop column name;
@@ -1273,8 +1273,8 @@ alter table dropColumnExists drop column if exists non_existing; --succeed
select relname, attname, attinhcount, attislocal
from pg_class join pg_attribute on (pg_class.oid = pg_attribute.attrelid)
-where relname in ('p1','p2','c1','gc1') and attnum > 0 and not attisdropped
-order by relname, attnum;
+where relname in ('p1','p2','c1','gc1') and attphysnum > 0 and not attisdropped
+order by relname, attphysnum;
drop table p1, p2 cascade;
@@ -1287,8 +1287,8 @@ alter table depth0 add c text;
select attrelid::regclass, attname, attinhcount, attislocal
from pg_attribute
-where attnum > 0 and attrelid::regclass in ('depth0', 'depth1', 'depth2')
-order by attrelid::regclass::text, attnum;
+where attphysnum > 0 and attrelid::regclass in ('depth0', 'depth1', 'depth2')
+order by attrelid::regclass::text, attphysnum;
-- test renumbering of child-table columns in inherited operations
@@ -2434,7 +2434,7 @@ CREATE TABLE part_1 (
);
ALTER TABLE list_parted ATTACH PARTITION part_1 FOR VALUES IN (1);
-- attislocal and conislocal are always false for merged attributes and constraints respectively.
-SELECT attislocal, attinhcount FROM pg_attribute WHERE attrelid = 'part_1'::regclass AND attnum > 0;
+SELECT attislocal, attinhcount FROM pg_attribute WHERE attrelid = 'part_1'::regclass AND attphysnum > 0;
SELECT conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_1'::regclass AND conname = 'check_a';
-- check that the new partition won't overlap with an existing partition
@@ -2580,7 +2580,7 @@ CREATE TABLE part_7_a_null (
c int,
d int,
e int,
- LIKE list_parted2, -- 'a' will have attnum = 4
+ LIKE list_parted2, -- 'a' will have attphysnum = 4
CONSTRAINT check_b CHECK (b IS NULL OR b = 'a'),
CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 7)
);
@@ -2707,7 +2707,7 @@ DROP TABLE not_a_part;
-- check that, after being detached, attinhcount/coninhcount is dropped to 0 and
-- attislocal/conislocal is set to true
ALTER TABLE list_parted2 DETACH PARTITION part_3_4;
-SELECT attinhcount, attislocal FROM pg_attribute WHERE attrelid = 'part_3_4'::regclass AND attnum > 0;
+SELECT attinhcount, attislocal FROM pg_attribute WHERE attrelid = 'part_3_4'::regclass AND attphysnum > 0;
SELECT coninhcount, conislocal FROM pg_constraint WHERE conrelid = 'part_3_4'::regclass AND conname = 'check_a';
DROP TABLE part_3_4;
@@ -2816,8 +2816,8 @@ alter table p11 drop a;
alter table p11 add a int;
alter table p11 drop a;
alter table p11 add a int not null;
--- attnum for key attribute 'a' is different in p, p1, and p11
-select attrelid::regclass, attname, attnum
+-- attphysnum for key attribute 'a' is different in p, p1, and p11
+select attrelid::regclass, attname, attphysnum
from pg_attribute
where attname = 'a'
and (attrelid = 'p'::regclass
diff --git a/src/test/regress/sql/create_index.sql b/src/test/regress/sql/create_index.sql
index d8fded3d93..c2b0f58c6b 100644
--- a/src/test/regress/sql/create_index.sql
+++ b/src/test/regress/sql/create_index.sql
@@ -1140,12 +1140,12 @@ SELECT starelid::regclass, count(*) FROM pg_statistic WHERE starelid IN (
'concur_exprs_index_pred_2'::regclass)
GROUP BY starelid ORDER BY starelid::regclass::text;
-- attstattarget should remain intact
-SELECT attrelid::regclass, attnum, attstattarget
+SELECT attrelid::regclass, attphysnum, attstattarget
FROM pg_attribute WHERE attrelid IN (
'concur_exprs_index_expr'::regclass,
'concur_exprs_index_pred'::regclass,
'concur_exprs_index_pred_2'::regclass)
- ORDER BY attrelid::regclass::text, attnum;
+ ORDER BY attrelid::regclass::text, attphysnum;
DROP TABLE concur_exprs_tab;
-- Temporary tables and on-commit actions, where CONCURRENTLY is ignored.
diff --git a/src/test/regress/sql/create_table.sql b/src/test/regress/sql/create_table.sql
index 5175f404f7..b1d935c0fe 100644
--- a/src/test/regress/sql/create_table.sql
+++ b/src/test/regress/sql/create_table.sql
@@ -513,8 +513,8 @@ CREATE TABLE part_a PARTITION OF parted FOR VALUES IN ('a');
-- only inherited attributes (never local ones)
SELECT attname, attislocal, attinhcount FROM pg_attribute
- WHERE attrelid = 'part_a'::regclass and attnum > 0
- ORDER BY attnum;
+ WHERE attrelid = 'part_a'::regclass and attphysnum > 0
+ ORDER BY attphysnum;
-- able to specify column default, column constraint, and table constraint
diff --git a/src/test/regress/sql/create_type.sql b/src/test/regress/sql/create_type.sql
index c6fc4f9029..017484ec65 100644
--- a/src/test/regress/sql/create_type.sql
+++ b/src/test/regress/sql/create_type.sql
@@ -180,7 +180,7 @@ CREATE TEMP TABLE mytab (foo widget(42,13,7)); -- should fail
CREATE TEMP TABLE mytab (foo widget(42,13));
SELECT format_type(atttypid,atttypmod) FROM pg_attribute
-WHERE attrelid = 'mytab'::regclass AND attnum > 0;
+WHERE attrelid = 'mytab'::regclass AND attphysnum > 0;
-- might as well exercise the widget type while we're here
INSERT INTO mytab VALUES ('(1,2,3)'), ('(-44,5.5,12)');
diff --git a/src/test/regress/sql/foreign_key.sql b/src/test/regress/sql/foreign_key.sql
index 725a59a525..6a1118098a 100644
--- a/src/test/regress/sql/foreign_key.sql
+++ b/src/test/regress/sql/foreign_key.sql
@@ -1087,7 +1087,7 @@ create rule r1 as on delete to t1 do delete from t2 where t2.b = old.a;
explain (costs off) delete from t1 where a = 1;
delete from t1 where a = 1;
--- Test a primary key with attributes located in later attnum positions
+-- Test a primary key with attributes located in later attphysnum positions
-- compared to the fk attributes.
create table pktable2 (a int, b int, c int, d int, e int, primary key (d, e));
create table fktable2 (d int, e int, foreign key (d, e) references pktable2);
diff --git a/src/test/regress/sql/indexing.sql b/src/test/regress/sql/indexing.sql
index 42f398b67c..5370452cb2 100644
--- a/src/test/regress/sql/indexing.sql
+++ b/src/test/regress/sql/indexing.sql
@@ -423,9 +423,9 @@ create index on idxpart (col_keep);
alter table idxpart attach partition idxpart1 for values from (0) to (1000);
\d idxpart
\d idxpart1
-select attrelid::regclass, attname, attnum from pg_attribute
- where attrelid::regclass::text like 'idxpart%' and attnum > 0
- order by attrelid::regclass, attnum;
+select attrelid::regclass, attname, attphysnum from pg_attribute
+ where attrelid::regclass::text like 'idxpart%' and attphysnum > 0
+ order by attrelid::regclass, attphysnum;
drop table idxpart;
-- Column number mapping: dropped columns in the parent table
@@ -439,9 +439,9 @@ create index on idxpart (col_keep);
alter table idxpart attach partition idxpart1 for values from (0) to (1000);
\d idxpart
\d idxpart1
-select attrelid::regclass, attname, attnum from pg_attribute
- where attrelid::regclass::text like 'idxpart%' and attnum > 0
- order by attrelid::regclass, attnum;
+select attrelid::regclass, attname, attphysnum from pg_attribute
+ where attrelid::regclass::text like 'idxpart%' and attphysnum > 0
+ order by attrelid::regclass, attphysnum;
drop table idxpart;
--
diff --git a/src/test/regress/sql/inherit.sql b/src/test/regress/sql/inherit.sql
index 195aedb5ff..8075f622b6 100644
--- a/src/test/regress/sql/inherit.sql
+++ b/src/test/regress/sql/inherit.sql
@@ -375,7 +375,7 @@ SELECT a.attrelid::regclass, a.attname, a.attinhcount, e.expected
FROM (SELECT inhrelid, count(*) AS expected FROM pg_inherits
WHERE inhparent IN (SELECT inhrelid FROM r) GROUP BY inhrelid) e
JOIN pg_attribute a ON e.inhrelid = a.attrelid WHERE NOT attislocal
- ORDER BY a.attrelid::regclass::name, a.attnum;
+ ORDER BY a.attrelid::regclass::name, a.attphysnum;
DROP TABLE inht1, inhs1 CASCADE;
diff --git a/src/test/regress/sql/insert.sql b/src/test/regress/sql/insert.sql
index bdcffd0314..5ca1483716 100644
--- a/src/test/regress/sql/insert.sql
+++ b/src/test/regress/sql/insert.sql
@@ -299,8 +299,8 @@ alter table mlparted11 drop a;
alter table mlparted11 add a int;
alter table mlparted11 drop a;
alter table mlparted11 add a int not null;
--- attnum for key attribute 'a' is different in mlparted, mlparted1, and mlparted11
-select attrelid::regclass, attname, attnum
+-- attphysnum for key attribute 'a' is different in mlparted, mlparted1, and mlparted11
+select attrelid::regclass, attname, attphysnum
from pg_attribute
where attname = 'a'
and (attrelid = 'mlparted'::regclass
diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql
index a27a72086e..397f2add63 100644
--- a/src/test/regress/sql/join.sql
+++ b/src/test/regress/sql/join.sql
@@ -1770,8 +1770,8 @@ select uunique1 from
select atts.relid::regclass, s.* from pg_stats s join
pg_attribute a on s.attname = a.attname and s.tablename =
- a.attrelid::regclass::text join (select unnest(indkey) attnum,
- indexrelid from pg_index i) atts on atts.attnum = a.attnum where
+ a.attrelid::regclass::text join (select unnest(indkey) attphysnum,
+ indexrelid from pg_index i) atts on atts.attphysnum = a.attphysnum where
schemaname != 'pg_catalog';
--
diff --git a/src/test/regress/sql/opr_sanity.sql b/src/test/regress/sql/opr_sanity.sql
index 63fe114fed..5aae345792 100644
--- a/src/test/regress/sql/opr_sanity.sql
+++ b/src/test/regress/sql/opr_sanity.sql
@@ -1353,7 +1353,7 @@ FROM (SELECT indexrelid, indrelid, unnest(indkey) as ikey,
FROM pg_index) ss,
pg_attribute a,
pg_opclass opc
-WHERE a.attrelid = indrelid AND a.attnum = ikey AND opc.oid = iclass AND
+WHERE a.attrelid = indrelid AND a.attphysnum = ikey AND opc.oid = iclass AND
(NOT binary_coercible(atttypid, opcintype) OR icoll != attcollation);
-- For system catalogs, be even tighter: nearly all indexes should be
@@ -1367,7 +1367,7 @@ FROM (SELECT indexrelid, indrelid, unnest(indkey) as ikey,
WHERE indrelid < 16384) ss,
pg_attribute a,
pg_opclass opc
-WHERE a.attrelid = indrelid AND a.attnum = ikey AND opc.oid = iclass AND
+WHERE a.attrelid = indrelid AND a.attphysnum = ikey AND opc.oid = iclass AND
(opcintype != atttypid OR icoll != attcollation)
ORDER BY 1;
diff --git a/src/test/regress/sql/psql.sql b/src/test/regress/sql/psql.sql
index 1149c6a839..4fcb86d67c 100644
--- a/src/test/regress/sql/psql.sql
+++ b/src/test/regress/sql/psql.sql
@@ -124,8 +124,8 @@ SELECT 3 AS x, 'Hello', 4 AS y, true AS "dirty\name" \gdesc \g
create temporary table gexec_test(a int, b text, c date, d float);
select format('create index on gexec_test(%I)', attname)
from pg_attribute
-where attrelid = 'gexec_test'::regclass and attnum > 0
-order by attnum
+where attrelid = 'gexec_test'::regclass and attphysnum > 0
+order by attphysnum
\gexec
-- \gexec should work in FETCH_COUNT mode too
diff --git a/src/test/regress/sql/sanity_check.sql b/src/test/regress/sql/sanity_check.sql
index 7f338d191c..67d6b076b7 100644
--- a/src/test/regress/sql/sanity_check.sql
+++ b/src/test/regress/sql/sanity_check.sql
@@ -11,7 +11,7 @@ SELECT relname, nspname
WHERE relkind = 'r' and c.oid < 16384
AND ((nspname ~ '^pg_') IS NOT FALSE)
AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid
- AND indkey[0] = a.attnum AND indnatts = 1
+ AND indkey[0] = a.attphysnum AND indnatts = 1
AND indisunique AND indimmediate);
-- check that relations without storage don't have relfilenode
@@ -34,8 +34,8 @@ WITH check_columns AS (
SELECT t.oid
FROM pg_type t JOIN pg_attribute pa ON t.oid = pa.atttypid
WHERE pa.attrelid = a.attrelid AND
- pa.attnum > 0 AND pa.attnum < a.attnum
- ORDER BY pa.attnum) AS coltypes
+ pa.attphysnum > 0 AND pa.attphysnum < a.attphysnum
+ ORDER BY pa.attphysnum) AS coltypes
FROM pg_attribute a JOIN pg_class c ON c.oid = attrelid
JOIN pg_namespace n ON c.relnamespace = n.oid
WHERE attalign = 'd' AND relkind = 'r' AND
diff --git a/src/test/regress/sql/type_sanity.sql b/src/test/regress/sql/type_sanity.sql
index 5edc1f1f6e..fedd8790ac 100644
--- a/src/test/regress/sql/type_sanity.sql
+++ b/src/test/regress/sql/type_sanity.sql
@@ -420,15 +420,15 @@ WHERE pc.relkind IN ('r', 't', 'm') and
SELECT a1.attrelid, a1.attname
FROM pg_attribute as a1
-WHERE a1.attrelid = 0 OR a1.atttypid = 0 OR a1.attnum = 0 OR
+WHERE a1.attrelid = 0 OR a1.atttypid = 0 OR a1.attphysnum = 0 OR
a1.attcacheoff != -1 OR a1.attinhcount < 0 OR
(a1.attinhcount = 0 AND NOT a1.attislocal);
--- Cross-check attnum against parent relation
+-- Cross-check attphysnum against parent relation
SELECT a1.attrelid, a1.attname, c1.oid, c1.relname
FROM pg_attribute AS a1, pg_class AS c1
-WHERE a1.attrelid = c1.oid AND a1.attnum > c1.relnatts;
+WHERE a1.attrelid = c1.oid AND a1.attphysnum > c1.relnatts;
-- Detect missing pg_attribute entries: should have as many non-system
-- attributes as parent relation expects
@@ -436,7 +436,7 @@ WHERE a1.attrelid = c1.oid AND a1.attnum > c1.relnatts;
SELECT c1.oid, c1.relname
FROM pg_class AS c1
WHERE c1.relnatts != (SELECT count(*) FROM pg_attribute AS a1
- WHERE a1.attrelid = c1.oid AND a1.attnum > 0);
+ WHERE a1.attrelid = c1.oid AND a1.attphysnum > 0);
-- Cross-check against pg_type entry
-- NOTE: we allow attstorage to be 'plain' even when typstorage is not;
@@ -588,5 +588,5 @@ SELECT oid, typname, typtype, typelem, typarray
AND NOT EXISTS (SELECT 1
FROM pg_attribute a
WHERE a.atttypid=t.oid AND
- a.attnum > 0 AND
+ a.attphysnum > 0 AND
a.attrelid='tab_core_types'::regclass);
diff --git a/src/tutorial/syscat.source b/src/tutorial/syscat.source
index 6458c32372..9aa7a6e999 100644
--- a/src/tutorial/syscat.source
+++ b/src/tutorial/syscat.source
@@ -57,7 +57,7 @@ SELECT n.nspname AS schema_name,
WHERE bc.relnamespace = n.oid
and i.indrelid = bc.oid
and i.indexrelid = ic.oid
- and i.indkey[0] = a.attnum
+ and i.indkey[0] = a.attphysnum
and i.indnatts = 1
and a.attrelid = bc.oid
ORDER BY schema_name, class_name, index_name, attname;
@@ -74,7 +74,7 @@ SELECT n.nspname, c.relname, a.attname, format_type(t.oid, null) as typname
and c.relkind = 'r' -- no indices
and n.nspname not like 'pg\_%' -- no catalogs
and n.nspname != 'information_schema' -- no information_schema
- and a.attnum > 0 -- no system att's
+ and a.attphysnum > 0 -- no system att's
and not a.attisdropped -- no dropped columns
and a.attrelid = c.oid
and a.atttypid = t.oid
--
2.33.1
v1-0002-WIP-Handle-logical-attnum.patchtext/plain; charset=us-asciiDownload
From 4d1cc1fc3c6c7ed13418bee9032825b488650151 Mon Sep 17 00:00:00 2001
From: Julien Rouhaud <julien.rouhaud@free.fr>
Date: Sat, 4 Jun 2022 03:07:47 +0800
Subject: [PATCH v1 2/5] WIP Handle logical attnum
A new attnum column is added to pg_attribute, to store the logical column
position. The default is to have the same as the physical position.
A relation is now expanded in logical order, for instance:
- A plain SELECT * FROM table
- A RETURNING * clause in a DML command
- A COPY table FROM/TO without explicit column names
Note that there's for now no possibility to declare a different logical
position.
psql displays a table columns information using the logical order rather the
physical order, and if verbose emits an addition "Physical order" footer if the
logical layout is different from the physical one.
Many problems that still exist, for instance deparsing view that didn't have
explicit column list and later requires it (e.g. after renaming attributes).
Author: Julien Rouhaud
Reviewed-by: FIXME
Discussion: FIXME
---
src/backend/access/common/attmap.c | 5 +-
src/backend/access/common/tupconvert.c | 7 +-
src/backend/access/common/tupdesc.c | 43 +++++++++++
src/backend/bootstrap/bootstrap.c | 1 +
src/backend/catalog/genbki.pl | 2 +
src/backend/catalog/heap.c | 8 ++
src/backend/catalog/index.c | 1 +
src/backend/commands/copy.c | 48 ++++++++++--
src/backend/commands/tablecmds.c | 11 ++-
src/backend/nodes/copyfuncs.c | 2 +
src/backend/nodes/equalfuncs.c | 1 +
src/backend/nodes/outfuncs.c | 2 +
src/backend/nodes/readfuncs.c | 2 +
src/backend/optimizer/util/plancat.c | 2 +
src/backend/optimizer/util/tlist.c | 43 +++++++++++
src/backend/parser/analyze.c | 2 +-
src/backend/parser/parse_clause.c | 1 +
src/backend/parser/parse_relation.c | 100 ++++++++++++++++++++-----
src/backend/parser/parse_target.c | 100 ++++++++++++++++++-------
src/backend/parser/parse_utilcmd.c | 9 ++-
src/backend/utils/cache/relcache.c | 5 +-
src/bin/psql/describe.c | 71 +++++++++++++++---
src/include/access/tupdesc.h | 2 +
src/include/catalog/pg_attribute.h | 6 ++
src/include/nodes/primnodes.h | 4 +-
src/include/optimizer/tlist.h | 1 +
src/include/parser/parse_node.h | 3 +-
src/include/parser/parse_relation.h | 2 +-
src/test/regress/regress.c | 17 ++++-
29 files changed, 424 insertions(+), 77 deletions(-)
diff --git a/src/backend/access/common/attmap.c b/src/backend/access/common/attmap.c
index d84b1bcdc4..f323b4a72e 100644
--- a/src/backend/access/common/attmap.c
+++ b/src/backend/access/common/attmap.c
@@ -100,6 +100,7 @@ build_attrmap_by_position(TupleDesc indesc,
Form_pg_attribute att = TupleDescAttr(outdesc, i);
Oid atttypid;
int32 atttypmod;
+ AttrNumber attphysnum = att->attphysnum;
if (att->attisdropped)
continue; /* attrMap->attnums[i] is already 0 */
@@ -125,11 +126,11 @@ build_attrmap_by_position(TupleDesc indesc,
format_type_with_typemod(atttypid,
atttypmod),
noutcols)));
- attrMap->attnums[i] = (AttrNumber) (j + 1);
+ attrMap->attnums[attphysnum - 1] = (AttrNumber) (j + 1);
j++;
break;
}
- if (attrMap->attnums[i] == 0)
+ if (attrMap->attnums[attphysnum - 1] == 0)
same = false; /* we'll complain below */
}
diff --git a/src/backend/access/common/tupconvert.c b/src/backend/access/common/tupconvert.c
index 4010e20cfb..68d05f343a 100644
--- a/src/backend/access/common/tupconvert.c
+++ b/src/backend/access/common/tupconvert.c
@@ -60,12 +60,15 @@ convert_tuples_by_position(TupleDesc indesc,
TupleDesc outdesc,
const char *msg)
{
+ TupleDesc sorted_outdesc = CreateTupleDescCopy(outdesc);
TupleConversionMap *map;
int n;
AttrMap *attrMap;
- /* Verify compatibility and prepare attribute-number map */
- attrMap = build_attrmap_by_position(indesc, outdesc, msg);
+ /* Verify compatibility and prepare attribute-number map. */
+ TupleDescSortByAttnum(sorted_outdesc);
+ attrMap = build_attrmap_by_position(indesc, sorted_outdesc, msg);
+ pfree(sorted_outdesc);
if (attrMap == NULL)
{
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index 409a93ccdf..e9f9afbd0c 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -128,6 +128,9 @@ CreateTupleDescCopy(TupleDesc tupdesc)
{
Form_pg_attribute att = TupleDescAttr(desc, i);
+ /* Caller should have provided it */
+ Assert(AttributeNumberIsValid(att->attnum));
+
att->attnotnull = false;
att->atthasdef = false;
att->atthasmissing = false;
@@ -285,6 +288,8 @@ TupleDescCopyEntry(TupleDesc dst, AttrNumber dstAttno,
/*
* Aside from updating the attno, we'd better reset attcacheoff.
*
+ * The attnum should however be preserved.
+ *
* XXX Actually, to be entirely safe we'd need to reset the attcacheoff of
* all following columns in dst as well. Current usage scenarios don't
* require that though, because all following columns will get initialized
@@ -620,6 +625,8 @@ TupleDescInitEntry(TupleDesc desc,
att->atttypmod = typmod;
att->attphysnum = attributeNumber;
+ /* FIXME should we put 0 and let caller always set it as needed? */
+ att->attnum = attributeNumber;
att->attndims = attdim;
att->attnotnull = false;
@@ -765,6 +772,40 @@ TupleDescInitEntryCollation(TupleDesc desc,
TupleDescAttr(desc, attributeNumber - 1)->attcollation = collationid;
}
+/*
+ * cmp_attnum
+ *
+ * Comparator for sorting TupleDesc attributes by they logical position
+ * (attnum).
+ */
+static int
+cmp_attnum(const void *a, const void *b)
+{
+ FormData_pg_attribute *atta = (FormData_pg_attribute *) a;
+ FormData_pg_attribute *attb = (FormData_pg_attribute *) b;
+
+ return (atta->attnum > attb->attnum) ? 1
+ : (atta->attnum == attb->attnum) ? 0
+ : -1;
+}
+
+/*
+ * TupleDescSortByAttnum
+ *
+ * Sort the attributes by their logical position (attnum) rather than their
+ * physical position (attphysnum).
+ * This function will modify the given TupleDesc, so caller should make a copy
+ * first if needed.
+ */
+void
+TupleDescSortByAttnum(TupleDesc desc)
+{
+ if (desc->natts <= 1)
+ return;
+
+ qsort(desc->attrs, desc->natts, sizeof(FormData_pg_attribute), cmp_attnum);
+}
+
/*
* BuildDescForRelation
@@ -828,6 +869,8 @@ BuildDescForRelation(List *schema)
TupleDescInitEntry(desc, attphysnum, attname,
atttypid, atttypmod, attdim);
att = TupleDescAttr(desc, attphysnum - 1);
+ /* FIXME - change me when there's a syntax to specify it */
+ att->attnum = attphysnum;
/* Override TupleDescInitEntry's settings as requested */
TupleDescInitEntryCollation(desc, attphysnum, attcollation);
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 37107dc12b..767bdd5477 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -518,6 +518,7 @@ DefineAttr(char *name, char *type, int attphysnum, int nullness)
namestrcpy(&attrtypes[attphysnum]->attname, name);
elog(DEBUG4, "column %s %s", NameStr(attrtypes[attphysnum]->attname), type);
attrtypes[attphysnum]->attphysnum = attphysnum + 1;
+ attrtypes[attphysnum]->attnum = attphysnum + 1;
typeoid = gettype(type);
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index f1d33dd949..cc23c5e909 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -852,6 +852,7 @@ sub gen_pg_attribute
$attphysnum++;
my %row;
$row{attphysnum} = $attphysnum;
+ $row{attnum} = $attphysnum;
$row{attrelid} = $table->{relation_oid};
morph_row_for_pgattr(\%row, $schema, $attr, $priorfixedwidth);
@@ -888,6 +889,7 @@ sub gen_pg_attribute
$attphysnum--;
my %row;
$row{attphysnum} = $attphysnum;
+ $row{attnum} = $attphysnum;
$row{attrelid} = $table->{relation_oid};
$row{attstattarget} = '0';
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index ed9929e67a..1ce0517e57 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -732,6 +732,14 @@ InsertPgAttributeTuples(Relation pg_attribute_rel,
slot[slotCount]->tts_values[Anum_pg_attribute_attstattarget - 1] = Int32GetDatum(attrs->attstattarget);
slot[slotCount]->tts_values[Anum_pg_attribute_attlen - 1] = Int16GetDatum(attrs->attlen);
slot[slotCount]->tts_values[Anum_pg_attribute_attphysnum - 1] = Int16GetDatum(attrs->attphysnum);
+ /*
+ * If caller provided a specific attnum use it, otherwise just fallback
+ * on attphysnum
+ */
+ if (AttributeNumberIsValid(attrs->attnum))
+ slot[slotCount]->tts_values[Anum_pg_attribute_attnum - 1] = Int16GetDatum(attrs->attnum);
+ else
+ slot[slotCount]->tts_values[Anum_pg_attribute_attnum - 1] = Int16GetDatum(attrs->attphysnum);
slot[slotCount]->tts_values[Anum_pg_attribute_attndims - 1] = Int32GetDatum(attrs->attndims);
slot[slotCount]->tts_values[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(-1);
slot[slotCount]->tts_values[Anum_pg_attribute_atttypmod - 1] = Int32GetDatum(attrs->atttypmod);
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index c514e3b622..153916e44c 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -311,6 +311,7 @@ ConstructTupleDescriptor(Relation heapRelation,
MemSet(to, 0, ATTRIBUTE_FIXED_PART_SIZE);
to->attphysnum = i + 1;
+ to->attnum = to->attphysnum;
to->attstattarget = -1;
to->attcacheoff = -1;
to->attislocal = true;
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 6b15837dba..7ee0703ed0 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -65,6 +65,7 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
int stmt_location, int stmt_len,
uint64 *processed)
{
+ List *attlist = stmt->attlist;
bool is_from = stmt->is_from;
bool pipe = (stmt->filename == NULL);
Relation rel;
@@ -147,7 +148,34 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
}
tupDesc = RelationGetDescr(rel);
- attnums = CopyGetAttnums(tupDesc, rel, stmt->attlist);
+
+ /* If no column list has been provided, generate one using the logical
+ * attribute numbers rather than physical order.
+ * We don't include generated columns in the generated full list and we
+ * don't allow them to be specified explicitly.
+ */
+ if (attlist == NIL)
+ {
+ TupleDesc tmp = CreateTupleDescCopyConstr(tupDesc);
+ TupleDescSortByAttnum(tmp);
+
+ for (int i = 0; i < tmp->natts; i++)
+ {
+ Form_pg_attribute attr = TupleDescAttr(tmp, i);
+
+ if (attr->attisdropped)
+ continue;
+ if (attr->attgenerated)
+ continue;
+
+ attlist = lappend(attlist,
+ makeString(pstrdup(NameStr(attr->attname))));
+ }
+
+ pfree(tmp);
+ }
+
+ attnums = CopyGetAttnums(tupDesc, rel, attlist);
foreach(cur, attnums)
{
int attno = lfirst_int(cur) -
@@ -199,8 +227,10 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
* In the case that columns are specified in the attribute list,
* create a ColumnRef and ResTarget for each column and add them
* to the target list for the resulting SELECT statement.
+ *
+ * FIXME - should be dead code
*/
- if (!stmt->attlist)
+ if (!attlist)
{
cr = makeNode(ColumnRef);
cr->fields = list_make1(makeNode(A_Star));
@@ -218,7 +248,7 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
{
ListCell *lc;
- foreach(lc, stmt->attlist)
+ foreach(lc, attlist)
{
/*
* Build the ColumnRef for each column. The ColumnRef
@@ -294,7 +324,7 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
cstate = BeginCopyFrom(pstate, rel, whereClause,
stmt->filename, stmt->is_program,
- NULL, stmt->attlist, stmt->options);
+ NULL, attlist, stmt->options);
*processed = CopyFrom(cstate); /* copy from file to database */
EndCopyFrom(cstate);
}
@@ -304,7 +334,7 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
cstate = BeginCopyTo(pstate, rel, query, relid,
stmt->filename, stmt->is_program,
- stmt->attlist, stmt->options);
+ attlist, stmt->options);
*processed = DoCopyTo(cstate); /* copy from database to file */
EndCopyTo(cstate);
}
@@ -724,11 +754,13 @@ CopyGetAttnums(TupleDesc tupDesc, Relation rel, List *attnamelist)
for (i = 0; i < attr_count; i++)
{
- if (TupleDescAttr(tupDesc, i)->attisdropped)
+ Form_pg_attribute attr = TupleDescAttr(tupDesc, i);
+
+ if (attr->attisdropped)
continue;
- if (TupleDescAttr(tupDesc, i)->attgenerated)
+ if (attr->attgenerated)
continue;
- attnums = lappend_int(attnums, i + 1);
+ attnums = lappend_int(attnums, attr->attphysnum);
}
}
else
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index ff9a9fc911..007e355d9d 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -2504,7 +2504,14 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(relation->rd_rel->relkind),
RelationGetRelationName(relation));
- tupleDesc = RelationGetDescr(relation);
+ /*
+ * Make a copy of the tupledesc and sort it by logical attnum, as this
+ * is the expected order for inherited relations.
+ * FIXME - should keep the original attphysnum and compute an attnum
+ * instead?
+ */
+ tupleDesc = CreateTupleDescCopyConstr(RelationGetDescr(relation));
+ TupleDescSortByAttnum(tupleDesc);
constr = tupleDesc->constr;
/*
@@ -6815,6 +6822,8 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
attribute.attstattarget = (newattnum > 0) ? -1 : 0;
attribute.attlen = tform->typlen;
attribute.attphysnum = newattnum;
+ /* FIXME - change me when there's a syntax to specify it */
+ attribute.attnum = newattnum;
attribute.attndims = list_length(colDef->typeName->arrayBounds);
attribute.atttypmod = typmod;
attribute.attbyval = tform->typbyval;
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 51d630fa89..68c6fb7c93 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -1455,6 +1455,7 @@ _copyVar(const Var *from)
COPY_SCALAR_FIELD(varno);
COPY_SCALAR_FIELD(varattno);
+ COPY_SCALAR_FIELD(varnum);
COPY_SCALAR_FIELD(vartype);
COPY_SCALAR_FIELD(vartypmod);
COPY_SCALAR_FIELD(varcollid);
@@ -1814,6 +1815,7 @@ _copyFieldSelect(const FieldSelect *from)
COPY_NODE_FIELD(arg);
COPY_SCALAR_FIELD(fieldnum);
+ COPY_SCALAR_FIELD(fieldlognum);
COPY_SCALAR_FIELD(resulttype);
COPY_SCALAR_FIELD(resulttypmod);
COPY_SCALAR_FIELD(resultcollid);
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index e747e1667d..d9ca25606b 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -551,6 +551,7 @@ _equalFieldSelect(const FieldSelect *a, const FieldSelect *b)
{
COMPARE_NODE_FIELD(arg);
COMPARE_SCALAR_FIELD(fieldnum);
+ COMPARE_SCALAR_FIELD(fieldlognum);
COMPARE_SCALAR_FIELD(resulttype);
COMPARE_SCALAR_FIELD(resulttypmod);
COMPARE_SCALAR_FIELD(resultcollid);
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index ce12915592..d80d18cfca 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -1143,6 +1143,7 @@ _outVar(StringInfo str, const Var *node)
WRITE_INT_FIELD(varno);
WRITE_INT_FIELD(varattno);
+ WRITE_INT_FIELD(varnum);
WRITE_OID_FIELD(vartype);
WRITE_INT_FIELD(vartypmod);
WRITE_OID_FIELD(varcollid);
@@ -1421,6 +1422,7 @@ _outFieldSelect(StringInfo str, const FieldSelect *node)
WRITE_NODE_FIELD(arg);
WRITE_INT_FIELD(fieldnum);
+ WRITE_INT_FIELD(fieldlognum);
WRITE_OID_FIELD(resulttype);
WRITE_INT_FIELD(resulttypmod);
WRITE_OID_FIELD(resultcollid);
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c
index 6a05b69415..f56070bbf6 100644
--- a/src/backend/nodes/readfuncs.c
+++ b/src/backend/nodes/readfuncs.c
@@ -619,6 +619,7 @@ _readVar(void)
READ_INT_FIELD(varno);
READ_INT_FIELD(varattno);
+ READ_INT_FIELD(varnum);
READ_OID_FIELD(vartype);
READ_INT_FIELD(vartypmod);
READ_OID_FIELD(varcollid);
@@ -939,6 +940,7 @@ _readFieldSelect(void)
READ_NODE_FIELD(arg);
READ_INT_FIELD(fieldnum);
+ READ_INT_FIELD(fieldlognum);
READ_OID_FIELD(resulttype);
READ_INT_FIELD(resulttypmod);
READ_OID_FIELD(resultcollid);
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 5012bfe142..07baf4c9eb 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -41,6 +41,7 @@
#include "optimizer/optimizer.h"
#include "optimizer/plancat.h"
#include "optimizer/prep.h"
+#include "optimizer/tlist.h"
#include "parser/parse_relation.h"
#include "parser/parsetree.h"
#include "partitioning/partdesc.h"
@@ -1698,6 +1699,7 @@ build_physical_tlist(PlannerInfo *root, RelOptInfo *rel)
att_tup->atttypmod,
att_tup->attcollation,
0);
+ var->varnum = att_tup->attnum;
tlist = lappend(tlist,
makeTargetEntry((Expr *) var,
diff --git a/src/backend/optimizer/util/tlist.c b/src/backend/optimizer/util/tlist.c
index fe9a9d7d89..82f28c071b 100644
--- a/src/backend/optimizer/util/tlist.c
+++ b/src/backend/optimizer/util/tlist.c
@@ -1056,6 +1056,49 @@ split_pathtarget_at_srfs(PlannerInfo *root,
}
}
+/*
+ * Comparator for sorting list of TargetEntries by their logical order.
+ *
+ * The target entry's expr should be either a Var or a FieldSelect.
+ */
+int
+cmp_targetentry_logical_order(const ListCell *a, const ListCell *b)
+{
+ TargetEntry *ta = lfirst_node(TargetEntry, a);
+ TargetEntry *tb = lfirst_node(TargetEntry, b);
+
+ if (IsA(ta->expr, Var))
+ {
+ Var *va;
+ Var *vb;
+
+ Assert(IsA(tb->expr, Var));
+
+ va = (Var *) ta->expr;
+ vb = (Var *) tb->expr;
+
+ if (va->varno != vb->varno)
+ return (va->varno > vb->varno) ? 1 : (va->varno == vb->varno) ? 0 : -1;
+ return (va->varnum > vb->varnum) ? 1 : (va->varnum == vb->varnum) ? 0 : -1;
+ }
+ else
+ {
+ FieldSelect *fa;
+ FieldSelect *fb;
+
+ Assert(IsA(ta->expr, FieldSelect) && IsA(tb->expr, FieldSelect));
+
+ fa = (FieldSelect *) ta->expr;
+ fb = (FieldSelect *) tb->expr;
+
+ Assert(AttributeNumberIsValid(fa->fieldlognum) &&
+ AttributeNumberIsValid(fb->fieldlognum));
+
+ return (fa->fieldlognum > fb->fieldlognum) ? 1 : (fa->fieldlognum == fb->fieldlognum) ? 0 : -1;
+ }
+
+}
+
/*
* Recursively examine expressions for split_pathtarget_at_srfs.
*
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 5ced631957..bf811b3f06 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -1589,7 +1589,7 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
* Generate a targetlist as though expanding "*"
*/
Assert(pstate->p_next_resno == 1);
- qry->targetList = expandNSItemAttrs(pstate, nsitem, 0, true, -1);
+ qry->targetList = expandNSItemAttrs(pstate, nsitem, 0, true, false, -1);
/*
* The grammar allows attaching ORDER BY, LIMIT, and FOR UPDATE to a
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index d1b0080268..8aa2fd7d65 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -1569,6 +1569,7 @@ buildVarFromNSColumn(ParseNamespaceColumn *nscol)
nscol->p_varcollid,
0);
/* makeVar doesn't offer parameters for these, so set by hand: */
+ var->varnum = nscol->p_varnum;
var->varnosyn = nscol->p_varnosyn;
var->varattnosyn = nscol->p_varattnosyn;
return var;
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 27c3abb7ec..8bc9ccbadf 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -26,6 +26,7 @@
#include "funcapi.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
+#include "optimizer/tlist.h"
#include "parser/parse_enr.h"
#include "parser/parse_relation.h"
#include "parser/parse_type.h"
@@ -733,6 +734,7 @@ scanNSItemForColumn(ParseState *pstate, ParseNamespaceItem *nsitem,
nscol->p_varcollid,
sublevels_up);
/* makeVar doesn't offer parameters for these, so set them by hand: */
+ var->varnum = nscol->p_varnum;
var->varnosyn = nscol->p_varnosyn;
var->varattnosyn = nscol->p_varattnosyn;
}
@@ -1126,28 +1128,65 @@ buildRelationAliases(TupleDesc tupdesc, Alias *alias, Alias *eref)
{
int maxattrs = tupdesc->natts;
List *aliaslist;
- ListCell *aliaslc;
int numaliases;
int varattno;
int numdropped = 0;
+ int *mappings;
Assert(eref->colnames == NIL);
if (alias)
{
aliaslist = alias->colnames;
- aliaslc = list_head(aliaslist);
numaliases = list_length(aliaslist);
/* We'll rebuild the alias colname list */
alias->colnames = NIL;
+ mappings = palloc0(sizeof(int) * (maxattrs + 1));
}
else
{
aliaslist = NIL;
- aliaslc = NULL;
numaliases = 0;
}
+ /*
+ * Build a physical/logical position mapping to emit aliases in logical
+ * order.
+ */
+ if (numaliases > 0)
+ {
+ TupleDesc sorted = CreateTupleDescCopy(tupdesc);
+ int i = 1;
+
+ TupleDescSortByAttnum(sorted);
+
+ for (varattno = 0; varattno < maxattrs; varattno++)
+ {
+ Form_pg_attribute attr = TupleDescAttr(sorted, varattno);
+
+ if (attr->attisdropped)
+ continue;
+
+ /*
+ * We record a 1-based position mapping to be able to use
+ * AttributeNumberIsValid.
+ */
+ mappings[attr->attphysnum] = i++;
+
+ /* We're done if we already mapped all the provided aliases. */
+ if (i > numaliases)
+ break;
+ }
+ pfree(sorted);
+
+ /* Too many user-supplied aliases? */
+ if (i <= numaliases)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
+ errmsg("table \"%s\" has %d columns available but %d columns specified",
+ eref->aliasname, i - 1, numaliases)));
+ }
+
for (varattno = 0; varattno < maxattrs; varattno++)
{
Form_pg_attribute attr = TupleDescAttr(tupdesc, varattno);
@@ -1157,15 +1196,15 @@ buildRelationAliases(TupleDesc tupdesc, Alias *alias, Alias *eref)
{
/* Always insert an empty string for a dropped column */
attrname = makeString(pstrdup(""));
- if (aliaslc)
- alias->colnames = lappend(alias->colnames, attrname);
numdropped++;
+ if (aliaslist && varattno - numdropped > numaliases)
+ alias->colnames = lappend(alias->colnames, attrname);
}
- else if (aliaslc)
+ else if (aliaslist && AttributeNumberIsValid(mappings[attr->attphysnum]))
{
- /* Use the next user-supplied alias */
- attrname = lfirst_node(String, aliaslc);
- aliaslc = lnext(aliaslist, aliaslc);
+ /* Use the next user-supplied alias, in logical order */
+ attrname = list_nth_node(String, aliaslist,
+ mappings[attr->attphysnum] - 1);
alias->colnames = lappend(alias->colnames, attrname);
}
else
@@ -1176,13 +1215,6 @@ buildRelationAliases(TupleDesc tupdesc, Alias *alias, Alias *eref)
eref->colnames = lappend(eref->colnames, attrname);
}
-
- /* Too many user-supplied aliases? */
- if (aliaslc)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
- errmsg("table \"%s\" has %d columns available but %d columns specified",
- eref->aliasname, maxattrs - numdropped, numaliases)));
}
/*
@@ -1262,11 +1294,14 @@ buildNSItemFromTupleDesc(RangeTblEntry *rte, Index rtindex, TupleDesc tupdesc)
nscolumns[varattno].p_varno = rtindex;
nscolumns[varattno].p_varattno = varattno + 1;
+ nscolumns[varattno].p_varattno = attr->attphysnum;
+ nscolumns[varattno].p_varnum = attr->attnum;
nscolumns[varattno].p_vartype = attr->atttypid;
nscolumns[varattno].p_vartypmod = attr->atttypmod;
nscolumns[varattno].p_varcollid = attr->attcollation;
nscolumns[varattno].p_varnosyn = rtindex;
nscolumns[varattno].p_varattnosyn = varattno + 1;
+ nscolumns[varattno].p_varattnosyn = attr->attphysnum;
}
/* ... and build the nsitem */
@@ -1323,6 +1358,10 @@ buildNSItemFromLists(RangeTblEntry *rte, Index rtindex,
{
nscolumns[varattno].p_varno = rtindex;
nscolumns[varattno].p_varattno = varattno + 1;
+ if (rte->rtekind == RTE_RELATION)
+ nscolumns[varattno].p_varnum = varattno + 1;
+ else
+ nscolumns[varattno].p_varnum = InvalidAttrNumber;
nscolumns[varattno].p_vartype = lfirst_oid(lct);
nscolumns[varattno].p_vartypmod = lfirst_int(lcm);
nscolumns[varattno].p_varcollid = lfirst_oid(lcc);
@@ -1408,6 +1447,9 @@ parserOpenTable(ParseState *pstate, const RangeVar *relation, int lockmode)
*
* Note: formerly this checked for refname conflicts, but that's wrong.
* Caller is responsible for checking for conflicts in the appropriate scope.
+ *
+ * Note also that the ParseNamespaceItem is generated using the range table's
+ * logical order (attnum) rather than physical order (attphysnum).
*/
ParseNamespaceItem *
addRangeTableEntry(ParseState *pstate,
@@ -1447,7 +1489,7 @@ addRangeTableEntry(ParseState *pstate,
/*
* Build the list of effective column names using user-supplied aliases
- * and/or actual column names.
+ * and/or actual column names, using the range table logical order.
*/
rte->eref = makeAlias(refname, NIL);
buildRelationAliases(rel->rd_att, alias, rte->eref);
@@ -3099,6 +3141,7 @@ expandNSItemVars(ParseNamespaceItem *nsitem,
nscol->p_varcollid,
sublevels_up);
/* makeVar doesn't offer parameters for these, so set by hand: */
+ var->varnum = nscol->p_varnum;
var->varnosyn = nscol->p_varnosyn;
var->varattnosyn = nscol->p_varattnosyn;
var->location = location;
@@ -3127,13 +3170,15 @@ expandNSItemVars(ParseNamespaceItem *nsitem,
*/
List *
expandNSItemAttrs(ParseState *pstate, ParseNamespaceItem *nsitem,
- int sublevels_up, bool require_col_privs, int location)
+ int sublevels_up, bool require_col_privs, bool logical_order,
+ int location)
{
RangeTblEntry *rte = nsitem->p_rte;
List *names,
*vars;
ListCell *name,
- *var;
+ *var,
+ *lc;
List *te_list = NIL;
vars = expandNSItemVars(nsitem, sublevels_up, location, &names);
@@ -3155,8 +3200,12 @@ expandNSItemAttrs(ParseState *pstate, ParseNamespaceItem *nsitem,
Var *varnode = (Var *) lfirst(var);
TargetEntry *te;
+ /*
+ * We don't assign the resno here, as we may have to sort the list by
+ * logical attnum first.
+ */
te = makeTargetEntry((Expr *) varnode,
- (AttrNumber) pstate->p_next_resno++,
+ 0,
label,
false);
te_list = lappend(te_list, te);
@@ -3168,6 +3217,17 @@ expandNSItemAttrs(ParseState *pstate, ParseNamespaceItem *nsitem,
}
}
+ if (logical_order)
+ list_sort(te_list, cmp_targetentry_logical_order);
+
+ /* Assign the resnos now that the list is in the final order */
+ foreach(lc, te_list)
+ {
+ TargetEntry *te = (TargetEntry *) lfirst(lc);
+
+ te->resno = (AttrNumber) pstate->p_next_resno++;
+ }
+
Assert(name == NULL && var == NULL); /* lists not the same length? */
return te_list;
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index cff1cda48d..2b887ee4d9 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -20,6 +20,7 @@
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
+#include "optimizer/tlist.h"
#include "parser/parse_coerce.h"
#include "parser/parse_expr.h"
#include "parser/parse_func.h"
@@ -48,15 +49,18 @@ static Node *transformAssignmentSubscripts(ParseState *pstate,
CoercionContext ccontext,
int location);
static List *ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
- bool make_target_entry);
-static List *ExpandAllTables(ParseState *pstate, int location);
+ bool make_target_entry,
+ bool logical_order);
+static List *ExpandAllTables(ParseState *pstate, bool logical_order,
+ int location);
static List *ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind,
- bool make_target_entry, ParseExprKind exprKind);
+ bool make_target_entry, bool logical_order,
+ ParseExprKind exprKind);
static List *ExpandSingleTable(ParseState *pstate, ParseNamespaceItem *nsitem,
int sublevels_up, int location,
- bool make_target_entry);
+ bool make_target_entry, bool logical_order);
static List *ExpandRowReference(ParseState *pstate, Node *expr,
- bool make_target_entry);
+ bool make_target_entry, bool logical_order);
static int FigureColnameInternal(Node *node, char **name);
@@ -150,10 +154,12 @@ transformTargetList(ParseState *pstate, List *targetlist,
if (IsA(llast(cref->fields), A_Star))
{
- /* It is something.*, expand into multiple items */
+ /*
+ $ It is something.*, expand into multiple items
+ */
p_target = list_concat(p_target,
- ExpandColumnRefStar(pstate,
- cref,
+ ExpandColumnRefStar(pstate, cref,
+ true,
true));
continue;
}
@@ -169,6 +175,7 @@ transformTargetList(ParseState *pstate, List *targetlist,
ExpandIndirectionStar(pstate,
ind,
true,
+ true,
exprKind));
continue;
}
@@ -243,7 +250,7 @@ transformExpressionList(ParseState *pstate, List *exprlist,
/* It is something.*, expand into multiple items */
result = list_concat(result,
ExpandColumnRefStar(pstate, cref,
- false));
+ false, false));
continue;
}
}
@@ -256,7 +263,8 @@ transformExpressionList(ParseState *pstate, List *exprlist,
/* It is something.*, expand into multiple items */
result = list_concat(result,
ExpandIndirectionStar(pstate, ind,
- false, exprKind));
+ false, false,
+ exprKind));
continue;
}
}
@@ -1014,6 +1022,8 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
if (cols == NIL)
{
+ TupleDesc tupdesc;
+
/*
* Generate default column list for INSERT.
*/
@@ -1021,12 +1031,15 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
int i;
+ tupdesc = CreateTupleDescCopy(pstate->p_target_relation->rd_att);
+ TupleDescSortByAttnum(tupdesc);
+
for (i = 0; i < numcol; i++)
{
ResTarget *col;
Form_pg_attribute attr;
- attr = TupleDescAttr(pstate->p_target_relation->rd_att, i);
+ attr = TupleDescAttr(tupdesc, i);
if (attr->attisdropped)
continue;
@@ -1037,8 +1050,10 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
col->val = NULL;
col->location = -1;
cols = lappend(cols, col);
- *attrnos = lappend_int(*attrnos, i + 1);
+ *attrnos = lappend_int(*attrnos, attr->attphysnum);
}
+
+ pfree(tupdesc);
}
else
{
@@ -1114,7 +1129,7 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
*/
static List *
ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
- bool make_target_entry)
+ bool make_target_entry, bool logical_order)
{
List *fields = cref->fields;
int numnames = list_length(fields);
@@ -1130,7 +1145,7 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
* need not handle the make_target_entry==false case here.
*/
Assert(make_target_entry);
- return ExpandAllTables(pstate, cref->location);
+ return ExpandAllTables(pstate, logical_order, cref->location);
}
else
{
@@ -1169,7 +1184,8 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
node = pstate->p_pre_columnref_hook(pstate, cref);
if (node != NULL)
- return ExpandRowReference(pstate, node, make_target_entry);
+ return ExpandRowReference(pstate, node, make_target_entry,
+ logical_order);
}
switch (numnames)
@@ -1234,7 +1250,8 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
errmsg("column reference \"%s\" is ambiguous",
NameListToString(cref->fields)),
parser_errposition(pstate, cref->location)));
- return ExpandRowReference(pstate, node, make_target_entry);
+ return ExpandRowReference(pstate, node, make_target_entry,
+ logical_order);
}
}
@@ -1270,7 +1287,7 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
* OK, expand the nsitem into fields.
*/
return ExpandSingleTable(pstate, nsitem, levels_up, cref->location,
- make_target_entry);
+ make_target_entry, logical_order);
}
}
@@ -1283,10 +1300,13 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
* that would include input tables of aliasless JOINs, NEW/OLD pseudo-entries,
* etc.
*
+ * If logical_order is true, the expansion is done using the relation logical
+ * order (attnum) rather than physical order.
+ *
* The referenced relations/columns are marked as requiring SELECT access.
*/
static List *
-ExpandAllTables(ParseState *pstate, int location)
+ExpandAllTables(ParseState *pstate, bool logical_order, int location)
{
List *target = NIL;
bool found_table = false;
@@ -1309,6 +1329,7 @@ ExpandAllTables(ParseState *pstate, int location)
nsitem,
0,
true,
+ logical_order,
location));
}
@@ -1339,7 +1360,8 @@ ExpandAllTables(ParseState *pstate, int location)
*/
static List *
ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind,
- bool make_target_entry, ParseExprKind exprKind)
+ bool make_target_entry, bool logical_order,
+ ParseExprKind exprKind)
{
Node *expr;
@@ -1352,7 +1374,7 @@ ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind,
expr = transformExpr(pstate, (Node *) ind, exprKind);
/* Expand the rowtype expression into individual fields */
- return ExpandRowReference(pstate, expr, make_target_entry);
+ return ExpandRowReference(pstate, expr, make_target_entry, logical_order);
}
/*
@@ -1366,12 +1388,14 @@ ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind,
*/
static List *
ExpandSingleTable(ParseState *pstate, ParseNamespaceItem *nsitem,
- int sublevels_up, int location, bool make_target_entry)
+ int sublevels_up, int location, bool make_target_entry,
+ bool logical_order)
{
if (make_target_entry)
{
/* expandNSItemAttrs handles permissions marking */
- return expandNSItemAttrs(pstate, nsitem, sublevels_up, true, location);
+ return expandNSItemAttrs(pstate, nsitem, sublevels_up, true,
+ logical_order, location);
}
else
{
@@ -1413,9 +1437,10 @@ ExpandSingleTable(ParseState *pstate, ParseNamespaceItem *nsitem,
*/
static List *
ExpandRowReference(ParseState *pstate, Node *expr,
- bool make_target_entry)
+ bool make_target_entry, bool logical_order)
{
List *result = NIL;
+ ListCell *lc;
TupleDesc tupleDesc;
int numAttrs;
int i;
@@ -1436,7 +1461,9 @@ ExpandRowReference(ParseState *pstate, Node *expr,
ParseNamespaceItem *nsitem;
nsitem = GetNSItemByRangeTablePosn(pstate, var->varno, var->varlevelsup);
- return ExpandSingleTable(pstate, nsitem, var->varlevelsup, var->location, make_target_entry);
+ return ExpandSingleTable(pstate, nsitem, var->varlevelsup,
+ var->location, make_target_entry,
+ logical_order);
}
/*
@@ -1472,6 +1499,7 @@ ExpandRowReference(ParseState *pstate, Node *expr,
fselect = makeNode(FieldSelect);
fselect->arg = (Expr *) copyObject(expr);
fselect->fieldnum = i + 1;
+ fselect->fieldlognum = att->attnum;
fselect->resulttype = att->atttypid;
fselect->resulttypmod = att->atttypmod;
/* save attribute's collation for parse_collate.c */
@@ -1482,8 +1510,12 @@ ExpandRowReference(ParseState *pstate, Node *expr,
/* add TargetEntry decoration */
TargetEntry *te;
+ /*
+ * We don't assign the resno here, as we may have to sort the list
+ * by logical attnum first.
+ */
te = makeTargetEntry((Expr *) fselect,
- (AttrNumber) pstate->p_next_resno++,
+ 0,
pstrdup(NameStr(att->attname)),
false);
result = lappend(result, te);
@@ -1492,6 +1524,24 @@ ExpandRowReference(ParseState *pstate, Node *expr,
result = lappend(result, fselect);
}
+ /*
+ * If caller didn't ask to make target entries, we can return the list now
+ */
+ if (!make_target_entry)
+ return result;
+
+ /* If caller asked for logical order, sort the target entries */
+ if (logical_order)
+ list_sort(result, cmp_targetentry_logical_order);
+
+ /* And assign the resnos now that the list is in the final order */
+ foreach(lc, result)
+ {
+ TargetEntry *te = (TargetEntry *) lfirst(lc);
+
+ te->resno = (AttrNumber) pstate->p_next_resno++;
+ }
+
return result;
}
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 69132f729d..33e571b3b4 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -1001,7 +1001,13 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
RelationGetRelationName(relation));
}
- tupleDesc = RelationGetDescr(relation);
+ /*
+ * The expansion has to be done in the logical order (attnum) rather than
+ * the physical order, and the code also needs to access the constraints so
+ * make a full copy of the tuple desc.
+ */
+ tupleDesc = CreateTupleDescCopyConstr(RelationGetDescr(relation));
+ TupleDescSortByAttnum(tupleDesc);
/*
* Insert the copied attributes into the cxt for the new table definition.
@@ -1110,6 +1116,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
cxt->alist = lappend(cxt->alist, stmt);
}
}
+ pfree(tupleDesc);
/*
* We cannot yet deal with defaults, CHECK constraints, or indexes, since
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 8a98060956..febc305244 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -576,8 +576,11 @@ RelationBuildTupleDesc(Relation relation)
attphysnum = attp->attphysnum;
if (attphysnum <= 0 || attphysnum > RelationGetNumberOfAttributes(relation))
- elog(ERROR, "invalid attribute number %d for relation \"%s\"",
+ elog(ERROR, "invalid physical attribute number %d for relation \"%s\"",
attp->attphysnum, RelationGetRelationName(relation));
+ if (attp->attnum <= 0 || attp->attnum > RelationGetNumberOfAttributes(relation))
+ elog(ERROR, "invalid logical attribute number %d for relation \"%s\"",
+ attp->attnum, RelationGetRelationName(relation));
memcpy(TupleDescAttr(relation->rd_att, attphysnum - 1),
attp,
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index a25ec298fd..0e56b546e3 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -1534,6 +1534,7 @@ describeOneTableDetails(const char *schemaname,
char relpersistence;
char relreplident;
char *relam;
+ bool haslogicalorder;
} tableinfo;
bool show_column_details = false;
@@ -1546,7 +1547,28 @@ describeOneTableDetails(const char *schemaname,
initPQExpBuffer(&tmpbuf);
/* Get general table info */
- if (pset.sversion >= 120000)
+ if (pset.sversion >= 150000) /* FXME - bump me when pg15 branched */
+ {
+ printfPQExpBuffer(&buf,
+ "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
+ "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
+ "false AS relhasoids, c.relispartition, %s, c.reltablespace, "
+ "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
+ "c.relpersistence, c.relreplident, am.amname,\n"
+ " (SELECT count(*) > 0 FROM pg_catalog.pg_attribute a\n"
+ " WHERE a.attrelid = c.oid\n"
+ " AND a.attphysnum != a.attnum)\n"
+ "FROM pg_catalog.pg_class c\n "
+ "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
+ "LEFT JOIN pg_catalog.pg_am am ON (c.relam = am.oid)\n"
+ "WHERE c.oid = '%s';",
+ (verbose ?
+ "pg_catalog.array_to_string(c.reloptions || "
+ "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
+ : "''"),
+ oid);
+ }
+ else if (pset.sversion >= 120000)
{
printfPQExpBuffer(&buf,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1666,6 +1688,11 @@ describeOneTableDetails(const char *schemaname,
(char *) NULL : pg_strdup(PQgetvalue(res, 0, 14));
else
tableinfo.relam = NULL;
+ /* FIXME - bump me when pg15 branched */
+ if (pset.sversion >= 150000)
+ tableinfo.haslogicalorder = strcmp(PQgetvalue(res, 0, 15), "t") == 0;
+ else
+ tableinfo.haslogicalorder = false;
PQclear(res);
res = NULL;
@@ -1955,16 +1982,8 @@ describeOneTableDetails(const char *schemaname,
}
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_attribute a");
- if (pset.sversion >= 150000) /* FIXME - bump me when pg15 branched */
- {
- appendPQExpBuffer(&buf, "\nWHERE a.attrelid = '%s' AND a.attphysnum > 0 AND NOT a.attisdropped", oid);
- appendPQExpBufferStr(&buf, "\nORDER BY a.attphysnum;");
- }
- else
- {
- appendPQExpBuffer(&buf, "\nWHERE a.attrelid = '%s' AND a.attnum > 0 AND NOT a.attisdropped", oid);
- appendPQExpBufferStr(&buf, "\nORDER BY a.attnum;");
- }
+ appendPQExpBuffer(&buf, "\nWHERE a.attrelid = '%s' AND a.attnum > 0 AND NOT a.attisdropped", oid);
+ appendPQExpBufferStr(&buf, "\nORDER BY a.attnum;");
res = PSQLexec(buf.data);
if (!res)
@@ -2386,6 +2405,36 @@ describeOneTableDetails(const char *schemaname,
PGresult *result = NULL;
int tuples = 0;
+ /*
+ * print physical attribute order if different from logical
+ * FIXME - bump me when pg15 branched
+ */
+ if (pset.sversion >= 150000 && tableinfo.haslogicalorder && verbose)
+ {
+ Assert(tableinfo.relkind == RELKIND_RELATION);
+
+ printfPQExpBuffer(&buf,
+ "SELECT string_agg(a.attname, ', ')\n"
+ "FROM pg_catalog.pg_class c\n"
+ "JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid\n"
+ "WHERE c.oid = '%s' \n"
+ "AND a.attphysnum > 0 \n"
+ "AND NOT a.attisdropped", oid);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
+
+ Assert(tuples == 1);
+
+ printfPQExpBuffer(&buf, "(%s)", PQgetvalue(result, 0, 0));
+ PQclear(result);
+
+ printTableAddFooter(&cont, _("Physical order:"));
+ printTableAddFooter(&cont, buf.data);
+ }
+
/* print indexes */
if (tableinfo.hasindex)
{
diff --git a/src/include/access/tupdesc.h b/src/include/access/tupdesc.h
index 28dd6de18b..f519758b22 100644
--- a/src/include/access/tupdesc.h
+++ b/src/include/access/tupdesc.h
@@ -147,6 +147,8 @@ extern void TupleDescInitEntryCollation(TupleDesc desc,
AttrNumber attributeNumber,
Oid collationid);
+extern void TupleDescSortByAttnum(TupleDesc desc);
+
extern TupleDesc BuildDescForRelation(List *schema);
extern TupleDesc BuildDescFromLists(List *names, List *types, List *typmods, List *collations);
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index 746566eb8d..d2e8b5f765 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -82,6 +82,11 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
*/
int16 attphysnum;
+ /* FIXME Same as attphysnum, but for the "logical" order, e.g. for a
+ * star-expansion.
+ */
+ int16 attnum;
+
/*
* attndims is the declared number of dimensions, if an array type,
* otherwise zero.
@@ -207,6 +212,7 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
typedef FormData_pg_attribute *Form_pg_attribute;
DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index, 2658, AttributeRelidNameIndexId, on pg_attribute using btree(attrelid oid_ops, attname name_ops));
+DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnum_index, 8294, AttributeReliNumIndexId, on pg_attribute using btree(attrelid oid_ops, attnum int2_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_attribute_relid_attphysnum_index, 2659, AttributeRelidPhysNumIndexId, on pg_attribute using btree(attrelid oid_ops, attphysnum int2_ops));
#ifdef EXPOSE_TO_CLIENT_CODE
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index 51505eee85..7dad6f4fb6 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -199,6 +199,7 @@ typedef struct Var
* table, or INNER_VAR/OUTER_VAR/etc */
AttrNumber varattno; /* attribute number of this var, or zero for
* all attrs ("whole-row Var") */
+ AttrNumber varnum; /* logical attribute number of this var FIXME */
Oid vartype; /* pg_type OID for the type of this var */
int32 vartypmod; /* pg_attribute typmod value */
Oid varcollid; /* OID of collation, or InvalidOid if none */
@@ -815,7 +816,8 @@ typedef struct FieldSelect
{
Expr xpr;
Expr *arg; /* input expression */
- AttrNumber fieldnum; /* attribute number of field to extract */
+ AttrNumber fieldnum; /* physical attribute number of field to extract */
+ AttrNumber fieldlognum; /* logical attribute number of field (can be 0) */
Oid resulttype; /* type of the field (result type of this
* node) */
int32 resulttypmod; /* output typmod (usually -1) */
diff --git a/src/include/optimizer/tlist.h b/src/include/optimizer/tlist.h
index 04668ba1c0..5e4fb21bc8 100644
--- a/src/include/optimizer/tlist.h
+++ b/src/include/optimizer/tlist.h
@@ -48,6 +48,7 @@ extern void apply_pathtarget_labeling_to_tlist(List *tlist, PathTarget *target);
extern void split_pathtarget_at_srfs(PlannerInfo *root,
PathTarget *target, PathTarget *input_target,
List **targets, List **targets_contain_srfs);
+extern int cmp_targetentry_logical_order(const ListCell *a, const ListCell *b);
/* Convenience macro to get a PathTarget with valid cost/width fields */
#define create_pathtarget(root, tlist) \
diff --git a/src/include/parser/parse_node.h b/src/include/parser/parse_node.h
index cf9c759025..642ef43b32 100644
--- a/src/include/parser/parse_node.h
+++ b/src/include/parser/parse_node.h
@@ -300,7 +300,8 @@ struct ParseNamespaceItem
struct ParseNamespaceColumn
{
Index p_varno; /* rangetable index */
- AttrNumber p_varattno; /* attribute number of the column */
+ AttrNumber p_varattno; /* physical attribute number of the column */
+ AttrNumber p_varnum; /* logical attribute number of the column */
Oid p_vartype; /* pg_type OID */
int32 p_vartypmod; /* type modifier value */
Oid p_varcollid; /* OID of collation, or InvalidOid */
diff --git a/src/include/parser/parse_relation.h b/src/include/parser/parse_relation.h
index de21c3c649..97e1c3f453 100644
--- a/src/include/parser/parse_relation.h
+++ b/src/include/parser/parse_relation.h
@@ -114,7 +114,7 @@ extern List *expandNSItemVars(ParseNamespaceItem *nsitem,
List **colnames);
extern List *expandNSItemAttrs(ParseState *pstate, ParseNamespaceItem *nsitem,
int sublevels_up, bool require_col_privs,
- int location);
+ bool logical_order, int location);
extern int attnameAttNum(Relation rd, const char *attname, bool sysColOK);
extern const NameData *attnumAttName(Relation rd, int attid);
extern Oid attnumTypeId(Relation rd, int attid);
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index f34c8474b4..fbd079f8b2 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -414,9 +414,22 @@ ttdummy(PG_FUNCTION_ARGS)
query = (char *) palloc(100 + 16 * natts);
/*
- * Construct query: INSERT INTO _relation_ VALUES ($1, ...)
+ * Construct query:
+ * INSERT INTO _relation_ (field1, ...) VALUES ($1, ...)
+ * We have to specify the fields explicitly as we provide the value in
+ * the relation physical order and not the possibly different logical
+ * order.
*/
- sprintf(query, "INSERT INTO %s VALUES (", relname);
+ sprintf(query, "INSERT INTO %s(", relname);
+ for (i = 0; i < natts; i++)
+ {
+ if (i > 0)
+ sprintf(query + strlen(query), ", ");
+
+ sprintf(query + strlen(query),
+ "%s", NameStr(TupleDescAttr(tupdesc, i)->attname));
+ }
+ sprintf(query + strlen(query), ") VALUES (");
for (i = 1; i <= natts; i++)
{
sprintf(query + strlen(query), "$%d%s",
--
2.33.1
v1-0003-POC-Add-infrastructure-to-specify-catalog-attribu.patchtext/plain; charset=us-asciiDownload
From 552680f18ac8b5db47be1167d789591994f6cf84 Mon Sep 17 00:00:00 2001
From: Julien Rouhaud <julien.rouhaud@free.fr>
Date: Tue, 14 Jun 2022 23:48:37 +0800
Subject: [PATCH v1 3/5] POC: Add infrastructure to specify catalog attributes
logical position.
This introduces a new optional macro ATTNUM(attnum) which added to specify the
logical order of the attributes declared in a struct, if the regular struct
order isn't wanted.
Catalog.pm and genbki.pl will use that information to generate the data in the
correct oder.
Sanity check are performed to make sure that the declared ATTNUMs are a
gapeless sequence from 1 to the maximum number of attributes.
As an example, move relname near the end of pg_class struct and attname near
the end of pg_attribute.
Author: Julien Rouhaud
Discussion: FIXME
---
src/backend/catalog/Catalog.pm | 4 ++
src/backend/catalog/genbki.pl | 51 ++++++++++++++++++++++
src/include/catalog/genbki.h | 2 +
src/include/catalog/pg_attribute.h | 55 +++++++++++------------
src/include/catalog/pg_class.h | 70 +++++++++++++++---------------
5 files changed, 120 insertions(+), 62 deletions(-)
diff --git a/src/backend/catalog/Catalog.pm b/src/backend/catalog/Catalog.pm
index e91a8e10a8..7e08466534 100644
--- a/src/backend/catalog/Catalog.pm
+++ b/src/backend/catalog/Catalog.pm
@@ -253,6 +253,10 @@ sub ParseHeader
pk_cols => 'oid'
};
}
+ elsif ($attopt =~ /ATTNUM\((\w+)\)/)
+ {
+ $column{attnum} = $1;
+ }
else
{
die
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index cc23c5e909..b0b517ee95 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -847,6 +847,7 @@ sub gen_pg_attribute
# Generate entries for user attributes.
my $attphysnum = 0;
my $priorfixedwidth = 1;
+ my %mappings;
foreach my $attr (@{ $table->{columns} })
{
$attphysnum++;
@@ -857,6 +858,31 @@ sub gen_pg_attribute
morph_row_for_pgattr(\%row, $schema, $attr, $priorfixedwidth);
+ # Sanity checks for the assigned attnum
+ if ($row{attnum} <= 0)
+ {
+ warn sprintf "Invalid attnum %d for attribute %s of table %s",
+ $row{attnum}, $row{attname}, $table_name;
+ $num_errors++;
+ }
+
+ if ($row{attnum} > $table->{columns})
+ {
+ warn sprintf "Invalid attnum %d for attribute %s of table %s",
+ $row{attnum}, $row{attname}, $table_name;
+ $num_errors++;
+ }
+
+ if (exists $mappings{$row{attnum}})
+ {
+ warn sprintf "Attnum %d used for columns %s and %s in table %s",
+ $row{attnum}, $mappings{$row{attnum}}, $row{attname},
+ $table_name;
+ $num_errors++;
+ }
+
+ $mappings{$row{attnum}} = $row{attname};
+
# Update $priorfixedwidth --- must match morph_row_for_pgattr
$priorfixedwidth &=
($row{attnotnull} eq 't'
@@ -872,6 +898,20 @@ sub gen_pg_attribute
join(', ', grep { defined $_ } @row{@attnames});
}
+ # Complain if there's any "hole" in the attnum sequence. Prior code
+ # should have already complained about inconsistencies, but this can
+ # save some time by explicitly mentionning which attnums are missing as
+ # a result.
+ for (my $i = 1; $i <= $attphysnum; $i++)
+ {
+ if (not exists($mappings{$i}))
+ {
+ warn sprintf "No attnum %d defined for table %s",
+ $i, $table_name;
+ $num_errors++;
+ }
+ }
+
# Generate entries for system attributes.
# We only need postgres.bki entries, not schemapg.h entries.
if ($table->{bootstrap})
@@ -913,6 +953,17 @@ sub morph_row_for_pgattr
my $attname = $attr->{name};
my $atttype = $attr->{type};
+ # use the attnum previously found in the headers if any, otherwise fallback
+ # to attphysnum
+ if (defined $attr->{attnum})
+ {
+ $row->{attnum} = $attr->{attnum};
+ }
+ else
+ {
+ $row->{attnum} = $row->{attphysnum};
+ }
+
$row->{attname} = $attname;
# Copy the type data from pg_type, and add some type-dependent items
diff --git a/src/include/catalog/genbki.h b/src/include/catalog/genbki.h
index 992b784236..229aa90f6a 100644
--- a/src/include/catalog/genbki.h
+++ b/src/include/catalog/genbki.h
@@ -45,6 +45,8 @@
*/
#define BKI_LOOKUP(catalog)
#define BKI_LOOKUP_OPT(catalog)
+/* Specifies the logical attribute number */
+#define ATTNUM(attnum)
/*
* These lines are processed by genbki.pl to create the statements
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index d2e8b5f765..1d0c43b82a 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -36,9 +36,8 @@
*/
CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,AttributeRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
- Oid attrelid BKI_LOOKUP(pg_class); /* OID of relation containing
+ Oid attrelid BKI_LOOKUP(pg_class) ATTNUM(1); /* OID of relation containing
* this attribute */
- NameData attname; /* name of attribute */
/*
* atttypid is the OID of the instance in Catalog Class pg_type that
@@ -50,7 +49,7 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
* attbyval, and attalign to still tell us how large the values in the
* table are.
*/
- Oid atttypid BKI_LOOKUP_OPT(pg_type);
+ Oid atttypid BKI_LOOKUP_OPT(pg_type) ATTNUM(3);
/*
* attstattarget is the target number of statistics datapoints to collect
@@ -59,13 +58,13 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
* that no value has been explicitly set for this column, so ANALYZE
* should use the default setting.
*/
- int32 attstattarget BKI_DEFAULT(-1);
+ int32 attstattarget BKI_DEFAULT(-1) ATTNUM(4);
/*
* attlen is a copy of the typlen field from pg_type for this attribute.
* See atttypid comments above.
*/
- int16 attlen;
+ int16 attlen ATTNUM(5);
/*
* attphysnum is the "attribute number" for the attribute: A value that
@@ -80,18 +79,18 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
*
* Note that (attphysnum - 1) is often used as the index to an array.
*/
- int16 attphysnum;
+ int16 attphysnum ATTNUM(6);
/* FIXME Same as attphysnum, but for the "logical" order, e.g. for a
* star-expansion.
*/
- int16 attnum;
+ int16 attnum ATTNUM(7);
/*
* attndims is the declared number of dimensions, if an array type,
* otherwise zero.
*/
- int32 attndims;
+ int32 attndims ATTNUM(8);
/*
* fastgetattr() uses attcacheoff to cache byte offsets of attributes in
@@ -100,7 +99,7 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
* descriptor, we may then update attcacheoff in the copies. This speeds
* up the attribute walking process.
*/
- int32 attcacheoff BKI_DEFAULT(-1);
+ int32 attcacheoff BKI_DEFAULT(-1) ATTNUM(9);
/*
* atttypmod records type-specific data supplied at table creation time
@@ -108,19 +107,19 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
* type-specific input and output functions as the third argument. The
* value will generally be -1 for types that do not need typmod.
*/
- int32 atttypmod BKI_DEFAULT(-1);
+ int32 atttypmod BKI_DEFAULT(-1) ATTNUM(10);
/*
* attbyval is a copy of the typbyval field from pg_type for this
* attribute. See atttypid comments above.
*/
- bool attbyval;
+ bool attbyval ATTNUM(11);
/*
* attalign is a copy of the typalign field from pg_type for this
* attribute. See atttypid comments above.
*/
- char attalign;
+ char attalign ATTNUM(12);
/*----------
* attstorage tells for VARLENA attributes, what the heap access
@@ -128,7 +127,7 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
* Possible values are as for pg_type.typstorage (see TYPSTORAGE macros).
*----------
*/
- char attstorage;
+ char attstorage ATTNUM(13);
/*
* attcompression sets the current compression method of the attribute.
@@ -138,25 +137,25 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
* However, this field is ignored whenever attstorage does not allow
* compression.
*/
- char attcompression BKI_DEFAULT('\0');
+ char attcompression BKI_DEFAULT('\0') ATTNUM(14);
/* This flag represents the "NOT NULL" constraint */
- bool attnotnull;
+ bool attnotnull ATTNUM(15);
/* Has DEFAULT value or not */
- bool atthasdef BKI_DEFAULT(f);
+ bool atthasdef BKI_DEFAULT(f) ATTNUM(16);
/* Has a missing value or not */
- bool atthasmissing BKI_DEFAULT(f);
+ bool atthasmissing BKI_DEFAULT(f) ATTNUM(17);
/* One of the ATTRIBUTE_IDENTITY_* constants below, or '\0' */
- char attidentity BKI_DEFAULT('\0');
+ char attidentity BKI_DEFAULT('\0') ATTNUM(18);
/* One of the ATTRIBUTE_GENERATED_* constants below, or '\0' */
- char attgenerated BKI_DEFAULT('\0');
+ char attgenerated BKI_DEFAULT('\0') ATTNUM(19);
/* Is dropped (ie, logically invisible) or not */
- bool attisdropped BKI_DEFAULT(f);
+ bool attisdropped BKI_DEFAULT(f) ATTNUM(20);
/*
* This flag specifies whether this column has ever had a local
@@ -167,31 +166,33 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
* not dropped by a parent's DROP COLUMN even if this causes the column's
* attinhcount to become zero.
*/
- bool attislocal BKI_DEFAULT(t);
+ bool attislocal BKI_DEFAULT(t) ATTNUM(21);
/* Number of times inherited from direct parent relation(s) */
- int32 attinhcount BKI_DEFAULT(0);
+ int32 attinhcount BKI_DEFAULT(0) ATTNUM(22);
+
+ NameData attname ATTNUM(2); /* name of attribute */
/* attribute's collation, if any */
- Oid attcollation BKI_LOOKUP_OPT(pg_collation);
+ Oid attcollation BKI_LOOKUP_OPT(pg_collation) ATTNUM(23);
#ifdef CATALOG_VARLEN /* variable-length fields start here */
/* NOTE: The following fields are not present in tuple descriptors. */
/* Column-level access permissions */
- aclitem attacl[1] BKI_DEFAULT(_null_);
+ aclitem attacl[1] BKI_DEFAULT(_null_) ATTNUM(24);
/* Column-level options */
- text attoptions[1] BKI_DEFAULT(_null_);
+ text attoptions[1] BKI_DEFAULT(_null_) ATTNUM(25);
/* Column-level FDW options */
- text attfdwoptions[1] BKI_DEFAULT(_null_);
+ text attfdwoptions[1] BKI_DEFAULT(_null_) ATTNUM(26);
/*
* Missing value for added columns. This is a one element array which lets
* us store a value of the attribute type here.
*/
- anyarray attmissingval BKI_DEFAULT(_null_);
+ anyarray attmissingval BKI_DEFAULT(_null_) ATTNUM(27);
#endif
} FormData_pg_attribute;
diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h
index e1f4eefa22..2911903cb9 100644
--- a/src/include/catalog/pg_class.h
+++ b/src/include/catalog/pg_class.h
@@ -32,59 +32,56 @@
CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,RelationRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
/* oid */
- Oid oid;
-
- /* class name */
- NameData relname;
+ Oid oid ATTNUM(1);
/* OID of namespace containing this class */
- Oid relnamespace BKI_DEFAULT(pg_catalog) BKI_LOOKUP(pg_namespace);
+ Oid relnamespace BKI_DEFAULT(pg_catalog) BKI_LOOKUP(pg_namespace) ATTNUM(3);
/* OID of entry in pg_type for relation's implicit row type, if any */
- Oid reltype BKI_LOOKUP_OPT(pg_type);
+ Oid reltype BKI_LOOKUP_OPT(pg_type) ATTNUM(4);
/* OID of entry in pg_type for underlying composite type, if any */
- Oid reloftype BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_type);
+ Oid reloftype BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_type) ATTNUM(5);
/* class owner */
- Oid relowner BKI_DEFAULT(POSTGRES) BKI_LOOKUP(pg_authid);
+ Oid relowner BKI_DEFAULT(POSTGRES) BKI_LOOKUP(pg_authid) ATTNUM(6);
/* access method; 0 if not a table / index */
- Oid relam BKI_DEFAULT(heap) BKI_LOOKUP_OPT(pg_am);
+ Oid relam BKI_DEFAULT(heap) BKI_LOOKUP_OPT(pg_am) ATTNUM(7);
/* identifier of physical storage file */
/* relfilenode == 0 means it is a "mapped" relation, see relmapper.c */
- Oid relfilenode BKI_DEFAULT(0);
+ Oid relfilenode BKI_DEFAULT(0) ATTNUM(8);
/* identifier of table space for relation (0 means default for database) */
- Oid reltablespace BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_tablespace);
+ Oid reltablespace BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_tablespace) ATTNUM(9);
/* # of blocks (not always up-to-date) */
- int32 relpages BKI_DEFAULT(0);
+ int32 relpages BKI_DEFAULT(0) ATTNUM(10);
/* # of tuples (not always up-to-date; -1 means "unknown") */
- float4 reltuples BKI_DEFAULT(-1);
+ float4 reltuples BKI_DEFAULT(-1) ATTNUM(11);
/* # of all-visible blocks (not always up-to-date) */
- int32 relallvisible BKI_DEFAULT(0);
+ int32 relallvisible BKI_DEFAULT(0) ATTNUM(12);
/* OID of toast table; 0 if none */
- Oid reltoastrelid BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_class);
+ Oid reltoastrelid BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_class) ATTNUM(13);
/* T if has (or has had) any indexes */
- bool relhasindex BKI_DEFAULT(f);
+ bool relhasindex BKI_DEFAULT(f) ATTNUM(14);
/* T if shared across databases */
- bool relisshared BKI_DEFAULT(f);
+ bool relisshared BKI_DEFAULT(f) ATTNUM(15);
/* see RELPERSISTENCE_xxx constants below */
- char relpersistence BKI_DEFAULT(p);
+ char relpersistence BKI_DEFAULT(p) ATTNUM(16);
/* see RELKIND_xxx constants below */
- char relkind BKI_DEFAULT(r);
+ char relkind BKI_DEFAULT(r) ATTNUM(17);
/* number of user attributes */
- int16 relnatts BKI_DEFAULT(0); /* genbki.pl will fill this in */
+ int16 relnatts BKI_DEFAULT(0) ATTNUM(18); /* genbki.pl will fill this in */
/*
* Class pg_attribute must contain exactly "relnatts" user attributes
@@ -93,51 +90,54 @@ CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,Relat
*/
/* # of CHECK constraints for class */
- int16 relchecks BKI_DEFAULT(0);
+ int16 relchecks BKI_DEFAULT(0) ATTNUM(19);
/* has (or has had) any rules */
- bool relhasrules BKI_DEFAULT(f);
+ bool relhasrules BKI_DEFAULT(f) ATTNUM(20);
/* has (or has had) any TRIGGERs */
- bool relhastriggers BKI_DEFAULT(f);
+ bool relhastriggers BKI_DEFAULT(f) ATTNUM(21);
/* has (or has had) child tables or indexes */
- bool relhassubclass BKI_DEFAULT(f);
+ bool relhassubclass BKI_DEFAULT(f) ATTNUM(22);
/* row security is enabled or not */
- bool relrowsecurity BKI_DEFAULT(f);
+ bool relrowsecurity BKI_DEFAULT(f) ATTNUM(23);
/* row security forced for owners or not */
- bool relforcerowsecurity BKI_DEFAULT(f);
+ bool relforcerowsecurity BKI_DEFAULT(f) ATTNUM(24);
/* matview currently holds query results */
- bool relispopulated BKI_DEFAULT(t);
+ bool relispopulated BKI_DEFAULT(t) ATTNUM(25);
/* see REPLICA_IDENTITY_xxx constants */
- char relreplident BKI_DEFAULT(n);
+ char relreplident BKI_DEFAULT(n) ATTNUM(26);
/* is relation a partition? */
- bool relispartition BKI_DEFAULT(f);
+ bool relispartition BKI_DEFAULT(f) ATTNUM(27);
/* link to original rel during table rewrite; otherwise 0 */
- Oid relrewrite BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_class);
+ Oid relrewrite BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_class) ATTNUM(28);
/* all Xids < this are frozen in this rel */
- TransactionId relfrozenxid BKI_DEFAULT(3); /* FirstNormalTransactionId */
+ TransactionId relfrozenxid BKI_DEFAULT(3) ATTNUM(29); /* FirstNormalTransactionId */
+
+ /* class name */
+ NameData relname ATTNUM(2);
/* all multixacts in this rel are >= this; it is really a MultiXactId */
- TransactionId relminmxid BKI_DEFAULT(1); /* FirstMultiXactId */
+ TransactionId relminmxid BKI_DEFAULT(1) ATTNUM(30); /* FirstMultiXactId */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
/* NOTE: These fields are not present in a relcache entry's rd_rel field. */
/* access permissions */
- aclitem relacl[1] BKI_DEFAULT(_null_);
+ aclitem relacl[1] BKI_DEFAULT(_null_) ATTNUM(31);
/* access-method-specific options */
- text reloptions[1] BKI_DEFAULT(_null_);
+ text reloptions[1] BKI_DEFAULT(_null_) ATTNUM(32);
/* partition bound node tree */
- pg_node_tree relpartbound BKI_DEFAULT(_null_);
+ pg_node_tree relpartbound BKI_DEFAULT(_null_) ATTNUM(33);
#endif
} FormData_pg_class;
--
2.33.1
v1-0004-Debugging-automatically-shuffle-all-table-attribu.patchtext/plain; charset=us-asciiDownload
From e768be9c2601efa8f12f386e491a4fc4ff4cf098 Mon Sep 17 00:00:00 2001
From: Julien Rouhaud <julien.rouhaud@free.fr>
Date: Sun, 5 Jun 2022 03:06:55 +0800
Subject: [PATCH v1 4/5] Debugging: automatically shuffle all table attributes
physical position.
Author: Julien Rouhaud
Reviewed-by: FIXME
Discussion: FIXME
---
src/backend/commands/tablecmds.c | 55 ++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 007e355d9d..06b9733717 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -635,6 +635,18 @@ static void ATDetachCheckNoForeignKeyRefs(Relation partition);
static char GetAttributeCompression(Oid atttypid, char *compression);
+static int
+cmp_att_reversed(const void *a, const void *b)
+{
+ FormData_pg_attribute *atta = (FormData_pg_attribute *) a;
+ FormData_pg_attribute *attb = (FormData_pg_attribute *) b;
+
+ return (atta->attphysnum > attb->attphysnum) ? -1
+ : (atta->attphysnum == attb->attphysnum) ? 0
+ : 1;
+}
+
+
/* ----------------------------------------------------------------
* DefineRelation
* Creates a new relation.
@@ -933,6 +945,49 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
colDef->compression);
}
+ /*
+ * FIXME
+ * testing mode: inverse all attribute positions. This has to be done
+ * after that defaults have been computed.
+ */
+ if (relkind == RELKIND_RELATION && inheritOids == NIL
+ && descriptor->natts > 1
+ /* lame attempt to discard CTAS */
+ && queryString != NULL)
+ {
+ AttrNumber *mappings;
+
+ mappings = palloc(sizeof(AttrNumber) * (descriptor->natts + 1));
+
+ qsort(descriptor->attrs, descriptor->natts,
+ sizeof(FormData_pg_attribute),
+ cmp_att_reversed);
+
+ for (int i = 0; i < descriptor->natts; i++)
+ {
+ Form_pg_attribute att = TupleDescAttr(descriptor, i);
+
+ mappings[att->attphysnum] = i + 1;
+
+ att->attnum = att->attphysnum;
+ att->attphysnum = i + 1;
+ }
+
+ /* Fixup the defautls references */
+ foreach(listptr, rawDefaults)
+ {
+ RawColumnDefault *rowEnt = lfirst(listptr);
+
+ rowEnt->attphysnum = mappings[rowEnt->attphysnum];
+ }
+ foreach(listptr, cookedDefaults)
+ {
+ CookedConstraint *cooked = lfirst(listptr);
+
+ cooked->attphysnum = mappings[cooked->attphysnum];
+ }
+ }
+
/*
* If the statement hasn't specified an access method, but we're defining
* a type of relation that needs one, use the default.
--
2.33.1
v1-0005-POC-Add-naive-grammar-to-specify-the-column-logic.patchtext/plain; charset=us-asciiDownload
From a2243303e93a997b2d7bf4f288cb48db63082798 Mon Sep 17 00:00:00 2001
From: Julien Rouhaud <julien.rouhaud@free.fr>
Date: Tue, 7 Jun 2022 18:46:06 +0800
Subject: [PATCH v1 5/5] POC: Add naive grammar to specify the column logical
order in CREATE TABLE
e.g.:
CREATE TABLE ab (b integer, a integer) ORDER (a, b).
Author: Julien Rouhaud
Reviewed-by: FIXME
Discussion: FIXME
---
src/backend/commands/tablecmds.c | 39 +++++++++++++++++++++++++++++-
src/backend/nodes/copyfuncs.c | 1 +
src/backend/nodes/equalfuncs.c | 1 +
src/backend/nodes/outfuncs.c | 1 +
src/backend/parser/gram.y | 41 +++++++++++++++++++++++++++-----
src/include/nodes/parsenodes.h | 1 +
6 files changed, 77 insertions(+), 7 deletions(-)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 06b9733717..660a18c638 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -945,12 +945,49 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
colDef->compression);
}
+ /* Change rels logical attributes position if needed */
+ if (stmt->orderElts != NIL)
+ {
+ if (list_length(stmt->orderElts) != descriptor->natts)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
+ errmsg("Invalid number of elements in ORDER clause"),
+ errdetail("expected %d, found %d", descriptor->natts,
+ list_length(stmt->orderElts))));
+
+ for (int i = 0; i < descriptor->natts; i++)
+ {
+ Form_pg_attribute att = TupleDescAttr(descriptor, i);
+ ListCell *lc;
+ AttrNumber attnum = 1;
+ bool found = false;
+
+ foreach(lc, stmt->orderElts)
+ {
+ char *colname = strVal(lfirst(lc));
+
+ if (strcmp(colname, NameStr(att->attname)) == 0)
+ {
+ found = true;
+ att->attnum = attnum;
+ break;
+ }
+ attnum++;
+ }
+
+ if (!found)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
+ errmsg("order attribute \"%s\" not found in \"%s\" attributes",
+ NameStr(att->attname), relname)));
+ }
+ }
/*
* FIXME
* testing mode: inverse all attribute positions. This has to be done
* after that defaults have been computed.
*/
- if (relkind == RELKIND_RELATION && inheritOids == NIL
+ else if (relkind == RELKIND_RELATION && inheritOids == NIL
&& descriptor->natts > 1
/* lame attempt to discard CTAS */
&& queryString != NULL)
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 68c6fb7c93..07dc422101 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -4065,6 +4065,7 @@ CopyCreateStmtFields(const CreateStmt *from, CreateStmt *newnode)
{
COPY_NODE_FIELD(relation);
COPY_NODE_FIELD(tableElts);
+ COPY_NODE_FIELD(orderElts);
COPY_NODE_FIELD(inhRelations);
COPY_NODE_FIELD(partspec);
COPY_NODE_FIELD(partbound);
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index d9ca25606b..bab8abfb02 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -1647,6 +1647,7 @@ _equalCreateStmt(const CreateStmt *a, const CreateStmt *b)
{
COMPARE_NODE_FIELD(relation);
COMPARE_NODE_FIELD(tableElts);
+ COMPARE_NODE_FIELD(orderElts);
COMPARE_NODE_FIELD(inhRelations);
COMPARE_NODE_FIELD(partbound);
COMPARE_NODE_FIELD(partspec);
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index d80d18cfca..65dbe6ea20 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -2870,6 +2870,7 @@ _outCreateStmtInfo(StringInfo str, const CreateStmt *node)
{
WRITE_NODE_FIELD(relation);
WRITE_NODE_FIELD(tableElts);
+ WRITE_NODE_FIELD(orderElts);
WRITE_NODE_FIELD(inhRelations);
WRITE_NODE_FIELD(partspec);
WRITE_NODE_FIELD(partbound);
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 969c9c158f..c24adf59de 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -425,6 +425,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> parse_toplevel stmtmulti routine_body_stmt_list
OptTableElementList TableElementList OptInherit definition
+ OptOrderElementList OrderElementList
OptTypedTableElementList TypedTableElementList
reloptions opt_reloptions
OptWith opt_definition func_args func_args_list
@@ -524,6 +525,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
SetResetClause FunctionSetResetClause
%type <node> TableElement TypedTableElement ConstraintElem TableFuncElement
+ OrderElement
%type <node> columnDef columnOptions
%type <defelt> def_elem reloption_elem old_aggr_elem operator_def_elem
%type <node> def_arg columnElem where_clause where_or_current_clause
@@ -3577,6 +3579,7 @@ copy_generic_opt_arg_list_item:
*****************************************************************************/
CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
+ OptOrderElementList
OptInherit OptPartitionSpec table_access_method_clause OptWith
OnCommitOption OptTableSpace
{
@@ -3585,14 +3588,15 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
$4->relpersistence = $2;
n->relation = $4;
n->tableElts = $6;
- n->inhRelations = $8;
- n->partspec = $9;
+ n->orderElts = $8;
+ n->inhRelations = $9;
+ n->partspec = $10;
n->ofTypename = NULL;
n->constraints = NIL;
- n->accessMethod = $10;
- n->options = $11;
- n->oncommit = $12;
- n->tablespacename = $13;
+ n->accessMethod = $11;
+ n->options = $12;
+ n->oncommit = $13;
+ n->tablespacename = $14;
n->if_not_exists = false;
$$ = (Node *) n;
}
@@ -3605,6 +3609,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
$7->relpersistence = $2;
n->relation = $7;
n->tableElts = $9;
+ n->orderElts = NIL;
n->inhRelations = $11;
n->partspec = $12;
n->ofTypename = NULL;
@@ -3625,6 +3630,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
$4->relpersistence = $2;
n->relation = $4;
n->tableElts = $7;
+ n->orderElts = NIL;
n->inhRelations = NIL;
n->partspec = $8;
n->ofTypename = makeTypeNameFromNameList($6);
@@ -3646,6 +3652,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
$7->relpersistence = $2;
n->relation = $7;
n->tableElts = $10;
+ n->orderElts = NIL;
n->inhRelations = NIL;
n->partspec = $11;
n->ofTypename = makeTypeNameFromNameList($9);
@@ -3667,6 +3674,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
$4->relpersistence = $2;
n->relation = $4;
n->tableElts = $8;
+ n->orderElts = NIL;
n->inhRelations = list_make1($7);
n->partbound = $9;
n->partspec = $10;
@@ -3688,6 +3696,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
$7->relpersistence = $2;
n->relation = $7;
n->tableElts = $11;
+ n->orderElts = NIL;
n->inhRelations = list_make1($10);
n->partbound = $12;
n->partspec = $13;
@@ -3735,6 +3744,26 @@ OptTemp: TEMPORARY { $$ = RELPERSISTENCE_TEMP; }
| /*EMPTY*/ { $$ = RELPERSISTENCE_PERMANENT; }
;
+OptOrderElementList:
+ ORDER '(' OrderElementList ')' { $$ = $3; }
+ | /*EMPTY*/ { $$ = NIL; }
+ ;
+
+OrderElementList:
+ OrderElement
+ {
+ $$ = list_make1($1);
+ }
+ | OrderElementList ',' OrderElement
+ {
+ $$ = lappend($1, $3);
+ }
+ ;
+
+OrderElement:
+ columnElem { $$ = $1; }
+ ;
+
OptTableElementList:
TableElementList { $$ = $1; }
| /*EMPTY*/ { $$ = NIL; }
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 73f635b455..0f39d72f6f 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2530,6 +2530,7 @@ typedef struct CreateStmt
NodeTag type;
RangeVar *relation; /* relation to create */
List *tableElts; /* column definitions (list of ColumnDef) */
+ List *orderElts; /* column logical order (list of String) */
List *inhRelations; /* relations to inherit from (list of
* RangeVar) */
PartitionBoundSpec *partbound; /* FOR VALUES clause */
--
2.33.1
Hi,
On 2022-06-03 13:28:16 +0700, John Naylor wrote:
1. That would require putting the name physically closer to the end of
the column list. To make this less annoying for users, we'd need to
separate physical order from display order (at least/at first only for
system catalogs).
FWIW, it's not at all clear to me that this would be required. If I were to
tackle this I'd look at breaking up the mirroring of C structs to catalog
struct layout, by having genbki (or such) generate functions to map to/from
tuple layout. It'll be an annoying amount of changes, but feasible, I think.
This would require:
- changing star expansion in SELECTs (expandRTE etc)
- adjusting pg_dump, \d, etcThat much seems clear and agreed upon.
FWIW, I don't agree that this is a reasonable way to tackle changing
NAMEDATALEN. It'd be nice to have, but it to me it seems a pretty small
fraction of the problem of making Names variable length. You'll still have all
the problems of name fields being accessed all over, but now not being
included in the part of the struct visible to C etc.
Greetings,
Andres Freund
On Thu, Jun 23, 2022 at 6:13 AM Julien Rouhaud <rjuju123@gmail.com> wrote:
While some problem wouldn't happen if we restricted the feature to system
catalogs only (e.g. with renamed / dropped attributes, inheritance...), a lot
would still exist and would have to be dealt with initially. However I'm not
sure what behavior would be wanted or acceptable, especially if we want
something that can eventually be used for user relations too, with possibly
dynamic positions.
I am not very convinced that this would make the project a whole lot
easier, but it does seem like the result would be less nice.
I'll describe some of those problems, and just to make things easier I will use
a normal table "ab" with 2 attributes, a and b, with their physical / logical
position reversed.Obviously
SELECT * FROM ab
should return a and b in that order. The aliases should also probably match
the logical position, as in:SELECT * FROM ab ab(aa, bb)
should probably map aa to a and bb to b.
Check.
But should COPY FROM / COPY TO / INSERT INTO use the logical position too if
not column list is provided? I'd think so, but it goes further from the
original "only handle star expansion" idea.
I think yes.
And should record_in / record_out use the logical position, as in:
SELECT ab::text FROM ab / SELECT (a, b)::ab;I would think not, as relying on a possibly dynamic order could break things if
you store the results somewhere, but YMMV.
I think here the answer is yes again. I mean, consider that you could
also ALTER TABLE DROP COLUMN and then ALTER TABLE ADD COLUMN with the
same name. That is surely going to affect the meaning of such things.
I don't think we want to have one meaning if you reorder things that
way and a different meaning if you reorder things using whatever
commands we create for changing the display column positions.
Note that there a variations of that, like
SELECT ab::ab FROM (SELECT * FROM ab) ab;But those should probably work as intended (for now it doesn't) as you can't
store a bare record, and storing a plain "ab" type wouldn't be problematic with
dynamic changes.
If the sub-SELECT and the cast both use the display order, which I
think they should, then there's no problem here, I believe.
Then, what about joinrels expansion? I learned that the column ordering rules
are far from being obvious, and I didn't find those in the documentation (note
that I don't know if that something actually described in the SQL standard).
So for instance, if a join is using an explicit USING clause rather than an ON
clause, the merged columns are expanded first, so:SELECT * FROM ab ab1 JOIN ab ab2 USING (b)
should unexpectedly expand to (b, a, a). Is this order a strict requirement?
I dunno, but I can't see why it creates a problem for this patch to
maintain the current behavior. I mean, just use the logical column
position instead of the physical one here and forget about the details
of how it works beyond that.
Another problem (that probably wouldn't be a problem for system catalogs) is
that defaults are evaluated in the physical position. This example from the
regression test will clearly have a different behavior if the columns are in a
different physical order:CREATE TABLE INSERT_TBL (
x INT DEFAULT nextval('insert_seq'),
y TEXT DEFAULT '-NULL-',
z INT DEFAULT -1 * currval('insert_seq'),
CONSTRAINT INSERT_TBL_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8),
CHECK (x + z = 0));But changing the behavior to rely on the logical position seems quite
dangerous.
Why?
--
Robert Haas
EDB: http://www.enterprisedb.com
On Thu, Jun 23, 2022 at 10:17 AM Andres Freund <andres@anarazel.de> wrote:
This would require:
- changing star expansion in SELECTs (expandRTE etc)
- adjusting pg_dump, \d, etcThat much seems clear and agreed upon.
FWIW, I don't agree that this is a reasonable way to tackle changing
NAMEDATALEN. It'd be nice to have, but it to me it seems a pretty small
fraction of the problem of making Names variable length. You'll still have all
the problems of name fields being accessed all over, but now not being
included in the part of the struct visible to C etc.
Yeah, I agree. I think that being able to reorder columns logically
without changing anything physically would be cool, but I think we
could find some way of making the catalog columns variable-length
without introducing that feature.
I'm not sure whether your idea of creating translator functions is a
good one or not, but it doesn't seem too crazy. It'd be like a special
purpose tuple deformer.
deform_pg_class_tuple(&pg_class_struct, pg_class_tuple);
The code in there could be automatically generated statements that
maybe look like this:
memcpy(&struct.relnamespace, tuple + Aoffset_pg_class_relnamespace,
sizeof(Oid));
Once you hit the first variable-length field you'd need something more
clever, but because the code would be specialized for each catalog, it
would probably be quite fast anyway.
--
Robert Haas
EDB: http://www.enterprisedb.com
Robert Haas <robertmhaas@gmail.com> writes:
On Thu, Jun 23, 2022 at 10:17 AM Andres Freund <andres@anarazel.de> wrote:
FWIW, I don't agree that this is a reasonable way to tackle changing
NAMEDATALEN. It'd be nice to have, but it to me it seems a pretty small
fraction of the problem of making Names variable length. You'll still have all
the problems of name fields being accessed all over, but now not being
included in the part of the struct visible to C etc.
Yeah, I agree. I think that being able to reorder columns logically
without changing anything physically would be cool, but I think we
could find some way of making the catalog columns variable-length
without introducing that feature.
Agreed. Bearing in mind that multiple smart people have tackled that idea
and gotten nowhere, I think setting it as a prerequisite for this project
is a good way of ensuring this won't happen.
I'm not sure whether your idea of creating translator functions is a
good one or not, but it doesn't seem too crazy. It'd be like a special
purpose tuple deformer.
Sounds worth investigating, anyway. It'd also get us out from under
C-struct-related problems such as the nearby AIX alignment issue.
The extra cost of the deforming step could also be repaid, in some
cases, by not having to use SysCacheGetAttr etc later on to fetch
variable-length fields. That is, I'm imagining that the deformer
would extract all the fields, even varlena ones, and drop pointers
or whatever into fields of the C struct.
regards, tom lane
On Thu, Jun 23, 2022 at 2:07 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Sounds worth investigating, anyway. It'd also get us out from under
C-struct-related problems such as the nearby AIX alignment issue.
Yeah.
The extra cost of the deforming step could also be repaid, in some
cases, by not having to use SysCacheGetAttr etc later on to fetch
variable-length fields. That is, I'm imagining that the deformer
would extract all the fields, even varlena ones, and drop pointers
or whatever into fields of the C struct.
Yeah, if we were going to do something like this, I can't see why we
wouldn't do it this way. It wouldn't make sense to do it for only some
of the attributes.
I'm not sure exactly where we would put this translation step, though.
I think for the syscaches and relcache we'd want to translate when
populating the cache so that when you do a cache lookup you get the
data already translated. It's hard to be sure without testing, but
that seems like it would make this cheap enough that we wouldn't have
to be too worried, since the number of times we build new cache
entries should be small compared to the number of times we access
existing ones. The trickier thing might be code that uses
systable_beginscan() et. al. directly.
--
Robert Haas
EDB: http://www.enterprisedb.com
Hi,
On 2022-06-23 14:42:17 -0400, Robert Haas wrote:
On Thu, Jun 23, 2022 at 2:07 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
The extra cost of the deforming step could also be repaid, in some
cases, by not having to use SysCacheGetAttr etc later on to fetch
variable-length fields. That is, I'm imagining that the deformer
would extract all the fields, even varlena ones, and drop pointers
or whatever into fields of the C struct.
I was also thinking we'd translate all attributes. Not entirely sure whether
we'd want to use "plain" pointers though - there are some places where we rely
on being able to copy such structs around. That'd be a bit easier with
relative pointers, pointing to the end of the struct. But likely the
notational overhead of dealing with relative pointers would be far higher than
the notational overhead of having to invoke a generated "tuple struct" copy
function. Which we'd likely need anyway, because some previously statically
sized allocations would end up being variable sized?
Yeah, if we were going to do something like this, I can't see why we
wouldn't do it this way. It wouldn't make sense to do it for only some
of the attributes.
Agreed.
I'm not sure exactly where we would put this translation step, though.
I think for the syscaches and relcache we'd want to translate when
populating the cache so that when you do a cache lookup you get the
data already translated. It's hard to be sure without testing, but
that seems like it would make this cheap enough that we wouldn't have
to be too worried, since the number of times we build new cache
entries should be small compared to the number of times we access
existing ones. The trickier thing might be code that uses
systable_beginscan() et. al. directly.
I was thinking we'd basically do it wherever we do a GETSTRUCT() today.
A first step could be to transform code like
(Form_pg_attribute) GETSTRUCT(tuple)
into
GETSTRUCT(pg_attribute, tuple)
then, in a subsequent step, we'd redefine GETSTRUCT as something
#define GESTRUCT(catalog, tuple) tuple_to_struct_##catalog(tuple)
Greetings,
Andres Freund
On Thu, Jun 23, 2022 at 5:49 PM Andres Freund <andres@anarazel.de> wrote:
I was thinking we'd basically do it wherever we do a GETSTRUCT() today.
A first step could be to transform code like
(Form_pg_attribute) GETSTRUCT(tuple)
into
GETSTRUCT(pg_attribute, tuple)then, in a subsequent step, we'd redefine GETSTRUCT as something
#define GESTRUCT(catalog, tuple) tuple_to_struct_##catalog(tuple)
That seems a little fraught, because you'd be turning what's now
basically a trivial operation into a non-trivial operation involving
memory allocation.
--
Robert Haas
EDB: http://www.enterprisedb.com
Robert Haas <robertmhaas@gmail.com> writes:
On Thu, Jun 23, 2022 at 5:49 PM Andres Freund <andres@anarazel.de> wrote:
I was thinking we'd basically do it wherever we do a GETSTRUCT() today.
That seems a little fraught, because you'd be turning what's now
basically a trivial operation into a non-trivial operation involving
memory allocation.
Nonetheless, the presence of GETSTRUCT calls should be a good guide
to where we need to do something.
regards, tom lane
On Thu, Jun 23, 2022 at 9:17 PM Andres Freund <andres@anarazel.de> wrote:
Hi,
On 2022-06-03 13:28:16 +0700, John Naylor wrote:
1. That would require putting the name physically closer to the end of
the column list. To make this less annoying for users, we'd need to
separate physical order from display order (at least/at first only for
system catalogs).FWIW, it's not at all clear to me that this would be required. If I were to
tackle this I'd look at breaking up the mirroring of C structs to catalog
struct layout, by having genbki (or such) generate functions to map to/from
tuple layout. It'll be an annoying amount of changes, but feasible, I think.
Hmm, I must have misunderstood this aspect. In my mind I was thinking
that if a varlen attribute were at the end, these functions would make
it easier to access them quickly. But from this and the follow-on
responses, these would be used to access varlen attributes wherever
they may be. I'll take a look at the current uses of GETSTRUCT().
--
John Naylor
EDB: http://www.enterprisedb.com
On Thu, Jun 23, 2022 at 6:43 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Nonetheless, the presence of GETSTRUCT calls should be a good guide
to where we need to do something.
Indubitably.
--
Robert Haas
EDB: http://www.enterprisedb.com
On Thu, Jun 23, 2022 at 11:11 PM John Naylor
<john.naylor@enterprisedb.com> wrote:
Hmm, I must have misunderstood this aspect. In my mind I was thinking
that if a varlen attribute were at the end, these functions would make
it easier to access them quickly. But from this and the follow-on
responses, these would be used to access varlen attributes wherever
they may be. I'll take a look at the current uses of GETSTRUCT().
I don't know whether we can or should move all the "name" columns to
the end of the catalog. It would be user-visible and probably not
user-desirable, but it would save something in terms of tuple
deforming cost. I'm just not sure how much.
--
Robert Haas
EDB: http://www.enterprisedb.com
Robert Haas <robertmhaas@gmail.com> writes:
I don't know whether we can or should move all the "name" columns to
the end of the catalog. It would be user-visible and probably not
user-desirable,
I'm a strong -1 on changing that if we're not absolutely forced to.
but it would save something in terms of tuple
deforming cost. I'm just not sure how much.
I'd guess nothing, if we are deforming all the fields.
regards, tom lane
On Thu, Jun 23, 2022 at 10:19:44AM -0400, Robert Haas wrote:
On Thu, Jun 23, 2022 at 6:13 AM Julien Rouhaud <rjuju123@gmail.com> wrote:
And should record_in / record_out use the logical position, as in:
SELECT ab::text FROM ab / SELECT (a, b)::ab;I would think not, as relying on a possibly dynamic order could break things if
you store the results somewhere, but YMMV.I think here the answer is yes again. I mean, consider that you could
also ALTER TABLE DROP COLUMN and then ALTER TABLE ADD COLUMN with the
same name. That is surely going to affect the meaning of such things.
I don't think we want to have one meaning if you reorder things that
way and a different meaning if you reorder things using whatever
commands we create for changing the display column positions.
It indeed would, but ALTER TABLE DROP COLUMN is a destructive operation, and
I'm assuming that anyone doing that is aware that it will have an impact on
stored data and such. I initially thought that changing the display order of
columns shouldn't have the same impact with the stability of otherwise
unchanged record definition, as it would make such reorder much more impacting.
But I agree that having different behaviors seems worse.
Then, what about joinrels expansion? I learned that the column ordering rules
are far from being obvious, and I didn't find those in the documentation (note
that I don't know if that something actually described in the SQL standard).
So for instance, if a join is using an explicit USING clause rather than an ON
clause, the merged columns are expanded first, so:SELECT * FROM ab ab1 JOIN ab ab2 USING (b)
should unexpectedly expand to (b, a, a). Is this order a strict requirement?
I dunno, but I can't see why it creates a problem for this patch to
maintain the current behavior. I mean, just use the logical column
position instead of the physical one here and forget about the details
of how it works beyond that.
I'm not that familiar with this part of the code so I may have missed
something, but I didn't see any place where I could just simply do that.
To be clear, the approach I used is to change the expansion ordering but
otherwise keep the current behavior, to try to minimize the changes. This is
done by keeping the attribute in the physical ordering pretty much everywhere,
including in the nsitems, and just logically reorder them during the expansion.
In other words all the code still knows that the 1st column is the first
physical column and so on.
So in that query, the ordering is supposed to happen when handling the "SELECT
*", which makes it impossible to retain that order.
I'm assuming that what you meant is to change the ordering when processing the
JOIN and retain the old "SELECT *" behavior, which is to emit items in the
order they're found. But IIUC the only way to do that would be to change the
order when building the nsitems themselves, and have the code believe that the
attributes are physically stored in the logical order. That's probably doable,
but that looks like a way more impacting change. Or did you mean to keep the
approach I used, and just have some special case for "SELECT *" when referring
to a joinrel and instead try to handle the logical expansion in the join?
AFAICS it would require to add some extra info in the parsing structures, as it
doesn't really really store any position, just relies on array offset / list
position and maps things that way.
Another problem (that probably wouldn't be a problem for system catalogs) is
that defaults are evaluated in the physical position. This example from the
regression test will clearly have a different behavior if the columns are in a
different physical order:CREATE TABLE INSERT_TBL (
x INT DEFAULT nextval('insert_seq'),
y TEXT DEFAULT '-NULL-',
z INT DEFAULT -1 * currval('insert_seq'),
CONSTRAINT INSERT_TBL_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8),
CHECK (x + z = 0));But changing the behavior to rely on the logical position seems quite
dangerous.Why?
It feels to me like a POLA violation, and probably people wouldn't expect it to
behave this way (even if this is clearly some corner case problem). Even if
you argue that this is not simply a default display order but something more
like real column order, the physical position being some implementation detail,
it still doesn't really feels right.
The main reason for having the possibility to change the logical position is to
have "better looking", easier to work with, relations even if you have some
requirements with the real physical order like trying to optimize things as
much as possible (reordering columns to avoid padding space, put non-nullable
columns first...). The order in which defaults are evaluated looks like the
same kind of requirements. How useful would it be if you could chose a logical
order, but not being able to chose the one you actually want because it would
break your default values?
Anyway, per the nearby discussions I don't see much interest, especially not in
the context of varlena identifiers (I should have started a different thread,
sorry about that), so I don't think it's worth investing more efforts into it.
Hi,
On 2022-06-26 10:48:24 +0800, Julien Rouhaud wrote:
Anyway, per the nearby discussions I don't see much interest, especially not in
the context of varlena identifiers (I should have started a different thread,
sorry about that), so I don't think it's worth investing more efforts into
it.
FWIW, I still think it's a worthwhile feature - just, to me, unrelated to
varlena identifiers. I've seen tremendous amounts of space wasted in tables
just because of alignment issues...
- Andres
On Sat, Jun 25, 2022 at 08:00:04PM -0700, Andres Freund wrote:
On 2022-06-26 10:48:24 +0800, Julien Rouhaud wrote:
Anyway, per the nearby discussions I don't see much interest, especially not in
the context of varlena identifiers (I should have started a different thread,
sorry about that), so I don't think it's worth investing more efforts into
it.FWIW, I still think it's a worthwhile feature
Oh, ok, I will start a new thread then.
- just, to me, unrelated to varlena identifiers.
Yeah I get that and I agree.
I've seen tremendous amounts of space wasted in tables
just because of alignment issues...
Same here unfortunately.
On Fri, Jun 24, 2022 at 4:49 AM Andres Freund <andres@anarazel.de> wrote:
A first step could be to transform code like
(Form_pg_attribute) GETSTRUCT(tuple)
into
GETSTRUCT(pg_attribute, tuple)
To get the ball rolling, I've done this much in 0001. This is an easy
mechanical change, although we'll next want a third argument to pass
the Form_* pointer.
0002 changes this macro to
#define GETSTRUCT(CAT, TUP) Deform_##CAT##_tuple((char *)
((TUP)->t_data) + (TUP)->t_data->t_hoff)
...where genbki.pl generates stub macros in the form of
#define Deform_pg_am_tuple(TUP) (Form_pg_am) (TUP)
...which live in pg_*_deform.h and are #included into each main
catalog header after the Form_* is defined. Feedback on whether a more
tasteful way should be sought would be appreciated.
While not very interesting on its own, it gives an idea of how the
build would work. Next step would be to turn these into functions like
static inline void
Deform_pg_am_tuple(Form_pg_am, char * tuple)
{...}
that just memcpy() things over as already discussed, adjusting the
callers of GETSTRUCT to match. This won't be quite as mechanical and
will require some manual work since some not least because some call
sites mix declaration and assignment. I imagine there will also be a
need for the inverse operation, forming a tuple from a struct.
We will also have to take care to work around cases where the Form_*
pointer is currently used for in-place updates. I imagine there are
not many, but they will require extra care. The pseudo-catalog
pg_sequence_data is an example, and a bit of a special case anyway.
On Fri, Jun 24, 2022 at 1:07 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Sounds worth investigating, anyway. It'd also get us out from under
C-struct-related problems such as the nearby AIX alignment issue.
Getting around that issue sounds like a good first goal for committing.
--
John Naylor
EDB: http://www.enterprisedb.com
Attachments:
v1-0002-Generate-stubs-for-catalog-tuple-deforming-functi.patchapplication/x-patch; name=v1-0002-Generate-stubs-for-catalog-tuple-deforming-functi.patchDownload
From 0f03edfaf02611c13deba1f4e5179d59a2bd2ff1 Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Sun, 10 Jul 2022 14:33:51 +0700
Subject: [PATCH v1 2/2] Generate stubs for catalog tuple deforming functions
These are just the same macros as before, but gives some idea
how this would work. Manual work needed for FormData_pg_sequence_data,
since it's not a catalog in the usual sense, but we still need to
form/deform tuples for it.
---
src/backend/catalog/Makefile | 2 +-
src/backend/catalog/genbki.pl | 25 ++++++++++++++++++-
src/include/access/htup_details.h | 2 +-
src/include/catalog/pg_aggregate.h | 3 +++
src/include/catalog/pg_am.h | 3 +++
src/include/catalog/pg_amop.h | 3 +++
src/include/catalog/pg_amproc.h | 3 +++
src/include/catalog/pg_attrdef.h | 3 +++
src/include/catalog/pg_attribute.h | 3 +++
src/include/catalog/pg_auth_members.h | 3 +++
src/include/catalog/pg_authid.h | 3 +++
src/include/catalog/pg_cast.h | 3 +++
src/include/catalog/pg_class.h | 3 +++
src/include/catalog/pg_collation.h | 3 +++
src/include/catalog/pg_constraint.h | 3 +++
src/include/catalog/pg_conversion.h | 3 +++
src/include/catalog/pg_database.h | 3 +++
src/include/catalog/pg_db_role_setting.h | 3 +++
src/include/catalog/pg_default_acl.h | 3 +++
src/include/catalog/pg_depend.h | 3 +++
src/include/catalog/pg_description.h | 3 +++
src/include/catalog/pg_enum.h | 3 +++
src/include/catalog/pg_event_trigger.h | 3 +++
src/include/catalog/pg_extension.h | 3 +++
src/include/catalog/pg_foreign_data_wrapper.h | 3 +++
src/include/catalog/pg_foreign_server.h | 3 +++
src/include/catalog/pg_foreign_table.h | 3 +++
src/include/catalog/pg_index.h | 3 +++
src/include/catalog/pg_inherits.h | 3 +++
src/include/catalog/pg_init_privs.h | 3 +++
src/include/catalog/pg_language.h | 3 +++
src/include/catalog/pg_largeobject.h | 3 +++
src/include/catalog/pg_largeobject_metadata.h | 3 +++
src/include/catalog/pg_namespace.h | 3 +++
src/include/catalog/pg_opclass.h | 3 +++
src/include/catalog/pg_operator.h | 3 +++
src/include/catalog/pg_opfamily.h | 3 +++
src/include/catalog/pg_parameter_acl.h | 3 +++
src/include/catalog/pg_partitioned_table.h | 3 +++
src/include/catalog/pg_policy.h | 3 +++
src/include/catalog/pg_proc.h | 3 +++
src/include/catalog/pg_publication.h | 3 +++
.../catalog/pg_publication_namespace.h | 3 +++
src/include/catalog/pg_publication_rel.h | 3 +++
src/include/catalog/pg_range.h | 3 +++
src/include/catalog/pg_replication_origin.h | 3 +++
src/include/catalog/pg_rewrite.h | 3 +++
src/include/catalog/pg_sequence.h | 3 +++
src/include/catalog/pg_shdepend.h | 3 +++
src/include/catalog/pg_shdescription.h | 3 +++
src/include/catalog/pg_shseclabel.h | 3 +++
src/include/catalog/pg_statistic.h | 3 +++
src/include/catalog/pg_statistic_ext.h | 3 +++
src/include/catalog/pg_statistic_ext_data.h | 3 +++
src/include/catalog/pg_subscription.h | 3 +++
src/include/catalog/pg_subscription_rel.h | 3 +++
src/include/catalog/pg_tablespace.h | 3 +++
src/include/catalog/pg_transform.h | 3 +++
src/include/catalog/pg_trigger.h | 3 +++
src/include/catalog/pg_ts_config.h | 3 +++
src/include/catalog/pg_ts_config_map.h | 3 +++
src/include/catalog/pg_ts_dict.h | 3 +++
src/include/catalog/pg_ts_parser.h | 3 +++
src/include/catalog/pg_ts_template.h | 3 +++
src/include/catalog/pg_type.h | 3 +++
src/include/catalog/pg_user_mapping.h | 3 +++
src/include/commands/sequence.h | 3 +++
67 files changed, 218 insertions(+), 3 deletions(-)
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 89a0221ec9..d7bca52391 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -74,7 +74,7 @@ CATALOG_HEADERS := \
pg_sequence.h pg_publication.h pg_publication_namespace.h \
pg_publication_rel.h pg_subscription.h pg_subscription_rel.h
-GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h system_fk_info.h
+GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) $(CATALOG_HEADERS:%.h=%_deform.h) schemapg.h system_fk_info.h
POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/, $(CATALOG_HEADERS))
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index 17b2c5e3f3..ad7a3aebd6 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -440,6 +440,11 @@ foreach my $catname (@catnames)
open my $def, '>', $def_file . $tmpext
or die "can't open $def_file$tmpext: $!";
+ # Create one header with the tuple deforming function for each catalog.
+ my $deform_file = $output_path . $catname . '_deform.h';
+ open my $deform, '>', $deform_file . $tmpext
+ or die "can't open $deform_file$tmpext: $!";
+
# Opening boilerplate for pg_*_d.h
printf $def <<EOM, $catname, $catname, uc $catname, uc $catname;
/*-------------------------------------------------------------------------
@@ -462,6 +467,21 @@ foreach my $catname (@catnames)
#ifndef %s_D_H
#define %s_D_H
+EOM
+
+ # Opening boilerplate for pg_*_deform.h
+ printf $deform <<EOM, uc $catname, uc $catname;
+/* generated by src/backend/catalog/genbki.pl, do not edit */
+
+#ifndef %s_DEFORM_H
+#define %s_DEFORM_H
+
+EOM
+
+ # Emit tuple deforming function
+ # WIP: just the same macro we had before
+ print $deform <<EOM;
+#define Deform_$catname\_tuple(TUP) (Form_$catname) (TUP)
EOM
# Emit OID macros for catalog's OID and rowtype OID, if wanted
@@ -673,10 +693,13 @@ EOM
print $bki "close $catname\n";
printf $def "\n#endif\t\t\t\t\t\t\t/* %s_D_H */\n", uc $catname;
+ printf $deform "\n#endif\t\t\t\t\t\t\t/* %s_DEFORM_H */\n", uc $catname;
- # Close and rename definition header
+ # Close and rename per-catalog headers
close $def;
Catalog::RenameTempFile($def_file, $tmpext);
+ close $deform;
+ Catalog::RenameTempFile($deform_file, $tmpext);
}
# Any information needed for the BKI that is not contained in a pg_*.h header
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 7310e3b2b8..9d5bd76d7b 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -651,7 +651,7 @@ struct MinimalTupleData
/*
* GETSTRUCT - given a HeapTuple pointer, return address of the user data
*/
-#define GETSTRUCT(CAT, TUP) ((Form_##CAT) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff))
+#define GETSTRUCT(CAT, TUP) Deform_##CAT##_tuple((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)
/*
* Accessor macros to be used with HeapTuple pointers.
diff --git a/src/include/catalog/pg_aggregate.h b/src/include/catalog/pg_aggregate.h
index 593da9f76a..dae5116e2f 100644
--- a/src/include/catalog/pg_aggregate.h
+++ b/src/include/catalog/pg_aggregate.h
@@ -108,6 +108,9 @@ CATALOG(pg_aggregate,2600,AggregateRelationId)
*/
typedef FormData_pg_aggregate *Form_pg_aggregate;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_aggregate_deform.h"
+
DECLARE_TOAST(pg_aggregate, 4159, 4160);
DECLARE_UNIQUE_INDEX_PKEY(pg_aggregate_fnoid_index, 2650, AggregateFnoidIndexId, on pg_aggregate using btree(aggfnoid oid_ops));
diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h
index 50a68fe4c3..c3dcb48184 100644
--- a/src/include/catalog/pg_am.h
+++ b/src/include/catalog/pg_am.h
@@ -47,6 +47,9 @@ CATALOG(pg_am,2601,AccessMethodRelationId)
*/
typedef FormData_pg_am *Form_pg_am;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_am_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_am_name_index, 2651, AmNameIndexId, on pg_am using btree(amname name_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_am_oid_index, 2652, AmOidIndexId, on pg_am using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h
index 6c714b61ab..87e83b5760 100644
--- a/src/include/catalog/pg_amop.h
+++ b/src/include/catalog/pg_amop.h
@@ -87,6 +87,9 @@ CATALOG(pg_amop,2602,AccessMethodOperatorRelationId)
*/
typedef FormData_pg_amop *Form_pg_amop;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_amop_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_amop_fam_strat_index, 2653, AccessMethodStrategyIndexId, on pg_amop using btree(amopfamily oid_ops, amoplefttype oid_ops, amoprighttype oid_ops, amopstrategy int2_ops));
DECLARE_UNIQUE_INDEX(pg_amop_opr_fam_index, 2654, AccessMethodOperatorIndexId, on pg_amop using btree(amopopr oid_ops, amoppurpose char_ops, amopfamily oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_amop_oid_index, 2756, AccessMethodOperatorOidIndexId, on pg_amop using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h
index f529fc6053..10026093c8 100644
--- a/src/include/catalog/pg_amproc.h
+++ b/src/include/catalog/pg_amproc.h
@@ -67,6 +67,9 @@ CATALOG(pg_amproc,2603,AccessMethodProcedureRelationId)
*/
typedef FormData_pg_amproc *Form_pg_amproc;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_amproc_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_amproc_fam_proc_index, 2655, AccessMethodProcedureIndexId, on pg_amproc using btree(amprocfamily oid_ops, amproclefttype oid_ops, amprocrighttype oid_ops, amprocnum int2_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_amproc_oid_index, 2757, AccessMethodProcedureOidIndexId, on pg_amproc using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_attrdef.h b/src/include/catalog/pg_attrdef.h
index a21dd3812b..020c70a09e 100644
--- a/src/include/catalog/pg_attrdef.h
+++ b/src/include/catalog/pg_attrdef.h
@@ -48,6 +48,9 @@ CATALOG(pg_attrdef,2604,AttrDefaultRelationId)
*/
typedef FormData_pg_attrdef *Form_pg_attrdef;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_attrdef_deform.h"
+
DECLARE_TOAST(pg_attrdef, 2830, 2831);
DECLARE_UNIQUE_INDEX(pg_attrdef_adrelid_adnum_index, 2656, AttrDefaultIndexId, on pg_attrdef using btree(adrelid oid_ops, adnum int2_ops));
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index 053294c99f..081063afef 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -206,6 +206,9 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
*/
typedef FormData_pg_attribute *Form_pg_attribute;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_attribute_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index, 2658, AttributeRelidNameIndexId, on pg_attribute using btree(attrelid oid_ops, attname name_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_attribute_relid_attnum_index, 2659, AttributeRelidNumIndexId, on pg_attribute using btree(attrelid oid_ops, attnum int2_ops));
diff --git a/src/include/catalog/pg_auth_members.h b/src/include/catalog/pg_auth_members.h
index 1bc027f133..1288694b97 100644
--- a/src/include/catalog/pg_auth_members.h
+++ b/src/include/catalog/pg_auth_members.h
@@ -42,6 +42,9 @@ CATALOG(pg_auth_members,1261,AuthMemRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_
*/
typedef FormData_pg_auth_members *Form_pg_auth_members;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_auth_members_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_auth_members_role_member_index, 2694, AuthMemRoleMemIndexId, on pg_auth_members using btree(roleid oid_ops, member oid_ops));
DECLARE_UNIQUE_INDEX(pg_auth_members_member_role_index, 2695, AuthMemMemRoleIndexId, on pg_auth_members using btree(member oid_ops, roleid oid_ops));
diff --git a/src/include/catalog/pg_authid.h b/src/include/catalog/pg_authid.h
index 3512601c80..08b833198f 100644
--- a/src/include/catalog/pg_authid.h
+++ b/src/include/catalog/pg_authid.h
@@ -55,6 +55,9 @@ CATALOG(pg_authid,1260,AuthIdRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(284
*/
typedef FormData_pg_authid *Form_pg_authid;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_authid_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_authid, 4175, 4176, PgAuthidToastTable, PgAuthidToastIndex);
DECLARE_UNIQUE_INDEX(pg_authid_rolname_index, 2676, AuthIdRolnameIndexId, on pg_authid using btree(rolname name_ops));
diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h
index 3c15df0053..4887ea16bd 100644
--- a/src/include/catalog/pg_cast.h
+++ b/src/include/catalog/pg_cast.h
@@ -56,6 +56,9 @@ CATALOG(pg_cast,2605,CastRelationId)
*/
typedef FormData_pg_cast *Form_pg_cast;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_cast_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_cast_oid_index, 2660, CastOidIndexId, on pg_cast using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_cast_source_target_index, 2661, CastSourceTargetIndexId, on pg_cast using btree(castsource oid_ops, casttarget oid_ops));
diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h
index e1f4eefa22..1405fa07f5 100644
--- a/src/include/catalog/pg_class.h
+++ b/src/include/catalog/pg_class.h
@@ -152,6 +152,9 @@ CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,Relat
*/
typedef FormData_pg_class *Form_pg_class;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_class_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_class_oid_index, 2662, ClassOidIndexId, on pg_class using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_class_relname_nsp_index, 2663, ClassNameNspIndexId, on pg_class using btree(relname name_ops, relnamespace oid_ops));
DECLARE_INDEX(pg_class_tblspc_relfilenode_index, 3455, ClassTblspcRelfilenodeIndexId, on pg_class using btree(reltablespace oid_ops, relfilenode oid_ops));
diff --git a/src/include/catalog/pg_collation.h b/src/include/catalog/pg_collation.h
index 2190ccb5b8..a5f6ab75a1 100644
--- a/src/include/catalog/pg_collation.h
+++ b/src/include/catalog/pg_collation.h
@@ -56,6 +56,9 @@ CATALOG(pg_collation,3456,CollationRelationId)
*/
typedef FormData_pg_collation *Form_pg_collation;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_collation_deform.h"
+
DECLARE_TOAST(pg_collation, 6175, 6176);
DECLARE_UNIQUE_INDEX(pg_collation_name_enc_nsp_index, 3164, CollationNameEncNspIndexId, on pg_collation using btree(collname name_ops, collencoding int4_ops, collnamespace oid_ops));
diff --git a/src/include/catalog/pg_constraint.h b/src/include/catalog/pg_constraint.h
index e7d967f137..184baf88ba 100644
--- a/src/include/catalog/pg_constraint.h
+++ b/src/include/catalog/pg_constraint.h
@@ -164,6 +164,9 @@ CATALOG(pg_constraint,2606,ConstraintRelationId)
*/
typedef FormData_pg_constraint *Form_pg_constraint;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_constraint_deform.h"
+
DECLARE_TOAST(pg_constraint, 2832, 2833);
DECLARE_INDEX(pg_constraint_conname_nsp_index, 2664, ConstraintNameNspIndexId, on pg_constraint using btree(conname name_ops, connamespace oid_ops));
diff --git a/src/include/catalog/pg_conversion.h b/src/include/catalog/pg_conversion.h
index fb26123aa9..b652cc9c8d 100644
--- a/src/include/catalog/pg_conversion.h
+++ b/src/include/catalog/pg_conversion.h
@@ -60,6 +60,9 @@ CATALOG(pg_conversion,2607,ConversionRelationId)
*/
typedef FormData_pg_conversion *Form_pg_conversion;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_conversion_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_conversion_default_index, 2668, ConversionDefaultIndexId, on pg_conversion using btree(connamespace oid_ops, conforencoding int4_ops, contoencoding int4_ops, oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_conversion_name_nsp_index, 2669, ConversionNameNspIndexId, on pg_conversion using btree(conname name_ops, connamespace oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_conversion_oid_index, 2670, ConversionOidIndexId, on pg_conversion using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_database.h b/src/include/catalog/pg_database.h
index 611c95656a..b01375996a 100644
--- a/src/include/catalog/pg_database.h
+++ b/src/include/catalog/pg_database.h
@@ -86,6 +86,9 @@ CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID
*/
typedef FormData_pg_database *Form_pg_database;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_database_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_database, 4177, 4178, PgDatabaseToastTable, PgDatabaseToastIndex);
DECLARE_UNIQUE_INDEX(pg_database_datname_index, 2671, DatabaseNameIndexId, on pg_database using btree(datname name_ops));
diff --git a/src/include/catalog/pg_db_role_setting.h b/src/include/catalog/pg_db_role_setting.h
index 45d478e9e7..519d90dafb 100644
--- a/src/include/catalog/pg_db_role_setting.h
+++ b/src/include/catalog/pg_db_role_setting.h
@@ -46,6 +46,9 @@ CATALOG(pg_db_role_setting,2964,DbRoleSettingRelationId) BKI_SHARED_RELATION
typedef FormData_pg_db_role_setting * Form_pg_db_role_setting;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_db_role_setting_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_db_role_setting, 2966, 2967, PgDbRoleSettingToastTable, PgDbRoleSettingToastIndex);
DECLARE_UNIQUE_INDEX_PKEY(pg_db_role_setting_databaseid_rol_index, 2965, DbRoleSettingDatidRolidIndexId, on pg_db_role_setting using btree(setdatabase oid_ops, setrole oid_ops));
diff --git a/src/include/catalog/pg_default_acl.h b/src/include/catalog/pg_default_acl.h
index 2a79155636..ebd3323930 100644
--- a/src/include/catalog/pg_default_acl.h
+++ b/src/include/catalog/pg_default_acl.h
@@ -49,6 +49,9 @@ CATALOG(pg_default_acl,826,DefaultAclRelationId)
*/
typedef FormData_pg_default_acl *Form_pg_default_acl;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_default_acl_deform.h"
+
DECLARE_TOAST(pg_default_acl, 4143, 4144);
DECLARE_UNIQUE_INDEX(pg_default_acl_role_nsp_obj_index, 827, DefaultAclRoleNspObjIndexId, on pg_default_acl using btree(defaclrole oid_ops, defaclnamespace oid_ops, defaclobjtype char_ops));
diff --git a/src/include/catalog/pg_depend.h b/src/include/catalog/pg_depend.h
index 2f736ecd6c..971718e5f2 100644
--- a/src/include/catalog/pg_depend.h
+++ b/src/include/catalog/pg_depend.h
@@ -71,6 +71,9 @@ CATALOG(pg_depend,2608,DependRelationId)
*/
typedef FormData_pg_depend *Form_pg_depend;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_depend_deform.h"
+
DECLARE_INDEX(pg_depend_depender_index, 2673, DependDependerIndexId, on pg_depend using btree(classid oid_ops, objid oid_ops, objsubid int4_ops));
DECLARE_INDEX(pg_depend_reference_index, 2674, DependReferenceIndexId, on pg_depend using btree(refclassid oid_ops, refobjid oid_ops, refobjsubid int4_ops));
diff --git a/src/include/catalog/pg_description.h b/src/include/catalog/pg_description.h
index 67636ba926..0cb41eabf1 100644
--- a/src/include/catalog/pg_description.h
+++ b/src/include/catalog/pg_description.h
@@ -63,6 +63,9 @@ CATALOG(pg_description,2609,DescriptionRelationId)
*/
typedef FormData_pg_description * Form_pg_description;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_description_deform.h"
+
DECLARE_TOAST(pg_description, 2834, 2835);
DECLARE_UNIQUE_INDEX_PKEY(pg_description_o_c_o_index, 2675, DescriptionObjIndexId, on pg_description using btree(objoid oid_ops, classoid oid_ops, objsubid int4_ops));
diff --git a/src/include/catalog/pg_enum.h b/src/include/catalog/pg_enum.h
index 9c6deddc6a..947368aa96 100644
--- a/src/include/catalog/pg_enum.h
+++ b/src/include/catalog/pg_enum.h
@@ -43,6 +43,9 @@ CATALOG(pg_enum,3501,EnumRelationId)
*/
typedef FormData_pg_enum *Form_pg_enum;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_enum_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_enum_oid_index, 3502, EnumOidIndexId, on pg_enum using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_enum_typid_label_index, 3503, EnumTypIdLabelIndexId, on pg_enum using btree(enumtypid oid_ops, enumlabel name_ops));
DECLARE_UNIQUE_INDEX(pg_enum_typid_sortorder_index, 3534, EnumTypIdSortOrderIndexId, on pg_enum using btree(enumtypid oid_ops, enumsortorder float4_ops));
diff --git a/src/include/catalog/pg_event_trigger.h b/src/include/catalog/pg_event_trigger.h
index 3fe0e8db78..ce3bcab135 100644
--- a/src/include/catalog/pg_event_trigger.h
+++ b/src/include/catalog/pg_event_trigger.h
@@ -49,6 +49,9 @@ CATALOG(pg_event_trigger,3466,EventTriggerRelationId)
*/
typedef FormData_pg_event_trigger *Form_pg_event_trigger;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_event_trigger_deform.h"
+
DECLARE_TOAST(pg_event_trigger, 4145, 4146);
DECLARE_UNIQUE_INDEX(pg_event_trigger_evtname_index, 3467, EventTriggerNameIndexId, on pg_event_trigger using btree(evtname name_ops));
diff --git a/src/include/catalog/pg_extension.h b/src/include/catalog/pg_extension.h
index 43d16d4857..59aeb748a0 100644
--- a/src/include/catalog/pg_extension.h
+++ b/src/include/catalog/pg_extension.h
@@ -51,6 +51,9 @@ CATALOG(pg_extension,3079,ExtensionRelationId)
*/
typedef FormData_pg_extension *Form_pg_extension;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_extension_deform.h"
+
DECLARE_TOAST(pg_extension, 4147, 4148);
DECLARE_UNIQUE_INDEX_PKEY(pg_extension_oid_index, 3080, ExtensionOidIndexId, on pg_extension using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_foreign_data_wrapper.h b/src/include/catalog/pg_foreign_data_wrapper.h
index 86db6546cc..1e1c73b8a9 100644
--- a/src/include/catalog/pg_foreign_data_wrapper.h
+++ b/src/include/catalog/pg_foreign_data_wrapper.h
@@ -50,6 +50,9 @@ CATALOG(pg_foreign_data_wrapper,2328,ForeignDataWrapperRelationId)
*/
typedef FormData_pg_foreign_data_wrapper *Form_pg_foreign_data_wrapper;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_foreign_data_wrapper_deform.h"
+
DECLARE_TOAST(pg_foreign_data_wrapper, 4149, 4150);
DECLARE_UNIQUE_INDEX_PKEY(pg_foreign_data_wrapper_oid_index, 112, ForeignDataWrapperOidIndexId, on pg_foreign_data_wrapper using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_foreign_server.h b/src/include/catalog/pg_foreign_server.h
index dcef33de24..966853bf72 100644
--- a/src/include/catalog/pg_foreign_server.h
+++ b/src/include/catalog/pg_foreign_server.h
@@ -47,6 +47,9 @@ CATALOG(pg_foreign_server,1417,ForeignServerRelationId)
*/
typedef FormData_pg_foreign_server *Form_pg_foreign_server;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_foreign_server_deform.h"
+
DECLARE_TOAST(pg_foreign_server, 4151, 4152);
DECLARE_UNIQUE_INDEX_PKEY(pg_foreign_server_oid_index, 113, ForeignServerOidIndexId, on pg_foreign_server using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_foreign_table.h b/src/include/catalog/pg_foreign_table.h
index 88753cd5f8..4d9101e248 100644
--- a/src/include/catalog/pg_foreign_table.h
+++ b/src/include/catalog/pg_foreign_table.h
@@ -42,6 +42,9 @@ CATALOG(pg_foreign_table,3118,ForeignTableRelationId)
*/
typedef FormData_pg_foreign_table *Form_pg_foreign_table;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_foreign_table_deform.h"
+
DECLARE_TOAST(pg_foreign_table, 4153, 4154);
DECLARE_UNIQUE_INDEX_PKEY(pg_foreign_table_relid_index, 3119, ForeignTableRelidIndexId, on pg_foreign_table using btree(ftrelid oid_ops));
diff --git a/src/include/catalog/pg_index.h b/src/include/catalog/pg_index.h
index f853846ee1..99903d8eff 100644
--- a/src/include/catalog/pg_index.h
+++ b/src/include/catalog/pg_index.h
@@ -69,6 +69,9 @@ CATALOG(pg_index,2610,IndexRelationId) BKI_SCHEMA_MACRO
*/
typedef FormData_pg_index *Form_pg_index;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_index_deform.h"
+
DECLARE_INDEX(pg_index_indrelid_index, 2678, IndexIndrelidIndexId, on pg_index using btree(indrelid oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_index_indexrelid_index, 2679, IndexRelidIndexId, on pg_index using btree(indexrelid oid_ops));
diff --git a/src/include/catalog/pg_inherits.h b/src/include/catalog/pg_inherits.h
index b5a32755a6..c8a25994b7 100644
--- a/src/include/catalog/pg_inherits.h
+++ b/src/include/catalog/pg_inherits.h
@@ -44,6 +44,9 @@ CATALOG(pg_inherits,2611,InheritsRelationId)
*/
typedef FormData_pg_inherits *Form_pg_inherits;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_inherits_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_inherits_relid_seqno_index, 2680, InheritsRelidSeqnoIndexId, on pg_inherits using btree(inhrelid oid_ops, inhseqno int4_ops));
DECLARE_INDEX(pg_inherits_parent_index, 2187, InheritsParentIndexId, on pg_inherits using btree(inhparent oid_ops));
diff --git a/src/include/catalog/pg_init_privs.h b/src/include/catalog/pg_init_privs.h
index c226edc4a4..9697053907 100644
--- a/src/include/catalog/pg_init_privs.h
+++ b/src/include/catalog/pg_init_privs.h
@@ -63,6 +63,9 @@ CATALOG(pg_init_privs,3394,InitPrivsRelationId)
*/
typedef FormData_pg_init_privs * Form_pg_init_privs;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_init_privs_deform.h"
+
DECLARE_TOAST(pg_init_privs, 4155, 4156);
DECLARE_UNIQUE_INDEX_PKEY(pg_init_privs_o_c_o_index, 3395, InitPrivsObjIndexId, on pg_init_privs using btree(objoid oid_ops, classoid oid_ops, objsubid int4_ops));
diff --git a/src/include/catalog/pg_language.h b/src/include/catalog/pg_language.h
index 4b9c259554..8a7dd7eddc 100644
--- a/src/include/catalog/pg_language.h
+++ b/src/include/catalog/pg_language.h
@@ -64,6 +64,9 @@ CATALOG(pg_language,2612,LanguageRelationId)
*/
typedef FormData_pg_language *Form_pg_language;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_language_deform.h"
+
DECLARE_TOAST(pg_language, 4157, 4158);
DECLARE_UNIQUE_INDEX(pg_language_name_index, 2681, LanguageNameIndexId, on pg_language using btree(lanname name_ops));
diff --git a/src/include/catalog/pg_largeobject.h b/src/include/catalog/pg_largeobject.h
index 1fd076d799..c1cf040e00 100644
--- a/src/include/catalog/pg_largeobject.h
+++ b/src/include/catalog/pg_largeobject.h
@@ -44,6 +44,9 @@ CATALOG(pg_largeobject,2613,LargeObjectRelationId)
*/
typedef FormData_pg_largeobject *Form_pg_largeobject;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_largeobject_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_largeobject_loid_pn_index, 2683, LargeObjectLOidPNIndexId, on pg_largeobject using btree(loid oid_ops, pageno int4_ops));
extern Oid LargeObjectCreate(Oid loid);
diff --git a/src/include/catalog/pg_largeobject_metadata.h b/src/include/catalog/pg_largeobject_metadata.h
index ec1c3bf755..22b9b732a9 100644
--- a/src/include/catalog/pg_largeobject_metadata.h
+++ b/src/include/catalog/pg_largeobject_metadata.h
@@ -46,6 +46,9 @@ CATALOG(pg_largeobject_metadata,2995,LargeObjectMetadataRelationId)
*/
typedef FormData_pg_largeobject_metadata *Form_pg_largeobject_metadata;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_largeobject_metadata_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_largeobject_metadata_oid_index, 2996, LargeObjectMetadataOidIndexId, on pg_largeobject_metadata using btree(oid oid_ops));
#endif /* PG_LARGEOBJECT_METADATA_H */
diff --git a/src/include/catalog/pg_namespace.h b/src/include/catalog/pg_namespace.h
index ba56e44d61..d220737615 100644
--- a/src/include/catalog/pg_namespace.h
+++ b/src/include/catalog/pg_namespace.h
@@ -51,6 +51,9 @@ CATALOG(pg_namespace,2615,NamespaceRelationId)
*/
typedef FormData_pg_namespace *Form_pg_namespace;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_namespace_deform.h"
+
DECLARE_TOAST(pg_namespace, 4163, 4164);
DECLARE_UNIQUE_INDEX(pg_namespace_nspname_index, 2684, NamespaceNameIndexId, on pg_namespace using btree(nspname name_ops));
diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h
index 3a3a19b83b..91faa3eebf 100644
--- a/src/include/catalog/pg_opclass.h
+++ b/src/include/catalog/pg_opclass.h
@@ -82,6 +82,9 @@ CATALOG(pg_opclass,2616,OperatorClassRelationId)
*/
typedef FormData_pg_opclass *Form_pg_opclass;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_opclass_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_opclass_am_name_nsp_index, 2686, OpclassAmNameNspIndexId, on pg_opclass using btree(opcmethod oid_ops, opcname name_ops, opcnamespace oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_opclass_oid_index, 2687, OpclassOidIndexId, on pg_opclass using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h
index 51263f550f..873b4f73d7 100644
--- a/src/include/catalog/pg_operator.h
+++ b/src/include/catalog/pg_operator.h
@@ -82,6 +82,9 @@ CATALOG(pg_operator,2617,OperatorRelationId)
*/
typedef FormData_pg_operator *Form_pg_operator;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_operator_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_operator_oid_index, 2688, OperatorOidIndexId, on pg_operator using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_operator_oprname_l_r_n_index, 2689, OperatorNameNspIndexId, on pg_operator using btree(oprname name_ops, oprleft oid_ops, oprright oid_ops, oprnamespace oid_ops));
diff --git a/src/include/catalog/pg_opfamily.h b/src/include/catalog/pg_opfamily.h
index 8dc9ce01bb..7339fd9cd2 100644
--- a/src/include/catalog/pg_opfamily.h
+++ b/src/include/catalog/pg_opfamily.h
@@ -50,6 +50,9 @@ CATALOG(pg_opfamily,2753,OperatorFamilyRelationId)
*/
typedef FormData_pg_opfamily *Form_pg_opfamily;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_opfamily_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_opfamily_am_name_nsp_index, 2754, OpfamilyAmNameNspIndexId, on pg_opfamily using btree(opfmethod oid_ops, opfname name_ops, opfnamespace oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_opfamily_oid_index, 2755, OpfamilyOidIndexId, on pg_opfamily using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_parameter_acl.h b/src/include/catalog/pg_parameter_acl.h
index 4bd52c2d7d..210fd7b2b8 100644
--- a/src/include/catalog/pg_parameter_acl.h
+++ b/src/include/catalog/pg_parameter_acl.h
@@ -48,6 +48,9 @@ CATALOG(pg_parameter_acl,6243,ParameterAclRelationId) BKI_SHARED_RELATION
*/
typedef FormData_pg_parameter_acl * Form_pg_parameter_acl;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_parameter_acl_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_parameter_acl, 6244, 6245, PgParameterAclToastTable, PgParameterAclToastIndex);
DECLARE_UNIQUE_INDEX(pg_parameter_acl_parname_index, 6246, ParameterAclParnameIndexId, on pg_parameter_acl using btree(parname text_ops));
diff --git a/src/include/catalog/pg_partitioned_table.h b/src/include/catalog/pg_partitioned_table.h
index 9b78f84cd5..f2fd24794d 100644
--- a/src/include/catalog/pg_partitioned_table.h
+++ b/src/include/catalog/pg_partitioned_table.h
@@ -64,6 +64,9 @@ CATALOG(pg_partitioned_table,3350,PartitionedRelationId)
*/
typedef FormData_pg_partitioned_table *Form_pg_partitioned_table;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_partitioned_table_deform.h"
+
DECLARE_TOAST(pg_partitioned_table, 4165, 4166);
DECLARE_UNIQUE_INDEX_PKEY(pg_partitioned_table_partrelid_index, 3351, PartitionedRelidIndexId, on pg_partitioned_table using btree(partrelid oid_ops));
diff --git a/src/include/catalog/pg_policy.h b/src/include/catalog/pg_policy.h
index 56b0ea100b..3c294d04f1 100644
--- a/src/include/catalog/pg_policy.h
+++ b/src/include/catalog/pg_policy.h
@@ -50,6 +50,9 @@ CATALOG(pg_policy,3256,PolicyRelationId)
*/
typedef FormData_pg_policy *Form_pg_policy;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_policy_deform.h"
+
DECLARE_TOAST(pg_policy, 4167, 4168);
DECLARE_UNIQUE_INDEX_PKEY(pg_policy_oid_index, 3257, PolicyOidIndexId, on pg_policy using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 76310d4cc9..362edeac08 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -135,6 +135,9 @@ CATALOG(pg_proc,1255,ProcedureRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81,Proce
*/
typedef FormData_pg_proc *Form_pg_proc;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_proc_deform.h"
+
DECLARE_TOAST(pg_proc, 2836, 2837);
DECLARE_UNIQUE_INDEX_PKEY(pg_proc_oid_index, 2690, ProcedureOidIndexId, on pg_proc using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_publication.h b/src/include/catalog/pg_publication.h
index 48205ba429..11106a7227 100644
--- a/src/include/catalog/pg_publication.h
+++ b/src/include/catalog/pg_publication.h
@@ -63,6 +63,9 @@ CATALOG(pg_publication,6104,PublicationRelationId)
*/
typedef FormData_pg_publication *Form_pg_publication;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_publication_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_publication_oid_index, 6110, PublicationObjectIndexId, on pg_publication using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_publication_pubname_index, 6111, PublicationNameIndexId, on pg_publication using btree(pubname name_ops));
diff --git a/src/include/catalog/pg_publication_namespace.h b/src/include/catalog/pg_publication_namespace.h
index d166600b26..930050358f 100644
--- a/src/include/catalog/pg_publication_namespace.h
+++ b/src/include/catalog/pg_publication_namespace.h
@@ -41,6 +41,9 @@ CATALOG(pg_publication_namespace,6237,PublicationNamespaceRelationId)
*/
typedef FormData_pg_publication_namespace *Form_pg_publication_namespace;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_publication_namespace_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_publication_namespace_oid_index, 6238, PublicationNamespaceObjectIndexId, on pg_publication_namespace using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_publication_namespace_pnnspid_pnpubid_index, 6239, PublicationNamespacePnnspidPnpubidIndexId, on pg_publication_namespace using btree(pnnspid oid_ops, pnpubid oid_ops));
diff --git a/src/include/catalog/pg_publication_rel.h b/src/include/catalog/pg_publication_rel.h
index ecd3739f1a..c0cd7dc555 100644
--- a/src/include/catalog/pg_publication_rel.h
+++ b/src/include/catalog/pg_publication_rel.h
@@ -45,6 +45,9 @@ CATALOG(pg_publication_rel,6106,PublicationRelRelationId)
*/
typedef FormData_pg_publication_rel *Form_pg_publication_rel;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_publication_rel_deform.h"
+
DECLARE_TOAST(pg_publication_rel, 6228, 6229);
DECLARE_UNIQUE_INDEX_PKEY(pg_publication_rel_oid_index, 6112, PublicationRelObjectIndexId, on pg_publication_rel using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_range.h b/src/include/catalog/pg_range.h
index faa57e8cea..a1979f7484 100644
--- a/src/include/catalog/pg_range.h
+++ b/src/include/catalog/pg_range.h
@@ -57,6 +57,9 @@ CATALOG(pg_range,3541,RangeRelationId)
*/
typedef FormData_pg_range *Form_pg_range;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_range_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_range_rngtypid_index, 3542, RangeTypidIndexId, on pg_range using btree(rngtypid oid_ops));
DECLARE_UNIQUE_INDEX(pg_range_rngmultitypid_index, 2228, RangeMultirangeTypidIndexId, on pg_range using btree(rngmultitypid oid_ops));
diff --git a/src/include/catalog/pg_replication_origin.h b/src/include/catalog/pg_replication_origin.h
index 3b11cd21cb..7eb9063ac0 100644
--- a/src/include/catalog/pg_replication_origin.h
+++ b/src/include/catalog/pg_replication_origin.h
@@ -54,6 +54,9 @@ CATALOG(pg_replication_origin,6000,ReplicationOriginRelationId) BKI_SHARED_RELAT
typedef FormData_pg_replication_origin *Form_pg_replication_origin;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_replication_origin_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_replication_origin, 4181, 4182, PgReplicationOriginToastTable, PgReplicationOriginToastIndex);
DECLARE_UNIQUE_INDEX_PKEY(pg_replication_origin_roiident_index, 6001, ReplicationOriginIdentIndex, on pg_replication_origin using btree(roident oid_ops));
diff --git a/src/include/catalog/pg_rewrite.h b/src/include/catalog/pg_rewrite.h
index c647f26aca..cace6f2a28 100644
--- a/src/include/catalog/pg_rewrite.h
+++ b/src/include/catalog/pg_rewrite.h
@@ -51,6 +51,9 @@ CATALOG(pg_rewrite,2618,RewriteRelationId)
*/
typedef FormData_pg_rewrite *Form_pg_rewrite;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_rewrite_deform.h"
+
DECLARE_TOAST(pg_rewrite, 2838, 2839);
DECLARE_UNIQUE_INDEX_PKEY(pg_rewrite_oid_index, 2692, RewriteOidIndexId, on pg_rewrite using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_sequence.h b/src/include/catalog/pg_sequence.h
index 82b35aa65b..946d336174 100644
--- a/src/include/catalog/pg_sequence.h
+++ b/src/include/catalog/pg_sequence.h
@@ -39,6 +39,9 @@ CATALOG(pg_sequence,2224,SequenceRelationId)
*/
typedef FormData_pg_sequence *Form_pg_sequence;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_sequence_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_sequence_seqrelid_index, 5002, SequenceRelidIndexId, on pg_sequence using btree(seqrelid oid_ops));
#endif /* PG_SEQUENCE_H */
diff --git a/src/include/catalog/pg_shdepend.h b/src/include/catalog/pg_shdepend.h
index 8119b28e44..68e5fc2021 100644
--- a/src/include/catalog/pg_shdepend.h
+++ b/src/include/catalog/pg_shdepend.h
@@ -72,6 +72,9 @@ CATALOG(pg_shdepend,1214,SharedDependRelationId) BKI_SHARED_RELATION
*/
typedef FormData_pg_shdepend *Form_pg_shdepend;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_shdepend_deform.h"
+
DECLARE_INDEX(pg_shdepend_depender_index, 1232, SharedDependDependerIndexId, on pg_shdepend using btree(dbid oid_ops, classid oid_ops, objid oid_ops, objsubid int4_ops));
DECLARE_INDEX(pg_shdepend_reference_index, 1233, SharedDependReferenceIndexId, on pg_shdepend using btree(refclassid oid_ops, refobjid oid_ops));
diff --git a/src/include/catalog/pg_shdescription.h b/src/include/catalog/pg_shdescription.h
index da2b9f6fdf..5bd5d777f8 100644
--- a/src/include/catalog/pg_shdescription.h
+++ b/src/include/catalog/pg_shdescription.h
@@ -55,6 +55,9 @@ CATALOG(pg_shdescription,2396,SharedDescriptionRelationId) BKI_SHARED_RELATION
*/
typedef FormData_pg_shdescription * Form_pg_shdescription;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_shdescription_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_shdescription, 2846, 2847, PgShdescriptionToastTable, PgShdescriptionToastIndex);
DECLARE_UNIQUE_INDEX_PKEY(pg_shdescription_o_c_index, 2397, SharedDescriptionObjIndexId, on pg_shdescription using btree(objoid oid_ops, classoid oid_ops));
diff --git a/src/include/catalog/pg_shseclabel.h b/src/include/catalog/pg_shseclabel.h
index fc1b97f46f..6cc96bc66e 100644
--- a/src/include/catalog/pg_shseclabel.h
+++ b/src/include/catalog/pg_shseclabel.h
@@ -39,6 +39,9 @@ CATALOG(pg_shseclabel,3592,SharedSecLabelRelationId) BKI_SHARED_RELATION BKI_ROW
typedef FormData_pg_shseclabel * Form_pg_shseclabel;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_shseclabel_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_shseclabel, 4060, 4061, PgShseclabelToastTable, PgShseclabelToastIndex);
DECLARE_UNIQUE_INDEX_PKEY(pg_shseclabel_object_index, 3593, SharedSecLabelObjectIndexId, on pg_shseclabel using btree(objoid oid_ops, classoid oid_ops, provider text_ops));
diff --git a/src/include/catalog/pg_statistic.h b/src/include/catalog/pg_statistic.h
index cdf7448139..dd1c324af8 100644
--- a/src/include/catalog/pg_statistic.h
+++ b/src/include/catalog/pg_statistic.h
@@ -134,6 +134,9 @@ CATALOG(pg_statistic,2619,StatisticRelationId)
*/
typedef FormData_pg_statistic *Form_pg_statistic;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_statistic_deform.h"
+
DECLARE_TOAST(pg_statistic, 2840, 2841);
DECLARE_UNIQUE_INDEX_PKEY(pg_statistic_relid_att_inh_index, 2696, StatisticRelidAttnumInhIndexId, on pg_statistic using btree(starelid oid_ops, staattnum int2_ops, stainherit bool_ops));
diff --git a/src/include/catalog/pg_statistic_ext.h b/src/include/catalog/pg_statistic_ext.h
index b8520ba923..d3b0ae8fde 100644
--- a/src/include/catalog/pg_statistic_ext.h
+++ b/src/include/catalog/pg_statistic_ext.h
@@ -68,6 +68,9 @@ CATALOG(pg_statistic_ext,3381,StatisticExtRelationId)
*/
typedef FormData_pg_statistic_ext *Form_pg_statistic_ext;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_statistic_ext_deform.h"
+
DECLARE_TOAST(pg_statistic_ext, 3439, 3440);
DECLARE_UNIQUE_INDEX_PKEY(pg_statistic_ext_oid_index, 3380, StatisticExtOidIndexId, on pg_statistic_ext using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_statistic_ext_data.h b/src/include/catalog/pg_statistic_ext_data.h
index 0ea3c41b5b..dc4461a0cf 100644
--- a/src/include/catalog/pg_statistic_ext_data.h
+++ b/src/include/catalog/pg_statistic_ext_data.h
@@ -52,6 +52,9 @@ CATALOG(pg_statistic_ext_data,3429,StatisticExtDataRelationId)
*/
typedef FormData_pg_statistic_ext_data *Form_pg_statistic_ext_data;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_statistic_ext_data_deform.h"
+
DECLARE_TOAST(pg_statistic_ext_data, 3430, 3431);
DECLARE_UNIQUE_INDEX_PKEY(pg_statistic_ext_data_stxoid_inh_index, 3433, StatisticExtDataStxoidInhIndexId, on pg_statistic_ext_data using btree(stxoid oid_ops, stxdinherit bool_ops));
diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_subscription.h
index d1260f590c..b3e136e64b 100644
--- a/src/include/catalog/pg_subscription.h
+++ b/src/include/catalog/pg_subscription.h
@@ -92,6 +92,9 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
typedef FormData_pg_subscription *Form_pg_subscription;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_subscription_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_subscription, 4183, 4184, PgSubscriptionToastTable, PgSubscriptionToastIndex);
DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_oid_index, 6114, SubscriptionObjectIndexId, on pg_subscription using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_subscription_rel.h b/src/include/catalog/pg_subscription_rel.h
index 9df99c3418..0ff6a25882 100644
--- a/src/include/catalog/pg_subscription_rel.h
+++ b/src/include/catalog/pg_subscription_rel.h
@@ -49,6 +49,9 @@ CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
typedef FormData_pg_subscription_rel *Form_pg_subscription_rel;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_subscription_rel_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_rel_srrelid_srsubid_index, 6117, SubscriptionRelSrrelidSrsubidIndexId, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));
#ifdef EXPOSE_TO_CLIENT_CODE
diff --git a/src/include/catalog/pg_tablespace.h b/src/include/catalog/pg_tablespace.h
index 572eeeb8a6..74a766f001 100644
--- a/src/include/catalog/pg_tablespace.h
+++ b/src/include/catalog/pg_tablespace.h
@@ -47,6 +47,9 @@ CATALOG(pg_tablespace,1213,TableSpaceRelationId) BKI_SHARED_RELATION
*/
typedef FormData_pg_tablespace *Form_pg_tablespace;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_tablespace_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_tablespace, 4185, 4186, PgTablespaceToastTable, PgTablespaceToastIndex);
DECLARE_UNIQUE_INDEX_PKEY(pg_tablespace_oid_index, 2697, TablespaceOidIndexId, on pg_tablespace using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_transform.h b/src/include/catalog/pg_transform.h
index 2a02691510..665e4d0165 100644
--- a/src/include/catalog/pg_transform.h
+++ b/src/include/catalog/pg_transform.h
@@ -42,6 +42,9 @@ CATALOG(pg_transform,3576,TransformRelationId)
*/
typedef FormData_pg_transform *Form_pg_transform;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_transform_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_transform_oid_index, 3574, TransformOidIndexId, on pg_transform using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_transform_type_lang_index, 3575, TransformTypeLangIndexId, on pg_transform using btree(trftype oid_ops, trflang oid_ops));
diff --git a/src/include/catalog/pg_trigger.h b/src/include/catalog/pg_trigger.h
index 194277bca5..bbf6569766 100644
--- a/src/include/catalog/pg_trigger.h
+++ b/src/include/catalog/pg_trigger.h
@@ -79,6 +79,9 @@ CATALOG(pg_trigger,2620,TriggerRelationId)
*/
typedef FormData_pg_trigger *Form_pg_trigger;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_trigger_deform.h"
+
DECLARE_TOAST(pg_trigger, 2336, 2337);
DECLARE_INDEX(pg_trigger_tgconstraint_index, 2699, TriggerConstraintIndexId, on pg_trigger using btree(tgconstraint oid_ops));
diff --git a/src/include/catalog/pg_ts_config.h b/src/include/catalog/pg_ts_config.h
index e5a308475c..6d85628b64 100644
--- a/src/include/catalog/pg_ts_config.h
+++ b/src/include/catalog/pg_ts_config.h
@@ -47,6 +47,9 @@ CATALOG(pg_ts_config,3602,TSConfigRelationId)
typedef FormData_pg_ts_config *Form_pg_ts_config;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_config_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_ts_config_cfgname_index, 3608, TSConfigNameNspIndexId, on pg_ts_config using btree(cfgname name_ops, cfgnamespace oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_ts_config_oid_index, 3712, TSConfigOidIndexId, on pg_ts_config using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_ts_config_map.h b/src/include/catalog/pg_ts_config_map.h
index c10e0c5164..fa4fa584db 100644
--- a/src/include/catalog/pg_ts_config_map.h
+++ b/src/include/catalog/pg_ts_config_map.h
@@ -44,6 +44,9 @@ CATALOG(pg_ts_config_map,3603,TSConfigMapRelationId)
typedef FormData_pg_ts_config_map *Form_pg_ts_config_map;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_config_map_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_ts_config_map_index, 3609, TSConfigMapIndexId, on pg_ts_config_map using btree(mapcfg oid_ops, maptokentype int4_ops, mapseqno int4_ops));
#endif /* PG_TS_CONFIG_MAP_H */
diff --git a/src/include/catalog/pg_ts_dict.h b/src/include/catalog/pg_ts_dict.h
index 4b6188f4fa..6311d702c0 100644
--- a/src/include/catalog/pg_ts_dict.h
+++ b/src/include/catalog/pg_ts_dict.h
@@ -51,6 +51,9 @@ CATALOG(pg_ts_dict,3600,TSDictionaryRelationId)
typedef FormData_pg_ts_dict *Form_pg_ts_dict;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_dict_deform.h"
+
DECLARE_TOAST(pg_ts_dict, 4169, 4170);
DECLARE_UNIQUE_INDEX(pg_ts_dict_dictname_index, 3604, TSDictionaryNameNspIndexId, on pg_ts_dict using btree(dictname name_ops, dictnamespace oid_ops));
diff --git a/src/include/catalog/pg_ts_parser.h b/src/include/catalog/pg_ts_parser.h
index c2d474dca7..4f2602ccac 100644
--- a/src/include/catalog/pg_ts_parser.h
+++ b/src/include/catalog/pg_ts_parser.h
@@ -54,6 +54,9 @@ CATALOG(pg_ts_parser,3601,TSParserRelationId)
typedef FormData_pg_ts_parser *Form_pg_ts_parser;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_parser_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_ts_parser_prsname_index, 3606, TSParserNameNspIndexId, on pg_ts_parser using btree(prsname name_ops, prsnamespace oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_ts_parser_oid_index, 3607, TSParserOidIndexId, on pg_ts_parser using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_ts_template.h b/src/include/catalog/pg_ts_template.h
index 2a553fef52..f30f5008dc 100644
--- a/src/include/catalog/pg_ts_template.h
+++ b/src/include/catalog/pg_ts_template.h
@@ -45,6 +45,9 @@ CATALOG(pg_ts_template,3764,TSTemplateRelationId)
typedef FormData_pg_ts_template *Form_pg_ts_template;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_template_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_ts_template_tmplname_index, 3766, TSTemplateNameNspIndexId, on pg_ts_template using btree(tmplname name_ops, tmplnamespace oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_ts_template_oid_index, 3767, TSTemplateOidIndexId, on pg_ts_template using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index 48a2559137..e31425a2a5 100644
--- a/src/include/catalog/pg_type.h
+++ b/src/include/catalog/pg_type.h
@@ -260,6 +260,9 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati
*/
typedef FormData_pg_type *Form_pg_type;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_type_deform.h"
+
DECLARE_TOAST(pg_type, 4171, 4172);
DECLARE_UNIQUE_INDEX_PKEY(pg_type_oid_index, 2703, TypeOidIndexId, on pg_type using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_user_mapping.h b/src/include/catalog/pg_user_mapping.h
index 56150611be..2f29c6dd23 100644
--- a/src/include/catalog/pg_user_mapping.h
+++ b/src/include/catalog/pg_user_mapping.h
@@ -47,6 +47,9 @@ CATALOG(pg_user_mapping,1418,UserMappingRelationId)
*/
typedef FormData_pg_user_mapping *Form_pg_user_mapping;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_user_mapping_deform.h"
+
DECLARE_TOAST(pg_user_mapping, 4173, 4174);
DECLARE_UNIQUE_INDEX_PKEY(pg_user_mapping_oid_index, 174, UserMappingOidIndexId, on pg_user_mapping using btree(oid oid_ops));
diff --git a/src/include/commands/sequence.h b/src/include/commands/sequence.h
index d38c0e2388..a3876de82b 100644
--- a/src/include/commands/sequence.h
+++ b/src/include/commands/sequence.h
@@ -31,6 +31,9 @@ typedef struct FormData_pg_sequence_data
typedef FormData_pg_sequence_data *Form_pg_sequence_data;
+/* this is not a real catalog, so define by hand */
+#define Deform_pg_sequence_data_tuple(TUP) (Form_pg_sequence_data) (TUP)
+
/*
* Columns of a sequence relation
*/
--
2.36.1
v1-0001-Transform-GETSTRUCT-macro-so-the-cast-is-built-in.patchapplication/x-patch; name=v1-0001-Transform-GETSTRUCT-macro-so-the-cast-is-built-in.patchDownload
From 3277c2359369b1adee76d4e065f723c883ad2b6f Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Sat, 9 Jul 2022 12:19:18 +0700
Subject: [PATCH v1 1/2] Transform GETSTRUCT macro so the cast is built in
Per suggestion from Andres Freund
---
contrib/bloom/blvalidate.c | 8 +-
contrib/dblink/dblink.c | 2 +-
contrib/intarray/_int_selfuncs.c | 2 +-
contrib/postgres_fdw/deparse.c | 8 +-
contrib/sepgsql/database.c | 2 +-
contrib/sepgsql/dml.c | 4 +-
contrib/sepgsql/label.c | 10 +-
contrib/sepgsql/proc.c | 6 +-
contrib/sepgsql/relation.c | 12 +-
contrib/sepgsql/schema.c | 2 +-
contrib/tcn/tcn.c | 2 +-
src/backend/access/brin/brin_validate.c | 8 +-
src/backend/access/common/reloptions.c | 2 +-
src/backend/access/common/tupdesc.c | 2 +-
src/backend/access/gin/ginvalidate.c | 8 +-
src/backend/access/gist/gistvalidate.c | 8 +-
src/backend/access/hash/hashvalidate.c | 10 +-
src/backend/access/index/amapi.c | 4 +-
src/backend/access/index/amvalidate.c | 14 +-
src/backend/access/nbtree/nbtvalidate.c | 8 +-
src/backend/access/spgist/spgutils.c | 4 +-
src/backend/access/spgist/spgvalidate.c | 8 +-
src/backend/bootstrap/bootstrap.c | 2 +-
src/backend/catalog/aclchk.c | 118 ++++-----
src/backend/catalog/catalog.c | 2 +-
src/backend/catalog/dependency.c | 4 +-
src/backend/catalog/heap.c | 24 +-
src/backend/catalog/index.c | 40 +--
src/backend/catalog/namespace.c | 40 +--
src/backend/catalog/objectaddress.c | 124 ++++-----
src/backend/catalog/partition.c | 8 +-
src/backend/catalog/pg_aggregate.c | 8 +-
src/backend/catalog/pg_attrdef.c | 14 +-
src/backend/catalog/pg_constraint.c | 28 +-
src/backend/catalog/pg_conversion.c | 2 +-
src/backend/catalog/pg_depend.c | 26 +-
src/backend/catalog/pg_enum.c | 20 +-
src/backend/catalog/pg_inherits.c | 14 +-
src/backend/catalog/pg_operator.c | 8 +-
src/backend/catalog/pg_proc.c | 6 +-
src/backend/catalog/pg_publication.c | 22 +-
src/backend/catalog/pg_shdepend.c | 14 +-
src/backend/catalog/pg_subscription.c | 12 +-
src/backend/catalog/pg_type.c | 6 +-
src/backend/catalog/toasting.c | 2 +-
src/backend/commands/alter.c | 16 +-
src/backend/commands/amcmds.c | 4 +-
src/backend/commands/analyze.c | 2 +-
src/backend/commands/cluster.c | 12 +-
src/backend/commands/collationcmds.c | 10 +-
src/backend/commands/dbcommands.c | 28 +-
src/backend/commands/event_trigger.c | 6 +-
src/backend/commands/extension.c | 14 +-
src/backend/commands/foreigncmds.c | 12 +-
src/backend/commands/functioncmds.c | 22 +-
src/backend/commands/indexcmds.c | 24 +-
src/backend/commands/matview.c | 4 +-
src/backend/commands/opclasscmds.c | 20 +-
src/backend/commands/operatorcmds.c | 4 +-
src/backend/commands/policy.c | 16 +-
src/backend/commands/proclang.c | 2 +-
src/backend/commands/publicationcmds.c | 22 +-
src/backend/commands/schemacmds.c | 8 +-
src/backend/commands/sequence.c | 18 +-
src/backend/commands/statscmds.c | 6 +-
src/backend/commands/subscriptioncmds.c | 8 +-
src/backend/commands/tablecmds.c | 240 +++++++++---------
src/backend/commands/tablespace.c | 10 +-
src/backend/commands/trigger.c | 34 +--
src/backend/commands/tsearchcmds.c | 26 +-
src/backend/commands/typecmds.c | 42 +--
src/backend/commands/user.c | 14 +-
src/backend/commands/vacuum.c | 12 +-
src/backend/commands/variable.c | 4 +-
src/backend/executor/execAmi.c | 2 +-
src/backend/executor/functions.c | 4 +-
src/backend/executor/nodeAgg.c | 4 +-
src/backend/executor/nodeWindowAgg.c | 4 +-
src/backend/executor/spi.c | 2 +-
src/backend/foreign/foreign.c | 14 +-
src/backend/optimizer/plan/planagg.c | 2 +-
src/backend/optimizer/plan/subselect.c | 2 +-
src/backend/optimizer/prep/prepagg.c | 2 +-
src/backend/optimizer/util/appendinfo.c | 2 +-
src/backend/optimizer/util/clauses.c | 14 +-
src/backend/optimizer/util/plancat.c | 8 +-
src/backend/parser/parse_clause.c | 2 +-
src/backend/parser/parse_coerce.c | 12 +-
src/backend/parser/parse_func.c | 6 +-
src/backend/parser/parse_oper.c | 10 +-
src/backend/parser/parse_relation.c | 2 +-
src/backend/parser/parse_type.c | 32 +--
src/backend/parser/parse_utilcmd.c | 22 +-
src/backend/postmaster/autovacuum.c | 20 +-
src/backend/replication/logical/launcher.c | 2 +-
src/backend/replication/logical/origin.c | 4 +-
src/backend/replication/logical/proto.c | 4 +-
src/backend/replication/logical/worker.c | 2 +-
src/backend/rewrite/rewriteDefine.c | 10 +-
src/backend/rewrite/rewriteRemove.c | 2 +-
src/backend/rewrite/rewriteSupport.c | 4 +-
src/backend/statistics/extended_stats.c | 6 +-
src/backend/storage/large_object/inv_api.c | 8 +-
src/backend/tcop/fastpath.c | 2 +-
src/backend/tsearch/ts_selfuncs.c | 2 +-
src/backend/utils/adt/acl.c | 16 +-
src/backend/utils/adt/amutils.c | 4 +-
src/backend/utils/adt/array_selfuncs.c | 4 +-
src/backend/utils/adt/dbsize.c | 4 +-
src/backend/utils/adt/domains.c | 2 +-
src/backend/utils/adt/enum.c | 16 +-
src/backend/utils/adt/format_type.c | 4 +-
src/backend/utils/adt/jsonfuncs.c | 2 +-
src/backend/utils/adt/like_support.c | 2 +-
.../utils/adt/multirangetypes_selfuncs.c | 2 +-
src/backend/utils/adt/network_selfuncs.c | 10 +-
src/backend/utils/adt/pg_locale.c | 4 +-
src/backend/utils/adt/rangetypes_selfuncs.c | 2 +-
src/backend/utils/adt/regproc.c | 22 +-
src/backend/utils/adt/ri_triggers.c | 6 +-
src/backend/utils/adt/ruleutils.c | 54 ++--
src/backend/utils/adt/selfuncs.c | 28 +-
src/backend/utils/adt/xml.c | 4 +-
src/backend/utils/cache/evtcache.c | 2 +-
src/backend/utils/cache/inval.c | 10 +-
src/backend/utils/cache/lsyscache.c | 196 +++++++-------
src/backend/utils/cache/partcache.c | 4 +-
src/backend/utils/cache/relcache.c | 44 ++--
src/backend/utils/cache/relfilenumbermap.c | 2 +-
src/backend/utils/cache/syscache.c | 4 +-
src/backend/utils/cache/ts_cache.c | 12 +-
src/backend/utils/cache/typcache.c | 12 +-
src/backend/utils/fmgr/fmgr.c | 18 +-
src/backend/utils/fmgr/funcapi.c | 6 +-
src/backend/utils/init/miscinit.c | 6 +-
src/backend/utils/init/postinit.c | 10 +-
src/backend/utils/misc/rls.c | 2 +-
src/backend/utils/misc/superuser.c | 2 +-
src/include/access/htup_details.h | 2 +-
src/pl/plperl/plperl.c | 10 +-
src/pl/plpgsql/src/pl_comp.c | 14 +-
src/pl/plpgsql/src/pl_handler.c | 2 +-
src/pl/plpython/plpy_main.c | 2 +-
src/pl/plpython/plpy_procedure.c | 6 +-
src/pl/tcl/pltcl.c | 8 +-
src/test/modules/plsample/plsample.c | 8 +-
146 files changed, 1049 insertions(+), 1049 deletions(-)
diff --git a/contrib/bloom/blvalidate.c b/contrib/bloom/blvalidate.c
index 333a35d377..fc9911d6bf 100644
--- a/contrib/bloom/blvalidate.c
+++ b/contrib/bloom/blvalidate.c
@@ -52,7 +52,7 @@ blvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -65,7 +65,7 @@ blvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -77,7 +77,7 @@ blvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/*
@@ -138,7 +138,7 @@ blvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* Check it's allowed strategy for bloom */
if (oprform->amopstrategy < 1 ||
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index e323fdd0e6..faa2a07da2 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -2075,7 +2075,7 @@ get_pkey_attnames(Relation rel, int16 *indnkeyatts)
while (HeapTupleIsValid(indexTuple = systable_getnext(scan)))
{
- Form_pg_index index = (Form_pg_index) GETSTRUCT(indexTuple);
+ Form_pg_index index = GETSTRUCT(pg_index, indexTuple);
/* we're only interested if it is the primary key */
if (index->indisprimary)
diff --git a/contrib/intarray/_int_selfuncs.c b/contrib/intarray/_int_selfuncs.c
index 3d8ff6781b..a66d5fee92 100644
--- a/contrib/intarray/_int_selfuncs.c
+++ b/contrib/intarray/_int_selfuncs.c
@@ -191,7 +191,7 @@ _int_matchsel(PG_FUNCTION_ARGS)
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
nullfrac = stats->stanullfrac;
/*
diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c
index 8f4d8a5022..63dc4e8c55 100644
--- a/contrib/postgres_fdw/deparse.c
+++ b/contrib/postgres_fdw/deparse.c
@@ -3005,7 +3005,7 @@ deparseOpExpr(OpExpr *node, deparse_expr_cxt *context)
tuple = SearchSysCache1(OPEROID, ObjectIdGetDatum(node->opno));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for operator %u", node->opno);
- form = (Form_pg_operator) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_operator, tuple);
oprkind = form->oprkind;
/* Sanity check. */
@@ -3180,7 +3180,7 @@ deparseScalarArrayOpExpr(ScalarArrayOpExpr *node, deparse_expr_cxt *context)
tuple = SearchSysCache1(OPEROID, ObjectIdGetDatum(node->opno));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for operator %u", node->opno);
- form = (Form_pg_operator) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_operator, tuple);
/* Sanity check. */
Assert(list_length(node->args) == 2);
@@ -3519,7 +3519,7 @@ appendOrderBySuffix(Oid sortop, Oid sortcoltype, bool nulls_first,
opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(sortop));
if (!HeapTupleIsValid(opertup))
elog(ERROR, "cache lookup failed for operator %u", sortop);
- operform = (Form_pg_operator) GETSTRUCT(opertup);
+ operform = GETSTRUCT(pg_operator, opertup);
deparseOperatorName(buf, operform);
ReleaseSysCache(opertup);
}
@@ -3734,7 +3734,7 @@ appendFunctionName(Oid funcid, deparse_expr_cxt *context)
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
/* Print schema name only if it's not pg_catalog */
if (procform->pronamespace != PG_CATALOG_NAMESPACE)
diff --git a/contrib/sepgsql/database.c b/contrib/sepgsql/database.c
index dce97859f4..a73d600cb8 100644
--- a/contrib/sepgsql/database.c
+++ b/contrib/sepgsql/database.c
@@ -89,7 +89,7 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for database %u", databaseId);
- datForm = (Form_pg_database) GETSTRUCT(tuple);
+ datForm = GETSTRUCT(pg_database, tuple);
ncontext = sepgsql_compute_create(sepgsql_get_client_label(),
tcontext,
diff --git a/contrib/sepgsql/dml.c b/contrib/sepgsql/dml.c
index 3bb98dfb06..114a46c2db 100644
--- a/contrib/sepgsql/dml.c
+++ b/contrib/sepgsql/dml.c
@@ -52,7 +52,7 @@ fixup_whole_row_references(Oid relOid, Bitmapset *columns)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- natts = ((Form_pg_class) GETSTRUCT(tuple))->relnatts;
+ natts = (GETSTRUCT(pg_class, tuple))->relnatts;
ReleaseSysCache(tuple);
/* remove bit 0 from column set, add in all the non-dropped columns */
@@ -67,7 +67,7 @@ fixup_whole_row_references(Oid relOid, Bitmapset *columns)
if (!HeapTupleIsValid(tuple))
continue; /* unexpected case, should we error? */
- if (!((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
+ if (!(GETSTRUCT(pg_attribute, tuple))->attisdropped)
{
index = attno - FirstLowInvalidHeapAttributeNumber;
result = bms_add_member(result, index);
diff --git a/contrib/sepgsql/label.c b/contrib/sepgsql/label.c
index e4c98b7eae..a7dd60fb90 100644
--- a/contrib/sepgsql/label.c
+++ b/contrib/sepgsql/label.c
@@ -733,7 +733,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
switch (catalogId)
{
case DatabaseRelationId:
- datForm = (Form_pg_database) GETSTRUCT(tuple);
+ datForm = GETSTRUCT(pg_database, tuple);
objtype = SELABEL_DB_DATABASE;
@@ -746,7 +746,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
break;
case NamespaceRelationId:
- nspForm = (Form_pg_namespace) GETSTRUCT(tuple);
+ nspForm = GETSTRUCT(pg_namespace, tuple);
objtype = SELABEL_DB_SCHEMA;
@@ -760,7 +760,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
break;
case RelationRelationId:
- relForm = (Form_pg_class) GETSTRUCT(tuple);
+ relForm = GETSTRUCT(pg_class, tuple);
if (relForm->relkind == RELKIND_RELATION ||
relForm->relkind == RELKIND_PARTITIONED_TABLE)
@@ -785,7 +785,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
break;
case AttributeRelationId:
- attForm = (Form_pg_attribute) GETSTRUCT(tuple);
+ attForm = GETSTRUCT(pg_attribute, tuple);
if (get_rel_relkind(attForm->attrelid) != RELKIND_RELATION &&
get_rel_relkind(attForm->attrelid) != RELKIND_PARTITIONED_TABLE)
@@ -809,7 +809,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
break;
case ProcedureRelationId:
- proForm = (Form_pg_proc) GETSTRUCT(tuple);
+ proForm = GETSTRUCT(pg_proc, tuple);
objtype = SELABEL_DB_PROCEDURE;
diff --git a/contrib/sepgsql/proc.c b/contrib/sepgsql/proc.c
index 45f006ed2a..54446cb02d 100644
--- a/contrib/sepgsql/proc.c
+++ b/contrib/sepgsql/proc.c
@@ -68,7 +68,7 @@ sepgsql_proc_post_create(Oid functionId)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for function %u", functionId);
- proForm = (Form_pg_proc) GETSTRUCT(tuple);
+ proForm = GETSTRUCT(pg_proc, tuple);
/*
* check db_schema:{add_name} permission of the namespace
@@ -260,7 +260,7 @@ sepgsql_proc_setattr(Oid functionId)
newtup = systable_getnext(sscan);
if (!HeapTupleIsValid(newtup))
elog(ERROR, "could not find tuple for function %u", functionId);
- newform = (Form_pg_proc) GETSTRUCT(newtup);
+ newform = GETSTRUCT(pg_proc, newtup);
/*
* Fetch older catalog
@@ -268,7 +268,7 @@ sepgsql_proc_setattr(Oid functionId)
oldtup = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId));
if (!HeapTupleIsValid(oldtup))
elog(ERROR, "cache lookup failed for function %u", functionId);
- oldform = (Form_pg_proc) GETSTRUCT(oldtup);
+ oldform = GETSTRUCT(pg_proc, oldtup);
/*
* Does this ALTER command takes operation to namespace?
diff --git a/contrib/sepgsql/relation.c b/contrib/sepgsql/relation.c
index 8767988c4d..1d79397448 100644
--- a/contrib/sepgsql/relation.c
+++ b/contrib/sepgsql/relation.c
@@ -84,7 +84,7 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
elog(ERROR, "could not find tuple for column %d of relation %u",
attnum, relOid);
- attForm = (Form_pg_attribute) GETSTRUCT(tuple);
+ attForm = GETSTRUCT(pg_attribute, tuple);
scontext = sepgsql_get_client_label();
tcontext = sepgsql_get_label(RelationRelationId, relOid, 0);
@@ -271,7 +271,7 @@ sepgsql_relation_post_create(Oid relOid)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for relation %u", relOid);
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/* ignore indexes on toast tables */
if (classForm->relkind == RELKIND_INDEX &&
@@ -368,7 +368,7 @@ sepgsql_relation_post_create(Oid relOid)
while (HeapTupleIsValid(atup = systable_getnext(ascan)))
{
- attForm = (Form_pg_attribute) GETSTRUCT(atup);
+ attForm = GETSTRUCT(pg_attribute, atup);
resetStringInfo(&audit_name);
appendStringInfo(&audit_name, "%s.%s.%s",
@@ -494,7 +494,7 @@ sepgsql_relation_drop(Oid relOid)
for (i = 0; i < attrList->n_members; i++)
{
atttup = &attrList->members[i]->tuple;
- attForm = (Form_pg_attribute) GETSTRUCT(atttup);
+ attForm = GETSTRUCT(pg_attribute, atttup);
if (attForm->attisdropped)
continue;
@@ -662,7 +662,7 @@ sepgsql_relation_setattr(Oid relOid)
newtup = systable_getnext(sscan);
if (!HeapTupleIsValid(newtup))
elog(ERROR, "could not find tuple for relation %u", relOid);
- newform = (Form_pg_class) GETSTRUCT(newtup);
+ newform = GETSTRUCT(pg_class, newtup);
/*
* Fetch older catalog
@@ -670,7 +670,7 @@ sepgsql_relation_setattr(Oid relOid)
oldtup = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(oldtup))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- oldform = (Form_pg_class) GETSTRUCT(oldtup);
+ oldform = GETSTRUCT(pg_class, oldtup);
/*
* Does this ALTER command takes operation to namespace?
diff --git a/contrib/sepgsql/schema.c b/contrib/sepgsql/schema.c
index fecd02f07a..28c6cb3d03 100644
--- a/contrib/sepgsql/schema.c
+++ b/contrib/sepgsql/schema.c
@@ -67,7 +67,7 @@ sepgsql_schema_post_create(Oid namespaceId)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for namespace %u", namespaceId);
- nspForm = (Form_pg_namespace) GETSTRUCT(tuple);
+ nspForm = GETSTRUCT(pg_namespace, tuple);
nsp_name = NameStr(nspForm->nspname);
if (strncmp(nsp_name, "pg_temp_", 8) == 0)
nsp_name = "pg_temp";
diff --git a/contrib/tcn/tcn.c b/contrib/tcn/tcn.c
index a2de6c385c..ff9990e044 100644
--- a/contrib/tcn/tcn.c
+++ b/contrib/tcn/tcn.c
@@ -134,7 +134,7 @@ triggered_change_notification(PG_FUNCTION_ARGS)
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple)) /* should not happen */
elog(ERROR, "cache lookup failed for index %u", indexoid);
- index = (Form_pg_index) GETSTRUCT(indexTuple);
+ index = GETSTRUCT(pg_index, indexTuple);
/* we're only interested if it is the primary key and valid */
if (index->indisprimary && index->indisvalid)
{
diff --git a/src/backend/access/brin/brin_validate.c b/src/backend/access/brin/brin_validate.c
index c54c874bc0..06c60b6780 100644
--- a/src/backend/access/brin/brin_validate.c
+++ b/src/backend/access/brin/brin_validate.c
@@ -58,7 +58,7 @@ brinvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -68,7 +68,7 @@ brinvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -80,7 +80,7 @@ brinvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/* Check procedure numbers and function signatures */
@@ -146,7 +146,7 @@ brinvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* Check that only allowed strategy numbers exist */
if (oprform->amopstrategy < 1 || oprform->amopstrategy > 63)
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index 609329bb21..e58c1ff436 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -1393,7 +1393,7 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc,
if (isnull)
return NULL;
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/* Parse into appropriate format; don't error out here */
switch (classForm->relkind)
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index d6fb261e20..dfad4a8dfa 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -635,7 +635,7 @@ TupleDescInitEntry(TupleDesc desc,
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(oidtypeid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", oidtypeid);
- typeForm = (Form_pg_type) GETSTRUCT(tuple);
+ typeForm = GETSTRUCT(pg_type, tuple);
att->atttypid = oidtypeid;
att->attlen = typeForm->typlen;
diff --git a/src/backend/access/gin/ginvalidate.c b/src/backend/access/gin/ginvalidate.c
index 44f2ff205d..a873ab8b70 100644
--- a/src/backend/access/gin/ginvalidate.c
+++ b/src/backend/access/gin/ginvalidate.c
@@ -53,7 +53,7 @@ ginvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -66,7 +66,7 @@ ginvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -78,7 +78,7 @@ ginvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/*
@@ -172,7 +172,7 @@ ginvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* TODO: Check that only allowed strategy numbers exist */
if (oprform->amopstrategy < 1 || oprform->amopstrategy > 63)
diff --git a/src/backend/access/gist/gistvalidate.c b/src/backend/access/gist/gistvalidate.c
index 95beca05fe..ce87ea3f9e 100644
--- a/src/backend/access/gist/gistvalidate.c
+++ b/src/backend/access/gist/gistvalidate.c
@@ -54,7 +54,7 @@ gistvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -67,7 +67,7 @@ gistvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -79,7 +79,7 @@ gistvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/*
@@ -174,7 +174,7 @@ gistvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
Oid op_rettype;
/* TODO: Check that only allowed strategy numbers exist */
diff --git a/src/backend/access/hash/hashvalidate.c b/src/backend/access/hash/hashvalidate.c
index 10bf26ce7c..8f8712a552 100644
--- a/src/backend/access/hash/hashvalidate.c
+++ b/src/backend/access/hash/hashvalidate.c
@@ -67,7 +67,7 @@ hashvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -77,7 +77,7 @@ hashvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -89,7 +89,7 @@ hashvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
/*
* All hash functions should be registered with matching left/right
@@ -149,7 +149,7 @@ hashvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* Check that only allowed strategy numbers exist */
if (oprform->amopstrategy < 1 ||
@@ -299,7 +299,7 @@ check_hash_func_signature(Oid funcid, int16 amprocnum, Oid argtype)
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(tp);
+ procform = GETSTRUCT(pg_proc, tp);
if (procform->prorettype != restype || procform->proretset ||
procform->pronargs != nargs)
diff --git a/src/backend/access/index/amapi.c b/src/backend/access/index/amapi.c
index 2b028e1950..243d80c2e5 100644
--- a/src/backend/access/index/amapi.c
+++ b/src/backend/access/index/amapi.c
@@ -68,7 +68,7 @@ GetIndexAmRoutineByAmId(Oid amoid, bool noerror)
elog(ERROR, "cache lookup failed for access method %u",
amoid);
}
- amform = (Form_pg_am) GETSTRUCT(tuple);
+ amform = GETSTRUCT(pg_am, tuple);
/* Check if it's an index access method as opposed to some other AM */
if (amform->amtype != AMTYPE_INDEX)
@@ -123,7 +123,7 @@ amvalidate(PG_FUNCTION_ARGS)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
amoid = classform->opcmethod;
diff --git a/src/backend/access/index/amvalidate.c b/src/backend/access/index/amvalidate.c
index d13054e33f..89b5ade49a 100644
--- a/src/backend/access/index/amvalidate.c
+++ b/src/backend/access/index/amvalidate.c
@@ -62,14 +62,14 @@ identify_opfamily_groups(CatCList *oprlist, CatCList *proclist)
io = ip = 0;
if (io < oprlist->n_members)
{
- oprform = (Form_pg_amop) GETSTRUCT(&oprlist->members[io]->tuple);
+ oprform = GETSTRUCT(pg_amop, &oprlist->members[io]->tuple);
io++;
}
else
oprform = NULL;
if (ip < proclist->n_members)
{
- procform = (Form_pg_amproc) GETSTRUCT(&proclist->members[ip]->tuple);
+ procform = GETSTRUCT(pg_amproc, &proclist->members[ip]->tuple);
ip++;
}
else
@@ -89,7 +89,7 @@ identify_opfamily_groups(CatCList *oprlist, CatCList *proclist)
if (io < oprlist->n_members)
{
- oprform = (Form_pg_amop) GETSTRUCT(&oprlist->members[io]->tuple);
+ oprform = GETSTRUCT(pg_amop, &oprlist->members[io]->tuple);
io++;
}
else
@@ -109,7 +109,7 @@ identify_opfamily_groups(CatCList *oprlist, CatCList *proclist)
if (ip < proclist->n_members)
{
- procform = (Form_pg_amproc) GETSTRUCT(&proclist->members[ip]->tuple);
+ procform = GETSTRUCT(pg_amproc, &proclist->members[ip]->tuple);
ip++;
}
else
@@ -161,7 +161,7 @@ check_amproc_signature(Oid funcid, Oid restype, bool exact,
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(tp);
+ procform = GETSTRUCT(pg_proc, tp);
if (procform->prorettype != restype || procform->proretset ||
procform->pronargs < minargs || procform->pronargs > maxargs)
@@ -212,7 +212,7 @@ check_amop_signature(Oid opno, Oid restype, Oid lefttype, Oid righttype)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for operator %u", opno);
- opform = (Form_pg_operator) GETSTRUCT(tp);
+ opform = GETSTRUCT(pg_operator, tp);
if (opform->oprresult != restype || opform->oprkind != 'b' ||
opform->oprleft != lefttype || opform->oprright != righttype)
@@ -249,7 +249,7 @@ opclass_for_family_datatype(Oid amoid, Oid opfamilyoid, Oid datatypeoid)
for (i = 0; i < opclist->n_members; i++)
{
HeapTuple classtup = &opclist->members[i]->tuple;
- Form_pg_opclass classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ Form_pg_opclass classform = GETSTRUCT(pg_opclass, classtup);
if (classform->opcfamily == opfamilyoid &&
classform->opcintype == datatypeoid)
diff --git a/src/backend/access/nbtree/nbtvalidate.c b/src/backend/access/nbtree/nbtvalidate.c
index 55ed3251d3..05d3c6707e 100644
--- a/src/backend/access/nbtree/nbtvalidate.c
+++ b/src/backend/access/nbtree/nbtvalidate.c
@@ -62,7 +62,7 @@ btvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -72,7 +72,7 @@ btvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -84,7 +84,7 @@ btvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/* Check procedure numbers and function signatures */
@@ -141,7 +141,7 @@ btvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* Check that only allowed strategy numbers exist */
if (oprform->amopstrategy < 1 ||
diff --git a/src/backend/access/spgist/spgutils.c b/src/backend/access/spgist/spgutils.c
index 2c661fcf96..93ed425c29 100644
--- a/src/backend/access/spgist/spgutils.c
+++ b/src/backend/access/spgist/spgutils.c
@@ -163,7 +163,7 @@ fillTypeDesc(SpGistTypeDesc *desc, Oid type)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", type);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
desc->attlen = typtup->typlen;
desc->attbyval = typtup->typbyval;
desc->attalign = typtup->typalign;
@@ -1328,7 +1328,7 @@ spgproperty(Oid index_oid, int attno,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple amoptup = &catlist->members[i]->tuple;
- Form_pg_amop amopform = (Form_pg_amop) GETSTRUCT(amoptup);
+ Form_pg_amop amopform = GETSTRUCT(pg_amop, amoptup);
if (amopform->amoppurpose == AMOP_ORDER &&
(amopform->amoplefttype == opcintype ||
diff --git a/src/backend/access/spgist/spgvalidate.c b/src/backend/access/spgist/spgvalidate.c
index 82281f7b83..ab055f9371 100644
--- a/src/backend/access/spgist/spgvalidate.c
+++ b/src/backend/access/spgist/spgvalidate.c
@@ -64,7 +64,7 @@ spgvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -75,7 +75,7 @@ spgvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -88,7 +88,7 @@ spgvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/*
@@ -210,7 +210,7 @@ spgvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
Oid op_rettype;
/* TODO: Check that only allowed strategy numbers exist */
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 088556ab54..3a718201f3 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -720,7 +720,7 @@ populate_typ_list(void)
old = MemoryContextSwitchTo(TopMemoryContext);
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_type typForm = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typForm = GETSTRUCT(pg_type, tup);
struct typmap *newtyp;
newtyp = (struct typmap *) palloc(sizeof(struct typmap));
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index 5f1726c095..913fdbbea0 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -884,7 +884,7 @@ objectsInSchemaToOids(ObjectType objtype, List *nspnames)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Oid oid = ((Form_pg_proc) GETSTRUCT(tuple))->oid;
+ Oid oid = (GETSTRUCT(pg_proc, tuple))->oid;
objects = lappend_oid(objects, oid);
}
@@ -931,7 +931,7 @@ getRelationsInNamespace(Oid namespaceId, char relkind)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Oid oid = ((Form_pg_class) GETSTRUCT(tuple))->oid;
+ Oid oid = (GETSTRUCT(pg_class, tuple))->oid;
relations = lappend_oid(relations, oid);
}
@@ -1333,7 +1333,7 @@ SetDefaultACL(InternalDefaultACL *iacls)
* there shouldn't be anything depending on this entry.
*/
myself.classId = DefaultAclRelationId;
- myself.objectId = ((Form_pg_default_acl) GETSTRUCT(tuple))->oid;
+ myself.objectId = (GETSTRUCT(pg_default_acl, tuple))->oid;
myself.objectSubId = 0;
performDeletion(&myself, DROP_RESTRICT, 0);
@@ -1364,7 +1364,7 @@ SetDefaultACL(InternalDefaultACL *iacls)
}
else
{
- defAclOid = ((Form_pg_default_acl) GETSTRUCT(tuple))->oid;
+ defAclOid = (GETSTRUCT(pg_default_acl, tuple))->oid;
/* update existing entry */
values[Anum_pg_default_acl_defaclacl - 1] = PointerGetDatum(new_acl);
@@ -1460,7 +1460,7 @@ RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for default ACL %u", objid);
- pg_default_acl_tuple = (Form_pg_default_acl) GETSTRUCT(tuple);
+ pg_default_acl_tuple = GETSTRUCT(pg_default_acl, tuple);
iacls.roleid = pg_default_acl_tuple->defaclrole;
iacls.nspid = pg_default_acl_tuple->defaclnamespace;
@@ -1630,7 +1630,7 @@ expand_all_col_privileges(Oid table_oid, Form_pg_class classForm,
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
curr_att, table_oid);
- isdropped = ((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped;
+ isdropped = (GETSTRUCT(pg_attribute, attTuple))->attisdropped;
ReleaseSysCache(attTuple);
@@ -1676,7 +1676,7 @@ ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname,
if (!HeapTupleIsValid(attr_tuple))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relOid);
- pg_attribute_tuple = (Form_pg_attribute) GETSTRUCT(attr_tuple);
+ pg_attribute_tuple = GETSTRUCT(pg_attribute, attr_tuple);
/*
* Get working copy of existing ACL. If there's no ACL, substitute the
@@ -1825,7 +1825,7 @@ ExecGrant_Relation(InternalGrant *istmt)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
+ pg_class_tuple = GETSTRUCT(pg_class, tuple);
/* Not sensible to grant on an index */
if (pg_class_tuple->relkind == RELKIND_INDEX ||
@@ -2163,7 +2163,7 @@ ExecGrant_Database(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for database %u", datId);
- pg_database_tuple = (Form_pg_database) GETSTRUCT(tuple);
+ pg_database_tuple = GETSTRUCT(pg_database, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2284,7 +2284,7 @@ ExecGrant_Fdw(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for foreign-data wrapper %u", fdwid);
- pg_fdw_tuple = (Form_pg_foreign_data_wrapper) GETSTRUCT(tuple);
+ pg_fdw_tuple = GETSTRUCT(pg_foreign_data_wrapper, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2410,7 +2410,7 @@ ExecGrant_ForeignServer(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for foreign server %u", srvid);
- pg_server_tuple = (Form_pg_foreign_server) GETSTRUCT(tuple);
+ pg_server_tuple = GETSTRUCT(pg_foreign_server, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2535,7 +2535,7 @@ ExecGrant_Function(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcId);
- pg_proc_tuple = (Form_pg_proc) GETSTRUCT(tuple);
+ pg_proc_tuple = GETSTRUCT(pg_proc, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2658,7 +2658,7 @@ ExecGrant_Language(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for language %u", langId);
- pg_language_tuple = (Form_pg_language) GETSTRUCT(tuple);
+ pg_language_tuple = GETSTRUCT(pg_language, tuple);
if (!pg_language_tuple->lanpltrusted)
ereport(ERROR,
@@ -2803,7 +2803,7 @@ ExecGrant_Largeobject(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for large object %u", loid);
- form_lo_meta = (Form_pg_largeobject_metadata) GETSTRUCT(tuple);
+ form_lo_meta = GETSTRUCT(pg_largeobject_metadata, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2929,7 +2929,7 @@ ExecGrant_Namespace(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for namespace %u", nspid);
- pg_namespace_tuple = (Form_pg_namespace) GETSTRUCT(tuple);
+ pg_namespace_tuple = GETSTRUCT(pg_namespace, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -3054,7 +3054,7 @@ ExecGrant_Tablespace(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for tablespace %u", tblId);
- pg_tablespace_tuple = (Form_pg_tablespace) GETSTRUCT(tuple);
+ pg_tablespace_tuple = GETSTRUCT(pg_tablespace, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -3174,7 +3174,7 @@ ExecGrant_Type(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", typId);
- pg_type_tuple = (Form_pg_type) GETSTRUCT(tuple);
+ pg_type_tuple = GETSTRUCT(pg_type, tuple);
if (IsTrueArrayType(pg_type_tuple))
ereport(ERROR,
@@ -3958,7 +3958,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
attnum, table_oid)));
}
- attributeForm = (Form_pg_attribute) GETSTRUCT(attTuple);
+ attributeForm = GETSTRUCT(pg_attribute, attTuple);
/* Check dropped columns, too */
if (attributeForm->attisdropped)
@@ -4005,7 +4005,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
ReleaseSysCache(attTuple);
return 0;
}
- classForm = (Form_pg_class) GETSTRUCT(classTuple);
+ classForm = GETSTRUCT(pg_class, classTuple);
ownerId = classForm->relowner;
@@ -4072,7 +4072,7 @@ pg_class_aclmask_ext(Oid table_oid, Oid roleid, AclMode mask,
table_oid)));
}
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/*
* Deny anyone permission to update a system catalog unless
@@ -4183,7 +4183,7 @@ pg_database_aclmask(Oid db_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database with OID %u does not exist", db_oid)));
- ownerId = ((Form_pg_database) GETSTRUCT(tuple))->datdba;
+ ownerId = (GETSTRUCT(pg_database, tuple))->datdba;
aclDatum = SysCacheGetAttr(DATABASEOID, tuple, Anum_pg_database_datacl,
&isNull);
@@ -4352,7 +4352,7 @@ pg_proc_aclmask(Oid proc_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function with OID %u does not exist", proc_oid)));
- ownerId = ((Form_pg_proc) GETSTRUCT(tuple))->proowner;
+ ownerId = (GETSTRUCT(pg_proc, tuple))->proowner;
aclDatum = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_proacl,
&isNull);
@@ -4406,7 +4406,7 @@ pg_language_aclmask(Oid lang_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("language with OID %u does not exist", lang_oid)));
- ownerId = ((Form_pg_language) GETSTRUCT(tuple))->lanowner;
+ ownerId = (GETSTRUCT(pg_language, tuple))->lanowner;
aclDatum = SysCacheGetAttr(LANGOID, tuple, Anum_pg_language_lanacl,
&isNull);
@@ -4485,7 +4485,7 @@ pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("large object %u does not exist", lobj_oid)));
- ownerId = ((Form_pg_largeobject_metadata) GETSTRUCT(tuple))->lomowner;
+ ownerId = (GETSTRUCT(pg_largeobject_metadata, tuple))->lomowner;
aclDatum = heap_getattr(tuple, Anum_pg_largeobject_metadata_lomacl,
RelationGetDescr(pg_lo_meta), &isNull);
@@ -4570,7 +4570,7 @@ pg_namespace_aclmask(Oid nsp_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema with OID %u does not exist", nsp_oid)));
- ownerId = ((Form_pg_namespace) GETSTRUCT(tuple))->nspowner;
+ ownerId = (GETSTRUCT(pg_namespace, tuple))->nspowner;
aclDatum = SysCacheGetAttr(NAMESPACEOID, tuple, Anum_pg_namespace_nspacl,
&isNull);
@@ -4634,7 +4634,7 @@ pg_tablespace_aclmask(Oid spc_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("tablespace with OID %u does not exist", spc_oid)));
- ownerId = ((Form_pg_tablespace) GETSTRUCT(tuple))->spcowner;
+ ownerId = (GETSTRUCT(pg_tablespace, tuple))->spcowner;
aclDatum = SysCacheGetAttr(TABLESPACEOID, tuple,
Anum_pg_tablespace_spcacl,
@@ -4693,7 +4693,7 @@ pg_foreign_data_wrapper_aclmask(Oid fdw_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign-data wrapper with OID %u does not exist",
fdw_oid)));
- fdwForm = (Form_pg_foreign_data_wrapper) GETSTRUCT(tuple);
+ fdwForm = GETSTRUCT(pg_foreign_data_wrapper, tuple);
/*
* Normal case: get the FDW's ACL from pg_foreign_data_wrapper
@@ -4755,7 +4755,7 @@ pg_foreign_server_aclmask(Oid srv_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign server with OID %u does not exist",
srv_oid)));
- srvForm = (Form_pg_foreign_server) GETSTRUCT(tuple);
+ srvForm = GETSTRUCT(pg_foreign_server, tuple);
/*
* Normal case: get the foreign server's ACL from pg_foreign_server
@@ -4815,7 +4815,7 @@ pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type with OID %u does not exist",
type_oid)));
- typeForm = (Form_pg_type) GETSTRUCT(tuple);
+ typeForm = GETSTRUCT(pg_type, tuple);
/*
* "True" array types don't manage permissions of their own; consult the
@@ -4831,7 +4831,7 @@ pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how)
/* this case is not a user-facing error, so elog not ereport */
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", elttype_oid);
- typeForm = (Form_pg_type) GETSTRUCT(tuple);
+ typeForm = GETSTRUCT(pg_type, tuple);
}
/*
@@ -4936,7 +4936,7 @@ pg_attribute_aclcheck_all(Oid table_oid, Oid roleid, AclMode mode,
classTuple = SearchSysCache1(RELOID, ObjectIdGetDatum(table_oid));
if (!HeapTupleIsValid(classTuple))
return ACLCHECK_NO_PRIV;
- classForm = (Form_pg_class) GETSTRUCT(classTuple);
+ classForm = GETSTRUCT(pg_class, classTuple);
nattrs = classForm->relnatts;
@@ -4960,7 +4960,7 @@ pg_attribute_aclcheck_all(Oid table_oid, Oid roleid, AclMode mode,
continue;
/* ignore dropped columns */
- if (((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped)
+ if ((GETSTRUCT(pg_attribute, attTuple))->attisdropped)
{
ReleaseSysCache(attTuple);
continue;
@@ -5183,7 +5183,7 @@ pg_class_ownercheck(Oid class_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_TABLE),
errmsg("relation with OID %u does not exist", class_oid)));
- ownerId = ((Form_pg_class) GETSTRUCT(tuple))->relowner;
+ ownerId = (GETSTRUCT(pg_class, tuple))->relowner;
ReleaseSysCache(tuple);
@@ -5209,7 +5209,7 @@ pg_type_ownercheck(Oid type_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type with OID %u does not exist", type_oid)));
- ownerId = ((Form_pg_type) GETSTRUCT(tuple))->typowner;
+ ownerId = (GETSTRUCT(pg_type, tuple))->typowner;
ReleaseSysCache(tuple);
@@ -5235,7 +5235,7 @@ pg_oper_ownercheck(Oid oper_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("operator with OID %u does not exist", oper_oid)));
- ownerId = ((Form_pg_operator) GETSTRUCT(tuple))->oprowner;
+ ownerId = (GETSTRUCT(pg_operator, tuple))->oprowner;
ReleaseSysCache(tuple);
@@ -5261,7 +5261,7 @@ pg_proc_ownercheck(Oid proc_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function with OID %u does not exist", proc_oid)));
- ownerId = ((Form_pg_proc) GETSTRUCT(tuple))->proowner;
+ ownerId = (GETSTRUCT(pg_proc, tuple))->proowner;
ReleaseSysCache(tuple);
@@ -5287,7 +5287,7 @@ pg_language_ownercheck(Oid lan_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("language with OID %u does not exist", lan_oid)));
- ownerId = ((Form_pg_language) GETSTRUCT(tuple))->lanowner;
+ ownerId = (GETSTRUCT(pg_language, tuple))->lanowner;
ReleaseSysCache(tuple);
@@ -5332,7 +5332,7 @@ pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("large object %u does not exist", lobj_oid)));
- ownerId = ((Form_pg_largeobject_metadata) GETSTRUCT(tuple))->lomowner;
+ ownerId = (GETSTRUCT(pg_largeobject_metadata, tuple))->lomowner;
systable_endscan(scan);
table_close(pg_lo_meta, AccessShareLock);
@@ -5359,7 +5359,7 @@ pg_namespace_ownercheck(Oid nsp_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema with OID %u does not exist", nsp_oid)));
- ownerId = ((Form_pg_namespace) GETSTRUCT(tuple))->nspowner;
+ ownerId = (GETSTRUCT(pg_namespace, tuple))->nspowner;
ReleaseSysCache(tuple);
@@ -5386,7 +5386,7 @@ pg_tablespace_ownercheck(Oid spc_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("tablespace with OID %u does not exist", spc_oid)));
- spcowner = ((Form_pg_tablespace) GETSTRUCT(spctuple))->spcowner;
+ spcowner = (GETSTRUCT(pg_tablespace, spctuple))->spcowner;
ReleaseSysCache(spctuple);
@@ -5413,7 +5413,7 @@ pg_opclass_ownercheck(Oid opc_oid, Oid roleid)
errmsg("operator class with OID %u does not exist",
opc_oid)));
- ownerId = ((Form_pg_opclass) GETSTRUCT(tuple))->opcowner;
+ ownerId = (GETSTRUCT(pg_opclass, tuple))->opcowner;
ReleaseSysCache(tuple);
@@ -5440,7 +5440,7 @@ pg_opfamily_ownercheck(Oid opf_oid, Oid roleid)
errmsg("operator family with OID %u does not exist",
opf_oid)));
- ownerId = ((Form_pg_opfamily) GETSTRUCT(tuple))->opfowner;
+ ownerId = (GETSTRUCT(pg_opfamily, tuple))->opfowner;
ReleaseSysCache(tuple);
@@ -5467,7 +5467,7 @@ pg_ts_dict_ownercheck(Oid dict_oid, Oid roleid)
errmsg("text search dictionary with OID %u does not exist",
dict_oid)));
- ownerId = ((Form_pg_ts_dict) GETSTRUCT(tuple))->dictowner;
+ ownerId = (GETSTRUCT(pg_ts_dict, tuple))->dictowner;
ReleaseSysCache(tuple);
@@ -5494,7 +5494,7 @@ pg_ts_config_ownercheck(Oid cfg_oid, Oid roleid)
errmsg("text search configuration with OID %u does not exist",
cfg_oid)));
- ownerId = ((Form_pg_ts_config) GETSTRUCT(tuple))->cfgowner;
+ ownerId = (GETSTRUCT(pg_ts_config, tuple))->cfgowner;
ReleaseSysCache(tuple);
@@ -5521,7 +5521,7 @@ pg_foreign_data_wrapper_ownercheck(Oid srv_oid, Oid roleid)
errmsg("foreign-data wrapper with OID %u does not exist",
srv_oid)));
- ownerId = ((Form_pg_foreign_data_wrapper) GETSTRUCT(tuple))->fdwowner;
+ ownerId = (GETSTRUCT(pg_foreign_data_wrapper, tuple))->fdwowner;
ReleaseSysCache(tuple);
@@ -5548,7 +5548,7 @@ pg_foreign_server_ownercheck(Oid srv_oid, Oid roleid)
errmsg("foreign server with OID %u does not exist",
srv_oid)));
- ownerId = ((Form_pg_foreign_server) GETSTRUCT(tuple))->srvowner;
+ ownerId = (GETSTRUCT(pg_foreign_server, tuple))->srvowner;
ReleaseSysCache(tuple);
@@ -5575,7 +5575,7 @@ pg_event_trigger_ownercheck(Oid et_oid, Oid roleid)
errmsg("event trigger with OID %u does not exist",
et_oid)));
- ownerId = ((Form_pg_event_trigger) GETSTRUCT(tuple))->evtowner;
+ ownerId = (GETSTRUCT(pg_event_trigger, tuple))->evtowner;
ReleaseSysCache(tuple);
@@ -5601,7 +5601,7 @@ pg_database_ownercheck(Oid db_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database with OID %u does not exist", db_oid)));
- dba = ((Form_pg_database) GETSTRUCT(tuple))->datdba;
+ dba = (GETSTRUCT(pg_database, tuple))->datdba;
ReleaseSysCache(tuple);
@@ -5627,7 +5627,7 @@ pg_collation_ownercheck(Oid coll_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("collation with OID %u does not exist", coll_oid)));
- ownerId = ((Form_pg_collation) GETSTRUCT(tuple))->collowner;
+ ownerId = (GETSTRUCT(pg_collation, tuple))->collowner;
ReleaseSysCache(tuple);
@@ -5653,7 +5653,7 @@ pg_conversion_ownercheck(Oid conv_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("conversion with OID %u does not exist", conv_oid)));
- ownerId = ((Form_pg_conversion) GETSTRUCT(tuple))->conowner;
+ ownerId = (GETSTRUCT(pg_conversion, tuple))->conowner;
ReleaseSysCache(tuple);
@@ -5694,7 +5694,7 @@ pg_extension_ownercheck(Oid ext_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("extension with OID %u does not exist", ext_oid)));
- ownerId = ((Form_pg_extension) GETSTRUCT(tuple))->extowner;
+ ownerId = (GETSTRUCT(pg_extension, tuple))->extowner;
systable_endscan(scan);
table_close(pg_extension, AccessShareLock);
@@ -5721,7 +5721,7 @@ pg_publication_ownercheck(Oid pub_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("publication with OID %u does not exist", pub_oid)));
- ownerId = ((Form_pg_publication) GETSTRUCT(tuple))->pubowner;
+ ownerId = (GETSTRUCT(pg_publication, tuple))->pubowner;
ReleaseSysCache(tuple);
@@ -5747,7 +5747,7 @@ pg_subscription_ownercheck(Oid sub_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("subscription with OID %u does not exist", sub_oid)));
- ownerId = ((Form_pg_subscription) GETSTRUCT(tuple))->subowner;
+ ownerId = (GETSTRUCT(pg_subscription, tuple))->subowner;
ReleaseSysCache(tuple);
@@ -5774,7 +5774,7 @@ pg_statistics_object_ownercheck(Oid stat_oid, Oid roleid)
errmsg("statistics object with OID %u does not exist",
stat_oid)));
- ownerId = ((Form_pg_statistic_ext) GETSTRUCT(tuple))->stxowner;
+ ownerId = (GETSTRUCT(pg_statistic_ext, tuple))->stxowner;
ReleaseSysCache(tuple);
@@ -5805,7 +5805,7 @@ has_createrole_privilege(Oid roleid)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolcreaterole;
+ result = (GETSTRUCT(pg_authid, utup))->rolcreaterole;
ReleaseSysCache(utup);
}
return result;
@@ -5824,7 +5824,7 @@ has_bypassrls_privilege(Oid roleid)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolbypassrls;
+ result = (GETSTRUCT(pg_authid, utup))->rolbypassrls;
ReleaseSysCache(utup);
}
return result;
@@ -5996,7 +5996,7 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", objoid);
- pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
+ pg_class_tuple = GETSTRUCT(pg_class, tuple);
/*
* Indexes don't have permissions, neither do the pg_class rows for
@@ -6033,7 +6033,7 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
continue;
/* ignore dropped columns */
- if (((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped)
+ if ((GETSTRUCT(pg_attribute, attTuple))->attisdropped)
{
ReleaseSysCache(attTuple);
continue;
@@ -6290,7 +6290,7 @@ removeExtObjInitPriv(Oid objoid, Oid classoid)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", objoid);
- pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
+ pg_class_tuple = GETSTRUCT(pg_class, tuple);
/*
* Indexes don't have permissions, neither do the pg_class rows for
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 6f43870779..31e06aab3e 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -629,7 +629,7 @@ pg_nextoid(PG_FUNCTION_ARGS)
errmsg("column \"%s\" of relation \"%s\" does not exist",
NameStr(*attname), RelationGetRelationName(rel))));
- attform = ((Form_pg_attribute) GETSTRUCT(atttuple));
+ attform = (GETSTRUCT(pg_attribute, atttuple));
attno = attform->attnum;
if (attform->atttypid != OIDOID)
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index de10923391..4c96444617 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -577,7 +577,7 @@ findDependentObjects(const ObjectAddress *object,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend foundDep = GETSTRUCT(pg_depend, tup);
otherObject.classId = foundDep->refclassid;
otherObject.objectId = foundDep->refobjid;
@@ -866,7 +866,7 @@ findDependentObjects(const ObjectAddress *object,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend foundDep = GETSTRUCT(pg_depend, tup);
int subflags;
otherObject.classId = foundDep->classid;
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index e770ea6eb8..3c4778a5d4 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -1664,7 +1664,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- attStruct = (Form_pg_attribute) GETSTRUCT(tuple);
+ attStruct = GETSTRUCT(pg_attribute, tuple);
if (attnum < 0)
{
@@ -1776,7 +1776,7 @@ heap_drop_with_catalog(Oid relid)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- if (((Form_pg_class) GETSTRUCT(tuple))->relispartition)
+ if ((GETSTRUCT(pg_class, tuple))->relispartition)
{
/*
* We have to lock the parent if the partition is being detached,
@@ -1973,7 +1973,7 @@ RelationClearMissing(Relation rel)
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ attrtuple = GETSTRUCT(pg_attribute, tuple);
/* ignore any where atthasmissing is not true */
if (attrtuple->atthasmissing)
@@ -2032,7 +2032,7 @@ SetAttrMissing(Oid relid, char *attname, char *value)
if (!HeapTupleIsValid(atttup))
elog(ERROR, "cache lookup failed for attribute %s of relation %u",
attname, relid);
- attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
+ attStruct = GETSTRUCT(pg_attribute, atttup);
/* get an array value from the value string */
missingval = OidFunctionCall3(F_ARRAY_IN,
@@ -2536,7 +2536,7 @@ MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr,
/* There can be at most one matching row */
if (HeapTupleIsValid(tup = systable_getnext(conscan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tup);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tup);
/* Found it. Conflicts if not identical check constraint */
if (con->contype == CONSTRAINT_CHECK)
@@ -2605,7 +2605,7 @@ MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr,
ccname)));
tup = heap_copytuple(tup);
- con = (Form_pg_constraint) GETSTRUCT(tup);
+ con = GETSTRUCT(pg_constraint, tup);
/*
* In case of partitions, an inherited constraint must be inherited
@@ -2663,7 +2663,7 @@ SetRelationNumChecks(Relation rel, int numchecks)
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(rel));
- relStruct = (Form_pg_class) GETSTRUCT(reltup);
+ relStruct = GETSTRUCT(pg_class, reltup);
if (relStruct->relchecks != numchecks)
{
@@ -2882,7 +2882,7 @@ CopyStatistics(Oid fromrelid, Oid torelid)
/* make a modifiable copy */
tup = heap_copytuple(tup);
- statform = (Form_pg_statistic) GETSTRUCT(tup);
+ statform = GETSTRUCT(pg_statistic, tup);
/* update the copy of the tuple and insert it */
statform->starelid = torelid;
@@ -3207,7 +3207,7 @@ restart:
while (HeapTupleIsValid(tuple = systable_getnext(fkeyScan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
/* Not a foreign key */
if (con->contype != CONSTRAINT_FOREIGN)
@@ -3259,7 +3259,7 @@ restart:
tuple = systable_getnext(fkeyScan);
if (HeapTupleIsValid(tuple))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
/*
* pg_constraint rows always appear for partitioned hierarchies
@@ -3486,7 +3486,7 @@ StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
Form_pg_class classForm;
bool isnull;
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
Assert(!classForm->relispartition);
(void) SysCacheGetAttr(RELOID, tuple, Anum_pg_class_relpartbound,
&isnull);
@@ -3504,7 +3504,7 @@ StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
newtuple = heap_modify_tuple(tuple, RelationGetDescr(classRel),
new_val, new_null, new_repl);
/* Also set the flag */
- ((Form_pg_class) GETSTRUCT(newtuple))->relispartition = true;
+ (GETSTRUCT(pg_class, newtuple))->relispartition = true;
CatalogTupleUpdate(classRel, &newtuple->t_self, newtuple);
heap_freetuple(newtuple);
table_close(classRel, RowExclusiveLock);
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index c5d463ac55..bd909be6d1 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -170,7 +170,7 @@ relationHasPrimaryKey(Relation rel)
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple)) /* should not happen */
elog(ERROR, "cache lookup failed for index %u", indexoid);
- result = ((Form_pg_index) GETSTRUCT(indexTuple))->indisprimary;
+ result = (GETSTRUCT(pg_index, indexTuple))->indisprimary;
ReleaseSysCache(indexTuple);
if (result)
break;
@@ -251,7 +251,7 @@ index_check_primary_key(Relation heapRel,
if (!HeapTupleIsValid(atttuple))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, RelationGetRelid(heapRel));
- attform = (Form_pg_attribute) GETSTRUCT(atttuple);
+ attform = GETSTRUCT(pg_attribute, atttuple);
if (!attform->attnotnull)
ereport(ERROR,
@@ -369,7 +369,7 @@ ConstructTupleDescriptor(Relation heapRelation,
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(keyType));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", keyType);
- typeTup = (Form_pg_type) GETSTRUCT(tuple);
+ typeTup = GETSTRUCT(pg_type, tuple);
/*
* Assign some of the attributes values. Leave the rest.
@@ -426,7 +426,7 @@ ConstructTupleDescriptor(Relation heapRelation,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for opclass %u",
classObjectId[i]);
- opclassTup = (Form_pg_opclass) GETSTRUCT(tuple);
+ opclassTup = GETSTRUCT(pg_opclass, tuple);
if (OidIsValid(opclassTup->opckeytype))
keyType = opclassTup->opckeytype;
@@ -459,7 +459,7 @@ ConstructTupleDescriptor(Relation heapRelation,
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(keyType));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", keyType);
- typeTup = (Form_pg_type) GETSTRUCT(tuple);
+ typeTup = GETSTRUCT(pg_type, tuple);
to->atttypid = keyType;
to->atttypmod = -1;
@@ -812,7 +812,7 @@ index_create(Relation heapRelation,
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("nondeterministic collations are not supported for operator class \"%s\"",
- NameStr(((Form_pg_opclass) GETSTRUCT(classtup))->opcname))));
+ NameStr((GETSTRUCT(pg_opclass, classtup))->opcname))));
ReleaseSysCache(classtup);
}
}
@@ -1547,8 +1547,8 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
if (!HeapTupleIsValid(newClassTuple))
elog(ERROR, "could not find tuple for relation %u", newIndexId);
- oldClassForm = (Form_pg_class) GETSTRUCT(oldClassTuple);
- newClassForm = (Form_pg_class) GETSTRUCT(newClassTuple);
+ oldClassForm = GETSTRUCT(pg_class, oldClassTuple);
+ newClassForm = GETSTRUCT(pg_class, newClassTuple);
/* Swap the names */
namestrcpy(&newClassForm->relname, NameStr(oldClassForm->relname));
@@ -1577,8 +1577,8 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
if (!HeapTupleIsValid(newIndexTuple))
elog(ERROR, "could not find tuple for relation %u", newIndexId);
- oldIndexForm = (Form_pg_index) GETSTRUCT(oldIndexTuple);
- newIndexForm = (Form_pg_index) GETSTRUCT(newIndexTuple);
+ oldIndexForm = GETSTRUCT(pg_index, oldIndexTuple);
+ newIndexForm = GETSTRUCT(pg_index, newIndexTuple);
/*
* Copy constraint flags from the old index. This is safe because the old
@@ -1641,7 +1641,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
if (!HeapTupleIsValid(constraintTuple))
elog(ERROR, "could not find tuple for constraint %u", constraintOid);
- conForm = ((Form_pg_constraint) GETSTRUCT(constraintTuple));
+ conForm = (GETSTRUCT(pg_constraint, constraintTuple));
if (conForm->conindid == oldIndexId)
{
@@ -1663,14 +1663,14 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
while (HeapTupleIsValid((triggerTuple = systable_getnext(scan))))
{
- Form_pg_trigger tgForm = (Form_pg_trigger) GETSTRUCT(triggerTuple);
+ Form_pg_trigger tgForm = GETSTRUCT(pg_trigger, triggerTuple);
if (tgForm->tgconstrindid != oldIndexId)
continue;
/* Make a modifiable copy */
triggerTuple = heap_copytuple(triggerTuple);
- tgForm = (Form_pg_trigger) GETSTRUCT(triggerTuple);
+ tgForm = GETSTRUCT(pg_trigger, triggerTuple);
tgForm->tgconstrindid = newIndexId;
@@ -1776,7 +1776,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
while (HeapTupleIsValid((attrTuple = systable_getnext(scan))))
{
- Form_pg_attribute att = (Form_pg_attribute) GETSTRUCT(attrTuple);
+ Form_pg_attribute att = GETSTRUCT(pg_attribute, attrTuple);
Datum repl_val[Natts_pg_attribute];
bool repl_null[Natts_pg_attribute];
bool repl_repl[Natts_pg_attribute];
@@ -2078,7 +2078,7 @@ index_constraint_create(Relation heapRelation,
ObjectIdGetDatum(indexRelationId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexRelationId);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
if (mark_as_primary && !indexForm->indisprimary)
{
@@ -2854,7 +2854,7 @@ index_update_stats(Relation rel,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for relation %u", relid);
- rd_rel = (Form_pg_class) GETSTRUCT(tuple);
+ rd_rel = GETSTRUCT(pg_class, tuple);
/* Should this be a more comprehensive test? */
Assert(rd_rel->relkind != RELKIND_PARTITIONED_INDEX);
@@ -3078,7 +3078,7 @@ index_build(Relation heapRelation,
ObjectIdGetDatum(indexId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexId);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
/* If it's a new index, indcheckxmin shouldn't be set ... */
Assert(!indexForm->indcheckxmin);
@@ -3450,7 +3450,7 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
ObjectIdGetDatum(indexId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexId);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
/* Perform the requested state change on the copy */
switch (action)
@@ -3531,7 +3531,7 @@ IndexGetRelation(Oid indexId, bool missing_ok)
return InvalidOid;
elog(ERROR, "cache lookup failed for index %u", indexId);
}
- index = (Form_pg_index) GETSTRUCT(tuple);
+ index = GETSTRUCT(pg_index, tuple);
Assert(index->indexrelid == indexId);
result = index->indrelid;
@@ -3768,7 +3768,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
ObjectIdGetDatum(indexId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexId);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
index_bad = (!indexForm->indisvalid ||
!indexForm->indisready ||
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c
index fafb9349cc..737cc9d64b 100644
--- a/src/backend/catalog/namespace.c
+++ b/src/backend/catalog/namespace.c
@@ -717,7 +717,7 @@ RelationIsVisible(Oid relid)
reltup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", relid);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
recomputeNamespacePath();
@@ -825,7 +825,7 @@ TypeIsVisible(Oid typid)
typtup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(typtup))
elog(ERROR, "cache lookup failed for type %u", typid);
- typform = (Form_pg_type) GETSTRUCT(typtup);
+ typform = GETSTRUCT(pg_type, typtup);
recomputeNamespacePath();
@@ -986,7 +986,7 @@ FuncnameGetCandidates(List *names, int nargs, List *argnames,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple proctup = &catlist->members[i]->tuple;
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, proctup);
Oid *proargtypes = procform->proargtypes.values;
int pronargs = procform->pronargs;
int effective_nargs;
@@ -1349,7 +1349,7 @@ MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
bool include_out_arguments, int pronargs,
int **argnumbers)
{
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, proctup);
int numposargs = nargs - list_length(argnames);
int pronallargs;
Oid *p_argtypes;
@@ -1466,7 +1466,7 @@ FunctionIsVisible(Oid funcid)
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
recomputeNamespacePath();
@@ -1553,7 +1553,7 @@ OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
ObjectIdGetDatum(namespaceId));
if (HeapTupleIsValid(opertup))
{
- Form_pg_operator operclass = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operclass = GETSTRUCT(pg_operator, opertup);
Oid result = operclass->oid;
ReleaseSysCache(opertup);
@@ -1595,7 +1595,7 @@ OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple opertup = &catlist->members[i]->tuple;
- Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operform = GETSTRUCT(pg_operator, opertup);
if (operform->oprnamespace == namespaceId)
{
@@ -1678,7 +1678,7 @@ OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple opertup = &catlist->members[i]->tuple;
- Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operform = GETSTRUCT(pg_operator, opertup);
int pathpos = 0;
FuncCandidateList newResult;
@@ -1800,7 +1800,7 @@ OperatorIsVisible(Oid oprid)
oprtup = SearchSysCache1(OPEROID, ObjectIdGetDatum(oprid));
if (!HeapTupleIsValid(oprtup))
elog(ERROR, "cache lookup failed for operator %u", oprid);
- oprform = (Form_pg_operator) GETSTRUCT(oprtup);
+ oprform = GETSTRUCT(pg_operator, oprtup);
recomputeNamespacePath();
@@ -1886,7 +1886,7 @@ OpclassIsVisible(Oid opcid)
opctup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opcid));
if (!HeapTupleIsValid(opctup))
elog(ERROR, "cache lookup failed for opclass %u", opcid);
- opcform = (Form_pg_opclass) GETSTRUCT(opctup);
+ opcform = GETSTRUCT(pg_opclass, opctup);
recomputeNamespacePath();
@@ -1969,7 +1969,7 @@ OpfamilyIsVisible(Oid opfid)
opftup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfid));
if (!HeapTupleIsValid(opftup))
elog(ERROR, "cache lookup failed for opfamily %u", opfid);
- opfform = (Form_pg_opfamily) GETSTRUCT(opftup);
+ opfform = GETSTRUCT(pg_opfamily, opftup);
recomputeNamespacePath();
@@ -2032,7 +2032,7 @@ lookup_collation(const char *collname, Oid collnamespace, int32 encoding)
ObjectIdGetDatum(collnamespace));
if (!HeapTupleIsValid(colltup))
return InvalidOid;
- collform = (Form_pg_collation) GETSTRUCT(colltup);
+ collform = GETSTRUCT(pg_collation, colltup);
if (collform->collprovider == COLLPROVIDER_ICU)
{
if (is_encoding_supported_by_icu(encoding))
@@ -2101,7 +2101,7 @@ CollationIsVisible(Oid collid)
colltup = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
if (!HeapTupleIsValid(colltup))
elog(ERROR, "cache lookup failed for collation %u", collid);
- collform = (Form_pg_collation) GETSTRUCT(colltup);
+ collform = GETSTRUCT(pg_collation, colltup);
recomputeNamespacePath();
@@ -2184,7 +2184,7 @@ ConversionIsVisible(Oid conid)
contup = SearchSysCache1(CONVOID, ObjectIdGetDatum(conid));
if (!HeapTupleIsValid(contup))
elog(ERROR, "cache lookup failed for conversion %u", conid);
- conform = (Form_pg_conversion) GETSTRUCT(contup);
+ conform = GETSTRUCT(pg_conversion, contup);
recomputeNamespacePath();
@@ -2288,7 +2288,7 @@ StatisticsObjIsVisible(Oid relid)
stxtup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(stxtup))
elog(ERROR, "cache lookup failed for statistics object %u", relid);
- stxform = (Form_pg_statistic_ext) GETSTRUCT(stxtup);
+ stxform = GETSTRUCT(pg_statistic_ext, stxtup);
recomputeNamespacePath();
@@ -2411,7 +2411,7 @@ TSParserIsVisible(Oid prsId)
tup = SearchSysCache1(TSPARSEROID, ObjectIdGetDatum(prsId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search parser %u", prsId);
- form = (Form_pg_ts_parser) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_ts_parser, tup);
recomputeNamespacePath();
@@ -2538,7 +2538,7 @@ TSDictionaryIsVisible(Oid dictId)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search dictionary %u",
dictId);
- form = (Form_pg_ts_dict) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_ts_dict, tup);
recomputeNamespacePath();
@@ -2664,7 +2664,7 @@ TSTemplateIsVisible(Oid tmplId)
tup = SearchSysCache1(TSTEMPLATEOID, ObjectIdGetDatum(tmplId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search template %u", tmplId);
- form = (Form_pg_ts_template) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_ts_template, tup);
recomputeNamespacePath();
@@ -2791,7 +2791,7 @@ TSConfigIsVisible(Oid cfgid)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search configuration %u",
cfgid);
- form = (Form_pg_ts_config) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_ts_config, tup);
recomputeNamespacePath();
@@ -3835,7 +3835,7 @@ recomputeNamespacePath(void)
{
char *rname;
- rname = NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname);
+ rname = NameStr((GETSTRUCT(pg_authid, tuple))->rolname);
namespaceId = get_namespace_oid(rname, true);
ReleaseSysCache(tuple);
if (OidIsValid(namespaceId) &&
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 2d21db4690..87cb1c78ba 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -1643,7 +1643,7 @@ get_object_address_type(ObjectType objtype, TypeName *typename, bool missing_ok)
if (objtype == OBJECT_DOMAIN)
{
- if (((Form_pg_type) GETSTRUCT(tup))->typtype != TYPTYPE_DOMAIN)
+ if ((GETSTRUCT(pg_type, tup))->typtype != TYPTYPE_DOMAIN)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a domain",
@@ -1762,7 +1762,7 @@ get_object_address_opf_member(ObjectType objtype,
}
else
{
- address.objectId = ((Form_pg_amop) GETSTRUCT(tp))->oid;
+ address.objectId = (GETSTRUCT(pg_amop, tp))->oid;
ReleaseSysCache(tp);
}
}
@@ -1793,7 +1793,7 @@ get_object_address_opf_member(ObjectType objtype,
}
else
{
- address.objectId = ((Form_pg_amproc) GETSTRUCT(tp))->oid;
+ address.objectId = (GETSTRUCT(pg_amproc, tp))->oid;
ReleaseSysCache(tp);
}
}
@@ -1840,7 +1840,7 @@ get_object_address_usermapping(List *object, bool missing_ok)
username, servername)));
return address;
}
- userid = ((Form_pg_authid) GETSTRUCT(tp))->oid;
+ userid = (GETSTRUCT(pg_authid, tp))->oid;
ReleaseSysCache(tp);
}
@@ -1867,7 +1867,7 @@ get_object_address_usermapping(List *object, bool missing_ok)
return address;
}
- address.objectId = ((Form_pg_user_mapping) GETSTRUCT(tp))->oid;
+ address.objectId = (GETSTRUCT(pg_user_mapping, tp))->oid;
ReleaseSysCache(tp);
@@ -2040,7 +2040,7 @@ get_object_address_defacl(List *object, bool missing_ok)
CStringGetDatum(username));
if (!HeapTupleIsValid(tp))
goto not_found;
- userid = ((Form_pg_authid) GETSTRUCT(tp))->oid;
+ userid = (GETSTRUCT(pg_authid, tp))->oid;
ReleaseSysCache(tp);
/*
@@ -2064,7 +2064,7 @@ get_object_address_defacl(List *object, bool missing_ok)
if (!HeapTupleIsValid(tp))
goto not_found;
- address.objectId = ((Form_pg_default_acl) GETSTRUCT(tp))->oid;
+ address.objectId = (GETSTRUCT(pg_default_acl, tp))->oid;
ReleaseSysCache(tp);
return address;
@@ -2440,7 +2440,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
elog(ERROR, "constraint with OID %u does not exist",
address.objectId);
- contypid = ((Form_pg_constraint) GETSTRUCT(tuple))->contypid;
+ contypid = (GETSTRUCT(pg_constraint, tuple))->contypid;
ReleaseSysCache(tuple);
@@ -2908,7 +2908,7 @@ getPublicationSchemaInfo(const ObjectAddress *object, bool missing_ok,
return false;
}
- pnform = (Form_pg_publication_namespace) GETSTRUCT(tup);
+ pnform = GETSTRUCT(pg_publication_namespace, tup);
*pubname = get_publication_name(pnform->pnpubid, missing_ok);
if (!(*pubname))
{
@@ -3028,7 +3028,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- castForm = (Form_pg_cast) GETSTRUCT(tup);
+ castForm = GETSTRUCT(pg_cast, tup);
appendStringInfo(&buffer, _("cast from %s to %s"),
format_type_be(castForm->castsource),
@@ -3055,7 +3055,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- coll = (Form_pg_collation) GETSTRUCT(collTup);
+ coll = GETSTRUCT(pg_collation, collTup);
/* Qualify the name if not visible in search path */
if (CollationIsVisible(object->objectId))
@@ -3085,7 +3085,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- con = (Form_pg_constraint) GETSTRUCT(conTup);
+ con = GETSTRUCT(pg_constraint, conTup);
if (OidIsValid(con->conrelid))
{
@@ -3124,7 +3124,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- conv = (Form_pg_conversion) GETSTRUCT(conTup);
+ conv = GETSTRUCT(pg_conversion, conTup);
/* Qualify the name if not visible in search path */
if (ConversionIsVisible(object->objectId))
@@ -3208,14 +3208,14 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- opcForm = (Form_pg_opclass) GETSTRUCT(opcTup);
+ opcForm = GETSTRUCT(pg_opclass, opcTup);
amTup = SearchSysCache1(AMOID,
ObjectIdGetDatum(opcForm->opcmethod));
if (!HeapTupleIsValid(amTup))
elog(ERROR, "cache lookup failed for access method %u",
opcForm->opcmethod);
- amForm = (Form_pg_am) GETSTRUCT(amTup);
+ amForm = GETSTRUCT(pg_am, amTup);
/* Qualify the name if not visible in search path */
if (OpclassIsVisible(object->objectId))
@@ -3252,7 +3252,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
}
appendStringInfo(&buffer, _("access method %s"),
- NameStr(((Form_pg_am) GETSTRUCT(tup))->amname));
+ NameStr((GETSTRUCT(pg_am, tup))->amname));
ReleaseSysCache(tup);
break;
}
@@ -3290,7 +3290,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- amopForm = (Form_pg_amop) GETSTRUCT(tup);
+ amopForm = GETSTRUCT(pg_amop, tup);
initStringInfo(&opfam);
getOpFamilyDescription(&opfam, amopForm->amopfamily, false);
@@ -3347,7 +3347,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- amprocForm = (Form_pg_amproc) GETSTRUCT(tup);
+ amprocForm = GETSTRUCT(pg_amproc, tup);
initStringInfo(&opfam);
getOpFamilyDescription(&opfam, amprocForm->amprocfamily, false);
@@ -3403,7 +3403,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- rule = (Form_pg_rewrite) GETSTRUCT(tup);
+ rule = GETSTRUCT(pg_rewrite, tup);
initStringInfo(&rel);
getRelationDescription(&rel, rule->ev_class, false);
@@ -3449,7 +3449,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- trig = (Form_pg_trigger) GETSTRUCT(tup);
+ trig = GETSTRUCT(pg_trigger, tup);
initStringInfo(&rel);
getRelationDescription(&rel, trig->tgrelid, false);
@@ -3495,7 +3495,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- stxForm = (Form_pg_statistic_ext) GETSTRUCT(stxTup);
+ stxForm = GETSTRUCT(pg_statistic_ext, stxTup);
/* Qualify the name if not visible in search path */
if (StatisticsObjIsVisible(object->objectId))
@@ -3526,7 +3526,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
object->objectId);
break;
}
- prsForm = (Form_pg_ts_parser) GETSTRUCT(tup);
+ prsForm = GETSTRUCT(pg_ts_parser, tup);
/* Qualify the name if not visible in search path */
if (TSParserIsVisible(object->objectId))
@@ -3557,7 +3557,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- dictForm = (Form_pg_ts_dict) GETSTRUCT(tup);
+ dictForm = GETSTRUCT(pg_ts_dict, tup);
/* Qualify the name if not visible in search path */
if (TSDictionaryIsVisible(object->objectId))
@@ -3588,7 +3588,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- tmplForm = (Form_pg_ts_template) GETSTRUCT(tup);
+ tmplForm = GETSTRUCT(pg_ts_template, tup);
/* Qualify the name if not visible in search path */
if (TSTemplateIsVisible(object->objectId))
@@ -3619,7 +3619,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- cfgForm = (Form_pg_ts_config) GETSTRUCT(tup);
+ cfgForm = GETSTRUCT(pg_ts_config, tup);
/* Qualify the name if not visible in search path */
if (TSConfigIsVisible(object->objectId))
@@ -3715,7 +3715,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- umform = (Form_pg_user_mapping) GETSTRUCT(tup);
+ umform = GETSTRUCT(pg_user_mapping, tup);
useid = umform->umuser;
srv = GetForeignServer(umform->umserver);
@@ -3764,7 +3764,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- defacl = (Form_pg_default_acl) GETSTRUCT(tup);
+ defacl = GETSTRUCT(pg_default_acl, tup);
rolename = GetUserNameFromId(defacl->defaclrole, false);
@@ -3869,7 +3869,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
appendStringInfo(&buffer, _("event trigger %s"),
- NameStr(((Form_pg_event_trigger) GETSTRUCT(tup))->evtname));
+ NameStr((GETSTRUCT(pg_event_trigger, tup))->evtname));
ReleaseSysCache(tup);
break;
}
@@ -3932,7 +3932,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- form_policy = (Form_pg_policy) GETSTRUCT(tuple);
+ form_policy = GETSTRUCT(pg_policy, tuple);
initStringInfo(&rel);
getRelationDescription(&rel, form_policy->polrelid, false);
@@ -3989,7 +3989,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- prform = (Form_pg_publication_rel) GETSTRUCT(tup);
+ prform = GETSTRUCT(pg_publication_rel, tup);
pubname = get_publication_name(prform->prpubid, false);
initStringInfo(&rel);
@@ -4028,7 +4028,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- trfForm = (Form_pg_transform) GETSTRUCT(trfTup);
+ trfForm = GETSTRUCT(pg_transform, trfTup);
appendStringInfo(&buffer, _("transform for %s language %s"),
format_type_be(trfForm->trftype),
@@ -4087,7 +4087,7 @@ getRelationDescription(StringInfo buffer, Oid relid, bool missing_ok)
elog(ERROR, "cache lookup failed for relation %u", relid);
return;
}
- relForm = (Form_pg_class) GETSTRUCT(relTup);
+ relForm = GETSTRUCT(pg_class, relTup);
/* Qualify the name if not visible in search path */
if (RelationIsVisible(relid))
@@ -4162,13 +4162,13 @@ getOpFamilyDescription(StringInfo buffer, Oid opfid, bool missing_ok)
elog(ERROR, "cache lookup failed for opfamily %u", opfid);
return;
}
- opfForm = (Form_pg_opfamily) GETSTRUCT(opfTup);
+ opfForm = GETSTRUCT(pg_opfamily, opfTup);
amTup = SearchSysCache1(AMOID, ObjectIdGetDatum(opfForm->opfmethod));
if (!HeapTupleIsValid(amTup))
elog(ERROR, "cache lookup failed for access method %u",
opfForm->opfmethod);
- amForm = (Form_pg_am) GETSTRUCT(amTup);
+ amForm = GETSTRUCT(pg_am, amTup);
/* Qualify the name if not visible in search path */
if (OpfamilyIsVisible(opfid))
@@ -4626,7 +4626,7 @@ getRelationTypeDescription(StringInfo buffer, Oid relid, int32 objectSubId,
appendStringInfoString(buffer, "relation");
return;
}
- relForm = (Form_pg_class) GETSTRUCT(relTup);
+ relForm = GETSTRUCT(pg_class, relTup);
switch (relForm->relkind)
{
@@ -4693,7 +4693,7 @@ getConstraintTypeDescription(StringInfo buffer, Oid constroid, bool missing_ok)
return;
}
- constrForm = (Form_pg_constraint) GETSTRUCT(constrTup);
+ constrForm = GETSTRUCT(pg_constraint, constrTup);
if (OidIsValid(constrForm->conrelid))
appendStringInfoString(buffer, "table constraint");
@@ -4726,7 +4726,7 @@ getProcedureTypeDescription(StringInfo buffer, Oid procid,
appendStringInfoString(buffer, "routine");
return;
}
- procForm = (Form_pg_proc) GETSTRUCT(procTup);
+ procForm = GETSTRUCT(pg_proc, procTup);
if (procForm->prokind == PROKIND_AGGREGATE)
appendStringInfoString(buffer, "aggregate");
@@ -4870,7 +4870,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- castForm = (Form_pg_cast) GETSTRUCT(tup);
+ castForm = GETSTRUCT(pg_cast, tup);
appendStringInfo(&buffer, "(%s AS %s)",
format_type_be_qualified(castForm->castsource),
@@ -4901,7 +4901,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- coll = (Form_pg_collation) GETSTRUCT(collTup);
+ coll = GETSTRUCT(pg_collation, collTup);
schema = get_namespace_name_or_temp(coll->collnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -4927,7 +4927,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- con = (Form_pg_constraint) GETSTRUCT(conTup);
+ con = GETSTRUCT(pg_constraint, conTup);
if (OidIsValid(con->conrelid))
{
@@ -4975,7 +4975,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- conForm = (Form_pg_conversion) GETSTRUCT(conTup);
+ conForm = GETSTRUCT(pg_conversion, conTup);
schema = get_namespace_name_or_temp(conForm->connamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5022,7 +5022,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- langForm = (Form_pg_language) GETSTRUCT(langTup);
+ langForm = GETSTRUCT(pg_language, langTup);
appendStringInfoString(&buffer,
quote_identifier(NameStr(langForm->lanname)));
if (objname)
@@ -5071,7 +5071,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- opcForm = (Form_pg_opclass) GETSTRUCT(opcTup);
+ opcForm = GETSTRUCT(pg_opclass, opcTup);
schema = get_namespace_name_or_temp(opcForm->opcnamespace);
amTup = SearchSysCache1(AMOID,
@@ -5079,7 +5079,7 @@ getObjectIdentityParts(const ObjectAddress *object,
if (!HeapTupleIsValid(amTup))
elog(ERROR, "cache lookup failed for access method %u",
opcForm->opcmethod);
- amForm = (Form_pg_am) GETSTRUCT(amTup);
+ amForm = GETSTRUCT(pg_am, amTup);
appendStringInfo(&buffer, "%s USING %s",
quote_qualified_identifier(schema,
@@ -5153,7 +5153,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- amopForm = (Form_pg_amop) GETSTRUCT(tup);
+ amopForm = GETSTRUCT(pg_amop, tup);
initStringInfo(&opfam);
getOpFamilyIdentity(&opfam, amopForm->amopfamily, objname,
@@ -5215,7 +5215,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- amprocForm = (Form_pg_amproc) GETSTRUCT(tup);
+ amprocForm = GETSTRUCT(pg_amproc, tup);
initStringInfo(&opfam);
getOpFamilyIdentity(&opfam, amprocForm->amprocfamily, objname,
@@ -5263,7 +5263,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- rule = (Form_pg_rewrite) GETSTRUCT(tup);
+ rule = GETSTRUCT(pg_rewrite, tup);
appendStringInfo(&buffer, "%s on ",
quote_identifier(NameStr(rule->rulename)));
@@ -5296,7 +5296,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- trig = (Form_pg_trigger) GETSTRUCT(tup);
+ trig = GETSTRUCT(pg_trigger, tup);
appendStringInfo(&buffer, "%s on ",
quote_identifier(NameStr(trig->tgname)));
@@ -5342,7 +5342,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formStatistic = (Form_pg_statistic_ext) GETSTRUCT(tup);
+ formStatistic = GETSTRUCT(pg_statistic_ext, tup);
schema = get_namespace_name_or_temp(formStatistic->stxnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5369,7 +5369,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formParser = (Form_pg_ts_parser) GETSTRUCT(tup);
+ formParser = GETSTRUCT(pg_ts_parser, tup);
schema = get_namespace_name_or_temp(formParser->prsnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5396,7 +5396,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formDict = (Form_pg_ts_dict) GETSTRUCT(tup);
+ formDict = GETSTRUCT(pg_ts_dict, tup);
schema = get_namespace_name_or_temp(formDict->dictnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5423,7 +5423,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formTmpl = (Form_pg_ts_template) GETSTRUCT(tup);
+ formTmpl = GETSTRUCT(pg_ts_template, tup);
schema = get_namespace_name_or_temp(formTmpl->tmplnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5450,7 +5450,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formCfg = (Form_pg_ts_config) GETSTRUCT(tup);
+ formCfg = GETSTRUCT(pg_ts_config, tup);
schema = get_namespace_name_or_temp(formCfg->cfgnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5562,7 +5562,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- umform = (Form_pg_user_mapping) GETSTRUCT(tup);
+ umform = GETSTRUCT(pg_user_mapping, tup);
useid = umform->umuser;
srv = GetForeignServer(umform->umserver);
@@ -5618,7 +5618,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- defacl = (Form_pg_default_acl) GETSTRUCT(tup);
+ defacl = GETSTRUCT(pg_default_acl, tup);
username = GetUserNameFromId(defacl->defaclrole, false);
appendStringInfo(&buffer,
@@ -5705,7 +5705,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- trigForm = (Form_pg_event_trigger) GETSTRUCT(tup);
+ trigForm = GETSTRUCT(pg_event_trigger, tup);
evtname = pstrdup(NameStr(trigForm->evtname));
appendStringInfoString(&buffer, quote_identifier(evtname));
if (objname)
@@ -5763,7 +5763,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- policy = (Form_pg_policy) GETSTRUCT(tup);
+ policy = GETSTRUCT(pg_policy, tup);
appendStringInfo(&buffer, "%s on ",
quote_identifier(NameStr(policy->polname)));
@@ -5830,7 +5830,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- prform = (Form_pg_publication_rel) GETSTRUCT(tup);
+ prform = GETSTRUCT(pg_publication_rel, tup);
pubname = get_publication_name(prform->prpubid, false);
getRelationIdentity(&buffer, prform->prrelid, objname, false);
@@ -5882,7 +5882,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- transform = (Form_pg_transform) GETSTRUCT(tup);
+ transform = GETSTRUCT(pg_transform, tup);
transformType = format_type_be_qualified(transform->trftype);
transformLang = get_language_name(transform->trflang, false);
@@ -5948,13 +5948,13 @@ getOpFamilyIdentity(StringInfo buffer, Oid opfid, List **object,
elog(ERROR, "cache lookup failed for opfamily %u", opfid);
return;
}
- opfForm = (Form_pg_opfamily) GETSTRUCT(opfTup);
+ opfForm = GETSTRUCT(pg_opfamily, opfTup);
amTup = SearchSysCache1(AMOID, ObjectIdGetDatum(opfForm->opfmethod));
if (!HeapTupleIsValid(amTup))
elog(ERROR, "cache lookup failed for access method %u",
opfForm->opfmethod);
- amForm = (Form_pg_am) GETSTRUCT(amTup);
+ amForm = GETSTRUCT(pg_am, amTup);
schema = get_namespace_name_or_temp(opfForm->opfnamespace);
appendStringInfo(buffer, "%s USING %s",
@@ -5994,7 +5994,7 @@ getRelationIdentity(StringInfo buffer, Oid relid, List **object,
*object = NIL;
return;
}
- relForm = (Form_pg_class) GETSTRUCT(relTup);
+ relForm = GETSTRUCT(pg_class, relTup);
schema = get_namespace_name_or_temp(relForm->relnamespace);
appendStringInfoString(buffer,
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c
index c6ec479004..a3d4ebe38d 100644
--- a/src/backend/catalog/partition.c
+++ b/src/backend/catalog/partition.c
@@ -106,7 +106,7 @@ get_partition_parent_worker(Relation inhRel, Oid relid, bool *detach_pending)
tuple = systable_getnext(scan);
if (HeapTupleIsValid(tuple))
{
- Form_pg_inherits form = (Form_pg_inherits) GETSTRUCT(tuple);
+ Form_pg_inherits form = GETSTRUCT(pg_inherits, tuple);
/* Let caller know of partition being detached */
if (form->inhdetachpending)
@@ -187,7 +187,7 @@ index_get_partition(Relation partition, Oid indexId)
tup = SearchSysCache1(RELOID, ObjectIdGetDatum(partIdx));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for relation %u", partIdx);
- classForm = (Form_pg_class) GETSTRUCT(tup);
+ classForm = GETSTRUCT(pg_class, tup);
ispartition = classForm->relispartition;
ReleaseSysCache(tup);
if (!ispartition)
@@ -321,7 +321,7 @@ get_default_partition_oid(Oid parentId)
{
Form_pg_partitioned_table part_table_form;
- part_table_form = (Form_pg_partitioned_table) GETSTRUCT(tuple);
+ part_table_form = GETSTRUCT(pg_partitioned_table, tuple);
defaultPartId = part_table_form->partdefid;
ReleaseSysCache(tuple);
}
@@ -349,7 +349,7 @@ update_default_partition_oid(Oid parentId, Oid defaultPartId)
elog(ERROR, "cache lookup failed for partition key of relation %u",
parentId);
- part_table_form = (Form_pg_partitioned_table) GETSTRUCT(tuple);
+ part_table_form = GETSTRUCT(pg_partitioned_table, tuple);
part_table_form->partdefid = defaultPartId;
CatalogTupleUpdate(pg_partitioned_table, &tuple->t_self, tuple);
diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c
index 0d0daa69b3..392296edbe 100644
--- a/src/backend/catalog/pg_aggregate.c
+++ b/src/backend/catalog/pg_aggregate.c
@@ -250,7 +250,7 @@ AggregateCreate(const char *aggName,
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(transfn));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for function %u", transfn);
- proc = (Form_pg_proc) GETSTRUCT(tup);
+ proc = GETSTRUCT(pg_proc, tup);
/*
* If the transfn is strict and the initval is NULL, make sure first input
@@ -294,7 +294,7 @@ AggregateCreate(const char *aggName,
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(mtransfn));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for function %u", mtransfn);
- proc = (Form_pg_proc) GETSTRUCT(tup);
+ proc = GETSTRUCT(pg_proc, tup);
/*
* If the mtransfn is strict and the minitval is NULL, check first
@@ -339,7 +339,7 @@ AggregateCreate(const char *aggName,
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(minvtransfn));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for function %u", minvtransfn);
- proc = (Form_pg_proc) GETSTRUCT(tup);
+ proc = GETSTRUCT(pg_proc, tup);
/*
* We require the strictness settings of the forward and inverse
@@ -692,7 +692,7 @@ AggregateCreate(const char *aggName,
if (HeapTupleIsValid(oldtup))
{
- Form_pg_aggregate oldagg = (Form_pg_aggregate) GETSTRUCT(oldtup);
+ Form_pg_aggregate oldagg = GETSTRUCT(pg_aggregate, oldtup);
/*
* If we're replacing an existing entry, we need to validate that
diff --git a/src/backend/catalog/pg_attrdef.c b/src/backend/catalog/pg_attrdef.c
index c5d4a9912e..d52e1050ed 100644
--- a/src/backend/catalog/pg_attrdef.c
+++ b/src/backend/catalog/pg_attrdef.c
@@ -101,7 +101,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
if (!HeapTupleIsValid(atttup))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, RelationGetRelid(rel));
- attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
+ attStruct = GETSTRUCT(pg_attribute, atttup);
attgenerated = attStruct->attgenerated;
if (!attStruct->atthasdef)
{
@@ -240,7 +240,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
ObjectAddress object;
- Form_pg_attrdef attrtuple = (Form_pg_attrdef) GETSTRUCT(tuple);
+ Form_pg_attrdef attrtuple = GETSTRUCT(pg_attrdef, tuple);
object.classId = AttrDefaultRelationId;
object.objectId = attrtuple->oid;
@@ -295,8 +295,8 @@ RemoveAttrDefaultById(Oid attrdefId)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for attrdef %u", attrdefId);
- myrelid = ((Form_pg_attrdef) GETSTRUCT(tuple))->adrelid;
- myattnum = ((Form_pg_attrdef) GETSTRUCT(tuple))->adnum;
+ myrelid = (GETSTRUCT(pg_attrdef, tuple))->adrelid;
+ myattnum = (GETSTRUCT(pg_attrdef, tuple))->adnum;
/* Get an exclusive lock on the relation owning the attribute */
myrel = relation_open(myrelid, AccessExclusiveLock);
@@ -317,7 +317,7 @@ RemoveAttrDefaultById(Oid attrdefId)
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
myattnum, myrelid);
- ((Form_pg_attribute) GETSTRUCT(tuple))->atthasdef = false;
+ (GETSTRUCT(pg_attribute, tuple))->atthasdef = false;
CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple);
@@ -363,7 +363,7 @@ GetAttrDefaultOid(Oid relid, AttrNumber attnum)
if (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_attrdef atdform = (Form_pg_attrdef) GETSTRUCT(tup);
+ Form_pg_attrdef atdform = GETSTRUCT(pg_attrdef, tup);
result = atdform->oid;
}
@@ -399,7 +399,7 @@ GetAttrDefaultColumnAddress(Oid attrdefoid)
if (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_attrdef atdform = (Form_pg_attrdef) GETSTRUCT(tup);
+ Form_pg_attrdef atdform = GETSTRUCT(pg_attrdef, tup);
result.classId = RelationRelationId;
result.objectId = atdform->adrelid;
diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c
index bb65fb1e0a..48f1653242 100644
--- a/src/backend/catalog/pg_constraint.c
+++ b/src/backend/catalog/pg_constraint.c
@@ -577,7 +577,7 @@ RemoveConstraintById(Oid conId)
tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for constraint %u", conId);
- con = (Form_pg_constraint) GETSTRUCT(tup);
+ con = GETSTRUCT(pg_constraint, tup);
/*
* Special processing depending on what the constraint is for.
@@ -609,7 +609,7 @@ RemoveConstraintById(Oid conId)
if (!HeapTupleIsValid(relTup))
elog(ERROR, "cache lookup failed for relation %u",
con->conrelid);
- classForm = (Form_pg_class) GETSTRUCT(relTup);
+ classForm = GETSTRUCT(pg_class, relTup);
if (classForm->relchecks == 0) /* should not happen */
elog(ERROR, "relation \"%s\" has relchecks = 0",
@@ -668,7 +668,7 @@ RenameConstraintById(Oid conId, const char *newname)
tuple = SearchSysCacheCopy1(CONSTROID, ObjectIdGetDatum(conId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", conId);
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
/*
* For user-friendliness, check whether the name is already in use.
@@ -733,7 +733,7 @@ AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(tup);
+ Form_pg_constraint conform = GETSTRUCT(pg_constraint, tup);
ObjectAddress thisobj;
ObjectAddressSet(thisobj, ConstraintRelationId, conform->oid);
@@ -745,7 +745,7 @@ AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
if (conform->connamespace == oldNspId && oldNspId != newNspId)
{
tup = heap_copytuple(tup);
- conform = (Form_pg_constraint) GETSTRUCT(tup);
+ conform = GETSTRUCT(pg_constraint, tup);
conform->connamespace = newNspId;
@@ -794,7 +794,7 @@ ConstraintSetParentConstraint(Oid childConstrId,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", childConstrId);
newtup = heap_copytuple(tuple);
- constrForm = (Form_pg_constraint) GETSTRUCT(newtup);
+ constrForm = GETSTRUCT(pg_constraint, newtup);
if (OidIsValid(parentConstrId))
{
/* don't allow setting parent for a constraint that already has one */
@@ -875,7 +875,7 @@ get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok)
/* There can be at most one matching row */
if (HeapTupleIsValid(tuple = systable_getnext(scan)))
- conOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ conOid = (GETSTRUCT(pg_constraint, tuple))->oid;
systable_endscan(scan);
@@ -940,7 +940,7 @@ get_relation_constraint_attnos(Oid relid, const char *conname,
Datum adatum;
bool isNull;
- *constraintOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ *constraintOid = (GETSTRUCT(pg_constraint, tuple))->oid;
/* Extract the conkey array, ie, attnums of constrained columns */
adatum = heap_getattr(tuple, Anum_pg_constraint_conkey,
@@ -1010,7 +1010,7 @@ get_relation_idx_constraint_oid(Oid relationId, Oid indexId)
{
Form_pg_constraint constrForm;
- constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ constrForm = GETSTRUCT(pg_constraint, tuple);
if (constrForm->conindid == indexId)
{
constraintId = constrForm->oid;
@@ -1057,7 +1057,7 @@ get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok)
/* There can be at most one matching row */
if (HeapTupleIsValid(tuple = systable_getnext(scan)))
- conOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ conOid = (GETSTRUCT(pg_constraint, tuple))->oid;
systable_endscan(scan);
@@ -1112,7 +1112,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid)
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
Datum adatum;
bool isNull;
ArrayType *arr;
@@ -1137,7 +1137,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid)
RelationGetDescr(pg_constraint), &isNull);
if (isNull)
elog(ERROR, "null conkey for constraint %u",
- ((Form_pg_constraint) GETSTRUCT(tuple))->oid);
+ (GETSTRUCT(pg_constraint, tuple))->oid);
arr = DatumGetArrayTypeP(adatum); /* ensure not toasted */
numkeys = ARR_DIMS(arr)[0];
if (ARR_NDIM(arr) != 1 ||
@@ -1153,7 +1153,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid)
pkattnos = bms_add_member(pkattnos,
attnums[i] - FirstLowInvalidHeapAttributeNumber);
}
- *constraintOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ *constraintOid = (GETSTRUCT(pg_constraint, tuple))->oid;
/* No need to search further */
break;
@@ -1185,7 +1185,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ArrayType *arr;
int numkeys;
- constrId = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ constrId = (GETSTRUCT(pg_constraint, tuple))->oid;
/*
* We expect the arrays to be 1-D arrays of the right types; verify that.
diff --git a/src/backend/catalog/pg_conversion.c b/src/backend/catalog/pg_conversion.c
index 3d8b86ace7..4a39593d4a 100644
--- a/src/backend/catalog/pg_conversion.c
+++ b/src/backend/catalog/pg_conversion.c
@@ -168,7 +168,7 @@ FindDefaultConversion(Oid name_space, int32 for_encoding, int32 to_encoding)
for (i = 0; i < catlist->n_members; i++)
{
tuple = &catlist->members[i]->tuple;
- body = (Form_pg_conversion) GETSTRUCT(tuple);
+ body = GETSTRUCT(pg_conversion, tuple);
if (body->condefault)
{
proc = body->conproc;
diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c
index e86e5e6898..20ebdcc6e6 100644
--- a/src/backend/catalog/pg_depend.c
+++ b/src/backend/catalog/pg_depend.c
@@ -266,7 +266,7 @@ deleteDependencyRecordsFor(Oid classId, Oid objectId,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
if (skipExtensionDeps &&
- ((Form_pg_depend) GETSTRUCT(tup))->deptype == DEPENDENCY_EXTENSION)
+ (GETSTRUCT(pg_depend, tup))->deptype == DEPENDENCY_EXTENSION)
continue;
CatalogTupleDelete(depRel, &tup->t_self);
@@ -315,7 +315,7 @@ deleteDependencyRecordsForClass(Oid classId, Oid objectId,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == refclassId && depform->deptype == deptype)
{
@@ -362,7 +362,7 @@ deleteDependencyRecordsForSpecific(Oid classId, Oid objectId, char deptype,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == refclassId &&
depform->refobjid == refobjectId &&
@@ -464,7 +464,7 @@ changeDependencyFor(Oid classId, Oid objectId,
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == refClassId &&
depform->refobjid == oldRefObjectId)
@@ -475,7 +475,7 @@ changeDependencyFor(Oid classId, Oid objectId,
{
/* make a modifiable copy */
tup = heap_copytuple(tup);
- depform = (Form_pg_depend) GETSTRUCT(tup);
+ depform = GETSTRUCT(pg_depend, tup);
depform->refobjid = newRefObjectId;
@@ -533,7 +533,7 @@ changeDependenciesOf(Oid classId, Oid oldObjectId,
/* make a modifiable copy */
tup = heap_copytuple(tup);
- depform = (Form_pg_depend) GETSTRUCT(tup);
+ depform = GETSTRUCT(pg_depend, tup);
depform->objid = newObjectId;
@@ -620,7 +620,7 @@ changeDependenciesOn(Oid refClassId, Oid oldRefObjectId,
/* make a modifiable copy */
tup = heap_copytuple(tup);
- depform = (Form_pg_depend) GETSTRUCT(tup);
+ depform = GETSTRUCT(pg_depend, tup);
depform->refobjid = newRefObjectId;
@@ -695,7 +695,7 @@ getExtensionOfObject(Oid classId, Oid objectId)
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == ExtensionRelationId &&
depform->deptype == DEPENDENCY_EXTENSION)
@@ -741,7 +741,7 @@ getAutoExtensionsOfObject(Oid classId, Oid objectId)
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == ExtensionRelationId &&
depform->deptype == DEPENDENCY_AUTO_EXTENSION)
@@ -791,7 +791,7 @@ sequenceIsOwned(Oid seqId, char deptype, Oid *tableId, int32 *colId)
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == RelationRelationId &&
depform->deptype == deptype)
@@ -845,7 +845,7 @@ getOwnedSequences_internal(Oid relid, AttrNumber attnum, char deptype)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend deprec = GETSTRUCT(pg_depend, tup);
/*
* We assume any auto or internal dependency of a sequence on a column
@@ -937,7 +937,7 @@ get_index_constraint(Oid indexId)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend deprec = GETSTRUCT(pg_depend, tup);
/*
* We assume any internal dependency on a constraint must be what we
@@ -993,7 +993,7 @@ get_index_ref_constraints(Oid indexId)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend deprec = GETSTRUCT(pg_depend, tup);
/*
* We assume any normal dependency from a constraint must be what we
diff --git a/src/backend/catalog/pg_enum.c b/src/backend/catalog/pg_enum.c
index 114715498d..3a518b9122 100644
--- a/src/backend/catalog/pg_enum.c
+++ b/src/backend/catalog/pg_enum.c
@@ -292,7 +292,7 @@ restart:
*/
if (nelems > 0)
{
- Form_pg_enum en = (Form_pg_enum) GETSTRUCT(existing[nelems - 1]);
+ Form_pg_enum en = GETSTRUCT(pg_enum, existing[nelems - 1]);
newelemorder = en->enumsortorder + 1;
}
@@ -310,7 +310,7 @@ restart:
/* Locate the neighbor element */
for (nbr_index = 0; nbr_index < nelems; nbr_index++)
{
- Form_pg_enum en = (Form_pg_enum) GETSTRUCT(existing[nbr_index]);
+ Form_pg_enum en = GETSTRUCT(pg_enum, existing[nbr_index]);
if (strcmp(NameStr(en->enumlabel), neighbor) == 0)
break;
@@ -320,7 +320,7 @@ restart:
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" is not an existing enum label",
neighbor)));
- nbr_en = (Form_pg_enum) GETSTRUCT(existing[nbr_index]);
+ nbr_en = GETSTRUCT(pg_enum, existing[nbr_index]);
/*
* Attempt to assign an appropriate enumsortorder value: one less than
@@ -352,7 +352,7 @@ restart:
*/
volatile float4 midpoint;
- other_nbr_en = (Form_pg_enum) GETSTRUCT(existing[other_nbr_index]);
+ other_nbr_en = GETSTRUCT(pg_enum, existing[other_nbr_index]);
midpoint = (nbr_en->enumsortorder +
other_nbr_en->enumsortorder) / 2;
@@ -418,7 +418,7 @@ restart:
for (i = 0; i < nelems; i++)
{
HeapTuple exists_tup = existing[i];
- Form_pg_enum exists_en = (Form_pg_enum) GETSTRUCT(exists_tup);
+ Form_pg_enum exists_en = GETSTRUCT(pg_enum, exists_tup);
Oid exists_oid = exists_en->oid;
if (exists_oid & 1)
@@ -552,7 +552,7 @@ RenameEnumLabel(Oid enumTypeOid,
for (i = 0; i < nelems; i++)
{
enum_tup = &(list->members[i]->tuple);
- en = (Form_pg_enum) GETSTRUCT(enum_tup);
+ en = GETSTRUCT(pg_enum, enum_tup);
if (strcmp(NameStr(en->enumlabel), oldVal) == 0)
old_tup = enum_tup;
if (strcmp(NameStr(en->enumlabel), newVal) == 0)
@@ -571,7 +571,7 @@ RenameEnumLabel(Oid enumTypeOid,
/* OK, make a writable copy of old tuple */
enum_tup = heap_copytuple(old_tup);
- en = (Form_pg_enum) GETSTRUCT(enum_tup);
+ en = GETSTRUCT(pg_enum, enum_tup);
ReleaseCatCacheList(list);
@@ -656,7 +656,7 @@ RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems)
float4 newsortorder;
newtup = heap_copytuple(existing[i]);
- en = (Form_pg_enum) GETSTRUCT(newtup);
+ en = GETSTRUCT(pg_enum, newtup);
newsortorder = i + 1;
if (en->enumsortorder != newsortorder)
@@ -680,8 +680,8 @@ sort_order_cmp(const void *p1, const void *p2)
{
HeapTuple v1 = *((const HeapTuple *) p1);
HeapTuple v2 = *((const HeapTuple *) p2);
- Form_pg_enum en1 = (Form_pg_enum) GETSTRUCT(v1);
- Form_pg_enum en2 = (Form_pg_enum) GETSTRUCT(v2);
+ Form_pg_enum en1 = GETSTRUCT(pg_enum, v1);
+ Form_pg_enum en2 = GETSTRUCT(pg_enum, v2);
if (en1->enumsortorder < en2->enumsortorder)
return -1;
diff --git a/src/backend/catalog/pg_inherits.c b/src/backend/catalog/pg_inherits.c
index 92afbc2f25..2764c1c35c 100644
--- a/src/backend/catalog/pg_inherits.c
+++ b/src/backend/catalog/pg_inherits.c
@@ -136,7 +136,7 @@ find_inheritance_children_extended(Oid parentrelId, bool omit_detached,
* SERIALIZABLE transactions: such queries use a different snapshot
* than the one used by regular (user) queries.
*/
- if (((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending)
+ if ((GETSTRUCT(pg_inherits, inheritsTuple))->inhdetachpending)
{
if (detached_exist)
*detached_exist = true;
@@ -179,7 +179,7 @@ find_inheritance_children_extended(Oid parentrelId, bool omit_detached,
}
}
- inhrelid = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhrelid;
+ inhrelid = (GETSTRUCT(pg_inherits, inheritsTuple))->inhrelid;
if (numoids >= maxoids)
{
maxoids *= 2;
@@ -362,7 +362,7 @@ has_subclass(Oid relationId)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationId);
- result = ((Form_pg_class) GETSTRUCT(tuple))->relhassubclass;
+ result = (GETSTRUCT(pg_class, tuple))->relhassubclass;
ReleaseSysCache(tuple);
return result;
}
@@ -473,7 +473,7 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId)
while ((inhtup = systable_getnext(inhscan)) != NULL)
{
- Form_pg_inherits inh = (Form_pg_inherits) GETSTRUCT(inhtup);
+ Form_pg_inherits inh = GETSTRUCT(pg_inherits, inhtup);
Oid inhparent = inh->inhparent;
/* If this is the target superclass, we're done */
@@ -575,13 +575,13 @@ DeleteInheritsTuple(Oid inhrelid, Oid inhparent, bool expect_detach_pending,
Oid parent;
/* Compare inhparent if it was given, and do the actual deletion. */
- parent = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhparent;
+ parent = (GETSTRUCT(pg_inherits, inheritsTuple))->inhparent;
if (!OidIsValid(inhparent) || parent == inhparent)
{
bool detach_pending;
detach_pending =
- ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending;
+ (GETSTRUCT(pg_inherits, inheritsTuple))->inhdetachpending;
/*
* Raise error depending on state. This should only happen for
@@ -643,7 +643,7 @@ PartitionHasPendingDetach(Oid partoid)
bool detached;
detached =
- ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending;
+ (GETSTRUCT(pg_inherits, inheritsTuple))->inhdetachpending;
/* Done */
systable_endscan(scan);
diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c
index 630bf3e56c..6b4db2306f 100644
--- a/src/backend/catalog/pg_operator.c
+++ b/src/backend/catalog/pg_operator.c
@@ -143,7 +143,7 @@ OperatorGet(const char *operatorName,
ObjectIdGetDatum(operatorNamespace));
if (HeapTupleIsValid(tup))
{
- Form_pg_operator oprform = (Form_pg_operator) GETSTRUCT(tup);
+ Form_pg_operator oprform = GETSTRUCT(pg_operator, tup);
operatorObjectId = oprform->oid;
*defined = RegProcedureIsValid(oprform->oprcode);
@@ -677,7 +677,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId, bool isDelete)
/* Update the commutator's tuple if need be. */
if (HeapTupleIsValid(tup))
{
- Form_pg_operator t = (Form_pg_operator) GETSTRUCT(tup);
+ Form_pg_operator t = GETSTRUCT(pg_operator, tup);
bool update_commutator = false;
/*
@@ -722,7 +722,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId, bool isDelete)
if (HeapTupleIsValid(tup))
{
- Form_pg_operator t = (Form_pg_operator) GETSTRUCT(tup);
+ Form_pg_operator t = GETSTRUCT(pg_operator, tup);
bool update_negator = false;
/*
@@ -778,7 +778,7 @@ makeOperatorDependencies(HeapTuple tuple,
bool makeExtensionDep,
bool isUpdate)
{
- Form_pg_operator oper = (Form_pg_operator) GETSTRUCT(tuple);
+ Form_pg_operator oper = GETSTRUCT(pg_operator, tuple);
ObjectAddress myself,
referenced;
ObjectAddresses *addrs;
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index a9fe45e347..8eed22b3fb 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -365,7 +365,7 @@ ProcedureCreate(const char *procedureName,
if (HeapTupleIsValid(oldtup))
{
/* There is one; okay to replace it? */
- Form_pg_proc oldproc = (Form_pg_proc) GETSTRUCT(oldtup);
+ Form_pg_proc oldproc = GETSTRUCT(pg_proc, oldtup);
Datum proargnames;
bool isnull;
const char *dropcmd;
@@ -586,7 +586,7 @@ ProcedureCreate(const char *procedureName,
}
- retval = ((Form_pg_proc) GETSTRUCT(tup))->oid;
+ retval = (GETSTRUCT(pg_proc, tup))->oid;
/*
* Create dependencies for the new function. If we are updating an
@@ -842,7 +842,7 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- proc = (Form_pg_proc) GETSTRUCT(tuple);
+ proc = GETSTRUCT(pg_proc, tuple);
/* Disallow pseudotype result */
/* except for RECORD, VOID, or polymorphic */
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index c365de3a72..2819aafe75 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -236,7 +236,7 @@ pg_relation_is_publishable(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- result = is_publishable_class(relid, (Form_pg_class) GETSTRUCT(tuple));
+ result = is_publishable_class(relid, GETSTRUCT(pg_class, tuple));
ReleaseSysCache(tuple);
PG_RETURN_BOOL(result);
}
@@ -678,7 +678,7 @@ GetRelationPublications(Oid relid)
for (i = 0; i < pubrellist->n_members; i++)
{
HeapTuple tup = &pubrellist->members[i]->tuple;
- Oid pubid = ((Form_pg_publication_rel) GETSTRUCT(tup))->prpubid;
+ Oid pubid = (GETSTRUCT(pg_publication_rel, tup))->prpubid;
result = lappend_oid(result, pubid);
}
@@ -719,7 +719,7 @@ GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
{
Form_pg_publication_rel pubrel;
- pubrel = (Form_pg_publication_rel) GETSTRUCT(tup);
+ pubrel = GETSTRUCT(pg_publication_rel, tup);
result = GetPubPartitionOptionRelations(result, pub_partopt,
pubrel->prrelid);
}
@@ -760,7 +760,7 @@ GetAllTablesPublications(void)
result = NIL;
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Oid oid = ((Form_pg_publication) GETSTRUCT(tup))->oid;
+ Oid oid = (GETSTRUCT(pg_publication, tup))->oid;
result = lappend_oid(result, oid);
}
@@ -798,7 +798,7 @@ GetAllTablesPublicationRelations(bool pubviaroot)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class relForm = GETSTRUCT(pg_class, tuple);
Oid relid = relForm->oid;
if (is_publishable_class(relid, relForm) &&
@@ -819,7 +819,7 @@ GetAllTablesPublicationRelations(bool pubviaroot)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class relForm = GETSTRUCT(pg_class, tuple);
Oid relid = relForm->oid;
if (is_publishable_class(relid, relForm) &&
@@ -863,7 +863,7 @@ GetPublicationSchemas(Oid pubid)
{
Form_pg_publication_namespace pubsch;
- pubsch = (Form_pg_publication_namespace) GETSTRUCT(tup);
+ pubsch = GETSTRUCT(pg_publication_namespace, tup);
result = lappend_oid(result, pubsch->pnnspid);
}
@@ -890,7 +890,7 @@ GetSchemaPublications(Oid schemaid)
for (i = 0; i < pubschlist->n_members; i++)
{
HeapTuple tup = &pubschlist->members[i]->tuple;
- Oid pubid = ((Form_pg_publication_namespace) GETSTRUCT(tup))->pnpubid;
+ Oid pubid = (GETSTRUCT(pg_publication_namespace, tup))->pnpubid;
result = lappend_oid(result, pubid);
}
@@ -925,7 +925,7 @@ GetSchemaPublicationRelations(Oid schemaid, PublicationPartOpt pub_partopt)
scan = table_beginscan_catalog(classRel, 1, key);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class relForm = GETSTRUCT(pg_class, tuple);
Oid relid = relForm->oid;
char relkind;
@@ -995,7 +995,7 @@ GetPublication(Oid pubid)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication %u", pubid);
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
pub = (Publication *) palloc(sizeof(Publication));
pub->oid = pubid;
@@ -1068,7 +1068,7 @@ get_publication_name(Oid pubid, bool missing_ok)
return NULL;
}
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
pubname = pstrdup(NameStr(pubform->pubname));
ReleaseSysCache(tup);
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index 3e8fa008b9..b0f6ca6f8a 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -242,7 +242,7 @@ shdepChangeDep(Relation sdepRel,
while ((scantup = systable_getnext(scan)) != NULL)
{
/* Ignore if not of the target dependency type */
- if (((Form_pg_shdepend) GETSTRUCT(scantup))->deptype != deptype)
+ if ((GETSTRUCT(pg_shdepend, scantup))->deptype != deptype)
continue;
/* Caller screwed up if multiple matches */
if (oldtup)
@@ -263,7 +263,7 @@ shdepChangeDep(Relation sdepRel,
else if (oldtup)
{
/* Need to update existing entry */
- Form_pg_shdepend shForm = (Form_pg_shdepend) GETSTRUCT(oldtup);
+ Form_pg_shdepend shForm = GETSTRUCT(pg_shdepend, oldtup);
/* Since oldtup is a copy, we can just modify it in-memory */
shForm->refclassid = refclassid;
@@ -692,7 +692,7 @@ checkSharedDependencies(Oid classId, Oid objectId,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tup);
+ Form_pg_shdepend sdepForm = GETSTRUCT(pg_shdepend, tup);
object.classId = sdepForm->classid;
object.objectId = sdepForm->objid;
@@ -907,7 +907,7 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId)
memset(slot[slot_stored_count]->tts_isnull, false,
slot[slot_stored_count]->tts_tupleDescriptor->natts * sizeof(bool));
- shdep = (Form_pg_shdepend) GETSTRUCT(tup);
+ shdep = GETSTRUCT(pg_shdepend, tup);
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_dbid - 1] = ObjectIdGetDatum(newDbId);
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_classid - 1] = shdep->classid;
@@ -1115,7 +1115,7 @@ shdepDropDependency(Relation sdepRel,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_shdepend shdepForm = (Form_pg_shdepend) GETSTRUCT(tup);
+ Form_pg_shdepend shdepForm = GETSTRUCT(pg_shdepend, tup);
/* Filter entries according to additional parameters */
if (OidIsValid(refclassId) && shdepForm->refclassid != refclassId)
@@ -1347,7 +1347,7 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
while ((tuple = systable_getnext(scan)) != NULL)
{
- Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tuple);
+ Form_pg_shdepend sdepForm = GETSTRUCT(pg_shdepend, tuple);
ObjectAddress obj;
/*
@@ -1497,7 +1497,7 @@ shdepReassignOwned(List *roleids, Oid newrole)
while ((tuple = systable_getnext(scan)) != NULL)
{
- Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tuple);
+ Form_pg_shdepend sdepForm = GETSTRUCT(pg_shdepend, tuple);
MemoryContext cxt,
oldcxt;
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c
index 8856ce3b50..cb6e1675d9 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_subscription.c
@@ -58,7 +58,7 @@ GetSubscription(Oid subid, bool missing_ok)
elog(ERROR, "cache lookup failed for subscription %u", subid);
}
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = GETSTRUCT(pg_subscription, tup);
sub = (Subscription *) palloc(sizeof(Subscription));
sub->oid = subid;
@@ -239,7 +239,7 @@ get_subscription_name(Oid subid, bool missing_ok)
return NULL;
}
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = GETSTRUCT(pg_subscription, tup);
subname = pstrdup(NameStr(subform->subname));
ReleaseSysCache(tup);
@@ -399,7 +399,7 @@ GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn)
}
/* Get the state. */
- substate = ((Form_pg_subscription_rel) GETSTRUCT(tup))->srsubstate;
+ substate = (GETSTRUCT(pg_subscription_rel, tup))->srsubstate;
/* Get the LSN */
d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
@@ -456,7 +456,7 @@ RemoveSubscriptionRel(Oid subid, Oid relid)
{
Form_pg_subscription_rel subrel;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = GETSTRUCT(pg_subscription_rel, tup);
/*
* We don't allow to drop the relation mapping when the table
@@ -555,7 +555,7 @@ GetSubscriptionRelations(Oid subid)
Datum d;
bool isnull;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = GETSTRUCT(pg_subscription_rel, tup);
relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
@@ -614,7 +614,7 @@ GetSubscriptionNotReadyRelations(Oid subid)
Datum d;
bool isnull;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = GETSTRUCT(pg_subscription_rel, tup);
relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index 03788cb975..9fb756d728 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -424,7 +424,7 @@ TypeCreate(Oid newTypeOid,
ObjectIdGetDatum(typeNamespace));
if (HeapTupleIsValid(tup))
{
- Form_pg_type typform = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typform = GETSTRUCT(pg_type, tup);
/*
* check that the type is not already defined. It may exist as a
@@ -562,7 +562,7 @@ GenerateTypeDependencies(HeapTuple typeTuple,
bool makeExtensionDep,
bool rebuild)
{
- Form_pg_type typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
+ Form_pg_type typeForm = GETSTRUCT(pg_type, typeTuple);
Oid typeObjectId = typeForm->oid;
Datum datum;
bool isNull;
@@ -751,7 +751,7 @@ RenameTypeInternal(Oid typeOid, const char *newTypeName, Oid typeNamespace)
tuple = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typ = (Form_pg_type) GETSTRUCT(tuple);
+ typ = GETSTRUCT(pg_type, tuple);
/* We are not supposed to be changing schemas here */
Assert(typeNamespace == typ->typnamespace);
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index 9bc10729b0..5b10baff8a 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -341,7 +341,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- ((Form_pg_class) GETSTRUCT(reltup))->reltoastrelid = toast_relid;
+ (GETSTRUCT(pg_class, reltup))->reltoastrelid = toast_relid;
if (!IsBootstrapProcessingMode())
{
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 5456b8222b..018582b304 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -243,27 +243,27 @@ AlterObjectRename_internal(Relation rel, Oid objectId, const char *new_name)
*/
if (classId == ProcedureRelationId)
{
- Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(oldtup);
+ Form_pg_proc proc = GETSTRUCT(pg_proc, oldtup);
IsThereFunctionInNamespace(new_name, proc->pronargs,
&proc->proargtypes, proc->pronamespace);
}
else if (classId == CollationRelationId)
{
- Form_pg_collation coll = (Form_pg_collation) GETSTRUCT(oldtup);
+ Form_pg_collation coll = GETSTRUCT(pg_collation, oldtup);
IsThereCollationInNamespace(new_name, coll->collnamespace);
}
else if (classId == OperatorClassRelationId)
{
- Form_pg_opclass opc = (Form_pg_opclass) GETSTRUCT(oldtup);
+ Form_pg_opclass opc = GETSTRUCT(pg_opclass, oldtup);
IsThereOpClassInNamespace(new_name, opc->opcmethod,
opc->opcnamespace);
}
else if (classId == OperatorFamilyRelationId)
{
- Form_pg_opfamily opf = (Form_pg_opfamily) GETSTRUCT(oldtup);
+ Form_pg_opfamily opf = GETSTRUCT(pg_opfamily, oldtup);
IsThereOpFamilyInNamespace(new_name, opf->opfmethod,
opf->opfnamespace);
@@ -769,27 +769,27 @@ AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid)
*/
if (classId == ProcedureRelationId)
{
- Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(tup);
+ Form_pg_proc proc = GETSTRUCT(pg_proc, tup);
IsThereFunctionInNamespace(NameStr(proc->proname), proc->pronargs,
&proc->proargtypes, nspOid);
}
else if (classId == CollationRelationId)
{
- Form_pg_collation coll = (Form_pg_collation) GETSTRUCT(tup);
+ Form_pg_collation coll = GETSTRUCT(pg_collation, tup);
IsThereCollationInNamespace(NameStr(coll->collname), nspOid);
}
else if (classId == OperatorClassRelationId)
{
- Form_pg_opclass opc = (Form_pg_opclass) GETSTRUCT(tup);
+ Form_pg_opclass opc = GETSTRUCT(pg_opclass, tup);
IsThereOpClassInNamespace(NameStr(opc->opcname),
opc->opcmethod, nspOid);
}
else if (classId == OperatorFamilyRelationId)
{
- Form_pg_opfamily opf = (Form_pg_opfamily) GETSTRUCT(tup);
+ Form_pg_opfamily opf = GETSTRUCT(pg_opfamily, tup);
IsThereOpFamilyInNamespace(NameStr(opf->opfname),
opf->opfmethod, nspOid);
diff --git a/src/backend/commands/amcmds.c b/src/backend/commands/amcmds.c
index 914cfa4cc7..ea057efe80 100644
--- a/src/backend/commands/amcmds.c
+++ b/src/backend/commands/amcmds.c
@@ -134,7 +134,7 @@ get_am_type_oid(const char *amname, char amtype, bool missing_ok)
tup = SearchSysCache1(AMNAME, CStringGetDatum(amname));
if (HeapTupleIsValid(tup))
{
- Form_pg_am amform = (Form_pg_am) GETSTRUCT(tup);
+ Form_pg_am amform = GETSTRUCT(pg_am, tup);
if (amtype != '\0' &&
amform->amtype != amtype)
@@ -197,7 +197,7 @@ get_am_name(Oid amOid)
tup = SearchSysCache1(AMOID, ObjectIdGetDatum(amOid));
if (HeapTupleIsValid(tup))
{
- Form_pg_am amform = (Form_pg_am) GETSTRUCT(tup);
+ Form_pg_am amform = GETSTRUCT(pg_am, tup);
result = pstrdup(NameStr(amform->amname));
ReleaseSysCache(tup);
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 07613c38b5..156384f59e 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -1057,7 +1057,7 @@ examine_attribute(Relation onerel, int attnum, Node *index_expr)
ObjectIdGetDatum(stats->attrtypid));
if (!HeapTupleIsValid(typtuple))
elog(ERROR, "cache lookup failed for type %u", stats->attrtypid);
- stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple);
+ stats->attrtype = GETSTRUCT(pg_type, typtuple);
stats->anl_context = anl_context;
stats->tupattnum = attnum;
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index dc35b02910..d5163e038e 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -590,7 +590,7 @@ mark_index_clustered(Relation rel, Oid indexOid, bool is_internal)
ObjectIdGetDatum(thisIndexOid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", thisIndexOid);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
/*
* Unset the bit if set. We know it's wrong because we checked this
@@ -1003,7 +1003,7 @@ copy_table_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(OIDNewHeap));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", OIDNewHeap);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
relform->relpages = num_pages;
relform->reltuples = num_tuples;
@@ -1072,12 +1072,12 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
reltup1 = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(r1));
if (!HeapTupleIsValid(reltup1))
elog(ERROR, "cache lookup failed for relation %u", r1);
- relform1 = (Form_pg_class) GETSTRUCT(reltup1);
+ relform1 = GETSTRUCT(pg_class, reltup1);
reltup2 = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(r2));
if (!HeapTupleIsValid(reltup2))
elog(ERROR, "cache lookup failed for relation %u", r2);
- relform2 = (Form_pg_class) GETSTRUCT(reltup2);
+ relform2 = GETSTRUCT(pg_class, reltup2);
relfilenumber1 = relform1->relfilenode;
relfilenumber2 = relform2->relfilenode;
@@ -1515,7 +1515,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(OIDOldHeap));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", OIDOldHeap);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
relform->relfrozenxid = frozenXid;
relform->relminmxid = cutoffMulti;
@@ -1638,7 +1638,7 @@ get_tables_to_cluster(MemoryContext cluster_context)
{
RelToCluster *rtc;
- index = (Form_pg_index) GETSTRUCT(indexTuple);
+ index = GETSTRUCT(pg_index, indexTuple);
if (!pg_class_ownercheck(index->indrelid, GetUserId()))
continue;
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
index fcfc02d2ae..956249259f 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -137,9 +137,9 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collid);
- collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider;
- collisdeterministic = ((Form_pg_collation) GETSTRUCT(tp))->collisdeterministic;
- collencoding = ((Form_pg_collation) GETSTRUCT(tp))->collencoding;
+ collprovider = (GETSTRUCT(pg_collation, tp))->collprovider;
+ collisdeterministic = (GETSTRUCT(pg_collation, tp))->collisdeterministic;
+ collencoding = (GETSTRUCT(pg_collation, tp))->collencoding;
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collcollate, &isnull);
if (!isnull)
@@ -373,7 +373,7 @@ AlterCollation(AlterCollationStmt *stmt)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for collation %u", collOid);
- collForm = (Form_pg_collation) GETSTRUCT(tup);
+ collForm = GETSTRUCT(pg_collation, tup);
datum = SysCacheGetAttr(COLLOID, tup, Anum_pg_collation_collversion, &isnull);
oldversion = isnull ? NULL : TextDatumGetCString(datum);
@@ -438,7 +438,7 @@ pg_collation_actual_version(PG_FUNCTION_ARGS)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("collation with OID %u does not exist", collid)));
- collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider;
+ collprovider = (GETSTRUCT(pg_collation, tp))->collprovider;
if (collprovider != COLLPROVIDER_DEFAULT)
{
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 1901b434c5..7af9401e34 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -399,7 +399,7 @@ ScanSourceDatabasePgClassTuple(HeapTupleData *tuple, Oid tbid, Oid dbid,
Form_pg_class classForm;
Oid relfilenumber = InvalidRelFileNumber;
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/*
* Return NULL if this object does not need to be copied.
@@ -579,7 +579,7 @@ CreateDatabaseUsingFileCopy(Oid src_dboid, Oid dst_dboid, Oid src_tsid,
scan = table_beginscan_catalog(rel, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_tablespace spaceform = (Form_pg_tablespace) GETSTRUCT(tuple);
+ Form_pg_tablespace spaceform = GETSTRUCT(pg_tablespace, tuple);
Oid srctablespace = spaceform->oid;
Oid dsttablespace;
char *srcpath;
@@ -1792,7 +1792,7 @@ RenameDatabase(const char *oldname, const char *newname)
newtup = SearchSysCacheCopy1(DATABASEOID, ObjectIdGetDatum(db_id));
if (!HeapTupleIsValid(newtup))
elog(ERROR, "cache lookup failed for database %u", db_id);
- namestrcpy(&(((Form_pg_database) GETSTRUCT(newtup))->datname), newname);
+ namestrcpy(&((GETSTRUCT(pg_database, newtup))->datname), newname);
CatalogTupleUpdate(rel, &newtup->t_self, newtup);
InvokeObjectPostAlterHook(DatabaseRelationId, db_id, 0);
@@ -2284,7 +2284,7 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", stmt->dbname)));
- datform = (Form_pg_database) GETSTRUCT(tuple);
+ datform = GETSTRUCT(pg_database, tuple);
dboid = datform->oid;
if (!pg_database_ownercheck(dboid, GetUserId()))
@@ -2371,7 +2371,7 @@ AlterDatabaseRefreshColl(AlterDatabaseRefreshCollStmt *stmt)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", stmt->dbname)));
- datForm = (Form_pg_database) GETSTRUCT(tuple);
+ datForm = GETSTRUCT(pg_database, tuple);
db_id = datForm->oid;
if (!pg_database_ownercheck(db_id, GetUserId()))
@@ -2481,7 +2481,7 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", dbname)));
- datForm = (Form_pg_database) GETSTRUCT(tuple);
+ datForm = GETSTRUCT(pg_database, tuple);
db_id = datForm->oid;
/*
@@ -2581,7 +2581,7 @@ pg_database_collation_actual_version(PG_FUNCTION_ARGS)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("database with OID %u does not exist", dbid)));
- datlocprovider = ((Form_pg_database) GETSTRUCT(tp))->datlocprovider;
+ datlocprovider = (GETSTRUCT(pg_database, tp))->datlocprovider;
datum = SysCacheGetAttr(DATABASEOID, tp, datlocprovider == COLLPROVIDER_ICU ? Anum_pg_database_daticulocale : Anum_pg_database_datcollate, &isnull);
if (isnull)
@@ -2657,7 +2657,7 @@ get_db_info(const char *name, LOCKMODE lockmode,
break;
}
- dbOid = ((Form_pg_database) GETSTRUCT(tuple))->oid;
+ dbOid = (GETSTRUCT(pg_database, tuple))->oid;
systable_endscan(scan);
@@ -2675,7 +2675,7 @@ get_db_info(const char *name, LOCKMODE lockmode,
tuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbOid));
if (HeapTupleIsValid(tuple))
{
- Form_pg_database dbform = (Form_pg_database) GETSTRUCT(tuple);
+ Form_pg_database dbform = GETSTRUCT(pg_database, tuple);
if (strcmp(name, NameStr(dbform->datname)) == 0)
{
@@ -2768,7 +2768,7 @@ have_createdb_privilege(void)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(GetUserId()));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolcreatedb;
+ result = (GETSTRUCT(pg_authid, utup))->rolcreatedb;
ReleaseSysCache(utup);
}
return result;
@@ -2796,7 +2796,7 @@ remove_dbtablespaces(Oid db_id)
scan = table_beginscan_catalog(rel, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_tablespace spcform = (Form_pg_tablespace) GETSTRUCT(tuple);
+ Form_pg_tablespace spcform = GETSTRUCT(pg_tablespace, tuple);
Oid dsttablespace = spcform->oid;
char *dstpath;
struct stat st;
@@ -2882,7 +2882,7 @@ check_db_file_conflict(Oid db_id)
scan = table_beginscan_catalog(rel, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_tablespace spcform = (Form_pg_tablespace) GETSTRUCT(tuple);
+ Form_pg_tablespace spcform = GETSTRUCT(pg_tablespace, tuple);
Oid dsttablespace = spcform->oid;
char *dstpath;
struct stat st;
@@ -2968,7 +2968,7 @@ get_database_oid(const char *dbname, bool missing_ok)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(dbtuple))
- oid = ((Form_pg_database) GETSTRUCT(dbtuple))->oid;
+ oid = (GETSTRUCT(pg_database, dbtuple))->oid;
else
oid = InvalidOid;
@@ -2999,7 +2999,7 @@ get_database_name(Oid dbid)
dbtuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbid));
if (HeapTupleIsValid(dbtuple))
{
- result = pstrdup(NameStr(((Form_pg_database) GETSTRUCT(dbtuple))->datname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_database, dbtuple))->datname));
ReleaseSysCache(dbtuple);
}
else
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index f46f86474a..04d5f2ed68 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -376,7 +376,7 @@ AlterEventTrigger(AlterEventTrigStmt *stmt)
errmsg("event trigger \"%s\" does not exist",
stmt->trigname)));
- evtForm = (Form_pg_event_trigger) GETSTRUCT(tup);
+ evtForm = GETSTRUCT(pg_event_trigger, tup);
trigoid = evtForm->oid;
if (!pg_event_trigger_ownercheck(trigoid, GetUserId()))
@@ -419,7 +419,7 @@ AlterEventTriggerOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("event trigger \"%s\" does not exist", name)));
- evtForm = (Form_pg_event_trigger) GETSTRUCT(tup);
+ evtForm = GETSTRUCT(pg_event_trigger, tup);
evtOid = evtForm->oid;
AlterEventTriggerOwner_internal(rel, tup, newOwnerId);
@@ -466,7 +466,7 @@ AlterEventTriggerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
{
Form_pg_event_trigger form;
- form = (Form_pg_event_trigger) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_event_trigger, tup);
if (form->evtowner == newOwnerId)
return;
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index 3db859c3ea..fd31544069 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -159,7 +159,7 @@ get_extension_oid(const char *extname, bool missing_ok)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = ((Form_pg_extension) GETSTRUCT(tuple))->oid;
+ result = (GETSTRUCT(pg_extension, tuple))->oid;
else
result = InvalidOid;
@@ -204,7 +204,7 @@ get_extension_name(Oid ext_oid)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = pstrdup(NameStr(((Form_pg_extension) GETSTRUCT(tuple))->extname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_extension, tuple))->extname));
else
result = NULL;
@@ -243,7 +243,7 @@ get_extension_schema(Oid ext_oid)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = ((Form_pg_extension) GETSTRUCT(tuple))->extnamespace;
+ result = (GETSTRUCT(pg_extension, tuple))->extnamespace;
else
result = InvalidOid;
@@ -2762,7 +2762,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
/* Copy tuple so we can modify it below */
extTup = heap_copytuple(extTup);
- extForm = (Form_pg_extension) GETSTRUCT(extTup);
+ extForm = GETSTRUCT(pg_extension, extTup);
systable_endscan(extScan);
@@ -2805,7 +2805,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
while (HeapTupleIsValid(depTup = systable_getnext(depScan)))
{
- Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend pg_depend = GETSTRUCT(pg_depend, depTup);
ObjectAddress dep;
Oid dep_oldNspOid;
@@ -2927,7 +2927,7 @@ ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt)
errmsg("extension \"%s\" does not exist",
stmt->extname)));
- extensionOid = ((Form_pg_extension) GETSTRUCT(extTup))->oid;
+ extensionOid = (GETSTRUCT(pg_extension, extTup))->oid;
/*
* Determine the existing version we are updating from
@@ -3079,7 +3079,7 @@ ApplyExtensionUpdates(Oid extensionOid,
elog(ERROR, "could not find tuple for extension %u",
extensionOid);
- extForm = (Form_pg_extension) GETSTRUCT(extTup);
+ extForm = GETSTRUCT(pg_extension, extTup);
/*
* Determine the target schema (set by original install)
diff --git a/src/backend/commands/foreigncmds.c b/src/backend/commands/foreigncmds.c
index ea27857bb8..899e1cceef 100644
--- a/src/backend/commands/foreigncmds.c
+++ b/src/backend/commands/foreigncmds.c
@@ -212,7 +212,7 @@ AlterForeignDataWrapperOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerI
Datum aclDatum;
bool isNull;
- form = (Form_pg_foreign_data_wrapper) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_foreign_data_wrapper, tup);
/* Must be a superuser to change a FDW owner */
if (!superuser())
@@ -290,7 +290,7 @@ AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign-data wrapper \"%s\" does not exist", name)));
- form = (Form_pg_foreign_data_wrapper) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_foreign_data_wrapper, tup);
fdwId = form->oid;
AlterForeignDataWrapperOwner_internal(rel, tup, newOwnerId);
@@ -345,7 +345,7 @@ AlterForeignServerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
Datum aclDatum;
bool isNull;
- form = (Form_pg_foreign_server) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_foreign_server, tup);
if (form->srvowner != newOwnerId)
{
@@ -429,7 +429,7 @@ AlterForeignServerOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("server \"%s\" does not exist", name)));
- form = (Form_pg_foreign_server) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_foreign_server, tup);
servOid = form->oid;
AlterForeignServerOwner_internal(rel, tup, newOwnerId);
@@ -706,7 +706,7 @@ AlterForeignDataWrapper(ParseState *pstate, AlterFdwStmt *stmt)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign-data wrapper \"%s\" does not exist", stmt->fdwname)));
- fdwForm = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp);
+ fdwForm = GETSTRUCT(pg_foreign_data_wrapper, tp);
fdwId = fdwForm->oid;
memset(repl_val, 0, sizeof(repl_val));
@@ -983,7 +983,7 @@ AlterForeignServer(AlterForeignServerStmt *stmt)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("server \"%s\" does not exist", stmt->servername)));
- srvForm = (Form_pg_foreign_server) GETSTRUCT(tp);
+ srvForm = GETSTRUCT(pg_foreign_server, tp);
srvId = srvForm->oid;
/*
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index b016eecb2c..cdac19d505 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -101,7 +101,7 @@ compute_return_type(TypeName *returnType, Oid languageOid,
if (typtup)
{
- if (!((Form_pg_type) GETSTRUCT(typtup))->typisdefined)
+ if (!(GETSTRUCT(pg_type, typtup))->typisdefined)
{
if (languageOid == SQLlanguageId)
ereport(ERROR,
@@ -241,7 +241,7 @@ interpret_function_parameter_list(ParseState *pstate,
typtup = LookupTypeName(NULL, t, NULL, false);
if (typtup)
{
- if (!((Form_pg_type) GETSTRUCT(typtup))->typisdefined)
+ if (!(GETSTRUCT(pg_type, typtup))->typisdefined)
{
/* As above, hard error if language is SQL */
if (languageOid == SQLlanguageId)
@@ -1106,7 +1106,7 @@ CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
(extension_file_exists(language) ?
errhint("Use CREATE EXTENSION to load the language into the database.") : 0)));
- languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
+ languageStruct = GETSTRUCT(pg_language, languageTuple);
languageOid = languageStruct->oid;
if (languageStruct->lanpltrusted)
@@ -1313,7 +1313,7 @@ RemoveFunctionById(Oid funcOid)
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", funcOid);
- prokind = ((Form_pg_proc) GETSTRUCT(tup))->prokind;
+ prokind = (GETSTRUCT(pg_proc, tup))->prokind;
CatalogTupleDelete(relation, &tup->t_self);
@@ -1377,7 +1377,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", funcOid);
- procForm = (Form_pg_proc) GETSTRUCT(tup);
+ procForm = GETSTRUCT(pg_proc, tup);
/* Permission check: must own function */
if (!pg_proc_ownercheck(funcOid, GetUserId()))
@@ -1600,7 +1600,7 @@ CreateCast(CreateCastStmt *stmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procstruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procstruct = GETSTRUCT(pg_proc, tuple);
nargs = procstruct->pronargs;
if (nargs < 1 || nargs > 3)
ereport(ERROR,
@@ -1868,7 +1868,7 @@ CreateTransform(CreateTransformStmt *stmt)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(fromsqlfuncid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", fromsqlfuncid);
- procstruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procstruct = GETSTRUCT(pg_proc, tuple);
if (procstruct->prorettype != INTERNALOID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
@@ -1894,7 +1894,7 @@ CreateTransform(CreateTransformStmt *stmt)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(tosqlfuncid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", tosqlfuncid);
- procstruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procstruct = GETSTRUCT(pg_proc, tuple);
if (procstruct->prorettype != typeid)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
@@ -1922,7 +1922,7 @@ CreateTransform(CreateTransformStmt *stmt)
ObjectIdGetDatum(langid));
if (HeapTupleIsValid(tuple))
{
- Form_pg_transform form = (Form_pg_transform) GETSTRUCT(tuple);
+ Form_pg_transform form = GETSTRUCT(pg_transform, tuple);
if (!stmt->replace)
ereport(ERROR,
@@ -2106,7 +2106,7 @@ ExecuteDoStmt(ParseState *pstate, DoStmt *stmt, bool atomic)
(extension_file_exists(language) ?
errhint("Use CREATE EXTENSION to load the language into the database.") : 0)));
- languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
+ languageStruct = GETSTRUCT(pg_language, languageTuple);
codeblock->langOid = languageStruct->oid;
codeblock->langIsTrusted = languageStruct->lanpltrusted;
codeblock->atomic = atomic;
@@ -2220,7 +2220,7 @@ ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver
* and AbortTransaction() resets the security context. This could be
* reorganized, but right now it doesn't work.
*/
- if (((Form_pg_proc) GETSTRUCT(tp))->prosecdef)
+ if ((GETSTRUCT(pg_proc, tp))->prosecdef)
callcontext->atomic = true;
ReleaseSysCache(tp);
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index ff847579f3..233d265f71 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -212,7 +212,7 @@ CheckIndexCompatible(Oid oldId,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("access method \"%s\" does not exist",
accessMethodName)));
- accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
+ accessMethodForm = GETSTRUCT(pg_am, tuple);
accessMethodId = accessMethodForm->oid;
amRoutine = GetIndexAmRoutine(accessMethodForm->amhandler);
ReleaseSysCache(tuple);
@@ -245,7 +245,7 @@ CheckIndexCompatible(Oid oldId,
tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(oldId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u", oldId);
- indexForm = (Form_pg_index) GETSTRUCT(tuple);
+ indexForm = GETSTRUCT(pg_index, tuple);
/*
* We don't assess expressions or predicates; assume incompatibility.
@@ -833,7 +833,7 @@ DefineIndex(Oid relationId,
errmsg("access method \"%s\" does not exist",
accessMethodName)));
}
- accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
+ accessMethodForm = GETSTRUCT(pg_am, tuple);
accessMethodId = accessMethodForm->oid;
amRoutine = GetIndexAmRoutine(accessMethodForm->amhandler);
@@ -1441,7 +1441,7 @@ DefineIndex(Oid relationId,
elog(ERROR, "cache lookup failed for index %u",
indexRelationId);
newtup = heap_copytuple(tup);
- ((Form_pg_index) GETSTRUCT(newtup))->indisvalid = false;
+ (GETSTRUCT(pg_index, newtup))->indisvalid = false;
CatalogTupleUpdate(pg_index, &tup->t_self, newtup);
ReleaseSysCache(tup);
table_close(pg_index, RowExclusiveLock);
@@ -1822,7 +1822,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
errmsg("column \"%s\" does not exist",
attribute->name)));
}
- attform = (Form_pg_attribute) GETSTRUCT(atttuple);
+ attform = GETSTRUCT(pg_attribute, atttuple);
indexInfo->ii_IndexAttrNumbers[attn] = attform->attnum;
atttype = attform->atttypid;
attcollation = attform->attcollation;
@@ -2044,7 +2044,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
if (!HeapTupleIsValid(opftuple))
elog(ERROR, "cache lookup failed for opfamily %u",
opfamily);
- opfform = (Form_pg_opfamily) GETSTRUCT(opftuple);
+ opfform = GETSTRUCT(pg_opfamily, opftuple);
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -2183,7 +2183,7 @@ ResolveOpClass(List *opclass, Oid attrType,
* Verify that the index operator class accepts this datatype. Note we
* will accept binary compatibility.
*/
- opform = (Form_pg_opclass) GETSTRUCT(tuple);
+ opform = GETSTRUCT(pg_opclass, tuple);
opClassId = opform->oid;
opInputType = opform->opcintype;
@@ -2246,7 +2246,7 @@ GetDefaultOpClass(Oid type_id, Oid am_id)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_opclass opclass = (Form_pg_opclass) GETSTRUCT(tup);
+ Form_pg_opclass opclass = GETSTRUCT(pg_opclass, tup);
/* ignore altogether if not a default opclass */
if (!opclass->opcdefault)
@@ -2951,7 +2951,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
scan = table_beginscan_catalog(relationRelation, num_keys, scan_keys);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classtuple = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classtuple = GETSTRUCT(pg_class, tuple);
Oid relid = classtuple->oid;
/*
@@ -4194,7 +4194,7 @@ IndexSetParentIndex(Relation partitionIdx, Oid parentOid)
}
else
{
- Form_pg_inherits inhForm = (Form_pg_inherits) GETSTRUCT(tuple);
+ Form_pg_inherits inhForm = GETSTRUCT(pg_inherits, tuple);
if (parentOid == InvalidOid)
{
@@ -4285,8 +4285,8 @@ update_relispartition(Oid relationId, bool newval)
tup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for relation %u", relationId);
- Assert(((Form_pg_class) GETSTRUCT(tup))->relispartition != newval);
- ((Form_pg_class) GETSTRUCT(tup))->relispartition = newval;
+ Assert((GETSTRUCT(pg_class, tup))->relispartition != newval);
+ (GETSTRUCT(pg_class, tup))->relispartition = newval;
CatalogTupleUpdate(classRel, &tup->t_self, tup);
heap_freetuple(tup);
table_close(classRel, RowExclusiveLock);
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c
index 9ac0383459..0e5e86ccb3 100644
--- a/src/backend/commands/matview.c
+++ b/src/backend/commands/matview.c
@@ -100,7 +100,7 @@ SetMatViewPopulatedState(Relation relation, bool newstate)
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(relation));
- ((Form_pg_class) GETSTRUCT(tuple))->relispopulated = newstate;
+ (GETSTRUCT(pg_class, tuple))->relispopulated = newstate;
CatalogTupleUpdate(pgrel, &tuple->t_self, tuple);
@@ -724,7 +724,7 @@ refresh_by_match_merge(Oid matviewOid, Oid tempOid, Oid relowner,
cla_ht = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(cla_ht))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- cla_tup = (Form_pg_opclass) GETSTRUCT(cla_ht);
+ cla_tup = GETSTRUCT(pg_opclass, cla_ht);
Assert(cla_tup->opcmethod == BTREE_AM_OID);
opfamily = cla_tup->opcfamily;
opcintype = cla_tup->opcintype;
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 7a931ab758..91b782ed0f 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -123,7 +123,7 @@ OpFamilyCacheLookup(Oid amID, List *opfamilyname, bool missing_ok)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("operator family \"%s\" does not exist for access method \"%s\"",
NameListToString(opfamilyname),
- NameStr(((Form_pg_am) GETSTRUCT(amtup))->amname))));
+ NameStr((GETSTRUCT(pg_am, amtup))->amname))));
}
return htup;
@@ -145,7 +145,7 @@ get_opfamily_oid(Oid amID, List *opfamilyname, bool missing_ok)
htup = OpFamilyCacheLookup(amID, opfamilyname, missing_ok);
if (!HeapTupleIsValid(htup))
return InvalidOid;
- opfamform = (Form_pg_opfamily) GETSTRUCT(htup);
+ opfamform = GETSTRUCT(pg_opfamily, htup);
opfID = opfamform->oid;
ReleaseSysCache(htup);
@@ -204,7 +204,7 @@ OpClassCacheLookup(Oid amID, List *opclassname, bool missing_ok)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("operator class \"%s\" does not exist for access method \"%s\"",
NameListToString(opclassname),
- NameStr(((Form_pg_am) GETSTRUCT(amtup))->amname))));
+ NameStr((GETSTRUCT(pg_am, amtup))->amname))));
}
return htup;
@@ -226,7 +226,7 @@ get_opclass_oid(Oid amID, List *opclassname, bool missing_ok)
htup = OpClassCacheLookup(amID, opclassname, missing_ok);
if (!HeapTupleIsValid(htup))
return InvalidOid;
- opcform = (Form_pg_opclass) GETSTRUCT(htup);
+ opcform = GETSTRUCT(pg_opclass, htup);
opcID = opcform->oid;
ReleaseSysCache(htup);
@@ -375,7 +375,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
errmsg("access method \"%s\" does not exist",
stmt->amname)));
- amform = (Form_pg_am) GETSTRUCT(tup);
+ amform = GETSTRUCT(pg_am, tup);
amoid = amform->oid;
amroutine = GetIndexAmRoutineByAmId(amoid, false);
ReleaseSysCache(tup);
@@ -442,7 +442,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
ObjectIdGetDatum(namespaceoid));
if (HeapTupleIsValid(tup))
{
- opfamilyoid = ((Form_pg_opfamily) GETSTRUCT(tup))->oid;
+ opfamilyoid = (GETSTRUCT(pg_opfamily, tup))->oid;
/*
* XXX given the superuser check above, there's no need for an
@@ -630,7 +630,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_opclass opclass = (Form_pg_opclass) GETSTRUCT(tup);
+ Form_pg_opclass opclass = GETSTRUCT(pg_opclass, tup);
if (opclass->opcintype == typeoid && opclass->opcdefault)
ereport(ERROR,
@@ -833,7 +833,7 @@ AlterOpFamily(AlterOpFamilyStmt *stmt)
errmsg("access method \"%s\" does not exist",
stmt->amname)));
- amform = (Form_pg_am) GETSTRUCT(tup);
+ amform = GETSTRUCT(pg_am, tup);
amoid = amform->oid;
amroutine = GetIndexAmRoutineByAmId(amoid, false);
ReleaseSysCache(tup);
@@ -1143,7 +1143,7 @@ assignOperTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
optup = SearchSysCache1(OPEROID, ObjectIdGetDatum(member->object));
if (!HeapTupleIsValid(optup))
elog(ERROR, "cache lookup failed for operator %u", member->object);
- opform = (Form_pg_operator) GETSTRUCT(optup);
+ opform = GETSTRUCT(pg_operator, optup);
/*
* Opfamily operators must be binary.
@@ -1210,7 +1210,7 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid,
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(member->object));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", member->object);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
/* Check the signature of the opclass options parsing function */
if (member->number == opclassOptsProcNum)
diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c
index a5924d7d56..312588f296 100644
--- a/src/backend/commands/operatorcmds.c
+++ b/src/backend/commands/operatorcmds.c
@@ -372,7 +372,7 @@ RemoveOperatorById(Oid operOid)
tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for operator %u", operOid);
- op = (Form_pg_operator) GETSTRUCT(tup);
+ op = GETSTRUCT(pg_operator, tup);
/*
* Reset links from commutator and negator, if any. In case of a
@@ -431,7 +431,7 @@ AlterOperator(AlterOperatorStmt *stmt)
tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for operator %u", oprId);
- oprForm = (Form_pg_operator) GETSTRUCT(tup);
+ oprForm = GETSTRUCT(pg_operator, tup);
/* Process options */
foreach(pl, stmt->options)
diff --git a/src/backend/commands/policy.c b/src/backend/commands/policy.c
index d9dff9ecaa..99e210fb7c 100644
--- a/src/backend/commands/policy.c
+++ b/src/backend/commands/policy.c
@@ -75,7 +75,7 @@ RangeVarCallbackForPolicy(const RangeVar *rv, Oid relid, Oid oldrelid,
if (!HeapTupleIsValid(tuple))
return;
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
relkind = classform->relkind;
/* Must own relation. */
@@ -236,7 +236,7 @@ RelationBuildRowSecurity(Relation relation)
while (HeapTupleIsValid(tuple = systable_getnext(sscan)))
{
- Form_pg_policy policy_form = (Form_pg_policy) GETSTRUCT(tuple);
+ Form_pg_policy policy_form = GETSTRUCT(pg_policy, tuple);
RowSecurityPolicy *policy;
Datum datum;
bool isnull;
@@ -366,7 +366,7 @@ RemovePolicyById(Oid policy_id)
* set of policies the rel has; furthermore we've got to hold the lock
* till commit.)
*/
- relid = ((Form_pg_policy) GETSTRUCT(tuple))->polrelid;
+ relid = (GETSTRUCT(pg_policy, tuple))->polrelid;
rel = table_open(relid, AccessExclusiveLock);
if (rel->rd_rel->relkind != RELKIND_RELATION &&
@@ -455,7 +455,7 @@ RemoveRoleFromObjectPolicy(Oid roleid, Oid classid, Oid policy_id)
elog(ERROR, "could not find tuple for policy %u", policy_id);
/* Identify rel the policy belongs to */
- relid = ((Form_pg_policy) GETSTRUCT(tuple))->polrelid;
+ relid = (GETSTRUCT(pg_policy, tuple))->polrelid;
/* Get the current set of roles */
roles_datum = heap_getattr(tuple,
@@ -917,7 +917,7 @@ AlterPolicy(AlterPolicyStmt *stmt)
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("only WITH CHECK expression allowed for INSERT")));
- policy_id = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid;
+ policy_id = (GETSTRUCT(pg_policy, policy_tuple))->oid;
if (role_ids != NULL)
{
@@ -1169,11 +1169,11 @@ rename_policy(RenameStmt *stmt)
errmsg("policy \"%s\" for table \"%s\" does not exist",
stmt->subname, RelationGetRelationName(target_table))));
- opoloid = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid;
+ opoloid = (GETSTRUCT(pg_policy, policy_tuple))->oid;
policy_tuple = heap_copytuple(policy_tuple);
- namestrcpy(&((Form_pg_policy) GETSTRUCT(policy_tuple))->polname,
+ namestrcpy(&(GETSTRUCT(pg_policy, policy_tuple))->polname,
stmt->newname);
CatalogTupleUpdate(pg_policy_rel, &policy_tuple->t_self, policy_tuple);
@@ -1243,7 +1243,7 @@ get_relation_policy_oid(Oid relid, const char *policy_name, bool missing_ok)
policy_oid = InvalidOid;
}
else
- policy_oid = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid;
+ policy_oid = (GETSTRUCT(pg_policy, policy_tuple))->oid;
/* Clean up. */
systable_endscan(sscan);
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c
index 4a093f45d8..d28274e3c4 100644
--- a/src/backend/commands/proclang.c
+++ b/src/backend/commands/proclang.c
@@ -124,7 +124,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
if (HeapTupleIsValid(oldtup))
{
- Form_pg_language oldform = (Form_pg_language) GETSTRUCT(oldtup);
+ Form_pg_language oldform = GETSTRUCT(pg_language, oldtup);
/* There is one; okay to replace it? */
if (!stmt->replace)
diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index 8e645741e4..c939ae689a 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -922,7 +922,7 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt,
&publish_via_partition_root_given,
&publish_via_partition_root);
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
/*
* If the publication doesn't publish changes via the root partitioned
@@ -1038,7 +1038,7 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt,
CommandCounterIncrement();
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
/* Invalidate the relcache. */
if (pubform->puballtables)
@@ -1114,7 +1114,7 @@ AlterPublicationTables(AlterPublicationStmt *stmt, HeapTuple tup,
const char *queryString)
{
List *rels = NIL;
- Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
+ Form_pg_publication pubform = GETSTRUCT(pg_publication, tup);
Oid pubid = pubform->oid;
/*
@@ -1291,7 +1291,7 @@ static void
AlterPublicationSchemas(AlterPublicationStmt *stmt,
HeapTuple tup, List *schemaidlist)
{
- Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
+ Form_pg_publication pubform = GETSTRUCT(pg_publication, tup);
/*
* Nothing to do if no objects, except in SET: for that it is quite
@@ -1355,7 +1355,7 @@ static void
CheckAlterPublication(AlterPublicationStmt *stmt, HeapTuple tup,
List *tables, List *schemaidlist)
{
- Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
+ Form_pg_publication pubform = GETSTRUCT(pg_publication, tup);
if ((stmt->action == AP_AddObjects || stmt->action == AP_SetObjects) &&
schemaidlist && !superuser())
@@ -1407,7 +1407,7 @@ AlterPublication(ParseState *pstate, AlterPublicationStmt *stmt)
errmsg("publication \"%s\" does not exist",
stmt->pubname)));
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
/* must be owner */
if (!pg_publication_ownercheck(pubform->oid, GetUserId()))
@@ -1482,7 +1482,7 @@ RemovePublicationRelById(Oid proid)
elog(ERROR, "cache lookup failed for publication table %u",
proid);
- pubrel = (Form_pg_publication_rel) GETSTRUCT(tup);
+ pubrel = GETSTRUCT(pg_publication_rel, tup);
/*
* Invalidate relcache so that publication info is rebuilt.
@@ -1520,7 +1520,7 @@ RemovePublicationById(Oid pubid)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication %u", pubid);
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
/* Invalidate relcache so that publication info is rebuilt. */
if (pubform->puballtables)
@@ -1551,7 +1551,7 @@ RemovePublicationSchemaById(Oid psoid)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication schema %u", psoid);
- pubsch = (Form_pg_publication_namespace) GETSTRUCT(tup);
+ pubsch = GETSTRUCT(pg_publication_namespace, tup);
/*
* Invalidate relcache so that publication info is rebuilt. See
@@ -1944,7 +1944,7 @@ AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
{
Form_pg_publication form;
- form = (Form_pg_publication) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_publication, tup);
if (form->pubowner == newOwnerId)
return;
@@ -2015,7 +2015,7 @@ AlterPublicationOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("publication \"%s\" does not exist", name)));
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
subid = pubform->oid;
AlterPublicationOwner_internal(rel, tup, newOwnerId);
diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c
index be3925b3b4..204bd066fa 100644
--- a/src/backend/commands/schemacmds.c
+++ b/src/backend/commands/schemacmds.c
@@ -80,7 +80,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for role %u", owner_uid);
schemaName =
- pstrdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname));
+ pstrdup(NameStr((GETSTRUCT(pg_authid, tuple))->rolname));
ReleaseSysCache(tuple);
}
@@ -233,7 +233,7 @@ RenameSchema(const char *oldname, const char *newname)
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema \"%s\" does not exist", oldname)));
- nspform = (Form_pg_namespace) GETSTRUCT(tup);
+ nspform = GETSTRUCT(pg_namespace, tup);
nspOid = nspform->oid;
/* make sure the new name doesn't exist */
@@ -313,7 +313,7 @@ AlterSchemaOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema \"%s\" does not exist", name)));
- nspform = (Form_pg_namespace) GETSTRUCT(tup);
+ nspform = GETSTRUCT(pg_namespace, tup);
nspOid = nspform->oid;
AlterSchemaOwner_internal(tup, rel, newOwnerId);
@@ -335,7 +335,7 @@ AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerId)
Assert(tup->t_tableOid == NamespaceRelationId);
Assert(RelationGetRelid(rel) == NamespaceRelationId);
- nspForm = (Form_pg_namespace) GETSTRUCT(tup);
+ nspForm = GETSTRUCT(pg_namespace, tup);
/*
* If the new owner is the same as the existing owner, consider the
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 48d9d43dac..98c963e723 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -286,7 +286,7 @@ ResetSequence(Oid seq_relid)
pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(seq_relid));
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", seq_relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
startv = pgsform->seqstart;
ReleaseSysCache(pgstuple);
@@ -302,7 +302,7 @@ ResetSequence(Oid seq_relid)
* Modify the copied tuple to execute the restart (compare the RESTART
* action in AlterSequence)
*/
- seq = (Form_pg_sequence_data) GETSTRUCT(tuple);
+ seq = GETSTRUCT(pg_sequence_data, tuple);
seq->last_value = startv;
seq->is_called = false;
seq->log_cnt = 0;
@@ -478,14 +478,14 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
elog(ERROR, "cache lookup failed for sequence %u",
relid);
- seqform = (Form_pg_sequence) GETSTRUCT(seqtuple);
+ seqform = GETSTRUCT(pg_sequence, seqtuple);
/* lock page's buffer and read tuple into new sequence structure */
(void) read_seq_tuple(seqrel, &buf, &datatuple);
/* copy the existing sequence data tuple, so it can be modified locally */
newdatatuple = heap_copytuple(&datatuple);
- newdataform = (Form_pg_sequence_data) GETSTRUCT(newdatatuple);
+ newdataform = GETSTRUCT(pg_sequence_data, newdatatuple);
UnlockReleaseBuffer(buf);
@@ -676,7 +676,7 @@ nextval_internal(Oid relid, bool check_permissions)
pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
incby = pgsform->seqincrement;
maxv = pgsform->seqmax;
minv = pgsform->seqmin;
@@ -964,7 +964,7 @@ do_setval(Oid relid, int64 next, bool iscalled)
pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
maxv = pgsform->seqmax;
minv = pgsform->seqmin;
ReleaseSysCache(pgstuple);
@@ -1232,7 +1232,7 @@ read_seq_tuple(Relation rel, Buffer *buf, HeapTuple seqdatatuple)
MarkBufferDirtyHint(*buf, true);
}
- seq = (Form_pg_sequence_data) GETSTRUCT(seqdatatuple);
+ seq = GETSTRUCT(pg_sequence_data, seqdatatuple);
return seq;
}
@@ -1714,7 +1714,7 @@ sequence_options(Oid relid)
pgstuple = SearchSysCache1(SEQRELID, relid);
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
/* Use makeFloat() for 64-bit integers, like gram.y does. */
options = lappend(options,
@@ -1777,7 +1777,7 @@ pg_sequence_parameters(PG_FUNCTION_ARGS)
pgstuple = SearchSysCache1(SEQRELID, relid);
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
values[0] = Int64GetDatum(pgsform->seqstart);
values[1] = Int64GetDatum(pgsform->seqmin);
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index cd5e2f2b6b..68e599a104 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -238,7 +238,7 @@ CreateStatistics(CreateStatsStmt *stmt)
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" does not exist",
attname)));
- attForm = (Form_pg_attribute) GETSTRUCT(atttuple);
+ attForm = GETSTRUCT(pg_attribute, atttuple);
/* Disallow use of system attributes in extended stats */
if (attForm->attnum <= 0)
@@ -754,7 +754,7 @@ RemoveStatisticsById(Oid statsOid)
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for statistics object %u", statsOid);
- statext = (Form_pg_statistic_ext) GETSTRUCT(tup);
+ statext = GETSTRUCT(pg_statistic_ext, tup);
relid = statext->stxrelid;
CacheInvalidateRelcacheByRelid(relid);
@@ -885,7 +885,7 @@ StatisticsGetRelation(Oid statId, bool missing_ok)
return InvalidOid;
elog(ERROR, "cache lookup failed for statistics object %u", statId);
}
- stx = (Form_pg_statistic_ext) GETSTRUCT(tuple);
+ stx = GETSTRUCT(pg_statistic_ext, tuple);
Assert(stx->oid == statId);
result = stx->stxrelid;
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index bdc1208724..722d5337fc 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -990,7 +990,7 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt,
errmsg("subscription \"%s\" does not exist",
stmt->subname)));
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_subscription, tup);
subid = form->oid;
/* must be owner */
@@ -1362,7 +1362,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
return;
}
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_subscription, tup);
subid = form->oid;
/* must be owner */
@@ -1652,7 +1652,7 @@ AlterSubscriptionOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
{
Form_pg_subscription form;
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_subscription, tup);
if (form->subowner == newOwnerId)
return;
@@ -1705,7 +1705,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("subscription \"%s\" does not exist", name)));
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_subscription, tup);
subid = form->oid;
AlterSubscriptionOwner_internal(rel, tup, newOwnerId);
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index ef5b34a312..af4d1dcc2f 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -1539,7 +1539,7 @@ RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid, Oid oldRelOid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped, so nothing to do */
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
is_partition = classform->relispartition;
/* Pass back some data to save lookups in RemoveRelations */
@@ -1591,7 +1591,7 @@ RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid, Oid oldRelOid,
return;
}
- indexform = (Form_pg_index) GETSTRUCT(locTuple);
+ indexform = GETSTRUCT(pg_index, locTuple);
indisvalid = indexform->indisvalid;
ReleaseSysCache(locTuple);
@@ -3244,7 +3244,7 @@ SetRelationHasSubclass(Oid relationId, bool relhassubclass)
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationId);
- classtuple = (Form_pg_class) GETSTRUCT(tuple);
+ classtuple = GETSTRUCT(pg_class, tuple);
if (classtuple->relhassubclass != relhassubclass)
{
@@ -3346,7 +3346,7 @@ SetRelationTableSpace(Relation rel,
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(reloid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", reloid);
- rd_rel = (Form_pg_class) GETSTRUCT(tuple);
+ rd_rel = GETSTRUCT(pg_class, tuple);
/* Update the pg_class row. */
rd_rel->reltablespace = (newTableSpaceId == MyDatabaseTableSpace) ?
@@ -3518,7 +3518,7 @@ renameatt_internal(Oid myrelid,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" does not exist",
oldattname)));
- attform = (Form_pg_attribute) GETSTRUCT(atttup);
+ attform = GETSTRUCT(pg_attribute, atttup);
attnum = attform->attnum;
if (attnum <= 0)
@@ -3574,7 +3574,7 @@ RangeVarCallbackForRenameAttribute(const RangeVar *rv, Oid relid, Oid oldrelid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped */
- form = (Form_pg_class) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_class, tuple);
renameatt_check(relid, form, false);
ReleaseSysCache(tuple);
}
@@ -3660,7 +3660,7 @@ rename_constraint_internal(Oid myrelid,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u",
constraintOid);
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
if (myrelid && con->contype == CONSTRAINT_CHECK && !con->connoinherit)
{
@@ -3872,7 +3872,7 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bo
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for relation %u", myrelid);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
if (get_relname_relid(newrelname, namespaceId) != InvalidOid)
ereport(ERROR,
@@ -3947,7 +3947,7 @@ ResetRelRewrite(Oid myrelid)
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for relation %u", myrelid);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
/*
* Update pg_class tuple.
@@ -6443,7 +6443,7 @@ find_composite_type_dependencies(Oid typeOid, Relation origRelation,
while (HeapTupleIsValid(depTup = systable_getnext(depScan)))
{
- Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend pg_depend = GETSTRUCT(pg_depend, depTup);
Relation rel;
Form_pg_attribute att;
@@ -6549,7 +6549,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classform = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classform = GETSTRUCT(pg_class, tuple);
if (behavior == DROP_RESTRICT)
ereport(ERROR,
@@ -6581,7 +6581,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
void
check_of_type(HeapTuple typetuple)
{
- Form_pg_type typ = (Form_pg_type) GETSTRUCT(typetuple);
+ Form_pg_type typ = GETSTRUCT(pg_type, typetuple);
bool typeOk = false;
if (typ->typtype == TYPTYPE_COMPOSITE)
@@ -6700,7 +6700,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
tuple = SearchSysCacheCopyAttName(myrelid, colDef->colname);
if (HeapTupleIsValid(tuple))
{
- Form_pg_attribute childatt = (Form_pg_attribute) GETSTRUCT(tuple);
+ Form_pg_attribute childatt = GETSTRUCT(pg_attribute, tuple);
Oid ctypeId;
int32 ctypmod;
Oid ccollid;
@@ -6781,10 +6781,10 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", myrelid);
- relkind = ((Form_pg_class) GETSTRUCT(reltup))->relkind;
+ relkind = (GETSTRUCT(pg_class, reltup))->relkind;
/* Determine the new attribute's number */
- newattnum = ((Form_pg_class) GETSTRUCT(reltup))->relnatts + 1;
+ newattnum = (GETSTRUCT(pg_class, reltup))->relnatts + 1;
if (newattnum > MaxHeapAttributeNumber)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_COLUMNS),
@@ -6792,7 +6792,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
MaxHeapAttributeNumber)));
typeTuple = typenameType(NULL, colDef->typeName, &typmod);
- tform = (Form_pg_type) GETSTRUCT(typeTuple);
+ tform = GETSTRUCT(pg_type, typeTuple);
typeOid = tform->oid;
aclresult = pg_type_aclcheck(typeOid, GetUserId(), ACL_USAGE);
@@ -6844,7 +6844,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
/*
* Update pg_class tuple as appropriate
*/
- ((Form_pg_class) GETSTRUCT(reltup))->relnatts = newattnum;
+ (GETSTRUCT(pg_class, reltup))->relnatts = newattnum;
CatalogTupleUpdate(pgclass, &reltup->t_self, reltup);
@@ -7077,7 +7077,7 @@ check_for_column_name_collision(Relation rel, const char *colname,
if (!HeapTupleIsValid(attTuple))
return true;
- attnum = ((Form_pg_attribute) GETSTRUCT(attTuple))->attnum;
+ attnum = (GETSTRUCT(pg_attribute, attTuple))->attnum;
ReleaseSysCache(attTuple);
/*
@@ -7200,7 +7200,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
/* Prevent them from altering a system attribute */
@@ -7236,7 +7236,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexoid);
- indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexStruct = GETSTRUCT(pg_index, indexTuple);
/*
* If the index is not a primary key or an index used as replica
@@ -7357,7 +7357,7 @@ ATPrepSetNotNull(List **wqueue, Relation rel,
errmsg("column \"%s\" of relation \"%s\" does not exist",
cmd->name, RelationGetRelationName(rel))));
- attnotnull = ((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull;
+ attnotnull = (GETSTRUCT(pg_attribute, tuple))->attnotnull;
ReleaseSysCache(tuple);
if (attnotnull)
return;
@@ -7407,7 +7407,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attnum;
+ attnum = (GETSTRUCT(pg_attribute, tuple))->attnum;
/* Prevent them from altering a system attribute */
if (attnum <= 0)
@@ -7419,9 +7419,9 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
/*
* Okay, actually perform the catalog change ... if needed
*/
- if (!((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull)
+ if (!(GETSTRUCT(pg_attribute, tuple))->attnotnull)
{
- ((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull = true;
+ (GETSTRUCT(pg_attribute, tuple))->attnotnull = true;
CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple);
@@ -7432,7 +7432,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
* already found that we must verify some other NOT NULL constraint.
*/
if (!tab->verify_new_notnull &&
- !NotNullImpliedByRelConstraints(rel, (Form_pg_attribute) GETSTRUCT(tuple)))
+ !NotNullImpliedByRelConstraints(rel, GETSTRUCT(pg_attribute, tuple)))
{
/* Tell Phase 3 it needs to test the constraint */
tab->verify_new_notnull = true;
@@ -7481,7 +7481,7 @@ ATExecCheckNotNull(AlteredTableInfo *tab, Relation rel,
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- if (!((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull)
+ if (!(GETSTRUCT(pg_attribute, tuple))->attnotnull)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("constraint must be added to child tables too"),
@@ -7662,7 +7662,7 @@ ATExecAddIdentity(Relation rel, const char *colName,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
/* Can't alter a system attribute */
@@ -7757,7 +7757,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
if (attnum <= 0)
@@ -7816,7 +7816,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
if (attnum <= 0)
@@ -7905,7 +7905,7 @@ ATPrepDropExpression(Relation rel, AlterTableCmd *cmd, bool recurse, bool recurs
errmsg("column \"%s\" of relation \"%s\" does not exist",
cmd->name, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
if (attTup->attinhcount > 0)
ereport(ERROR,
@@ -7935,7 +7935,7 @@ ATExecDropExpression(Relation rel, const char *colName, bool missing_ok, LOCKMOD
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
if (attnum <= 0)
@@ -8074,7 +8074,7 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa
colNum, RelationGetRelationName(rel))));
}
- attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ attrtuple = GETSTRUCT(pg_attribute, tuple);
attnum = attrtuple->attnum;
if (attnum <= 0)
@@ -8144,7 +8144,7 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ attrtuple = GETSTRUCT(pg_attribute, tuple);
attnum = attrtuple->attnum;
if (attnum <= 0)
@@ -8234,7 +8234,7 @@ SetIndexStorageProperties(Relation rel, Relation attrelation,
if (HeapTupleIsValid(tuple))
{
- Form_pg_attribute attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ Form_pg_attribute attrtuple = GETSTRUCT(pg_attribute, tuple);
if (setstorage)
attrtuple->attstorage = newstorage;
@@ -8300,7 +8300,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ attrtuple = GETSTRUCT(pg_attribute, tuple);
attnum = attrtuple->attnum;
if (attnum <= 0)
@@ -8427,7 +8427,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
return InvalidObjectAddress;
}
}
- targetatt = (Form_pg_attribute) GETSTRUCT(tuple);
+ targetatt = GETSTRUCT(pg_attribute, tuple);
attnum = targetatt->attnum;
@@ -8501,7 +8501,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute \"%s\" of relation %u",
colName, childrelid);
- childatt = (Form_pg_attribute) GETSTRUCT(tuple);
+ childatt = GETSTRUCT(pg_attribute, tuple);
if (childatt->attinhcount <= 0) /* shouldn't happen */
elog(ERROR, "relation %u has non-inherited attribute \"%s\"",
@@ -9230,7 +9230,7 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
cla_ht = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclasses[i]));
if (!HeapTupleIsValid(cla_ht))
elog(ERROR, "cache lookup failed for opclass %u", opclasses[i]);
- cla_tup = (Form_pg_opclass) GETSTRUCT(cla_ht);
+ cla_tup = GETSTRUCT(pg_opclass, cla_ht);
amid = cla_tup->opcmethod;
opfamily = cla_tup->opcfamily;
opcintype = cla_tup->opcintype;
@@ -10008,7 +10008,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel)
NULL, 2, key);
while ((tuple = systable_getnext(scan)) != NULL)
{
- Form_pg_constraint constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint constrForm = GETSTRUCT(pg_constraint, tuple);
clone = lappend_oid(clone, constrForm->oid);
}
@@ -10048,7 +10048,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel)
tuple = SearchSysCache1(CONSTROID, constrOid);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", constrOid);
- constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ constrForm = GETSTRUCT(pg_constraint, tuple);
/*
* As explained above: don't try to clone a constraint for which we're
@@ -10235,7 +10235,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u",
parentConstrOid);
- constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ constrForm = GETSTRUCT(pg_constraint, tuple);
/* Don't clone constraints whose parents are being cloned */
if (list_member_oid(clone, constrForm->conparentid))
@@ -10442,7 +10442,7 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk,
ObjectIdGetDatum(parentConstrOid));
if (!HeapTupleIsValid(parentConstrTup))
elog(ERROR, "cache lookup failed for constraint %u", parentConstrOid);
- parentConstr = (Form_pg_constraint) GETSTRUCT(parentConstrTup);
+ parentConstr = GETSTRUCT(pg_constraint, parentConstrTup);
/*
* Do some quick & easy initial checks. If any of these fail, we cannot
@@ -10473,7 +10473,7 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk,
ObjectIdGetDatum(fk->conoid));
if (!HeapTupleIsValid(partcontup))
elog(ERROR, "cache lookup failed for constraint %u", fk->conoid);
- partConstr = (Form_pg_constraint) GETSTRUCT(partcontup);
+ partConstr = GETSTRUCT(pg_constraint, partcontup);
if (OidIsValid(partConstr->conparentid) ||
!partConstr->convalidated ||
partConstr->condeferrable != parentConstr->condeferrable ||
@@ -10505,7 +10505,7 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk,
NULL, 1, &key);
while ((trigtup = systable_getnext(scan)) != NULL)
{
- Form_pg_trigger trgform = (Form_pg_trigger) GETSTRUCT(trigtup);
+ Form_pg_trigger trgform = GETSTRUCT(pg_trigger, trigtup);
ObjectAddress trigger;
if (trgform->tgconstrrelid != fk->conrelid)
@@ -10579,7 +10579,7 @@ GetForeignKeyActionTriggers(Relation trigrel,
NULL, 1, &key);
while ((trigtup = systable_getnext(scan)) != NULL)
{
- Form_pg_trigger trgform = (Form_pg_trigger) GETSTRUCT(trigtup);
+ Form_pg_trigger trgform = GETSTRUCT(pg_trigger, trigtup);
if (trgform->tgconstrrelid != conrelid)
continue;
@@ -10634,7 +10634,7 @@ GetForeignKeyCheckTriggers(Relation trigrel,
NULL, 1, &key);
while ((trigtup = systable_getnext(scan)) != NULL)
{
- Form_pg_trigger trgform = (Form_pg_trigger) GETSTRUCT(trigtup);
+ Form_pg_trigger trgform = GETSTRUCT(pg_trigger, trigtup);
if (trgform->tgconstrrelid != confrelid)
continue;
@@ -10719,7 +10719,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd, bool recurse,
errmsg("constraint \"%s\" of relation \"%s\" does not exist",
cmdcon->conname, RelationGetRelationName(rel))));
- currcon = (Form_pg_constraint) GETSTRUCT(contuple);
+ currcon = GETSTRUCT(pg_constraint, contuple);
if (currcon->contype != CONSTRAINT_FOREIGN)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -10745,7 +10745,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd, bool recurse,
/* Loop to find the topmost constraint */
while (HeapTupleIsValid(tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(parent))))
{
- Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp);
+ Form_pg_constraint contup = GETSTRUCT(pg_constraint, tp);
/* If no parent, this is the constraint we want */
if (!OidIsValid(contup->conparentid))
@@ -10821,7 +10821,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
Oid refrelid;
bool changed = false;
- currcon = (Form_pg_constraint) GETSTRUCT(contuple);
+ currcon = GETSTRUCT(pg_constraint, contuple);
conoid = currcon->oid;
refrelid = currcon->confrelid;
@@ -10841,7 +10841,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
SysScanDesc tgscan;
copyTuple = heap_copytuple(contuple);
- copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple);
+ copy_con = GETSTRUCT(pg_constraint, copyTuple);
copy_con->condeferrable = cmdcon->deferrable;
copy_con->condeferred = cmdcon->initdeferred;
CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple);
@@ -10867,7 +10867,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
NULL, 1, &tgkey);
while (HeapTupleIsValid(tgtuple = systable_getnext(tgscan)))
{
- Form_pg_trigger tgform = (Form_pg_trigger) GETSTRUCT(tgtuple);
+ Form_pg_trigger tgform = GETSTRUCT(pg_trigger, tgtuple);
Form_pg_trigger copy_tg;
HeapTuple copyTuple;
@@ -10894,7 +10894,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
continue;
copyTuple = heap_copytuple(tgtuple);
- copy_tg = (Form_pg_trigger) GETSTRUCT(copyTuple);
+ copy_tg = GETSTRUCT(pg_trigger, copyTuple);
copy_tg->tgdeferrable = cmdcon->deferrable;
copy_tg->tginitdeferred = cmdcon->initdeferred;
@@ -10933,7 +10933,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
while (HeapTupleIsValid(childtup = systable_getnext(pscan)))
{
- Form_pg_constraint childcon = (Form_pg_constraint) GETSTRUCT(childtup);
+ Form_pg_constraint childcon = GETSTRUCT(pg_constraint, childtup);
Relation childrel;
childrel = table_open(childcon->conrelid, lockmode);
@@ -10997,7 +10997,7 @@ ATExecValidateConstraint(List **wqueue, Relation rel, char *constrName,
errmsg("constraint \"%s\" of relation \"%s\" does not exist",
constrName, RelationGetRelationName(rel))));
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
if (con->contype != CONSTRAINT_FOREIGN &&
con->contype != CONSTRAINT_CHECK)
ereport(ERROR,
@@ -11121,7 +11121,7 @@ ATExecValidateConstraint(List **wqueue, Relation rel, char *constrName,
* Now update the catalog, while we have the door open.
*/
copyTuple = heap_copytuple(tuple);
- copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple);
+ copy_con = GETSTRUCT(pg_constraint, copyTuple);
copy_con->convalidated = true;
CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple);
@@ -11171,9 +11171,9 @@ transformColumnNameList(Oid relId, List *colList,
(errcode(ERRCODE_TOO_MANY_COLUMNS),
errmsg("cannot have more than %d keys in a foreign key",
INDEX_MAX_KEYS)));
- attnums[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->attnum;
+ attnums[attnum] = (GETSTRUCT(pg_attribute, atttuple))->attnum;
if (atttypids != NULL)
- atttypids[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->atttypid;
+ atttypids[attnum] = (GETSTRUCT(pg_attribute, atttuple))->atttypid;
ReleaseSysCache(atttuple);
attnum++;
}
@@ -11224,7 +11224,7 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid,
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexoid);
- indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexStruct = GETSTRUCT(pg_index, indexTuple);
if (indexStruct->indisprimary && indexStruct->indisvalid)
{
/*
@@ -11337,7 +11337,7 @@ transformFkeyCheckAttrs(Relation pkrel,
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexoid);
- indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexStruct = GETSTRUCT(pg_index, indexTuple);
/*
* Must have the right number of columns; must be unique and not a
@@ -11851,7 +11851,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
{
ObjectAddress conobj;
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
/* Don't drop inherited constraints */
if (con->coninhcount > 0 && !recursing)
@@ -11984,7 +11984,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
systable_endscan(scan);
- con = (Form_pg_constraint) GETSTRUCT(copy_tuple);
+ con = GETSTRUCT(pg_constraint, copy_tuple);
/* Right now only CHECK constraints can be inherited */
if (con->contype != CONSTRAINT_CHECK)
@@ -12092,7 +12092,7 @@ ATPrepAlterColumnType(List **wqueue,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
/* Can't alter a system attribute */
@@ -12273,7 +12273,7 @@ ATPrepAlterColumnType(List **wqueue,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(childrel))));
- childattTup = (Form_pg_attribute) GETSTRUCT(childtuple);
+ childattTup = GETSTRUCT(pg_attribute, childtuple);
if (childattTup->attinhcount > numparents)
ereport(ERROR,
@@ -12433,7 +12433,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(heapTup);
+ attTup = GETSTRUCT(pg_attribute, heapTup);
attnum = attTup->attnum;
attOldTup = TupleDescAttr(tab->oldDesc, attnum - 1);
@@ -12447,7 +12447,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
/* Look up the target type (should not fail, since prep found it) */
typeTuple = typenameType(NULL, typeName, &targettypmod);
- tform = (Form_pg_type) GETSTRUCT(typeTuple);
+ tform = GETSTRUCT(pg_type, typeTuple);
targettype = tform->oid;
/* And the collation */
targetcollid = GetColumnDefCollation(NULL, def, targettype);
@@ -12521,7 +12521,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
while (HeapTupleIsValid(depTup = systable_getnext(scan)))
{
- Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend foundDep = GETSTRUCT(pg_depend, depTup);
ObjectAddress foundObject;
foundObject.classId = foundDep->classid;
@@ -12727,7 +12727,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
while (HeapTupleIsValid(depTup = systable_getnext(scan)))
{
- Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend foundDep = GETSTRUCT(pg_depend, depTup);
ObjectAddress foundObject;
foundObject.classId = foundDep->refclassid;
@@ -12815,7 +12815,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
valuesAtt, nullsAtt, replacesAtt);
heap_freetuple(heapTup);
heapTup = newTup;
- attTup = (Form_pg_attribute) GETSTRUCT(heapTup);
+ attTup = GETSTRUCT(pg_attribute, heapTup);
}
}
@@ -13093,7 +13093,7 @@ ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab, LOCKMODE lockmode)
tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(oldId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for constraint %u", oldId);
- con = (Form_pg_constraint) GETSTRUCT(tup);
+ con = GETSTRUCT(pg_constraint, tup);
if (OidIsValid(con->conrelid))
relid = con->conrelid;
else
@@ -13583,7 +13583,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign table \"%s\" does not exist",
RelationGetRelationName(rel))));
- fttableform = (Form_pg_foreign_table) GETSTRUCT(tuple);
+ fttableform = GETSTRUCT(pg_foreign_table, tuple);
server = GetForeignServer(fttableform->ftserver);
fdw = GetForeignDataWrapper(server->fdwid);
@@ -13599,7 +13599,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
colName, RelationGetRelationName(rel))));
/* Prevent them from altering a system attribute */
- atttableform = (Form_pg_attribute) GETSTRUCT(tuple);
+ atttableform = GETSTRUCT(pg_attribute, tuple);
attnum = atttableform->attnum;
if (attnum <= 0)
ereport(ERROR,
@@ -13687,7 +13687,7 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relationOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationOid);
- tuple_class = (Form_pg_class) GETSTRUCT(tuple);
+ tuple_class = GETSTRUCT(pg_class, tuple);
/* Can we change the ownership of this tuple? */
switch (tuple_class->relkind)
@@ -13923,7 +13923,7 @@ change_owner_fix_column_acls(Oid relationOid, Oid oldOwnerId, Oid newOwnerId)
true, NULL, 1, key);
while (HeapTupleIsValid(attributeTuple = systable_getnext(scan)))
{
- Form_pg_attribute att = (Form_pg_attribute) GETSTRUCT(attributeTuple);
+ Form_pg_attribute att = GETSTRUCT(pg_attribute, attributeTuple);
Datum repl_val[Natts_pg_attribute];
bool repl_null[Natts_pg_attribute];
bool repl_repl[Natts_pg_attribute];
@@ -14000,7 +14000,7 @@ change_owner_recurse_to_sequences(Oid relationOid, Oid newOwnerId, LOCKMODE lock
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend depForm = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depForm = GETSTRUCT(pg_depend, tup);
Relation seqRel;
/* skip dependencies other than auto dependencies on columns */
@@ -14543,7 +14543,7 @@ AlterTableMoveAll(AlterTableMoveAllStmt *stmt)
scan = table_beginscan_catalog(rel, 1, key);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class relForm = GETSTRUCT(pg_class, tuple);
Oid relOid = relForm->oid;
/*
@@ -14881,7 +14881,7 @@ CreateInheritance(Relation child_rel, Relation parent_rel)
inhseqno = 0;
while (HeapTupleIsValid(inheritsTuple = systable_getnext(scan)))
{
- Form_pg_inherits inh = (Form_pg_inherits) GETSTRUCT(inheritsTuple);
+ Form_pg_inherits inh = GETSTRUCT(pg_inherits, inheritsTuple);
if (inh->inhparent == RelationGetRelid(parent_rel))
ereport(ERROR,
@@ -14926,7 +14926,7 @@ decompile_conbin(HeapTuple contup, TupleDesc tupdesc)
Datum attr;
Datum expr;
- con = (Form_pg_constraint) GETSTRUCT(contup);
+ con = GETSTRUCT(pg_constraint, contup);
attr = heap_getattr(contup, Anum_pg_constraint_conbin, tupdesc, &isnull);
if (isnull)
elog(ERROR, "null conbin for constraint %u", con->oid);
@@ -14946,8 +14946,8 @@ decompile_conbin(HeapTuple contup, TupleDesc tupdesc)
static bool
constraints_equivalent(HeapTuple a, HeapTuple b, TupleDesc tupleDesc)
{
- Form_pg_constraint acon = (Form_pg_constraint) GETSTRUCT(a);
- Form_pg_constraint bcon = (Form_pg_constraint) GETSTRUCT(b);
+ Form_pg_constraint acon = GETSTRUCT(pg_constraint, a);
+ Form_pg_constraint bcon = GETSTRUCT(pg_constraint, b);
if (acon->condeferrable != bcon->condeferrable ||
acon->condeferred != bcon->condeferred ||
@@ -15007,7 +15007,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
if (HeapTupleIsValid(tuple))
{
/* Check they are same type, typmod, and collation */
- Form_pg_attribute childatt = (Form_pg_attribute) GETSTRUCT(tuple);
+ Form_pg_attribute childatt = GETSTRUCT(pg_attribute, tuple);
if (attribute->atttypid != childatt->atttypid ||
attribute->atttypmod != childatt->atttypmod)
@@ -15170,7 +15170,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
while (HeapTupleIsValid(parent_tuple = systable_getnext(parent_scan)))
{
- Form_pg_constraint parent_con = (Form_pg_constraint) GETSTRUCT(parent_tuple);
+ Form_pg_constraint parent_con = GETSTRUCT(pg_constraint, parent_tuple);
SysScanDesc child_scan;
ScanKeyData child_key;
HeapTuple child_tuple;
@@ -15193,7 +15193,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
while (HeapTupleIsValid(child_tuple = systable_getnext(child_scan)))
{
- Form_pg_constraint child_con = (Form_pg_constraint) GETSTRUCT(child_tuple);
+ Form_pg_constraint child_con = GETSTRUCT(pg_constraint, child_tuple);
HeapTuple child_copy;
if (child_con->contype != CONSTRAINT_CHECK)
@@ -15234,7 +15234,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
* later on, this change will just roll back.)
*/
child_copy = heap_copytuple(child_tuple);
- child_con = (Form_pg_constraint) GETSTRUCT(child_copy);
+ child_con = GETSTRUCT(pg_constraint, child_copy);
child_con->coninhcount++;
/*
@@ -15342,7 +15342,7 @@ MarkInheritDetached(Relation child_rel, Relation parent_rel)
{
Form_pg_inherits inhForm;
- inhForm = (Form_pg_inherits) GETSTRUCT(inheritsTuple);
+ inhForm = GETSTRUCT(pg_inherits, inheritsTuple);
if (inhForm->inhdetachpending)
ereport(ERROR,
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
@@ -15357,7 +15357,7 @@ MarkInheritDetached(Relation child_rel, Relation parent_rel)
HeapTuple newtup;
newtup = heap_copytuple(inheritsTuple);
- ((Form_pg_inherits) GETSTRUCT(newtup))->inhdetachpending = true;
+ (GETSTRUCT(pg_inherits, newtup))->inhdetachpending = true;
CatalogTupleUpdate(catalogRelation,
&inheritsTuple->t_self,
@@ -15446,7 +15446,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
true, NULL, 1, key);
while (HeapTupleIsValid(attributeTuple = systable_getnext(scan)))
{
- Form_pg_attribute att = (Form_pg_attribute) GETSTRUCT(attributeTuple);
+ Form_pg_attribute att = GETSTRUCT(pg_attribute, attributeTuple);
/* Ignore if dropped or not inherited */
if (att->attisdropped)
@@ -15459,7 +15459,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
{
/* Decrement inhcount and possibly set islocal to true */
HeapTuple copyTuple = heap_copytuple(attributeTuple);
- Form_pg_attribute copy_att = (Form_pg_attribute) GETSTRUCT(copyTuple);
+ Form_pg_attribute copy_att = GETSTRUCT(pg_attribute, copyTuple);
copy_att->attinhcount--;
if (copy_att->attinhcount == 0)
@@ -15490,7 +15490,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
while (HeapTupleIsValid(constraintTuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(constraintTuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, constraintTuple);
if (con->contype == CONSTRAINT_CHECK)
connames = lappend(connames, pstrdup(NameStr(con->conname)));
@@ -15508,7 +15508,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
while (HeapTupleIsValid(constraintTuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(constraintTuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, constraintTuple);
bool match;
ListCell *lc;
@@ -15529,7 +15529,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
{
/* Decrement inhcount and possibly set islocal to true */
HeapTuple copyTuple = heap_copytuple(constraintTuple);
- Form_pg_constraint copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple);
+ Form_pg_constraint copy_con = GETSTRUCT(pg_constraint, copyTuple);
if (copy_con->coninhcount <= 0) /* shouldn't happen */
elog(ERROR, "relation %u has non-inherited constraint \"%s\"",
@@ -15598,7 +15598,7 @@ drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid,
while (HeapTupleIsValid(depTuple = systable_getnext(scan)))
{
- Form_pg_depend dep = (Form_pg_depend) GETSTRUCT(depTuple);
+ Form_pg_depend dep = GETSTRUCT(pg_depend, depTuple);
if (dep->refclassid == refclassid &&
dep->refobjid == refobjid &&
@@ -15643,7 +15643,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
/* Validate the type. */
typetuple = typenameType(NULL, ofTypename, NULL);
check_of_type(typetuple);
- typeform = (Form_pg_type) GETSTRUCT(typetuple);
+ typeform = GETSTRUCT(pg_type, typetuple);
typeid = typeform->oid;
/* Fail if the table has any inheritance parents. */
@@ -15744,7 +15744,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
classtuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(classtuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- ((Form_pg_class) GETSTRUCT(classtuple))->reloftype = typeid;
+ (GETSTRUCT(pg_class, classtuple))->reloftype = typeid;
CatalogTupleUpdate(relationRelation, &classtuple->t_self, classtuple);
InvokeObjectPostAlterHook(RelationRelationId, relid, 0);
@@ -15789,7 +15789,7 @@ ATExecDropOf(Relation rel, LOCKMODE lockmode)
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- ((Form_pg_class) GETSTRUCT(tuple))->reloftype = InvalidOid;
+ (GETSTRUCT(pg_class, tuple))->reloftype = InvalidOid;
CatalogTupleUpdate(relationRelation, &tuple->t_self, tuple);
InvokeObjectPostAlterHook(RelationRelationId, relid, 0);
@@ -15826,7 +15826,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
if (!HeapTupleIsValid(pg_class_tuple))
elog(ERROR, "cache lookup failed for relation \"%s\"",
RelationGetRelationName(rel));
- pg_class_form = (Form_pg_class) GETSTRUCT(pg_class_tuple);
+ pg_class_form = GETSTRUCT(pg_class, pg_class_tuple);
if (pg_class_form->relreplident != ri_type)
{
pg_class_form->relreplident = ri_type;
@@ -15846,7 +15846,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
pg_index_tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexOid));
if (!HeapTupleIsValid(pg_index_tuple))
elog(ERROR, "cache lookup failed for index %u", indexOid);
- pg_index_form = (Form_pg_index) GETSTRUCT(pg_index_tuple);
+ pg_index_form = GETSTRUCT(pg_index, pg_index_tuple);
if (pg_index_form->indisreplident)
{
@@ -15870,7 +15870,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
ObjectIdGetDatum(thisIndexOid));
if (!HeapTupleIsValid(pg_index_tuple))
elog(ERROR, "cache lookup failed for index %u", thisIndexOid);
- pg_index_form = (Form_pg_index) GETSTRUCT(pg_index_tuple);
+ pg_index_form = GETSTRUCT(pg_index, pg_index_tuple);
/*
* Unset the bit if set. We know it's wrong because we checked this
@@ -16040,7 +16040,7 @@ ATExecSetRowSecurity(Relation rel, bool rls)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- ((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = rls;
+ (GETSTRUCT(pg_class, tuple))->relrowsecurity = rls;
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
table_close(pg_class, RowExclusiveLock);
@@ -16066,7 +16066,7 @@ ATExecForceNoForceRowSecurity(Relation rel, bool force_rls)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- ((Form_pg_class) GETSTRUCT(tuple))->relforcerowsecurity = force_rls;
+ (GETSTRUCT(pg_class, tuple))->relforcerowsecurity = force_rls;
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
table_close(pg_class, RowExclusiveLock);
@@ -16101,7 +16101,7 @@ ATExecGenericOptions(Relation rel, List *options)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign table \"%s\" does not exist",
RelationGetRelationName(rel))));
- tableform = (Form_pg_foreign_table) GETSTRUCT(tuple);
+ tableform = GETSTRUCT(pg_foreign_table, tuple);
server = GetForeignServer(tableform->ftserver);
fdw = GetForeignDataWrapper(server->fdwid);
@@ -16185,7 +16185,7 @@ ATExecSetCompression(AlteredTableInfo *tab,
column, RelationGetRelationName(rel))));
/* prevent them from altering a system attribute */
- atttableform = (Form_pg_attribute) GETSTRUCT(tuple);
+ atttableform = GETSTRUCT(pg_attribute, tuple);
attnum = atttableform->attnum;
if (attnum <= 0)
ereport(ERROR,
@@ -16306,7 +16306,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
if (con->contype == CONSTRAINT_FOREIGN)
{
@@ -16508,7 +16508,7 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(classTup))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- classForm = (Form_pg_class) GETSTRUCT(classTup);
+ classForm = GETSTRUCT(pg_class, classTup);
Assert(classForm->relnamespace == oldNspOid);
@@ -16640,7 +16640,7 @@ AlterSeqNamespaces(Relation classRel, Relation rel,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend depForm = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depForm = GETSTRUCT(pg_depend, tup);
Relation seqRel;
/* skip dependencies other than auto dependencies on columns */
@@ -16966,8 +16966,8 @@ RangeVarCallbackForTruncate(const RangeVar *relation,
if (!HeapTupleIsValid(tuple)) /* should not happen */
elog(ERROR, "cache lookup failed for relation %u", relId);
- truncate_check_rel(relId, (Form_pg_class) GETSTRUCT(tuple));
- truncate_check_perms(relId, (Form_pg_class) GETSTRUCT(tuple));
+ truncate_check_rel(relId, GETSTRUCT(pg_class, tuple));
+ truncate_check_perms(relId, GETSTRUCT(pg_class, tuple));
ReleaseSysCache(tuple);
}
@@ -16995,7 +16995,7 @@ RangeVarCallbackOwnsRelation(const RangeVar *relation,
relation->relname);
if (!allowSystemTableMods &&
- IsSystemClass(relId, (Form_pg_class) GETSTRUCT(tuple)))
+ IsSystemClass(relId, GETSTRUCT(pg_class, tuple)))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied: \"%s\" is a system catalog",
@@ -17022,7 +17022,7 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped */
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
relkind = classform->relkind;
/* Must own relation. */
@@ -17246,7 +17246,7 @@ ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNu
errmsg("column \"%s\" named in partition key does not exist",
pelem->name),
parser_errposition(pstate, pelem->location)));
- attform = (Form_pg_attribute) GETSTRUCT(atttuple);
+ attform = GETSTRUCT(pg_attribute, atttuple);
if (attform->attnum <= 0)
ereport(ERROR,
@@ -18154,7 +18154,7 @@ CloneRowTriggersToPartition(Relation parent, Relation partition)
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
- Form_pg_trigger trigForm = (Form_pg_trigger) GETSTRUCT(tuple);
+ Form_pg_trigger trigForm = GETSTRUCT(pg_trigger, tuple);
CreateTrigStmt *trigStmt;
Node *qual = NULL;
Datum value;
@@ -18508,7 +18508,7 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent,
contup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(fk->conoid));
if (!HeapTupleIsValid(contup))
elog(ERROR, "cache lookup failed for constraint %u", fk->conoid);
- conform = (Form_pg_constraint) GETSTRUCT(contup);
+ conform = GETSTRUCT(pg_constraint, contup);
/* consider only the inherited foreign keys */
if (conform->contype != CONSTRAINT_FOREIGN ||
@@ -18613,7 +18613,7 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(partRel));
- Assert(((Form_pg_class) GETSTRUCT(tuple))->relispartition);
+ Assert((GETSTRUCT(pg_class, tuple))->relispartition);
/* Clear relpartbound and reset relispartition */
memset(new_val, 0, sizeof(new_val));
@@ -18625,7 +18625,7 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent,
newtuple = heap_modify_tuple(tuple, RelationGetDescr(classRel),
new_val, new_null, new_repl);
- ((Form_pg_class) GETSTRUCT(newtuple))->relispartition = false;
+ (GETSTRUCT(pg_class, newtuple))->relispartition = false;
CatalogTupleUpdate(classRel, &newtuple->t_self, newtuple);
heap_freetuple(newtuple);
table_close(classRel, RowExclusiveLock);
@@ -18775,7 +18775,7 @@ DropClonedTriggersFromPartition(Oid partitionId)
true, NULL, 1, &skey);
while (HeapTupleIsValid(trigtup = systable_getnext(scan)))
{
- Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(trigtup);
+ Form_pg_trigger pg_trigger = GETSTRUCT(pg_trigger, trigtup);
ObjectAddress trig;
/* Ignore triggers that weren't cloned */
@@ -18862,7 +18862,7 @@ RangeVarCallbackForAttachIndex(const RangeVar *rv, Oid relOid, Oid oldRelOid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped, so nothing to do */
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
if (classform->relkind != RELKIND_PARTITIONED_INDEX &&
classform->relkind != RELKIND_INDEX)
ereport(ERROR,
@@ -19083,7 +19083,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
NULL, 1, &key);
while ((inhTup = systable_getnext(scan)) != NULL)
{
- Form_pg_inherits inhForm = (Form_pg_inherits) GETSTRUCT(inhTup);
+ Form_pg_inherits inhForm = GETSTRUCT(pg_inherits, inhTup);
HeapTuple indTup;
Form_pg_index indexForm;
@@ -19091,7 +19091,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
ObjectIdGetDatum(inhForm->inhrelid));
if (!HeapTupleIsValid(indTup))
elog(ERROR, "cache lookup failed for index %u", inhForm->inhrelid);
- indexForm = (Form_pg_index) GETSTRUCT(indTup);
+ indexForm = GETSTRUCT(pg_index, indTup);
if (indexForm->indisvalid)
tuples += 1;
ReleaseSysCache(indTup);
@@ -19113,7 +19113,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
idxRel = table_open(IndexRelationId, RowExclusiveLock);
newtup = heap_copytuple(partedIdx->rd_indextuple);
- ((Form_pg_index) GETSTRUCT(newtup))->indisvalid = true;
+ (GETSTRUCT(pg_index, newtup))->indisvalid = true;
updated = true;
CatalogTupleUpdate(idxRel, &partedIdx->rd_indextuple->t_self, newtup);
@@ -19183,7 +19183,7 @@ GetParentedForeignKeyRefs(Relation partition)
scan = systable_beginscan(pg_constraint, InvalidOid, true, NULL, 2, key);
while ((tuple = systable_getnext(scan)) != NULL)
{
- Form_pg_constraint constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint constrForm = GETSTRUCT(pg_constraint, tuple);
/*
* We only need to process constraints that are part of larger ones.
@@ -19224,7 +19224,7 @@ ATDetachCheckNoForeignKeyRefs(Relation partition)
tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constrOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", constrOid);
- constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ constrForm = GETSTRUCT(pg_constraint, tuple);
Assert(OidIsValid(constrForm->conparentid));
Assert(constrForm->confrelid == RelationGetRelid(partition));
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index c8bdd9992a..36ff46fda3 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -474,7 +474,7 @@ DropTableSpace(DropTableSpaceStmt *stmt)
return;
}
- spcform = (Form_pg_tablespace) GETSTRUCT(tuple);
+ spcform = GETSTRUCT(pg_tablespace, tuple);
tablespaceoid = spcform->oid;
/* Must be tablespace owner */
@@ -1002,7 +1002,7 @@ RenameTableSpace(const char *oldname, const char *newname)
oldname)));
newtuple = heap_copytuple(tup);
- newform = (Form_pg_tablespace) GETSTRUCT(newtuple);
+ newform = GETSTRUCT(pg_tablespace, newtuple);
tspId = newform->oid;
table_endscan(scan);
@@ -1090,7 +1090,7 @@ AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt)
errmsg("tablespace \"%s\" does not exist",
stmt->tablespacename)));
- tablespaceoid = ((Form_pg_tablespace) GETSTRUCT(tup))->oid;
+ tablespaceoid = (GETSTRUCT(pg_tablespace, tup))->oid;
/* Must be owner of the existing object */
if (!pg_tablespace_ownercheck(tablespaceoid, GetUserId()))
@@ -1495,7 +1495,7 @@ get_tablespace_oid(const char *tablespacename, bool missing_ok)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = ((Form_pg_tablespace) GETSTRUCT(tuple))->oid;
+ result = (GETSTRUCT(pg_tablespace, tuple))->oid;
else
result = InvalidOid;
@@ -1541,7 +1541,7 @@ get_tablespace_name(Oid spc_oid)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = pstrdup(NameStr(((Form_pg_tablespace) GETSTRUCT(tuple))->spcname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_tablespace, tuple))->spcname));
else
result = NULL;
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 13cb516752..5df3368f5b 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -743,7 +743,7 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
/* There should be at most one matching tuple */
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
- Form_pg_trigger oldtrigger = (Form_pg_trigger) GETSTRUCT(tuple);
+ Form_pg_trigger oldtrigger = GETSTRUCT(pg_trigger, tuple);
trigoid = oldtrigger->oid;
existing_constraint_oid = oldtrigger->tgconstraint;
@@ -1029,9 +1029,9 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(rel));
- if (!((Form_pg_class) GETSTRUCT(tuple))->relhastriggers)
+ if (!(GETSTRUCT(pg_class, tuple))->relhastriggers)
{
- ((Form_pg_class) GETSTRUCT(tuple))->relhastriggers = true;
+ (GETSTRUCT(pg_class, tuple))->relhastriggers = true;
CatalogTupleUpdate(pgrel, &tuple->t_self, tuple);
@@ -1290,7 +1290,7 @@ TriggerSetParentTrigger(Relation trigRel,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for trigger %u", childTrigId);
newtup = heap_copytuple(tuple);
- trigForm = (Form_pg_trigger) GETSTRUCT(newtup);
+ trigForm = GETSTRUCT(pg_trigger, newtup);
if (OidIsValid(parentTrigId))
{
/* don't allow setting parent for a constraint that already has one */
@@ -1362,7 +1362,7 @@ RemoveTriggerById(Oid trigOid)
/*
* Open and exclusive-lock the relation the trigger belongs to.
*/
- relid = ((Form_pg_trigger) GETSTRUCT(tup))->tgrelid;
+ relid = (GETSTRUCT(pg_trigger, tup))->tgrelid;
rel = table_open(relid, AccessExclusiveLock);
@@ -1450,7 +1450,7 @@ get_trigger_oid(Oid relid, const char *trigname, bool missing_ok)
}
else
{
- oid = ((Form_pg_trigger) GETSTRUCT(tup))->oid;
+ oid = (GETSTRUCT(pg_trigger, tup))->oid;
}
systable_endscan(tgscan);
@@ -1471,7 +1471,7 @@ RangeVarCallbackForRenameTrigger(const RangeVar *rv, Oid relid, Oid oldrelid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped */
- form = (Form_pg_class) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_class, tuple);
/* only tables and views can have triggers */
if (form->relkind != RELKIND_RELATION && form->relkind != RELKIND_VIEW &&
@@ -1558,7 +1558,7 @@ renametrig(RenameStmt *stmt)
{
Form_pg_trigger trigform;
- trigform = (Form_pg_trigger) GETSTRUCT(tuple);
+ trigform = GETSTRUCT(pg_trigger, tuple);
tgoid = trigform->oid;
/*
@@ -1632,7 +1632,7 @@ renametrig_internal(Relation tgrel, Relation targetrel, HeapTuple trigtup,
SysScanDesc tgscan;
/* If the trigger already has the new name, nothing to do. */
- tgform = (Form_pg_trigger) GETSTRUCT(trigtup);
+ tgform = GETSTRUCT(pg_trigger, trigtup);
if (strcmp(NameStr(tgform->tgname), newname) == 0)
return;
@@ -1662,7 +1662,7 @@ renametrig_internal(Relation tgrel, Relation targetrel, HeapTuple trigtup,
* The target name is free; update the existing pg_trigger tuple with it.
*/
tuple = heap_copytuple(trigtup); /* need a modifiable copy */
- tgform = (Form_pg_trigger) GETSTRUCT(tuple);
+ tgform = GETSTRUCT(pg_trigger, tuple);
/*
* If the trigger has a name different from what we expected, let the user
@@ -1714,7 +1714,7 @@ renametrig_partition(Relation tgrel, Oid partitionId, Oid parentTriggerOid,
NULL, 1, &key);
while (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
- Form_pg_trigger tgform = (Form_pg_trigger) GETSTRUCT(tuple);
+ Form_pg_trigger tgform = GETSTRUCT(pg_trigger, tuple);
Relation partitionRel;
if (tgform->tgparentid != parentTriggerOid)
@@ -1801,7 +1801,7 @@ EnableDisableTrigger(Relation rel, const char *tgname,
while (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
- Form_pg_trigger oldtrig = (Form_pg_trigger) GETSTRUCT(tuple);
+ Form_pg_trigger oldtrig = GETSTRUCT(pg_trigger, tuple);
if (oldtrig->tgisinternal)
{
@@ -1821,7 +1821,7 @@ EnableDisableTrigger(Relation rel, const char *tgname,
{
/* need to change this one ... make a copy to scribble on */
HeapTuple newtup = heap_copytuple(tuple);
- Form_pg_trigger newtrig = (Form_pg_trigger) GETSTRUCT(newtup);
+ Form_pg_trigger newtrig = GETSTRUCT(pg_trigger, newtup);
newtrig->tgenabled = fires_when;
@@ -1905,7 +1905,7 @@ RelationBuildTriggers(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(tgscan)))
{
- Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
+ Form_pg_trigger pg_trigger = GETSTRUCT(pg_trigger, htup);
Trigger *build;
Datum datum;
bool isnull;
@@ -5709,7 +5709,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
while (HeapTupleIsValid(tup = systable_getnext(conscan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tup);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tup);
if (con->condeferrable)
conoidlist = lappend_oid(conoidlist, con->oid);
@@ -5765,7 +5765,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
conoidlist = lappend_oid(conoidlist, con->oid);
}
@@ -5798,7 +5798,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
while (HeapTupleIsValid(htup = systable_getnext(tgscan)))
{
- Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
+ Form_pg_trigger pg_trigger = GETSTRUCT(pg_trigger, htup);
/*
* Silently skip triggers that are marked as non-deferrable in
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index 4cc4e3c00f..164379934a 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -130,7 +130,7 @@ get_ts_parser_func(DefElem *defel, int attnum)
static ObjectAddress
makeParserDependencies(HeapTuple tuple)
{
- Form_pg_ts_parser prs = (Form_pg_ts_parser) GETSTRUCT(tuple);
+ Form_pg_ts_parser prs = GETSTRUCT(pg_ts_parser, tuple);
ObjectAddress myself,
referenced;
ObjectAddresses *addrs;
@@ -300,7 +300,7 @@ DefineTSParser(List *names, List *parameters)
static ObjectAddress
makeDictionaryDependencies(HeapTuple tuple)
{
- Form_pg_ts_dict dict = (Form_pg_ts_dict) GETSTRUCT(tuple);
+ Form_pg_ts_dict dict = GETSTRUCT(pg_ts_dict, tuple);
ObjectAddress myself,
referenced;
ObjectAddresses *addrs;
@@ -353,7 +353,7 @@ verify_dictoptions(Oid tmplId, List *dictoptions)
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for text search template %u",
tmplId);
- tform = (Form_pg_ts_template) GETSTRUCT(tup);
+ tform = GETSTRUCT(pg_ts_template, tup);
initmethod = tform->tmplinit;
@@ -552,7 +552,7 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
/*
* Validate
*/
- verify_dictoptions(((Form_pg_ts_dict) GETSTRUCT(tup))->dicttemplate,
+ verify_dictoptions((GETSTRUCT(pg_ts_dict, tup))->dicttemplate,
dictoptions);
/*
@@ -645,7 +645,7 @@ get_ts_template_func(DefElem *defel, int attnum)
static ObjectAddress
makeTSTemplateDependencies(HeapTuple tuple)
{
- Form_pg_ts_template tmpl = (Form_pg_ts_template) GETSTRUCT(tuple);
+ Form_pg_ts_template tmpl = GETSTRUCT(pg_ts_template, tuple);
ObjectAddress myself,
referenced;
ObjectAddresses *addrs;
@@ -806,7 +806,7 @@ static ObjectAddress
makeConfigurationDependencies(HeapTuple tuple, bool removeOld,
Relation mapRel)
{
- Form_pg_ts_config cfg = (Form_pg_ts_config) GETSTRUCT(tuple);
+ Form_pg_ts_config cfg = GETSTRUCT(pg_ts_config, tuple);
ObjectAddresses *addrs;
ObjectAddress myself,
referenced;
@@ -867,7 +867,7 @@ makeConfigurationDependencies(HeapTuple tuple, bool removeOld,
while (HeapTupleIsValid((maptup = systable_getnext(scan))))
{
- Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup);
+ Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup);
referenced.classId = TSDictionaryRelationId;
referenced.objectId = cfgmap->mapdict;
@@ -959,7 +959,7 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied)
elog(ERROR, "cache lookup failed for text search configuration %u",
sourceOid);
- cfg = (Form_pg_ts_config) GETSTRUCT(tup);
+ cfg = GETSTRUCT(pg_ts_config, tup);
/* use source's parser */
prsOid = cfg->cfgparser;
@@ -1017,7 +1017,7 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied)
while (HeapTupleIsValid((maptup = systable_getnext(scan))))
{
- Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup);
+ Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup);
HeapTuple newmaptup;
Datum mapvalues[Natts_pg_ts_config_map];
bool mapnulls[Natts_pg_ts_config_map];
@@ -1121,7 +1121,7 @@ AlterTSConfiguration(AlterTSConfigurationStmt *stmt)
errmsg("text search configuration \"%s\" does not exist",
NameListToString(stmt->cfgname))));
- cfgId = ((Form_pg_ts_config) GETSTRUCT(tup))->oid;
+ cfgId = (GETSTRUCT(pg_ts_config, tup))->oid;
/* must be owner */
if (!pg_ts_config_ownercheck(cfgId, GetUserId()))
@@ -1226,7 +1226,7 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt,
int ndict;
ListCell *c;
- tsform = (Form_pg_ts_config) GETSTRUCT(tup);
+ tsform = GETSTRUCT(pg_ts_config, tup);
cfgId = tsform->oid;
prsId = tsform->cfgparser;
@@ -1293,7 +1293,7 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt,
while (HeapTupleIsValid((maptup = systable_getnext(scan))))
{
- Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup);
+ Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup);
/*
* check if it's one of target token types
@@ -1386,7 +1386,7 @@ DropConfigurationMapping(AlterTSConfigurationStmt *stmt,
int *tokens;
ListCell *c;
- tsform = (Form_pg_ts_config) GETSTRUCT(tup);
+ tsform = GETSTRUCT(pg_ts_config, tup);
cfgId = tsform->oid;
prsId = tsform->cfgparser;
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 4f5e7c7ccb..3719ea905e 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -345,7 +345,7 @@ DefineType(ParseState *pstate, List *names, List *parameters)
Form_pg_type likeForm;
likeType = typenameType(NULL, defGetTypeName(likeTypeEl), NULL);
- likeForm = (Form_pg_type) GETSTRUCT(likeType);
+ likeForm = GETSTRUCT(pg_type, likeType);
internalLength = likeForm->typlen;
byValue = likeForm->typbyval;
alignment = likeForm->typalign;
@@ -668,7 +668,7 @@ RemoveTypeById(Oid typeOid)
* making dependency entries for those, so it has to be done "by hand"
* here.
*/
- if (((Form_pg_type) GETSTRUCT(tup))->typtype == TYPTYPE_ENUM)
+ if ((GETSTRUCT(pg_type, tup))->typtype == TYPTYPE_ENUM)
EnumValuesDelete(typeOid);
/*
@@ -676,7 +676,7 @@ RemoveTypeById(Oid typeOid)
* with making a dependency entry for that, so it has to be done "by hand"
* here.
*/
- if (((Form_pg_type) GETSTRUCT(tup))->typtype == TYPTYPE_RANGE)
+ if ((GETSTRUCT(pg_type, tup))->typtype == TYPTYPE_RANGE)
RangeDelete(typeOid);
ReleaseSysCache(tup);
@@ -758,7 +758,7 @@ DefineDomain(CreateDomainStmt *stmt)
* Look up the base type.
*/
typeTup = typenameType(NULL, stmt->typeName, &basetypeMod);
- baseType = (Form_pg_type) GETSTRUCT(typeTup);
+ baseType = GETSTRUCT(pg_type, typeTup);
basetypeoid = baseType->oid;
/*
@@ -1308,7 +1308,7 @@ AlterEnum(AlterEnumStmt *stmt)
static void
checkEnumOwner(HeapTuple tup)
{
- Form_pg_type typTup = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typTup = GETSTRUCT(pg_type, tup);
/* Check that this is actually an enum */
if (typTup->typtype != TYPTYPE_ENUM)
@@ -2587,7 +2587,7 @@ AlterDomainDefault(List *names, Node *defaultRaw)
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* Check it's a domain and check user has permission for ALTER DOMAIN */
checkDomainOwner(tup);
@@ -2712,7 +2712,7 @@ AlterDomainNotNull(List *names, bool notNull)
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* Check it's a domain and check user has permission for ALTER DOMAIN */
checkDomainOwner(tup);
@@ -2867,7 +2867,7 @@ AlterDomainDropConstraint(List *names, const char *constrName,
ObjectAddress conobj;
conobj.classId = ConstraintRelationId;
- conobj.objectId = ((Form_pg_constraint) GETSTRUCT(contup))->oid;
+ conobj.objectId = (GETSTRUCT(pg_constraint, contup))->oid;
conobj.objectSubId = 0;
performDeletion(&conobj, behavior, 0);
@@ -2934,7 +2934,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint,
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* Check it's a domain and check user has permission for ALTER DOMAIN */
checkDomainOwner(tup);
@@ -3088,7 +3088,7 @@ AlterDomainValidateConstraint(List *names, const char *constrName)
errmsg("constraint \"%s\" of domain \"%s\" does not exist",
constrName, TypeNameToString(typename))));
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
if (con->contype != CONSTRAINT_CHECK)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -3109,7 +3109,7 @@ AlterDomainValidateConstraint(List *names, const char *constrName)
* Now update the catalog, while we have the door open.
*/
copyTuple = heap_copytuple(tuple);
- copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple);
+ copy_con = GETSTRUCT(pg_constraint, copyTuple);
copy_con->convalidated = true;
CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple);
@@ -3284,7 +3284,7 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
while (HeapTupleIsValid(depTup = systable_getnext(depScan)))
{
- Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend pg_depend = GETSTRUCT(pg_depend, depTup);
RelToCheck *rtc = NULL;
ListCell *rellist;
Form_pg_attribute pg_att;
@@ -3421,7 +3421,7 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
void
checkDomainOwner(HeapTuple tup)
{
- Form_pg_type typTup = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typTup = GETSTRUCT(pg_type, tup);
/* Check that this is actually a domain */
if (typTup->typtype != TYPTYPE_DOMAIN)
@@ -3617,7 +3617,7 @@ RenameType(RenameStmt *stmt)
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* check permissions on type */
if (!pg_type_ownercheck(typeOid, GetUserId()))
@@ -3702,7 +3702,7 @@ AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype)
newtup = heap_copytuple(tup);
ReleaseSysCache(tup);
tup = newtup;
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* Don't allow ALTER DOMAIN on a type */
if (objecttype == OBJECT_DOMAIN && typTup->typtype != TYPTYPE_DOMAIN)
@@ -3792,7 +3792,7 @@ AlterTypeOwner_oid(Oid typeOid, Oid newOwnerId, bool hasDependEntry)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/*
* If it's a composite type, invoke ATExecChangeOwner so that we fix up
@@ -3838,7 +3838,7 @@ AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId)
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
memset(repl_null, false, sizeof(repl_null));
memset(repl_repl, false, sizeof(repl_repl));
@@ -3979,7 +3979,7 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typform = (Form_pg_type) GETSTRUCT(tup);
+ typform = GETSTRUCT(pg_type, tup);
oldNspOid = typform->typnamespace;
arrayOid = typform->typarray;
@@ -4113,7 +4113,7 @@ AlterType(AlterTypeStmt *stmt)
tup = typenameType(NULL, typename, NULL);
typeOid = typeTypeId(tup);
- typForm = (Form_pg_type) GETSTRUCT(tup);
+ typForm = GETSTRUCT(pg_type, tup);
/* Process options */
memset(&atparams, 0, sizeof(atparams));
@@ -4427,7 +4427,7 @@ AlterTypeRecurse(Oid typeOid, bool isImplicitArray,
if (!isImplicitArray &&
(atparams->updateTypmodin || atparams->updateTypmodout))
{
- Oid arrtypoid = ((Form_pg_type) GETSTRUCT(newtup))->typarray;
+ Oid arrtypoid = (GETSTRUCT(pg_type, newtup))->typarray;
if (OidIsValid(arrtypoid))
{
@@ -4476,7 +4476,7 @@ AlterTypeRecurse(Oid typeOid, bool isImplicitArray,
while ((domainTup = systable_getnext(scan)) != NULL)
{
- Form_pg_type domainForm = (Form_pg_type) GETSTRUCT(domainTup);
+ Form_pg_type domainForm = GETSTRUCT(pg_type, domainTup);
/*
* Shouldn't have a nonzero typbasetype in a non-domain, but let's
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 984305ba31..767c75ce2f 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -446,7 +446,7 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
{
RoleSpec *oldrole = lfirst(item);
HeapTuple oldroletup = get_rolespec_tuple(oldrole);
- Form_pg_authid oldroleform = (Form_pg_authid) GETSTRUCT(oldroletup);
+ Form_pg_authid oldroleform = GETSTRUCT(pg_authid, oldroletup);
Oid oldroleid = oldroleform->oid;
char *oldrolename = NameStr(oldroleform->rolname);
@@ -620,7 +620,7 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
pg_authid_dsc = RelationGetDescr(pg_authid_rel);
tuple = get_rolespec_tuple(stmt->role);
- authform = (Form_pg_authid) GETSTRUCT(tuple);
+ authform = GETSTRUCT(pg_authid, tuple);
rolename = pstrdup(NameStr(authform->rolname));
roleid = authform->oid;
@@ -838,7 +838,7 @@ AlterRoleSet(AlterRoleSetStmt *stmt)
"Cannot alter reserved roles.");
roletuple = get_rolespec_tuple(stmt->role);
- roleform = (Form_pg_authid) GETSTRUCT(roletuple);
+ roleform = GETSTRUCT(pg_authid, roletuple);
roleid = roleform->oid;
/*
@@ -962,7 +962,7 @@ DropRole(DropRoleStmt *stmt)
continue;
}
- roleform = (Form_pg_authid) GETSTRUCT(tuple);
+ roleform = GETSTRUCT(pg_authid, tuple);
roleid = roleform->oid;
if (roleid == GetUserId())
@@ -1117,7 +1117,7 @@ RenameRole(const char *oldname, const char *newname)
* effective userid, though.
*/
- authform = (Form_pg_authid) GETSTRUCT(oldtuple);
+ authform = GETSTRUCT(pg_authid, oldtuple);
roleid = authform->oid;
if (roleid == GetSessionUserId())
@@ -1165,7 +1165,7 @@ RenameRole(const char *oldname, const char *newname)
/*
* createrole is enough privilege unless you want to mess with a superuser
*/
- if (((Form_pg_authid) GETSTRUCT(oldtuple))->rolsuper)
+ if ((GETSTRUCT(pg_authid, oldtuple))->rolsuper)
{
if (!superuser())
ereport(ERROR,
@@ -1490,7 +1490,7 @@ AddRoleMems(const char *rolename, Oid roleid,
ObjectIdGetDatum(memberid));
if (HeapTupleIsValid(authmem_tuple) &&
(!admin_opt ||
- ((Form_pg_auth_members) GETSTRUCT(authmem_tuple))->admin_option))
+ (GETSTRUCT(pg_auth_members, authmem_tuple))->admin_option))
{
ereport(NOTICE,
(errmsg("role \"%s\" is already a member of role \"%s\"",
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 8df25f59d8..72a028f21f 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -806,7 +806,7 @@ expand_vacuum_rel(VacuumRelation *vrel, int options)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/*
* Make a returnable VacuumRelation for this rel if user is a proper
@@ -894,7 +894,7 @@ get_all_vacuum_rels(int options)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classForm = GETSTRUCT(pg_class, tuple);
MemoryContext oldcontext;
Oid relid = classForm->oid;
@@ -1346,7 +1346,7 @@ vac_update_relstats(Relation relation,
if (!HeapTupleIsValid(ctup))
elog(ERROR, "pg_class entry for relid %u vanished during vacuuming",
relid);
- pgcform = (Form_pg_class) GETSTRUCT(ctup);
+ pgcform = GETSTRUCT(pg_class, ctup);
/* Apply statistical updates, if any, to copied tuple */
@@ -1545,7 +1545,7 @@ vac_update_datfrozenxid(void)
while ((classTup = systable_getnext(scan)) != NULL)
{
- Form_pg_class classForm = (Form_pg_class) GETSTRUCT(classTup);
+ Form_pg_class classForm = GETSTRUCT(pg_class, classTup);
/*
* Only consider relations able to hold unfrozen XIDs (anything else
@@ -1639,7 +1639,7 @@ vac_update_datfrozenxid(void)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for database %u", MyDatabaseId);
- dbform = (Form_pg_database) GETSTRUCT(tuple);
+ dbform = GETSTRUCT(pg_database, tuple);
/*
* As in vac_update_relstats(), we ordinarily don't want to let
@@ -1747,7 +1747,7 @@ vac_truncate_clog(TransactionId frozenXID,
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- volatile FormData_pg_database *dbform = (Form_pg_database) GETSTRUCT(tuple);
+ volatile FormData_pg_database *dbform = GETSTRUCT(pg_database, tuple);
TransactionId datfrozenxid = dbform->datfrozenxid;
TransactionId datminmxid = dbform->datminmxid;
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index e5ddcda0b4..49f548d144 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -782,7 +782,7 @@ check_session_authorization(char **newval, void **extra, GucSource source)
return false;
}
- roleform = (Form_pg_authid) GETSTRUCT(roleTup);
+ roleform = GETSTRUCT(pg_authid, roleTup);
roleid = roleform->oid;
is_superuser = roleform->rolsuper;
@@ -869,7 +869,7 @@ check_role(char **newval, void **extra, GucSource source)
return false;
}
- roleform = (Form_pg_authid) GETSTRUCT(roleTup);
+ roleform = GETSTRUCT(pg_authid, roleTup);
roleid = roleform->oid;
is_superuser = roleform->rolsuper;
diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c
index 44b2e0b82d..09c40fa1e1 100644
--- a/src/backend/executor/execAmi.c
+++ b/src/backend/executor/execAmi.c
@@ -612,7 +612,7 @@ IndexSupportsBackwardScan(Oid indexid)
ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(indexid));
if (!HeapTupleIsValid(ht_idxrel))
elog(ERROR, "cache lookup failed for relation %u", indexid);
- idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);
+ idxrelrec = GETSTRUCT(pg_class, ht_idxrel);
/* Fetch the index AM's API struct */
amroutine = GetIndexAmRoutineByAmId(idxrelrec->relam, false);
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index f9460ae506..4354928b11 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -178,7 +178,7 @@ prepare_sql_fn_parse_info(HeapTuple procedureTuple,
Oid inputCollation)
{
SQLFunctionParseInfoPtr pinfo;
- Form_pg_proc procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ Form_pg_proc procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
int nargs;
pinfo = (SQLFunctionParseInfoPtr) palloc0(sizeof(SQLFunctionParseInfo));
@@ -623,7 +623,7 @@ init_sql_fcache(FunctionCallInfo fcinfo, Oid collation, bool lazyEvalOK)
procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(foid));
if (!HeapTupleIsValid(procedureTuple))
elog(ERROR, "cache lookup failed for function %u", foid);
- procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
/*
* copy function name immediately for use by error reporting callback, and
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 2fc606cf29..668e3181ac 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -3666,7 +3666,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
if (!HeapTupleIsValid(aggTuple))
elog(ERROR, "cache lookup failed for aggregate %u",
aggref->aggfnoid);
- aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
+ aggform = GETSTRUCT(pg_aggregate, aggTuple);
/* Check permission to call aggregate function */
aclresult = pg_proc_aclcheck(aggref->aggfnoid, GetUserId(),
@@ -3731,7 +3731,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
if (!HeapTupleIsValid(procTuple))
elog(ERROR, "cache lookup failed for function %u",
aggref->aggfnoid);
- aggOwner = ((Form_pg_proc) GETSTRUCT(procTuple))->proowner;
+ aggOwner = (GETSTRUCT(pg_proc, procTuple))->proowner;
ReleaseSysCache(procTuple);
if (OidIsValid(finalfn_oid))
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 4b104c4d98..14b3547309 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -2775,7 +2775,7 @@ initialize_peragg(WindowAggState *winstate, WindowFunc *wfunc,
if (!HeapTupleIsValid(aggTuple))
elog(ERROR, "cache lookup failed for aggregate %u",
wfunc->winfnoid);
- aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
+ aggform = GETSTRUCT(pg_aggregate, aggTuple);
/*
* Figure out whether we want to use the moving-aggregate implementation,
@@ -2836,7 +2836,7 @@ initialize_peragg(WindowAggState *winstate, WindowFunc *wfunc,
if (!HeapTupleIsValid(procTuple))
elog(ERROR, "cache lookup failed for function %u",
wfunc->winfnoid);
- aggOwner = ((Form_pg_proc) GETSTRUCT(procTuple))->proowner;
+ aggOwner = (GETSTRUCT(pg_proc, procTuple))->proowner;
ReleaseSysCache(procTuple);
aclresult = pg_proc_aclcheck(transfn_oid, aggOwner,
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 29bc26669b..72998c71fb 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -1291,7 +1291,7 @@ SPI_gettype(TupleDesc tupdesc, int fnumber)
return NULL;
}
- result = pstrdup(NameStr(((Form_pg_type) GETSTRUCT(typeTuple))->typname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_type, typeTuple))->typname));
ReleaseSysCache(typeTuple);
return result;
}
diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c
index cf222fc3e9..4f52075f03 100644
--- a/src/backend/foreign/foreign.c
+++ b/src/backend/foreign/foreign.c
@@ -62,7 +62,7 @@ GetForeignDataWrapperExtended(Oid fdwid, bits16 flags)
return NULL;
}
- fdwform = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp);
+ fdwform = GETSTRUCT(pg_foreign_data_wrapper, tp);
fdw = (ForeignDataWrapper *) palloc(sizeof(ForeignDataWrapper));
fdw->fdwid = fdwid;
@@ -136,7 +136,7 @@ GetForeignServerExtended(Oid serverid, bits16 flags)
return NULL;
}
- serverform = (Form_pg_foreign_server) GETSTRUCT(tp);
+ serverform = GETSTRUCT(pg_foreign_server, tp);
server = (ForeignServer *) palloc(sizeof(ForeignServer));
server->serverid = serverid;
@@ -222,7 +222,7 @@ GetUserMapping(Oid userid, Oid serverid)
MappingUserName(userid))));
um = (UserMapping *) palloc(sizeof(UserMapping));
- um->umid = ((Form_pg_user_mapping) GETSTRUCT(tp))->oid;
+ um->umid = (GETSTRUCT(pg_user_mapping, tp))->oid;
um->userid = userid;
um->serverid = serverid;
@@ -257,7 +257,7 @@ GetForeignTable(Oid relid)
tp = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign table %u", relid);
- tableform = (Form_pg_foreign_table) GETSTRUCT(tp);
+ tableform = GETSTRUCT(pg_foreign_table, tp);
ft = (ForeignTable *) palloc(sizeof(ForeignTable));
ft->relid = relid;
@@ -347,7 +347,7 @@ GetForeignServerIdByRelId(Oid relid)
tp = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign table %u", relid);
- tableform = (Form_pg_foreign_table) GETSTRUCT(tp);
+ tableform = GETSTRUCT(pg_foreign_table, tp);
serverid = tableform->ftserver;
ReleaseSysCache(tp);
@@ -372,7 +372,7 @@ GetFdwRoutineByServerId(Oid serverid)
tp = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(serverid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign server %u", serverid);
- serverform = (Form_pg_foreign_server) GETSTRUCT(tp);
+ serverform = GETSTRUCT(pg_foreign_server, tp);
fdwid = serverform->srvfdw;
ReleaseSysCache(tp);
@@ -380,7 +380,7 @@ GetFdwRoutineByServerId(Oid serverid)
tp = SearchSysCache1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(fdwid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign-data wrapper %u", fdwid);
- fdwform = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp);
+ fdwform = GETSTRUCT(pg_foreign_data_wrapper, tp);
fdwhandler = fdwform->fdwhandler;
/* Complain if FDW has been set to NO HANDLER. */
diff --git a/src/backend/optimizer/plan/planagg.c b/src/backend/optimizer/plan/planagg.c
index 9330908cbf..c924c0e61c 100644
--- a/src/backend/optimizer/plan/planagg.c
+++ b/src/backend/optimizer/plan/planagg.c
@@ -505,7 +505,7 @@ fetch_agg_sort_op(Oid aggfnoid)
aggTuple = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(aggfnoid));
if (!HeapTupleIsValid(aggTuple))
return InvalidOid;
- aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
+ aggform = GETSTRUCT(pg_aggregate, aggTuple);
aggsortop = aggform->aggsortop;
ReleaseSysCache(aggTuple);
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c
index df4ca12919..c80434b08c 100644
--- a/src/backend/optimizer/plan/subselect.c
+++ b/src/backend/optimizer/plan/subselect.c
@@ -866,7 +866,7 @@ hash_ok_operator(OpExpr *expr)
tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(opid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for operator %u", opid);
- optup = (Form_pg_operator) GETSTRUCT(tup);
+ optup = GETSTRUCT(pg_operator, tup);
if (!optup->oprcanhash || !func_strict(optup->oprcode))
{
ReleaseSysCache(tup);
diff --git a/src/backend/optimizer/prep/prepagg.c b/src/backend/optimizer/prep/prepagg.c
index 404a5f1dac..45f28de829 100644
--- a/src/backend/optimizer/prep/prepagg.c
+++ b/src/backend/optimizer/prep/prepagg.c
@@ -152,7 +152,7 @@ preprocess_aggref(Aggref *aggref, PlannerInfo *root)
if (!HeapTupleIsValid(aggTuple))
elog(ERROR, "cache lookup failed for aggregate %u",
aggref->aggfnoid);
- aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
+ aggform = GETSTRUCT(pg_aggregate, aggTuple);
aggtransfn = aggform->aggtransfn;
aggfinalfn = aggform->aggfinalfn;
aggcombinefn = aggform->aggcombinefn;
diff --git a/src/backend/optimizer/util/appendinfo.c b/src/backend/optimizer/util/appendinfo.c
index 9d4bb47027..a450c1e69f 100644
--- a/src/backend/optimizer/util/appendinfo.c
+++ b/src/backend/optimizer/util/appendinfo.c
@@ -150,7 +150,7 @@ make_inh_translation_list(Relation oldrelation, Relation newrelation,
if (!HeapTupleIsValid(newtup))
elog(ERROR, "could not find inherited attribute \"%s\" of relation \"%s\"",
attname, RelationGetRelationName(newrelation));
- new_attno = ((Form_pg_attribute) GETSTRUCT(newtup))->attnum - 1;
+ new_attno = (GETSTRUCT(pg_attribute, newtup))->attnum - 1;
Assert(new_attno >= 0 && new_attno < newnatts);
ReleaseSysCache(newtup);
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index 533df86ff7..277218abdc 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -3962,7 +3962,7 @@ simplify_function(Oid funcid, Oid result_type, int32 result_typmod,
func_tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(func_tuple))
elog(ERROR, "cache lookup failed for function %u", funcid);
- func_form = (Form_pg_proc) GETSTRUCT(func_tuple);
+ func_form = GETSTRUCT(pg_proc, func_tuple);
/*
* Process the function arguments, unless the caller did it already.
@@ -4056,7 +4056,7 @@ List *
expand_function_arguments(List *args, bool include_out_arguments,
Oid result_type, HeapTuple func_tuple)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
Oid *proargtypes = funcform->proargtypes.values;
int pronargs = funcform->pronargs;
bool has_named_args = false;
@@ -4136,7 +4136,7 @@ expand_function_arguments(List *args, bool include_out_arguments,
static List *
reorder_function_arguments(List *args, int pronargs, HeapTuple func_tuple)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
int nargsprovided = list_length(args);
Node *argarray[FUNC_MAX_ARGS];
ListCell *lc;
@@ -4267,7 +4267,7 @@ recheck_cast_function_args(List *args, Oid result_type,
Oid *proargtypes, int pronargs,
HeapTuple func_tuple)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
int nargs;
Oid actual_arg_types[FUNC_MAX_ARGS];
Oid declared_arg_types[FUNC_MAX_ARGS];
@@ -4314,7 +4314,7 @@ evaluate_function(Oid funcid, Oid result_type, int32 result_typmod,
HeapTuple func_tuple,
eval_const_expressions_context *context)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
bool has_nonconst_input = false;
bool has_null_input = false;
ListCell *arg;
@@ -4441,7 +4441,7 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid,
HeapTuple func_tuple,
eval_const_expressions_context *context)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
char *src;
Datum tmp;
bool isNull;
@@ -5034,7 +5034,7 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
func_tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(func_oid));
if (!HeapTupleIsValid(func_tuple))
elog(ERROR, "cache lookup failed for function %u", func_oid);
- funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ funcform = GETSTRUCT(pg_proc, func_tuple);
/*
* Forget it if the function is not SQL-language or has other showstopper
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 5012bfe142..c163f1096e 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -1296,7 +1296,7 @@ get_relation_statistics_worker(List **stainfos, RelOptInfo *rel,
if (!HeapTupleIsValid(dtup))
return;
- dataForm = (Form_pg_statistic_ext_data) GETSTRUCT(dtup);
+ dataForm = GETSTRUCT(pg_statistic_ext_data, dtup);
/* add one StatisticExtInfo for each kind built */
if (statext_is_kind_built(dtup, STATS_EXT_NDISTINCT))
@@ -1388,7 +1388,7 @@ get_relation_statistics(RelOptInfo *rel, Relation relation)
htup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statOid));
if (!HeapTupleIsValid(htup))
elog(ERROR, "cache lookup failed for statistics object %u", statOid);
- staForm = (Form_pg_statistic_ext) GETSTRUCT(htup);
+ staForm = GETSTRUCT(pg_statistic_ext, htup);
/*
* First, build the array of columns covered. This is ultimately
@@ -1994,7 +1994,7 @@ add_function_cost(PlannerInfo *root, Oid funcid, Node *node,
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
if (OidIsValid(procform->prosupport))
{
@@ -2055,7 +2055,7 @@ get_function_rows(PlannerInfo *root, Oid funcid, Node *node)
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
Assert(procform->proretset); /* else caller error */
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index c655d188c7..36451e7d63 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -3617,7 +3617,7 @@ transformFrameOffset(ParseState *pstate, int frameOptions,
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
/* The search will find all support proc types; ignore others */
if (procform->amprocnum != BTINRANGE_PROC)
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index c4e958e4aa..172d4b2034 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -853,7 +853,7 @@ build_coercion_expression(Node *node,
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcId));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcId);
- procstruct = (Form_pg_proc) GETSTRUCT(tp);
+ procstruct = GETSTRUCT(pg_proc, tp);
/*
* These Asserts essentially check that function is a legal coercion
@@ -3056,7 +3056,7 @@ IsBinaryCoercible(Oid srctype, Oid targettype)
ObjectIdGetDatum(targettype));
if (!HeapTupleIsValid(tuple))
return false; /* no cast */
- castForm = (Form_pg_cast) GETSTRUCT(tuple);
+ castForm = GETSTRUCT(pg_cast, tuple);
result = (castForm->castmethod == COERCION_METHOD_BINARY &&
castForm->castcontext == COERCION_CODE_IMPLICIT);
@@ -3120,7 +3120,7 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
if (HeapTupleIsValid(tuple))
{
- Form_pg_cast castForm = (Form_pg_cast) GETSTRUCT(tuple);
+ Form_pg_cast castForm = GETSTRUCT(pg_cast, tuple);
CoercionContext castcontext;
/* convert char value for castcontext to CoercionContext enum */
@@ -3269,7 +3269,7 @@ find_typmod_coercion_function(Oid typeId,
result = COERCION_PATH_FUNC;
targetType = typeidType(typeId);
- typeForm = (Form_pg_type) GETSTRUCT(targetType);
+ typeForm = GETSTRUCT(pg_type, targetType);
/* Check for a "true" array type */
if (IsTrueArrayType(typeForm))
@@ -3287,7 +3287,7 @@ find_typmod_coercion_function(Oid typeId,
if (HeapTupleIsValid(tuple))
{
- Form_pg_cast castForm = (Form_pg_cast) GETSTRUCT(tuple);
+ Form_pg_cast castForm = GETSTRUCT(pg_cast, tuple);
*funcid = castForm->castfunc;
ReleaseSysCache(tuple);
@@ -3335,7 +3335,7 @@ typeIsOfTypedTable(Oid reltypeId, Oid reloftypeId)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltup = (Form_pg_class) GETSTRUCT(tp);
+ reltup = GETSTRUCT(pg_class, tp);
if (reltup->reloftype == reloftypeId)
result = true;
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index f71a682cd6..c9be37c173 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -367,7 +367,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
tup = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for aggregate %u", funcid);
- classForm = (Form_pg_aggregate) GETSTRUCT(tup);
+ classForm = GETSTRUCT(pg_aggregate, tup);
aggkind = classForm->aggkind;
catDirectArgs = classForm->aggnumdirectargs;
ReleaseSysCache(tup);
@@ -1623,7 +1623,7 @@ func_get_detail(List *funcname,
if (!HeapTupleIsValid(ftup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u",
best_candidate->oid);
- pform = (Form_pg_proc) GETSTRUCT(ftup);
+ pform = GETSTRUCT(pg_proc, ftup);
*rettype = pform->prorettype;
*retset = pform->proretset;
*vatype = pform->provariadic;
@@ -1893,7 +1893,7 @@ FuncNameAsType(List *funcname)
if (typtup == NULL)
return InvalidOid;
- if (((Form_pg_type) GETSTRUCT(typtup))->typisdefined &&
+ if ((GETSTRUCT(pg_type, typtup))->typisdefined &&
!OidIsValid(typeTypeRelid(typtup)))
result = typeTypeId(typtup);
else
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index cf64afbd85..2c165bb1be 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -249,14 +249,14 @@ get_sort_group_operators(Oid argtype,
Oid
oprid(Operator op)
{
- return ((Form_pg_operator) GETSTRUCT(op))->oid;
+ return (GETSTRUCT(pg_operator, op))->oid;
}
/* given operator tuple, return the underlying function's OID */
Oid
oprfuncid(Operator op)
{
- Form_pg_operator pgopform = (Form_pg_operator) GETSTRUCT(op);
+ Form_pg_operator pgopform = GETSTRUCT(pg_operator, op);
return pgopform->oprcode;
}
@@ -471,7 +471,7 @@ compatible_oper(ParseState *pstate, List *op, Oid arg1, Oid arg2,
return (Operator) NULL; /* must be noError case */
/* but is it good enough? */
- opform = (Form_pg_operator) GETSTRUCT(optup);
+ opform = GETSTRUCT(pg_operator, optup);
if (IsBinaryCoercible(arg1, opform->oprleft) &&
IsBinaryCoercible(arg2, opform->oprright))
return optup;
@@ -705,7 +705,7 @@ make_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree,
tup = oper(pstate, opname, ltypeId, rtypeId, false, location);
}
- opform = (Form_pg_operator) GETSTRUCT(tup);
+ opform = GETSTRUCT(pg_operator, tup);
/* Check it's not a shell */
if (!RegProcedureIsValid(opform->oprcode))
@@ -819,7 +819,7 @@ make_scalar_array_op(ParseState *pstate, List *opname,
/* Now resolve the operator */
tup = oper(pstate, opname, ltypeId, rtypeId, false, location);
- opform = (Form_pg_operator) GETSTRUCT(tup);
+ opform = GETSTRUCT(pg_operator, tup);
/* Check it's not a shell */
if (!RegProcedureIsValid(opform->oprcode))
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 926dcbf30e..84d7e05fa5 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -3243,7 +3243,7 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, rte->relid);
- att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ att_tup = GETSTRUCT(pg_attribute, tp);
result = att_tup->attisdropped;
ReleaseSysCache(tp);
}
diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c
index f7ad689459..65f0ab1489 100644
--- a/src/backend/parser/parse_type.c
+++ b/src/backend/parser/parse_type.c
@@ -247,7 +247,7 @@ LookupTypeNameOid(ParseState *pstate, const TypeName *typeName, bool missing_ok)
return InvalidOid;
}
- typoid = ((Form_pg_type) GETSTRUCT(tup))->oid;
+ typoid = (GETSTRUCT(pg_type, tup))->oid;
ReleaseSysCache(tup);
return typoid;
@@ -272,7 +272,7 @@ typenameType(ParseState *pstate, const TypeName *typeName, int32 *typmod_p)
errmsg("type \"%s\" does not exist",
TypeNameToString(typeName)),
parser_errposition(pstate, typeName->location)));
- if (!((Form_pg_type) GETSTRUCT(tup))->typisdefined)
+ if (!(GETSTRUCT(pg_type, tup))->typisdefined)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type \"%s\" is only a shell",
@@ -294,7 +294,7 @@ typenameTypeId(ParseState *pstate, const TypeName *typeName)
Type tup;
tup = typenameType(pstate, typeName, NULL);
- typoid = ((Form_pg_type) GETSTRUCT(tup))->oid;
+ typoid = (GETSTRUCT(pg_type, tup))->oid;
ReleaseSysCache(tup);
return typoid;
@@ -313,7 +313,7 @@ typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName,
Type tup;
tup = typenameType(pstate, typeName, typmod_p);
- *typeid_p = ((Form_pg_type) GETSTRUCT(tup))->oid;
+ *typeid_p = (GETSTRUCT(pg_type, tup))->oid;
ReleaseSysCache(tup);
}
@@ -348,14 +348,14 @@ typenameTypeMod(ParseState *pstate, const TypeName *typeName, Type typ)
* for the shell-type case, since a shell couldn't possibly have a
* typmodin function.
*/
- if (!((Form_pg_type) GETSTRUCT(typ))->typisdefined)
+ if (!(GETSTRUCT(pg_type, typ))->typisdefined)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("type modifier cannot be specified for shell type \"%s\"",
TypeNameToString(typeName)),
parser_errposition(pstate, typeName->location)));
- typmodin = ((Form_pg_type) GETSTRUCT(typ))->typmodin;
+ typmodin = (GETSTRUCT(pg_type, typ))->typmodin;
if (typmodin == InvalidOid)
ereport(ERROR,
@@ -591,7 +591,7 @@ typeTypeId(Type tp)
{
if (tp == NULL) /* probably useless */
elog(ERROR, "typeTypeId() called with NULL type struct");
- return ((Form_pg_type) GETSTRUCT(tp))->oid;
+ return (GETSTRUCT(pg_type, tp))->oid;
}
/* given type (as type struct), return the length of type */
@@ -600,7 +600,7 @@ typeLen(Type t)
{
Form_pg_type typ;
- typ = (Form_pg_type) GETSTRUCT(t);
+ typ = GETSTRUCT(pg_type, t);
return typ->typlen;
}
@@ -610,7 +610,7 @@ typeByVal(Type t)
{
Form_pg_type typ;
- typ = (Form_pg_type) GETSTRUCT(t);
+ typ = GETSTRUCT(pg_type, t);
return typ->typbyval;
}
@@ -620,7 +620,7 @@ typeTypeName(Type t)
{
Form_pg_type typ;
- typ = (Form_pg_type) GETSTRUCT(t);
+ typ = GETSTRUCT(pg_type, t);
/* pstrdup here because result may need to outlive the syscache entry */
return pstrdup(NameStr(typ->typname));
}
@@ -631,7 +631,7 @@ typeTypeRelid(Type typ)
{
Form_pg_type typtup;
- typtup = (Form_pg_type) GETSTRUCT(typ);
+ typtup = GETSTRUCT(pg_type, typ);
return typtup->typrelid;
}
@@ -641,7 +641,7 @@ typeTypeCollation(Type typ)
{
Form_pg_type typtup;
- typtup = (Form_pg_type) GETSTRUCT(typ);
+ typtup = GETSTRUCT(pg_type, typ);
return typtup->typcollation;
}
@@ -653,7 +653,7 @@ typeTypeCollation(Type typ)
Datum
stringTypeDatum(Type tp, char *string, int32 atttypmod)
{
- Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typform = GETSTRUCT(pg_type, tp);
Oid typinput = typform->typinput;
Oid typioparam = getTypeIOParam(tp);
@@ -674,7 +674,7 @@ typeidTypeRelid(Oid type_id)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_id));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type_id);
- type = (Form_pg_type) GETSTRUCT(typeTuple);
+ type = GETSTRUCT(pg_type, typeTuple);
result = type->typrelid;
ReleaseSysCache(typeTuple);
return result;
@@ -697,7 +697,7 @@ typeOrDomainTypeRelid(Oid type_id)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_id));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type_id);
- type = (Form_pg_type) GETSTRUCT(typeTuple);
+ type = GETSTRUCT(pg_type, typeTuple);
if (type->typtype != TYPTYPE_DOMAIN)
{
/* Not a domain, so done looking through domains */
@@ -797,7 +797,7 @@ parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p, bool missing_ok
}
else
{
- Form_pg_type typ = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typ = GETSTRUCT(pg_type, tup);
if (!typ->typisdefined)
ereport(ERROR,
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index b57253463b..417a571529 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -693,7 +693,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
errmsg("identity columns are not supported on partitions")));
ctype = typenameType(cxt->pstate, column->typeName, NULL);
- typeOid = ((Form_pg_type) GETSTRUCT(ctype))->oid;
+ typeOid = (GETSTRUCT(pg_type, ctype))->oid;
ReleaseSysCache(ctype);
if (saw_identity)
@@ -1457,7 +1457,7 @@ transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
tuple = typenameType(NULL, ofTypename, NULL);
check_of_type(tuple);
- ofTypeId = ((Form_pg_type) GETSTRUCT(tuple))->oid;
+ ofTypeId = (GETSTRUCT(pg_type, tuple))->oid;
ofTypename->typeOid = ofTypeId; /* cached for later */
tupdesc = lookup_rowtype_tupdesc(ofTypeId, -1);
@@ -1541,11 +1541,11 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(source_relid));
if (!HeapTupleIsValid(ht_idxrel))
elog(ERROR, "cache lookup failed for relation %u", source_relid);
- idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);
+ idxrelrec = GETSTRUCT(pg_class, ht_idxrel);
/* Fetch pg_index tuple for source index from relcache entry */
ht_idx = source_idx->rd_indextuple;
- idxrec = (Form_pg_index) GETSTRUCT(ht_idx);
+ idxrec = GETSTRUCT(pg_index, ht_idx);
indrelid = idxrec->indrelid;
/* Fetch the pg_am tuple of the index' access method */
@@ -1553,7 +1553,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
if (!HeapTupleIsValid(ht_am))
elog(ERROR, "cache lookup failed for access method %u",
idxrelrec->relam);
- amrec = (Form_pg_am) GETSTRUCT(ht_am);
+ amrec = GETSTRUCT(pg_am, ht_am);
/* Extract indcollation from the pg_index tuple */
datum = SysCacheGetAttr(INDEXRELID, ht_idx,
@@ -1620,7 +1620,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
if (!HeapTupleIsValid(ht_constr))
elog(ERROR, "cache lookup failed for constraint %u",
constraintId);
- conrec = (Form_pg_constraint) GETSTRUCT(ht_constr);
+ conrec = GETSTRUCT(pg_constraint, ht_constr);
index->isconstraint = true;
index->deferrable = conrec->condeferrable;
@@ -1658,7 +1658,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
if (!HeapTupleIsValid(opertup))
elog(ERROR, "cache lookup failed for operator %u",
operid);
- operform = (Form_pg_operator) GETSTRUCT(opertup);
+ operform = GETSTRUCT(pg_operator, opertup);
oprname = pstrdup(NameStr(operform->oprname));
/* For simplicity we always schema-qualify the op name */
nspname = get_namespace_name(operform->oprnamespace);
@@ -1889,7 +1889,7 @@ generateClonedExtStatsStmt(RangeVar *heapRel, Oid heapRelid,
ht_stats = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(source_statsid));
if (!HeapTupleIsValid(ht_stats))
elog(ERROR, "cache lookup failed for statistics object %u", source_statsid);
- statsrec = (Form_pg_statistic_ext) GETSTRUCT(ht_stats);
+ statsrec = GETSTRUCT(pg_statistic_ext, ht_stats);
/* Determine which statistics types exist */
datum = SysCacheGetAttr(STATEXTOID, ht_stats,
@@ -2001,7 +2001,7 @@ get_collation(Oid collation, Oid actual_datatype)
ht_coll = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation));
if (!HeapTupleIsValid(ht_coll))
elog(ERROR, "cache lookup failed for collation %u", collation);
- coll_rec = (Form_pg_collation) GETSTRUCT(ht_coll);
+ coll_rec = GETSTRUCT(pg_collation, ht_coll);
/* For simplicity, we always schema-qualify the name */
nsp_name = get_namespace_name(coll_rec->collnamespace);
@@ -2028,7 +2028,7 @@ get_opclass(Oid opclass, Oid actual_datatype)
ht_opc = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(ht_opc))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- opc_rec = (Form_pg_opclass) GETSTRUCT(ht_opc);
+ opc_rec = GETSTRUCT(pg_opclass, ht_opc);
if (GetDefaultOpClass(actual_datatype, opc_rec->opcmethod) != opclass)
{
@@ -3771,7 +3771,7 @@ transformColumnType(CreateStmtContext *cxt, ColumnDef *column)
if (column->collClause)
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(ctype);
+ Form_pg_type typtup = GETSTRUCT(pg_type, ctype);
LookupCollation(cxt->pstate,
column->collClause->collname,
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 2e146aac93..a3ffd2947b 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -1910,7 +1910,7 @@ get_database_list(void)
while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
{
- Form_pg_database pgdatabase = (Form_pg_database) GETSTRUCT(tup);
+ Form_pg_database pgdatabase = GETSTRUCT(pg_database, tup);
avw_dbase *avdb;
MemoryContext oldcxt;
@@ -1997,7 +1997,7 @@ do_autovacuum(void)
tuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
- dbForm = (Form_pg_database) GETSTRUCT(tuple);
+ dbForm = GETSTRUCT(pg_database, tuple);
if (dbForm->datistemplate || !dbForm->datallowconn)
{
@@ -2055,7 +2055,7 @@ do_autovacuum(void)
*/
while ((tuple = heap_getnext(relScan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classForm = GETSTRUCT(pg_class, tuple);
PgStat_StatTabEntry *tabentry;
AutoVacOpts *relopts;
Oid relid;
@@ -2148,7 +2148,7 @@ do_autovacuum(void)
relScan = table_beginscan_catalog(classRel, 1, &key);
while ((tuple = heap_getnext(relScan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classForm = GETSTRUCT(pg_class, tuple);
PgStat_StatTabEntry *tabentry;
Oid relid;
AutoVacOpts *relopts = NULL;
@@ -2235,7 +2235,7 @@ do_autovacuum(void)
UnlockRelationOid(relid, AccessExclusiveLock);
continue;
}
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/*
* Make all the same tests made in the loop above. In event of OID
@@ -2340,7 +2340,7 @@ do_autovacuum(void)
classTup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(classTup))
continue; /* somebody deleted the rel, forget it */
- isshared = ((Form_pg_class) GETSTRUCT(classTup))->relisshared;
+ isshared = (GETSTRUCT(pg_class, classTup))->relisshared;
ReleaseSysCache(classTup);
/*
@@ -2726,9 +2726,9 @@ extract_autovac_opts(HeapTuple tup, TupleDesc pg_class_desc)
bytea *relopts;
AutoVacOpts *av;
- Assert(((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_RELATION ||
- ((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_MATVIEW ||
- ((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_TOASTVALUE);
+ Assert((GETSTRUCT(pg_class, tup))->relkind == RELKIND_RELATION ||
+ (GETSTRUCT(pg_class, tup))->relkind == RELKIND_MATVIEW ||
+ (GETSTRUCT(pg_class, tup))->relkind == RELKIND_TOASTVALUE);
relopts = extractRelOptions(tup, pg_class_desc, NULL);
if (relopts == NULL)
@@ -2767,7 +2767,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(classTup))
return NULL;
- classForm = (Form_pg_class) GETSTRUCT(classTup);
+ classForm = GETSTRUCT(pg_class, classTup);
/*
* Get the applicable reloptions. If it is a TOAST table, try to get the
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index 2bdab53e19..8f8d61d682 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -114,7 +114,7 @@ get_subscription_list(void)
while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
{
- Form_pg_subscription subform = (Form_pg_subscription) GETSTRUCT(tup);
+ Form_pg_subscription subform = GETSTRUCT(pg_subscription, tup);
Subscription *sub;
MemoryContext oldcxt;
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index 21937ab2d3..bcc8ce4451 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -218,7 +218,7 @@ replorigin_by_name(const char *roname, bool missing_ok)
tuple = SearchSysCache1(REPLORIGNAME, roname_d);
if (HeapTupleIsValid(tuple))
{
- ident = (Form_pg_replication_origin) GETSTRUCT(tuple);
+ ident = GETSTRUCT(pg_replication_origin, tuple);
roident = ident->roident;
ReleaseSysCache(tuple);
}
@@ -460,7 +460,7 @@ replorigin_by_oid(RepOriginId roident, bool missing_ok, char **roname)
if (HeapTupleIsValid(tuple))
{
- ric = (Form_pg_replication_origin) GETSTRUCT(tuple);
+ ric = GETSTRUCT(pg_replication_origin, tuple);
*roname = text_to_cstring(&ric->roname);
ReleaseSysCache(tuple);
diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c
index ff8513e2d2..01f38d1b28 100644
--- a/src/backend/replication/logical/proto.c
+++ b/src/backend/replication/logical/proto.c
@@ -736,7 +736,7 @@ logicalrep_write_typ(StringInfo out, TransactionId xid, Oid typoid)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(basetypoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", basetypoid);
- typtup = (Form_pg_type) GETSTRUCT(tup);
+ typtup = GETSTRUCT(pg_type, tup);
/* use Oid as relation identifier */
pq_sendint32(out, typoid);
@@ -827,7 +827,7 @@ logicalrep_write_tuple(StringInfo out, Relation rel, TupleTableSlot *slot,
typtup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(att->atttypid));
if (!HeapTupleIsValid(typtup))
elog(ERROR, "cache lookup failed for type %u", att->atttypid);
- typclass = (Form_pg_type) GETSTRUCT(typtup);
+ typclass = GETSTRUCT(pg_type, typtup);
/*
* Send in binary if requested and type has suitable send function.
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 38e3b1c1b3..591d625c24 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -3939,7 +3939,7 @@ clear_subscription_skip_lsn(XLogRecPtr finish_lsn)
if (!HeapTupleIsValid(tup))
elog(ERROR, "subscription \"%s\" does not exist", MySubscription->name);
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = GETSTRUCT(pg_subscription, tup);
/*
* Clear the subskiplsn. If the user has already changed subskiplsn before
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index 185bf5fbff..75c7785044 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -128,7 +128,7 @@ InsertRule(const char *rulname,
ReleaseSysCache(oldtup);
- rewriteObjectId = ((Form_pg_rewrite) GETSTRUCT(tup))->oid;
+ rewriteObjectId = (GETSTRUCT(pg_rewrite, tup))->oid;
is_update = true;
}
else
@@ -627,7 +627,7 @@ DefineQueryRewrite(const char *rulename,
classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(event_relid));
if (!HeapTupleIsValid(classTup))
elog(ERROR, "cache lookup failed for relation %u", event_relid);
- classForm = (Form_pg_class) GETSTRUCT(classTup);
+ classForm = GETSTRUCT(pg_class, classTup);
classForm->relam = InvalidOid;
classForm->reltablespace = InvalidOid;
@@ -877,7 +877,7 @@ EnableDisableRule(Relation rel, const char *rulename,
errmsg("rule \"%s\" for relation \"%s\" does not exist",
rulename, get_rel_name(owningRel))));
- ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup);
+ ruleform = GETSTRUCT(pg_rewrite, ruletup);
/*
* Verify that the user has appropriate permissions.
@@ -928,7 +928,7 @@ RangeVarCallbackForRenameRule(const RangeVar *rv, Oid relid, Oid oldrelid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped */
- form = (Form_pg_class) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_class, tuple);
/* only tables and views can have rules */
if (form->relkind != RELKIND_RELATION &&
@@ -991,7 +991,7 @@ RenameRewriteRule(RangeVar *relation, const char *oldName,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("rule \"%s\" for relation \"%s\" does not exist",
oldName, RelationGetRelationName(targetrel))));
- ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup);
+ ruleform = GETSTRUCT(pg_rewrite, ruletup);
ruleOid = ruleform->oid;
/* rule with the new name should not already exist */
diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c
index 2b51683f6d..ad845f4124 100644
--- a/src/backend/rewrite/rewriteRemove.c
+++ b/src/backend/rewrite/rewriteRemove.c
@@ -71,7 +71,7 @@ RemoveRewriteRuleById(Oid ruleOid)
* going on that might depend on this rule. (Note: a weaker lock would
* suffice if it's not an ON SELECT rule.)
*/
- eventRelationOid = ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class;
+ eventRelationOid = (GETSTRUCT(pg_rewrite, tuple))->ev_class;
event_relation = table_open(eventRelationOid, AccessExclusiveLock);
if (!allowSystemTableMods && IsSystemRelation(event_relation))
diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c
index 80e2509450..bb8c6c1fbd 100644
--- a/src/backend/rewrite/rewriteSupport.c
+++ b/src/backend/rewrite/rewriteSupport.c
@@ -64,7 +64,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules)
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationId);
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
if (classForm->relhasrules != relHasRules)
{
@@ -109,7 +109,7 @@ get_rewrite_oid(Oid relid, const char *rulename, bool missing_ok)
errmsg("rule \"%s\" for relation \"%s\" does not exist",
rulename, get_rel_name(relid))));
}
- ruleform = (Form_pg_rewrite) GETSTRUCT(tuple);
+ ruleform = GETSTRUCT(pg_rewrite, tuple);
Assert(relid == ruleform->ev_class);
ruleoid = ruleform->oid;
ReleaseSysCache(tuple);
diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index 7c02fb279f..609622bbb6 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -453,7 +453,7 @@ fetch_statentries_for_relation(Relation pg_statext, Oid relid)
List *exprs = NIL;
entry = palloc0(sizeof(StatExtEntry));
- staForm = (Form_pg_statistic_ext) GETSTRUCT(htup);
+ staForm = GETSTRUCT(pg_statistic_ext, htup);
entry->statOid = staForm->oid;
entry->schema = get_namespace_name(staForm->stxnamespace);
entry->name = pstrdup(NameStr(staForm->stxname));
@@ -561,7 +561,7 @@ examine_attribute(Node *expr)
ObjectIdGetDatum(stats->attrtypid));
if (!HeapTupleIsValid(typtuple))
elog(ERROR, "cache lookup failed for type %u", stats->attrtypid);
- stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple);
+ stats->attrtype = GETSTRUCT(pg_type, typtuple);
/*
* We don't actually analyze individual attributes, so no need to set the
@@ -663,7 +663,7 @@ examine_expression(Node *expr, int stattarget)
if (!HeapTupleIsValid(typtuple))
elog(ERROR, "cache lookup failed for type %u", stats->attrtypid);
- stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple);
+ stats->attrtype = GETSTRUCT(pg_type, typtuple);
stats->anl_context = CurrentMemoryContext; /* XXX should be using
* something else? */
stats->tupattnum = InvalidAttrNumber;
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
index d204482a61..e63c78c20c 100644
--- a/src/backend/storage/large_object/inv_api.c
+++ b/src/backend/storage/large_object/inv_api.c
@@ -412,7 +412,7 @@ inv_getsize(LargeObjectDesc *obj_desc)
if (HeapTupleHasNulls(tuple)) /* paranoia */
elog(ERROR, "null field found in pg_largeobject");
- data = (Form_pg_largeobject) GETSTRUCT(tuple);
+ data = GETSTRUCT(pg_largeobject, tuple);
getdatafield(data, &datafield, &len, &pfreeit);
lastbyte = (uint64) data->pageno * LOBLKSIZE + len;
if (pfreeit)
@@ -534,7 +534,7 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
if (HeapTupleHasNulls(tuple)) /* paranoia */
elog(ERROR, "null field found in pg_largeobject");
- data = (Form_pg_largeobject) GETSTRUCT(tuple);
+ data = GETSTRUCT(pg_largeobject, tuple);
/*
* We expect the indexscan will deliver pages in order. However,
@@ -662,7 +662,7 @@ inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes)
{
if (HeapTupleHasNulls(oldtuple)) /* paranoia */
elog(ERROR, "null field found in pg_largeobject");
- olddata = (Form_pg_largeobject) GETSTRUCT(oldtuple);
+ olddata = GETSTRUCT(pg_largeobject, oldtuple);
Assert(olddata->pageno >= pageno);
}
neednextpage = false;
@@ -848,7 +848,7 @@ inv_truncate(LargeObjectDesc *obj_desc, int64 len)
{
if (HeapTupleHasNulls(oldtuple)) /* paranoia */
elog(ERROR, "null field found in pg_largeobject");
- olddata = (Form_pg_largeobject) GETSTRUCT(oldtuple);
+ olddata = GETSTRUCT(pg_largeobject, oldtuple);
Assert(olddata->pageno >= pageno);
}
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index d429aa4663..2311f1ad05 100644
--- a/src/backend/tcop/fastpath.c
+++ b/src/backend/tcop/fastpath.c
@@ -139,7 +139,7 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function with OID %u does not exist", func_id)));
- pp = (Form_pg_proc) GETSTRUCT(func_htp);
+ pp = GETSTRUCT(pg_proc, func_htp);
/* reject pg_proc entries that are unsafe to call via fastpath */
if (pp->prokind != PROKIND_FUNCTION || pp->proretset)
diff --git a/src/backend/tsearch/ts_selfuncs.c b/src/backend/tsearch/ts_selfuncs.c
index 8f2679f57e..69dcf0f327 100644
--- a/src/backend/tsearch/ts_selfuncs.c
+++ b/src/backend/tsearch/ts_selfuncs.c
@@ -165,7 +165,7 @@ tsquerysel(VariableStatData *vardata, Datum constval)
Form_pg_statistic stats;
AttStatsSlot sslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
/* MCELEM will be an array of TEXT elements for a tsvector column */
if (get_attstatsslot(&sslot, vardata->statsTuple,
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c
index b7fd3bcf05..6ee7101357 100644
--- a/src/backend/utils/adt/acl.c
+++ b/src/backend/utils/adt/acl.c
@@ -603,7 +603,7 @@ aclitemout(PG_FUNCTION_ARGS)
htup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(aip->ai_grantee));
if (HeapTupleIsValid(htup))
{
- putid(p, NameStr(((Form_pg_authid) GETSTRUCT(htup))->rolname));
+ putid(p, NameStr((GETSTRUCT(pg_authid, htup))->rolname));
ReleaseSysCache(htup);
}
else
@@ -631,7 +631,7 @@ aclitemout(PG_FUNCTION_ARGS)
htup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(aip->ai_grantor));
if (HeapTupleIsValid(htup))
{
- putid(p, NameStr(((Form_pg_authid) GETSTRUCT(htup))->rolname));
+ putid(p, NameStr((GETSTRUCT(pg_authid, htup))->rolname));
ReleaseSysCache(htup);
}
else
@@ -2818,7 +2818,7 @@ convert_column_name(Oid tableoid, text *column)
{
Form_pg_attribute attributeForm;
- attributeForm = (Form_pg_attribute) GETSTRUCT(attTuple);
+ attributeForm = GETSTRUCT(pg_attribute, attTuple);
/* We want to return NULL for dropped columns */
if (attributeForm->attisdropped)
attnum = InvalidAttrNumber;
@@ -4782,7 +4782,7 @@ has_rolinherit(Oid roleid)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolinherit;
+ result = (GETSTRUCT(pg_authid, utup))->rolinherit;
ReleaseSysCache(utup);
}
return result;
@@ -4835,7 +4835,7 @@ roles_is_member_of(Oid roleid, enum RoleRecurseType type,
dbtup = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
if (!HeapTupleIsValid(dbtup))
elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
- dba = ((Form_pg_database) GETSTRUCT(dbtup))->datdba;
+ dba = (GETSTRUCT(pg_database, dbtup))->datdba;
ReleaseSysCache(dbtup);
}
@@ -4867,14 +4867,14 @@ roles_is_member_of(Oid roleid, enum RoleRecurseType type,
for (i = 0; i < memlist->n_members; i++)
{
HeapTuple tup = &memlist->members[i]->tuple;
- Oid otherid = ((Form_pg_auth_members) GETSTRUCT(tup))->roleid;
+ Oid otherid = (GETSTRUCT(pg_auth_members, tup))->roleid;
/*
* While otherid==InvalidOid shouldn't appear in the catalog, the
* OidIsValid() avoids crashing if that arises.
*/
if (otherid == admin_of &&
- ((Form_pg_auth_members) GETSTRUCT(tup))->admin_option &&
+ (GETSTRUCT(pg_auth_members, tup))->admin_option &&
OidIsValid(admin_of))
*is_admin = true;
@@ -5274,7 +5274,7 @@ get_rolespec_name(const RoleSpec *role)
char *rolename;
tp = get_rolespec_tuple(role);
- authForm = (Form_pg_authid) GETSTRUCT(tp);
+ authForm = GETSTRUCT(pg_authid, tp);
rolename = pstrdup(NameStr(authForm->rolname));
ReleaseSysCache(tp);
diff --git a/src/backend/utils/adt/amutils.c b/src/backend/utils/adt/amutils.c
index 9d78a90d69..f04ed870fe 100644
--- a/src/backend/utils/adt/amutils.c
+++ b/src/backend/utils/adt/amutils.c
@@ -174,7 +174,7 @@ indexam_property(FunctionCallInfo fcinfo,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(index_oid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- rd_rel = (Form_pg_class) GETSTRUCT(tuple);
+ rd_rel = GETSTRUCT(pg_class, tuple);
if (rd_rel->relkind != RELKIND_INDEX &&
rd_rel->relkind != RELKIND_PARTITIONED_INDEX)
{
@@ -229,7 +229,7 @@ indexam_property(FunctionCallInfo fcinfo,
tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
Assert(index_oid == rd_index->indexrelid);
Assert(attno > 0 && attno <= rd_index->indnatts);
diff --git a/src/backend/utils/adt/array_selfuncs.c b/src/backend/utils/adt/array_selfuncs.c
index 8cbee1406b..9bac8771c1 100644
--- a/src/backend/utils/adt/array_selfuncs.c
+++ b/src/backend/utils/adt/array_selfuncs.c
@@ -139,7 +139,7 @@ scalararraysel_containment(PlannerInfo *root,
AttStatsSlot sslot;
AttStatsSlot hslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
/* MCELEM will be an array of same type as element */
if (get_attstatsslot(&sslot, vardata.statsTuple,
@@ -362,7 +362,7 @@ calc_arraycontsel(VariableStatData *vardata, Datum constval,
AttStatsSlot sslot;
AttStatsSlot hslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
/* MCELEM will be an array of same type as column */
if (get_attstatsslot(&sslot, vardata->statsTuple,
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c
index 34efa121b4..403cbd0b13 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -857,7 +857,7 @@ pg_relation_filenode(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- relform = (Form_pg_class) GETSTRUCT(tuple);
+ relform = GETSTRUCT(pg_class, tuple);
if (RELKIND_HAS_STORAGE(relform->relkind))
{
@@ -931,7 +931,7 @@ pg_relation_filepath(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- relform = (Form_pg_class) GETSTRUCT(tuple);
+ relform = GETSTRUCT(pg_class, tuple);
if (RELKIND_HAS_STORAGE(relform->relkind))
{
diff --git a/src/backend/utils/adt/domains.c b/src/backend/utils/adt/domains.c
index 3de0cb01a2..3d17b1de79 100644
--- a/src/backend/utils/adt/domains.c
+++ b/src/backend/utils/adt/domains.c
@@ -365,7 +365,7 @@ errdatatype(Oid datatypeOid)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(datatypeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", datatypeOid);
- typtup = (Form_pg_type) GETSTRUCT(tup);
+ typtup = GETSTRUCT(pg_type, tup);
err_generic_string(PG_DIAG_SCHEMA_NAME,
get_namespace_name(typtup->typnamespace));
diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c
index 0cc7a6d8ad..bb24bd13fa 100644
--- a/src/backend/utils/adt/enum.c
+++ b/src/backend/utils/adt/enum.c
@@ -63,7 +63,7 @@ static void
check_safe_enum_use(HeapTuple enumval_tup)
{
TransactionId xmin;
- Form_pg_enum en = (Form_pg_enum) GETSTRUCT(enumval_tup);
+ Form_pg_enum en = GETSTRUCT(pg_enum, enumval_tup);
/*
* If the row is hinted as committed, it's surely safe. This provides a
@@ -138,7 +138,7 @@ enum_in(PG_FUNCTION_ARGS)
* This comes from pg_enum.oid and stores system oids in user tables. This
* oid must be preserved by binary upgrades.
*/
- enumoid = ((Form_pg_enum) GETSTRUCT(tup))->oid;
+ enumoid = (GETSTRUCT(pg_enum, tup))->oid;
ReleaseSysCache(tup);
@@ -159,7 +159,7 @@ enum_out(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid internal value for enum: %u",
enumval)));
- en = (Form_pg_enum) GETSTRUCT(tup);
+ en = GETSTRUCT(pg_enum, tup);
result = pstrdup(NameStr(en->enumlabel));
@@ -202,7 +202,7 @@ enum_recv(PG_FUNCTION_ARGS)
/* check it's safe to use in SQL */
check_safe_enum_use(tup);
- enumoid = ((Form_pg_enum) GETSTRUCT(tup))->oid;
+ enumoid = (GETSTRUCT(pg_enum, tup))->oid;
ReleaseSysCache(tup);
@@ -225,7 +225,7 @@ enum_send(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid internal value for enum: %u",
enumval)));
- en = (Form_pg_enum) GETSTRUCT(tup);
+ en = GETSTRUCT(pg_enum, tup);
pq_begintypsend(&buf);
pq_sendtext(&buf, NameStr(en->enumlabel), strlen(NameStr(en->enumlabel)));
@@ -284,7 +284,7 @@ enum_cmp_internal(Oid arg1, Oid arg2, FunctionCallInfo fcinfo)
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid internal value for enum: %u",
arg1)));
- en = (Form_pg_enum) GETSTRUCT(enum_tup);
+ en = GETSTRUCT(pg_enum, enum_tup);
typeoid = en->enumtypid;
ReleaseSysCache(enum_tup);
/* Now locate and remember the typcache entry */
@@ -412,7 +412,7 @@ enum_endpoint(Oid enumtypoid, ScanDirection direction)
{
/* check it's safe to use in SQL */
check_safe_enum_use(enum_tuple);
- minmax = ((Form_pg_enum) GETSTRUCT(enum_tuple))->oid;
+ minmax = (GETSTRUCT(pg_enum, enum_tuple))->oid;
}
else
{
@@ -572,7 +572,7 @@ enum_range_internal(Oid enumtypoid, Oid lower, Oid upper)
while (HeapTupleIsValid(enum_tuple = systable_getnext_ordered(enum_scan, ForwardScanDirection)))
{
- Oid enum_oid = ((Form_pg_enum) GETSTRUCT(enum_tuple))->oid;
+ Oid enum_oid = (GETSTRUCT(pg_enum, enum_tuple))->oid;
if (!left_found && lower == enum_oid)
left_found = true;
diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c
index 060fd7e183..e2e127ac2c 100644
--- a/src/backend/utils/adt/format_type.c
+++ b/src/backend/utils/adt/format_type.c
@@ -136,7 +136,7 @@ format_type_extended(Oid type_oid, int32 typemod, bits16 flags)
else
elog(ERROR, "cache lookup failed for type %u", type_oid);
}
- typeform = (Form_pg_type) GETSTRUCT(tuple);
+ typeform = GETSTRUCT(pg_type, tuple);
/*
* Check if it's a "true" array type. Pseudo-array types such as "name"
@@ -161,7 +161,7 @@ format_type_extended(Oid type_oid, int32 typemod, bits16 flags)
else
elog(ERROR, "cache lookup failed for type %u", type_oid);
}
- typeform = (Form_pg_type) GETSTRUCT(tuple);
+ typeform = GETSTRUCT(pg_type, tuple);
type_oid = array_base_type;
is_array = true;
}
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index 9819e1a45c..8e70d97c9b 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -2997,7 +2997,7 @@ prepare_column_cache(ColumnIOData *column,
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typid);
- type = (Form_pg_type) GETSTRUCT(tup);
+ type = GETSTRUCT(pg_type, tup);
if (type->typtype == TYPTYPE_DOMAIN)
{
diff --git a/src/backend/utils/adt/like_support.c b/src/backend/utils/adt/like_support.c
index 65a57fc3c4..3884c19aef 100644
--- a/src/backend/utils/adt/like_support.c
+++ b/src/backend/utils/adt/like_support.c
@@ -608,7 +608,7 @@ patternsel_common(PlannerInfo *root,
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
nullfrac = stats->stanullfrac;
}
diff --git a/src/backend/utils/adt/multirangetypes_selfuncs.c b/src/backend/utils/adt/multirangetypes_selfuncs.c
index 919c8889d4..8d2a0977e5 100644
--- a/src/backend/utils/adt/multirangetypes_selfuncs.c
+++ b/src/backend/utils/adt/multirangetypes_selfuncs.c
@@ -306,7 +306,7 @@ calc_multirangesel(TypeCacheEntry *typcache, VariableStatData *vardata,
Form_pg_statistic stats;
AttStatsSlot sslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
null_frac = stats->stanullfrac;
/* Try to get fraction of empty multiranges */
diff --git a/src/backend/utils/adt/network_selfuncs.c b/src/backend/utils/adt/network_selfuncs.c
index 49196376a8..33b45e4d99 100644
--- a/src/backend/utils/adt/network_selfuncs.c
+++ b/src/backend/utils/adt/network_selfuncs.c
@@ -127,7 +127,7 @@ networksel(PG_FUNCTION_ARGS)
PG_RETURN_FLOAT8(DEFAULT_SEL(operator));
}
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
nullfrac = stats->stanullfrac;
/*
@@ -283,7 +283,7 @@ networkjoinsel_inner(Oid operator,
if (HeapTupleIsValid(vardata1->statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(vardata1->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata1->statsTuple);
nullfrac1 = stats->stanullfrac;
mcv1_exists = get_attstatsslot(&mcv1_slot, vardata1->statsTuple,
@@ -305,7 +305,7 @@ networkjoinsel_inner(Oid operator,
if (HeapTupleIsValid(vardata2->statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(vardata2->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata2->statsTuple);
nullfrac2 = stats->stanullfrac;
mcv2_exists = get_attstatsslot(&mcv2_slot, vardata2->statsTuple,
@@ -413,7 +413,7 @@ networkjoinsel_semi(Oid operator,
if (HeapTupleIsValid(vardata1->statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(vardata1->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata1->statsTuple);
nullfrac1 = stats->stanullfrac;
mcv1_exists = get_attstatsslot(&mcv1_slot, vardata1->statsTuple,
@@ -435,7 +435,7 @@ networkjoinsel_semi(Oid operator,
if (HeapTupleIsValid(vardata2->statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(vardata2->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata2->statsTuple);
nullfrac2 = stats->stanullfrac;
mcv2_exists = get_attstatsslot(&mcv2_slot, vardata2->statsTuple,
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index 5cf5dd5f87..42f52fd85f 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -1283,7 +1283,7 @@ lookup_collation_cache(Oid collation, bool set_flags)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collation);
- collform = (Form_pg_collation) GETSTRUCT(tp);
+ collform = GETSTRUCT(pg_collation, tp);
if (collform->collprovider == COLLPROVIDER_LIBC)
{
@@ -1535,7 +1535,7 @@ pg_newlocale_from_collation(Oid collid)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collid);
- collform = (Form_pg_collation) GETSTRUCT(tp);
+ collform = GETSTRUCT(pg_collation, tp);
/* We'll fill in the result struct locally before allocating memory */
memset(&result, 0, sizeof(result));
diff --git a/src/backend/utils/adt/rangetypes_selfuncs.c b/src/backend/utils/adt/rangetypes_selfuncs.c
index c2795f4593..70bdbbdf6c 100644
--- a/src/backend/utils/adt/rangetypes_selfuncs.c
+++ b/src/backend/utils/adt/rangetypes_selfuncs.c
@@ -244,7 +244,7 @@ calc_rangesel(TypeCacheEntry *typcache, VariableStatData *vardata,
Form_pg_statistic stats;
AttStatsSlot sslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
null_frac = stats->stanullfrac;
/* Try to get fraction of empty ranges */
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index 6d4c1c27a5..052374dd23 100644
--- a/src/backend/utils/adt/regproc.c
+++ b/src/backend/utils/adt/regproc.c
@@ -155,7 +155,7 @@ regprocout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(proctup))
{
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, proctup);
char *proname = NameStr(procform->proname);
/*
@@ -356,7 +356,7 @@ format_procedure_extended(Oid procedure_oid, bits16 flags)
if (HeapTupleIsValid(proctup))
{
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, proctup);
char *proname = NameStr(procform->proname);
int nargs = procform->pronargs;
int i;
@@ -436,7 +436,7 @@ format_procedure_parts(Oid procedure_oid, List **objnames, List **objargs,
return;
}
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
nargs = procform->pronargs;
*objnames = list_make2(get_namespace_name_or_temp(procform->pronamespace),
@@ -593,7 +593,7 @@ regoperout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(opertup))
{
- Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operform = GETSTRUCT(pg_operator, opertup);
char *oprname = NameStr(operform->oprname);
/*
@@ -787,7 +787,7 @@ format_operator_extended(Oid operator_oid, bits16 flags)
if (HeapTupleIsValid(opertup))
{
- Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operform = GETSTRUCT(pg_operator, opertup);
char *oprname = NameStr(operform->oprname);
char *nspname;
StringInfoData buf;
@@ -877,7 +877,7 @@ format_operator_parts(Oid operator_oid, List **objnames, List **objargs,
return;
}
- oprForm = (Form_pg_operator) GETSTRUCT(opertup);
+ oprForm = GETSTRUCT(pg_operator, opertup);
*objnames = list_make2(get_namespace_name_or_temp(oprForm->oprnamespace),
pstrdup(NameStr(oprForm->oprname)));
*objargs = NIL;
@@ -1023,7 +1023,7 @@ regclassout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(classtup))
{
- Form_pg_class classform = (Form_pg_class) GETSTRUCT(classtup);
+ Form_pg_class classform = GETSTRUCT(pg_class, classtup);
char *classname = NameStr(classform->relname);
/*
@@ -1174,7 +1174,7 @@ regcollationout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(collationtup))
{
- Form_pg_collation collationform = (Form_pg_collation) GETSTRUCT(collationtup);
+ Form_pg_collation collationform = GETSTRUCT(pg_collation, collationtup);
char *collationname = NameStr(collationform->collname);
/*
@@ -1326,7 +1326,7 @@ regtypeout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(typetup))
{
- Form_pg_type typeform = (Form_pg_type) GETSTRUCT(typetup);
+ Form_pg_type typeform = GETSTRUCT(pg_type, typetup);
/*
* In bootstrap mode, skip the fancy namespace stuff and just return
@@ -1439,7 +1439,7 @@ regconfigout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(cfgtup))
{
- Form_pg_ts_config cfgform = (Form_pg_ts_config) GETSTRUCT(cfgtup);
+ Form_pg_ts_config cfgform = GETSTRUCT(pg_ts_config, cfgtup);
char *cfgname = NameStr(cfgform->cfgname);
char *nspname;
@@ -1550,7 +1550,7 @@ regdictionaryout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(dicttup))
{
- Form_pg_ts_dict dictform = (Form_pg_ts_dict) GETSTRUCT(dicttup);
+ Form_pg_ts_dict dictform = GETSTRUCT(pg_ts_dict, dicttup);
char *dictname = NameStr(dictform->dictname);
char *nspname;
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index 51b3fdc9a0..33e9cfa567 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -1945,7 +1945,7 @@ ri_GenerateQualCollation(StringInfo buf, Oid collation)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collation);
- colltup = (Form_pg_collation) GETSTRUCT(tp);
+ colltup = GETSTRUCT(pg_collation, tp);
collname = NameStr(colltup->collname);
/*
@@ -2134,7 +2134,7 @@ ri_LoadConstraintInfo(Oid constraintOid)
tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constraintOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for constraint %u", constraintOid);
- conForm = (Form_pg_constraint) GETSTRUCT(tup);
+ conForm = GETSTRUCT(pg_constraint, tup);
if (conForm->contype != CONSTRAINT_FOREIGN) /* should not happen */
elog(ERROR, "constraint %u is not a foreign key constraint",
@@ -2197,7 +2197,7 @@ get_ri_constraint_root(Oid constrOid)
tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constrOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", constrOid);
- constrParentOid = ((Form_pg_constraint) GETSTRUCT(tuple))->conparentid;
+ constrParentOid = (GETSTRUCT(pg_constraint, tuple))->conparentid;
ReleaseSysCache(tuple);
if (!OidIsValid(constrParentOid))
break; /* we reached the root constraint */
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 26cf4fa9a0..f1b31fc4e7 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -898,7 +898,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
return NULL;
}
- trigrec = (Form_pg_trigger) GETSTRUCT(ht_trig);
+ trigrec = GETSTRUCT(pg_trigger, ht_trig);
/*
* Start the trigger definition. Note that the trigger's name should never
@@ -1253,7 +1253,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
return NULL;
elog(ERROR, "cache lookup failed for index %u", indexrelid);
}
- idxrec = (Form_pg_index) GETSTRUCT(ht_idx);
+ idxrec = GETSTRUCT(pg_index, ht_idx);
indrelid = idxrec->indrelid;
Assert(indexrelid == idxrec->indexrelid);
@@ -1280,7 +1280,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(indexrelid));
if (!HeapTupleIsValid(ht_idxrel))
elog(ERROR, "cache lookup failed for relation %u", indexrelid);
- idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);
+ idxrelrec = GETSTRUCT(pg_class, ht_idxrel);
/*
* Fetch the pg_am tuple of the index' access method
@@ -1289,7 +1289,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
if (!HeapTupleIsValid(ht_am))
elog(ERROR, "cache lookup failed for access method %u",
idxrelrec->relam);
- amrec = (Form_pg_am) GETSTRUCT(ht_am);
+ amrec = GETSTRUCT(pg_am, ht_am);
/* Fetch the index AM's API struct */
amroutine = GetIndexAmRoutine(amrec->amhandler);
@@ -1637,7 +1637,7 @@ pg_get_statisticsobj_worker(Oid statextid, bool columns_only, bool missing_ok)
/* has the statistics expressions? */
has_exprs = !heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL);
- statextrec = (Form_pg_statistic_ext) GETSTRUCT(statexttup);
+ statextrec = GETSTRUCT(pg_statistic_ext, statexttup);
/*
* Get the statistics expressions, if any. (NOTE: we do not use the
@@ -1821,7 +1821,7 @@ pg_get_statisticsobjdef_expressions(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
- statextrec = (Form_pg_statistic_ext) GETSTRUCT(statexttup);
+ statextrec = GETSTRUCT(pg_statistic_ext, statexttup);
/*
* Get the statistics expressions, and deparse them into text values.
@@ -1919,7 +1919,7 @@ pg_get_partkeydef_worker(Oid relid, int prettyFlags,
elog(ERROR, "cache lookup failed for partition key of %u", relid);
}
- form = (Form_pg_partitioned_table) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_partitioned_table, tuple);
Assert(form->partrelid == relid);
@@ -2197,7 +2197,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
elog(ERROR, "could not find tuple for constraint %u", constraintId);
}
- conForm = (Form_pg_constraint) GETSTRUCT(tup);
+ conForm = GETSTRUCT(pg_constraint, tup);
initStringInfo(&buf);
@@ -2371,7 +2371,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
if (!HeapTupleIsValid(indtup))
elog(ERROR, "cache lookup failed for index %u", indexId);
if (conForm->contype == CONSTRAINT_UNIQUE &&
- ((Form_pg_index) GETSTRUCT(indtup))->indnullsnotdistinct)
+ (GETSTRUCT(pg_index, indtup))->indnullsnotdistinct)
appendStringInfoString(&buf, "NULLS NOT DISTINCT ");
appendStringInfoString(&buf, "(");
@@ -2769,7 +2769,7 @@ pg_get_userbyid(PG_FUNCTION_ARGS)
roletup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(roletup))
{
- role_rec = (Form_pg_authid) GETSTRUCT(roletup);
+ role_rec = GETSTRUCT(pg_authid, roletup);
*result = role_rec->rolname;
ReleaseSysCache(roletup);
}
@@ -2837,7 +2837,7 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend deprec = GETSTRUCT(pg_depend, tup);
/*
* Look for an auto dependency (serial column) or internal dependency
@@ -2905,7 +2905,7 @@ pg_get_functiondef(PG_FUNCTION_ARGS)
if (!HeapTupleIsValid(proctup))
PG_RETURN_NULL();
- proc = (Form_pg_proc) GETSTRUCT(proctup);
+ proc = GETSTRUCT(pg_proc, proctup);
name = NameStr(proc->proname);
if (proc->prokind == PROKIND_AGGREGATE)
@@ -3197,7 +3197,7 @@ pg_get_function_result(PG_FUNCTION_ARGS)
if (!HeapTupleIsValid(proctup))
PG_RETURN_NULL();
- if (((Form_pg_proc) GETSTRUCT(proctup))->prokind == PROKIND_PROCEDURE)
+ if ((GETSTRUCT(pg_proc, proctup))->prokind == PROKIND_PROCEDURE)
{
ReleaseSysCache(proctup);
PG_RETURN_NULL();
@@ -3219,7 +3219,7 @@ pg_get_function_result(PG_FUNCTION_ARGS)
static void
print_function_rettype(StringInfo buf, HeapTuple proctup)
{
- Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc proc = GETSTRUCT(pg_proc, proctup);
int ntabargs = 0;
StringInfoData rbuf;
@@ -3258,7 +3258,7 @@ static int
print_function_arguments(StringInfo buf, HeapTuple proctup,
bool print_table_args, bool print_defaults)
{
- Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc proc = GETSTRUCT(pg_proc, proctup);
int numargs;
Oid *argtypes;
char **argnames;
@@ -3306,7 +3306,7 @@ print_function_arguments(StringInfo buf, HeapTuple proctup,
if (!HeapTupleIsValid(aggtup))
elog(ERROR, "cache lookup failed for aggregate %u",
proc->oid);
- agg = (Form_pg_aggregate) GETSTRUCT(aggtup);
+ agg = GETSTRUCT(pg_aggregate, aggtup);
if (AGGKIND_IS_ORDERED_SET(agg->aggkind))
insertorderbyat = agg->aggnumdirectargs;
ReleaseSysCache(aggtup);
@@ -3491,7 +3491,7 @@ pg_get_function_arg_default(PG_FUNCTION_ARGS)
argdefaults = castNode(List, stringToNode(str));
pfree(str);
- proc = (Form_pg_proc) GETSTRUCT(proctup);
+ proc = GETSTRUCT(pg_proc, proctup);
/*
* Calculate index into proargdefaults: proargdefaults corresponds to the
@@ -3524,7 +3524,7 @@ print_function_sqlbody(StringInfo buf, HeapTuple proctup)
bool isnull;
Node *n;
- dpns.funcname = pstrdup(NameStr(((Form_pg_proc) GETSTRUCT(proctup))->proname));
+ dpns.funcname = pstrdup(NameStr((GETSTRUCT(pg_proc, proctup))->proname));
numargs = get_func_arg_info(proctup,
&argtypes, &argnames, &argmodes);
dpns.numargs = numargs;
@@ -12029,7 +12029,7 @@ get_opclass_name(Oid opclass, Oid actual_datatype,
ht_opc = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(ht_opc))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- opcrec = (Form_pg_opclass) GETSTRUCT(ht_opc);
+ opcrec = GETSTRUCT(pg_opclass, ht_opc);
if (!OidIsValid(actual_datatype) ||
GetDefaultOpClass(actual_datatype, opcrec->opcmethod) != opclass)
@@ -12323,7 +12323,7 @@ generate_relation_name(Oid relid, List *namespaces)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltup = (Form_pg_class) GETSTRUCT(tp);
+ reltup = GETSTRUCT(pg_class, tp);
relname = NameStr(reltup->relname);
/* Check for conflicting CTE name */
@@ -12381,7 +12381,7 @@ generate_qualified_relation_name(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltup = (Form_pg_class) GETSTRUCT(tp);
+ reltup = GETSTRUCT(pg_class, tp);
relname = NameStr(reltup->relname);
nspname = get_namespace_name_or_temp(reltup->relnamespace);
@@ -12434,7 +12434,7 @@ generate_function_name(Oid funcid, int nargs, List *argnames, Oid *argtypes,
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
proname = NameStr(procform->proname);
/*
@@ -12531,7 +12531,7 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2)
opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operid));
if (!HeapTupleIsValid(opertup))
elog(ERROR, "cache lookup failed for operator %u", operid);
- operform = (Form_pg_operator) GETSTRUCT(opertup);
+ operform = GETSTRUCT(pg_operator, opertup);
oprname = NameStr(operform->oprname);
/*
@@ -12607,7 +12607,7 @@ generate_operator_clause(StringInfo buf,
opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(opoid));
if (!HeapTupleIsValid(opertup))
elog(ERROR, "cache lookup failed for operator %u", opoid);
- operform = (Form_pg_operator) GETSTRUCT(opertup);
+ operform = GETSTRUCT(pg_operator, opertup);
Assert(operform->oprkind == 'b');
oprname = NameStr(operform->oprname);
@@ -12644,7 +12644,7 @@ add_cast_to(StringInfo buf, Oid typid)
typetup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(typetup))
elog(ERROR, "cache lookup failed for type %u", typid);
- typform = (Form_pg_type) GETSTRUCT(typetup);
+ typform = GETSTRUCT(pg_type, typetup);
typname = NameStr(typform->typname);
nspname = get_namespace_name_or_temp(typform->typnamespace);
@@ -12676,7 +12676,7 @@ generate_qualified_type_name(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", typid);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
typname = NameStr(typtup->typname);
nspname = get_namespace_name_or_temp(typtup->typnamespace);
@@ -12709,7 +12709,7 @@ generate_collation_name(Oid collid)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collid);
- colltup = (Form_pg_collation) GETSTRUCT(tp);
+ colltup = GETSTRUCT(pg_collation, tp);
collname = NameStr(colltup->collname);
if (!CollationIsVisible(collid))
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index fa1f589fad..81eb913317 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -313,7 +313,7 @@ var_eq_const(VariableStatData *vardata, Oid operator, Oid collation,
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
nullfrac = stats->stanullfrac;
}
@@ -475,7 +475,7 @@ var_eq_non_const(VariableStatData *vardata, Oid operator, Oid collation,
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
nullfrac = stats->stanullfrac;
}
@@ -665,7 +665,7 @@ scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, bool iseq,
/* no stats available, so default result */
return DEFAULT_INEQ_SEL;
}
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
fmgr_info(get_opcode(operator), &opproc);
@@ -990,7 +990,7 @@ generic_restriction_selectivity(PlannerInfo *root, Oid oproid, Oid collation,
/* Don't forget to account for nulls. */
if (HeapTupleIsValid(vardata.statsTuple))
- nullfrac = ((Form_pg_statistic) GETSTRUCT(vardata.statsTuple))->stanullfrac;
+ nullfrac = (GETSTRUCT(pg_statistic, vardata.statsTuple))->stanullfrac;
else
nullfrac = 0.0;
@@ -1548,7 +1548,7 @@ booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg,
double freq_null;
AttStatsSlot sslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
freq_null = stats->stanullfrac;
if (get_attstatsslot(&sslot, vardata.statsTuple,
@@ -1705,7 +1705,7 @@ nulltestsel(PlannerInfo *root, NullTestType nulltesttype, Node *arg,
Form_pg_statistic stats;
double freq_null;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
freq_null = stats->stanullfrac;
switch (nulltesttype)
@@ -2277,7 +2277,7 @@ eqjoinsel(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(vardata1.statsTuple))
{
/* note we allow use of nullfrac regardless of security check */
- stats1 = (Form_pg_statistic) GETSTRUCT(vardata1.statsTuple);
+ stats1 = GETSTRUCT(pg_statistic, vardata1.statsTuple);
if (statistic_proc_security_check(&vardata1, opfuncoid))
have_mcvs1 = get_attstatsslot(&sslot1, vardata1.statsTuple,
STATISTIC_KIND_MCV, InvalidOid,
@@ -2287,7 +2287,7 @@ eqjoinsel(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(vardata2.statsTuple))
{
/* note we allow use of nullfrac regardless of security check */
- stats2 = (Form_pg_statistic) GETSTRUCT(vardata2.statsTuple);
+ stats2 = GETSTRUCT(pg_statistic, vardata2.statsTuple);
if (statistic_proc_security_check(&vardata2, opfuncoid))
have_mcvs2 = get_attstatsslot(&sslot2, vardata2.statsTuple,
STATISTIC_KIND_MCV, InvalidOid,
@@ -2804,7 +2804,7 @@ neqjoinsel(PG_FUNCTION_ARGS)
get_join_variables(root, args, sjinfo, &leftvar, &rightvar, &reversed);
statsTuple = reversed ? rightvar.statsTuple : leftvar.statsTuple;
if (HeapTupleIsValid(statsTuple))
- nullfrac = ((Form_pg_statistic) GETSTRUCT(statsTuple))->stanullfrac;
+ nullfrac = (GETSTRUCT(pg_statistic, statsTuple))->stanullfrac;
else
nullfrac = 0.0;
ReleaseVariableStats(leftvar);
@@ -3162,7 +3162,7 @@ mergejoinscansel(PlannerInfo *root, Node *clause,
if (HeapTupleIsValid(leftvar.statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(leftvar.statsTuple);
+ stats = GETSTRUCT(pg_statistic, leftvar.statsTuple);
*leftstart += stats->stanullfrac;
CLAMP_PROBABILITY(*leftstart);
*leftend += stats->stanullfrac;
@@ -3170,7 +3170,7 @@ mergejoinscansel(PlannerInfo *root, Node *clause,
}
if (HeapTupleIsValid(rightvar.statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(rightvar.statsTuple);
+ stats = GETSTRUCT(pg_statistic, rightvar.statsTuple);
*rightstart += stats->stanullfrac;
CLAMP_PROBABILITY(*rightstart);
*rightend += stats->stanullfrac;
@@ -3830,7 +3830,7 @@ estimate_hash_bucket_stats(PlannerInfo *root, Node *hashkey, double nbuckets,
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
stanullfrac = stats->stanullfrac;
}
else
@@ -5672,7 +5672,7 @@ get_variable_numdistinct(VariableStatData *vardata, bool *isdefault)
/* Use the pg_statistic entry */
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
stadistinct = stats->stadistinct;
stanullfrac = stats->stanullfrac;
}
@@ -5889,7 +5889,7 @@ get_variable_range(PlannerInfo *root, VariableStatData *vardata,
for (i = 0; i < sslot.nnumbers; i++)
sumcommon += sslot.numbers[i];
- nullfrac = ((Form_pg_statistic) GETSTRUCT(vardata->statsTuple))->stanullfrac;
+ nullfrac = (GETSTRUCT(pg_statistic, vardata->statsTuple))->stanullfrac;
if (sumcommon + nullfrac > 0.99999)
use_mcvs = true;
}
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index 60a85c4697..0ce9012784 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -3183,7 +3183,7 @@ map_sql_table_to_xmlschema(TupleDesc tupdesc, Oid relid, bool nulls,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltuple = (Form_pg_class) GETSTRUCT(tuple);
+ reltuple = GETSTRUCT(pg_class, tuple);
xmltn = map_sql_identifier_to_xml_name(NameStr(reltuple->relname),
true, false);
@@ -3483,7 +3483,7 @@ map_sql_type_to_xml_name(Oid typeoid, int typmod)
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", typeoid);
- typtuple = (Form_pg_type) GETSTRUCT(tuple);
+ typtuple = GETSTRUCT(pg_type, tuple);
appendStringInfoString(&result,
map_multipart_sql_identifier_to_xml_name((typtuple->typtype == TYPTYPE_DOMAIN) ? "Domain" : "UDT",
diff --git a/src/backend/utils/cache/evtcache.c b/src/backend/utils/cache/evtcache.c
index f7f7165f7f..a6893f9947 100644
--- a/src/backend/utils/cache/evtcache.c
+++ b/src/backend/utils/cache/evtcache.c
@@ -153,7 +153,7 @@ BuildEventTriggerCache(void)
break;
/* Skip trigger if disabled. */
- form = (Form_pg_event_trigger) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_event_trigger, tup);
if (form->evtenabled == TRIGGER_DISABLED)
continue;
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index eb5782f82a..8e100862bf 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -1259,7 +1259,7 @@ CacheInvalidateHeapTuple(Relation relation,
*/
if (tupleRelId == RelationRelationId)
{
- Form_pg_class classtup = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classtup = GETSTRUCT(pg_class, tuple);
relationId = classtup->oid;
if (classtup->relisshared)
@@ -1269,7 +1269,7 @@ CacheInvalidateHeapTuple(Relation relation,
}
else if (tupleRelId == AttributeRelationId)
{
- Form_pg_attribute atttup = (Form_pg_attribute) GETSTRUCT(tuple);
+ Form_pg_attribute atttup = GETSTRUCT(pg_attribute, tuple);
relationId = atttup->attrelid;
@@ -1287,7 +1287,7 @@ CacheInvalidateHeapTuple(Relation relation,
}
else if (tupleRelId == IndexRelationId)
{
- Form_pg_index indextup = (Form_pg_index) GETSTRUCT(tuple);
+ Form_pg_index indextup = GETSTRUCT(pg_index, tuple);
/*
* When a pg_index row is updated, we should send out a relcache inval
@@ -1300,7 +1300,7 @@ CacheInvalidateHeapTuple(Relation relation,
}
else if (tupleRelId == ConstraintRelationId)
{
- Form_pg_constraint constrtup = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint constrtup = GETSTRUCT(pg_constraint, tuple);
/*
* Foreign keys are part of relcache entries, too, so send out an
@@ -1398,7 +1398,7 @@ CacheInvalidateRelcacheAll(void)
void
CacheInvalidateRelcacheByTuple(HeapTuple classTuple)
{
- Form_pg_class classtup = (Form_pg_class) GETSTRUCT(classTuple);
+ Form_pg_class classtup = GETSTRUCT(pg_class, classTuple);
Oid databaseId;
Oid relationId;
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 1b7e11b93e..e189e5e564 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -90,7 +90,7 @@ get_op_opfamily_strategy(Oid opno, Oid opfamily)
ObjectIdGetDatum(opfamily));
if (!HeapTupleIsValid(tp))
return 0;
- amop_tup = (Form_pg_amop) GETSTRUCT(tp);
+ amop_tup = GETSTRUCT(pg_amop, tp);
result = amop_tup->amopstrategy;
ReleaseSysCache(tp);
return result;
@@ -115,7 +115,7 @@ get_op_opfamily_sortfamily(Oid opno, Oid opfamily)
ObjectIdGetDatum(opfamily));
if (!HeapTupleIsValid(tp))
return InvalidOid;
- amop_tup = (Form_pg_amop) GETSTRUCT(tp);
+ amop_tup = GETSTRUCT(pg_amop, tp);
result = amop_tup->amopsortfamily;
ReleaseSysCache(tp);
return result;
@@ -146,7 +146,7 @@ get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op,
if (!HeapTupleIsValid(tp))
elog(ERROR, "operator %u is not a member of opfamily %u",
opno, opfamily);
- amop_tup = (Form_pg_amop) GETSTRUCT(tp);
+ amop_tup = GETSTRUCT(pg_amop, tp);
*strategy = amop_tup->amopstrategy;
*lefttype = amop_tup->amoplefttype;
*righttype = amop_tup->amoprighttype;
@@ -175,7 +175,7 @@ get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
Int16GetDatum(strategy));
if (!HeapTupleIsValid(tp))
return InvalidOid;
- amop_tup = (Form_pg_amop) GETSTRUCT(tp);
+ amop_tup = GETSTRUCT(pg_amop, tp);
result = amop_tup->amopopr;
ReleaseSysCache(tp);
return result;
@@ -223,7 +223,7 @@ get_ordering_op_properties(Oid opno,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
/* must be btree */
if (aform->amopmethod != BTREE_AM_OID)
@@ -315,7 +315,7 @@ get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
/* must be btree */
if (aform->amopmethod != BTREE_AM_OID)
@@ -376,7 +376,7 @@ get_mergejoin_opfamilies(Oid opno)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
/* must be btree equality */
if (aform->amopmethod == BTREE_AM_OID &&
@@ -428,7 +428,7 @@ get_compatible_hash_operators(Oid opno,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
if (aform->amopmethod == HASH_AM_OID &&
aform->amopstrategy == HTEqualStrategyNumber)
@@ -528,7 +528,7 @@ get_op_hash_functions(Oid opno,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
if (aform->amopmethod == HASH_AM_OID &&
aform->amopstrategy == HTEqualStrategyNumber)
@@ -611,7 +611,7 @@ get_op_btree_interpretation(Oid opno)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
- Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple);
StrategyNumber op_strategy;
/* must be btree */
@@ -649,7 +649,7 @@ get_op_btree_interpretation(Oid opno)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
- Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple);
StrategyNumber op_strategy;
/* must be btree */
@@ -712,7 +712,7 @@ equality_ops_are_compatible(Oid opno1, Oid opno2)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
- Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple);
/* must be btree or hash */
if (op_form->amopmethod == BTREE_AM_OID ||
@@ -763,7 +763,7 @@ comparison_ops_are_compatible(Oid opno1, Oid opno2)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
- Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple);
if (op_form->amopmethod == BTREE_AM_OID)
{
@@ -804,7 +804,7 @@ get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
Int16GetDatum(procnum));
if (!HeapTupleIsValid(tp))
return InvalidOid;
- amproc_tup = (Form_pg_amproc) GETSTRUCT(tp);
+ amproc_tup = GETSTRUCT(pg_amproc, tp);
result = amproc_tup->amproc;
ReleaseSysCache(tp);
return result;
@@ -830,7 +830,7 @@ get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
ObjectIdGetDatum(relid), Int16GetDatum(attnum));
if (HeapTupleIsValid(tp))
{
- Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ Form_pg_attribute att_tup = GETSTRUCT(pg_attribute, tp);
char *result;
result = pstrdup(NameStr(att_tup->attname));
@@ -860,7 +860,7 @@ get_attnum(Oid relid, const char *attname)
tp = SearchSysCacheAttName(relid, attname);
if (HeapTupleIsValid(tp))
{
- Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ Form_pg_attribute att_tup = GETSTRUCT(pg_attribute, tp);
AttrNumber result;
result = att_tup->attnum;
@@ -892,7 +892,7 @@ get_attstattarget(Oid relid, AttrNumber attnum)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ att_tup = GETSTRUCT(pg_attribute, tp);
result = att_tup->attstattarget;
ReleaseSysCache(tp);
return result;
@@ -922,7 +922,7 @@ get_attgenerated(Oid relid, AttrNumber attnum)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ att_tup = GETSTRUCT(pg_attribute, tp);
result = att_tup->attgenerated;
ReleaseSysCache(tp);
return result;
@@ -944,7 +944,7 @@ get_atttype(Oid relid, AttrNumber attnum)
Int16GetDatum(attnum));
if (HeapTupleIsValid(tp))
{
- Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ Form_pg_attribute att_tup = GETSTRUCT(pg_attribute, tp);
Oid result;
result = att_tup->atttypid;
@@ -977,7 +977,7 @@ get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ att_tup = GETSTRUCT(pg_attribute, tp);
*typid = att_tup->atttypid;
*typmod = att_tup->atttypmod;
@@ -1064,7 +1064,7 @@ get_collation_name(Oid colloid)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
if (HeapTupleIsValid(tp))
{
- Form_pg_collation colltup = (Form_pg_collation) GETSTRUCT(tp);
+ Form_pg_collation colltup = GETSTRUCT(pg_collation, tp);
char *result;
result = pstrdup(NameStr(colltup->collname));
@@ -1085,7 +1085,7 @@ get_collation_isdeterministic(Oid colloid)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", colloid);
- colltup = (Form_pg_collation) GETSTRUCT(tp);
+ colltup = GETSTRUCT(pg_collation, tp);
result = colltup->collisdeterministic;
ReleaseSysCache(tp);
return result;
@@ -1110,7 +1110,7 @@ get_constraint_name(Oid conoid)
tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
if (HeapTupleIsValid(tp))
{
- Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp);
+ Form_pg_constraint contup = GETSTRUCT(pg_constraint, tp);
char *result;
result = pstrdup(NameStr(contup->conname));
@@ -1142,7 +1142,7 @@ get_constraint_index(Oid conoid)
tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
if (HeapTupleIsValid(tp))
{
- Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp);
+ Form_pg_constraint contup = GETSTRUCT(pg_constraint, tp);
Oid result;
if (contup->contype == CONSTRAINT_UNIQUE ||
@@ -1168,7 +1168,7 @@ get_language_name(Oid langoid, bool missing_ok)
tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
if (HeapTupleIsValid(tp))
{
- Form_pg_language lantup = (Form_pg_language) GETSTRUCT(tp);
+ Form_pg_language lantup = GETSTRUCT(pg_language, tp);
char *result;
result = pstrdup(NameStr(lantup->lanname));
@@ -1199,7 +1199,7 @@ get_opclass_family(Oid opclass)
tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
+ cla_tup = GETSTRUCT(pg_opclass, tp);
result = cla_tup->opcfamily;
ReleaseSysCache(tp);
@@ -1221,7 +1221,7 @@ get_opclass_input_type(Oid opclass)
tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
+ cla_tup = GETSTRUCT(pg_opclass, tp);
result = cla_tup->opcintype;
ReleaseSysCache(tp);
@@ -1244,7 +1244,7 @@ get_opclass_opfamily_and_input_type(Oid opclass, Oid *opfamily, Oid *opcintype)
if (!HeapTupleIsValid(tp))
return false;
- cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
+ cla_tup = GETSTRUCT(pg_opclass, tp);
*opfamily = cla_tup->opcfamily;
*opcintype = cla_tup->opcintype;
@@ -1270,7 +1270,7 @@ get_opcode(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
RegProcedure result;
result = optup->oprcode;
@@ -1295,7 +1295,7 @@ get_opname(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
char *result;
result = pstrdup(NameStr(optup->oprname));
@@ -1318,7 +1318,7 @@ get_op_rettype(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
Oid result;
result = optup->oprresult;
@@ -1344,7 +1344,7 @@ op_input_types(Oid opno, Oid *lefttype, Oid *righttype)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for operator %u", opno);
- optup = (Form_pg_operator) GETSTRUCT(tp);
+ optup = GETSTRUCT(pg_operator, tp);
*lefttype = optup->oprleft;
*righttype = optup->oprright;
ReleaseSysCache(tp);
@@ -1394,7 +1394,7 @@ op_mergejoinable(Oid opno, Oid inputtype)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
result = optup->oprcanmerge;
ReleaseSysCache(tp);
@@ -1440,7 +1440,7 @@ op_hashjoinable(Oid opno, Oid inputtype)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
result = optup->oprcanhash;
ReleaseSysCache(tp);
@@ -1494,7 +1494,7 @@ get_commutator(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
Oid result;
result = optup->oprcom;
@@ -1518,7 +1518,7 @@ get_negator(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
Oid result;
result = optup->oprnegate;
@@ -1542,7 +1542,7 @@ get_oprrest(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
RegProcedure result;
result = optup->oprrest;
@@ -1566,7 +1566,7 @@ get_oprjoin(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
RegProcedure result;
result = optup->oprjoin;
@@ -1593,7 +1593,7 @@ get_func_name(Oid funcid)
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (HeapTupleIsValid(tp))
{
- Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
+ Form_pg_proc functup = GETSTRUCT(pg_proc, tp);
char *result;
result = pstrdup(NameStr(functup->proname));
@@ -1617,7 +1617,7 @@ get_func_namespace(Oid funcid)
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (HeapTupleIsValid(tp))
{
- Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
+ Form_pg_proc functup = GETSTRUCT(pg_proc, tp);
Oid result;
result = functup->pronamespace;
@@ -1642,7 +1642,7 @@ get_func_rettype(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->prorettype;
+ result = (GETSTRUCT(pg_proc, tp))->prorettype;
ReleaseSysCache(tp);
return result;
}
@@ -1661,7 +1661,7 @@ get_func_nargs(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
+ result = (GETSTRUCT(pg_proc, tp))->pronargs;
ReleaseSysCache(tp);
return result;
}
@@ -1684,7 +1684,7 @@ get_func_signature(Oid funcid, Oid **argtypes, int *nargs)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procstruct = (Form_pg_proc) GETSTRUCT(tp);
+ procstruct = GETSTRUCT(pg_proc, tp);
result = procstruct->prorettype;
*nargs = (int) procstruct->pronargs;
@@ -1710,7 +1710,7 @@ get_func_variadictype(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->provariadic;
+ result = (GETSTRUCT(pg_proc, tp))->provariadic;
ReleaseSysCache(tp);
return result;
}
@@ -1729,7 +1729,7 @@ get_func_retset(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
+ result = (GETSTRUCT(pg_proc, tp))->proretset;
ReleaseSysCache(tp);
return result;
}
@@ -1748,7 +1748,7 @@ func_strict(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
+ result = (GETSTRUCT(pg_proc, tp))->proisstrict;
ReleaseSysCache(tp);
return result;
}
@@ -1767,7 +1767,7 @@ func_volatile(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->provolatile;
+ result = (GETSTRUCT(pg_proc, tp))->provolatile;
ReleaseSysCache(tp);
return result;
}
@@ -1786,7 +1786,7 @@ func_parallel(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
+ result = (GETSTRUCT(pg_proc, tp))->proparallel;
ReleaseSysCache(tp);
return result;
}
@@ -1805,7 +1805,7 @@ get_func_prokind(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->prokind;
+ result = (GETSTRUCT(pg_proc, tp))->prokind;
ReleaseSysCache(tp);
return result;
}
@@ -1824,7 +1824,7 @@ get_func_leakproof(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
+ result = (GETSTRUCT(pg_proc, tp))->proleakproof;
ReleaseSysCache(tp);
return result;
}
@@ -1843,7 +1843,7 @@ get_func_support(Oid funcid)
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (HeapTupleIsValid(tp))
{
- Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
+ Form_pg_proc functup = GETSTRUCT(pg_proc, tp);
RegProcedure result;
result = functup->prosupport;
@@ -1884,7 +1884,7 @@ get_relnatts(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
int result;
result = reltup->relnatts;
@@ -1913,7 +1913,7 @@ get_rel_name(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
char *result;
result = pstrdup(NameStr(reltup->relname));
@@ -1937,7 +1937,7 @@ get_rel_namespace(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
Oid result;
result = reltup->relnamespace;
@@ -1964,7 +1964,7 @@ get_rel_type_id(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
Oid result;
result = reltup->reltype;
@@ -1988,7 +1988,7 @@ get_rel_relkind(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
char result;
result = reltup->relkind;
@@ -2012,7 +2012,7 @@ get_rel_relispartition(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
bool result;
result = reltup->relispartition;
@@ -2039,7 +2039,7 @@ get_rel_tablespace(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
Oid result;
result = reltup->reltablespace;
@@ -2065,7 +2065,7 @@ get_rel_persistence(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltup = (Form_pg_class) GETSTRUCT(tp);
+ reltup = GETSTRUCT(pg_class, tp);
result = reltup->relpersistence;
ReleaseSysCache(tp);
@@ -2088,7 +2088,7 @@ get_transform_fromsql(Oid typid, Oid langid, List *trftypes)
{
Oid funcid;
- funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
+ funcid = (GETSTRUCT(pg_transform, tup))->trffromsql;
ReleaseSysCache(tup);
return funcid;
}
@@ -2109,7 +2109,7 @@ get_transform_tosql(Oid typid, Oid langid, List *trftypes)
{
Oid funcid;
- funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
+ funcid = (GETSTRUCT(pg_transform, tup))->trftosql;
ReleaseSysCache(tup);
return funcid;
}
@@ -2134,7 +2134,7 @@ get_typisdefined(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
bool result;
result = typtup->typisdefined;
@@ -2158,7 +2158,7 @@ get_typlen(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
int16 result;
result = typtup->typlen;
@@ -2183,7 +2183,7 @@ get_typbyval(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
bool result;
result = typtup->typbyval;
@@ -2213,7 +2213,7 @@ get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", typid);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
*typlen = typtup->typlen;
*typbyval = typtup->typbyval;
ReleaseSysCache(tp);
@@ -2234,7 +2234,7 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", typid);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
*typlen = typtup->typlen;
*typbyval = typtup->typbyval;
*typalign = typtup->typalign;
@@ -2259,7 +2259,7 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
Oid
getTypeIOParam(HeapTuple typeTuple)
{
- Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
+ Form_pg_type typeStruct = GETSTRUCT(pg_type, typeTuple);
/*
* Array types get their typelem as parameter; everybody else gets their
@@ -2326,7 +2326,7 @@ get_type_io_data(Oid typid,
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", typid);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
+ typeStruct = GETSTRUCT(pg_type, typeTuple);
*typlen = typeStruct->typlen;
*typbyval = typeStruct->typbyval;
@@ -2360,7 +2360,7 @@ get_typalign(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
char result;
result = typtup->typalign;
@@ -2380,7 +2380,7 @@ get_typstorage(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
char result;
result = typtup->typstorage;
@@ -2413,7 +2413,7 @@ get_typdefault(Oid typid)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", typid);
- type = (Form_pg_type) GETSTRUCT(typeTuple);
+ type = GETSTRUCT(pg_type, typeTuple);
/*
* typdefault and typdefaultbin are potentially null, so don't try to
@@ -2505,7 +2505,7 @@ getBaseTypeAndTypmod(Oid typid, int32 *typmod)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
if (typTup->typtype != TYPTYPE_DOMAIN)
{
/* Not a domain, so done */
@@ -2590,7 +2590,7 @@ get_typtype(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
char result;
result = typtup->typtype;
@@ -2672,7 +2672,7 @@ get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", typid);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
*typcategory = typtup->typcategory;
*typispreferred = typtup->typispreferred;
ReleaseSysCache(tp);
@@ -2692,7 +2692,7 @@ get_typ_typrelid(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
result = typtup->typrelid;
@@ -2720,7 +2720,7 @@ get_element_type(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
if (IsTrueArrayType(typtup))
@@ -2749,7 +2749,7 @@ get_array_type(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
+ result = (GETSTRUCT(pg_type, tp))->typarray;
ReleaseSysCache(tp);
}
return result;
@@ -2799,7 +2799,7 @@ get_base_element_type(Oid typid)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tup))
break;
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
if (typTup->typtype != TYPTYPE_DOMAIN)
{
/* Not a domain, so stop descending */
@@ -2836,7 +2836,7 @@ getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type);
- pt = (Form_pg_type) GETSTRUCT(typeTuple);
+ pt = GETSTRUCT(pg_type, typeTuple);
if (!pt->typisdefined)
ereport(ERROR,
@@ -2869,7 +2869,7 @@ getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type);
- pt = (Form_pg_type) GETSTRUCT(typeTuple);
+ pt = GETSTRUCT(pg_type, typeTuple);
if (!pt->typisdefined)
ereport(ERROR,
@@ -2902,7 +2902,7 @@ getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type);
- pt = (Form_pg_type) GETSTRUCT(typeTuple);
+ pt = GETSTRUCT(pg_type, typeTuple);
if (!pt->typisdefined)
ereport(ERROR,
@@ -2935,7 +2935,7 @@ getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type);
- pt = (Form_pg_type) GETSTRUCT(typeTuple);
+ pt = GETSTRUCT(pg_type, typeTuple);
if (!pt->typisdefined)
ereport(ERROR,
@@ -2967,7 +2967,7 @@ get_typmodin(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
result = typtup->typmodin;
@@ -2992,7 +2992,7 @@ get_typmodout(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
result = typtup->typmodout;
@@ -3017,7 +3017,7 @@ get_typcollation(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
result = typtup->typcollation;
@@ -3058,7 +3058,7 @@ get_typsubscript(Oid typid, Oid *typelemp)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typform = GETSTRUCT(pg_type, tp);
RegProcedure handler = typform->typsubscript;
if (typelemp)
@@ -3129,7 +3129,7 @@ get_attavgwidth(Oid relid, AttrNumber attnum)
BoolGetDatum(false));
if (HeapTupleIsValid(tp))
{
- stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
+ stawidth = (GETSTRUCT(pg_statistic, tp))->stawidth;
ReleaseSysCache(tp);
if (stawidth > 0)
return stawidth;
@@ -3187,7 +3187,7 @@ bool
get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple,
int reqkind, Oid reqop, int flags)
{
- Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
+ Form_pg_statistic stats = GETSTRUCT(pg_statistic, statstuple);
int i;
Datum val;
bool isnull;
@@ -3236,7 +3236,7 @@ get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple,
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
- typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
+ typeForm = GETSTRUCT(pg_type, typeTuple);
/* Deconstruct array into Datum elements; NULLs not expected */
deconstruct_array(statarray,
@@ -3330,7 +3330,7 @@ get_namespace_name(Oid nspid)
tp = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(nspid));
if (HeapTupleIsValid(tp))
{
- Form_pg_namespace nsptup = (Form_pg_namespace) GETSTRUCT(tp);
+ Form_pg_namespace nsptup = GETSTRUCT(pg_namespace, tp);
char *result;
result = pstrdup(NameStr(nsptup->nspname));
@@ -3371,7 +3371,7 @@ get_range_subtype(Oid rangeOid)
tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
if (HeapTupleIsValid(tp))
{
- Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
+ Form_pg_range rngtup = GETSTRUCT(pg_range, tp);
Oid result;
result = rngtup->rngsubtype;
@@ -3397,7 +3397,7 @@ get_range_collation(Oid rangeOid)
tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
if (HeapTupleIsValid(tp))
{
- Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
+ Form_pg_range rngtup = GETSTRUCT(pg_range, tp);
Oid result;
result = rngtup->rngcollation;
@@ -3422,7 +3422,7 @@ get_range_multirange(Oid rangeOid)
tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
if (HeapTupleIsValid(tp))
{
- Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
+ Form_pg_range rngtup = GETSTRUCT(pg_range, tp);
Oid result;
result = rngtup->rngmultitypid;
@@ -3447,7 +3447,7 @@ get_multirange_range(Oid multirangeOid)
tp = SearchSysCache1(RANGEMULTIRANGE, ObjectIdGetDatum(multirangeOid));
if (HeapTupleIsValid(tp))
{
- Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
+ Form_pg_range rngtup = GETSTRUCT(pg_range, tp);
Oid result;
result = rngtup->rngtypid;
@@ -3484,7 +3484,7 @@ get_index_column_opclass(Oid index_oid, int attno)
if (!HeapTupleIsValid(tuple))
return InvalidOid;
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
/* caller is supposed to guarantee this */
Assert(attno > 0 && attno <= rd_index->indnatts);
@@ -3526,7 +3526,7 @@ get_index_isreplident(Oid index_oid)
if (!HeapTupleIsValid(tuple))
return false;
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
result = rd_index->indisreplident;
ReleaseSysCache(tuple);
@@ -3549,7 +3549,7 @@ get_index_isvalid(Oid index_oid)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u", index_oid);
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
isvalid = rd_index->indisvalid;
ReleaseSysCache(tuple);
@@ -3572,7 +3572,7 @@ get_index_isclustered(Oid index_oid)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u", index_oid);
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
isclustered = rd_index->indisclustered;
ReleaseSysCache(tuple);
diff --git a/src/backend/utils/cache/partcache.c b/src/backend/utils/cache/partcache.c
index afa99c5d03..4f8c7c5bde 100644
--- a/src/backend/utils/cache/partcache.c
+++ b/src/backend/utils/cache/partcache.c
@@ -111,7 +111,7 @@ RelationBuildPartitionKey(Relation relation)
sizeof(PartitionKeyData));
/* Fixed-length attributes */
- form = (Form_pg_partitioned_table) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_partitioned_table, tuple);
key->strategy = form->partstrat;
key->partnatts = form->partnatts;
@@ -200,7 +200,7 @@ RelationBuildPartitionKey(Relation relation)
if (!HeapTupleIsValid(opclasstup))
elog(ERROR, "cache lookup failed for opclass %u", opclass->values[i]);
- opclassform = (Form_pg_opclass) GETSTRUCT(opclasstup);
+ opclassform = GETSTRUCT(pg_opclass, opclasstup);
key->partopfamily[i] = opclassform->opcfamily;
key->partopcintype[i] = opclassform->opcintype;
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index bdb771d278..7187de3a4c 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -572,7 +572,7 @@ RelationBuildTupleDesc(Relation relation)
Form_pg_attribute attp;
int attnum;
- attp = (Form_pg_attribute) GETSTRUCT(pg_attribute_tuple);
+ attp = GETSTRUCT(pg_attribute, pg_attribute_tuple);
attnum = attp->attnum;
if (attnum <= 0 || attnum > RelationGetNumberOfAttributes(relation))
@@ -785,7 +785,7 @@ RelationBuildRuleLock(Relation relation)
while (HeapTupleIsValid(rewrite_tuple = systable_getnext(rewrite_scan)))
{
- Form_pg_rewrite rewrite_form = (Form_pg_rewrite) GETSTRUCT(rewrite_tuple);
+ Form_pg_rewrite rewrite_form = GETSTRUCT(pg_rewrite, rewrite_tuple);
bool isnull;
Datum rule_datum;
char *rule_str;
@@ -1111,7 +1111,7 @@ retry:
/*
* get information from the pg_class_tuple
*/
- relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
+ relp = GETSTRUCT(pg_class, pg_class_tuple);
relid = relp->oid;
Assert(relid == targetRelId);
@@ -1349,7 +1349,7 @@ RelationInitPhysicalAddr(Relation relation)
if (!HeapTupleIsValid(phys_tuple))
elog(ERROR, "could not find pg_class entry for %u",
RelationGetRelid(relation));
- physrel = (Form_pg_class) GETSTRUCT(phys_tuple);
+ physrel = GETSTRUCT(pg_class, phys_tuple);
relation->rd_rel->reltablespace = physrel->reltablespace;
relation->rd_rel->relfilenode = physrel->relfilenode;
@@ -1442,7 +1442,7 @@ RelationInitIndexAccessInfo(Relation relation)
RelationGetRelid(relation));
oldcontext = MemoryContextSwitchTo(CacheMemoryContext);
relation->rd_indextuple = heap_copytuple(tuple);
- relation->rd_index = (Form_pg_index) GETSTRUCT(relation->rd_indextuple);
+ relation->rd_index = GETSTRUCT(pg_index, relation->rd_indextuple);
MemoryContextSwitchTo(oldcontext);
ReleaseSysCache(tuple);
@@ -1454,7 +1454,7 @@ RelationInitIndexAccessInfo(Relation relation)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for access method %u",
relation->rd_rel->relam);
- aform = (Form_pg_am) GETSTRUCT(tuple);
+ aform = GETSTRUCT(pg_am, tuple);
relation->rd_amhandler = aform->amhandler;
ReleaseSysCache(tuple);
@@ -1728,7 +1728,7 @@ LookupOpclassInfo(Oid operatorClassOid,
if (HeapTupleIsValid(htup = systable_getnext(scan)))
{
- Form_pg_opclass opclassform = (Form_pg_opclass) GETSTRUCT(htup);
+ Form_pg_opclass opclassform = GETSTRUCT(pg_opclass, htup);
opcentry->opcfamily = opclassform->opcfamily;
opcentry->opcintype = opclassform->opcintype;
@@ -1763,7 +1763,7 @@ LookupOpclassInfo(Oid operatorClassOid,
while (HeapTupleIsValid(htup = systable_getnext(scan)))
{
- Form_pg_amproc amprocform = (Form_pg_amproc) GETSTRUCT(htup);
+ Form_pg_amproc amprocform = GETSTRUCT(pg_amproc, htup);
if (amprocform->amprocnum <= 0 ||
(StrategyNumber) amprocform->amprocnum > numSupport)
@@ -1832,7 +1832,7 @@ RelationInitTableAccessMethod(Relation relation)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for access method %u",
relation->rd_rel->relam);
- aform = (Form_pg_am) GETSTRUCT(tuple);
+ aform = GETSTRUCT(pg_am, tuple);
relation->rd_amhandler = aform->amhandler;
ReleaseSysCache(tuple);
}
@@ -2257,7 +2257,7 @@ RelationReloadIndexInfo(Relation relation)
if (!HeapTupleIsValid(pg_class_tuple))
elog(ERROR, "could not find pg_class tuple for index %u",
RelationGetRelid(relation));
- relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
+ relp = GETSTRUCT(pg_class, pg_class_tuple);
memcpy(relation->rd_rel, relp, CLASS_TUPLE_SIZE);
/* Reload reloptions in case they changed */
if (relation->rd_options)
@@ -2286,7 +2286,7 @@ RelationReloadIndexInfo(Relation relation)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u",
RelationGetRelid(relation));
- index = (Form_pg_index) GETSTRUCT(tuple);
+ index = GETSTRUCT(pg_index, tuple);
/*
* Basically, let's just copy all the bool fields. There are one or
@@ -2378,7 +2378,7 @@ RelationReloadNailed(Relation relation)
pg_class_tuple = ScanPgRelation(RelationGetRelid(relation),
true, false);
- relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
+ relp = GETSTRUCT(pg_class, pg_class_tuple);
memcpy(relation->rd_rel, relp, CLASS_TUPLE_SIZE);
heap_freetuple(pg_class_tuple);
@@ -3721,7 +3721,7 @@ RelationSetNewRelfilenumber(Relation relation, char persistence)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for relation %u",
RelationGetRelid(relation));
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
/*
* Schedule unlinking of the old storage at transaction commit.
@@ -4137,7 +4137,7 @@ RelationCacheInitializePhase3(void)
if (!HeapTupleIsValid(htup))
elog(FATAL, "cache lookup failed for relation %u",
RelationGetRelid(relation));
- relp = (Form_pg_class) GETSTRUCT(htup);
+ relp = GETSTRUCT(pg_class, htup);
/*
* Copy tuple to relation->rd_rel. (See notes in
@@ -4382,7 +4382,7 @@ AttrDefaultFetch(Relation relation, int ndef)
while (HeapTupleIsValid(htup = systable_getnext(adscan)))
{
- Form_pg_attrdef adform = (Form_pg_attrdef) GETSTRUCT(htup);
+ Form_pg_attrdef adform = GETSTRUCT(pg_attrdef, htup);
Datum val;
bool isnull;
@@ -4478,7 +4478,7 @@ CheckConstraintFetch(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(conscan)))
{
- Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(htup);
+ Form_pg_constraint conform = GETSTRUCT(pg_constraint, htup);
Datum val;
bool isnull;
@@ -4602,7 +4602,7 @@ RelationGetFKeyList(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(conscan)))
{
- Form_pg_constraint constraint = (Form_pg_constraint) GETSTRUCT(htup);
+ Form_pg_constraint constraint = GETSTRUCT(pg_constraint, htup);
ForeignKeyCacheInfo *info;
/* consider only foreign keys */
@@ -4709,7 +4709,7 @@ RelationGetIndexList(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(indscan)))
{
- Form_pg_index index = (Form_pg_index) GETSTRUCT(htup);
+ Form_pg_index index = GETSTRUCT(pg_index, htup);
/*
* Ignore any indexes that are currently being dropped. This will
@@ -4828,7 +4828,7 @@ RelationGetStatExtList(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(indscan)))
{
- Oid oid = ((Form_pg_statistic_ext) GETSTRUCT(htup))->oid;
+ Oid oid = (GETSTRUCT(pg_statistic_ext, htup))->oid;
result = lappend_oid(result, oid);
}
@@ -5474,7 +5474,7 @@ RelationGetExclusionInfo(Relation indexRelation,
while (HeapTupleIsValid(htup = systable_getnext(conscan)))
{
- Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(htup);
+ Form_pg_constraint conform = GETSTRUCT(pg_constraint, htup);
Datum val;
bool isnull;
ArrayType *arr;
@@ -5621,7 +5621,7 @@ RelationBuildPublicationDesc(Relation relation, PublicationDesc *pubdesc)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication %u", pubid);
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
pubdesc->pubactions.pubinsert |= pubform->pubinsert;
pubdesc->pubactions.pubupdate |= pubform->pubupdate;
@@ -6088,7 +6088,7 @@ load_relcache_init_file(bool shared)
/* Fix up internal pointers in the tuple -- see heap_copytuple */
rel->rd_indextuple->t_data = (HeapTupleHeader) ((char *) rel->rd_indextuple + HEAPTUPLESIZE);
- rel->rd_index = (Form_pg_index) GETSTRUCT(rel->rd_indextuple);
+ rel->rd_index = GETSTRUCT(pg_index, rel->rd_indextuple);
/*
* prepare index info context --- parameters should match
diff --git a/src/backend/utils/cache/relfilenumbermap.c b/src/backend/utils/cache/relfilenumbermap.c
index c4245d5ccd..7570f5e095 100644
--- a/src/backend/utils/cache/relfilenumbermap.c
+++ b/src/backend/utils/cache/relfilenumbermap.c
@@ -209,7 +209,7 @@ RelidByRelfilenumber(Oid reltablespace, RelFileNumber relfilenumber)
while (HeapTupleIsValid(ntp = systable_getnext(scandesc)))
{
- Form_pg_class classform = (Form_pg_class) GETSTRUCT(ntp);
+ Form_pg_class classform = GETSTRUCT(pg_class, ntp);
if (found)
elog(ERROR,
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index 1912b12146..a8c320ef91 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -1320,7 +1320,7 @@ SearchSysCacheAttName(Oid relid, const char *attname)
CStringGetDatum(attname));
if (!HeapTupleIsValid(tuple))
return NULL;
- if (((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
+ if ((GETSTRUCT(pg_attribute, tuple))->attisdropped)
{
ReleaseSysCache(tuple);
return NULL;
@@ -1383,7 +1383,7 @@ SearchSysCacheAttNum(Oid relid, int16 attnum)
Int16GetDatum(attnum));
if (!HeapTupleIsValid(tuple))
return NULL;
- if (((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
+ if ((GETSTRUCT(pg_attribute, tuple))->attisdropped)
{
ReleaseSysCache(tuple);
return NULL;
diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c
index 24808dfbb1..e1d0dad795 100644
--- a/src/backend/utils/cache/ts_cache.c
+++ b/src/backend/utils/cache/ts_cache.c
@@ -152,7 +152,7 @@ lookup_ts_parser_cache(Oid prsId)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for text search parser %u",
prsId);
- prs = (Form_pg_ts_parser) GETSTRUCT(tp);
+ prs = GETSTRUCT(pg_ts_parser, tp);
/*
* Sanity checks
@@ -254,7 +254,7 @@ lookup_ts_dictionary_cache(Oid dictId)
if (!HeapTupleIsValid(tpdict))
elog(ERROR, "cache lookup failed for text search dictionary %u",
dictId);
- dict = (Form_pg_ts_dict) GETSTRUCT(tpdict);
+ dict = GETSTRUCT(pg_ts_dict, tpdict);
/*
* Sanity checks
@@ -270,7 +270,7 @@ lookup_ts_dictionary_cache(Oid dictId)
if (!HeapTupleIsValid(tptmpl))
elog(ERROR, "cache lookup failed for text search template %u",
dict->dicttemplate);
- template = (Form_pg_ts_template) GETSTRUCT(tptmpl);
+ template = GETSTRUCT(pg_ts_template, tptmpl);
/*
* Sanity checks
@@ -424,7 +424,7 @@ lookup_ts_config_cache(Oid cfgId)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for text search configuration %u",
cfgId);
- cfg = (Form_pg_ts_config) GETSTRUCT(tp);
+ cfg = GETSTRUCT(pg_ts_config, tp);
/*
* Sanity checks
@@ -484,7 +484,7 @@ lookup_ts_config_cache(Oid cfgId)
while ((maptup = systable_getnext_ordered(mapscan, ForwardScanDirection)) != NULL)
{
- Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup);
+ Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup);
int toktype = cfgmap->maptokentype;
if (toktype <= 0 || toktype > MAXTOKENTYPE)
@@ -625,7 +625,7 @@ check_TSCurrentConfig(char **newval, void **extra, GucSource source)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for text search configuration %u",
cfgId);
- cfg = (Form_pg_ts_config) GETSTRUCT(tuple);
+ cfg = GETSTRUCT(pg_ts_config, tuple);
buf = quote_qualified_identifier(get_namespace_name(cfg->cfgnamespace),
NameStr(cfg->cfgname));
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c
index 808f9ebd0d..6b55c4a4e1 100644
--- a/src/backend/utils/cache/typcache.c
+++ b/src/backend/utils/cache/typcache.c
@@ -383,7 +383,7 @@ lookup_type_cache(Oid type_id, int flags)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type with OID %u does not exist", type_id)));
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
if (!typtup->typisdefined)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -438,7 +438,7 @@ lookup_type_cache(Oid type_id, int flags)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type with OID %u does not exist", type_id)));
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
if (!typtup->typisdefined)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -922,7 +922,7 @@ load_rangetype_info(TypeCacheEntry *typentry)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for range type %u",
typentry->type_id);
- pg_range = (Form_pg_range) GETSTRUCT(tup);
+ pg_range = GETSTRUCT(pg_range, tup);
subtypeOid = pg_range->rngsubtype;
typentry->rng_collation = pg_range->rngcollation;
@@ -1032,7 +1032,7 @@ load_domaintype_info(TypeCacheEntry *typentry)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
if (typTup->typtype != TYPTYPE_DOMAIN)
{
@@ -1056,7 +1056,7 @@ load_domaintype_info(TypeCacheEntry *typentry)
while (HeapTupleIsValid(conTup = systable_getnext(scan)))
{
- Form_pg_constraint c = (Form_pg_constraint) GETSTRUCT(conTup);
+ Form_pg_constraint c = GETSTRUCT(pg_constraint, conTup);
Datum val;
bool isNull;
char *constring;
@@ -2592,7 +2592,7 @@ load_enum_cache_data(TypeCacheEntry *tcache)
while (HeapTupleIsValid(enum_tuple = systable_getnext(enum_scan)))
{
- Form_pg_enum en = (Form_pg_enum) GETSTRUCT(enum_tuple);
+ Form_pg_enum en = GETSTRUCT(pg_enum, enum_tuple);
if (numitems >= maxitems)
{
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index a9dd068095..125a175a11 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -181,7 +181,7 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt,
procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId));
if (!HeapTupleIsValid(procedureTuple))
elog(ERROR, "cache lookup failed for function %u", functionId);
- procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
finfo->fn_nargs = procedureStruct->pronargs;
finfo->fn_strict = procedureStruct->proisstrict;
@@ -291,7 +291,7 @@ fmgr_symbol(Oid functionId, char **mod, char **fn)
procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId));
if (!HeapTupleIsValid(procedureTuple))
elog(ERROR, "cache lookup failed for function %u", functionId);
- procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
if (procedureStruct->prosecdef ||
!heap_attisnull(procedureTuple, Anum_pg_proc_proconfig, NULL) ||
@@ -431,7 +431,7 @@ fmgr_info_C_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
static void
fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
{
- Form_pg_proc procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ Form_pg_proc procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
Oid language = procedureStruct->prolang;
HeapTuple languageTuple;
Form_pg_language languageStruct;
@@ -440,7 +440,7 @@ fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
languageTuple = SearchSysCache1(LANGOID, ObjectIdGetDatum(language));
if (!HeapTupleIsValid(languageTuple))
elog(ERROR, "cache lookup failed for language %u", language);
- languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
+ languageStruct = GETSTRUCT(pg_language, languageTuple);
/*
* Look up the language's call handler function, ignoring any attributes
@@ -528,7 +528,7 @@ fetch_finfo_record(void *filehandle, const char *funcname)
static CFuncHashTabEntry *
lookup_C_func(HeapTuple procedureTuple)
{
- Oid fn_oid = ((Form_pg_proc) GETSTRUCT(procedureTuple))->oid;
+ Oid fn_oid = (GETSTRUCT(pg_proc, procedureTuple))->oid;
CFuncHashTabEntry *entry;
if (CFuncHash == NULL)
@@ -553,7 +553,7 @@ static void
record_C_func(HeapTuple procedureTuple,
PGFunction user_fn, const Pg_finfo_record *inforec)
{
- Oid fn_oid = ((Form_pg_proc) GETSTRUCT(procedureTuple))->oid;
+ Oid fn_oid = (GETSTRUCT(pg_proc, procedureTuple))->oid;
CFuncHashTabEntry *entry;
bool found;
@@ -671,7 +671,7 @@ fmgr_security_definer(PG_FUNCTION_ARGS)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u",
fcinfo->flinfo->fn_oid);
- procedureStruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procedureStruct = GETSTRUCT(pg_proc, tuple);
if (procedureStruct->prosecdef)
fcache->userid = procedureStruct->proowner;
@@ -2035,7 +2035,7 @@ CheckFunctionValidatorAccess(Oid validatorOid, Oid functionOid)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function with OID %u does not exist", functionOid)));
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/*
* Fetch pg_language entry to know if this is the correct validation
@@ -2044,7 +2044,7 @@ CheckFunctionValidatorAccess(Oid validatorOid, Oid functionOid)
langTup = SearchSysCache1(LANGOID, ObjectIdGetDatum(procStruct->prolang));
if (!HeapTupleIsValid(langTup))
elog(ERROR, "cache lookup failed for language %u", procStruct->prolang);
- langStruct = (Form_pg_language) GETSTRUCT(langTup);
+ langStruct = GETSTRUCT(pg_language, langTup);
if (langStruct->lanvalidator != validatorOid)
ereport(ERROR,
diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c
index a1fe50ffca..213121461d 100644
--- a/src/backend/utils/fmgr/funcapi.c
+++ b/src/backend/utils/fmgr/funcapi.c
@@ -403,7 +403,7 @@ internal_get_result_type(Oid funcid,
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(tp);
+ procform = GETSTRUCT(pg_proc, tp);
rettype = procform->prorettype;
@@ -1337,7 +1337,7 @@ int
get_func_arg_info(HeapTuple procTup,
Oid **p_argtypes, char ***p_argnames, char **p_argmodes)
{
- Form_pg_proc procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ Form_pg_proc procStruct = GETSTRUCT(pg_proc, procTup);
Datum proallargtypes;
Datum proargmodes;
Datum proargnames;
@@ -1667,7 +1667,7 @@ get_func_result_name(Oid functionId)
TupleDesc
build_function_result_tupdesc_t(HeapTuple procTuple)
{
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(procTuple);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, procTuple);
Datum proallargtypes;
Datum proargmodes;
Datum proargnames;
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index eb43b2c5e5..df10da08b9 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -683,7 +683,7 @@ has_rolreplication(Oid roleid)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolreplication;
+ result = (GETSTRUCT(pg_authid, utup))->rolreplication;
ReleaseSysCache(utup);
}
return result;
@@ -732,7 +732,7 @@ InitializeSessionUserId(const char *rolename, Oid roleid)
errmsg("role with OID %u does not exist", roleid)));
}
- rform = (Form_pg_authid) GETSTRUCT(roleTup);
+ rform = GETSTRUCT(pg_authid, roleTup);
roleid = rform->oid;
rname = NameStr(rform->rolname);
@@ -925,7 +925,7 @@ GetUserNameFromId(Oid roleid, bool noerr)
}
else
{
- result = pstrdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_authid, tuple))->rolname));
ReleaseSysCache(tuple);
}
return result;
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index a5c208a20a..3ddd0d3c66 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -321,7 +321,7 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
tup = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
- dbform = (Form_pg_database) GETSTRUCT(tup);
+ dbform = GETSTRUCT(pg_database, tup);
/* This recheck is strictly paranoia */
if (strcmp(name, NameStr(dbform->datname)) != 0)
@@ -921,7 +921,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", in_dbname)));
- dbform = (Form_pg_database) GETSTRUCT(tuple);
+ dbform = GETSTRUCT(pg_database, tuple);
MyDatabaseId = dbform->oid;
MyDatabaseTableSpace = dbform->dattablespace;
/* take database name from the caller, just for paranoia */
@@ -938,7 +938,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database %u does not exist", dboid)));
- dbform = (Form_pg_database) GETSTRUCT(tuple);
+ dbform = GETSTRUCT(pg_database, tuple);
MyDatabaseId = dbform->oid;
MyDatabaseTableSpace = dbform->dattablespace;
Assert(MyDatabaseId == dboid);
@@ -1021,8 +1021,8 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
tuple = GetDatabaseTuple(dbname);
if (!HeapTupleIsValid(tuple) ||
- MyDatabaseId != ((Form_pg_database) GETSTRUCT(tuple))->oid ||
- MyDatabaseTableSpace != ((Form_pg_database) GETSTRUCT(tuple))->dattablespace)
+ MyDatabaseId != (GETSTRUCT(pg_database, tuple))->oid ||
+ MyDatabaseTableSpace != (GETSTRUCT(pg_database, tuple))->dattablespace)
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", dbname),
diff --git a/src/backend/utils/misc/rls.c b/src/backend/utils/misc/rls.c
index d15880670f..73fd21d843 100644
--- a/src/backend/utils/misc/rls.c
+++ b/src/backend/utils/misc/rls.c
@@ -66,7 +66,7 @@ check_enable_rls(Oid relid, Oid checkAsUser, bool noError)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return RLS_NONE;
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
relrowsecurity = classform->relrowsecurity;
relforcerowsecurity = classform->relforcerowsecurity;
diff --git a/src/backend/utils/misc/superuser.c b/src/backend/utils/misc/superuser.c
index d20e7af797..1902f49d0a 100644
--- a/src/backend/utils/misc/superuser.c
+++ b/src/backend/utils/misc/superuser.c
@@ -70,7 +70,7 @@ superuser_arg(Oid roleid)
rtup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(rtup))
{
- result = ((Form_pg_authid) GETSTRUCT(rtup))->rolsuper;
+ result = (GETSTRUCT(pg_authid, rtup))->rolsuper;
ReleaseSysCache(rtup);
}
else
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 51a60eda08..7310e3b2b8 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -651,7 +651,7 @@ struct MinimalTupleData
/*
* GETSTRUCT - given a HeapTuple pointer, return address of the user data
*/
-#define GETSTRUCT(TUP) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)
+#define GETSTRUCT(CAT, TUP) ((Form_##CAT) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff))
/*
* Accessor macros to be used with HeapTuple pointers.
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index edb93ec1c4..1aa8227afb 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -1994,7 +1994,7 @@ plperl_validator(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- proc = (Form_pg_proc) GETSTRUCT(tuple);
+ proc = GETSTRUCT(pg_proc, tuple);
functyptype = get_typtype(proc->prorettype);
@@ -2717,7 +2717,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(fn_oid));
if (!HeapTupleIsValid(procTup))
elog(ERROR, "cache lookup failed for function %u", fn_oid);
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/*
* Try to find function in plperl_proc_hash. The reason for this
@@ -2818,7 +2818,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
if (!HeapTupleIsValid(langTup))
elog(ERROR, "cache lookup failed for language %u",
procStruct->prolang);
- langStruct = (Form_pg_language) GETSTRUCT(langTup);
+ langStruct = GETSTRUCT(pg_language, langTup);
prodesc->lang_oid = langStruct->oid;
prodesc->lanpltrusted = langStruct->lanpltrusted;
ReleaseSysCache(langTup);
@@ -2834,7 +2834,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettype));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", rettype);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype result, except VOID or RECORD */
if (typeStruct->typtype == TYPTYPE_PSEUDO)
@@ -2883,7 +2883,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(argtype));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", argtype);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype argument, except RECORD */
if (typeStruct->typtype == TYPTYPE_PSEUDO &&
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index b791c23f06..96b6f547df 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -149,7 +149,7 @@ plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator)
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(procTup))
elog(ERROR, "cache lookup failed for function %u", funcOid);
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/*
* See if there's already a cache entry for the current FmgrInfo. If not,
@@ -267,7 +267,7 @@ do_compile(FunctionCallInfo fcinfo,
PLpgSQL_func_hashkey *hashkey,
bool forValidator)
{
- Form_pg_proc procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ Form_pg_proc procStruct = GETSTRUCT(pg_proc, procTup);
bool is_dml_trigger = CALLED_AS_TRIGGER(fcinfo);
bool is_event_trigger = CALLED_AS_EVENT_TRIGGER(fcinfo);
Datum prosrcdatum;
@@ -545,7 +545,7 @@ do_compile(FunctionCallInfo fcinfo,
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettypeid));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", rettypeid);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype result, except VOID or RECORD */
/* (note we already replaced polymorphic types) */
@@ -1649,7 +1649,7 @@ plpgsql_parse_wordtype(char *ident)
typeTup = LookupTypeName(NULL, typeName, NULL, false);
if (typeTup)
{
- Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ Form_pg_type typeStruct = GETSTRUCT(pg_type, typeTup);
if (!typeStruct->typisdefined ||
typeStruct->typrelid != InvalidOid)
@@ -1741,7 +1741,7 @@ plpgsql_parse_cwordtype(List *idents)
classtup = SearchSysCache1(RELOID, ObjectIdGetDatum(classOid));
if (!HeapTupleIsValid(classtup))
goto done;
- classStruct = (Form_pg_class) GETSTRUCT(classtup);
+ classStruct = GETSTRUCT(pg_class, classtup);
/*
* It must be a relation, sequence, view, materialized view, composite
@@ -1762,7 +1762,7 @@ plpgsql_parse_cwordtype(List *idents)
attrtup = SearchSysCacheAttName(classOid, fldname);
if (!HeapTupleIsValid(attrtup))
goto done;
- attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup);
+ attrStruct = GETSTRUCT(pg_attribute, attrtup);
typetup = SearchSysCache1(TYPEOID,
ObjectIdGetDatum(attrStruct->atttypid));
@@ -2113,7 +2113,7 @@ static PLpgSQL_type *
build_datatype(HeapTuple typeTup, int32 typmod,
Oid collation, TypeName *origtypname)
{
- Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ Form_pg_type typeStruct = GETSTRUCT(pg_type, typeTup);
PLpgSQL_type *typ;
if (!typeStruct->typisdefined)
diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c
index 190d286f1c..632e4c351d 100644
--- a/src/pl/plpgsql/src/pl_handler.c
+++ b/src/pl/plpgsql/src/pl_handler.c
@@ -460,7 +460,7 @@ plpgsql_validator(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- proc = (Form_pg_proc) GETSTRUCT(tuple);
+ proc = GETSTRUCT(pg_proc, tuple);
functyptype = get_typtype(proc->prorettype);
diff --git a/src/pl/plpython/plpy_main.c b/src/pl/plpython/plpy_main.c
index 0bce106495..ab5fc74c1b 100644
--- a/src/pl/plpython/plpy_main.c
+++ b/src/pl/plpython/plpy_main.c
@@ -177,7 +177,7 @@ plpython3_validator(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- procStruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procStruct = GETSTRUCT(pg_proc, tuple);
is_trigger = PLy_procedure_is_trigger(procStruct);
diff --git a/src/pl/plpython/plpy_procedure.c b/src/pl/plpython/plpy_procedure.c
index 494f109b32..2c91e6df81 100644
--- a/src/pl/plpython/plpy_procedure.c
+++ b/src/pl/plpython/plpy_procedure.c
@@ -140,7 +140,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
int rv;
char *ptr;
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
rv = snprintf(procName, sizeof(procName),
"__plpython_procedure_%s_%u",
NameStr(procStruct->proname),
@@ -211,7 +211,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
rvTypeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettype));
if (!HeapTupleIsValid(rvTypeTup))
elog(ERROR, "cache lookup failed for type %u", rettype);
- rvTypeStruct = (Form_pg_type) GETSTRUCT(rvTypeTup);
+ rvTypeStruct = GETSTRUCT(pg_type, rvTypeTup);
/* Disallow pseudotype result, except for void or record */
if (rvTypeStruct->typtype == TYPTYPE_PSEUDO)
@@ -298,7 +298,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
ObjectIdGetDatum(types[i]));
if (!HeapTupleIsValid(argTypeTup))
elog(ERROR, "cache lookup failed for type %u", types[i]);
- argTypeStruct = (Form_pg_type) GETSTRUCT(argTypeTup);
+ argTypeStruct = GETSTRUCT(pg_type, argTypeTup);
/* disallow pseudotype arguments */
if (argTypeStruct->typtype == TYPTYPE_PSEUDO)
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index 0dd6d8ab2c..0161a9bb9c 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -628,7 +628,7 @@ call_pltcl_start_proc(Oid prolang, bool pltrusted)
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procOid));
if (!HeapTupleIsValid(procTup))
elog(ERROR, "cache lookup failed for function %u", procOid);
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/* It must be same language as the function we're currently calling */
if (procStruct->prolang != prolang)
@@ -1405,7 +1405,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(fn_oid));
if (!HeapTupleIsValid(procTup))
elog(ERROR, "cache lookup failed for function %u", fn_oid);
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/*
* Look up function in pltcl_proc_htab; if it's not there, create an entry
@@ -1527,7 +1527,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettype));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", rettype);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype result, except VOID and RECORD */
if (typeStruct->typtype == TYPTYPE_PSEUDO)
@@ -1575,7 +1575,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(argtype));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", argtype);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype argument, except RECORD */
if (typeStruct->typtype == TYPTYPE_PSEUDO &&
diff --git a/src/test/modules/plsample/plsample.c b/src/test/modules/plsample/plsample.c
index 780db7292a..8cc3118985 100644
--- a/src/test/modules/plsample/plsample.c
+++ b/src/test/modules/plsample/plsample.c
@@ -122,7 +122,7 @@ plsample_func_handler(PG_FUNCTION_ARGS)
* Extract and print the source text of the function. This can be used as
* a base for the function validation and execution.
*/
- pl_struct = (Form_pg_proc) GETSTRUCT(pl_tuple);
+ pl_struct = GETSTRUCT(pg_proc, pl_tuple);
proname = pstrdup(NameStr(pl_struct->proname));
ret = SysCacheGetAttr(PROCOID, pl_tuple, Anum_pg_proc_prosrc, &isnull);
if (isnull)
@@ -157,7 +157,7 @@ plsample_func_handler(PG_FUNCTION_ARGS)
if (!HeapTupleIsValid(type_tuple))
elog(ERROR, "cache lookup failed for type %u", argtype);
- type_struct = (Form_pg_type) GETSTRUCT(type_tuple);
+ type_struct = GETSTRUCT(pg_type, type_tuple);
fmgr_info_cxt(type_struct->typoutput, &(arg_out_func[i]), proc_cxt);
ReleaseSysCache(type_tuple);
@@ -186,7 +186,7 @@ plsample_func_handler(PG_FUNCTION_ARGS)
ObjectIdGetDatum(prorettype));
if (!HeapTupleIsValid(type_tuple))
elog(ERROR, "cache lookup failed for type %u", prorettype);
- pg_type_entry = (Form_pg_type) GETSTRUCT(type_tuple);
+ pg_type_entry = GETSTRUCT(pg_type, type_tuple);
result_typioparam = getTypeIOParam(type_tuple);
fmgr_info_cxt(pg_type_entry->typinput, &result_in_func, proc_cxt);
@@ -239,7 +239,7 @@ plsample_trigger_handler(PG_FUNCTION_ARGS)
* Extract and print the source text of the function. This can be used as
* a base for the function validation and execution.
*/
- pl_struct = (Form_pg_proc) GETSTRUCT(pl_tuple);
+ pl_struct = GETSTRUCT(pg_proc, pl_tuple);
proname = pstrdup(NameStr(pl_struct->proname));
ret = SysCacheGetAttr(PROCOID, pl_tuple, Anum_pg_proc_prosrc, &isnull);
if (isnull)
--
2.36.1
On Thu, Jun 23, 2022 at 9:27 PM Robert Haas <robertmhaas@gmail.com> wrote:
I'm not sure whether your idea of creating translator functions is a
good one or not, but it doesn't seem too crazy. It'd be like a special
purpose tuple deformer.deform_pg_class_tuple(&pg_class_struct, pg_class_tuple);
The code in there could be automatically generated statements that
maybe look like this:memcpy(&struct.relnamespace, tuple + Aoffset_pg_class_relnamespace,
sizeof(Oid));
I've made a small step in this direction.
0001 is just boilerplate, same as v1
0002 teaches Catalog.pm to export both C attr name and SQL attr name, so we
can use "sizeof".
0003 generates static inline functions that work the same as the current
GETSTRUCT macro, i.e. just cast to the right pointer and return it.
0004 generates a function for pg_cast that memcpys to a passed struct, for
demonstration.
Here's the full deforming function generated for pg_cast. In English, the
current offset is the previous offset plus the previous type length, plus
any alignment padding suitable for the current type (there is none here, so
the alignment aspect is not tested). I'm hoping something like this will be
sufficient for what's in the current structs, but of course will need
additional work when expanding those to include pointers to varlen
attributes. I've not yet inspected the emitted assembly language, but
regression tests pass.
static inline void
Deform_pg_cast_tuple(Form_pg_cast pg_cast_struct, char * pg_cast_tuple)
{
#define Aoff_pg_cast_oid 0
memcpy(&pg_cast_struct->oid, pg_cast_tuple + Aoff_pg_cast_oid, sizeof(Oid));
#define Aoff_pg_cast_castsource att_align_nominal(Aoff_pg_cast_oid +
sizeof(Oid), 'i')
memcpy(&pg_cast_struct->castsource, pg_cast_tuple +
Aoff_pg_cast_castsource, sizeof(Oid));
#define Aoff_pg_cast_casttarget att_align_nominal(Aoff_pg_cast_castsource +
sizeof(Oid), 'i')
memcpy(&pg_cast_struct->casttarget, pg_cast_tuple +
Aoff_pg_cast_casttarget, sizeof(Oid));
#define Aoff_pg_cast_castfunc att_align_nominal(Aoff_pg_cast_casttarget +
sizeof(Oid), 'i')
memcpy(&pg_cast_struct->castfunc, pg_cast_tuple + Aoff_pg_cast_castfunc,
sizeof(Oid));
#define Aoff_pg_cast_castcontext att_align_nominal(Aoff_pg_cast_castfunc +
sizeof(Oid), 'c')
memcpy(&pg_cast_struct->castcontext, pg_cast_tuple +
Aoff_pg_cast_castcontext, sizeof(char));
#define Aoff_pg_cast_castmethod att_align_nominal(Aoff_pg_cast_castcontext
+ sizeof(char), 'c')
memcpy(&pg_cast_struct->castmethod, pg_cast_tuple +
Aoff_pg_cast_castmethod, sizeof(char));
}
Here's an example of the changes done in the call sites. For the rest of
the catalogs, perhaps many of them can be done mechanically. I still
anticipate a lot of manual work. Note that GETSTRUCT_MEMCPY is just
temporary scaffolding to distinguish from just returning a pointer, and is
not proposed for commit.
- Form_pg_cast castForm = GETSTRUCT(pg_cast, tuple);
+ FormData_pg_cast castForm;
CoercionContext castcontext;
+ GETSTRUCT_MEMCPY(pg_cast, &castForm, tuple);
+
/* convert char value for castcontext to CoercionContext
enum */
- switch (castForm->castcontext)
+ switch (castForm.castcontext)
--
John Naylor
EDB: http://www.enterprisedb.com
Attachments:
v2-0002-Distinguish-C-name-and-C-type-from-SQL-name-and-S.patchtext/x-patch; charset=US-ASCII; name=v2-0002-Distinguish-C-name-and-C-type-from-SQL-name-and-S.patchDownload
From 8a0c1a7921d8dfb7baa98b4bb090239647ded7a5 Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Sat, 16 Jul 2022 12:00:11 +0700
Subject: [PATCH v2 2/4] Distinguish C name and C type from SQL name and SQL
type in Catalog.pm's interface.
A future commit will need access to the C type. The C member name shouldn't
be needed, since having "[1]" is probably not useful, but include it for
the sake of symmetry.
---
src/backend/catalog/Catalog.pm | 32 +++++++++++++++-------
src/backend/catalog/genbki.pl | 34 ++++++++++++------------
src/include/catalog/reformat_dat_file.pl | 4 +--
3 files changed, 41 insertions(+), 29 deletions(-)
diff --git a/src/backend/catalog/Catalog.pm b/src/backend/catalog/Catalog.pm
index e91a8e10a8..206cb21ddc 100644
--- a/src/backend/catalog/Catalog.pm
+++ b/src/backend/catalog/Catalog.pm
@@ -190,27 +190,39 @@ sub ParseHeader
{
my %column;
my @attopts = split /\s+/, $_;
- my $atttype = shift @attopts;
- my $attname = shift @attopts;
+ my $ctype = shift @attopts;
+ my $cname = shift @attopts;
+ my $atttype;
+ my $attname;
die "parse error ($input_file)"
- unless ($attname and $atttype);
+ unless ($cname and $ctype);
- if (exists $RENAME_ATTTYPE{$atttype})
+ if (exists $RENAME_ATTTYPE{$ctype})
{
- $atttype = $RENAME_ATTTYPE{$atttype};
+ $atttype = $RENAME_ATTTYPE{$ctype};
+ }
+ else
+ {
+ $atttype = $ctype;
}
# If the C name ends with '[]' or '[digits]', we have
# an array type, so we discard that from the name and
# prepend '_' to the type.
- if ($attname =~ /(\w+)\[\d*\]/)
+ if ($cname =~ /(\w+)\[\d*\]/)
{
$attname = $1;
$atttype = '_' . $atttype;
}
+ else
+ {
+ $attname = $cname;
+ }
- $column{type} = $atttype;
- $column{name} = $attname;
+ $column{ctype} = $ctype;
+ $column{cname} = $cname;
+ $column{atttype} = $atttype;
+ $column{attname} = $attname;
$column{is_varlen} = 1 if $is_varlen;
foreach my $attopt (@attopts)
@@ -383,7 +395,7 @@ sub AddDefaultValues
# Now fill in defaults, and note any columns that remain undefined.
foreach my $column (@$schema)
{
- my $attname = $column->{name};
+ my $attname = $column->{attname};
# No work if field already has a value.
next if defined $row->{$attname};
@@ -441,7 +453,7 @@ sub GenerateArrayTypes
# Fill in the rest of the array entry's fields.
foreach my $column (@$pgtype_schema)
{
- my $attname = $column->{name};
+ my $attname = $column->{attname};
# Skip if we already set it above.
next if defined $array_type{$attname};
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index 17b2c5e3f3..932f3a9ab5 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -512,8 +512,8 @@ EOM
foreach my $column (@$schema)
{
$attnum++;
- my $attname = $column->{name};
- my $atttype = $column->{type};
+ my $attname = $column->{attname};
+ my $atttype = $column->{atttype};
# Build hash of column names for use later
$attnames{$attname} = 1;
@@ -585,8 +585,8 @@ EOM
# Perform required substitutions on fields
foreach my $column (@$schema)
{
- my $attname = $column->{name};
- my $atttype = $column->{type};
+ my $attname = $column->{attname};
+ my $atttype = $column->{atttype};
# Assign oid if oid column exists and no explicit assignment in row
if ($attname eq "oid" and not defined $bki_values{$attname})
@@ -830,7 +830,7 @@ sub gen_pg_attribute
my @attnames;
foreach my $column (@$schema)
{
- push @attnames, $column->{name};
+ push @attnames, $column->{attname};
}
foreach my $table_name (@catnames)
@@ -877,12 +877,12 @@ sub gen_pg_attribute
{
$attnum = 0;
my @SYS_ATTRS = (
- { name => 'ctid', type => 'tid' },
- { name => 'xmin', type => 'xid' },
- { name => 'cmin', type => 'cid' },
- { name => 'xmax', type => 'xid' },
- { name => 'cmax', type => 'cid' },
- { name => 'tableoid', type => 'oid' });
+ { attname => 'ctid', atttype => 'tid' },
+ { attname => 'xmin', atttype => 'xid' },
+ { attname => 'cmin', atttype => 'cid' },
+ { attname => 'xmax', atttype => 'xid' },
+ { attname => 'cmax', atttype => 'cid' },
+ { attname => 'tableoid', atttype => 'oid' });
foreach my $attr (@SYS_ATTRS)
{
$attnum--;
@@ -908,8 +908,8 @@ sub gen_pg_attribute
sub morph_row_for_pgattr
{
my ($row, $pgattr_schema, $attr, $priorfixedwidth) = @_;
- my $attname = $attr->{name};
- my $atttype = $attr->{type};
+ my $attname = $attr->{attname};
+ my $atttype = $attr->{atttype};
$row->{attname} = $attname;
@@ -969,8 +969,8 @@ sub print_bki_insert
foreach my $column (@$schema)
{
- my $attname = $column->{name};
- my $atttype = $column->{type};
+ my $attname = $column->{attname};
+ my $atttype = $column->{atttype};
my $bki_value = $row->{$attname};
# Fold backslash-zero to empty string if it's the entire string,
@@ -1007,8 +1007,8 @@ sub morph_row_for_schemapg
foreach my $column (@$pgattr_schema)
{
- my $attname = $column->{name};
- my $atttype = $column->{type};
+ my $attname = $column->{attname};
+ my $atttype = $column->{atttype};
# Some data types have special formatting rules.
if ($atttype eq 'name')
diff --git a/src/include/catalog/reformat_dat_file.pl b/src/include/catalog/reformat_dat_file.pl
index e4a105ebf5..5c03e79ccb 100755
--- a/src/include/catalog/reformat_dat_file.pl
+++ b/src/include/catalog/reformat_dat_file.pl
@@ -104,7 +104,7 @@ foreach my $catname (@catnames)
foreach my $column (@$schema)
{
- my $attname = $column->{name};
+ my $attname = $column->{attname};
# We may have ordinary columns at the storage level that we still
# want to format as a special value. Exclude these from the column
@@ -182,7 +182,7 @@ sub strip_default_values
# Delete values that match defaults.
foreach my $column (@$schema)
{
- my $attname = $column->{name};
+ my $attname = $column->{attname};
# It's okay if we have no oid value, since it will be assigned
# automatically before bootstrap.
--
2.36.1
v2-0001-Transform-GETSTRUCT-macro-to-pass-the-catalog-nam.patchtext/x-patch; charset=US-ASCII; name=v2-0001-Transform-GETSTRUCT-macro-to-pass-the-catalog-nam.patchDownload
From f9dffb28b8bff8abf29a2a3d322a6678d54c0796 Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Sat, 9 Jul 2022 12:19:18 +0700
Subject: [PATCH v2 1/4] Transform GETSTRUCT macro to pass the catalog name as
a parameter
Preparatory refactoring per suggestion from Andres Freund
---
contrib/bloom/blvalidate.c | 8 +-
contrib/dblink/dblink.c | 2 +-
contrib/intarray/_int_selfuncs.c | 2 +-
contrib/postgres_fdw/deparse.c | 8 +-
contrib/sepgsql/database.c | 2 +-
contrib/sepgsql/dml.c | 4 +-
contrib/sepgsql/label.c | 10 +-
contrib/sepgsql/proc.c | 6 +-
contrib/sepgsql/relation.c | 12 +-
contrib/sepgsql/schema.c | 2 +-
contrib/tcn/tcn.c | 2 +-
src/backend/access/brin/brin_validate.c | 8 +-
src/backend/access/common/reloptions.c | 2 +-
src/backend/access/common/tupdesc.c | 2 +-
src/backend/access/gin/ginvalidate.c | 8 +-
src/backend/access/gist/gistvalidate.c | 8 +-
src/backend/access/hash/hashvalidate.c | 10 +-
src/backend/access/index/amapi.c | 4 +-
src/backend/access/index/amvalidate.c | 14 +-
src/backend/access/nbtree/nbtvalidate.c | 8 +-
src/backend/access/spgist/spgutils.c | 4 +-
src/backend/access/spgist/spgvalidate.c | 8 +-
src/backend/bootstrap/bootstrap.c | 2 +-
src/backend/catalog/aclchk.c | 118 ++++-----
src/backend/catalog/catalog.c | 2 +-
src/backend/catalog/dependency.c | 4 +-
src/backend/catalog/heap.c | 24 +-
src/backend/catalog/index.c | 40 +--
src/backend/catalog/namespace.c | 40 +--
src/backend/catalog/objectaddress.c | 124 ++++-----
src/backend/catalog/partition.c | 8 +-
src/backend/catalog/pg_aggregate.c | 8 +-
src/backend/catalog/pg_attrdef.c | 14 +-
src/backend/catalog/pg_constraint.c | 28 +-
src/backend/catalog/pg_conversion.c | 2 +-
src/backend/catalog/pg_depend.c | 26 +-
src/backend/catalog/pg_enum.c | 20 +-
src/backend/catalog/pg_inherits.c | 14 +-
src/backend/catalog/pg_operator.c | 8 +-
src/backend/catalog/pg_proc.c | 6 +-
src/backend/catalog/pg_publication.c | 22 +-
src/backend/catalog/pg_shdepend.c | 14 +-
src/backend/catalog/pg_subscription.c | 12 +-
src/backend/catalog/pg_type.c | 6 +-
src/backend/catalog/toasting.c | 2 +-
src/backend/commands/alter.c | 16 +-
src/backend/commands/amcmds.c | 4 +-
src/backend/commands/analyze.c | 2 +-
src/backend/commands/cluster.c | 12 +-
src/backend/commands/collationcmds.c | 10 +-
src/backend/commands/dbcommands.c | 28 +-
src/backend/commands/event_trigger.c | 6 +-
src/backend/commands/extension.c | 14 +-
src/backend/commands/foreigncmds.c | 12 +-
src/backend/commands/functioncmds.c | 22 +-
src/backend/commands/indexcmds.c | 24 +-
src/backend/commands/matview.c | 4 +-
src/backend/commands/opclasscmds.c | 20 +-
src/backend/commands/operatorcmds.c | 4 +-
src/backend/commands/policy.c | 16 +-
src/backend/commands/proclang.c | 2 +-
src/backend/commands/publicationcmds.c | 22 +-
src/backend/commands/schemacmds.c | 8 +-
src/backend/commands/sequence.c | 18 +-
src/backend/commands/statscmds.c | 6 +-
src/backend/commands/subscriptioncmds.c | 8 +-
src/backend/commands/tablecmds.c | 240 +++++++++---------
src/backend/commands/tablespace.c | 10 +-
src/backend/commands/trigger.c | 34 +--
src/backend/commands/tsearchcmds.c | 26 +-
src/backend/commands/typecmds.c | 42 +--
src/backend/commands/user.c | 14 +-
src/backend/commands/vacuum.c | 12 +-
src/backend/commands/variable.c | 4 +-
src/backend/executor/execAmi.c | 2 +-
src/backend/executor/functions.c | 4 +-
src/backend/executor/nodeAgg.c | 4 +-
src/backend/executor/nodeWindowAgg.c | 4 +-
src/backend/executor/spi.c | 2 +-
src/backend/foreign/foreign.c | 14 +-
src/backend/optimizer/plan/planagg.c | 2 +-
src/backend/optimizer/plan/subselect.c | 2 +-
src/backend/optimizer/prep/prepagg.c | 2 +-
src/backend/optimizer/util/appendinfo.c | 2 +-
src/backend/optimizer/util/clauses.c | 14 +-
src/backend/optimizer/util/plancat.c | 8 +-
src/backend/parser/parse_clause.c | 2 +-
src/backend/parser/parse_coerce.c | 12 +-
src/backend/parser/parse_func.c | 6 +-
src/backend/parser/parse_oper.c | 10 +-
src/backend/parser/parse_relation.c | 2 +-
src/backend/parser/parse_type.c | 32 +--
src/backend/parser/parse_utilcmd.c | 22 +-
src/backend/postmaster/autovacuum.c | 20 +-
src/backend/replication/logical/launcher.c | 2 +-
src/backend/replication/logical/origin.c | 4 +-
src/backend/replication/logical/proto.c | 4 +-
src/backend/replication/logical/worker.c | 2 +-
src/backend/rewrite/rewriteDefine.c | 10 +-
src/backend/rewrite/rewriteRemove.c | 2 +-
src/backend/rewrite/rewriteSupport.c | 4 +-
src/backend/statistics/extended_stats.c | 6 +-
src/backend/storage/large_object/inv_api.c | 8 +-
src/backend/tcop/fastpath.c | 2 +-
src/backend/tsearch/ts_selfuncs.c | 2 +-
src/backend/utils/adt/acl.c | 16 +-
src/backend/utils/adt/amutils.c | 4 +-
src/backend/utils/adt/array_selfuncs.c | 4 +-
src/backend/utils/adt/dbsize.c | 4 +-
src/backend/utils/adt/domains.c | 2 +-
src/backend/utils/adt/enum.c | 16 +-
src/backend/utils/adt/format_type.c | 4 +-
src/backend/utils/adt/jsonfuncs.c | 2 +-
src/backend/utils/adt/like_support.c | 2 +-
.../utils/adt/multirangetypes_selfuncs.c | 2 +-
src/backend/utils/adt/network_selfuncs.c | 10 +-
src/backend/utils/adt/pg_locale.c | 4 +-
src/backend/utils/adt/rangetypes_selfuncs.c | 2 +-
src/backend/utils/adt/regproc.c | 22 +-
src/backend/utils/adt/ri_triggers.c | 6 +-
src/backend/utils/adt/ruleutils.c | 54 ++--
src/backend/utils/adt/selfuncs.c | 28 +-
src/backend/utils/adt/xml.c | 4 +-
src/backend/utils/cache/evtcache.c | 2 +-
src/backend/utils/cache/inval.c | 10 +-
src/backend/utils/cache/lsyscache.c | 196 +++++++-------
src/backend/utils/cache/partcache.c | 4 +-
src/backend/utils/cache/relcache.c | 44 ++--
src/backend/utils/cache/relfilenumbermap.c | 2 +-
src/backend/utils/cache/syscache.c | 4 +-
src/backend/utils/cache/ts_cache.c | 12 +-
src/backend/utils/cache/typcache.c | 12 +-
src/backend/utils/fmgr/fmgr.c | 18 +-
src/backend/utils/fmgr/funcapi.c | 6 +-
src/backend/utils/init/miscinit.c | 6 +-
src/backend/utils/init/postinit.c | 10 +-
src/backend/utils/misc/rls.c | 2 +-
src/backend/utils/misc/superuser.c | 2 +-
src/include/access/htup_details.h | 2 +-
src/pl/plperl/plperl.c | 10 +-
src/pl/plpgsql/src/pl_comp.c | 14 +-
src/pl/plpgsql/src/pl_handler.c | 2 +-
src/pl/plpython/plpy_main.c | 2 +-
src/pl/plpython/plpy_procedure.c | 6 +-
src/pl/tcl/pltcl.c | 8 +-
src/test/modules/plsample/plsample.c | 8 +-
146 files changed, 1049 insertions(+), 1049 deletions(-)
diff --git a/contrib/bloom/blvalidate.c b/contrib/bloom/blvalidate.c
index 333a35d377..fc9911d6bf 100644
--- a/contrib/bloom/blvalidate.c
+++ b/contrib/bloom/blvalidate.c
@@ -52,7 +52,7 @@ blvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -65,7 +65,7 @@ blvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -77,7 +77,7 @@ blvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/*
@@ -138,7 +138,7 @@ blvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* Check it's allowed strategy for bloom */
if (oprform->amopstrategy < 1 ||
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index e323fdd0e6..faa2a07da2 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -2075,7 +2075,7 @@ get_pkey_attnames(Relation rel, int16 *indnkeyatts)
while (HeapTupleIsValid(indexTuple = systable_getnext(scan)))
{
- Form_pg_index index = (Form_pg_index) GETSTRUCT(indexTuple);
+ Form_pg_index index = GETSTRUCT(pg_index, indexTuple);
/* we're only interested if it is the primary key */
if (index->indisprimary)
diff --git a/contrib/intarray/_int_selfuncs.c b/contrib/intarray/_int_selfuncs.c
index 3d8ff6781b..a66d5fee92 100644
--- a/contrib/intarray/_int_selfuncs.c
+++ b/contrib/intarray/_int_selfuncs.c
@@ -191,7 +191,7 @@ _int_matchsel(PG_FUNCTION_ARGS)
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
nullfrac = stats->stanullfrac;
/*
diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c
index 8f4d8a5022..63dc4e8c55 100644
--- a/contrib/postgres_fdw/deparse.c
+++ b/contrib/postgres_fdw/deparse.c
@@ -3005,7 +3005,7 @@ deparseOpExpr(OpExpr *node, deparse_expr_cxt *context)
tuple = SearchSysCache1(OPEROID, ObjectIdGetDatum(node->opno));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for operator %u", node->opno);
- form = (Form_pg_operator) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_operator, tuple);
oprkind = form->oprkind;
/* Sanity check. */
@@ -3180,7 +3180,7 @@ deparseScalarArrayOpExpr(ScalarArrayOpExpr *node, deparse_expr_cxt *context)
tuple = SearchSysCache1(OPEROID, ObjectIdGetDatum(node->opno));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for operator %u", node->opno);
- form = (Form_pg_operator) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_operator, tuple);
/* Sanity check. */
Assert(list_length(node->args) == 2);
@@ -3519,7 +3519,7 @@ appendOrderBySuffix(Oid sortop, Oid sortcoltype, bool nulls_first,
opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(sortop));
if (!HeapTupleIsValid(opertup))
elog(ERROR, "cache lookup failed for operator %u", sortop);
- operform = (Form_pg_operator) GETSTRUCT(opertup);
+ operform = GETSTRUCT(pg_operator, opertup);
deparseOperatorName(buf, operform);
ReleaseSysCache(opertup);
}
@@ -3734,7 +3734,7 @@ appendFunctionName(Oid funcid, deparse_expr_cxt *context)
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
/* Print schema name only if it's not pg_catalog */
if (procform->pronamespace != PG_CATALOG_NAMESPACE)
diff --git a/contrib/sepgsql/database.c b/contrib/sepgsql/database.c
index dce97859f4..a73d600cb8 100644
--- a/contrib/sepgsql/database.c
+++ b/contrib/sepgsql/database.c
@@ -89,7 +89,7 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for database %u", databaseId);
- datForm = (Form_pg_database) GETSTRUCT(tuple);
+ datForm = GETSTRUCT(pg_database, tuple);
ncontext = sepgsql_compute_create(sepgsql_get_client_label(),
tcontext,
diff --git a/contrib/sepgsql/dml.c b/contrib/sepgsql/dml.c
index 3bb98dfb06..114a46c2db 100644
--- a/contrib/sepgsql/dml.c
+++ b/contrib/sepgsql/dml.c
@@ -52,7 +52,7 @@ fixup_whole_row_references(Oid relOid, Bitmapset *columns)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- natts = ((Form_pg_class) GETSTRUCT(tuple))->relnatts;
+ natts = (GETSTRUCT(pg_class, tuple))->relnatts;
ReleaseSysCache(tuple);
/* remove bit 0 from column set, add in all the non-dropped columns */
@@ -67,7 +67,7 @@ fixup_whole_row_references(Oid relOid, Bitmapset *columns)
if (!HeapTupleIsValid(tuple))
continue; /* unexpected case, should we error? */
- if (!((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
+ if (!(GETSTRUCT(pg_attribute, tuple))->attisdropped)
{
index = attno - FirstLowInvalidHeapAttributeNumber;
result = bms_add_member(result, index);
diff --git a/contrib/sepgsql/label.c b/contrib/sepgsql/label.c
index e4c98b7eae..a7dd60fb90 100644
--- a/contrib/sepgsql/label.c
+++ b/contrib/sepgsql/label.c
@@ -733,7 +733,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
switch (catalogId)
{
case DatabaseRelationId:
- datForm = (Form_pg_database) GETSTRUCT(tuple);
+ datForm = GETSTRUCT(pg_database, tuple);
objtype = SELABEL_DB_DATABASE;
@@ -746,7 +746,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
break;
case NamespaceRelationId:
- nspForm = (Form_pg_namespace) GETSTRUCT(tuple);
+ nspForm = GETSTRUCT(pg_namespace, tuple);
objtype = SELABEL_DB_SCHEMA;
@@ -760,7 +760,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
break;
case RelationRelationId:
- relForm = (Form_pg_class) GETSTRUCT(tuple);
+ relForm = GETSTRUCT(pg_class, tuple);
if (relForm->relkind == RELKIND_RELATION ||
relForm->relkind == RELKIND_PARTITIONED_TABLE)
@@ -785,7 +785,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
break;
case AttributeRelationId:
- attForm = (Form_pg_attribute) GETSTRUCT(tuple);
+ attForm = GETSTRUCT(pg_attribute, tuple);
if (get_rel_relkind(attForm->attrelid) != RELKIND_RELATION &&
get_rel_relkind(attForm->attrelid) != RELKIND_PARTITIONED_TABLE)
@@ -809,7 +809,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
break;
case ProcedureRelationId:
- proForm = (Form_pg_proc) GETSTRUCT(tuple);
+ proForm = GETSTRUCT(pg_proc, tuple);
objtype = SELABEL_DB_PROCEDURE;
diff --git a/contrib/sepgsql/proc.c b/contrib/sepgsql/proc.c
index 45f006ed2a..54446cb02d 100644
--- a/contrib/sepgsql/proc.c
+++ b/contrib/sepgsql/proc.c
@@ -68,7 +68,7 @@ sepgsql_proc_post_create(Oid functionId)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for function %u", functionId);
- proForm = (Form_pg_proc) GETSTRUCT(tuple);
+ proForm = GETSTRUCT(pg_proc, tuple);
/*
* check db_schema:{add_name} permission of the namespace
@@ -260,7 +260,7 @@ sepgsql_proc_setattr(Oid functionId)
newtup = systable_getnext(sscan);
if (!HeapTupleIsValid(newtup))
elog(ERROR, "could not find tuple for function %u", functionId);
- newform = (Form_pg_proc) GETSTRUCT(newtup);
+ newform = GETSTRUCT(pg_proc, newtup);
/*
* Fetch older catalog
@@ -268,7 +268,7 @@ sepgsql_proc_setattr(Oid functionId)
oldtup = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId));
if (!HeapTupleIsValid(oldtup))
elog(ERROR, "cache lookup failed for function %u", functionId);
- oldform = (Form_pg_proc) GETSTRUCT(oldtup);
+ oldform = GETSTRUCT(pg_proc, oldtup);
/*
* Does this ALTER command takes operation to namespace?
diff --git a/contrib/sepgsql/relation.c b/contrib/sepgsql/relation.c
index 8767988c4d..1d79397448 100644
--- a/contrib/sepgsql/relation.c
+++ b/contrib/sepgsql/relation.c
@@ -84,7 +84,7 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
elog(ERROR, "could not find tuple for column %d of relation %u",
attnum, relOid);
- attForm = (Form_pg_attribute) GETSTRUCT(tuple);
+ attForm = GETSTRUCT(pg_attribute, tuple);
scontext = sepgsql_get_client_label();
tcontext = sepgsql_get_label(RelationRelationId, relOid, 0);
@@ -271,7 +271,7 @@ sepgsql_relation_post_create(Oid relOid)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for relation %u", relOid);
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/* ignore indexes on toast tables */
if (classForm->relkind == RELKIND_INDEX &&
@@ -368,7 +368,7 @@ sepgsql_relation_post_create(Oid relOid)
while (HeapTupleIsValid(atup = systable_getnext(ascan)))
{
- attForm = (Form_pg_attribute) GETSTRUCT(atup);
+ attForm = GETSTRUCT(pg_attribute, atup);
resetStringInfo(&audit_name);
appendStringInfo(&audit_name, "%s.%s.%s",
@@ -494,7 +494,7 @@ sepgsql_relation_drop(Oid relOid)
for (i = 0; i < attrList->n_members; i++)
{
atttup = &attrList->members[i]->tuple;
- attForm = (Form_pg_attribute) GETSTRUCT(atttup);
+ attForm = GETSTRUCT(pg_attribute, atttup);
if (attForm->attisdropped)
continue;
@@ -662,7 +662,7 @@ sepgsql_relation_setattr(Oid relOid)
newtup = systable_getnext(sscan);
if (!HeapTupleIsValid(newtup))
elog(ERROR, "could not find tuple for relation %u", relOid);
- newform = (Form_pg_class) GETSTRUCT(newtup);
+ newform = GETSTRUCT(pg_class, newtup);
/*
* Fetch older catalog
@@ -670,7 +670,7 @@ sepgsql_relation_setattr(Oid relOid)
oldtup = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(oldtup))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- oldform = (Form_pg_class) GETSTRUCT(oldtup);
+ oldform = GETSTRUCT(pg_class, oldtup);
/*
* Does this ALTER command takes operation to namespace?
diff --git a/contrib/sepgsql/schema.c b/contrib/sepgsql/schema.c
index fecd02f07a..28c6cb3d03 100644
--- a/contrib/sepgsql/schema.c
+++ b/contrib/sepgsql/schema.c
@@ -67,7 +67,7 @@ sepgsql_schema_post_create(Oid namespaceId)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for namespace %u", namespaceId);
- nspForm = (Form_pg_namespace) GETSTRUCT(tuple);
+ nspForm = GETSTRUCT(pg_namespace, tuple);
nsp_name = NameStr(nspForm->nspname);
if (strncmp(nsp_name, "pg_temp_", 8) == 0)
nsp_name = "pg_temp";
diff --git a/contrib/tcn/tcn.c b/contrib/tcn/tcn.c
index a2de6c385c..ff9990e044 100644
--- a/contrib/tcn/tcn.c
+++ b/contrib/tcn/tcn.c
@@ -134,7 +134,7 @@ triggered_change_notification(PG_FUNCTION_ARGS)
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple)) /* should not happen */
elog(ERROR, "cache lookup failed for index %u", indexoid);
- index = (Form_pg_index) GETSTRUCT(indexTuple);
+ index = GETSTRUCT(pg_index, indexTuple);
/* we're only interested if it is the primary key and valid */
if (index->indisprimary && index->indisvalid)
{
diff --git a/src/backend/access/brin/brin_validate.c b/src/backend/access/brin/brin_validate.c
index c54c874bc0..06c60b6780 100644
--- a/src/backend/access/brin/brin_validate.c
+++ b/src/backend/access/brin/brin_validate.c
@@ -58,7 +58,7 @@ brinvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -68,7 +68,7 @@ brinvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -80,7 +80,7 @@ brinvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/* Check procedure numbers and function signatures */
@@ -146,7 +146,7 @@ brinvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* Check that only allowed strategy numbers exist */
if (oprform->amopstrategy < 1 || oprform->amopstrategy > 63)
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index 609329bb21..e58c1ff436 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -1393,7 +1393,7 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc,
if (isnull)
return NULL;
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/* Parse into appropriate format; don't error out here */
switch (classForm->relkind)
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index d6fb261e20..dfad4a8dfa 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -635,7 +635,7 @@ TupleDescInitEntry(TupleDesc desc,
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(oidtypeid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", oidtypeid);
- typeForm = (Form_pg_type) GETSTRUCT(tuple);
+ typeForm = GETSTRUCT(pg_type, tuple);
att->atttypid = oidtypeid;
att->attlen = typeForm->typlen;
diff --git a/src/backend/access/gin/ginvalidate.c b/src/backend/access/gin/ginvalidate.c
index 44f2ff205d..a873ab8b70 100644
--- a/src/backend/access/gin/ginvalidate.c
+++ b/src/backend/access/gin/ginvalidate.c
@@ -53,7 +53,7 @@ ginvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -66,7 +66,7 @@ ginvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -78,7 +78,7 @@ ginvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/*
@@ -172,7 +172,7 @@ ginvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* TODO: Check that only allowed strategy numbers exist */
if (oprform->amopstrategy < 1 || oprform->amopstrategy > 63)
diff --git a/src/backend/access/gist/gistvalidate.c b/src/backend/access/gist/gistvalidate.c
index 95beca05fe..ce87ea3f9e 100644
--- a/src/backend/access/gist/gistvalidate.c
+++ b/src/backend/access/gist/gistvalidate.c
@@ -54,7 +54,7 @@ gistvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -67,7 +67,7 @@ gistvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -79,7 +79,7 @@ gistvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/*
@@ -174,7 +174,7 @@ gistvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
Oid op_rettype;
/* TODO: Check that only allowed strategy numbers exist */
diff --git a/src/backend/access/hash/hashvalidate.c b/src/backend/access/hash/hashvalidate.c
index 10bf26ce7c..8f8712a552 100644
--- a/src/backend/access/hash/hashvalidate.c
+++ b/src/backend/access/hash/hashvalidate.c
@@ -67,7 +67,7 @@ hashvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -77,7 +77,7 @@ hashvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -89,7 +89,7 @@ hashvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
/*
* All hash functions should be registered with matching left/right
@@ -149,7 +149,7 @@ hashvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* Check that only allowed strategy numbers exist */
if (oprform->amopstrategy < 1 ||
@@ -299,7 +299,7 @@ check_hash_func_signature(Oid funcid, int16 amprocnum, Oid argtype)
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(tp);
+ procform = GETSTRUCT(pg_proc, tp);
if (procform->prorettype != restype || procform->proretset ||
procform->pronargs != nargs)
diff --git a/src/backend/access/index/amapi.c b/src/backend/access/index/amapi.c
index 2b028e1950..243d80c2e5 100644
--- a/src/backend/access/index/amapi.c
+++ b/src/backend/access/index/amapi.c
@@ -68,7 +68,7 @@ GetIndexAmRoutineByAmId(Oid amoid, bool noerror)
elog(ERROR, "cache lookup failed for access method %u",
amoid);
}
- amform = (Form_pg_am) GETSTRUCT(tuple);
+ amform = GETSTRUCT(pg_am, tuple);
/* Check if it's an index access method as opposed to some other AM */
if (amform->amtype != AMTYPE_INDEX)
@@ -123,7 +123,7 @@ amvalidate(PG_FUNCTION_ARGS)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
amoid = classform->opcmethod;
diff --git a/src/backend/access/index/amvalidate.c b/src/backend/access/index/amvalidate.c
index d13054e33f..89b5ade49a 100644
--- a/src/backend/access/index/amvalidate.c
+++ b/src/backend/access/index/amvalidate.c
@@ -62,14 +62,14 @@ identify_opfamily_groups(CatCList *oprlist, CatCList *proclist)
io = ip = 0;
if (io < oprlist->n_members)
{
- oprform = (Form_pg_amop) GETSTRUCT(&oprlist->members[io]->tuple);
+ oprform = GETSTRUCT(pg_amop, &oprlist->members[io]->tuple);
io++;
}
else
oprform = NULL;
if (ip < proclist->n_members)
{
- procform = (Form_pg_amproc) GETSTRUCT(&proclist->members[ip]->tuple);
+ procform = GETSTRUCT(pg_amproc, &proclist->members[ip]->tuple);
ip++;
}
else
@@ -89,7 +89,7 @@ identify_opfamily_groups(CatCList *oprlist, CatCList *proclist)
if (io < oprlist->n_members)
{
- oprform = (Form_pg_amop) GETSTRUCT(&oprlist->members[io]->tuple);
+ oprform = GETSTRUCT(pg_amop, &oprlist->members[io]->tuple);
io++;
}
else
@@ -109,7 +109,7 @@ identify_opfamily_groups(CatCList *oprlist, CatCList *proclist)
if (ip < proclist->n_members)
{
- procform = (Form_pg_amproc) GETSTRUCT(&proclist->members[ip]->tuple);
+ procform = GETSTRUCT(pg_amproc, &proclist->members[ip]->tuple);
ip++;
}
else
@@ -161,7 +161,7 @@ check_amproc_signature(Oid funcid, Oid restype, bool exact,
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(tp);
+ procform = GETSTRUCT(pg_proc, tp);
if (procform->prorettype != restype || procform->proretset ||
procform->pronargs < minargs || procform->pronargs > maxargs)
@@ -212,7 +212,7 @@ check_amop_signature(Oid opno, Oid restype, Oid lefttype, Oid righttype)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for operator %u", opno);
- opform = (Form_pg_operator) GETSTRUCT(tp);
+ opform = GETSTRUCT(pg_operator, tp);
if (opform->oprresult != restype || opform->oprkind != 'b' ||
opform->oprleft != lefttype || opform->oprright != righttype)
@@ -249,7 +249,7 @@ opclass_for_family_datatype(Oid amoid, Oid opfamilyoid, Oid datatypeoid)
for (i = 0; i < opclist->n_members; i++)
{
HeapTuple classtup = &opclist->members[i]->tuple;
- Form_pg_opclass classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ Form_pg_opclass classform = GETSTRUCT(pg_opclass, classtup);
if (classform->opcfamily == opfamilyoid &&
classform->opcintype == datatypeoid)
diff --git a/src/backend/access/nbtree/nbtvalidate.c b/src/backend/access/nbtree/nbtvalidate.c
index 55ed3251d3..05d3c6707e 100644
--- a/src/backend/access/nbtree/nbtvalidate.c
+++ b/src/backend/access/nbtree/nbtvalidate.c
@@ -62,7 +62,7 @@ btvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -72,7 +72,7 @@ btvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -84,7 +84,7 @@ btvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/* Check procedure numbers and function signatures */
@@ -141,7 +141,7 @@ btvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* Check that only allowed strategy numbers exist */
if (oprform->amopstrategy < 1 ||
diff --git a/src/backend/access/spgist/spgutils.c b/src/backend/access/spgist/spgutils.c
index 2c661fcf96..93ed425c29 100644
--- a/src/backend/access/spgist/spgutils.c
+++ b/src/backend/access/spgist/spgutils.c
@@ -163,7 +163,7 @@ fillTypeDesc(SpGistTypeDesc *desc, Oid type)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", type);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
desc->attlen = typtup->typlen;
desc->attbyval = typtup->typbyval;
desc->attalign = typtup->typalign;
@@ -1328,7 +1328,7 @@ spgproperty(Oid index_oid, int attno,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple amoptup = &catlist->members[i]->tuple;
- Form_pg_amop amopform = (Form_pg_amop) GETSTRUCT(amoptup);
+ Form_pg_amop amopform = GETSTRUCT(pg_amop, amoptup);
if (amopform->amoppurpose == AMOP_ORDER &&
(amopform->amoplefttype == opcintype ||
diff --git a/src/backend/access/spgist/spgvalidate.c b/src/backend/access/spgist/spgvalidate.c
index 82281f7b83..ab055f9371 100644
--- a/src/backend/access/spgist/spgvalidate.c
+++ b/src/backend/access/spgist/spgvalidate.c
@@ -64,7 +64,7 @@ spgvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -75,7 +75,7 @@ spgvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -88,7 +88,7 @@ spgvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/*
@@ -210,7 +210,7 @@ spgvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
Oid op_rettype;
/* TODO: Check that only allowed strategy numbers exist */
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 088556ab54..3a718201f3 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -720,7 +720,7 @@ populate_typ_list(void)
old = MemoryContextSwitchTo(TopMemoryContext);
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_type typForm = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typForm = GETSTRUCT(pg_type, tup);
struct typmap *newtyp;
newtyp = (struct typmap *) palloc(sizeof(struct typmap));
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index 5f1726c095..913fdbbea0 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -884,7 +884,7 @@ objectsInSchemaToOids(ObjectType objtype, List *nspnames)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Oid oid = ((Form_pg_proc) GETSTRUCT(tuple))->oid;
+ Oid oid = (GETSTRUCT(pg_proc, tuple))->oid;
objects = lappend_oid(objects, oid);
}
@@ -931,7 +931,7 @@ getRelationsInNamespace(Oid namespaceId, char relkind)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Oid oid = ((Form_pg_class) GETSTRUCT(tuple))->oid;
+ Oid oid = (GETSTRUCT(pg_class, tuple))->oid;
relations = lappend_oid(relations, oid);
}
@@ -1333,7 +1333,7 @@ SetDefaultACL(InternalDefaultACL *iacls)
* there shouldn't be anything depending on this entry.
*/
myself.classId = DefaultAclRelationId;
- myself.objectId = ((Form_pg_default_acl) GETSTRUCT(tuple))->oid;
+ myself.objectId = (GETSTRUCT(pg_default_acl, tuple))->oid;
myself.objectSubId = 0;
performDeletion(&myself, DROP_RESTRICT, 0);
@@ -1364,7 +1364,7 @@ SetDefaultACL(InternalDefaultACL *iacls)
}
else
{
- defAclOid = ((Form_pg_default_acl) GETSTRUCT(tuple))->oid;
+ defAclOid = (GETSTRUCT(pg_default_acl, tuple))->oid;
/* update existing entry */
values[Anum_pg_default_acl_defaclacl - 1] = PointerGetDatum(new_acl);
@@ -1460,7 +1460,7 @@ RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for default ACL %u", objid);
- pg_default_acl_tuple = (Form_pg_default_acl) GETSTRUCT(tuple);
+ pg_default_acl_tuple = GETSTRUCT(pg_default_acl, tuple);
iacls.roleid = pg_default_acl_tuple->defaclrole;
iacls.nspid = pg_default_acl_tuple->defaclnamespace;
@@ -1630,7 +1630,7 @@ expand_all_col_privileges(Oid table_oid, Form_pg_class classForm,
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
curr_att, table_oid);
- isdropped = ((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped;
+ isdropped = (GETSTRUCT(pg_attribute, attTuple))->attisdropped;
ReleaseSysCache(attTuple);
@@ -1676,7 +1676,7 @@ ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname,
if (!HeapTupleIsValid(attr_tuple))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relOid);
- pg_attribute_tuple = (Form_pg_attribute) GETSTRUCT(attr_tuple);
+ pg_attribute_tuple = GETSTRUCT(pg_attribute, attr_tuple);
/*
* Get working copy of existing ACL. If there's no ACL, substitute the
@@ -1825,7 +1825,7 @@ ExecGrant_Relation(InternalGrant *istmt)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
+ pg_class_tuple = GETSTRUCT(pg_class, tuple);
/* Not sensible to grant on an index */
if (pg_class_tuple->relkind == RELKIND_INDEX ||
@@ -2163,7 +2163,7 @@ ExecGrant_Database(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for database %u", datId);
- pg_database_tuple = (Form_pg_database) GETSTRUCT(tuple);
+ pg_database_tuple = GETSTRUCT(pg_database, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2284,7 +2284,7 @@ ExecGrant_Fdw(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for foreign-data wrapper %u", fdwid);
- pg_fdw_tuple = (Form_pg_foreign_data_wrapper) GETSTRUCT(tuple);
+ pg_fdw_tuple = GETSTRUCT(pg_foreign_data_wrapper, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2410,7 +2410,7 @@ ExecGrant_ForeignServer(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for foreign server %u", srvid);
- pg_server_tuple = (Form_pg_foreign_server) GETSTRUCT(tuple);
+ pg_server_tuple = GETSTRUCT(pg_foreign_server, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2535,7 +2535,7 @@ ExecGrant_Function(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcId);
- pg_proc_tuple = (Form_pg_proc) GETSTRUCT(tuple);
+ pg_proc_tuple = GETSTRUCT(pg_proc, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2658,7 +2658,7 @@ ExecGrant_Language(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for language %u", langId);
- pg_language_tuple = (Form_pg_language) GETSTRUCT(tuple);
+ pg_language_tuple = GETSTRUCT(pg_language, tuple);
if (!pg_language_tuple->lanpltrusted)
ereport(ERROR,
@@ -2803,7 +2803,7 @@ ExecGrant_Largeobject(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for large object %u", loid);
- form_lo_meta = (Form_pg_largeobject_metadata) GETSTRUCT(tuple);
+ form_lo_meta = GETSTRUCT(pg_largeobject_metadata, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2929,7 +2929,7 @@ ExecGrant_Namespace(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for namespace %u", nspid);
- pg_namespace_tuple = (Form_pg_namespace) GETSTRUCT(tuple);
+ pg_namespace_tuple = GETSTRUCT(pg_namespace, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -3054,7 +3054,7 @@ ExecGrant_Tablespace(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for tablespace %u", tblId);
- pg_tablespace_tuple = (Form_pg_tablespace) GETSTRUCT(tuple);
+ pg_tablespace_tuple = GETSTRUCT(pg_tablespace, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -3174,7 +3174,7 @@ ExecGrant_Type(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", typId);
- pg_type_tuple = (Form_pg_type) GETSTRUCT(tuple);
+ pg_type_tuple = GETSTRUCT(pg_type, tuple);
if (IsTrueArrayType(pg_type_tuple))
ereport(ERROR,
@@ -3958,7 +3958,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
attnum, table_oid)));
}
- attributeForm = (Form_pg_attribute) GETSTRUCT(attTuple);
+ attributeForm = GETSTRUCT(pg_attribute, attTuple);
/* Check dropped columns, too */
if (attributeForm->attisdropped)
@@ -4005,7 +4005,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
ReleaseSysCache(attTuple);
return 0;
}
- classForm = (Form_pg_class) GETSTRUCT(classTuple);
+ classForm = GETSTRUCT(pg_class, classTuple);
ownerId = classForm->relowner;
@@ -4072,7 +4072,7 @@ pg_class_aclmask_ext(Oid table_oid, Oid roleid, AclMode mask,
table_oid)));
}
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/*
* Deny anyone permission to update a system catalog unless
@@ -4183,7 +4183,7 @@ pg_database_aclmask(Oid db_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database with OID %u does not exist", db_oid)));
- ownerId = ((Form_pg_database) GETSTRUCT(tuple))->datdba;
+ ownerId = (GETSTRUCT(pg_database, tuple))->datdba;
aclDatum = SysCacheGetAttr(DATABASEOID, tuple, Anum_pg_database_datacl,
&isNull);
@@ -4352,7 +4352,7 @@ pg_proc_aclmask(Oid proc_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function with OID %u does not exist", proc_oid)));
- ownerId = ((Form_pg_proc) GETSTRUCT(tuple))->proowner;
+ ownerId = (GETSTRUCT(pg_proc, tuple))->proowner;
aclDatum = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_proacl,
&isNull);
@@ -4406,7 +4406,7 @@ pg_language_aclmask(Oid lang_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("language with OID %u does not exist", lang_oid)));
- ownerId = ((Form_pg_language) GETSTRUCT(tuple))->lanowner;
+ ownerId = (GETSTRUCT(pg_language, tuple))->lanowner;
aclDatum = SysCacheGetAttr(LANGOID, tuple, Anum_pg_language_lanacl,
&isNull);
@@ -4485,7 +4485,7 @@ pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("large object %u does not exist", lobj_oid)));
- ownerId = ((Form_pg_largeobject_metadata) GETSTRUCT(tuple))->lomowner;
+ ownerId = (GETSTRUCT(pg_largeobject_metadata, tuple))->lomowner;
aclDatum = heap_getattr(tuple, Anum_pg_largeobject_metadata_lomacl,
RelationGetDescr(pg_lo_meta), &isNull);
@@ -4570,7 +4570,7 @@ pg_namespace_aclmask(Oid nsp_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema with OID %u does not exist", nsp_oid)));
- ownerId = ((Form_pg_namespace) GETSTRUCT(tuple))->nspowner;
+ ownerId = (GETSTRUCT(pg_namespace, tuple))->nspowner;
aclDatum = SysCacheGetAttr(NAMESPACEOID, tuple, Anum_pg_namespace_nspacl,
&isNull);
@@ -4634,7 +4634,7 @@ pg_tablespace_aclmask(Oid spc_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("tablespace with OID %u does not exist", spc_oid)));
- ownerId = ((Form_pg_tablespace) GETSTRUCT(tuple))->spcowner;
+ ownerId = (GETSTRUCT(pg_tablespace, tuple))->spcowner;
aclDatum = SysCacheGetAttr(TABLESPACEOID, tuple,
Anum_pg_tablespace_spcacl,
@@ -4693,7 +4693,7 @@ pg_foreign_data_wrapper_aclmask(Oid fdw_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign-data wrapper with OID %u does not exist",
fdw_oid)));
- fdwForm = (Form_pg_foreign_data_wrapper) GETSTRUCT(tuple);
+ fdwForm = GETSTRUCT(pg_foreign_data_wrapper, tuple);
/*
* Normal case: get the FDW's ACL from pg_foreign_data_wrapper
@@ -4755,7 +4755,7 @@ pg_foreign_server_aclmask(Oid srv_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign server with OID %u does not exist",
srv_oid)));
- srvForm = (Form_pg_foreign_server) GETSTRUCT(tuple);
+ srvForm = GETSTRUCT(pg_foreign_server, tuple);
/*
* Normal case: get the foreign server's ACL from pg_foreign_server
@@ -4815,7 +4815,7 @@ pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type with OID %u does not exist",
type_oid)));
- typeForm = (Form_pg_type) GETSTRUCT(tuple);
+ typeForm = GETSTRUCT(pg_type, tuple);
/*
* "True" array types don't manage permissions of their own; consult the
@@ -4831,7 +4831,7 @@ pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how)
/* this case is not a user-facing error, so elog not ereport */
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", elttype_oid);
- typeForm = (Form_pg_type) GETSTRUCT(tuple);
+ typeForm = GETSTRUCT(pg_type, tuple);
}
/*
@@ -4936,7 +4936,7 @@ pg_attribute_aclcheck_all(Oid table_oid, Oid roleid, AclMode mode,
classTuple = SearchSysCache1(RELOID, ObjectIdGetDatum(table_oid));
if (!HeapTupleIsValid(classTuple))
return ACLCHECK_NO_PRIV;
- classForm = (Form_pg_class) GETSTRUCT(classTuple);
+ classForm = GETSTRUCT(pg_class, classTuple);
nattrs = classForm->relnatts;
@@ -4960,7 +4960,7 @@ pg_attribute_aclcheck_all(Oid table_oid, Oid roleid, AclMode mode,
continue;
/* ignore dropped columns */
- if (((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped)
+ if ((GETSTRUCT(pg_attribute, attTuple))->attisdropped)
{
ReleaseSysCache(attTuple);
continue;
@@ -5183,7 +5183,7 @@ pg_class_ownercheck(Oid class_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_TABLE),
errmsg("relation with OID %u does not exist", class_oid)));
- ownerId = ((Form_pg_class) GETSTRUCT(tuple))->relowner;
+ ownerId = (GETSTRUCT(pg_class, tuple))->relowner;
ReleaseSysCache(tuple);
@@ -5209,7 +5209,7 @@ pg_type_ownercheck(Oid type_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type with OID %u does not exist", type_oid)));
- ownerId = ((Form_pg_type) GETSTRUCT(tuple))->typowner;
+ ownerId = (GETSTRUCT(pg_type, tuple))->typowner;
ReleaseSysCache(tuple);
@@ -5235,7 +5235,7 @@ pg_oper_ownercheck(Oid oper_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("operator with OID %u does not exist", oper_oid)));
- ownerId = ((Form_pg_operator) GETSTRUCT(tuple))->oprowner;
+ ownerId = (GETSTRUCT(pg_operator, tuple))->oprowner;
ReleaseSysCache(tuple);
@@ -5261,7 +5261,7 @@ pg_proc_ownercheck(Oid proc_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function with OID %u does not exist", proc_oid)));
- ownerId = ((Form_pg_proc) GETSTRUCT(tuple))->proowner;
+ ownerId = (GETSTRUCT(pg_proc, tuple))->proowner;
ReleaseSysCache(tuple);
@@ -5287,7 +5287,7 @@ pg_language_ownercheck(Oid lan_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("language with OID %u does not exist", lan_oid)));
- ownerId = ((Form_pg_language) GETSTRUCT(tuple))->lanowner;
+ ownerId = (GETSTRUCT(pg_language, tuple))->lanowner;
ReleaseSysCache(tuple);
@@ -5332,7 +5332,7 @@ pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("large object %u does not exist", lobj_oid)));
- ownerId = ((Form_pg_largeobject_metadata) GETSTRUCT(tuple))->lomowner;
+ ownerId = (GETSTRUCT(pg_largeobject_metadata, tuple))->lomowner;
systable_endscan(scan);
table_close(pg_lo_meta, AccessShareLock);
@@ -5359,7 +5359,7 @@ pg_namespace_ownercheck(Oid nsp_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema with OID %u does not exist", nsp_oid)));
- ownerId = ((Form_pg_namespace) GETSTRUCT(tuple))->nspowner;
+ ownerId = (GETSTRUCT(pg_namespace, tuple))->nspowner;
ReleaseSysCache(tuple);
@@ -5386,7 +5386,7 @@ pg_tablespace_ownercheck(Oid spc_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("tablespace with OID %u does not exist", spc_oid)));
- spcowner = ((Form_pg_tablespace) GETSTRUCT(spctuple))->spcowner;
+ spcowner = (GETSTRUCT(pg_tablespace, spctuple))->spcowner;
ReleaseSysCache(spctuple);
@@ -5413,7 +5413,7 @@ pg_opclass_ownercheck(Oid opc_oid, Oid roleid)
errmsg("operator class with OID %u does not exist",
opc_oid)));
- ownerId = ((Form_pg_opclass) GETSTRUCT(tuple))->opcowner;
+ ownerId = (GETSTRUCT(pg_opclass, tuple))->opcowner;
ReleaseSysCache(tuple);
@@ -5440,7 +5440,7 @@ pg_opfamily_ownercheck(Oid opf_oid, Oid roleid)
errmsg("operator family with OID %u does not exist",
opf_oid)));
- ownerId = ((Form_pg_opfamily) GETSTRUCT(tuple))->opfowner;
+ ownerId = (GETSTRUCT(pg_opfamily, tuple))->opfowner;
ReleaseSysCache(tuple);
@@ -5467,7 +5467,7 @@ pg_ts_dict_ownercheck(Oid dict_oid, Oid roleid)
errmsg("text search dictionary with OID %u does not exist",
dict_oid)));
- ownerId = ((Form_pg_ts_dict) GETSTRUCT(tuple))->dictowner;
+ ownerId = (GETSTRUCT(pg_ts_dict, tuple))->dictowner;
ReleaseSysCache(tuple);
@@ -5494,7 +5494,7 @@ pg_ts_config_ownercheck(Oid cfg_oid, Oid roleid)
errmsg("text search configuration with OID %u does not exist",
cfg_oid)));
- ownerId = ((Form_pg_ts_config) GETSTRUCT(tuple))->cfgowner;
+ ownerId = (GETSTRUCT(pg_ts_config, tuple))->cfgowner;
ReleaseSysCache(tuple);
@@ -5521,7 +5521,7 @@ pg_foreign_data_wrapper_ownercheck(Oid srv_oid, Oid roleid)
errmsg("foreign-data wrapper with OID %u does not exist",
srv_oid)));
- ownerId = ((Form_pg_foreign_data_wrapper) GETSTRUCT(tuple))->fdwowner;
+ ownerId = (GETSTRUCT(pg_foreign_data_wrapper, tuple))->fdwowner;
ReleaseSysCache(tuple);
@@ -5548,7 +5548,7 @@ pg_foreign_server_ownercheck(Oid srv_oid, Oid roleid)
errmsg("foreign server with OID %u does not exist",
srv_oid)));
- ownerId = ((Form_pg_foreign_server) GETSTRUCT(tuple))->srvowner;
+ ownerId = (GETSTRUCT(pg_foreign_server, tuple))->srvowner;
ReleaseSysCache(tuple);
@@ -5575,7 +5575,7 @@ pg_event_trigger_ownercheck(Oid et_oid, Oid roleid)
errmsg("event trigger with OID %u does not exist",
et_oid)));
- ownerId = ((Form_pg_event_trigger) GETSTRUCT(tuple))->evtowner;
+ ownerId = (GETSTRUCT(pg_event_trigger, tuple))->evtowner;
ReleaseSysCache(tuple);
@@ -5601,7 +5601,7 @@ pg_database_ownercheck(Oid db_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database with OID %u does not exist", db_oid)));
- dba = ((Form_pg_database) GETSTRUCT(tuple))->datdba;
+ dba = (GETSTRUCT(pg_database, tuple))->datdba;
ReleaseSysCache(tuple);
@@ -5627,7 +5627,7 @@ pg_collation_ownercheck(Oid coll_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("collation with OID %u does not exist", coll_oid)));
- ownerId = ((Form_pg_collation) GETSTRUCT(tuple))->collowner;
+ ownerId = (GETSTRUCT(pg_collation, tuple))->collowner;
ReleaseSysCache(tuple);
@@ -5653,7 +5653,7 @@ pg_conversion_ownercheck(Oid conv_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("conversion with OID %u does not exist", conv_oid)));
- ownerId = ((Form_pg_conversion) GETSTRUCT(tuple))->conowner;
+ ownerId = (GETSTRUCT(pg_conversion, tuple))->conowner;
ReleaseSysCache(tuple);
@@ -5694,7 +5694,7 @@ pg_extension_ownercheck(Oid ext_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("extension with OID %u does not exist", ext_oid)));
- ownerId = ((Form_pg_extension) GETSTRUCT(tuple))->extowner;
+ ownerId = (GETSTRUCT(pg_extension, tuple))->extowner;
systable_endscan(scan);
table_close(pg_extension, AccessShareLock);
@@ -5721,7 +5721,7 @@ pg_publication_ownercheck(Oid pub_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("publication with OID %u does not exist", pub_oid)));
- ownerId = ((Form_pg_publication) GETSTRUCT(tuple))->pubowner;
+ ownerId = (GETSTRUCT(pg_publication, tuple))->pubowner;
ReleaseSysCache(tuple);
@@ -5747,7 +5747,7 @@ pg_subscription_ownercheck(Oid sub_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("subscription with OID %u does not exist", sub_oid)));
- ownerId = ((Form_pg_subscription) GETSTRUCT(tuple))->subowner;
+ ownerId = (GETSTRUCT(pg_subscription, tuple))->subowner;
ReleaseSysCache(tuple);
@@ -5774,7 +5774,7 @@ pg_statistics_object_ownercheck(Oid stat_oid, Oid roleid)
errmsg("statistics object with OID %u does not exist",
stat_oid)));
- ownerId = ((Form_pg_statistic_ext) GETSTRUCT(tuple))->stxowner;
+ ownerId = (GETSTRUCT(pg_statistic_ext, tuple))->stxowner;
ReleaseSysCache(tuple);
@@ -5805,7 +5805,7 @@ has_createrole_privilege(Oid roleid)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolcreaterole;
+ result = (GETSTRUCT(pg_authid, utup))->rolcreaterole;
ReleaseSysCache(utup);
}
return result;
@@ -5824,7 +5824,7 @@ has_bypassrls_privilege(Oid roleid)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolbypassrls;
+ result = (GETSTRUCT(pg_authid, utup))->rolbypassrls;
ReleaseSysCache(utup);
}
return result;
@@ -5996,7 +5996,7 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", objoid);
- pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
+ pg_class_tuple = GETSTRUCT(pg_class, tuple);
/*
* Indexes don't have permissions, neither do the pg_class rows for
@@ -6033,7 +6033,7 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
continue;
/* ignore dropped columns */
- if (((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped)
+ if ((GETSTRUCT(pg_attribute, attTuple))->attisdropped)
{
ReleaseSysCache(attTuple);
continue;
@@ -6290,7 +6290,7 @@ removeExtObjInitPriv(Oid objoid, Oid classoid)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", objoid);
- pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
+ pg_class_tuple = GETSTRUCT(pg_class, tuple);
/*
* Indexes don't have permissions, neither do the pg_class rows for
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 6f43870779..31e06aab3e 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -629,7 +629,7 @@ pg_nextoid(PG_FUNCTION_ARGS)
errmsg("column \"%s\" of relation \"%s\" does not exist",
NameStr(*attname), RelationGetRelationName(rel))));
- attform = ((Form_pg_attribute) GETSTRUCT(atttuple));
+ attform = (GETSTRUCT(pg_attribute, atttuple));
attno = attform->attnum;
if (attform->atttypid != OIDOID)
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index de10923391..4c96444617 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -577,7 +577,7 @@ findDependentObjects(const ObjectAddress *object,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend foundDep = GETSTRUCT(pg_depend, tup);
otherObject.classId = foundDep->refclassid;
otherObject.objectId = foundDep->refobjid;
@@ -866,7 +866,7 @@ findDependentObjects(const ObjectAddress *object,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend foundDep = GETSTRUCT(pg_depend, tup);
int subflags;
otherObject.classId = foundDep->classid;
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index e770ea6eb8..3c4778a5d4 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -1664,7 +1664,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- attStruct = (Form_pg_attribute) GETSTRUCT(tuple);
+ attStruct = GETSTRUCT(pg_attribute, tuple);
if (attnum < 0)
{
@@ -1776,7 +1776,7 @@ heap_drop_with_catalog(Oid relid)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- if (((Form_pg_class) GETSTRUCT(tuple))->relispartition)
+ if ((GETSTRUCT(pg_class, tuple))->relispartition)
{
/*
* We have to lock the parent if the partition is being detached,
@@ -1973,7 +1973,7 @@ RelationClearMissing(Relation rel)
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ attrtuple = GETSTRUCT(pg_attribute, tuple);
/* ignore any where atthasmissing is not true */
if (attrtuple->atthasmissing)
@@ -2032,7 +2032,7 @@ SetAttrMissing(Oid relid, char *attname, char *value)
if (!HeapTupleIsValid(atttup))
elog(ERROR, "cache lookup failed for attribute %s of relation %u",
attname, relid);
- attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
+ attStruct = GETSTRUCT(pg_attribute, atttup);
/* get an array value from the value string */
missingval = OidFunctionCall3(F_ARRAY_IN,
@@ -2536,7 +2536,7 @@ MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr,
/* There can be at most one matching row */
if (HeapTupleIsValid(tup = systable_getnext(conscan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tup);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tup);
/* Found it. Conflicts if not identical check constraint */
if (con->contype == CONSTRAINT_CHECK)
@@ -2605,7 +2605,7 @@ MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr,
ccname)));
tup = heap_copytuple(tup);
- con = (Form_pg_constraint) GETSTRUCT(tup);
+ con = GETSTRUCT(pg_constraint, tup);
/*
* In case of partitions, an inherited constraint must be inherited
@@ -2663,7 +2663,7 @@ SetRelationNumChecks(Relation rel, int numchecks)
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(rel));
- relStruct = (Form_pg_class) GETSTRUCT(reltup);
+ relStruct = GETSTRUCT(pg_class, reltup);
if (relStruct->relchecks != numchecks)
{
@@ -2882,7 +2882,7 @@ CopyStatistics(Oid fromrelid, Oid torelid)
/* make a modifiable copy */
tup = heap_copytuple(tup);
- statform = (Form_pg_statistic) GETSTRUCT(tup);
+ statform = GETSTRUCT(pg_statistic, tup);
/* update the copy of the tuple and insert it */
statform->starelid = torelid;
@@ -3207,7 +3207,7 @@ restart:
while (HeapTupleIsValid(tuple = systable_getnext(fkeyScan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
/* Not a foreign key */
if (con->contype != CONSTRAINT_FOREIGN)
@@ -3259,7 +3259,7 @@ restart:
tuple = systable_getnext(fkeyScan);
if (HeapTupleIsValid(tuple))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
/*
* pg_constraint rows always appear for partitioned hierarchies
@@ -3486,7 +3486,7 @@ StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
Form_pg_class classForm;
bool isnull;
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
Assert(!classForm->relispartition);
(void) SysCacheGetAttr(RELOID, tuple, Anum_pg_class_relpartbound,
&isnull);
@@ -3504,7 +3504,7 @@ StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
newtuple = heap_modify_tuple(tuple, RelationGetDescr(classRel),
new_val, new_null, new_repl);
/* Also set the flag */
- ((Form_pg_class) GETSTRUCT(newtuple))->relispartition = true;
+ (GETSTRUCT(pg_class, newtuple))->relispartition = true;
CatalogTupleUpdate(classRel, &newtuple->t_self, newtuple);
heap_freetuple(newtuple);
table_close(classRel, RowExclusiveLock);
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index c5d463ac55..bd909be6d1 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -170,7 +170,7 @@ relationHasPrimaryKey(Relation rel)
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple)) /* should not happen */
elog(ERROR, "cache lookup failed for index %u", indexoid);
- result = ((Form_pg_index) GETSTRUCT(indexTuple))->indisprimary;
+ result = (GETSTRUCT(pg_index, indexTuple))->indisprimary;
ReleaseSysCache(indexTuple);
if (result)
break;
@@ -251,7 +251,7 @@ index_check_primary_key(Relation heapRel,
if (!HeapTupleIsValid(atttuple))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, RelationGetRelid(heapRel));
- attform = (Form_pg_attribute) GETSTRUCT(atttuple);
+ attform = GETSTRUCT(pg_attribute, atttuple);
if (!attform->attnotnull)
ereport(ERROR,
@@ -369,7 +369,7 @@ ConstructTupleDescriptor(Relation heapRelation,
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(keyType));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", keyType);
- typeTup = (Form_pg_type) GETSTRUCT(tuple);
+ typeTup = GETSTRUCT(pg_type, tuple);
/*
* Assign some of the attributes values. Leave the rest.
@@ -426,7 +426,7 @@ ConstructTupleDescriptor(Relation heapRelation,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for opclass %u",
classObjectId[i]);
- opclassTup = (Form_pg_opclass) GETSTRUCT(tuple);
+ opclassTup = GETSTRUCT(pg_opclass, tuple);
if (OidIsValid(opclassTup->opckeytype))
keyType = opclassTup->opckeytype;
@@ -459,7 +459,7 @@ ConstructTupleDescriptor(Relation heapRelation,
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(keyType));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", keyType);
- typeTup = (Form_pg_type) GETSTRUCT(tuple);
+ typeTup = GETSTRUCT(pg_type, tuple);
to->atttypid = keyType;
to->atttypmod = -1;
@@ -812,7 +812,7 @@ index_create(Relation heapRelation,
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("nondeterministic collations are not supported for operator class \"%s\"",
- NameStr(((Form_pg_opclass) GETSTRUCT(classtup))->opcname))));
+ NameStr((GETSTRUCT(pg_opclass, classtup))->opcname))));
ReleaseSysCache(classtup);
}
}
@@ -1547,8 +1547,8 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
if (!HeapTupleIsValid(newClassTuple))
elog(ERROR, "could not find tuple for relation %u", newIndexId);
- oldClassForm = (Form_pg_class) GETSTRUCT(oldClassTuple);
- newClassForm = (Form_pg_class) GETSTRUCT(newClassTuple);
+ oldClassForm = GETSTRUCT(pg_class, oldClassTuple);
+ newClassForm = GETSTRUCT(pg_class, newClassTuple);
/* Swap the names */
namestrcpy(&newClassForm->relname, NameStr(oldClassForm->relname));
@@ -1577,8 +1577,8 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
if (!HeapTupleIsValid(newIndexTuple))
elog(ERROR, "could not find tuple for relation %u", newIndexId);
- oldIndexForm = (Form_pg_index) GETSTRUCT(oldIndexTuple);
- newIndexForm = (Form_pg_index) GETSTRUCT(newIndexTuple);
+ oldIndexForm = GETSTRUCT(pg_index, oldIndexTuple);
+ newIndexForm = GETSTRUCT(pg_index, newIndexTuple);
/*
* Copy constraint flags from the old index. This is safe because the old
@@ -1641,7 +1641,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
if (!HeapTupleIsValid(constraintTuple))
elog(ERROR, "could not find tuple for constraint %u", constraintOid);
- conForm = ((Form_pg_constraint) GETSTRUCT(constraintTuple));
+ conForm = (GETSTRUCT(pg_constraint, constraintTuple));
if (conForm->conindid == oldIndexId)
{
@@ -1663,14 +1663,14 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
while (HeapTupleIsValid((triggerTuple = systable_getnext(scan))))
{
- Form_pg_trigger tgForm = (Form_pg_trigger) GETSTRUCT(triggerTuple);
+ Form_pg_trigger tgForm = GETSTRUCT(pg_trigger, triggerTuple);
if (tgForm->tgconstrindid != oldIndexId)
continue;
/* Make a modifiable copy */
triggerTuple = heap_copytuple(triggerTuple);
- tgForm = (Form_pg_trigger) GETSTRUCT(triggerTuple);
+ tgForm = GETSTRUCT(pg_trigger, triggerTuple);
tgForm->tgconstrindid = newIndexId;
@@ -1776,7 +1776,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
while (HeapTupleIsValid((attrTuple = systable_getnext(scan))))
{
- Form_pg_attribute att = (Form_pg_attribute) GETSTRUCT(attrTuple);
+ Form_pg_attribute att = GETSTRUCT(pg_attribute, attrTuple);
Datum repl_val[Natts_pg_attribute];
bool repl_null[Natts_pg_attribute];
bool repl_repl[Natts_pg_attribute];
@@ -2078,7 +2078,7 @@ index_constraint_create(Relation heapRelation,
ObjectIdGetDatum(indexRelationId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexRelationId);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
if (mark_as_primary && !indexForm->indisprimary)
{
@@ -2854,7 +2854,7 @@ index_update_stats(Relation rel,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for relation %u", relid);
- rd_rel = (Form_pg_class) GETSTRUCT(tuple);
+ rd_rel = GETSTRUCT(pg_class, tuple);
/* Should this be a more comprehensive test? */
Assert(rd_rel->relkind != RELKIND_PARTITIONED_INDEX);
@@ -3078,7 +3078,7 @@ index_build(Relation heapRelation,
ObjectIdGetDatum(indexId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexId);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
/* If it's a new index, indcheckxmin shouldn't be set ... */
Assert(!indexForm->indcheckxmin);
@@ -3450,7 +3450,7 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
ObjectIdGetDatum(indexId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexId);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
/* Perform the requested state change on the copy */
switch (action)
@@ -3531,7 +3531,7 @@ IndexGetRelation(Oid indexId, bool missing_ok)
return InvalidOid;
elog(ERROR, "cache lookup failed for index %u", indexId);
}
- index = (Form_pg_index) GETSTRUCT(tuple);
+ index = GETSTRUCT(pg_index, tuple);
Assert(index->indexrelid == indexId);
result = index->indrelid;
@@ -3768,7 +3768,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
ObjectIdGetDatum(indexId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexId);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
index_bad = (!indexForm->indisvalid ||
!indexForm->indisready ||
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c
index fafb9349cc..737cc9d64b 100644
--- a/src/backend/catalog/namespace.c
+++ b/src/backend/catalog/namespace.c
@@ -717,7 +717,7 @@ RelationIsVisible(Oid relid)
reltup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", relid);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
recomputeNamespacePath();
@@ -825,7 +825,7 @@ TypeIsVisible(Oid typid)
typtup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(typtup))
elog(ERROR, "cache lookup failed for type %u", typid);
- typform = (Form_pg_type) GETSTRUCT(typtup);
+ typform = GETSTRUCT(pg_type, typtup);
recomputeNamespacePath();
@@ -986,7 +986,7 @@ FuncnameGetCandidates(List *names, int nargs, List *argnames,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple proctup = &catlist->members[i]->tuple;
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, proctup);
Oid *proargtypes = procform->proargtypes.values;
int pronargs = procform->pronargs;
int effective_nargs;
@@ -1349,7 +1349,7 @@ MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
bool include_out_arguments, int pronargs,
int **argnumbers)
{
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, proctup);
int numposargs = nargs - list_length(argnames);
int pronallargs;
Oid *p_argtypes;
@@ -1466,7 +1466,7 @@ FunctionIsVisible(Oid funcid)
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
recomputeNamespacePath();
@@ -1553,7 +1553,7 @@ OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
ObjectIdGetDatum(namespaceId));
if (HeapTupleIsValid(opertup))
{
- Form_pg_operator operclass = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operclass = GETSTRUCT(pg_operator, opertup);
Oid result = operclass->oid;
ReleaseSysCache(opertup);
@@ -1595,7 +1595,7 @@ OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple opertup = &catlist->members[i]->tuple;
- Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operform = GETSTRUCT(pg_operator, opertup);
if (operform->oprnamespace == namespaceId)
{
@@ -1678,7 +1678,7 @@ OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple opertup = &catlist->members[i]->tuple;
- Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operform = GETSTRUCT(pg_operator, opertup);
int pathpos = 0;
FuncCandidateList newResult;
@@ -1800,7 +1800,7 @@ OperatorIsVisible(Oid oprid)
oprtup = SearchSysCache1(OPEROID, ObjectIdGetDatum(oprid));
if (!HeapTupleIsValid(oprtup))
elog(ERROR, "cache lookup failed for operator %u", oprid);
- oprform = (Form_pg_operator) GETSTRUCT(oprtup);
+ oprform = GETSTRUCT(pg_operator, oprtup);
recomputeNamespacePath();
@@ -1886,7 +1886,7 @@ OpclassIsVisible(Oid opcid)
opctup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opcid));
if (!HeapTupleIsValid(opctup))
elog(ERROR, "cache lookup failed for opclass %u", opcid);
- opcform = (Form_pg_opclass) GETSTRUCT(opctup);
+ opcform = GETSTRUCT(pg_opclass, opctup);
recomputeNamespacePath();
@@ -1969,7 +1969,7 @@ OpfamilyIsVisible(Oid opfid)
opftup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfid));
if (!HeapTupleIsValid(opftup))
elog(ERROR, "cache lookup failed for opfamily %u", opfid);
- opfform = (Form_pg_opfamily) GETSTRUCT(opftup);
+ opfform = GETSTRUCT(pg_opfamily, opftup);
recomputeNamespacePath();
@@ -2032,7 +2032,7 @@ lookup_collation(const char *collname, Oid collnamespace, int32 encoding)
ObjectIdGetDatum(collnamespace));
if (!HeapTupleIsValid(colltup))
return InvalidOid;
- collform = (Form_pg_collation) GETSTRUCT(colltup);
+ collform = GETSTRUCT(pg_collation, colltup);
if (collform->collprovider == COLLPROVIDER_ICU)
{
if (is_encoding_supported_by_icu(encoding))
@@ -2101,7 +2101,7 @@ CollationIsVisible(Oid collid)
colltup = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
if (!HeapTupleIsValid(colltup))
elog(ERROR, "cache lookup failed for collation %u", collid);
- collform = (Form_pg_collation) GETSTRUCT(colltup);
+ collform = GETSTRUCT(pg_collation, colltup);
recomputeNamespacePath();
@@ -2184,7 +2184,7 @@ ConversionIsVisible(Oid conid)
contup = SearchSysCache1(CONVOID, ObjectIdGetDatum(conid));
if (!HeapTupleIsValid(contup))
elog(ERROR, "cache lookup failed for conversion %u", conid);
- conform = (Form_pg_conversion) GETSTRUCT(contup);
+ conform = GETSTRUCT(pg_conversion, contup);
recomputeNamespacePath();
@@ -2288,7 +2288,7 @@ StatisticsObjIsVisible(Oid relid)
stxtup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(stxtup))
elog(ERROR, "cache lookup failed for statistics object %u", relid);
- stxform = (Form_pg_statistic_ext) GETSTRUCT(stxtup);
+ stxform = GETSTRUCT(pg_statistic_ext, stxtup);
recomputeNamespacePath();
@@ -2411,7 +2411,7 @@ TSParserIsVisible(Oid prsId)
tup = SearchSysCache1(TSPARSEROID, ObjectIdGetDatum(prsId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search parser %u", prsId);
- form = (Form_pg_ts_parser) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_ts_parser, tup);
recomputeNamespacePath();
@@ -2538,7 +2538,7 @@ TSDictionaryIsVisible(Oid dictId)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search dictionary %u",
dictId);
- form = (Form_pg_ts_dict) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_ts_dict, tup);
recomputeNamespacePath();
@@ -2664,7 +2664,7 @@ TSTemplateIsVisible(Oid tmplId)
tup = SearchSysCache1(TSTEMPLATEOID, ObjectIdGetDatum(tmplId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search template %u", tmplId);
- form = (Form_pg_ts_template) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_ts_template, tup);
recomputeNamespacePath();
@@ -2791,7 +2791,7 @@ TSConfigIsVisible(Oid cfgid)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search configuration %u",
cfgid);
- form = (Form_pg_ts_config) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_ts_config, tup);
recomputeNamespacePath();
@@ -3835,7 +3835,7 @@ recomputeNamespacePath(void)
{
char *rname;
- rname = NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname);
+ rname = NameStr((GETSTRUCT(pg_authid, tuple))->rolname);
namespaceId = get_namespace_oid(rname, true);
ReleaseSysCache(tuple);
if (OidIsValid(namespaceId) &&
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 6080ff8f5f..4991a76c41 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -1643,7 +1643,7 @@ get_object_address_type(ObjectType objtype, TypeName *typename, bool missing_ok)
if (objtype == OBJECT_DOMAIN)
{
- if (((Form_pg_type) GETSTRUCT(tup))->typtype != TYPTYPE_DOMAIN)
+ if ((GETSTRUCT(pg_type, tup))->typtype != TYPTYPE_DOMAIN)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a domain",
@@ -1762,7 +1762,7 @@ get_object_address_opf_member(ObjectType objtype,
}
else
{
- address.objectId = ((Form_pg_amop) GETSTRUCT(tp))->oid;
+ address.objectId = (GETSTRUCT(pg_amop, tp))->oid;
ReleaseSysCache(tp);
}
}
@@ -1793,7 +1793,7 @@ get_object_address_opf_member(ObjectType objtype,
}
else
{
- address.objectId = ((Form_pg_amproc) GETSTRUCT(tp))->oid;
+ address.objectId = (GETSTRUCT(pg_amproc, tp))->oid;
ReleaseSysCache(tp);
}
}
@@ -1840,7 +1840,7 @@ get_object_address_usermapping(List *object, bool missing_ok)
username, servername)));
return address;
}
- userid = ((Form_pg_authid) GETSTRUCT(tp))->oid;
+ userid = (GETSTRUCT(pg_authid, tp))->oid;
ReleaseSysCache(tp);
}
@@ -1867,7 +1867,7 @@ get_object_address_usermapping(List *object, bool missing_ok)
return address;
}
- address.objectId = ((Form_pg_user_mapping) GETSTRUCT(tp))->oid;
+ address.objectId = (GETSTRUCT(pg_user_mapping, tp))->oid;
ReleaseSysCache(tp);
@@ -2040,7 +2040,7 @@ get_object_address_defacl(List *object, bool missing_ok)
CStringGetDatum(username));
if (!HeapTupleIsValid(tp))
goto not_found;
- userid = ((Form_pg_authid) GETSTRUCT(tp))->oid;
+ userid = (GETSTRUCT(pg_authid, tp))->oid;
ReleaseSysCache(tp);
/*
@@ -2064,7 +2064,7 @@ get_object_address_defacl(List *object, bool missing_ok)
if (!HeapTupleIsValid(tp))
goto not_found;
- address.objectId = ((Form_pg_default_acl) GETSTRUCT(tp))->oid;
+ address.objectId = (GETSTRUCT(pg_default_acl, tp))->oid;
ReleaseSysCache(tp);
return address;
@@ -2440,7 +2440,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
elog(ERROR, "constraint with OID %u does not exist",
address.objectId);
- contypid = ((Form_pg_constraint) GETSTRUCT(tuple))->contypid;
+ contypid = (GETSTRUCT(pg_constraint, tuple))->contypid;
ReleaseSysCache(tuple);
@@ -2908,7 +2908,7 @@ getPublicationSchemaInfo(const ObjectAddress *object, bool missing_ok,
return false;
}
- pnform = (Form_pg_publication_namespace) GETSTRUCT(tup);
+ pnform = GETSTRUCT(pg_publication_namespace, tup);
*pubname = get_publication_name(pnform->pnpubid, missing_ok);
if (!(*pubname))
{
@@ -3028,7 +3028,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- castForm = (Form_pg_cast) GETSTRUCT(tup);
+ castForm = GETSTRUCT(pg_cast, tup);
appendStringInfo(&buffer, _("cast from %s to %s"),
format_type_be(castForm->castsource),
@@ -3055,7 +3055,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- coll = (Form_pg_collation) GETSTRUCT(collTup);
+ coll = GETSTRUCT(pg_collation, collTup);
/* Qualify the name if not visible in search path */
if (CollationIsVisible(object->objectId))
@@ -3085,7 +3085,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- con = (Form_pg_constraint) GETSTRUCT(conTup);
+ con = GETSTRUCT(pg_constraint, conTup);
if (OidIsValid(con->conrelid))
{
@@ -3124,7 +3124,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- conv = (Form_pg_conversion) GETSTRUCT(conTup);
+ conv = GETSTRUCT(pg_conversion, conTup);
/* Qualify the name if not visible in search path */
if (ConversionIsVisible(object->objectId))
@@ -3208,14 +3208,14 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- opcForm = (Form_pg_opclass) GETSTRUCT(opcTup);
+ opcForm = GETSTRUCT(pg_opclass, opcTup);
amTup = SearchSysCache1(AMOID,
ObjectIdGetDatum(opcForm->opcmethod));
if (!HeapTupleIsValid(amTup))
elog(ERROR, "cache lookup failed for access method %u",
opcForm->opcmethod);
- amForm = (Form_pg_am) GETSTRUCT(amTup);
+ amForm = GETSTRUCT(pg_am, amTup);
/* Qualify the name if not visible in search path */
if (OpclassIsVisible(object->objectId))
@@ -3252,7 +3252,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
}
appendStringInfo(&buffer, _("access method %s"),
- NameStr(((Form_pg_am) GETSTRUCT(tup))->amname));
+ NameStr((GETSTRUCT(pg_am, tup))->amname));
ReleaseSysCache(tup);
break;
}
@@ -3290,7 +3290,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- amopForm = (Form_pg_amop) GETSTRUCT(tup);
+ amopForm = GETSTRUCT(pg_amop, tup);
initStringInfo(&opfam);
getOpFamilyDescription(&opfam, amopForm->amopfamily, false);
@@ -3347,7 +3347,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- amprocForm = (Form_pg_amproc) GETSTRUCT(tup);
+ amprocForm = GETSTRUCT(pg_amproc, tup);
initStringInfo(&opfam);
getOpFamilyDescription(&opfam, amprocForm->amprocfamily, false);
@@ -3403,7 +3403,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- rule = (Form_pg_rewrite) GETSTRUCT(tup);
+ rule = GETSTRUCT(pg_rewrite, tup);
initStringInfo(&rel);
getRelationDescription(&rel, rule->ev_class, false);
@@ -3449,7 +3449,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- trig = (Form_pg_trigger) GETSTRUCT(tup);
+ trig = GETSTRUCT(pg_trigger, tup);
initStringInfo(&rel);
getRelationDescription(&rel, trig->tgrelid, false);
@@ -3495,7 +3495,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- stxForm = (Form_pg_statistic_ext) GETSTRUCT(stxTup);
+ stxForm = GETSTRUCT(pg_statistic_ext, stxTup);
/* Qualify the name if not visible in search path */
if (StatisticsObjIsVisible(object->objectId))
@@ -3526,7 +3526,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
object->objectId);
break;
}
- prsForm = (Form_pg_ts_parser) GETSTRUCT(tup);
+ prsForm = GETSTRUCT(pg_ts_parser, tup);
/* Qualify the name if not visible in search path */
if (TSParserIsVisible(object->objectId))
@@ -3557,7 +3557,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- dictForm = (Form_pg_ts_dict) GETSTRUCT(tup);
+ dictForm = GETSTRUCT(pg_ts_dict, tup);
/* Qualify the name if not visible in search path */
if (TSDictionaryIsVisible(object->objectId))
@@ -3588,7 +3588,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- tmplForm = (Form_pg_ts_template) GETSTRUCT(tup);
+ tmplForm = GETSTRUCT(pg_ts_template, tup);
/* Qualify the name if not visible in search path */
if (TSTemplateIsVisible(object->objectId))
@@ -3619,7 +3619,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- cfgForm = (Form_pg_ts_config) GETSTRUCT(tup);
+ cfgForm = GETSTRUCT(pg_ts_config, tup);
/* Qualify the name if not visible in search path */
if (TSConfigIsVisible(object->objectId))
@@ -3715,7 +3715,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- umform = (Form_pg_user_mapping) GETSTRUCT(tup);
+ umform = GETSTRUCT(pg_user_mapping, tup);
useid = umform->umuser;
srv = GetForeignServer(umform->umserver);
@@ -3764,7 +3764,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- defacl = (Form_pg_default_acl) GETSTRUCT(tup);
+ defacl = GETSTRUCT(pg_default_acl, tup);
rolename = GetUserNameFromId(defacl->defaclrole, false);
@@ -3869,7 +3869,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
appendStringInfo(&buffer, _("event trigger %s"),
- NameStr(((Form_pg_event_trigger) GETSTRUCT(tup))->evtname));
+ NameStr((GETSTRUCT(pg_event_trigger, tup))->evtname));
ReleaseSysCache(tup);
break;
}
@@ -3932,7 +3932,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- form_policy = (Form_pg_policy) GETSTRUCT(tuple);
+ form_policy = GETSTRUCT(pg_policy, tuple);
initStringInfo(&rel);
getRelationDescription(&rel, form_policy->polrelid, false);
@@ -3989,7 +3989,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- prform = (Form_pg_publication_rel) GETSTRUCT(tup);
+ prform = GETSTRUCT(pg_publication_rel, tup);
pubname = get_publication_name(prform->prpubid, false);
initStringInfo(&rel);
@@ -4028,7 +4028,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- trfForm = (Form_pg_transform) GETSTRUCT(trfTup);
+ trfForm = GETSTRUCT(pg_transform, trfTup);
appendStringInfo(&buffer, _("transform for %s language %s"),
format_type_be(trfForm->trftype),
@@ -4087,7 +4087,7 @@ getRelationDescription(StringInfo buffer, Oid relid, bool missing_ok)
elog(ERROR, "cache lookup failed for relation %u", relid);
return;
}
- relForm = (Form_pg_class) GETSTRUCT(relTup);
+ relForm = GETSTRUCT(pg_class, relTup);
/* Qualify the name if not visible in search path */
if (RelationIsVisible(relid))
@@ -4162,13 +4162,13 @@ getOpFamilyDescription(StringInfo buffer, Oid opfid, bool missing_ok)
elog(ERROR, "cache lookup failed for opfamily %u", opfid);
return;
}
- opfForm = (Form_pg_opfamily) GETSTRUCT(opfTup);
+ opfForm = GETSTRUCT(pg_opfamily, opfTup);
amTup = SearchSysCache1(AMOID, ObjectIdGetDatum(opfForm->opfmethod));
if (!HeapTupleIsValid(amTup))
elog(ERROR, "cache lookup failed for access method %u",
opfForm->opfmethod);
- amForm = (Form_pg_am) GETSTRUCT(amTup);
+ amForm = GETSTRUCT(pg_am, amTup);
/* Qualify the name if not visible in search path */
if (OpfamilyIsVisible(opfid))
@@ -4626,7 +4626,7 @@ getRelationTypeDescription(StringInfo buffer, Oid relid, int32 objectSubId,
appendStringInfoString(buffer, "relation");
return;
}
- relForm = (Form_pg_class) GETSTRUCT(relTup);
+ relForm = GETSTRUCT(pg_class, relTup);
switch (relForm->relkind)
{
@@ -4693,7 +4693,7 @@ getConstraintTypeDescription(StringInfo buffer, Oid constroid, bool missing_ok)
return;
}
- constrForm = (Form_pg_constraint) GETSTRUCT(constrTup);
+ constrForm = GETSTRUCT(pg_constraint, constrTup);
if (OidIsValid(constrForm->conrelid))
appendStringInfoString(buffer, "table constraint");
@@ -4726,7 +4726,7 @@ getProcedureTypeDescription(StringInfo buffer, Oid procid,
appendStringInfoString(buffer, "routine");
return;
}
- procForm = (Form_pg_proc) GETSTRUCT(procTup);
+ procForm = GETSTRUCT(pg_proc, procTup);
if (procForm->prokind == PROKIND_AGGREGATE)
appendStringInfoString(buffer, "aggregate");
@@ -4870,7 +4870,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- castForm = (Form_pg_cast) GETSTRUCT(tup);
+ castForm = GETSTRUCT(pg_cast, tup);
appendStringInfo(&buffer, "(%s AS %s)",
format_type_be_qualified(castForm->castsource),
@@ -4901,7 +4901,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- coll = (Form_pg_collation) GETSTRUCT(collTup);
+ coll = GETSTRUCT(pg_collation, collTup);
schema = get_namespace_name_or_temp(coll->collnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -4927,7 +4927,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- con = (Form_pg_constraint) GETSTRUCT(conTup);
+ con = GETSTRUCT(pg_constraint, conTup);
if (OidIsValid(con->conrelid))
{
@@ -4975,7 +4975,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- conForm = (Form_pg_conversion) GETSTRUCT(conTup);
+ conForm = GETSTRUCT(pg_conversion, conTup);
schema = get_namespace_name_or_temp(conForm->connamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5022,7 +5022,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- langForm = (Form_pg_language) GETSTRUCT(langTup);
+ langForm = GETSTRUCT(pg_language, langTup);
appendStringInfoString(&buffer,
quote_identifier(NameStr(langForm->lanname)));
if (objname)
@@ -5071,7 +5071,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- opcForm = (Form_pg_opclass) GETSTRUCT(opcTup);
+ opcForm = GETSTRUCT(pg_opclass, opcTup);
schema = get_namespace_name_or_temp(opcForm->opcnamespace);
amTup = SearchSysCache1(AMOID,
@@ -5079,7 +5079,7 @@ getObjectIdentityParts(const ObjectAddress *object,
if (!HeapTupleIsValid(amTup))
elog(ERROR, "cache lookup failed for access method %u",
opcForm->opcmethod);
- amForm = (Form_pg_am) GETSTRUCT(amTup);
+ amForm = GETSTRUCT(pg_am, amTup);
appendStringInfo(&buffer, "%s USING %s",
quote_qualified_identifier(schema,
@@ -5153,7 +5153,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- amopForm = (Form_pg_amop) GETSTRUCT(tup);
+ amopForm = GETSTRUCT(pg_amop, tup);
initStringInfo(&opfam);
getOpFamilyIdentity(&opfam, amopForm->amopfamily, objname,
@@ -5215,7 +5215,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- amprocForm = (Form_pg_amproc) GETSTRUCT(tup);
+ amprocForm = GETSTRUCT(pg_amproc, tup);
initStringInfo(&opfam);
getOpFamilyIdentity(&opfam, amprocForm->amprocfamily, objname,
@@ -5263,7 +5263,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- rule = (Form_pg_rewrite) GETSTRUCT(tup);
+ rule = GETSTRUCT(pg_rewrite, tup);
appendStringInfo(&buffer, "%s on ",
quote_identifier(NameStr(rule->rulename)));
@@ -5296,7 +5296,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- trig = (Form_pg_trigger) GETSTRUCT(tup);
+ trig = GETSTRUCT(pg_trigger, tup);
appendStringInfo(&buffer, "%s on ",
quote_identifier(NameStr(trig->tgname)));
@@ -5342,7 +5342,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formStatistic = (Form_pg_statistic_ext) GETSTRUCT(tup);
+ formStatistic = GETSTRUCT(pg_statistic_ext, tup);
schema = get_namespace_name_or_temp(formStatistic->stxnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5369,7 +5369,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formParser = (Form_pg_ts_parser) GETSTRUCT(tup);
+ formParser = GETSTRUCT(pg_ts_parser, tup);
schema = get_namespace_name_or_temp(formParser->prsnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5396,7 +5396,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formDict = (Form_pg_ts_dict) GETSTRUCT(tup);
+ formDict = GETSTRUCT(pg_ts_dict, tup);
schema = get_namespace_name_or_temp(formDict->dictnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5423,7 +5423,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formTmpl = (Form_pg_ts_template) GETSTRUCT(tup);
+ formTmpl = GETSTRUCT(pg_ts_template, tup);
schema = get_namespace_name_or_temp(formTmpl->tmplnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5450,7 +5450,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formCfg = (Form_pg_ts_config) GETSTRUCT(tup);
+ formCfg = GETSTRUCT(pg_ts_config, tup);
schema = get_namespace_name_or_temp(formCfg->cfgnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5562,7 +5562,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- umform = (Form_pg_user_mapping) GETSTRUCT(tup);
+ umform = GETSTRUCT(pg_user_mapping, tup);
useid = umform->umuser;
srv = GetForeignServer(umform->umserver);
@@ -5618,7 +5618,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- defacl = (Form_pg_default_acl) GETSTRUCT(tup);
+ defacl = GETSTRUCT(pg_default_acl, tup);
username = GetUserNameFromId(defacl->defaclrole, false);
appendStringInfo(&buffer,
@@ -5705,7 +5705,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- trigForm = (Form_pg_event_trigger) GETSTRUCT(tup);
+ trigForm = GETSTRUCT(pg_event_trigger, tup);
evtname = pstrdup(NameStr(trigForm->evtname));
appendStringInfoString(&buffer, quote_identifier(evtname));
if (objname)
@@ -5763,7 +5763,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- policy = (Form_pg_policy) GETSTRUCT(tup);
+ policy = GETSTRUCT(pg_policy, tup);
appendStringInfo(&buffer, "%s on ",
quote_identifier(NameStr(policy->polname)));
@@ -5830,7 +5830,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- prform = (Form_pg_publication_rel) GETSTRUCT(tup);
+ prform = GETSTRUCT(pg_publication_rel, tup);
pubname = get_publication_name(prform->prpubid, false);
getRelationIdentity(&buffer, prform->prrelid, objname, false);
@@ -5882,7 +5882,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- transform = (Form_pg_transform) GETSTRUCT(tup);
+ transform = GETSTRUCT(pg_transform, tup);
transformType = format_type_be_qualified(transform->trftype);
transformLang = get_language_name(transform->trflang, false);
@@ -5948,13 +5948,13 @@ getOpFamilyIdentity(StringInfo buffer, Oid opfid, List **object,
elog(ERROR, "cache lookup failed for opfamily %u", opfid);
return;
}
- opfForm = (Form_pg_opfamily) GETSTRUCT(opfTup);
+ opfForm = GETSTRUCT(pg_opfamily, opfTup);
amTup = SearchSysCache1(AMOID, ObjectIdGetDatum(opfForm->opfmethod));
if (!HeapTupleIsValid(amTup))
elog(ERROR, "cache lookup failed for access method %u",
opfForm->opfmethod);
- amForm = (Form_pg_am) GETSTRUCT(amTup);
+ amForm = GETSTRUCT(pg_am, amTup);
schema = get_namespace_name_or_temp(opfForm->opfnamespace);
appendStringInfo(buffer, "%s USING %s",
@@ -5994,7 +5994,7 @@ getRelationIdentity(StringInfo buffer, Oid relid, List **object,
*object = NIL;
return;
}
- relForm = (Form_pg_class) GETSTRUCT(relTup);
+ relForm = GETSTRUCT(pg_class, relTup);
schema = get_namespace_name_or_temp(relForm->relnamespace);
appendStringInfoString(buffer,
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c
index c6ec479004..a3d4ebe38d 100644
--- a/src/backend/catalog/partition.c
+++ b/src/backend/catalog/partition.c
@@ -106,7 +106,7 @@ get_partition_parent_worker(Relation inhRel, Oid relid, bool *detach_pending)
tuple = systable_getnext(scan);
if (HeapTupleIsValid(tuple))
{
- Form_pg_inherits form = (Form_pg_inherits) GETSTRUCT(tuple);
+ Form_pg_inherits form = GETSTRUCT(pg_inherits, tuple);
/* Let caller know of partition being detached */
if (form->inhdetachpending)
@@ -187,7 +187,7 @@ index_get_partition(Relation partition, Oid indexId)
tup = SearchSysCache1(RELOID, ObjectIdGetDatum(partIdx));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for relation %u", partIdx);
- classForm = (Form_pg_class) GETSTRUCT(tup);
+ classForm = GETSTRUCT(pg_class, tup);
ispartition = classForm->relispartition;
ReleaseSysCache(tup);
if (!ispartition)
@@ -321,7 +321,7 @@ get_default_partition_oid(Oid parentId)
{
Form_pg_partitioned_table part_table_form;
- part_table_form = (Form_pg_partitioned_table) GETSTRUCT(tuple);
+ part_table_form = GETSTRUCT(pg_partitioned_table, tuple);
defaultPartId = part_table_form->partdefid;
ReleaseSysCache(tuple);
}
@@ -349,7 +349,7 @@ update_default_partition_oid(Oid parentId, Oid defaultPartId)
elog(ERROR, "cache lookup failed for partition key of relation %u",
parentId);
- part_table_form = (Form_pg_partitioned_table) GETSTRUCT(tuple);
+ part_table_form = GETSTRUCT(pg_partitioned_table, tuple);
part_table_form->partdefid = defaultPartId;
CatalogTupleUpdate(pg_partitioned_table, &tuple->t_self, tuple);
diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c
index 0d0daa69b3..392296edbe 100644
--- a/src/backend/catalog/pg_aggregate.c
+++ b/src/backend/catalog/pg_aggregate.c
@@ -250,7 +250,7 @@ AggregateCreate(const char *aggName,
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(transfn));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for function %u", transfn);
- proc = (Form_pg_proc) GETSTRUCT(tup);
+ proc = GETSTRUCT(pg_proc, tup);
/*
* If the transfn is strict and the initval is NULL, make sure first input
@@ -294,7 +294,7 @@ AggregateCreate(const char *aggName,
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(mtransfn));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for function %u", mtransfn);
- proc = (Form_pg_proc) GETSTRUCT(tup);
+ proc = GETSTRUCT(pg_proc, tup);
/*
* If the mtransfn is strict and the minitval is NULL, check first
@@ -339,7 +339,7 @@ AggregateCreate(const char *aggName,
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(minvtransfn));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for function %u", minvtransfn);
- proc = (Form_pg_proc) GETSTRUCT(tup);
+ proc = GETSTRUCT(pg_proc, tup);
/*
* We require the strictness settings of the forward and inverse
@@ -692,7 +692,7 @@ AggregateCreate(const char *aggName,
if (HeapTupleIsValid(oldtup))
{
- Form_pg_aggregate oldagg = (Form_pg_aggregate) GETSTRUCT(oldtup);
+ Form_pg_aggregate oldagg = GETSTRUCT(pg_aggregate, oldtup);
/*
* If we're replacing an existing entry, we need to validate that
diff --git a/src/backend/catalog/pg_attrdef.c b/src/backend/catalog/pg_attrdef.c
index c5d4a9912e..d52e1050ed 100644
--- a/src/backend/catalog/pg_attrdef.c
+++ b/src/backend/catalog/pg_attrdef.c
@@ -101,7 +101,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
if (!HeapTupleIsValid(atttup))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, RelationGetRelid(rel));
- attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
+ attStruct = GETSTRUCT(pg_attribute, atttup);
attgenerated = attStruct->attgenerated;
if (!attStruct->atthasdef)
{
@@ -240,7 +240,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
ObjectAddress object;
- Form_pg_attrdef attrtuple = (Form_pg_attrdef) GETSTRUCT(tuple);
+ Form_pg_attrdef attrtuple = GETSTRUCT(pg_attrdef, tuple);
object.classId = AttrDefaultRelationId;
object.objectId = attrtuple->oid;
@@ -295,8 +295,8 @@ RemoveAttrDefaultById(Oid attrdefId)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for attrdef %u", attrdefId);
- myrelid = ((Form_pg_attrdef) GETSTRUCT(tuple))->adrelid;
- myattnum = ((Form_pg_attrdef) GETSTRUCT(tuple))->adnum;
+ myrelid = (GETSTRUCT(pg_attrdef, tuple))->adrelid;
+ myattnum = (GETSTRUCT(pg_attrdef, tuple))->adnum;
/* Get an exclusive lock on the relation owning the attribute */
myrel = relation_open(myrelid, AccessExclusiveLock);
@@ -317,7 +317,7 @@ RemoveAttrDefaultById(Oid attrdefId)
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
myattnum, myrelid);
- ((Form_pg_attribute) GETSTRUCT(tuple))->atthasdef = false;
+ (GETSTRUCT(pg_attribute, tuple))->atthasdef = false;
CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple);
@@ -363,7 +363,7 @@ GetAttrDefaultOid(Oid relid, AttrNumber attnum)
if (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_attrdef atdform = (Form_pg_attrdef) GETSTRUCT(tup);
+ Form_pg_attrdef atdform = GETSTRUCT(pg_attrdef, tup);
result = atdform->oid;
}
@@ -399,7 +399,7 @@ GetAttrDefaultColumnAddress(Oid attrdefoid)
if (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_attrdef atdform = (Form_pg_attrdef) GETSTRUCT(tup);
+ Form_pg_attrdef atdform = GETSTRUCT(pg_attrdef, tup);
result.classId = RelationRelationId;
result.objectId = atdform->adrelid;
diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c
index bb65fb1e0a..48f1653242 100644
--- a/src/backend/catalog/pg_constraint.c
+++ b/src/backend/catalog/pg_constraint.c
@@ -577,7 +577,7 @@ RemoveConstraintById(Oid conId)
tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for constraint %u", conId);
- con = (Form_pg_constraint) GETSTRUCT(tup);
+ con = GETSTRUCT(pg_constraint, tup);
/*
* Special processing depending on what the constraint is for.
@@ -609,7 +609,7 @@ RemoveConstraintById(Oid conId)
if (!HeapTupleIsValid(relTup))
elog(ERROR, "cache lookup failed for relation %u",
con->conrelid);
- classForm = (Form_pg_class) GETSTRUCT(relTup);
+ classForm = GETSTRUCT(pg_class, relTup);
if (classForm->relchecks == 0) /* should not happen */
elog(ERROR, "relation \"%s\" has relchecks = 0",
@@ -668,7 +668,7 @@ RenameConstraintById(Oid conId, const char *newname)
tuple = SearchSysCacheCopy1(CONSTROID, ObjectIdGetDatum(conId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", conId);
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
/*
* For user-friendliness, check whether the name is already in use.
@@ -733,7 +733,7 @@ AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(tup);
+ Form_pg_constraint conform = GETSTRUCT(pg_constraint, tup);
ObjectAddress thisobj;
ObjectAddressSet(thisobj, ConstraintRelationId, conform->oid);
@@ -745,7 +745,7 @@ AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
if (conform->connamespace == oldNspId && oldNspId != newNspId)
{
tup = heap_copytuple(tup);
- conform = (Form_pg_constraint) GETSTRUCT(tup);
+ conform = GETSTRUCT(pg_constraint, tup);
conform->connamespace = newNspId;
@@ -794,7 +794,7 @@ ConstraintSetParentConstraint(Oid childConstrId,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", childConstrId);
newtup = heap_copytuple(tuple);
- constrForm = (Form_pg_constraint) GETSTRUCT(newtup);
+ constrForm = GETSTRUCT(pg_constraint, newtup);
if (OidIsValid(parentConstrId))
{
/* don't allow setting parent for a constraint that already has one */
@@ -875,7 +875,7 @@ get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok)
/* There can be at most one matching row */
if (HeapTupleIsValid(tuple = systable_getnext(scan)))
- conOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ conOid = (GETSTRUCT(pg_constraint, tuple))->oid;
systable_endscan(scan);
@@ -940,7 +940,7 @@ get_relation_constraint_attnos(Oid relid, const char *conname,
Datum adatum;
bool isNull;
- *constraintOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ *constraintOid = (GETSTRUCT(pg_constraint, tuple))->oid;
/* Extract the conkey array, ie, attnums of constrained columns */
adatum = heap_getattr(tuple, Anum_pg_constraint_conkey,
@@ -1010,7 +1010,7 @@ get_relation_idx_constraint_oid(Oid relationId, Oid indexId)
{
Form_pg_constraint constrForm;
- constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ constrForm = GETSTRUCT(pg_constraint, tuple);
if (constrForm->conindid == indexId)
{
constraintId = constrForm->oid;
@@ -1057,7 +1057,7 @@ get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok)
/* There can be at most one matching row */
if (HeapTupleIsValid(tuple = systable_getnext(scan)))
- conOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ conOid = (GETSTRUCT(pg_constraint, tuple))->oid;
systable_endscan(scan);
@@ -1112,7 +1112,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid)
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
Datum adatum;
bool isNull;
ArrayType *arr;
@@ -1137,7 +1137,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid)
RelationGetDescr(pg_constraint), &isNull);
if (isNull)
elog(ERROR, "null conkey for constraint %u",
- ((Form_pg_constraint) GETSTRUCT(tuple))->oid);
+ (GETSTRUCT(pg_constraint, tuple))->oid);
arr = DatumGetArrayTypeP(adatum); /* ensure not toasted */
numkeys = ARR_DIMS(arr)[0];
if (ARR_NDIM(arr) != 1 ||
@@ -1153,7 +1153,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid)
pkattnos = bms_add_member(pkattnos,
attnums[i] - FirstLowInvalidHeapAttributeNumber);
}
- *constraintOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ *constraintOid = (GETSTRUCT(pg_constraint, tuple))->oid;
/* No need to search further */
break;
@@ -1185,7 +1185,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ArrayType *arr;
int numkeys;
- constrId = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ constrId = (GETSTRUCT(pg_constraint, tuple))->oid;
/*
* We expect the arrays to be 1-D arrays of the right types; verify that.
diff --git a/src/backend/catalog/pg_conversion.c b/src/backend/catalog/pg_conversion.c
index 3d8b86ace7..4a39593d4a 100644
--- a/src/backend/catalog/pg_conversion.c
+++ b/src/backend/catalog/pg_conversion.c
@@ -168,7 +168,7 @@ FindDefaultConversion(Oid name_space, int32 for_encoding, int32 to_encoding)
for (i = 0; i < catlist->n_members; i++)
{
tuple = &catlist->members[i]->tuple;
- body = (Form_pg_conversion) GETSTRUCT(tuple);
+ body = GETSTRUCT(pg_conversion, tuple);
if (body->condefault)
{
proc = body->conproc;
diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c
index e86e5e6898..20ebdcc6e6 100644
--- a/src/backend/catalog/pg_depend.c
+++ b/src/backend/catalog/pg_depend.c
@@ -266,7 +266,7 @@ deleteDependencyRecordsFor(Oid classId, Oid objectId,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
if (skipExtensionDeps &&
- ((Form_pg_depend) GETSTRUCT(tup))->deptype == DEPENDENCY_EXTENSION)
+ (GETSTRUCT(pg_depend, tup))->deptype == DEPENDENCY_EXTENSION)
continue;
CatalogTupleDelete(depRel, &tup->t_self);
@@ -315,7 +315,7 @@ deleteDependencyRecordsForClass(Oid classId, Oid objectId,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == refclassId && depform->deptype == deptype)
{
@@ -362,7 +362,7 @@ deleteDependencyRecordsForSpecific(Oid classId, Oid objectId, char deptype,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == refclassId &&
depform->refobjid == refobjectId &&
@@ -464,7 +464,7 @@ changeDependencyFor(Oid classId, Oid objectId,
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == refClassId &&
depform->refobjid == oldRefObjectId)
@@ -475,7 +475,7 @@ changeDependencyFor(Oid classId, Oid objectId,
{
/* make a modifiable copy */
tup = heap_copytuple(tup);
- depform = (Form_pg_depend) GETSTRUCT(tup);
+ depform = GETSTRUCT(pg_depend, tup);
depform->refobjid = newRefObjectId;
@@ -533,7 +533,7 @@ changeDependenciesOf(Oid classId, Oid oldObjectId,
/* make a modifiable copy */
tup = heap_copytuple(tup);
- depform = (Form_pg_depend) GETSTRUCT(tup);
+ depform = GETSTRUCT(pg_depend, tup);
depform->objid = newObjectId;
@@ -620,7 +620,7 @@ changeDependenciesOn(Oid refClassId, Oid oldRefObjectId,
/* make a modifiable copy */
tup = heap_copytuple(tup);
- depform = (Form_pg_depend) GETSTRUCT(tup);
+ depform = GETSTRUCT(pg_depend, tup);
depform->refobjid = newRefObjectId;
@@ -695,7 +695,7 @@ getExtensionOfObject(Oid classId, Oid objectId)
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == ExtensionRelationId &&
depform->deptype == DEPENDENCY_EXTENSION)
@@ -741,7 +741,7 @@ getAutoExtensionsOfObject(Oid classId, Oid objectId)
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == ExtensionRelationId &&
depform->deptype == DEPENDENCY_AUTO_EXTENSION)
@@ -791,7 +791,7 @@ sequenceIsOwned(Oid seqId, char deptype, Oid *tableId, int32 *colId)
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == RelationRelationId &&
depform->deptype == deptype)
@@ -845,7 +845,7 @@ getOwnedSequences_internal(Oid relid, AttrNumber attnum, char deptype)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend deprec = GETSTRUCT(pg_depend, tup);
/*
* We assume any auto or internal dependency of a sequence on a column
@@ -937,7 +937,7 @@ get_index_constraint(Oid indexId)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend deprec = GETSTRUCT(pg_depend, tup);
/*
* We assume any internal dependency on a constraint must be what we
@@ -993,7 +993,7 @@ get_index_ref_constraints(Oid indexId)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend deprec = GETSTRUCT(pg_depend, tup);
/*
* We assume any normal dependency from a constraint must be what we
diff --git a/src/backend/catalog/pg_enum.c b/src/backend/catalog/pg_enum.c
index 114715498d..3a518b9122 100644
--- a/src/backend/catalog/pg_enum.c
+++ b/src/backend/catalog/pg_enum.c
@@ -292,7 +292,7 @@ restart:
*/
if (nelems > 0)
{
- Form_pg_enum en = (Form_pg_enum) GETSTRUCT(existing[nelems - 1]);
+ Form_pg_enum en = GETSTRUCT(pg_enum, existing[nelems - 1]);
newelemorder = en->enumsortorder + 1;
}
@@ -310,7 +310,7 @@ restart:
/* Locate the neighbor element */
for (nbr_index = 0; nbr_index < nelems; nbr_index++)
{
- Form_pg_enum en = (Form_pg_enum) GETSTRUCT(existing[nbr_index]);
+ Form_pg_enum en = GETSTRUCT(pg_enum, existing[nbr_index]);
if (strcmp(NameStr(en->enumlabel), neighbor) == 0)
break;
@@ -320,7 +320,7 @@ restart:
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" is not an existing enum label",
neighbor)));
- nbr_en = (Form_pg_enum) GETSTRUCT(existing[nbr_index]);
+ nbr_en = GETSTRUCT(pg_enum, existing[nbr_index]);
/*
* Attempt to assign an appropriate enumsortorder value: one less than
@@ -352,7 +352,7 @@ restart:
*/
volatile float4 midpoint;
- other_nbr_en = (Form_pg_enum) GETSTRUCT(existing[other_nbr_index]);
+ other_nbr_en = GETSTRUCT(pg_enum, existing[other_nbr_index]);
midpoint = (nbr_en->enumsortorder +
other_nbr_en->enumsortorder) / 2;
@@ -418,7 +418,7 @@ restart:
for (i = 0; i < nelems; i++)
{
HeapTuple exists_tup = existing[i];
- Form_pg_enum exists_en = (Form_pg_enum) GETSTRUCT(exists_tup);
+ Form_pg_enum exists_en = GETSTRUCT(pg_enum, exists_tup);
Oid exists_oid = exists_en->oid;
if (exists_oid & 1)
@@ -552,7 +552,7 @@ RenameEnumLabel(Oid enumTypeOid,
for (i = 0; i < nelems; i++)
{
enum_tup = &(list->members[i]->tuple);
- en = (Form_pg_enum) GETSTRUCT(enum_tup);
+ en = GETSTRUCT(pg_enum, enum_tup);
if (strcmp(NameStr(en->enumlabel), oldVal) == 0)
old_tup = enum_tup;
if (strcmp(NameStr(en->enumlabel), newVal) == 0)
@@ -571,7 +571,7 @@ RenameEnumLabel(Oid enumTypeOid,
/* OK, make a writable copy of old tuple */
enum_tup = heap_copytuple(old_tup);
- en = (Form_pg_enum) GETSTRUCT(enum_tup);
+ en = GETSTRUCT(pg_enum, enum_tup);
ReleaseCatCacheList(list);
@@ -656,7 +656,7 @@ RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems)
float4 newsortorder;
newtup = heap_copytuple(existing[i]);
- en = (Form_pg_enum) GETSTRUCT(newtup);
+ en = GETSTRUCT(pg_enum, newtup);
newsortorder = i + 1;
if (en->enumsortorder != newsortorder)
@@ -680,8 +680,8 @@ sort_order_cmp(const void *p1, const void *p2)
{
HeapTuple v1 = *((const HeapTuple *) p1);
HeapTuple v2 = *((const HeapTuple *) p2);
- Form_pg_enum en1 = (Form_pg_enum) GETSTRUCT(v1);
- Form_pg_enum en2 = (Form_pg_enum) GETSTRUCT(v2);
+ Form_pg_enum en1 = GETSTRUCT(pg_enum, v1);
+ Form_pg_enum en2 = GETSTRUCT(pg_enum, v2);
if (en1->enumsortorder < en2->enumsortorder)
return -1;
diff --git a/src/backend/catalog/pg_inherits.c b/src/backend/catalog/pg_inherits.c
index 92afbc2f25..2764c1c35c 100644
--- a/src/backend/catalog/pg_inherits.c
+++ b/src/backend/catalog/pg_inherits.c
@@ -136,7 +136,7 @@ find_inheritance_children_extended(Oid parentrelId, bool omit_detached,
* SERIALIZABLE transactions: such queries use a different snapshot
* than the one used by regular (user) queries.
*/
- if (((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending)
+ if ((GETSTRUCT(pg_inherits, inheritsTuple))->inhdetachpending)
{
if (detached_exist)
*detached_exist = true;
@@ -179,7 +179,7 @@ find_inheritance_children_extended(Oid parentrelId, bool omit_detached,
}
}
- inhrelid = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhrelid;
+ inhrelid = (GETSTRUCT(pg_inherits, inheritsTuple))->inhrelid;
if (numoids >= maxoids)
{
maxoids *= 2;
@@ -362,7 +362,7 @@ has_subclass(Oid relationId)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationId);
- result = ((Form_pg_class) GETSTRUCT(tuple))->relhassubclass;
+ result = (GETSTRUCT(pg_class, tuple))->relhassubclass;
ReleaseSysCache(tuple);
return result;
}
@@ -473,7 +473,7 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId)
while ((inhtup = systable_getnext(inhscan)) != NULL)
{
- Form_pg_inherits inh = (Form_pg_inherits) GETSTRUCT(inhtup);
+ Form_pg_inherits inh = GETSTRUCT(pg_inherits, inhtup);
Oid inhparent = inh->inhparent;
/* If this is the target superclass, we're done */
@@ -575,13 +575,13 @@ DeleteInheritsTuple(Oid inhrelid, Oid inhparent, bool expect_detach_pending,
Oid parent;
/* Compare inhparent if it was given, and do the actual deletion. */
- parent = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhparent;
+ parent = (GETSTRUCT(pg_inherits, inheritsTuple))->inhparent;
if (!OidIsValid(inhparent) || parent == inhparent)
{
bool detach_pending;
detach_pending =
- ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending;
+ (GETSTRUCT(pg_inherits, inheritsTuple))->inhdetachpending;
/*
* Raise error depending on state. This should only happen for
@@ -643,7 +643,7 @@ PartitionHasPendingDetach(Oid partoid)
bool detached;
detached =
- ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending;
+ (GETSTRUCT(pg_inherits, inheritsTuple))->inhdetachpending;
/* Done */
systable_endscan(scan);
diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c
index 630bf3e56c..6b4db2306f 100644
--- a/src/backend/catalog/pg_operator.c
+++ b/src/backend/catalog/pg_operator.c
@@ -143,7 +143,7 @@ OperatorGet(const char *operatorName,
ObjectIdGetDatum(operatorNamespace));
if (HeapTupleIsValid(tup))
{
- Form_pg_operator oprform = (Form_pg_operator) GETSTRUCT(tup);
+ Form_pg_operator oprform = GETSTRUCT(pg_operator, tup);
operatorObjectId = oprform->oid;
*defined = RegProcedureIsValid(oprform->oprcode);
@@ -677,7 +677,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId, bool isDelete)
/* Update the commutator's tuple if need be. */
if (HeapTupleIsValid(tup))
{
- Form_pg_operator t = (Form_pg_operator) GETSTRUCT(tup);
+ Form_pg_operator t = GETSTRUCT(pg_operator, tup);
bool update_commutator = false;
/*
@@ -722,7 +722,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId, bool isDelete)
if (HeapTupleIsValid(tup))
{
- Form_pg_operator t = (Form_pg_operator) GETSTRUCT(tup);
+ Form_pg_operator t = GETSTRUCT(pg_operator, tup);
bool update_negator = false;
/*
@@ -778,7 +778,7 @@ makeOperatorDependencies(HeapTuple tuple,
bool makeExtensionDep,
bool isUpdate)
{
- Form_pg_operator oper = (Form_pg_operator) GETSTRUCT(tuple);
+ Form_pg_operator oper = GETSTRUCT(pg_operator, tuple);
ObjectAddress myself,
referenced;
ObjectAddresses *addrs;
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index a9fe45e347..8eed22b3fb 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -365,7 +365,7 @@ ProcedureCreate(const char *procedureName,
if (HeapTupleIsValid(oldtup))
{
/* There is one; okay to replace it? */
- Form_pg_proc oldproc = (Form_pg_proc) GETSTRUCT(oldtup);
+ Form_pg_proc oldproc = GETSTRUCT(pg_proc, oldtup);
Datum proargnames;
bool isnull;
const char *dropcmd;
@@ -586,7 +586,7 @@ ProcedureCreate(const char *procedureName,
}
- retval = ((Form_pg_proc) GETSTRUCT(tup))->oid;
+ retval = (GETSTRUCT(pg_proc, tup))->oid;
/*
* Create dependencies for the new function. If we are updating an
@@ -842,7 +842,7 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- proc = (Form_pg_proc) GETSTRUCT(tuple);
+ proc = GETSTRUCT(pg_proc, tuple);
/* Disallow pseudotype result */
/* except for RECORD, VOID, or polymorphic */
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index c365de3a72..2819aafe75 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -236,7 +236,7 @@ pg_relation_is_publishable(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- result = is_publishable_class(relid, (Form_pg_class) GETSTRUCT(tuple));
+ result = is_publishable_class(relid, GETSTRUCT(pg_class, tuple));
ReleaseSysCache(tuple);
PG_RETURN_BOOL(result);
}
@@ -678,7 +678,7 @@ GetRelationPublications(Oid relid)
for (i = 0; i < pubrellist->n_members; i++)
{
HeapTuple tup = &pubrellist->members[i]->tuple;
- Oid pubid = ((Form_pg_publication_rel) GETSTRUCT(tup))->prpubid;
+ Oid pubid = (GETSTRUCT(pg_publication_rel, tup))->prpubid;
result = lappend_oid(result, pubid);
}
@@ -719,7 +719,7 @@ GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
{
Form_pg_publication_rel pubrel;
- pubrel = (Form_pg_publication_rel) GETSTRUCT(tup);
+ pubrel = GETSTRUCT(pg_publication_rel, tup);
result = GetPubPartitionOptionRelations(result, pub_partopt,
pubrel->prrelid);
}
@@ -760,7 +760,7 @@ GetAllTablesPublications(void)
result = NIL;
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Oid oid = ((Form_pg_publication) GETSTRUCT(tup))->oid;
+ Oid oid = (GETSTRUCT(pg_publication, tup))->oid;
result = lappend_oid(result, oid);
}
@@ -798,7 +798,7 @@ GetAllTablesPublicationRelations(bool pubviaroot)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class relForm = GETSTRUCT(pg_class, tuple);
Oid relid = relForm->oid;
if (is_publishable_class(relid, relForm) &&
@@ -819,7 +819,7 @@ GetAllTablesPublicationRelations(bool pubviaroot)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class relForm = GETSTRUCT(pg_class, tuple);
Oid relid = relForm->oid;
if (is_publishable_class(relid, relForm) &&
@@ -863,7 +863,7 @@ GetPublicationSchemas(Oid pubid)
{
Form_pg_publication_namespace pubsch;
- pubsch = (Form_pg_publication_namespace) GETSTRUCT(tup);
+ pubsch = GETSTRUCT(pg_publication_namespace, tup);
result = lappend_oid(result, pubsch->pnnspid);
}
@@ -890,7 +890,7 @@ GetSchemaPublications(Oid schemaid)
for (i = 0; i < pubschlist->n_members; i++)
{
HeapTuple tup = &pubschlist->members[i]->tuple;
- Oid pubid = ((Form_pg_publication_namespace) GETSTRUCT(tup))->pnpubid;
+ Oid pubid = (GETSTRUCT(pg_publication_namespace, tup))->pnpubid;
result = lappend_oid(result, pubid);
}
@@ -925,7 +925,7 @@ GetSchemaPublicationRelations(Oid schemaid, PublicationPartOpt pub_partopt)
scan = table_beginscan_catalog(classRel, 1, key);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class relForm = GETSTRUCT(pg_class, tuple);
Oid relid = relForm->oid;
char relkind;
@@ -995,7 +995,7 @@ GetPublication(Oid pubid)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication %u", pubid);
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
pub = (Publication *) palloc(sizeof(Publication));
pub->oid = pubid;
@@ -1068,7 +1068,7 @@ get_publication_name(Oid pubid, bool missing_ok)
return NULL;
}
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
pubname = pstrdup(NameStr(pubform->pubname));
ReleaseSysCache(tup);
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index 3e8fa008b9..b0f6ca6f8a 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -242,7 +242,7 @@ shdepChangeDep(Relation sdepRel,
while ((scantup = systable_getnext(scan)) != NULL)
{
/* Ignore if not of the target dependency type */
- if (((Form_pg_shdepend) GETSTRUCT(scantup))->deptype != deptype)
+ if ((GETSTRUCT(pg_shdepend, scantup))->deptype != deptype)
continue;
/* Caller screwed up if multiple matches */
if (oldtup)
@@ -263,7 +263,7 @@ shdepChangeDep(Relation sdepRel,
else if (oldtup)
{
/* Need to update existing entry */
- Form_pg_shdepend shForm = (Form_pg_shdepend) GETSTRUCT(oldtup);
+ Form_pg_shdepend shForm = GETSTRUCT(pg_shdepend, oldtup);
/* Since oldtup is a copy, we can just modify it in-memory */
shForm->refclassid = refclassid;
@@ -692,7 +692,7 @@ checkSharedDependencies(Oid classId, Oid objectId,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tup);
+ Form_pg_shdepend sdepForm = GETSTRUCT(pg_shdepend, tup);
object.classId = sdepForm->classid;
object.objectId = sdepForm->objid;
@@ -907,7 +907,7 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId)
memset(slot[slot_stored_count]->tts_isnull, false,
slot[slot_stored_count]->tts_tupleDescriptor->natts * sizeof(bool));
- shdep = (Form_pg_shdepend) GETSTRUCT(tup);
+ shdep = GETSTRUCT(pg_shdepend, tup);
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_dbid - 1] = ObjectIdGetDatum(newDbId);
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_classid - 1] = shdep->classid;
@@ -1115,7 +1115,7 @@ shdepDropDependency(Relation sdepRel,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_shdepend shdepForm = (Form_pg_shdepend) GETSTRUCT(tup);
+ Form_pg_shdepend shdepForm = GETSTRUCT(pg_shdepend, tup);
/* Filter entries according to additional parameters */
if (OidIsValid(refclassId) && shdepForm->refclassid != refclassId)
@@ -1347,7 +1347,7 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
while ((tuple = systable_getnext(scan)) != NULL)
{
- Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tuple);
+ Form_pg_shdepend sdepForm = GETSTRUCT(pg_shdepend, tuple);
ObjectAddress obj;
/*
@@ -1497,7 +1497,7 @@ shdepReassignOwned(List *roleids, Oid newrole)
while ((tuple = systable_getnext(scan)) != NULL)
{
- Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tuple);
+ Form_pg_shdepend sdepForm = GETSTRUCT(pg_shdepend, tuple);
MemoryContext cxt,
oldcxt;
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c
index 8856ce3b50..cb6e1675d9 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_subscription.c
@@ -58,7 +58,7 @@ GetSubscription(Oid subid, bool missing_ok)
elog(ERROR, "cache lookup failed for subscription %u", subid);
}
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = GETSTRUCT(pg_subscription, tup);
sub = (Subscription *) palloc(sizeof(Subscription));
sub->oid = subid;
@@ -239,7 +239,7 @@ get_subscription_name(Oid subid, bool missing_ok)
return NULL;
}
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = GETSTRUCT(pg_subscription, tup);
subname = pstrdup(NameStr(subform->subname));
ReleaseSysCache(tup);
@@ -399,7 +399,7 @@ GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn)
}
/* Get the state. */
- substate = ((Form_pg_subscription_rel) GETSTRUCT(tup))->srsubstate;
+ substate = (GETSTRUCT(pg_subscription_rel, tup))->srsubstate;
/* Get the LSN */
d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
@@ -456,7 +456,7 @@ RemoveSubscriptionRel(Oid subid, Oid relid)
{
Form_pg_subscription_rel subrel;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = GETSTRUCT(pg_subscription_rel, tup);
/*
* We don't allow to drop the relation mapping when the table
@@ -555,7 +555,7 @@ GetSubscriptionRelations(Oid subid)
Datum d;
bool isnull;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = GETSTRUCT(pg_subscription_rel, tup);
relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
@@ -614,7 +614,7 @@ GetSubscriptionNotReadyRelations(Oid subid)
Datum d;
bool isnull;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = GETSTRUCT(pg_subscription_rel, tup);
relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index 03788cb975..9fb756d728 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -424,7 +424,7 @@ TypeCreate(Oid newTypeOid,
ObjectIdGetDatum(typeNamespace));
if (HeapTupleIsValid(tup))
{
- Form_pg_type typform = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typform = GETSTRUCT(pg_type, tup);
/*
* check that the type is not already defined. It may exist as a
@@ -562,7 +562,7 @@ GenerateTypeDependencies(HeapTuple typeTuple,
bool makeExtensionDep,
bool rebuild)
{
- Form_pg_type typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
+ Form_pg_type typeForm = GETSTRUCT(pg_type, typeTuple);
Oid typeObjectId = typeForm->oid;
Datum datum;
bool isNull;
@@ -751,7 +751,7 @@ RenameTypeInternal(Oid typeOid, const char *newTypeName, Oid typeNamespace)
tuple = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typ = (Form_pg_type) GETSTRUCT(tuple);
+ typ = GETSTRUCT(pg_type, tuple);
/* We are not supposed to be changing schemas here */
Assert(typeNamespace == typ->typnamespace);
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index 9bc10729b0..5b10baff8a 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -341,7 +341,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- ((Form_pg_class) GETSTRUCT(reltup))->reltoastrelid = toast_relid;
+ (GETSTRUCT(pg_class, reltup))->reltoastrelid = toast_relid;
if (!IsBootstrapProcessingMode())
{
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 5456b8222b..018582b304 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -243,27 +243,27 @@ AlterObjectRename_internal(Relation rel, Oid objectId, const char *new_name)
*/
if (classId == ProcedureRelationId)
{
- Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(oldtup);
+ Form_pg_proc proc = GETSTRUCT(pg_proc, oldtup);
IsThereFunctionInNamespace(new_name, proc->pronargs,
&proc->proargtypes, proc->pronamespace);
}
else if (classId == CollationRelationId)
{
- Form_pg_collation coll = (Form_pg_collation) GETSTRUCT(oldtup);
+ Form_pg_collation coll = GETSTRUCT(pg_collation, oldtup);
IsThereCollationInNamespace(new_name, coll->collnamespace);
}
else if (classId == OperatorClassRelationId)
{
- Form_pg_opclass opc = (Form_pg_opclass) GETSTRUCT(oldtup);
+ Form_pg_opclass opc = GETSTRUCT(pg_opclass, oldtup);
IsThereOpClassInNamespace(new_name, opc->opcmethod,
opc->opcnamespace);
}
else if (classId == OperatorFamilyRelationId)
{
- Form_pg_opfamily opf = (Form_pg_opfamily) GETSTRUCT(oldtup);
+ Form_pg_opfamily opf = GETSTRUCT(pg_opfamily, oldtup);
IsThereOpFamilyInNamespace(new_name, opf->opfmethod,
opf->opfnamespace);
@@ -769,27 +769,27 @@ AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid)
*/
if (classId == ProcedureRelationId)
{
- Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(tup);
+ Form_pg_proc proc = GETSTRUCT(pg_proc, tup);
IsThereFunctionInNamespace(NameStr(proc->proname), proc->pronargs,
&proc->proargtypes, nspOid);
}
else if (classId == CollationRelationId)
{
- Form_pg_collation coll = (Form_pg_collation) GETSTRUCT(tup);
+ Form_pg_collation coll = GETSTRUCT(pg_collation, tup);
IsThereCollationInNamespace(NameStr(coll->collname), nspOid);
}
else if (classId == OperatorClassRelationId)
{
- Form_pg_opclass opc = (Form_pg_opclass) GETSTRUCT(tup);
+ Form_pg_opclass opc = GETSTRUCT(pg_opclass, tup);
IsThereOpClassInNamespace(NameStr(opc->opcname),
opc->opcmethod, nspOid);
}
else if (classId == OperatorFamilyRelationId)
{
- Form_pg_opfamily opf = (Form_pg_opfamily) GETSTRUCT(tup);
+ Form_pg_opfamily opf = GETSTRUCT(pg_opfamily, tup);
IsThereOpFamilyInNamespace(NameStr(opf->opfname),
opf->opfmethod, nspOid);
diff --git a/src/backend/commands/amcmds.c b/src/backend/commands/amcmds.c
index 914cfa4cc7..ea057efe80 100644
--- a/src/backend/commands/amcmds.c
+++ b/src/backend/commands/amcmds.c
@@ -134,7 +134,7 @@ get_am_type_oid(const char *amname, char amtype, bool missing_ok)
tup = SearchSysCache1(AMNAME, CStringGetDatum(amname));
if (HeapTupleIsValid(tup))
{
- Form_pg_am amform = (Form_pg_am) GETSTRUCT(tup);
+ Form_pg_am amform = GETSTRUCT(pg_am, tup);
if (amtype != '\0' &&
amform->amtype != amtype)
@@ -197,7 +197,7 @@ get_am_name(Oid amOid)
tup = SearchSysCache1(AMOID, ObjectIdGetDatum(amOid));
if (HeapTupleIsValid(tup))
{
- Form_pg_am amform = (Form_pg_am) GETSTRUCT(tup);
+ Form_pg_am amform = GETSTRUCT(pg_am, tup);
result = pstrdup(NameStr(amform->amname));
ReleaseSysCache(tup);
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index a7966fff83..fb4f748ee1 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -1057,7 +1057,7 @@ examine_attribute(Relation onerel, int attnum, Node *index_expr)
ObjectIdGetDatum(stats->attrtypid));
if (!HeapTupleIsValid(typtuple))
elog(ERROR, "cache lookup failed for type %u", stats->attrtypid);
- stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple);
+ stats->attrtype = GETSTRUCT(pg_type, typtuple);
stats->anl_context = anl_context;
stats->tupattnum = attnum;
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index dc35b02910..d5163e038e 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -590,7 +590,7 @@ mark_index_clustered(Relation rel, Oid indexOid, bool is_internal)
ObjectIdGetDatum(thisIndexOid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", thisIndexOid);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
/*
* Unset the bit if set. We know it's wrong because we checked this
@@ -1003,7 +1003,7 @@ copy_table_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(OIDNewHeap));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", OIDNewHeap);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
relform->relpages = num_pages;
relform->reltuples = num_tuples;
@@ -1072,12 +1072,12 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
reltup1 = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(r1));
if (!HeapTupleIsValid(reltup1))
elog(ERROR, "cache lookup failed for relation %u", r1);
- relform1 = (Form_pg_class) GETSTRUCT(reltup1);
+ relform1 = GETSTRUCT(pg_class, reltup1);
reltup2 = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(r2));
if (!HeapTupleIsValid(reltup2))
elog(ERROR, "cache lookup failed for relation %u", r2);
- relform2 = (Form_pg_class) GETSTRUCT(reltup2);
+ relform2 = GETSTRUCT(pg_class, reltup2);
relfilenumber1 = relform1->relfilenode;
relfilenumber2 = relform2->relfilenode;
@@ -1515,7 +1515,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(OIDOldHeap));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", OIDOldHeap);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
relform->relfrozenxid = frozenXid;
relform->relminmxid = cutoffMulti;
@@ -1638,7 +1638,7 @@ get_tables_to_cluster(MemoryContext cluster_context)
{
RelToCluster *rtc;
- index = (Form_pg_index) GETSTRUCT(indexTuple);
+ index = GETSTRUCT(pg_index, indexTuple);
if (!pg_class_ownercheck(index->indrelid, GetUserId()))
continue;
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
index fcfc02d2ae..956249259f 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -137,9 +137,9 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collid);
- collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider;
- collisdeterministic = ((Form_pg_collation) GETSTRUCT(tp))->collisdeterministic;
- collencoding = ((Form_pg_collation) GETSTRUCT(tp))->collencoding;
+ collprovider = (GETSTRUCT(pg_collation, tp))->collprovider;
+ collisdeterministic = (GETSTRUCT(pg_collation, tp))->collisdeterministic;
+ collencoding = (GETSTRUCT(pg_collation, tp))->collencoding;
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collcollate, &isnull);
if (!isnull)
@@ -373,7 +373,7 @@ AlterCollation(AlterCollationStmt *stmt)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for collation %u", collOid);
- collForm = (Form_pg_collation) GETSTRUCT(tup);
+ collForm = GETSTRUCT(pg_collation, tup);
datum = SysCacheGetAttr(COLLOID, tup, Anum_pg_collation_collversion, &isnull);
oldversion = isnull ? NULL : TextDatumGetCString(datum);
@@ -438,7 +438,7 @@ pg_collation_actual_version(PG_FUNCTION_ARGS)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("collation with OID %u does not exist", collid)));
- collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider;
+ collprovider = (GETSTRUCT(pg_collation, tp))->collprovider;
if (collprovider != COLLPROVIDER_DEFAULT)
{
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 1901b434c5..7af9401e34 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -399,7 +399,7 @@ ScanSourceDatabasePgClassTuple(HeapTupleData *tuple, Oid tbid, Oid dbid,
Form_pg_class classForm;
Oid relfilenumber = InvalidRelFileNumber;
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/*
* Return NULL if this object does not need to be copied.
@@ -579,7 +579,7 @@ CreateDatabaseUsingFileCopy(Oid src_dboid, Oid dst_dboid, Oid src_tsid,
scan = table_beginscan_catalog(rel, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_tablespace spaceform = (Form_pg_tablespace) GETSTRUCT(tuple);
+ Form_pg_tablespace spaceform = GETSTRUCT(pg_tablespace, tuple);
Oid srctablespace = spaceform->oid;
Oid dsttablespace;
char *srcpath;
@@ -1792,7 +1792,7 @@ RenameDatabase(const char *oldname, const char *newname)
newtup = SearchSysCacheCopy1(DATABASEOID, ObjectIdGetDatum(db_id));
if (!HeapTupleIsValid(newtup))
elog(ERROR, "cache lookup failed for database %u", db_id);
- namestrcpy(&(((Form_pg_database) GETSTRUCT(newtup))->datname), newname);
+ namestrcpy(&((GETSTRUCT(pg_database, newtup))->datname), newname);
CatalogTupleUpdate(rel, &newtup->t_self, newtup);
InvokeObjectPostAlterHook(DatabaseRelationId, db_id, 0);
@@ -2284,7 +2284,7 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", stmt->dbname)));
- datform = (Form_pg_database) GETSTRUCT(tuple);
+ datform = GETSTRUCT(pg_database, tuple);
dboid = datform->oid;
if (!pg_database_ownercheck(dboid, GetUserId()))
@@ -2371,7 +2371,7 @@ AlterDatabaseRefreshColl(AlterDatabaseRefreshCollStmt *stmt)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", stmt->dbname)));
- datForm = (Form_pg_database) GETSTRUCT(tuple);
+ datForm = GETSTRUCT(pg_database, tuple);
db_id = datForm->oid;
if (!pg_database_ownercheck(db_id, GetUserId()))
@@ -2481,7 +2481,7 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", dbname)));
- datForm = (Form_pg_database) GETSTRUCT(tuple);
+ datForm = GETSTRUCT(pg_database, tuple);
db_id = datForm->oid;
/*
@@ -2581,7 +2581,7 @@ pg_database_collation_actual_version(PG_FUNCTION_ARGS)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("database with OID %u does not exist", dbid)));
- datlocprovider = ((Form_pg_database) GETSTRUCT(tp))->datlocprovider;
+ datlocprovider = (GETSTRUCT(pg_database, tp))->datlocprovider;
datum = SysCacheGetAttr(DATABASEOID, tp, datlocprovider == COLLPROVIDER_ICU ? Anum_pg_database_daticulocale : Anum_pg_database_datcollate, &isnull);
if (isnull)
@@ -2657,7 +2657,7 @@ get_db_info(const char *name, LOCKMODE lockmode,
break;
}
- dbOid = ((Form_pg_database) GETSTRUCT(tuple))->oid;
+ dbOid = (GETSTRUCT(pg_database, tuple))->oid;
systable_endscan(scan);
@@ -2675,7 +2675,7 @@ get_db_info(const char *name, LOCKMODE lockmode,
tuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbOid));
if (HeapTupleIsValid(tuple))
{
- Form_pg_database dbform = (Form_pg_database) GETSTRUCT(tuple);
+ Form_pg_database dbform = GETSTRUCT(pg_database, tuple);
if (strcmp(name, NameStr(dbform->datname)) == 0)
{
@@ -2768,7 +2768,7 @@ have_createdb_privilege(void)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(GetUserId()));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolcreatedb;
+ result = (GETSTRUCT(pg_authid, utup))->rolcreatedb;
ReleaseSysCache(utup);
}
return result;
@@ -2796,7 +2796,7 @@ remove_dbtablespaces(Oid db_id)
scan = table_beginscan_catalog(rel, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_tablespace spcform = (Form_pg_tablespace) GETSTRUCT(tuple);
+ Form_pg_tablespace spcform = GETSTRUCT(pg_tablespace, tuple);
Oid dsttablespace = spcform->oid;
char *dstpath;
struct stat st;
@@ -2882,7 +2882,7 @@ check_db_file_conflict(Oid db_id)
scan = table_beginscan_catalog(rel, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_tablespace spcform = (Form_pg_tablespace) GETSTRUCT(tuple);
+ Form_pg_tablespace spcform = GETSTRUCT(pg_tablespace, tuple);
Oid dsttablespace = spcform->oid;
char *dstpath;
struct stat st;
@@ -2968,7 +2968,7 @@ get_database_oid(const char *dbname, bool missing_ok)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(dbtuple))
- oid = ((Form_pg_database) GETSTRUCT(dbtuple))->oid;
+ oid = (GETSTRUCT(pg_database, dbtuple))->oid;
else
oid = InvalidOid;
@@ -2999,7 +2999,7 @@ get_database_name(Oid dbid)
dbtuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbid));
if (HeapTupleIsValid(dbtuple))
{
- result = pstrdup(NameStr(((Form_pg_database) GETSTRUCT(dbtuple))->datname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_database, dbtuple))->datname));
ReleaseSysCache(dbtuple);
}
else
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index f46f86474a..04d5f2ed68 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -376,7 +376,7 @@ AlterEventTrigger(AlterEventTrigStmt *stmt)
errmsg("event trigger \"%s\" does not exist",
stmt->trigname)));
- evtForm = (Form_pg_event_trigger) GETSTRUCT(tup);
+ evtForm = GETSTRUCT(pg_event_trigger, tup);
trigoid = evtForm->oid;
if (!pg_event_trigger_ownercheck(trigoid, GetUserId()))
@@ -419,7 +419,7 @@ AlterEventTriggerOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("event trigger \"%s\" does not exist", name)));
- evtForm = (Form_pg_event_trigger) GETSTRUCT(tup);
+ evtForm = GETSTRUCT(pg_event_trigger, tup);
evtOid = evtForm->oid;
AlterEventTriggerOwner_internal(rel, tup, newOwnerId);
@@ -466,7 +466,7 @@ AlterEventTriggerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
{
Form_pg_event_trigger form;
- form = (Form_pg_event_trigger) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_event_trigger, tup);
if (form->evtowner == newOwnerId)
return;
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index 3db859c3ea..fd31544069 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -159,7 +159,7 @@ get_extension_oid(const char *extname, bool missing_ok)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = ((Form_pg_extension) GETSTRUCT(tuple))->oid;
+ result = (GETSTRUCT(pg_extension, tuple))->oid;
else
result = InvalidOid;
@@ -204,7 +204,7 @@ get_extension_name(Oid ext_oid)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = pstrdup(NameStr(((Form_pg_extension) GETSTRUCT(tuple))->extname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_extension, tuple))->extname));
else
result = NULL;
@@ -243,7 +243,7 @@ get_extension_schema(Oid ext_oid)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = ((Form_pg_extension) GETSTRUCT(tuple))->extnamespace;
+ result = (GETSTRUCT(pg_extension, tuple))->extnamespace;
else
result = InvalidOid;
@@ -2762,7 +2762,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
/* Copy tuple so we can modify it below */
extTup = heap_copytuple(extTup);
- extForm = (Form_pg_extension) GETSTRUCT(extTup);
+ extForm = GETSTRUCT(pg_extension, extTup);
systable_endscan(extScan);
@@ -2805,7 +2805,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
while (HeapTupleIsValid(depTup = systable_getnext(depScan)))
{
- Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend pg_depend = GETSTRUCT(pg_depend, depTup);
ObjectAddress dep;
Oid dep_oldNspOid;
@@ -2927,7 +2927,7 @@ ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt)
errmsg("extension \"%s\" does not exist",
stmt->extname)));
- extensionOid = ((Form_pg_extension) GETSTRUCT(extTup))->oid;
+ extensionOid = (GETSTRUCT(pg_extension, extTup))->oid;
/*
* Determine the existing version we are updating from
@@ -3079,7 +3079,7 @@ ApplyExtensionUpdates(Oid extensionOid,
elog(ERROR, "could not find tuple for extension %u",
extensionOid);
- extForm = (Form_pg_extension) GETSTRUCT(extTup);
+ extForm = GETSTRUCT(pg_extension, extTup);
/*
* Determine the target schema (set by original install)
diff --git a/src/backend/commands/foreigncmds.c b/src/backend/commands/foreigncmds.c
index ea27857bb8..899e1cceef 100644
--- a/src/backend/commands/foreigncmds.c
+++ b/src/backend/commands/foreigncmds.c
@@ -212,7 +212,7 @@ AlterForeignDataWrapperOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerI
Datum aclDatum;
bool isNull;
- form = (Form_pg_foreign_data_wrapper) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_foreign_data_wrapper, tup);
/* Must be a superuser to change a FDW owner */
if (!superuser())
@@ -290,7 +290,7 @@ AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign-data wrapper \"%s\" does not exist", name)));
- form = (Form_pg_foreign_data_wrapper) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_foreign_data_wrapper, tup);
fdwId = form->oid;
AlterForeignDataWrapperOwner_internal(rel, tup, newOwnerId);
@@ -345,7 +345,7 @@ AlterForeignServerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
Datum aclDatum;
bool isNull;
- form = (Form_pg_foreign_server) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_foreign_server, tup);
if (form->srvowner != newOwnerId)
{
@@ -429,7 +429,7 @@ AlterForeignServerOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("server \"%s\" does not exist", name)));
- form = (Form_pg_foreign_server) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_foreign_server, tup);
servOid = form->oid;
AlterForeignServerOwner_internal(rel, tup, newOwnerId);
@@ -706,7 +706,7 @@ AlterForeignDataWrapper(ParseState *pstate, AlterFdwStmt *stmt)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign-data wrapper \"%s\" does not exist", stmt->fdwname)));
- fdwForm = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp);
+ fdwForm = GETSTRUCT(pg_foreign_data_wrapper, tp);
fdwId = fdwForm->oid;
memset(repl_val, 0, sizeof(repl_val));
@@ -983,7 +983,7 @@ AlterForeignServer(AlterForeignServerStmt *stmt)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("server \"%s\" does not exist", stmt->servername)));
- srvForm = (Form_pg_foreign_server) GETSTRUCT(tp);
+ srvForm = GETSTRUCT(pg_foreign_server, tp);
srvId = srvForm->oid;
/*
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index b016eecb2c..cdac19d505 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -101,7 +101,7 @@ compute_return_type(TypeName *returnType, Oid languageOid,
if (typtup)
{
- if (!((Form_pg_type) GETSTRUCT(typtup))->typisdefined)
+ if (!(GETSTRUCT(pg_type, typtup))->typisdefined)
{
if (languageOid == SQLlanguageId)
ereport(ERROR,
@@ -241,7 +241,7 @@ interpret_function_parameter_list(ParseState *pstate,
typtup = LookupTypeName(NULL, t, NULL, false);
if (typtup)
{
- if (!((Form_pg_type) GETSTRUCT(typtup))->typisdefined)
+ if (!(GETSTRUCT(pg_type, typtup))->typisdefined)
{
/* As above, hard error if language is SQL */
if (languageOid == SQLlanguageId)
@@ -1106,7 +1106,7 @@ CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
(extension_file_exists(language) ?
errhint("Use CREATE EXTENSION to load the language into the database.") : 0)));
- languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
+ languageStruct = GETSTRUCT(pg_language, languageTuple);
languageOid = languageStruct->oid;
if (languageStruct->lanpltrusted)
@@ -1313,7 +1313,7 @@ RemoveFunctionById(Oid funcOid)
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", funcOid);
- prokind = ((Form_pg_proc) GETSTRUCT(tup))->prokind;
+ prokind = (GETSTRUCT(pg_proc, tup))->prokind;
CatalogTupleDelete(relation, &tup->t_self);
@@ -1377,7 +1377,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", funcOid);
- procForm = (Form_pg_proc) GETSTRUCT(tup);
+ procForm = GETSTRUCT(pg_proc, tup);
/* Permission check: must own function */
if (!pg_proc_ownercheck(funcOid, GetUserId()))
@@ -1600,7 +1600,7 @@ CreateCast(CreateCastStmt *stmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procstruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procstruct = GETSTRUCT(pg_proc, tuple);
nargs = procstruct->pronargs;
if (nargs < 1 || nargs > 3)
ereport(ERROR,
@@ -1868,7 +1868,7 @@ CreateTransform(CreateTransformStmt *stmt)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(fromsqlfuncid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", fromsqlfuncid);
- procstruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procstruct = GETSTRUCT(pg_proc, tuple);
if (procstruct->prorettype != INTERNALOID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
@@ -1894,7 +1894,7 @@ CreateTransform(CreateTransformStmt *stmt)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(tosqlfuncid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", tosqlfuncid);
- procstruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procstruct = GETSTRUCT(pg_proc, tuple);
if (procstruct->prorettype != typeid)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
@@ -1922,7 +1922,7 @@ CreateTransform(CreateTransformStmt *stmt)
ObjectIdGetDatum(langid));
if (HeapTupleIsValid(tuple))
{
- Form_pg_transform form = (Form_pg_transform) GETSTRUCT(tuple);
+ Form_pg_transform form = GETSTRUCT(pg_transform, tuple);
if (!stmt->replace)
ereport(ERROR,
@@ -2106,7 +2106,7 @@ ExecuteDoStmt(ParseState *pstate, DoStmt *stmt, bool atomic)
(extension_file_exists(language) ?
errhint("Use CREATE EXTENSION to load the language into the database.") : 0)));
- languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
+ languageStruct = GETSTRUCT(pg_language, languageTuple);
codeblock->langOid = languageStruct->oid;
codeblock->langIsTrusted = languageStruct->lanpltrusted;
codeblock->atomic = atomic;
@@ -2220,7 +2220,7 @@ ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver
* and AbortTransaction() resets the security context. This could be
* reorganized, but right now it doesn't work.
*/
- if (((Form_pg_proc) GETSTRUCT(tp))->prosecdef)
+ if ((GETSTRUCT(pg_proc, tp))->prosecdef)
callcontext->atomic = true;
ReleaseSysCache(tp);
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index ff847579f3..233d265f71 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -212,7 +212,7 @@ CheckIndexCompatible(Oid oldId,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("access method \"%s\" does not exist",
accessMethodName)));
- accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
+ accessMethodForm = GETSTRUCT(pg_am, tuple);
accessMethodId = accessMethodForm->oid;
amRoutine = GetIndexAmRoutine(accessMethodForm->amhandler);
ReleaseSysCache(tuple);
@@ -245,7 +245,7 @@ CheckIndexCompatible(Oid oldId,
tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(oldId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u", oldId);
- indexForm = (Form_pg_index) GETSTRUCT(tuple);
+ indexForm = GETSTRUCT(pg_index, tuple);
/*
* We don't assess expressions or predicates; assume incompatibility.
@@ -833,7 +833,7 @@ DefineIndex(Oid relationId,
errmsg("access method \"%s\" does not exist",
accessMethodName)));
}
- accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
+ accessMethodForm = GETSTRUCT(pg_am, tuple);
accessMethodId = accessMethodForm->oid;
amRoutine = GetIndexAmRoutine(accessMethodForm->amhandler);
@@ -1441,7 +1441,7 @@ DefineIndex(Oid relationId,
elog(ERROR, "cache lookup failed for index %u",
indexRelationId);
newtup = heap_copytuple(tup);
- ((Form_pg_index) GETSTRUCT(newtup))->indisvalid = false;
+ (GETSTRUCT(pg_index, newtup))->indisvalid = false;
CatalogTupleUpdate(pg_index, &tup->t_self, newtup);
ReleaseSysCache(tup);
table_close(pg_index, RowExclusiveLock);
@@ -1822,7 +1822,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
errmsg("column \"%s\" does not exist",
attribute->name)));
}
- attform = (Form_pg_attribute) GETSTRUCT(atttuple);
+ attform = GETSTRUCT(pg_attribute, atttuple);
indexInfo->ii_IndexAttrNumbers[attn] = attform->attnum;
atttype = attform->atttypid;
attcollation = attform->attcollation;
@@ -2044,7 +2044,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
if (!HeapTupleIsValid(opftuple))
elog(ERROR, "cache lookup failed for opfamily %u",
opfamily);
- opfform = (Form_pg_opfamily) GETSTRUCT(opftuple);
+ opfform = GETSTRUCT(pg_opfamily, opftuple);
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -2183,7 +2183,7 @@ ResolveOpClass(List *opclass, Oid attrType,
* Verify that the index operator class accepts this datatype. Note we
* will accept binary compatibility.
*/
- opform = (Form_pg_opclass) GETSTRUCT(tuple);
+ opform = GETSTRUCT(pg_opclass, tuple);
opClassId = opform->oid;
opInputType = opform->opcintype;
@@ -2246,7 +2246,7 @@ GetDefaultOpClass(Oid type_id, Oid am_id)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_opclass opclass = (Form_pg_opclass) GETSTRUCT(tup);
+ Form_pg_opclass opclass = GETSTRUCT(pg_opclass, tup);
/* ignore altogether if not a default opclass */
if (!opclass->opcdefault)
@@ -2951,7 +2951,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
scan = table_beginscan_catalog(relationRelation, num_keys, scan_keys);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classtuple = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classtuple = GETSTRUCT(pg_class, tuple);
Oid relid = classtuple->oid;
/*
@@ -4194,7 +4194,7 @@ IndexSetParentIndex(Relation partitionIdx, Oid parentOid)
}
else
{
- Form_pg_inherits inhForm = (Form_pg_inherits) GETSTRUCT(tuple);
+ Form_pg_inherits inhForm = GETSTRUCT(pg_inherits, tuple);
if (parentOid == InvalidOid)
{
@@ -4285,8 +4285,8 @@ update_relispartition(Oid relationId, bool newval)
tup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for relation %u", relationId);
- Assert(((Form_pg_class) GETSTRUCT(tup))->relispartition != newval);
- ((Form_pg_class) GETSTRUCT(tup))->relispartition = newval;
+ Assert((GETSTRUCT(pg_class, tup))->relispartition != newval);
+ (GETSTRUCT(pg_class, tup))->relispartition = newval;
CatalogTupleUpdate(classRel, &tup->t_self, tup);
heap_freetuple(tup);
table_close(classRel, RowExclusiveLock);
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c
index 9ac0383459..0e5e86ccb3 100644
--- a/src/backend/commands/matview.c
+++ b/src/backend/commands/matview.c
@@ -100,7 +100,7 @@ SetMatViewPopulatedState(Relation relation, bool newstate)
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(relation));
- ((Form_pg_class) GETSTRUCT(tuple))->relispopulated = newstate;
+ (GETSTRUCT(pg_class, tuple))->relispopulated = newstate;
CatalogTupleUpdate(pgrel, &tuple->t_self, tuple);
@@ -724,7 +724,7 @@ refresh_by_match_merge(Oid matviewOid, Oid tempOid, Oid relowner,
cla_ht = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(cla_ht))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- cla_tup = (Form_pg_opclass) GETSTRUCT(cla_ht);
+ cla_tup = GETSTRUCT(pg_opclass, cla_ht);
Assert(cla_tup->opcmethod == BTREE_AM_OID);
opfamily = cla_tup->opcfamily;
opcintype = cla_tup->opcintype;
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 7a931ab758..91b782ed0f 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -123,7 +123,7 @@ OpFamilyCacheLookup(Oid amID, List *opfamilyname, bool missing_ok)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("operator family \"%s\" does not exist for access method \"%s\"",
NameListToString(opfamilyname),
- NameStr(((Form_pg_am) GETSTRUCT(amtup))->amname))));
+ NameStr((GETSTRUCT(pg_am, amtup))->amname))));
}
return htup;
@@ -145,7 +145,7 @@ get_opfamily_oid(Oid amID, List *opfamilyname, bool missing_ok)
htup = OpFamilyCacheLookup(amID, opfamilyname, missing_ok);
if (!HeapTupleIsValid(htup))
return InvalidOid;
- opfamform = (Form_pg_opfamily) GETSTRUCT(htup);
+ opfamform = GETSTRUCT(pg_opfamily, htup);
opfID = opfamform->oid;
ReleaseSysCache(htup);
@@ -204,7 +204,7 @@ OpClassCacheLookup(Oid amID, List *opclassname, bool missing_ok)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("operator class \"%s\" does not exist for access method \"%s\"",
NameListToString(opclassname),
- NameStr(((Form_pg_am) GETSTRUCT(amtup))->amname))));
+ NameStr((GETSTRUCT(pg_am, amtup))->amname))));
}
return htup;
@@ -226,7 +226,7 @@ get_opclass_oid(Oid amID, List *opclassname, bool missing_ok)
htup = OpClassCacheLookup(amID, opclassname, missing_ok);
if (!HeapTupleIsValid(htup))
return InvalidOid;
- opcform = (Form_pg_opclass) GETSTRUCT(htup);
+ opcform = GETSTRUCT(pg_opclass, htup);
opcID = opcform->oid;
ReleaseSysCache(htup);
@@ -375,7 +375,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
errmsg("access method \"%s\" does not exist",
stmt->amname)));
- amform = (Form_pg_am) GETSTRUCT(tup);
+ amform = GETSTRUCT(pg_am, tup);
amoid = amform->oid;
amroutine = GetIndexAmRoutineByAmId(amoid, false);
ReleaseSysCache(tup);
@@ -442,7 +442,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
ObjectIdGetDatum(namespaceoid));
if (HeapTupleIsValid(tup))
{
- opfamilyoid = ((Form_pg_opfamily) GETSTRUCT(tup))->oid;
+ opfamilyoid = (GETSTRUCT(pg_opfamily, tup))->oid;
/*
* XXX given the superuser check above, there's no need for an
@@ -630,7 +630,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_opclass opclass = (Form_pg_opclass) GETSTRUCT(tup);
+ Form_pg_opclass opclass = GETSTRUCT(pg_opclass, tup);
if (opclass->opcintype == typeoid && opclass->opcdefault)
ereport(ERROR,
@@ -833,7 +833,7 @@ AlterOpFamily(AlterOpFamilyStmt *stmt)
errmsg("access method \"%s\" does not exist",
stmt->amname)));
- amform = (Form_pg_am) GETSTRUCT(tup);
+ amform = GETSTRUCT(pg_am, tup);
amoid = amform->oid;
amroutine = GetIndexAmRoutineByAmId(amoid, false);
ReleaseSysCache(tup);
@@ -1143,7 +1143,7 @@ assignOperTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
optup = SearchSysCache1(OPEROID, ObjectIdGetDatum(member->object));
if (!HeapTupleIsValid(optup))
elog(ERROR, "cache lookup failed for operator %u", member->object);
- opform = (Form_pg_operator) GETSTRUCT(optup);
+ opform = GETSTRUCT(pg_operator, optup);
/*
* Opfamily operators must be binary.
@@ -1210,7 +1210,7 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid,
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(member->object));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", member->object);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
/* Check the signature of the opclass options parsing function */
if (member->number == opclassOptsProcNum)
diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c
index a5924d7d56..312588f296 100644
--- a/src/backend/commands/operatorcmds.c
+++ b/src/backend/commands/operatorcmds.c
@@ -372,7 +372,7 @@ RemoveOperatorById(Oid operOid)
tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for operator %u", operOid);
- op = (Form_pg_operator) GETSTRUCT(tup);
+ op = GETSTRUCT(pg_operator, tup);
/*
* Reset links from commutator and negator, if any. In case of a
@@ -431,7 +431,7 @@ AlterOperator(AlterOperatorStmt *stmt)
tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for operator %u", oprId);
- oprForm = (Form_pg_operator) GETSTRUCT(tup);
+ oprForm = GETSTRUCT(pg_operator, tup);
/* Process options */
foreach(pl, stmt->options)
diff --git a/src/backend/commands/policy.c b/src/backend/commands/policy.c
index d9dff9ecaa..99e210fb7c 100644
--- a/src/backend/commands/policy.c
+++ b/src/backend/commands/policy.c
@@ -75,7 +75,7 @@ RangeVarCallbackForPolicy(const RangeVar *rv, Oid relid, Oid oldrelid,
if (!HeapTupleIsValid(tuple))
return;
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
relkind = classform->relkind;
/* Must own relation. */
@@ -236,7 +236,7 @@ RelationBuildRowSecurity(Relation relation)
while (HeapTupleIsValid(tuple = systable_getnext(sscan)))
{
- Form_pg_policy policy_form = (Form_pg_policy) GETSTRUCT(tuple);
+ Form_pg_policy policy_form = GETSTRUCT(pg_policy, tuple);
RowSecurityPolicy *policy;
Datum datum;
bool isnull;
@@ -366,7 +366,7 @@ RemovePolicyById(Oid policy_id)
* set of policies the rel has; furthermore we've got to hold the lock
* till commit.)
*/
- relid = ((Form_pg_policy) GETSTRUCT(tuple))->polrelid;
+ relid = (GETSTRUCT(pg_policy, tuple))->polrelid;
rel = table_open(relid, AccessExclusiveLock);
if (rel->rd_rel->relkind != RELKIND_RELATION &&
@@ -455,7 +455,7 @@ RemoveRoleFromObjectPolicy(Oid roleid, Oid classid, Oid policy_id)
elog(ERROR, "could not find tuple for policy %u", policy_id);
/* Identify rel the policy belongs to */
- relid = ((Form_pg_policy) GETSTRUCT(tuple))->polrelid;
+ relid = (GETSTRUCT(pg_policy, tuple))->polrelid;
/* Get the current set of roles */
roles_datum = heap_getattr(tuple,
@@ -917,7 +917,7 @@ AlterPolicy(AlterPolicyStmt *stmt)
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("only WITH CHECK expression allowed for INSERT")));
- policy_id = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid;
+ policy_id = (GETSTRUCT(pg_policy, policy_tuple))->oid;
if (role_ids != NULL)
{
@@ -1169,11 +1169,11 @@ rename_policy(RenameStmt *stmt)
errmsg("policy \"%s\" for table \"%s\" does not exist",
stmt->subname, RelationGetRelationName(target_table))));
- opoloid = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid;
+ opoloid = (GETSTRUCT(pg_policy, policy_tuple))->oid;
policy_tuple = heap_copytuple(policy_tuple);
- namestrcpy(&((Form_pg_policy) GETSTRUCT(policy_tuple))->polname,
+ namestrcpy(&(GETSTRUCT(pg_policy, policy_tuple))->polname,
stmt->newname);
CatalogTupleUpdate(pg_policy_rel, &policy_tuple->t_self, policy_tuple);
@@ -1243,7 +1243,7 @@ get_relation_policy_oid(Oid relid, const char *policy_name, bool missing_ok)
policy_oid = InvalidOid;
}
else
- policy_oid = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid;
+ policy_oid = (GETSTRUCT(pg_policy, policy_tuple))->oid;
/* Clean up. */
systable_endscan(sscan);
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c
index 4a093f45d8..d28274e3c4 100644
--- a/src/backend/commands/proclang.c
+++ b/src/backend/commands/proclang.c
@@ -124,7 +124,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
if (HeapTupleIsValid(oldtup))
{
- Form_pg_language oldform = (Form_pg_language) GETSTRUCT(oldtup);
+ Form_pg_language oldform = GETSTRUCT(pg_language, oldtup);
/* There is one; okay to replace it? */
if (!stmt->replace)
diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index 8e645741e4..c939ae689a 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -922,7 +922,7 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt,
&publish_via_partition_root_given,
&publish_via_partition_root);
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
/*
* If the publication doesn't publish changes via the root partitioned
@@ -1038,7 +1038,7 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt,
CommandCounterIncrement();
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
/* Invalidate the relcache. */
if (pubform->puballtables)
@@ -1114,7 +1114,7 @@ AlterPublicationTables(AlterPublicationStmt *stmt, HeapTuple tup,
const char *queryString)
{
List *rels = NIL;
- Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
+ Form_pg_publication pubform = GETSTRUCT(pg_publication, tup);
Oid pubid = pubform->oid;
/*
@@ -1291,7 +1291,7 @@ static void
AlterPublicationSchemas(AlterPublicationStmt *stmt,
HeapTuple tup, List *schemaidlist)
{
- Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
+ Form_pg_publication pubform = GETSTRUCT(pg_publication, tup);
/*
* Nothing to do if no objects, except in SET: for that it is quite
@@ -1355,7 +1355,7 @@ static void
CheckAlterPublication(AlterPublicationStmt *stmt, HeapTuple tup,
List *tables, List *schemaidlist)
{
- Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
+ Form_pg_publication pubform = GETSTRUCT(pg_publication, tup);
if ((stmt->action == AP_AddObjects || stmt->action == AP_SetObjects) &&
schemaidlist && !superuser())
@@ -1407,7 +1407,7 @@ AlterPublication(ParseState *pstate, AlterPublicationStmt *stmt)
errmsg("publication \"%s\" does not exist",
stmt->pubname)));
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
/* must be owner */
if (!pg_publication_ownercheck(pubform->oid, GetUserId()))
@@ -1482,7 +1482,7 @@ RemovePublicationRelById(Oid proid)
elog(ERROR, "cache lookup failed for publication table %u",
proid);
- pubrel = (Form_pg_publication_rel) GETSTRUCT(tup);
+ pubrel = GETSTRUCT(pg_publication_rel, tup);
/*
* Invalidate relcache so that publication info is rebuilt.
@@ -1520,7 +1520,7 @@ RemovePublicationById(Oid pubid)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication %u", pubid);
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
/* Invalidate relcache so that publication info is rebuilt. */
if (pubform->puballtables)
@@ -1551,7 +1551,7 @@ RemovePublicationSchemaById(Oid psoid)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication schema %u", psoid);
- pubsch = (Form_pg_publication_namespace) GETSTRUCT(tup);
+ pubsch = GETSTRUCT(pg_publication_namespace, tup);
/*
* Invalidate relcache so that publication info is rebuilt. See
@@ -1944,7 +1944,7 @@ AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
{
Form_pg_publication form;
- form = (Form_pg_publication) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_publication, tup);
if (form->pubowner == newOwnerId)
return;
@@ -2015,7 +2015,7 @@ AlterPublicationOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("publication \"%s\" does not exist", name)));
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
subid = pubform->oid;
AlterPublicationOwner_internal(rel, tup, newOwnerId);
diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c
index be3925b3b4..204bd066fa 100644
--- a/src/backend/commands/schemacmds.c
+++ b/src/backend/commands/schemacmds.c
@@ -80,7 +80,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for role %u", owner_uid);
schemaName =
- pstrdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname));
+ pstrdup(NameStr((GETSTRUCT(pg_authid, tuple))->rolname));
ReleaseSysCache(tuple);
}
@@ -233,7 +233,7 @@ RenameSchema(const char *oldname, const char *newname)
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema \"%s\" does not exist", oldname)));
- nspform = (Form_pg_namespace) GETSTRUCT(tup);
+ nspform = GETSTRUCT(pg_namespace, tup);
nspOid = nspform->oid;
/* make sure the new name doesn't exist */
@@ -313,7 +313,7 @@ AlterSchemaOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema \"%s\" does not exist", name)));
- nspform = (Form_pg_namespace) GETSTRUCT(tup);
+ nspform = GETSTRUCT(pg_namespace, tup);
nspOid = nspform->oid;
AlterSchemaOwner_internal(tup, rel, newOwnerId);
@@ -335,7 +335,7 @@ AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerId)
Assert(tup->t_tableOid == NamespaceRelationId);
Assert(RelationGetRelid(rel) == NamespaceRelationId);
- nspForm = (Form_pg_namespace) GETSTRUCT(tup);
+ nspForm = GETSTRUCT(pg_namespace, tup);
/*
* If the new owner is the same as the existing owner, consider the
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index b0b211891c..d070904fb1 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -286,7 +286,7 @@ ResetSequence(Oid seq_relid)
pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(seq_relid));
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", seq_relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
startv = pgsform->seqstart;
ReleaseSysCache(pgstuple);
@@ -302,7 +302,7 @@ ResetSequence(Oid seq_relid)
* Modify the copied tuple to execute the restart (compare the RESTART
* action in AlterSequence)
*/
- seq = (Form_pg_sequence_data) GETSTRUCT(tuple);
+ seq = GETSTRUCT(pg_sequence_data, tuple);
seq->last_value = startv;
seq->is_called = false;
seq->log_cnt = 0;
@@ -478,14 +478,14 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
elog(ERROR, "cache lookup failed for sequence %u",
relid);
- seqform = (Form_pg_sequence) GETSTRUCT(seqtuple);
+ seqform = GETSTRUCT(pg_sequence, seqtuple);
/* lock page's buffer and read tuple into new sequence structure */
(void) read_seq_tuple(seqrel, &buf, &datatuple);
/* copy the existing sequence data tuple, so it can be modified locally */
newdatatuple = heap_copytuple(&datatuple);
- newdataform = (Form_pg_sequence_data) GETSTRUCT(newdatatuple);
+ newdataform = GETSTRUCT(pg_sequence_data, newdatatuple);
UnlockReleaseBuffer(buf);
@@ -676,7 +676,7 @@ nextval_internal(Oid relid, bool check_permissions)
pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
incby = pgsform->seqincrement;
maxv = pgsform->seqmax;
minv = pgsform->seqmin;
@@ -964,7 +964,7 @@ do_setval(Oid relid, int64 next, bool iscalled)
pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
maxv = pgsform->seqmax;
minv = pgsform->seqmin;
ReleaseSysCache(pgstuple);
@@ -1232,7 +1232,7 @@ read_seq_tuple(Relation rel, Buffer *buf, HeapTuple seqdatatuple)
MarkBufferDirtyHint(*buf, true);
}
- seq = (Form_pg_sequence_data) GETSTRUCT(seqdatatuple);
+ seq = GETSTRUCT(pg_sequence_data, seqdatatuple);
return seq;
}
@@ -1714,7 +1714,7 @@ sequence_options(Oid relid)
pgstuple = SearchSysCache1(SEQRELID, relid);
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
/* Use makeFloat() for 64-bit integers, like gram.y does. */
options = lappend(options,
@@ -1777,7 +1777,7 @@ pg_sequence_parameters(PG_FUNCTION_ARGS)
pgstuple = SearchSysCache1(SEQRELID, relid);
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
values[0] = Int64GetDatum(pgsform->seqstart);
values[1] = Int64GetDatum(pgsform->seqmin);
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index cd5e2f2b6b..68e599a104 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -238,7 +238,7 @@ CreateStatistics(CreateStatsStmt *stmt)
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" does not exist",
attname)));
- attForm = (Form_pg_attribute) GETSTRUCT(atttuple);
+ attForm = GETSTRUCT(pg_attribute, atttuple);
/* Disallow use of system attributes in extended stats */
if (attForm->attnum <= 0)
@@ -754,7 +754,7 @@ RemoveStatisticsById(Oid statsOid)
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for statistics object %u", statsOid);
- statext = (Form_pg_statistic_ext) GETSTRUCT(tup);
+ statext = GETSTRUCT(pg_statistic_ext, tup);
relid = statext->stxrelid;
CacheInvalidateRelcacheByRelid(relid);
@@ -885,7 +885,7 @@ StatisticsGetRelation(Oid statId, bool missing_ok)
return InvalidOid;
elog(ERROR, "cache lookup failed for statistics object %u", statId);
}
- stx = (Form_pg_statistic_ext) GETSTRUCT(tuple);
+ stx = GETSTRUCT(pg_statistic_ext, tuple);
Assert(stx->oid == statId);
result = stx->stxrelid;
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index bdc1208724..722d5337fc 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -990,7 +990,7 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt,
errmsg("subscription \"%s\" does not exist",
stmt->subname)));
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_subscription, tup);
subid = form->oid;
/* must be owner */
@@ -1362,7 +1362,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
return;
}
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_subscription, tup);
subid = form->oid;
/* must be owner */
@@ -1652,7 +1652,7 @@ AlterSubscriptionOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
{
Form_pg_subscription form;
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_subscription, tup);
if (form->subowner == newOwnerId)
return;
@@ -1705,7 +1705,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("subscription \"%s\" does not exist", name)));
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_subscription, tup);
subid = form->oid;
AlterSubscriptionOwner_internal(rel, tup, newOwnerId);
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index f2947ea9b4..5fe2701ed1 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -1543,7 +1543,7 @@ RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid, Oid oldRelOid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped, so nothing to do */
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
is_partition = classform->relispartition;
/* Pass back some data to save lookups in RemoveRelations */
@@ -1595,7 +1595,7 @@ RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid, Oid oldRelOid,
return;
}
- indexform = (Form_pg_index) GETSTRUCT(locTuple);
+ indexform = GETSTRUCT(pg_index, locTuple);
indisvalid = indexform->indisvalid;
ReleaseSysCache(locTuple);
@@ -3248,7 +3248,7 @@ SetRelationHasSubclass(Oid relationId, bool relhassubclass)
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationId);
- classtuple = (Form_pg_class) GETSTRUCT(tuple);
+ classtuple = GETSTRUCT(pg_class, tuple);
if (classtuple->relhassubclass != relhassubclass)
{
@@ -3350,7 +3350,7 @@ SetRelationTableSpace(Relation rel,
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(reloid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", reloid);
- rd_rel = (Form_pg_class) GETSTRUCT(tuple);
+ rd_rel = GETSTRUCT(pg_class, tuple);
/* Update the pg_class row. */
rd_rel->reltablespace = (newTableSpaceId == MyDatabaseTableSpace) ?
@@ -3522,7 +3522,7 @@ renameatt_internal(Oid myrelid,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" does not exist",
oldattname)));
- attform = (Form_pg_attribute) GETSTRUCT(atttup);
+ attform = GETSTRUCT(pg_attribute, atttup);
attnum = attform->attnum;
if (attnum <= 0)
@@ -3578,7 +3578,7 @@ RangeVarCallbackForRenameAttribute(const RangeVar *rv, Oid relid, Oid oldrelid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped */
- form = (Form_pg_class) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_class, tuple);
renameatt_check(relid, form, false);
ReleaseSysCache(tuple);
}
@@ -3664,7 +3664,7 @@ rename_constraint_internal(Oid myrelid,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u",
constraintOid);
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
if (myrelid && con->contype == CONSTRAINT_CHECK && !con->connoinherit)
{
@@ -3876,7 +3876,7 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bo
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for relation %u", myrelid);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
if (get_relname_relid(newrelname, namespaceId) != InvalidOid)
ereport(ERROR,
@@ -3951,7 +3951,7 @@ ResetRelRewrite(Oid myrelid)
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for relation %u", myrelid);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
/*
* Update pg_class tuple.
@@ -6447,7 +6447,7 @@ find_composite_type_dependencies(Oid typeOid, Relation origRelation,
while (HeapTupleIsValid(depTup = systable_getnext(depScan)))
{
- Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend pg_depend = GETSTRUCT(pg_depend, depTup);
Relation rel;
Form_pg_attribute att;
@@ -6553,7 +6553,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classform = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classform = GETSTRUCT(pg_class, tuple);
if (behavior == DROP_RESTRICT)
ereport(ERROR,
@@ -6585,7 +6585,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
void
check_of_type(HeapTuple typetuple)
{
- Form_pg_type typ = (Form_pg_type) GETSTRUCT(typetuple);
+ Form_pg_type typ = GETSTRUCT(pg_type, typetuple);
bool typeOk = false;
if (typ->typtype == TYPTYPE_COMPOSITE)
@@ -6704,7 +6704,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
tuple = SearchSysCacheCopyAttName(myrelid, colDef->colname);
if (HeapTupleIsValid(tuple))
{
- Form_pg_attribute childatt = (Form_pg_attribute) GETSTRUCT(tuple);
+ Form_pg_attribute childatt = GETSTRUCT(pg_attribute, tuple);
Oid ctypeId;
int32 ctypmod;
Oid ccollid;
@@ -6785,10 +6785,10 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", myrelid);
- relkind = ((Form_pg_class) GETSTRUCT(reltup))->relkind;
+ relkind = (GETSTRUCT(pg_class, reltup))->relkind;
/* Determine the new attribute's number */
- newattnum = ((Form_pg_class) GETSTRUCT(reltup))->relnatts + 1;
+ newattnum = (GETSTRUCT(pg_class, reltup))->relnatts + 1;
if (newattnum > MaxHeapAttributeNumber)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_COLUMNS),
@@ -6796,7 +6796,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
MaxHeapAttributeNumber)));
typeTuple = typenameType(NULL, colDef->typeName, &typmod);
- tform = (Form_pg_type) GETSTRUCT(typeTuple);
+ tform = GETSTRUCT(pg_type, typeTuple);
typeOid = tform->oid;
aclresult = pg_type_aclcheck(typeOid, GetUserId(), ACL_USAGE);
@@ -6851,7 +6851,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
/*
* Update pg_class tuple as appropriate
*/
- ((Form_pg_class) GETSTRUCT(reltup))->relnatts = newattnum;
+ (GETSTRUCT(pg_class, reltup))->relnatts = newattnum;
CatalogTupleUpdate(pgclass, &reltup->t_self, reltup);
@@ -7084,7 +7084,7 @@ check_for_column_name_collision(Relation rel, const char *colname,
if (!HeapTupleIsValid(attTuple))
return true;
- attnum = ((Form_pg_attribute) GETSTRUCT(attTuple))->attnum;
+ attnum = (GETSTRUCT(pg_attribute, attTuple))->attnum;
ReleaseSysCache(attTuple);
/*
@@ -7207,7 +7207,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
/* Prevent them from altering a system attribute */
@@ -7243,7 +7243,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexoid);
- indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexStruct = GETSTRUCT(pg_index, indexTuple);
/*
* If the index is not a primary key or an index used as replica
@@ -7364,7 +7364,7 @@ ATPrepSetNotNull(List **wqueue, Relation rel,
errmsg("column \"%s\" of relation \"%s\" does not exist",
cmd->name, RelationGetRelationName(rel))));
- attnotnull = ((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull;
+ attnotnull = (GETSTRUCT(pg_attribute, tuple))->attnotnull;
ReleaseSysCache(tuple);
if (attnotnull)
return;
@@ -7414,7 +7414,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attnum;
+ attnum = (GETSTRUCT(pg_attribute, tuple))->attnum;
/* Prevent them from altering a system attribute */
if (attnum <= 0)
@@ -7426,9 +7426,9 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
/*
* Okay, actually perform the catalog change ... if needed
*/
- if (!((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull)
+ if (!(GETSTRUCT(pg_attribute, tuple))->attnotnull)
{
- ((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull = true;
+ (GETSTRUCT(pg_attribute, tuple))->attnotnull = true;
CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple);
@@ -7439,7 +7439,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
* already found that we must verify some other NOT NULL constraint.
*/
if (!tab->verify_new_notnull &&
- !NotNullImpliedByRelConstraints(rel, (Form_pg_attribute) GETSTRUCT(tuple)))
+ !NotNullImpliedByRelConstraints(rel, GETSTRUCT(pg_attribute, tuple)))
{
/* Tell Phase 3 it needs to test the constraint */
tab->verify_new_notnull = true;
@@ -7488,7 +7488,7 @@ ATExecCheckNotNull(AlteredTableInfo *tab, Relation rel,
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- if (!((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull)
+ if (!(GETSTRUCT(pg_attribute, tuple))->attnotnull)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("constraint must be added to child tables too"),
@@ -7669,7 +7669,7 @@ ATExecAddIdentity(Relation rel, const char *colName,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
/* Can't alter a system attribute */
@@ -7764,7 +7764,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
if (attnum <= 0)
@@ -7823,7 +7823,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
if (attnum <= 0)
@@ -7912,7 +7912,7 @@ ATPrepDropExpression(Relation rel, AlterTableCmd *cmd, bool recurse, bool recurs
errmsg("column \"%s\" of relation \"%s\" does not exist",
cmd->name, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
if (attTup->attinhcount > 0)
ereport(ERROR,
@@ -7942,7 +7942,7 @@ ATExecDropExpression(Relation rel, const char *colName, bool missing_ok, LOCKMOD
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
if (attnum <= 0)
@@ -8081,7 +8081,7 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa
colNum, RelationGetRelationName(rel))));
}
- attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ attrtuple = GETSTRUCT(pg_attribute, tuple);
attnum = attrtuple->attnum;
if (attnum <= 0)
@@ -8151,7 +8151,7 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ attrtuple = GETSTRUCT(pg_attribute, tuple);
attnum = attrtuple->attnum;
if (attnum <= 0)
@@ -8241,7 +8241,7 @@ SetIndexStorageProperties(Relation rel, Relation attrelation,
if (HeapTupleIsValid(tuple))
{
- Form_pg_attribute attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ Form_pg_attribute attrtuple = GETSTRUCT(pg_attribute, tuple);
if (setstorage)
attrtuple->attstorage = newstorage;
@@ -8285,7 +8285,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ attrtuple = GETSTRUCT(pg_attribute, tuple);
attnum = attrtuple->attnum;
if (attnum <= 0)
@@ -8402,7 +8402,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
return InvalidObjectAddress;
}
}
- targetatt = (Form_pg_attribute) GETSTRUCT(tuple);
+ targetatt = GETSTRUCT(pg_attribute, tuple);
attnum = targetatt->attnum;
@@ -8476,7 +8476,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute \"%s\" of relation %u",
colName, childrelid);
- childatt = (Form_pg_attribute) GETSTRUCT(tuple);
+ childatt = GETSTRUCT(pg_attribute, tuple);
if (childatt->attinhcount <= 0) /* shouldn't happen */
elog(ERROR, "relation %u has non-inherited attribute \"%s\"",
@@ -9205,7 +9205,7 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
cla_ht = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclasses[i]));
if (!HeapTupleIsValid(cla_ht))
elog(ERROR, "cache lookup failed for opclass %u", opclasses[i]);
- cla_tup = (Form_pg_opclass) GETSTRUCT(cla_ht);
+ cla_tup = GETSTRUCT(pg_opclass, cla_ht);
amid = cla_tup->opcmethod;
opfamily = cla_tup->opcfamily;
opcintype = cla_tup->opcintype;
@@ -9983,7 +9983,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel)
NULL, 2, key);
while ((tuple = systable_getnext(scan)) != NULL)
{
- Form_pg_constraint constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint constrForm = GETSTRUCT(pg_constraint, tuple);
clone = lappend_oid(clone, constrForm->oid);
}
@@ -10023,7 +10023,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel)
tuple = SearchSysCache1(CONSTROID, constrOid);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", constrOid);
- constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ constrForm = GETSTRUCT(pg_constraint, tuple);
/*
* As explained above: don't try to clone a constraint for which we're
@@ -10210,7 +10210,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u",
parentConstrOid);
- constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ constrForm = GETSTRUCT(pg_constraint, tuple);
/* Don't clone constraints whose parents are being cloned */
if (list_member_oid(clone, constrForm->conparentid))
@@ -10417,7 +10417,7 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk,
ObjectIdGetDatum(parentConstrOid));
if (!HeapTupleIsValid(parentConstrTup))
elog(ERROR, "cache lookup failed for constraint %u", parentConstrOid);
- parentConstr = (Form_pg_constraint) GETSTRUCT(parentConstrTup);
+ parentConstr = GETSTRUCT(pg_constraint, parentConstrTup);
/*
* Do some quick & easy initial checks. If any of these fail, we cannot
@@ -10448,7 +10448,7 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk,
ObjectIdGetDatum(fk->conoid));
if (!HeapTupleIsValid(partcontup))
elog(ERROR, "cache lookup failed for constraint %u", fk->conoid);
- partConstr = (Form_pg_constraint) GETSTRUCT(partcontup);
+ partConstr = GETSTRUCT(pg_constraint, partcontup);
if (OidIsValid(partConstr->conparentid) ||
!partConstr->convalidated ||
partConstr->condeferrable != parentConstr->condeferrable ||
@@ -10480,7 +10480,7 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk,
NULL, 1, &key);
while ((trigtup = systable_getnext(scan)) != NULL)
{
- Form_pg_trigger trgform = (Form_pg_trigger) GETSTRUCT(trigtup);
+ Form_pg_trigger trgform = GETSTRUCT(pg_trigger, trigtup);
ObjectAddress trigger;
if (trgform->tgconstrrelid != fk->conrelid)
@@ -10554,7 +10554,7 @@ GetForeignKeyActionTriggers(Relation trigrel,
NULL, 1, &key);
while ((trigtup = systable_getnext(scan)) != NULL)
{
- Form_pg_trigger trgform = (Form_pg_trigger) GETSTRUCT(trigtup);
+ Form_pg_trigger trgform = GETSTRUCT(pg_trigger, trigtup);
if (trgform->tgconstrrelid != conrelid)
continue;
@@ -10609,7 +10609,7 @@ GetForeignKeyCheckTriggers(Relation trigrel,
NULL, 1, &key);
while ((trigtup = systable_getnext(scan)) != NULL)
{
- Form_pg_trigger trgform = (Form_pg_trigger) GETSTRUCT(trigtup);
+ Form_pg_trigger trgform = GETSTRUCT(pg_trigger, trigtup);
if (trgform->tgconstrrelid != confrelid)
continue;
@@ -10694,7 +10694,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd, bool recurse,
errmsg("constraint \"%s\" of relation \"%s\" does not exist",
cmdcon->conname, RelationGetRelationName(rel))));
- currcon = (Form_pg_constraint) GETSTRUCT(contuple);
+ currcon = GETSTRUCT(pg_constraint, contuple);
if (currcon->contype != CONSTRAINT_FOREIGN)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -10720,7 +10720,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd, bool recurse,
/* Loop to find the topmost constraint */
while (HeapTupleIsValid(tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(parent))))
{
- Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp);
+ Form_pg_constraint contup = GETSTRUCT(pg_constraint, tp);
/* If no parent, this is the constraint we want */
if (!OidIsValid(contup->conparentid))
@@ -10796,7 +10796,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
Oid refrelid;
bool changed = false;
- currcon = (Form_pg_constraint) GETSTRUCT(contuple);
+ currcon = GETSTRUCT(pg_constraint, contuple);
conoid = currcon->oid;
refrelid = currcon->confrelid;
@@ -10816,7 +10816,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
SysScanDesc tgscan;
copyTuple = heap_copytuple(contuple);
- copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple);
+ copy_con = GETSTRUCT(pg_constraint, copyTuple);
copy_con->condeferrable = cmdcon->deferrable;
copy_con->condeferred = cmdcon->initdeferred;
CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple);
@@ -10842,7 +10842,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
NULL, 1, &tgkey);
while (HeapTupleIsValid(tgtuple = systable_getnext(tgscan)))
{
- Form_pg_trigger tgform = (Form_pg_trigger) GETSTRUCT(tgtuple);
+ Form_pg_trigger tgform = GETSTRUCT(pg_trigger, tgtuple);
Form_pg_trigger copy_tg;
HeapTuple copyTuple;
@@ -10869,7 +10869,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
continue;
copyTuple = heap_copytuple(tgtuple);
- copy_tg = (Form_pg_trigger) GETSTRUCT(copyTuple);
+ copy_tg = GETSTRUCT(pg_trigger, copyTuple);
copy_tg->tgdeferrable = cmdcon->deferrable;
copy_tg->tginitdeferred = cmdcon->initdeferred;
@@ -10908,7 +10908,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
while (HeapTupleIsValid(childtup = systable_getnext(pscan)))
{
- Form_pg_constraint childcon = (Form_pg_constraint) GETSTRUCT(childtup);
+ Form_pg_constraint childcon = GETSTRUCT(pg_constraint, childtup);
Relation childrel;
childrel = table_open(childcon->conrelid, lockmode);
@@ -10972,7 +10972,7 @@ ATExecValidateConstraint(List **wqueue, Relation rel, char *constrName,
errmsg("constraint \"%s\" of relation \"%s\" does not exist",
constrName, RelationGetRelationName(rel))));
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
if (con->contype != CONSTRAINT_FOREIGN &&
con->contype != CONSTRAINT_CHECK)
ereport(ERROR,
@@ -11096,7 +11096,7 @@ ATExecValidateConstraint(List **wqueue, Relation rel, char *constrName,
* Now update the catalog, while we have the door open.
*/
copyTuple = heap_copytuple(tuple);
- copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple);
+ copy_con = GETSTRUCT(pg_constraint, copyTuple);
copy_con->convalidated = true;
CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple);
@@ -11146,9 +11146,9 @@ transformColumnNameList(Oid relId, List *colList,
(errcode(ERRCODE_TOO_MANY_COLUMNS),
errmsg("cannot have more than %d keys in a foreign key",
INDEX_MAX_KEYS)));
- attnums[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->attnum;
+ attnums[attnum] = (GETSTRUCT(pg_attribute, atttuple))->attnum;
if (atttypids != NULL)
- atttypids[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->atttypid;
+ atttypids[attnum] = (GETSTRUCT(pg_attribute, atttuple))->atttypid;
ReleaseSysCache(atttuple);
attnum++;
}
@@ -11199,7 +11199,7 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid,
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexoid);
- indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexStruct = GETSTRUCT(pg_index, indexTuple);
if (indexStruct->indisprimary && indexStruct->indisvalid)
{
/*
@@ -11312,7 +11312,7 @@ transformFkeyCheckAttrs(Relation pkrel,
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexoid);
- indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexStruct = GETSTRUCT(pg_index, indexTuple);
/*
* Must have the right number of columns; must be unique and not a
@@ -11826,7 +11826,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
{
ObjectAddress conobj;
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
/* Don't drop inherited constraints */
if (con->coninhcount > 0 && !recursing)
@@ -11959,7 +11959,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
systable_endscan(scan);
- con = (Form_pg_constraint) GETSTRUCT(copy_tuple);
+ con = GETSTRUCT(pg_constraint, copy_tuple);
/* Right now only CHECK constraints can be inherited */
if (con->contype != CONSTRAINT_CHECK)
@@ -12067,7 +12067,7 @@ ATPrepAlterColumnType(List **wqueue,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
/* Can't alter a system attribute */
@@ -12248,7 +12248,7 @@ ATPrepAlterColumnType(List **wqueue,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(childrel))));
- childattTup = (Form_pg_attribute) GETSTRUCT(childtuple);
+ childattTup = GETSTRUCT(pg_attribute, childtuple);
if (childattTup->attinhcount > numparents)
ereport(ERROR,
@@ -12408,7 +12408,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(heapTup);
+ attTup = GETSTRUCT(pg_attribute, heapTup);
attnum = attTup->attnum;
attOldTup = TupleDescAttr(tab->oldDesc, attnum - 1);
@@ -12422,7 +12422,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
/* Look up the target type (should not fail, since prep found it) */
typeTuple = typenameType(NULL, typeName, &targettypmod);
- tform = (Form_pg_type) GETSTRUCT(typeTuple);
+ tform = GETSTRUCT(pg_type, typeTuple);
targettype = tform->oid;
/* And the collation */
targetcollid = GetColumnDefCollation(NULL, def, targettype);
@@ -12496,7 +12496,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
while (HeapTupleIsValid(depTup = systable_getnext(scan)))
{
- Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend foundDep = GETSTRUCT(pg_depend, depTup);
ObjectAddress foundObject;
foundObject.classId = foundDep->classid;
@@ -12702,7 +12702,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
while (HeapTupleIsValid(depTup = systable_getnext(scan)))
{
- Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend foundDep = GETSTRUCT(pg_depend, depTup);
ObjectAddress foundObject;
foundObject.classId = foundDep->refclassid;
@@ -12790,7 +12790,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
valuesAtt, nullsAtt, replacesAtt);
heap_freetuple(heapTup);
heapTup = newTup;
- attTup = (Form_pg_attribute) GETSTRUCT(heapTup);
+ attTup = GETSTRUCT(pg_attribute, heapTup);
}
}
@@ -13068,7 +13068,7 @@ ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab, LOCKMODE lockmode)
tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(oldId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for constraint %u", oldId);
- con = (Form_pg_constraint) GETSTRUCT(tup);
+ con = GETSTRUCT(pg_constraint, tup);
if (OidIsValid(con->conrelid))
relid = con->conrelid;
else
@@ -13558,7 +13558,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign table \"%s\" does not exist",
RelationGetRelationName(rel))));
- fttableform = (Form_pg_foreign_table) GETSTRUCT(tuple);
+ fttableform = GETSTRUCT(pg_foreign_table, tuple);
server = GetForeignServer(fttableform->ftserver);
fdw = GetForeignDataWrapper(server->fdwid);
@@ -13574,7 +13574,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
colName, RelationGetRelationName(rel))));
/* Prevent them from altering a system attribute */
- atttableform = (Form_pg_attribute) GETSTRUCT(tuple);
+ atttableform = GETSTRUCT(pg_attribute, tuple);
attnum = atttableform->attnum;
if (attnum <= 0)
ereport(ERROR,
@@ -13662,7 +13662,7 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relationOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationOid);
- tuple_class = (Form_pg_class) GETSTRUCT(tuple);
+ tuple_class = GETSTRUCT(pg_class, tuple);
/* Can we change the ownership of this tuple? */
switch (tuple_class->relkind)
@@ -13898,7 +13898,7 @@ change_owner_fix_column_acls(Oid relationOid, Oid oldOwnerId, Oid newOwnerId)
true, NULL, 1, key);
while (HeapTupleIsValid(attributeTuple = systable_getnext(scan)))
{
- Form_pg_attribute att = (Form_pg_attribute) GETSTRUCT(attributeTuple);
+ Form_pg_attribute att = GETSTRUCT(pg_attribute, attributeTuple);
Datum repl_val[Natts_pg_attribute];
bool repl_null[Natts_pg_attribute];
bool repl_repl[Natts_pg_attribute];
@@ -13975,7 +13975,7 @@ change_owner_recurse_to_sequences(Oid relationOid, Oid newOwnerId, LOCKMODE lock
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend depForm = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depForm = GETSTRUCT(pg_depend, tup);
Relation seqRel;
/* skip dependencies other than auto dependencies on columns */
@@ -14518,7 +14518,7 @@ AlterTableMoveAll(AlterTableMoveAllStmt *stmt)
scan = table_beginscan_catalog(rel, 1, key);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class relForm = GETSTRUCT(pg_class, tuple);
Oid relOid = relForm->oid;
/*
@@ -14856,7 +14856,7 @@ CreateInheritance(Relation child_rel, Relation parent_rel)
inhseqno = 0;
while (HeapTupleIsValid(inheritsTuple = systable_getnext(scan)))
{
- Form_pg_inherits inh = (Form_pg_inherits) GETSTRUCT(inheritsTuple);
+ Form_pg_inherits inh = GETSTRUCT(pg_inherits, inheritsTuple);
if (inh->inhparent == RelationGetRelid(parent_rel))
ereport(ERROR,
@@ -14901,7 +14901,7 @@ decompile_conbin(HeapTuple contup, TupleDesc tupdesc)
Datum attr;
Datum expr;
- con = (Form_pg_constraint) GETSTRUCT(contup);
+ con = GETSTRUCT(pg_constraint, contup);
attr = heap_getattr(contup, Anum_pg_constraint_conbin, tupdesc, &isnull);
if (isnull)
elog(ERROR, "null conbin for constraint %u", con->oid);
@@ -14921,8 +14921,8 @@ decompile_conbin(HeapTuple contup, TupleDesc tupdesc)
static bool
constraints_equivalent(HeapTuple a, HeapTuple b, TupleDesc tupleDesc)
{
- Form_pg_constraint acon = (Form_pg_constraint) GETSTRUCT(a);
- Form_pg_constraint bcon = (Form_pg_constraint) GETSTRUCT(b);
+ Form_pg_constraint acon = GETSTRUCT(pg_constraint, a);
+ Form_pg_constraint bcon = GETSTRUCT(pg_constraint, b);
if (acon->condeferrable != bcon->condeferrable ||
acon->condeferred != bcon->condeferred ||
@@ -14982,7 +14982,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
if (HeapTupleIsValid(tuple))
{
/* Check they are same type, typmod, and collation */
- Form_pg_attribute childatt = (Form_pg_attribute) GETSTRUCT(tuple);
+ Form_pg_attribute childatt = GETSTRUCT(pg_attribute, tuple);
if (attribute->atttypid != childatt->atttypid ||
attribute->atttypmod != childatt->atttypmod)
@@ -15145,7 +15145,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
while (HeapTupleIsValid(parent_tuple = systable_getnext(parent_scan)))
{
- Form_pg_constraint parent_con = (Form_pg_constraint) GETSTRUCT(parent_tuple);
+ Form_pg_constraint parent_con = GETSTRUCT(pg_constraint, parent_tuple);
SysScanDesc child_scan;
ScanKeyData child_key;
HeapTuple child_tuple;
@@ -15168,7 +15168,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
while (HeapTupleIsValid(child_tuple = systable_getnext(child_scan)))
{
- Form_pg_constraint child_con = (Form_pg_constraint) GETSTRUCT(child_tuple);
+ Form_pg_constraint child_con = GETSTRUCT(pg_constraint, child_tuple);
HeapTuple child_copy;
if (child_con->contype != CONSTRAINT_CHECK)
@@ -15209,7 +15209,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
* later on, this change will just roll back.)
*/
child_copy = heap_copytuple(child_tuple);
- child_con = (Form_pg_constraint) GETSTRUCT(child_copy);
+ child_con = GETSTRUCT(pg_constraint, child_copy);
child_con->coninhcount++;
/*
@@ -15317,7 +15317,7 @@ MarkInheritDetached(Relation child_rel, Relation parent_rel)
{
Form_pg_inherits inhForm;
- inhForm = (Form_pg_inherits) GETSTRUCT(inheritsTuple);
+ inhForm = GETSTRUCT(pg_inherits, inheritsTuple);
if (inhForm->inhdetachpending)
ereport(ERROR,
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
@@ -15332,7 +15332,7 @@ MarkInheritDetached(Relation child_rel, Relation parent_rel)
HeapTuple newtup;
newtup = heap_copytuple(inheritsTuple);
- ((Form_pg_inherits) GETSTRUCT(newtup))->inhdetachpending = true;
+ (GETSTRUCT(pg_inherits, newtup))->inhdetachpending = true;
CatalogTupleUpdate(catalogRelation,
&inheritsTuple->t_self,
@@ -15421,7 +15421,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
true, NULL, 1, key);
while (HeapTupleIsValid(attributeTuple = systable_getnext(scan)))
{
- Form_pg_attribute att = (Form_pg_attribute) GETSTRUCT(attributeTuple);
+ Form_pg_attribute att = GETSTRUCT(pg_attribute, attributeTuple);
/* Ignore if dropped or not inherited */
if (att->attisdropped)
@@ -15434,7 +15434,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
{
/* Decrement inhcount and possibly set islocal to true */
HeapTuple copyTuple = heap_copytuple(attributeTuple);
- Form_pg_attribute copy_att = (Form_pg_attribute) GETSTRUCT(copyTuple);
+ Form_pg_attribute copy_att = GETSTRUCT(pg_attribute, copyTuple);
copy_att->attinhcount--;
if (copy_att->attinhcount == 0)
@@ -15465,7 +15465,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
while (HeapTupleIsValid(constraintTuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(constraintTuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, constraintTuple);
if (con->contype == CONSTRAINT_CHECK)
connames = lappend(connames, pstrdup(NameStr(con->conname)));
@@ -15483,7 +15483,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
while (HeapTupleIsValid(constraintTuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(constraintTuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, constraintTuple);
bool match;
ListCell *lc;
@@ -15504,7 +15504,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
{
/* Decrement inhcount and possibly set islocal to true */
HeapTuple copyTuple = heap_copytuple(constraintTuple);
- Form_pg_constraint copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple);
+ Form_pg_constraint copy_con = GETSTRUCT(pg_constraint, copyTuple);
if (copy_con->coninhcount <= 0) /* shouldn't happen */
elog(ERROR, "relation %u has non-inherited constraint \"%s\"",
@@ -15573,7 +15573,7 @@ drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid,
while (HeapTupleIsValid(depTuple = systable_getnext(scan)))
{
- Form_pg_depend dep = (Form_pg_depend) GETSTRUCT(depTuple);
+ Form_pg_depend dep = GETSTRUCT(pg_depend, depTuple);
if (dep->refclassid == refclassid &&
dep->refobjid == refobjid &&
@@ -15618,7 +15618,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
/* Validate the type. */
typetuple = typenameType(NULL, ofTypename, NULL);
check_of_type(typetuple);
- typeform = (Form_pg_type) GETSTRUCT(typetuple);
+ typeform = GETSTRUCT(pg_type, typetuple);
typeid = typeform->oid;
/* Fail if the table has any inheritance parents. */
@@ -15719,7 +15719,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
classtuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(classtuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- ((Form_pg_class) GETSTRUCT(classtuple))->reloftype = typeid;
+ (GETSTRUCT(pg_class, classtuple))->reloftype = typeid;
CatalogTupleUpdate(relationRelation, &classtuple->t_self, classtuple);
InvokeObjectPostAlterHook(RelationRelationId, relid, 0);
@@ -15764,7 +15764,7 @@ ATExecDropOf(Relation rel, LOCKMODE lockmode)
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- ((Form_pg_class) GETSTRUCT(tuple))->reloftype = InvalidOid;
+ (GETSTRUCT(pg_class, tuple))->reloftype = InvalidOid;
CatalogTupleUpdate(relationRelation, &tuple->t_self, tuple);
InvokeObjectPostAlterHook(RelationRelationId, relid, 0);
@@ -15801,7 +15801,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
if (!HeapTupleIsValid(pg_class_tuple))
elog(ERROR, "cache lookup failed for relation \"%s\"",
RelationGetRelationName(rel));
- pg_class_form = (Form_pg_class) GETSTRUCT(pg_class_tuple);
+ pg_class_form = GETSTRUCT(pg_class, pg_class_tuple);
if (pg_class_form->relreplident != ri_type)
{
pg_class_form->relreplident = ri_type;
@@ -15821,7 +15821,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
pg_index_tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexOid));
if (!HeapTupleIsValid(pg_index_tuple))
elog(ERROR, "cache lookup failed for index %u", indexOid);
- pg_index_form = (Form_pg_index) GETSTRUCT(pg_index_tuple);
+ pg_index_form = GETSTRUCT(pg_index, pg_index_tuple);
if (pg_index_form->indisreplident)
{
@@ -15845,7 +15845,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
ObjectIdGetDatum(thisIndexOid));
if (!HeapTupleIsValid(pg_index_tuple))
elog(ERROR, "cache lookup failed for index %u", thisIndexOid);
- pg_index_form = (Form_pg_index) GETSTRUCT(pg_index_tuple);
+ pg_index_form = GETSTRUCT(pg_index, pg_index_tuple);
/*
* Unset the bit if set. We know it's wrong because we checked this
@@ -16015,7 +16015,7 @@ ATExecSetRowSecurity(Relation rel, bool rls)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- ((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = rls;
+ (GETSTRUCT(pg_class, tuple))->relrowsecurity = rls;
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
table_close(pg_class, RowExclusiveLock);
@@ -16041,7 +16041,7 @@ ATExecForceNoForceRowSecurity(Relation rel, bool force_rls)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- ((Form_pg_class) GETSTRUCT(tuple))->relforcerowsecurity = force_rls;
+ (GETSTRUCT(pg_class, tuple))->relforcerowsecurity = force_rls;
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
table_close(pg_class, RowExclusiveLock);
@@ -16076,7 +16076,7 @@ ATExecGenericOptions(Relation rel, List *options)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign table \"%s\" does not exist",
RelationGetRelationName(rel))));
- tableform = (Form_pg_foreign_table) GETSTRUCT(tuple);
+ tableform = GETSTRUCT(pg_foreign_table, tuple);
server = GetForeignServer(tableform->ftserver);
fdw = GetForeignDataWrapper(server->fdwid);
@@ -16158,7 +16158,7 @@ ATExecSetCompression(Relation rel,
column, RelationGetRelationName(rel))));
/* prevent them from altering a system attribute */
- atttableform = (Form_pg_attribute) GETSTRUCT(tuple);
+ atttableform = GETSTRUCT(pg_attribute, tuple);
attnum = atttableform->attnum;
if (attnum <= 0)
ereport(ERROR,
@@ -16279,7 +16279,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
if (con->contype == CONSTRAINT_FOREIGN)
{
@@ -16481,7 +16481,7 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(classTup))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- classForm = (Form_pg_class) GETSTRUCT(classTup);
+ classForm = GETSTRUCT(pg_class, classTup);
Assert(classForm->relnamespace == oldNspOid);
@@ -16613,7 +16613,7 @@ AlterSeqNamespaces(Relation classRel, Relation rel,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend depForm = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depForm = GETSTRUCT(pg_depend, tup);
Relation seqRel;
/* skip dependencies other than auto dependencies on columns */
@@ -16939,8 +16939,8 @@ RangeVarCallbackForTruncate(const RangeVar *relation,
if (!HeapTupleIsValid(tuple)) /* should not happen */
elog(ERROR, "cache lookup failed for relation %u", relId);
- truncate_check_rel(relId, (Form_pg_class) GETSTRUCT(tuple));
- truncate_check_perms(relId, (Form_pg_class) GETSTRUCT(tuple));
+ truncate_check_rel(relId, GETSTRUCT(pg_class, tuple));
+ truncate_check_perms(relId, GETSTRUCT(pg_class, tuple));
ReleaseSysCache(tuple);
}
@@ -16968,7 +16968,7 @@ RangeVarCallbackOwnsRelation(const RangeVar *relation,
relation->relname);
if (!allowSystemTableMods &&
- IsSystemClass(relId, (Form_pg_class) GETSTRUCT(tuple)))
+ IsSystemClass(relId, GETSTRUCT(pg_class, tuple)))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied: \"%s\" is a system catalog",
@@ -16995,7 +16995,7 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped */
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
relkind = classform->relkind;
/* Must own relation. */
@@ -17219,7 +17219,7 @@ ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNu
errmsg("column \"%s\" named in partition key does not exist",
pelem->name),
parser_errposition(pstate, pelem->location)));
- attform = (Form_pg_attribute) GETSTRUCT(atttuple);
+ attform = GETSTRUCT(pg_attribute, atttuple);
if (attform->attnum <= 0)
ereport(ERROR,
@@ -18127,7 +18127,7 @@ CloneRowTriggersToPartition(Relation parent, Relation partition)
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
- Form_pg_trigger trigForm = (Form_pg_trigger) GETSTRUCT(tuple);
+ Form_pg_trigger trigForm = GETSTRUCT(pg_trigger, tuple);
CreateTrigStmt *trigStmt;
Node *qual = NULL;
Datum value;
@@ -18481,7 +18481,7 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent,
contup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(fk->conoid));
if (!HeapTupleIsValid(contup))
elog(ERROR, "cache lookup failed for constraint %u", fk->conoid);
- conform = (Form_pg_constraint) GETSTRUCT(contup);
+ conform = GETSTRUCT(pg_constraint, contup);
/* consider only the inherited foreign keys */
if (conform->contype != CONSTRAINT_FOREIGN ||
@@ -18586,7 +18586,7 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(partRel));
- Assert(((Form_pg_class) GETSTRUCT(tuple))->relispartition);
+ Assert((GETSTRUCT(pg_class, tuple))->relispartition);
/* Clear relpartbound and reset relispartition */
memset(new_val, 0, sizeof(new_val));
@@ -18598,7 +18598,7 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent,
newtuple = heap_modify_tuple(tuple, RelationGetDescr(classRel),
new_val, new_null, new_repl);
- ((Form_pg_class) GETSTRUCT(newtuple))->relispartition = false;
+ (GETSTRUCT(pg_class, newtuple))->relispartition = false;
CatalogTupleUpdate(classRel, &newtuple->t_self, newtuple);
heap_freetuple(newtuple);
table_close(classRel, RowExclusiveLock);
@@ -18748,7 +18748,7 @@ DropClonedTriggersFromPartition(Oid partitionId)
true, NULL, 1, &skey);
while (HeapTupleIsValid(trigtup = systable_getnext(scan)))
{
- Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(trigtup);
+ Form_pg_trigger pg_trigger = GETSTRUCT(pg_trigger, trigtup);
ObjectAddress trig;
/* Ignore triggers that weren't cloned */
@@ -18835,7 +18835,7 @@ RangeVarCallbackForAttachIndex(const RangeVar *rv, Oid relOid, Oid oldRelOid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped, so nothing to do */
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
if (classform->relkind != RELKIND_PARTITIONED_INDEX &&
classform->relkind != RELKIND_INDEX)
ereport(ERROR,
@@ -19056,7 +19056,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
NULL, 1, &key);
while ((inhTup = systable_getnext(scan)) != NULL)
{
- Form_pg_inherits inhForm = (Form_pg_inherits) GETSTRUCT(inhTup);
+ Form_pg_inherits inhForm = GETSTRUCT(pg_inherits, inhTup);
HeapTuple indTup;
Form_pg_index indexForm;
@@ -19064,7 +19064,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
ObjectIdGetDatum(inhForm->inhrelid));
if (!HeapTupleIsValid(indTup))
elog(ERROR, "cache lookup failed for index %u", inhForm->inhrelid);
- indexForm = (Form_pg_index) GETSTRUCT(indTup);
+ indexForm = GETSTRUCT(pg_index, indTup);
if (indexForm->indisvalid)
tuples += 1;
ReleaseSysCache(indTup);
@@ -19086,7 +19086,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
idxRel = table_open(IndexRelationId, RowExclusiveLock);
newtup = heap_copytuple(partedIdx->rd_indextuple);
- ((Form_pg_index) GETSTRUCT(newtup))->indisvalid = true;
+ (GETSTRUCT(pg_index, newtup))->indisvalid = true;
updated = true;
CatalogTupleUpdate(idxRel, &partedIdx->rd_indextuple->t_self, newtup);
@@ -19156,7 +19156,7 @@ GetParentedForeignKeyRefs(Relation partition)
scan = systable_beginscan(pg_constraint, InvalidOid, true, NULL, 2, key);
while ((tuple = systable_getnext(scan)) != NULL)
{
- Form_pg_constraint constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint constrForm = GETSTRUCT(pg_constraint, tuple);
/*
* We only need to process constraints that are part of larger ones.
@@ -19197,7 +19197,7 @@ ATDetachCheckNoForeignKeyRefs(Relation partition)
tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constrOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", constrOid);
- constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ constrForm = GETSTRUCT(pg_constraint, tuple);
Assert(OidIsValid(constrForm->conparentid));
Assert(constrForm->confrelid == RelationGetRelid(partition));
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index c8bdd9992a..36ff46fda3 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -474,7 +474,7 @@ DropTableSpace(DropTableSpaceStmt *stmt)
return;
}
- spcform = (Form_pg_tablespace) GETSTRUCT(tuple);
+ spcform = GETSTRUCT(pg_tablespace, tuple);
tablespaceoid = spcform->oid;
/* Must be tablespace owner */
@@ -1002,7 +1002,7 @@ RenameTableSpace(const char *oldname, const char *newname)
oldname)));
newtuple = heap_copytuple(tup);
- newform = (Form_pg_tablespace) GETSTRUCT(newtuple);
+ newform = GETSTRUCT(pg_tablespace, newtuple);
tspId = newform->oid;
table_endscan(scan);
@@ -1090,7 +1090,7 @@ AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt)
errmsg("tablespace \"%s\" does not exist",
stmt->tablespacename)));
- tablespaceoid = ((Form_pg_tablespace) GETSTRUCT(tup))->oid;
+ tablespaceoid = (GETSTRUCT(pg_tablespace, tup))->oid;
/* Must be owner of the existing object */
if (!pg_tablespace_ownercheck(tablespaceoid, GetUserId()))
@@ -1495,7 +1495,7 @@ get_tablespace_oid(const char *tablespacename, bool missing_ok)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = ((Form_pg_tablespace) GETSTRUCT(tuple))->oid;
+ result = (GETSTRUCT(pg_tablespace, tuple))->oid;
else
result = InvalidOid;
@@ -1541,7 +1541,7 @@ get_tablespace_name(Oid spc_oid)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = pstrdup(NameStr(((Form_pg_tablespace) GETSTRUCT(tuple))->spcname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_tablespace, tuple))->spcname));
else
result = NULL;
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index b8db53b66d..47ef4004fa 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -736,7 +736,7 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
/* There should be at most one matching tuple */
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
- Form_pg_trigger oldtrigger = (Form_pg_trigger) GETSTRUCT(tuple);
+ Form_pg_trigger oldtrigger = GETSTRUCT(pg_trigger, tuple);
trigoid = oldtrigger->oid;
existing_constraint_oid = oldtrigger->tgconstraint;
@@ -1022,9 +1022,9 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(rel));
- if (!((Form_pg_class) GETSTRUCT(tuple))->relhastriggers)
+ if (!(GETSTRUCT(pg_class, tuple))->relhastriggers)
{
- ((Form_pg_class) GETSTRUCT(tuple))->relhastriggers = true;
+ (GETSTRUCT(pg_class, tuple))->relhastriggers = true;
CatalogTupleUpdate(pgrel, &tuple->t_self, tuple);
@@ -1283,7 +1283,7 @@ TriggerSetParentTrigger(Relation trigRel,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for trigger %u", childTrigId);
newtup = heap_copytuple(tuple);
- trigForm = (Form_pg_trigger) GETSTRUCT(newtup);
+ trigForm = GETSTRUCT(pg_trigger, newtup);
if (OidIsValid(parentTrigId))
{
/* don't allow setting parent for a constraint that already has one */
@@ -1355,7 +1355,7 @@ RemoveTriggerById(Oid trigOid)
/*
* Open and exclusive-lock the relation the trigger belongs to.
*/
- relid = ((Form_pg_trigger) GETSTRUCT(tup))->tgrelid;
+ relid = (GETSTRUCT(pg_trigger, tup))->tgrelid;
rel = table_open(relid, AccessExclusiveLock);
@@ -1443,7 +1443,7 @@ get_trigger_oid(Oid relid, const char *trigname, bool missing_ok)
}
else
{
- oid = ((Form_pg_trigger) GETSTRUCT(tup))->oid;
+ oid = (GETSTRUCT(pg_trigger, tup))->oid;
}
systable_endscan(tgscan);
@@ -1464,7 +1464,7 @@ RangeVarCallbackForRenameTrigger(const RangeVar *rv, Oid relid, Oid oldrelid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped */
- form = (Form_pg_class) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_class, tuple);
/* only tables and views can have triggers */
if (form->relkind != RELKIND_RELATION && form->relkind != RELKIND_VIEW &&
@@ -1551,7 +1551,7 @@ renametrig(RenameStmt *stmt)
{
Form_pg_trigger trigform;
- trigform = (Form_pg_trigger) GETSTRUCT(tuple);
+ trigform = GETSTRUCT(pg_trigger, tuple);
tgoid = trigform->oid;
/*
@@ -1625,7 +1625,7 @@ renametrig_internal(Relation tgrel, Relation targetrel, HeapTuple trigtup,
SysScanDesc tgscan;
/* If the trigger already has the new name, nothing to do. */
- tgform = (Form_pg_trigger) GETSTRUCT(trigtup);
+ tgform = GETSTRUCT(pg_trigger, trigtup);
if (strcmp(NameStr(tgform->tgname), newname) == 0)
return;
@@ -1655,7 +1655,7 @@ renametrig_internal(Relation tgrel, Relation targetrel, HeapTuple trigtup,
* The target name is free; update the existing pg_trigger tuple with it.
*/
tuple = heap_copytuple(trigtup); /* need a modifiable copy */
- tgform = (Form_pg_trigger) GETSTRUCT(tuple);
+ tgform = GETSTRUCT(pg_trigger, tuple);
/*
* If the trigger has a name different from what we expected, let the user
@@ -1707,7 +1707,7 @@ renametrig_partition(Relation tgrel, Oid partitionId, Oid parentTriggerOid,
NULL, 1, &key);
while (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
- Form_pg_trigger tgform = (Form_pg_trigger) GETSTRUCT(tuple);
+ Form_pg_trigger tgform = GETSTRUCT(pg_trigger, tuple);
Relation partitionRel;
if (tgform->tgparentid != parentTriggerOid)
@@ -1794,7 +1794,7 @@ EnableDisableTrigger(Relation rel, const char *tgname,
while (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
- Form_pg_trigger oldtrig = (Form_pg_trigger) GETSTRUCT(tuple);
+ Form_pg_trigger oldtrig = GETSTRUCT(pg_trigger, tuple);
if (oldtrig->tgisinternal)
{
@@ -1814,7 +1814,7 @@ EnableDisableTrigger(Relation rel, const char *tgname,
{
/* need to change this one ... make a copy to scribble on */
HeapTuple newtup = heap_copytuple(tuple);
- Form_pg_trigger newtrig = (Form_pg_trigger) GETSTRUCT(newtup);
+ Form_pg_trigger newtrig = GETSTRUCT(pg_trigger, newtup);
newtrig->tgenabled = fires_when;
@@ -1898,7 +1898,7 @@ RelationBuildTriggers(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(tgscan)))
{
- Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
+ Form_pg_trigger pg_trigger = GETSTRUCT(pg_trigger, htup);
Trigger *build;
Datum datum;
bool isnull;
@@ -5702,7 +5702,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
while (HeapTupleIsValid(tup = systable_getnext(conscan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tup);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tup);
if (con->condeferrable)
conoidlist = lappend_oid(conoidlist, con->oid);
@@ -5758,7 +5758,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
conoidlist = lappend_oid(conoidlist, con->oid);
}
@@ -5791,7 +5791,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
while (HeapTupleIsValid(htup = systable_getnext(tgscan)))
{
- Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
+ Form_pg_trigger pg_trigger = GETSTRUCT(pg_trigger, htup);
/*
* Silently skip triggers that are marked as non-deferrable in
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index 4cc4e3c00f..164379934a 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -130,7 +130,7 @@ get_ts_parser_func(DefElem *defel, int attnum)
static ObjectAddress
makeParserDependencies(HeapTuple tuple)
{
- Form_pg_ts_parser prs = (Form_pg_ts_parser) GETSTRUCT(tuple);
+ Form_pg_ts_parser prs = GETSTRUCT(pg_ts_parser, tuple);
ObjectAddress myself,
referenced;
ObjectAddresses *addrs;
@@ -300,7 +300,7 @@ DefineTSParser(List *names, List *parameters)
static ObjectAddress
makeDictionaryDependencies(HeapTuple tuple)
{
- Form_pg_ts_dict dict = (Form_pg_ts_dict) GETSTRUCT(tuple);
+ Form_pg_ts_dict dict = GETSTRUCT(pg_ts_dict, tuple);
ObjectAddress myself,
referenced;
ObjectAddresses *addrs;
@@ -353,7 +353,7 @@ verify_dictoptions(Oid tmplId, List *dictoptions)
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for text search template %u",
tmplId);
- tform = (Form_pg_ts_template) GETSTRUCT(tup);
+ tform = GETSTRUCT(pg_ts_template, tup);
initmethod = tform->tmplinit;
@@ -552,7 +552,7 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
/*
* Validate
*/
- verify_dictoptions(((Form_pg_ts_dict) GETSTRUCT(tup))->dicttemplate,
+ verify_dictoptions((GETSTRUCT(pg_ts_dict, tup))->dicttemplate,
dictoptions);
/*
@@ -645,7 +645,7 @@ get_ts_template_func(DefElem *defel, int attnum)
static ObjectAddress
makeTSTemplateDependencies(HeapTuple tuple)
{
- Form_pg_ts_template tmpl = (Form_pg_ts_template) GETSTRUCT(tuple);
+ Form_pg_ts_template tmpl = GETSTRUCT(pg_ts_template, tuple);
ObjectAddress myself,
referenced;
ObjectAddresses *addrs;
@@ -806,7 +806,7 @@ static ObjectAddress
makeConfigurationDependencies(HeapTuple tuple, bool removeOld,
Relation mapRel)
{
- Form_pg_ts_config cfg = (Form_pg_ts_config) GETSTRUCT(tuple);
+ Form_pg_ts_config cfg = GETSTRUCT(pg_ts_config, tuple);
ObjectAddresses *addrs;
ObjectAddress myself,
referenced;
@@ -867,7 +867,7 @@ makeConfigurationDependencies(HeapTuple tuple, bool removeOld,
while (HeapTupleIsValid((maptup = systable_getnext(scan))))
{
- Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup);
+ Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup);
referenced.classId = TSDictionaryRelationId;
referenced.objectId = cfgmap->mapdict;
@@ -959,7 +959,7 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied)
elog(ERROR, "cache lookup failed for text search configuration %u",
sourceOid);
- cfg = (Form_pg_ts_config) GETSTRUCT(tup);
+ cfg = GETSTRUCT(pg_ts_config, tup);
/* use source's parser */
prsOid = cfg->cfgparser;
@@ -1017,7 +1017,7 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied)
while (HeapTupleIsValid((maptup = systable_getnext(scan))))
{
- Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup);
+ Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup);
HeapTuple newmaptup;
Datum mapvalues[Natts_pg_ts_config_map];
bool mapnulls[Natts_pg_ts_config_map];
@@ -1121,7 +1121,7 @@ AlterTSConfiguration(AlterTSConfigurationStmt *stmt)
errmsg("text search configuration \"%s\" does not exist",
NameListToString(stmt->cfgname))));
- cfgId = ((Form_pg_ts_config) GETSTRUCT(tup))->oid;
+ cfgId = (GETSTRUCT(pg_ts_config, tup))->oid;
/* must be owner */
if (!pg_ts_config_ownercheck(cfgId, GetUserId()))
@@ -1226,7 +1226,7 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt,
int ndict;
ListCell *c;
- tsform = (Form_pg_ts_config) GETSTRUCT(tup);
+ tsform = GETSTRUCT(pg_ts_config, tup);
cfgId = tsform->oid;
prsId = tsform->cfgparser;
@@ -1293,7 +1293,7 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt,
while (HeapTupleIsValid((maptup = systable_getnext(scan))))
{
- Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup);
+ Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup);
/*
* check if it's one of target token types
@@ -1386,7 +1386,7 @@ DropConfigurationMapping(AlterTSConfigurationStmt *stmt,
int *tokens;
ListCell *c;
- tsform = (Form_pg_ts_config) GETSTRUCT(tup);
+ tsform = GETSTRUCT(pg_ts_config, tup);
cfgId = tsform->oid;
prsId = tsform->cfgparser;
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index a8757a90bf..fc1e512c75 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -345,7 +345,7 @@ DefineType(ParseState *pstate, List *names, List *parameters)
Form_pg_type likeForm;
likeType = typenameType(NULL, defGetTypeName(likeTypeEl), NULL);
- likeForm = (Form_pg_type) GETSTRUCT(likeType);
+ likeForm = GETSTRUCT(pg_type, likeType);
internalLength = likeForm->typlen;
byValue = likeForm->typbyval;
alignment = likeForm->typalign;
@@ -668,7 +668,7 @@ RemoveTypeById(Oid typeOid)
* making dependency entries for those, so it has to be done "by hand"
* here.
*/
- if (((Form_pg_type) GETSTRUCT(tup))->typtype == TYPTYPE_ENUM)
+ if ((GETSTRUCT(pg_type, tup))->typtype == TYPTYPE_ENUM)
EnumValuesDelete(typeOid);
/*
@@ -676,7 +676,7 @@ RemoveTypeById(Oid typeOid)
* with making a dependency entry for that, so it has to be done "by hand"
* here.
*/
- if (((Form_pg_type) GETSTRUCT(tup))->typtype == TYPTYPE_RANGE)
+ if ((GETSTRUCT(pg_type, tup))->typtype == TYPTYPE_RANGE)
RangeDelete(typeOid);
ReleaseSysCache(tup);
@@ -758,7 +758,7 @@ DefineDomain(CreateDomainStmt *stmt)
* Look up the base type.
*/
typeTup = typenameType(NULL, stmt->typeName, &basetypeMod);
- baseType = (Form_pg_type) GETSTRUCT(typeTup);
+ baseType = GETSTRUCT(pg_type, typeTup);
basetypeoid = baseType->oid;
/*
@@ -1308,7 +1308,7 @@ AlterEnum(AlterEnumStmt *stmt)
static void
checkEnumOwner(HeapTuple tup)
{
- Form_pg_type typTup = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typTup = GETSTRUCT(pg_type, tup);
/* Check that this is actually an enum */
if (typTup->typtype != TYPTYPE_ENUM)
@@ -2587,7 +2587,7 @@ AlterDomainDefault(List *names, Node *defaultRaw)
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* Check it's a domain and check user has permission for ALTER DOMAIN */
checkDomainOwner(tup);
@@ -2712,7 +2712,7 @@ AlterDomainNotNull(List *names, bool notNull)
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* Check it's a domain and check user has permission for ALTER DOMAIN */
checkDomainOwner(tup);
@@ -2867,7 +2867,7 @@ AlterDomainDropConstraint(List *names, const char *constrName,
ObjectAddress conobj;
conobj.classId = ConstraintRelationId;
- conobj.objectId = ((Form_pg_constraint) GETSTRUCT(contup))->oid;
+ conobj.objectId = (GETSTRUCT(pg_constraint, contup))->oid;
conobj.objectSubId = 0;
performDeletion(&conobj, behavior, 0);
@@ -2934,7 +2934,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint,
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* Check it's a domain and check user has permission for ALTER DOMAIN */
checkDomainOwner(tup);
@@ -3088,7 +3088,7 @@ AlterDomainValidateConstraint(List *names, const char *constrName)
errmsg("constraint \"%s\" of domain \"%s\" does not exist",
constrName, TypeNameToString(typename))));
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
if (con->contype != CONSTRAINT_CHECK)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -3109,7 +3109,7 @@ AlterDomainValidateConstraint(List *names, const char *constrName)
* Now update the catalog, while we have the door open.
*/
copyTuple = heap_copytuple(tuple);
- copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple);
+ copy_con = GETSTRUCT(pg_constraint, copyTuple);
copy_con->convalidated = true;
CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple);
@@ -3284,7 +3284,7 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
while (HeapTupleIsValid(depTup = systable_getnext(depScan)))
{
- Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend pg_depend = GETSTRUCT(pg_depend, depTup);
RelToCheck *rtc = NULL;
ListCell *rellist;
Form_pg_attribute pg_att;
@@ -3421,7 +3421,7 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
void
checkDomainOwner(HeapTuple tup)
{
- Form_pg_type typTup = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typTup = GETSTRUCT(pg_type, tup);
/* Check that this is actually a domain */
if (typTup->typtype != TYPTYPE_DOMAIN)
@@ -3616,7 +3616,7 @@ RenameType(RenameStmt *stmt)
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* check permissions on type */
if (!pg_type_ownercheck(typeOid, GetUserId()))
@@ -3701,7 +3701,7 @@ AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype)
newtup = heap_copytuple(tup);
ReleaseSysCache(tup);
tup = newtup;
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* Don't allow ALTER DOMAIN on a type */
if (objecttype == OBJECT_DOMAIN && typTup->typtype != TYPTYPE_DOMAIN)
@@ -3791,7 +3791,7 @@ AlterTypeOwner_oid(Oid typeOid, Oid newOwnerId, bool hasDependEntry)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/*
* If it's a composite type, invoke ATExecChangeOwner so that we fix up
@@ -3837,7 +3837,7 @@ AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId)
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
memset(repl_null, false, sizeof(repl_null));
memset(repl_repl, false, sizeof(repl_repl));
@@ -3978,7 +3978,7 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typform = (Form_pg_type) GETSTRUCT(tup);
+ typform = GETSTRUCT(pg_type, tup);
oldNspOid = typform->typnamespace;
arrayOid = typform->typarray;
@@ -4112,7 +4112,7 @@ AlterType(AlterTypeStmt *stmt)
tup = typenameType(NULL, typename, NULL);
typeOid = typeTypeId(tup);
- typForm = (Form_pg_type) GETSTRUCT(tup);
+ typForm = GETSTRUCT(pg_type, tup);
/* Process options */
memset(&atparams, 0, sizeof(atparams));
@@ -4426,7 +4426,7 @@ AlterTypeRecurse(Oid typeOid, bool isImplicitArray,
if (!isImplicitArray &&
(atparams->updateTypmodin || atparams->updateTypmodout))
{
- Oid arrtypoid = ((Form_pg_type) GETSTRUCT(newtup))->typarray;
+ Oid arrtypoid = (GETSTRUCT(pg_type, newtup))->typarray;
if (OidIsValid(arrtypoid))
{
@@ -4475,7 +4475,7 @@ AlterTypeRecurse(Oid typeOid, bool isImplicitArray,
while ((domainTup = systable_getnext(scan)) != NULL)
{
- Form_pg_type domainForm = (Form_pg_type) GETSTRUCT(domainTup);
+ Form_pg_type domainForm = GETSTRUCT(pg_type, domainTup);
/*
* Shouldn't have a nonzero typbasetype in a non-domain, but let's
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 984305ba31..767c75ce2f 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -446,7 +446,7 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
{
RoleSpec *oldrole = lfirst(item);
HeapTuple oldroletup = get_rolespec_tuple(oldrole);
- Form_pg_authid oldroleform = (Form_pg_authid) GETSTRUCT(oldroletup);
+ Form_pg_authid oldroleform = GETSTRUCT(pg_authid, oldroletup);
Oid oldroleid = oldroleform->oid;
char *oldrolename = NameStr(oldroleform->rolname);
@@ -620,7 +620,7 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
pg_authid_dsc = RelationGetDescr(pg_authid_rel);
tuple = get_rolespec_tuple(stmt->role);
- authform = (Form_pg_authid) GETSTRUCT(tuple);
+ authform = GETSTRUCT(pg_authid, tuple);
rolename = pstrdup(NameStr(authform->rolname));
roleid = authform->oid;
@@ -838,7 +838,7 @@ AlterRoleSet(AlterRoleSetStmt *stmt)
"Cannot alter reserved roles.");
roletuple = get_rolespec_tuple(stmt->role);
- roleform = (Form_pg_authid) GETSTRUCT(roletuple);
+ roleform = GETSTRUCT(pg_authid, roletuple);
roleid = roleform->oid;
/*
@@ -962,7 +962,7 @@ DropRole(DropRoleStmt *stmt)
continue;
}
- roleform = (Form_pg_authid) GETSTRUCT(tuple);
+ roleform = GETSTRUCT(pg_authid, tuple);
roleid = roleform->oid;
if (roleid == GetUserId())
@@ -1117,7 +1117,7 @@ RenameRole(const char *oldname, const char *newname)
* effective userid, though.
*/
- authform = (Form_pg_authid) GETSTRUCT(oldtuple);
+ authform = GETSTRUCT(pg_authid, oldtuple);
roleid = authform->oid;
if (roleid == GetSessionUserId())
@@ -1165,7 +1165,7 @@ RenameRole(const char *oldname, const char *newname)
/*
* createrole is enough privilege unless you want to mess with a superuser
*/
- if (((Form_pg_authid) GETSTRUCT(oldtuple))->rolsuper)
+ if ((GETSTRUCT(pg_authid, oldtuple))->rolsuper)
{
if (!superuser())
ereport(ERROR,
@@ -1490,7 +1490,7 @@ AddRoleMems(const char *rolename, Oid roleid,
ObjectIdGetDatum(memberid));
if (HeapTupleIsValid(authmem_tuple) &&
(!admin_opt ||
- ((Form_pg_auth_members) GETSTRUCT(authmem_tuple))->admin_option))
+ (GETSTRUCT(pg_auth_members, authmem_tuple))->admin_option))
{
ereport(NOTICE,
(errmsg("role \"%s\" is already a member of role \"%s\"",
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 8df25f59d8..72a028f21f 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -806,7 +806,7 @@ expand_vacuum_rel(VacuumRelation *vrel, int options)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/*
* Make a returnable VacuumRelation for this rel if user is a proper
@@ -894,7 +894,7 @@ get_all_vacuum_rels(int options)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classForm = GETSTRUCT(pg_class, tuple);
MemoryContext oldcontext;
Oid relid = classForm->oid;
@@ -1346,7 +1346,7 @@ vac_update_relstats(Relation relation,
if (!HeapTupleIsValid(ctup))
elog(ERROR, "pg_class entry for relid %u vanished during vacuuming",
relid);
- pgcform = (Form_pg_class) GETSTRUCT(ctup);
+ pgcform = GETSTRUCT(pg_class, ctup);
/* Apply statistical updates, if any, to copied tuple */
@@ -1545,7 +1545,7 @@ vac_update_datfrozenxid(void)
while ((classTup = systable_getnext(scan)) != NULL)
{
- Form_pg_class classForm = (Form_pg_class) GETSTRUCT(classTup);
+ Form_pg_class classForm = GETSTRUCT(pg_class, classTup);
/*
* Only consider relations able to hold unfrozen XIDs (anything else
@@ -1639,7 +1639,7 @@ vac_update_datfrozenxid(void)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for database %u", MyDatabaseId);
- dbform = (Form_pg_database) GETSTRUCT(tuple);
+ dbform = GETSTRUCT(pg_database, tuple);
/*
* As in vac_update_relstats(), we ordinarily don't want to let
@@ -1747,7 +1747,7 @@ vac_truncate_clog(TransactionId frozenXID,
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- volatile FormData_pg_database *dbform = (Form_pg_database) GETSTRUCT(tuple);
+ volatile FormData_pg_database *dbform = GETSTRUCT(pg_database, tuple);
TransactionId datfrozenxid = dbform->datfrozenxid;
TransactionId datminmxid = dbform->datminmxid;
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index e5ddcda0b4..49f548d144 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -782,7 +782,7 @@ check_session_authorization(char **newval, void **extra, GucSource source)
return false;
}
- roleform = (Form_pg_authid) GETSTRUCT(roleTup);
+ roleform = GETSTRUCT(pg_authid, roleTup);
roleid = roleform->oid;
is_superuser = roleform->rolsuper;
@@ -869,7 +869,7 @@ check_role(char **newval, void **extra, GucSource source)
return false;
}
- roleform = (Form_pg_authid) GETSTRUCT(roleTup);
+ roleform = GETSTRUCT(pg_authid, roleTup);
roleid = roleform->oid;
is_superuser = roleform->rolsuper;
diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c
index 44b2e0b82d..09c40fa1e1 100644
--- a/src/backend/executor/execAmi.c
+++ b/src/backend/executor/execAmi.c
@@ -612,7 +612,7 @@ IndexSupportsBackwardScan(Oid indexid)
ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(indexid));
if (!HeapTupleIsValid(ht_idxrel))
elog(ERROR, "cache lookup failed for relation %u", indexid);
- idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);
+ idxrelrec = GETSTRUCT(pg_class, ht_idxrel);
/* Fetch the index AM's API struct */
amroutine = GetIndexAmRoutineByAmId(idxrelrec->relam, false);
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index 076226868f..76f18bbbdc 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -178,7 +178,7 @@ prepare_sql_fn_parse_info(HeapTuple procedureTuple,
Oid inputCollation)
{
SQLFunctionParseInfoPtr pinfo;
- Form_pg_proc procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ Form_pg_proc procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
int nargs;
pinfo = (SQLFunctionParseInfoPtr) palloc0(sizeof(SQLFunctionParseInfo));
@@ -621,7 +621,7 @@ init_sql_fcache(FunctionCallInfo fcinfo, Oid collation, bool lazyEvalOK)
procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(foid));
if (!HeapTupleIsValid(procedureTuple))
elog(ERROR, "cache lookup failed for function %u", foid);
- procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
/*
* copy function name immediately for use by error reporting callback, and
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 2fc606cf29..668e3181ac 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -3666,7 +3666,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
if (!HeapTupleIsValid(aggTuple))
elog(ERROR, "cache lookup failed for aggregate %u",
aggref->aggfnoid);
- aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
+ aggform = GETSTRUCT(pg_aggregate, aggTuple);
/* Check permission to call aggregate function */
aclresult = pg_proc_aclcheck(aggref->aggfnoid, GetUserId(),
@@ -3731,7 +3731,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
if (!HeapTupleIsValid(procTuple))
elog(ERROR, "cache lookup failed for function %u",
aggref->aggfnoid);
- aggOwner = ((Form_pg_proc) GETSTRUCT(procTuple))->proowner;
+ aggOwner = (GETSTRUCT(pg_proc, procTuple))->proowner;
ReleaseSysCache(procTuple);
if (OidIsValid(finalfn_oid))
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 4b104c4d98..14b3547309 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -2775,7 +2775,7 @@ initialize_peragg(WindowAggState *winstate, WindowFunc *wfunc,
if (!HeapTupleIsValid(aggTuple))
elog(ERROR, "cache lookup failed for aggregate %u",
wfunc->winfnoid);
- aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
+ aggform = GETSTRUCT(pg_aggregate, aggTuple);
/*
* Figure out whether we want to use the moving-aggregate implementation,
@@ -2836,7 +2836,7 @@ initialize_peragg(WindowAggState *winstate, WindowFunc *wfunc,
if (!HeapTupleIsValid(procTuple))
elog(ERROR, "cache lookup failed for function %u",
wfunc->winfnoid);
- aggOwner = ((Form_pg_proc) GETSTRUCT(procTuple))->proowner;
+ aggOwner = (GETSTRUCT(pg_proc, procTuple))->proowner;
ReleaseSysCache(procTuple);
aclresult = pg_proc_aclcheck(transfn_oid, aggOwner,
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 29bc26669b..72998c71fb 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -1291,7 +1291,7 @@ SPI_gettype(TupleDesc tupdesc, int fnumber)
return NULL;
}
- result = pstrdup(NameStr(((Form_pg_type) GETSTRUCT(typeTuple))->typname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_type, typeTuple))->typname));
ReleaseSysCache(typeTuple);
return result;
}
diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c
index cf222fc3e9..4f52075f03 100644
--- a/src/backend/foreign/foreign.c
+++ b/src/backend/foreign/foreign.c
@@ -62,7 +62,7 @@ GetForeignDataWrapperExtended(Oid fdwid, bits16 flags)
return NULL;
}
- fdwform = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp);
+ fdwform = GETSTRUCT(pg_foreign_data_wrapper, tp);
fdw = (ForeignDataWrapper *) palloc(sizeof(ForeignDataWrapper));
fdw->fdwid = fdwid;
@@ -136,7 +136,7 @@ GetForeignServerExtended(Oid serverid, bits16 flags)
return NULL;
}
- serverform = (Form_pg_foreign_server) GETSTRUCT(tp);
+ serverform = GETSTRUCT(pg_foreign_server, tp);
server = (ForeignServer *) palloc(sizeof(ForeignServer));
server->serverid = serverid;
@@ -222,7 +222,7 @@ GetUserMapping(Oid userid, Oid serverid)
MappingUserName(userid))));
um = (UserMapping *) palloc(sizeof(UserMapping));
- um->umid = ((Form_pg_user_mapping) GETSTRUCT(tp))->oid;
+ um->umid = (GETSTRUCT(pg_user_mapping, tp))->oid;
um->userid = userid;
um->serverid = serverid;
@@ -257,7 +257,7 @@ GetForeignTable(Oid relid)
tp = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign table %u", relid);
- tableform = (Form_pg_foreign_table) GETSTRUCT(tp);
+ tableform = GETSTRUCT(pg_foreign_table, tp);
ft = (ForeignTable *) palloc(sizeof(ForeignTable));
ft->relid = relid;
@@ -347,7 +347,7 @@ GetForeignServerIdByRelId(Oid relid)
tp = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign table %u", relid);
- tableform = (Form_pg_foreign_table) GETSTRUCT(tp);
+ tableform = GETSTRUCT(pg_foreign_table, tp);
serverid = tableform->ftserver;
ReleaseSysCache(tp);
@@ -372,7 +372,7 @@ GetFdwRoutineByServerId(Oid serverid)
tp = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(serverid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign server %u", serverid);
- serverform = (Form_pg_foreign_server) GETSTRUCT(tp);
+ serverform = GETSTRUCT(pg_foreign_server, tp);
fdwid = serverform->srvfdw;
ReleaseSysCache(tp);
@@ -380,7 +380,7 @@ GetFdwRoutineByServerId(Oid serverid)
tp = SearchSysCache1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(fdwid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign-data wrapper %u", fdwid);
- fdwform = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp);
+ fdwform = GETSTRUCT(pg_foreign_data_wrapper, tp);
fdwhandler = fdwform->fdwhandler;
/* Complain if FDW has been set to NO HANDLER. */
diff --git a/src/backend/optimizer/plan/planagg.c b/src/backend/optimizer/plan/planagg.c
index 9330908cbf..c924c0e61c 100644
--- a/src/backend/optimizer/plan/planagg.c
+++ b/src/backend/optimizer/plan/planagg.c
@@ -505,7 +505,7 @@ fetch_agg_sort_op(Oid aggfnoid)
aggTuple = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(aggfnoid));
if (!HeapTupleIsValid(aggTuple))
return InvalidOid;
- aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
+ aggform = GETSTRUCT(pg_aggregate, aggTuple);
aggsortop = aggform->aggsortop;
ReleaseSysCache(aggTuple);
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c
index df4ca12919..c80434b08c 100644
--- a/src/backend/optimizer/plan/subselect.c
+++ b/src/backend/optimizer/plan/subselect.c
@@ -866,7 +866,7 @@ hash_ok_operator(OpExpr *expr)
tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(opid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for operator %u", opid);
- optup = (Form_pg_operator) GETSTRUCT(tup);
+ optup = GETSTRUCT(pg_operator, tup);
if (!optup->oprcanhash || !func_strict(optup->oprcode))
{
ReleaseSysCache(tup);
diff --git a/src/backend/optimizer/prep/prepagg.c b/src/backend/optimizer/prep/prepagg.c
index 404a5f1dac..45f28de829 100644
--- a/src/backend/optimizer/prep/prepagg.c
+++ b/src/backend/optimizer/prep/prepagg.c
@@ -152,7 +152,7 @@ preprocess_aggref(Aggref *aggref, PlannerInfo *root)
if (!HeapTupleIsValid(aggTuple))
elog(ERROR, "cache lookup failed for aggregate %u",
aggref->aggfnoid);
- aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
+ aggform = GETSTRUCT(pg_aggregate, aggTuple);
aggtransfn = aggform->aggtransfn;
aggfinalfn = aggform->aggfinalfn;
aggcombinefn = aggform->aggcombinefn;
diff --git a/src/backend/optimizer/util/appendinfo.c b/src/backend/optimizer/util/appendinfo.c
index 9d4bb47027..a450c1e69f 100644
--- a/src/backend/optimizer/util/appendinfo.c
+++ b/src/backend/optimizer/util/appendinfo.c
@@ -150,7 +150,7 @@ make_inh_translation_list(Relation oldrelation, Relation newrelation,
if (!HeapTupleIsValid(newtup))
elog(ERROR, "could not find inherited attribute \"%s\" of relation \"%s\"",
attname, RelationGetRelationName(newrelation));
- new_attno = ((Form_pg_attribute) GETSTRUCT(newtup))->attnum - 1;
+ new_attno = (GETSTRUCT(pg_attribute, newtup))->attnum - 1;
Assert(new_attno >= 0 && new_attno < newnatts);
ReleaseSysCache(newtup);
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index 533df86ff7..277218abdc 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -3962,7 +3962,7 @@ simplify_function(Oid funcid, Oid result_type, int32 result_typmod,
func_tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(func_tuple))
elog(ERROR, "cache lookup failed for function %u", funcid);
- func_form = (Form_pg_proc) GETSTRUCT(func_tuple);
+ func_form = GETSTRUCT(pg_proc, func_tuple);
/*
* Process the function arguments, unless the caller did it already.
@@ -4056,7 +4056,7 @@ List *
expand_function_arguments(List *args, bool include_out_arguments,
Oid result_type, HeapTuple func_tuple)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
Oid *proargtypes = funcform->proargtypes.values;
int pronargs = funcform->pronargs;
bool has_named_args = false;
@@ -4136,7 +4136,7 @@ expand_function_arguments(List *args, bool include_out_arguments,
static List *
reorder_function_arguments(List *args, int pronargs, HeapTuple func_tuple)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
int nargsprovided = list_length(args);
Node *argarray[FUNC_MAX_ARGS];
ListCell *lc;
@@ -4267,7 +4267,7 @@ recheck_cast_function_args(List *args, Oid result_type,
Oid *proargtypes, int pronargs,
HeapTuple func_tuple)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
int nargs;
Oid actual_arg_types[FUNC_MAX_ARGS];
Oid declared_arg_types[FUNC_MAX_ARGS];
@@ -4314,7 +4314,7 @@ evaluate_function(Oid funcid, Oid result_type, int32 result_typmod,
HeapTuple func_tuple,
eval_const_expressions_context *context)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
bool has_nonconst_input = false;
bool has_null_input = false;
ListCell *arg;
@@ -4441,7 +4441,7 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid,
HeapTuple func_tuple,
eval_const_expressions_context *context)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
char *src;
Datum tmp;
bool isNull;
@@ -5034,7 +5034,7 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
func_tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(func_oid));
if (!HeapTupleIsValid(func_tuple))
elog(ERROR, "cache lookup failed for function %u", func_oid);
- funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ funcform = GETSTRUCT(pg_proc, func_tuple);
/*
* Forget it if the function is not SQL-language or has other showstopper
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 5012bfe142..c163f1096e 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -1296,7 +1296,7 @@ get_relation_statistics_worker(List **stainfos, RelOptInfo *rel,
if (!HeapTupleIsValid(dtup))
return;
- dataForm = (Form_pg_statistic_ext_data) GETSTRUCT(dtup);
+ dataForm = GETSTRUCT(pg_statistic_ext_data, dtup);
/* add one StatisticExtInfo for each kind built */
if (statext_is_kind_built(dtup, STATS_EXT_NDISTINCT))
@@ -1388,7 +1388,7 @@ get_relation_statistics(RelOptInfo *rel, Relation relation)
htup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statOid));
if (!HeapTupleIsValid(htup))
elog(ERROR, "cache lookup failed for statistics object %u", statOid);
- staForm = (Form_pg_statistic_ext) GETSTRUCT(htup);
+ staForm = GETSTRUCT(pg_statistic_ext, htup);
/*
* First, build the array of columns covered. This is ultimately
@@ -1994,7 +1994,7 @@ add_function_cost(PlannerInfo *root, Oid funcid, Node *node,
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
if (OidIsValid(procform->prosupport))
{
@@ -2055,7 +2055,7 @@ get_function_rows(PlannerInfo *root, Oid funcid, Node *node)
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
Assert(procform->proretset); /* else caller error */
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index c655d188c7..36451e7d63 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -3617,7 +3617,7 @@ transformFrameOffset(ParseState *pstate, int frameOptions,
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
/* The search will find all support proc types; ignore others */
if (procform->amprocnum != BTINRANGE_PROC)
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index c4e958e4aa..172d4b2034 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -853,7 +853,7 @@ build_coercion_expression(Node *node,
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcId));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcId);
- procstruct = (Form_pg_proc) GETSTRUCT(tp);
+ procstruct = GETSTRUCT(pg_proc, tp);
/*
* These Asserts essentially check that function is a legal coercion
@@ -3056,7 +3056,7 @@ IsBinaryCoercible(Oid srctype, Oid targettype)
ObjectIdGetDatum(targettype));
if (!HeapTupleIsValid(tuple))
return false; /* no cast */
- castForm = (Form_pg_cast) GETSTRUCT(tuple);
+ castForm = GETSTRUCT(pg_cast, tuple);
result = (castForm->castmethod == COERCION_METHOD_BINARY &&
castForm->castcontext == COERCION_CODE_IMPLICIT);
@@ -3120,7 +3120,7 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
if (HeapTupleIsValid(tuple))
{
- Form_pg_cast castForm = (Form_pg_cast) GETSTRUCT(tuple);
+ Form_pg_cast castForm = GETSTRUCT(pg_cast, tuple);
CoercionContext castcontext;
/* convert char value for castcontext to CoercionContext enum */
@@ -3269,7 +3269,7 @@ find_typmod_coercion_function(Oid typeId,
result = COERCION_PATH_FUNC;
targetType = typeidType(typeId);
- typeForm = (Form_pg_type) GETSTRUCT(targetType);
+ typeForm = GETSTRUCT(pg_type, targetType);
/* Check for a "true" array type */
if (IsTrueArrayType(typeForm))
@@ -3287,7 +3287,7 @@ find_typmod_coercion_function(Oid typeId,
if (HeapTupleIsValid(tuple))
{
- Form_pg_cast castForm = (Form_pg_cast) GETSTRUCT(tuple);
+ Form_pg_cast castForm = GETSTRUCT(pg_cast, tuple);
*funcid = castForm->castfunc;
ReleaseSysCache(tuple);
@@ -3335,7 +3335,7 @@ typeIsOfTypedTable(Oid reltypeId, Oid reloftypeId)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltup = (Form_pg_class) GETSTRUCT(tp);
+ reltup = GETSTRUCT(pg_class, tp);
if (reltup->reloftype == reloftypeId)
result = true;
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index f71a682cd6..c9be37c173 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -367,7 +367,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
tup = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for aggregate %u", funcid);
- classForm = (Form_pg_aggregate) GETSTRUCT(tup);
+ classForm = GETSTRUCT(pg_aggregate, tup);
aggkind = classForm->aggkind;
catDirectArgs = classForm->aggnumdirectargs;
ReleaseSysCache(tup);
@@ -1623,7 +1623,7 @@ func_get_detail(List *funcname,
if (!HeapTupleIsValid(ftup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u",
best_candidate->oid);
- pform = (Form_pg_proc) GETSTRUCT(ftup);
+ pform = GETSTRUCT(pg_proc, ftup);
*rettype = pform->prorettype;
*retset = pform->proretset;
*vatype = pform->provariadic;
@@ -1893,7 +1893,7 @@ FuncNameAsType(List *funcname)
if (typtup == NULL)
return InvalidOid;
- if (((Form_pg_type) GETSTRUCT(typtup))->typisdefined &&
+ if ((GETSTRUCT(pg_type, typtup))->typisdefined &&
!OidIsValid(typeTypeRelid(typtup)))
result = typeTypeId(typtup);
else
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index cf64afbd85..2c165bb1be 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -249,14 +249,14 @@ get_sort_group_operators(Oid argtype,
Oid
oprid(Operator op)
{
- return ((Form_pg_operator) GETSTRUCT(op))->oid;
+ return (GETSTRUCT(pg_operator, op))->oid;
}
/* given operator tuple, return the underlying function's OID */
Oid
oprfuncid(Operator op)
{
- Form_pg_operator pgopform = (Form_pg_operator) GETSTRUCT(op);
+ Form_pg_operator pgopform = GETSTRUCT(pg_operator, op);
return pgopform->oprcode;
}
@@ -471,7 +471,7 @@ compatible_oper(ParseState *pstate, List *op, Oid arg1, Oid arg2,
return (Operator) NULL; /* must be noError case */
/* but is it good enough? */
- opform = (Form_pg_operator) GETSTRUCT(optup);
+ opform = GETSTRUCT(pg_operator, optup);
if (IsBinaryCoercible(arg1, opform->oprleft) &&
IsBinaryCoercible(arg2, opform->oprright))
return optup;
@@ -705,7 +705,7 @@ make_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree,
tup = oper(pstate, opname, ltypeId, rtypeId, false, location);
}
- opform = (Form_pg_operator) GETSTRUCT(tup);
+ opform = GETSTRUCT(pg_operator, tup);
/* Check it's not a shell */
if (!RegProcedureIsValid(opform->oprcode))
@@ -819,7 +819,7 @@ make_scalar_array_op(ParseState *pstate, List *opname,
/* Now resolve the operator */
tup = oper(pstate, opname, ltypeId, rtypeId, false, location);
- opform = (Form_pg_operator) GETSTRUCT(tup);
+ opform = GETSTRUCT(pg_operator, tup);
/* Check it's not a shell */
if (!RegProcedureIsValid(opform->oprcode))
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 926dcbf30e..84d7e05fa5 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -3243,7 +3243,7 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, rte->relid);
- att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ att_tup = GETSTRUCT(pg_attribute, tp);
result = att_tup->attisdropped;
ReleaseSysCache(tp);
}
diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c
index f7ad689459..65f0ab1489 100644
--- a/src/backend/parser/parse_type.c
+++ b/src/backend/parser/parse_type.c
@@ -247,7 +247,7 @@ LookupTypeNameOid(ParseState *pstate, const TypeName *typeName, bool missing_ok)
return InvalidOid;
}
- typoid = ((Form_pg_type) GETSTRUCT(tup))->oid;
+ typoid = (GETSTRUCT(pg_type, tup))->oid;
ReleaseSysCache(tup);
return typoid;
@@ -272,7 +272,7 @@ typenameType(ParseState *pstate, const TypeName *typeName, int32 *typmod_p)
errmsg("type \"%s\" does not exist",
TypeNameToString(typeName)),
parser_errposition(pstate, typeName->location)));
- if (!((Form_pg_type) GETSTRUCT(tup))->typisdefined)
+ if (!(GETSTRUCT(pg_type, tup))->typisdefined)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type \"%s\" is only a shell",
@@ -294,7 +294,7 @@ typenameTypeId(ParseState *pstate, const TypeName *typeName)
Type tup;
tup = typenameType(pstate, typeName, NULL);
- typoid = ((Form_pg_type) GETSTRUCT(tup))->oid;
+ typoid = (GETSTRUCT(pg_type, tup))->oid;
ReleaseSysCache(tup);
return typoid;
@@ -313,7 +313,7 @@ typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName,
Type tup;
tup = typenameType(pstate, typeName, typmod_p);
- *typeid_p = ((Form_pg_type) GETSTRUCT(tup))->oid;
+ *typeid_p = (GETSTRUCT(pg_type, tup))->oid;
ReleaseSysCache(tup);
}
@@ -348,14 +348,14 @@ typenameTypeMod(ParseState *pstate, const TypeName *typeName, Type typ)
* for the shell-type case, since a shell couldn't possibly have a
* typmodin function.
*/
- if (!((Form_pg_type) GETSTRUCT(typ))->typisdefined)
+ if (!(GETSTRUCT(pg_type, typ))->typisdefined)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("type modifier cannot be specified for shell type \"%s\"",
TypeNameToString(typeName)),
parser_errposition(pstate, typeName->location)));
- typmodin = ((Form_pg_type) GETSTRUCT(typ))->typmodin;
+ typmodin = (GETSTRUCT(pg_type, typ))->typmodin;
if (typmodin == InvalidOid)
ereport(ERROR,
@@ -591,7 +591,7 @@ typeTypeId(Type tp)
{
if (tp == NULL) /* probably useless */
elog(ERROR, "typeTypeId() called with NULL type struct");
- return ((Form_pg_type) GETSTRUCT(tp))->oid;
+ return (GETSTRUCT(pg_type, tp))->oid;
}
/* given type (as type struct), return the length of type */
@@ -600,7 +600,7 @@ typeLen(Type t)
{
Form_pg_type typ;
- typ = (Form_pg_type) GETSTRUCT(t);
+ typ = GETSTRUCT(pg_type, t);
return typ->typlen;
}
@@ -610,7 +610,7 @@ typeByVal(Type t)
{
Form_pg_type typ;
- typ = (Form_pg_type) GETSTRUCT(t);
+ typ = GETSTRUCT(pg_type, t);
return typ->typbyval;
}
@@ -620,7 +620,7 @@ typeTypeName(Type t)
{
Form_pg_type typ;
- typ = (Form_pg_type) GETSTRUCT(t);
+ typ = GETSTRUCT(pg_type, t);
/* pstrdup here because result may need to outlive the syscache entry */
return pstrdup(NameStr(typ->typname));
}
@@ -631,7 +631,7 @@ typeTypeRelid(Type typ)
{
Form_pg_type typtup;
- typtup = (Form_pg_type) GETSTRUCT(typ);
+ typtup = GETSTRUCT(pg_type, typ);
return typtup->typrelid;
}
@@ -641,7 +641,7 @@ typeTypeCollation(Type typ)
{
Form_pg_type typtup;
- typtup = (Form_pg_type) GETSTRUCT(typ);
+ typtup = GETSTRUCT(pg_type, typ);
return typtup->typcollation;
}
@@ -653,7 +653,7 @@ typeTypeCollation(Type typ)
Datum
stringTypeDatum(Type tp, char *string, int32 atttypmod)
{
- Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typform = GETSTRUCT(pg_type, tp);
Oid typinput = typform->typinput;
Oid typioparam = getTypeIOParam(tp);
@@ -674,7 +674,7 @@ typeidTypeRelid(Oid type_id)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_id));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type_id);
- type = (Form_pg_type) GETSTRUCT(typeTuple);
+ type = GETSTRUCT(pg_type, typeTuple);
result = type->typrelid;
ReleaseSysCache(typeTuple);
return result;
@@ -697,7 +697,7 @@ typeOrDomainTypeRelid(Oid type_id)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_id));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type_id);
- type = (Form_pg_type) GETSTRUCT(typeTuple);
+ type = GETSTRUCT(pg_type, typeTuple);
if (type->typtype != TYPTYPE_DOMAIN)
{
/* Not a domain, so done looking through domains */
@@ -797,7 +797,7 @@ parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p, bool missing_ok
}
else
{
- Form_pg_type typ = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typ = GETSTRUCT(pg_type, tup);
if (!typ->typisdefined)
ereport(ERROR,
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index b57253463b..417a571529 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -693,7 +693,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
errmsg("identity columns are not supported on partitions")));
ctype = typenameType(cxt->pstate, column->typeName, NULL);
- typeOid = ((Form_pg_type) GETSTRUCT(ctype))->oid;
+ typeOid = (GETSTRUCT(pg_type, ctype))->oid;
ReleaseSysCache(ctype);
if (saw_identity)
@@ -1457,7 +1457,7 @@ transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
tuple = typenameType(NULL, ofTypename, NULL);
check_of_type(tuple);
- ofTypeId = ((Form_pg_type) GETSTRUCT(tuple))->oid;
+ ofTypeId = (GETSTRUCT(pg_type, tuple))->oid;
ofTypename->typeOid = ofTypeId; /* cached for later */
tupdesc = lookup_rowtype_tupdesc(ofTypeId, -1);
@@ -1541,11 +1541,11 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(source_relid));
if (!HeapTupleIsValid(ht_idxrel))
elog(ERROR, "cache lookup failed for relation %u", source_relid);
- idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);
+ idxrelrec = GETSTRUCT(pg_class, ht_idxrel);
/* Fetch pg_index tuple for source index from relcache entry */
ht_idx = source_idx->rd_indextuple;
- idxrec = (Form_pg_index) GETSTRUCT(ht_idx);
+ idxrec = GETSTRUCT(pg_index, ht_idx);
indrelid = idxrec->indrelid;
/* Fetch the pg_am tuple of the index' access method */
@@ -1553,7 +1553,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
if (!HeapTupleIsValid(ht_am))
elog(ERROR, "cache lookup failed for access method %u",
idxrelrec->relam);
- amrec = (Form_pg_am) GETSTRUCT(ht_am);
+ amrec = GETSTRUCT(pg_am, ht_am);
/* Extract indcollation from the pg_index tuple */
datum = SysCacheGetAttr(INDEXRELID, ht_idx,
@@ -1620,7 +1620,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
if (!HeapTupleIsValid(ht_constr))
elog(ERROR, "cache lookup failed for constraint %u",
constraintId);
- conrec = (Form_pg_constraint) GETSTRUCT(ht_constr);
+ conrec = GETSTRUCT(pg_constraint, ht_constr);
index->isconstraint = true;
index->deferrable = conrec->condeferrable;
@@ -1658,7 +1658,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
if (!HeapTupleIsValid(opertup))
elog(ERROR, "cache lookup failed for operator %u",
operid);
- operform = (Form_pg_operator) GETSTRUCT(opertup);
+ operform = GETSTRUCT(pg_operator, opertup);
oprname = pstrdup(NameStr(operform->oprname));
/* For simplicity we always schema-qualify the op name */
nspname = get_namespace_name(operform->oprnamespace);
@@ -1889,7 +1889,7 @@ generateClonedExtStatsStmt(RangeVar *heapRel, Oid heapRelid,
ht_stats = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(source_statsid));
if (!HeapTupleIsValid(ht_stats))
elog(ERROR, "cache lookup failed for statistics object %u", source_statsid);
- statsrec = (Form_pg_statistic_ext) GETSTRUCT(ht_stats);
+ statsrec = GETSTRUCT(pg_statistic_ext, ht_stats);
/* Determine which statistics types exist */
datum = SysCacheGetAttr(STATEXTOID, ht_stats,
@@ -2001,7 +2001,7 @@ get_collation(Oid collation, Oid actual_datatype)
ht_coll = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation));
if (!HeapTupleIsValid(ht_coll))
elog(ERROR, "cache lookup failed for collation %u", collation);
- coll_rec = (Form_pg_collation) GETSTRUCT(ht_coll);
+ coll_rec = GETSTRUCT(pg_collation, ht_coll);
/* For simplicity, we always schema-qualify the name */
nsp_name = get_namespace_name(coll_rec->collnamespace);
@@ -2028,7 +2028,7 @@ get_opclass(Oid opclass, Oid actual_datatype)
ht_opc = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(ht_opc))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- opc_rec = (Form_pg_opclass) GETSTRUCT(ht_opc);
+ opc_rec = GETSTRUCT(pg_opclass, ht_opc);
if (GetDefaultOpClass(actual_datatype, opc_rec->opcmethod) != opclass)
{
@@ -3771,7 +3771,7 @@ transformColumnType(CreateStmtContext *cxt, ColumnDef *column)
if (column->collClause)
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(ctype);
+ Form_pg_type typtup = GETSTRUCT(pg_type, ctype);
LookupCollation(cxt->pstate,
column->collClause->collname,
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 2e146aac93..a3ffd2947b 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -1910,7 +1910,7 @@ get_database_list(void)
while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
{
- Form_pg_database pgdatabase = (Form_pg_database) GETSTRUCT(tup);
+ Form_pg_database pgdatabase = GETSTRUCT(pg_database, tup);
avw_dbase *avdb;
MemoryContext oldcxt;
@@ -1997,7 +1997,7 @@ do_autovacuum(void)
tuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
- dbForm = (Form_pg_database) GETSTRUCT(tuple);
+ dbForm = GETSTRUCT(pg_database, tuple);
if (dbForm->datistemplate || !dbForm->datallowconn)
{
@@ -2055,7 +2055,7 @@ do_autovacuum(void)
*/
while ((tuple = heap_getnext(relScan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classForm = GETSTRUCT(pg_class, tuple);
PgStat_StatTabEntry *tabentry;
AutoVacOpts *relopts;
Oid relid;
@@ -2148,7 +2148,7 @@ do_autovacuum(void)
relScan = table_beginscan_catalog(classRel, 1, &key);
while ((tuple = heap_getnext(relScan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classForm = GETSTRUCT(pg_class, tuple);
PgStat_StatTabEntry *tabentry;
Oid relid;
AutoVacOpts *relopts = NULL;
@@ -2235,7 +2235,7 @@ do_autovacuum(void)
UnlockRelationOid(relid, AccessExclusiveLock);
continue;
}
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/*
* Make all the same tests made in the loop above. In event of OID
@@ -2340,7 +2340,7 @@ do_autovacuum(void)
classTup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(classTup))
continue; /* somebody deleted the rel, forget it */
- isshared = ((Form_pg_class) GETSTRUCT(classTup))->relisshared;
+ isshared = (GETSTRUCT(pg_class, classTup))->relisshared;
ReleaseSysCache(classTup);
/*
@@ -2726,9 +2726,9 @@ extract_autovac_opts(HeapTuple tup, TupleDesc pg_class_desc)
bytea *relopts;
AutoVacOpts *av;
- Assert(((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_RELATION ||
- ((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_MATVIEW ||
- ((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_TOASTVALUE);
+ Assert((GETSTRUCT(pg_class, tup))->relkind == RELKIND_RELATION ||
+ (GETSTRUCT(pg_class, tup))->relkind == RELKIND_MATVIEW ||
+ (GETSTRUCT(pg_class, tup))->relkind == RELKIND_TOASTVALUE);
relopts = extractRelOptions(tup, pg_class_desc, NULL);
if (relopts == NULL)
@@ -2767,7 +2767,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(classTup))
return NULL;
- classForm = (Form_pg_class) GETSTRUCT(classTup);
+ classForm = GETSTRUCT(pg_class, classTup);
/*
* Get the applicable reloptions. If it is a TOAST table, try to get the
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index 2bdab53e19..8f8d61d682 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -114,7 +114,7 @@ get_subscription_list(void)
while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
{
- Form_pg_subscription subform = (Form_pg_subscription) GETSTRUCT(tup);
+ Form_pg_subscription subform = GETSTRUCT(pg_subscription, tup);
Subscription *sub;
MemoryContext oldcxt;
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index 21937ab2d3..bcc8ce4451 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -218,7 +218,7 @@ replorigin_by_name(const char *roname, bool missing_ok)
tuple = SearchSysCache1(REPLORIGNAME, roname_d);
if (HeapTupleIsValid(tuple))
{
- ident = (Form_pg_replication_origin) GETSTRUCT(tuple);
+ ident = GETSTRUCT(pg_replication_origin, tuple);
roident = ident->roident;
ReleaseSysCache(tuple);
}
@@ -460,7 +460,7 @@ replorigin_by_oid(RepOriginId roident, bool missing_ok, char **roname)
if (HeapTupleIsValid(tuple))
{
- ric = (Form_pg_replication_origin) GETSTRUCT(tuple);
+ ric = GETSTRUCT(pg_replication_origin, tuple);
*roname = text_to_cstring(&ric->roname);
ReleaseSysCache(tuple);
diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c
index ff8513e2d2..01f38d1b28 100644
--- a/src/backend/replication/logical/proto.c
+++ b/src/backend/replication/logical/proto.c
@@ -736,7 +736,7 @@ logicalrep_write_typ(StringInfo out, TransactionId xid, Oid typoid)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(basetypoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", basetypoid);
- typtup = (Form_pg_type) GETSTRUCT(tup);
+ typtup = GETSTRUCT(pg_type, tup);
/* use Oid as relation identifier */
pq_sendint32(out, typoid);
@@ -827,7 +827,7 @@ logicalrep_write_tuple(StringInfo out, Relation rel, TupleTableSlot *slot,
typtup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(att->atttypid));
if (!HeapTupleIsValid(typtup))
elog(ERROR, "cache lookup failed for type %u", att->atttypid);
- typclass = (Form_pg_type) GETSTRUCT(typtup);
+ typclass = GETSTRUCT(pg_type, typtup);
/*
* Send in binary if requested and type has suitable send function.
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 38e3b1c1b3..591d625c24 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -3939,7 +3939,7 @@ clear_subscription_skip_lsn(XLogRecPtr finish_lsn)
if (!HeapTupleIsValid(tup))
elog(ERROR, "subscription \"%s\" does not exist", MySubscription->name);
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = GETSTRUCT(pg_subscription, tup);
/*
* Clear the subskiplsn. If the user has already changed subskiplsn before
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index 185bf5fbff..75c7785044 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -128,7 +128,7 @@ InsertRule(const char *rulname,
ReleaseSysCache(oldtup);
- rewriteObjectId = ((Form_pg_rewrite) GETSTRUCT(tup))->oid;
+ rewriteObjectId = (GETSTRUCT(pg_rewrite, tup))->oid;
is_update = true;
}
else
@@ -627,7 +627,7 @@ DefineQueryRewrite(const char *rulename,
classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(event_relid));
if (!HeapTupleIsValid(classTup))
elog(ERROR, "cache lookup failed for relation %u", event_relid);
- classForm = (Form_pg_class) GETSTRUCT(classTup);
+ classForm = GETSTRUCT(pg_class, classTup);
classForm->relam = InvalidOid;
classForm->reltablespace = InvalidOid;
@@ -877,7 +877,7 @@ EnableDisableRule(Relation rel, const char *rulename,
errmsg("rule \"%s\" for relation \"%s\" does not exist",
rulename, get_rel_name(owningRel))));
- ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup);
+ ruleform = GETSTRUCT(pg_rewrite, ruletup);
/*
* Verify that the user has appropriate permissions.
@@ -928,7 +928,7 @@ RangeVarCallbackForRenameRule(const RangeVar *rv, Oid relid, Oid oldrelid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped */
- form = (Form_pg_class) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_class, tuple);
/* only tables and views can have rules */
if (form->relkind != RELKIND_RELATION &&
@@ -991,7 +991,7 @@ RenameRewriteRule(RangeVar *relation, const char *oldName,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("rule \"%s\" for relation \"%s\" does not exist",
oldName, RelationGetRelationName(targetrel))));
- ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup);
+ ruleform = GETSTRUCT(pg_rewrite, ruletup);
ruleOid = ruleform->oid;
/* rule with the new name should not already exist */
diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c
index 2b51683f6d..ad845f4124 100644
--- a/src/backend/rewrite/rewriteRemove.c
+++ b/src/backend/rewrite/rewriteRemove.c
@@ -71,7 +71,7 @@ RemoveRewriteRuleById(Oid ruleOid)
* going on that might depend on this rule. (Note: a weaker lock would
* suffice if it's not an ON SELECT rule.)
*/
- eventRelationOid = ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class;
+ eventRelationOid = (GETSTRUCT(pg_rewrite, tuple))->ev_class;
event_relation = table_open(eventRelationOid, AccessExclusiveLock);
if (!allowSystemTableMods && IsSystemRelation(event_relation))
diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c
index 80e2509450..bb8c6c1fbd 100644
--- a/src/backend/rewrite/rewriteSupport.c
+++ b/src/backend/rewrite/rewriteSupport.c
@@ -64,7 +64,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules)
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationId);
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
if (classForm->relhasrules != relHasRules)
{
@@ -109,7 +109,7 @@ get_rewrite_oid(Oid relid, const char *rulename, bool missing_ok)
errmsg("rule \"%s\" for relation \"%s\" does not exist",
rulename, get_rel_name(relid))));
}
- ruleform = (Form_pg_rewrite) GETSTRUCT(tuple);
+ ruleform = GETSTRUCT(pg_rewrite, tuple);
Assert(relid == ruleform->ev_class);
ruleoid = ruleform->oid;
ReleaseSysCache(tuple);
diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index d2aa8d0ca3..9d9bfa1912 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -453,7 +453,7 @@ fetch_statentries_for_relation(Relation pg_statext, Oid relid)
List *exprs = NIL;
entry = palloc0(sizeof(StatExtEntry));
- staForm = (Form_pg_statistic_ext) GETSTRUCT(htup);
+ staForm = GETSTRUCT(pg_statistic_ext, htup);
entry->statOid = staForm->oid;
entry->schema = get_namespace_name(staForm->stxnamespace);
entry->name = pstrdup(NameStr(staForm->stxname));
@@ -561,7 +561,7 @@ examine_attribute(Node *expr)
ObjectIdGetDatum(stats->attrtypid));
if (!HeapTupleIsValid(typtuple))
elog(ERROR, "cache lookup failed for type %u", stats->attrtypid);
- stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple);
+ stats->attrtype = GETSTRUCT(pg_type, typtuple);
/*
* We don't actually analyze individual attributes, so no need to set the
@@ -663,7 +663,7 @@ examine_expression(Node *expr, int stattarget)
if (!HeapTupleIsValid(typtuple))
elog(ERROR, "cache lookup failed for type %u", stats->attrtypid);
- stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple);
+ stats->attrtype = GETSTRUCT(pg_type, typtuple);
stats->anl_context = CurrentMemoryContext; /* XXX should be using
* something else? */
stats->tupattnum = InvalidAttrNumber;
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
index d204482a61..e63c78c20c 100644
--- a/src/backend/storage/large_object/inv_api.c
+++ b/src/backend/storage/large_object/inv_api.c
@@ -412,7 +412,7 @@ inv_getsize(LargeObjectDesc *obj_desc)
if (HeapTupleHasNulls(tuple)) /* paranoia */
elog(ERROR, "null field found in pg_largeobject");
- data = (Form_pg_largeobject) GETSTRUCT(tuple);
+ data = GETSTRUCT(pg_largeobject, tuple);
getdatafield(data, &datafield, &len, &pfreeit);
lastbyte = (uint64) data->pageno * LOBLKSIZE + len;
if (pfreeit)
@@ -534,7 +534,7 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
if (HeapTupleHasNulls(tuple)) /* paranoia */
elog(ERROR, "null field found in pg_largeobject");
- data = (Form_pg_largeobject) GETSTRUCT(tuple);
+ data = GETSTRUCT(pg_largeobject, tuple);
/*
* We expect the indexscan will deliver pages in order. However,
@@ -662,7 +662,7 @@ inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes)
{
if (HeapTupleHasNulls(oldtuple)) /* paranoia */
elog(ERROR, "null field found in pg_largeobject");
- olddata = (Form_pg_largeobject) GETSTRUCT(oldtuple);
+ olddata = GETSTRUCT(pg_largeobject, oldtuple);
Assert(olddata->pageno >= pageno);
}
neednextpage = false;
@@ -848,7 +848,7 @@ inv_truncate(LargeObjectDesc *obj_desc, int64 len)
{
if (HeapTupleHasNulls(oldtuple)) /* paranoia */
elog(ERROR, "null field found in pg_largeobject");
- olddata = (Form_pg_largeobject) GETSTRUCT(oldtuple);
+ olddata = GETSTRUCT(pg_largeobject, oldtuple);
Assert(olddata->pageno >= pageno);
}
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index d429aa4663..2311f1ad05 100644
--- a/src/backend/tcop/fastpath.c
+++ b/src/backend/tcop/fastpath.c
@@ -139,7 +139,7 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function with OID %u does not exist", func_id)));
- pp = (Form_pg_proc) GETSTRUCT(func_htp);
+ pp = GETSTRUCT(pg_proc, func_htp);
/* reject pg_proc entries that are unsafe to call via fastpath */
if (pp->prokind != PROKIND_FUNCTION || pp->proretset)
diff --git a/src/backend/tsearch/ts_selfuncs.c b/src/backend/tsearch/ts_selfuncs.c
index 8f2679f57e..69dcf0f327 100644
--- a/src/backend/tsearch/ts_selfuncs.c
+++ b/src/backend/tsearch/ts_selfuncs.c
@@ -165,7 +165,7 @@ tsquerysel(VariableStatData *vardata, Datum constval)
Form_pg_statistic stats;
AttStatsSlot sslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
/* MCELEM will be an array of TEXT elements for a tsvector column */
if (get_attstatsslot(&sslot, vardata->statsTuple,
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c
index b7fd3bcf05..6ee7101357 100644
--- a/src/backend/utils/adt/acl.c
+++ b/src/backend/utils/adt/acl.c
@@ -603,7 +603,7 @@ aclitemout(PG_FUNCTION_ARGS)
htup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(aip->ai_grantee));
if (HeapTupleIsValid(htup))
{
- putid(p, NameStr(((Form_pg_authid) GETSTRUCT(htup))->rolname));
+ putid(p, NameStr((GETSTRUCT(pg_authid, htup))->rolname));
ReleaseSysCache(htup);
}
else
@@ -631,7 +631,7 @@ aclitemout(PG_FUNCTION_ARGS)
htup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(aip->ai_grantor));
if (HeapTupleIsValid(htup))
{
- putid(p, NameStr(((Form_pg_authid) GETSTRUCT(htup))->rolname));
+ putid(p, NameStr((GETSTRUCT(pg_authid, htup))->rolname));
ReleaseSysCache(htup);
}
else
@@ -2818,7 +2818,7 @@ convert_column_name(Oid tableoid, text *column)
{
Form_pg_attribute attributeForm;
- attributeForm = (Form_pg_attribute) GETSTRUCT(attTuple);
+ attributeForm = GETSTRUCT(pg_attribute, attTuple);
/* We want to return NULL for dropped columns */
if (attributeForm->attisdropped)
attnum = InvalidAttrNumber;
@@ -4782,7 +4782,7 @@ has_rolinherit(Oid roleid)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolinherit;
+ result = (GETSTRUCT(pg_authid, utup))->rolinherit;
ReleaseSysCache(utup);
}
return result;
@@ -4835,7 +4835,7 @@ roles_is_member_of(Oid roleid, enum RoleRecurseType type,
dbtup = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
if (!HeapTupleIsValid(dbtup))
elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
- dba = ((Form_pg_database) GETSTRUCT(dbtup))->datdba;
+ dba = (GETSTRUCT(pg_database, dbtup))->datdba;
ReleaseSysCache(dbtup);
}
@@ -4867,14 +4867,14 @@ roles_is_member_of(Oid roleid, enum RoleRecurseType type,
for (i = 0; i < memlist->n_members; i++)
{
HeapTuple tup = &memlist->members[i]->tuple;
- Oid otherid = ((Form_pg_auth_members) GETSTRUCT(tup))->roleid;
+ Oid otherid = (GETSTRUCT(pg_auth_members, tup))->roleid;
/*
* While otherid==InvalidOid shouldn't appear in the catalog, the
* OidIsValid() avoids crashing if that arises.
*/
if (otherid == admin_of &&
- ((Form_pg_auth_members) GETSTRUCT(tup))->admin_option &&
+ (GETSTRUCT(pg_auth_members, tup))->admin_option &&
OidIsValid(admin_of))
*is_admin = true;
@@ -5274,7 +5274,7 @@ get_rolespec_name(const RoleSpec *role)
char *rolename;
tp = get_rolespec_tuple(role);
- authForm = (Form_pg_authid) GETSTRUCT(tp);
+ authForm = GETSTRUCT(pg_authid, tp);
rolename = pstrdup(NameStr(authForm->rolname));
ReleaseSysCache(tp);
diff --git a/src/backend/utils/adt/amutils.c b/src/backend/utils/adt/amutils.c
index 9d78a90d69..f04ed870fe 100644
--- a/src/backend/utils/adt/amutils.c
+++ b/src/backend/utils/adt/amutils.c
@@ -174,7 +174,7 @@ indexam_property(FunctionCallInfo fcinfo,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(index_oid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- rd_rel = (Form_pg_class) GETSTRUCT(tuple);
+ rd_rel = GETSTRUCT(pg_class, tuple);
if (rd_rel->relkind != RELKIND_INDEX &&
rd_rel->relkind != RELKIND_PARTITIONED_INDEX)
{
@@ -229,7 +229,7 @@ indexam_property(FunctionCallInfo fcinfo,
tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
Assert(index_oid == rd_index->indexrelid);
Assert(attno > 0 && attno <= rd_index->indnatts);
diff --git a/src/backend/utils/adt/array_selfuncs.c b/src/backend/utils/adt/array_selfuncs.c
index 8cbee1406b..9bac8771c1 100644
--- a/src/backend/utils/adt/array_selfuncs.c
+++ b/src/backend/utils/adt/array_selfuncs.c
@@ -139,7 +139,7 @@ scalararraysel_containment(PlannerInfo *root,
AttStatsSlot sslot;
AttStatsSlot hslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
/* MCELEM will be an array of same type as element */
if (get_attstatsslot(&sslot, vardata.statsTuple,
@@ -362,7 +362,7 @@ calc_arraycontsel(VariableStatData *vardata, Datum constval,
AttStatsSlot sslot;
AttStatsSlot hslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
/* MCELEM will be an array of same type as column */
if (get_attstatsslot(&sslot, vardata->statsTuple,
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c
index 34efa121b4..403cbd0b13 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -857,7 +857,7 @@ pg_relation_filenode(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- relform = (Form_pg_class) GETSTRUCT(tuple);
+ relform = GETSTRUCT(pg_class, tuple);
if (RELKIND_HAS_STORAGE(relform->relkind))
{
@@ -931,7 +931,7 @@ pg_relation_filepath(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- relform = (Form_pg_class) GETSTRUCT(tuple);
+ relform = GETSTRUCT(pg_class, tuple);
if (RELKIND_HAS_STORAGE(relform->relkind))
{
diff --git a/src/backend/utils/adt/domains.c b/src/backend/utils/adt/domains.c
index 3de0cb01a2..3d17b1de79 100644
--- a/src/backend/utils/adt/domains.c
+++ b/src/backend/utils/adt/domains.c
@@ -365,7 +365,7 @@ errdatatype(Oid datatypeOid)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(datatypeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", datatypeOid);
- typtup = (Form_pg_type) GETSTRUCT(tup);
+ typtup = GETSTRUCT(pg_type, tup);
err_generic_string(PG_DIAG_SCHEMA_NAME,
get_namespace_name(typtup->typnamespace));
diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c
index 0cc7a6d8ad..bb24bd13fa 100644
--- a/src/backend/utils/adt/enum.c
+++ b/src/backend/utils/adt/enum.c
@@ -63,7 +63,7 @@ static void
check_safe_enum_use(HeapTuple enumval_tup)
{
TransactionId xmin;
- Form_pg_enum en = (Form_pg_enum) GETSTRUCT(enumval_tup);
+ Form_pg_enum en = GETSTRUCT(pg_enum, enumval_tup);
/*
* If the row is hinted as committed, it's surely safe. This provides a
@@ -138,7 +138,7 @@ enum_in(PG_FUNCTION_ARGS)
* This comes from pg_enum.oid and stores system oids in user tables. This
* oid must be preserved by binary upgrades.
*/
- enumoid = ((Form_pg_enum) GETSTRUCT(tup))->oid;
+ enumoid = (GETSTRUCT(pg_enum, tup))->oid;
ReleaseSysCache(tup);
@@ -159,7 +159,7 @@ enum_out(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid internal value for enum: %u",
enumval)));
- en = (Form_pg_enum) GETSTRUCT(tup);
+ en = GETSTRUCT(pg_enum, tup);
result = pstrdup(NameStr(en->enumlabel));
@@ -202,7 +202,7 @@ enum_recv(PG_FUNCTION_ARGS)
/* check it's safe to use in SQL */
check_safe_enum_use(tup);
- enumoid = ((Form_pg_enum) GETSTRUCT(tup))->oid;
+ enumoid = (GETSTRUCT(pg_enum, tup))->oid;
ReleaseSysCache(tup);
@@ -225,7 +225,7 @@ enum_send(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid internal value for enum: %u",
enumval)));
- en = (Form_pg_enum) GETSTRUCT(tup);
+ en = GETSTRUCT(pg_enum, tup);
pq_begintypsend(&buf);
pq_sendtext(&buf, NameStr(en->enumlabel), strlen(NameStr(en->enumlabel)));
@@ -284,7 +284,7 @@ enum_cmp_internal(Oid arg1, Oid arg2, FunctionCallInfo fcinfo)
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid internal value for enum: %u",
arg1)));
- en = (Form_pg_enum) GETSTRUCT(enum_tup);
+ en = GETSTRUCT(pg_enum, enum_tup);
typeoid = en->enumtypid;
ReleaseSysCache(enum_tup);
/* Now locate and remember the typcache entry */
@@ -412,7 +412,7 @@ enum_endpoint(Oid enumtypoid, ScanDirection direction)
{
/* check it's safe to use in SQL */
check_safe_enum_use(enum_tuple);
- minmax = ((Form_pg_enum) GETSTRUCT(enum_tuple))->oid;
+ minmax = (GETSTRUCT(pg_enum, enum_tuple))->oid;
}
else
{
@@ -572,7 +572,7 @@ enum_range_internal(Oid enumtypoid, Oid lower, Oid upper)
while (HeapTupleIsValid(enum_tuple = systable_getnext_ordered(enum_scan, ForwardScanDirection)))
{
- Oid enum_oid = ((Form_pg_enum) GETSTRUCT(enum_tuple))->oid;
+ Oid enum_oid = (GETSTRUCT(pg_enum, enum_tuple))->oid;
if (!left_found && lower == enum_oid)
left_found = true;
diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c
index 060fd7e183..e2e127ac2c 100644
--- a/src/backend/utils/adt/format_type.c
+++ b/src/backend/utils/adt/format_type.c
@@ -136,7 +136,7 @@ format_type_extended(Oid type_oid, int32 typemod, bits16 flags)
else
elog(ERROR, "cache lookup failed for type %u", type_oid);
}
- typeform = (Form_pg_type) GETSTRUCT(tuple);
+ typeform = GETSTRUCT(pg_type, tuple);
/*
* Check if it's a "true" array type. Pseudo-array types such as "name"
@@ -161,7 +161,7 @@ format_type_extended(Oid type_oid, int32 typemod, bits16 flags)
else
elog(ERROR, "cache lookup failed for type %u", type_oid);
}
- typeform = (Form_pg_type) GETSTRUCT(tuple);
+ typeform = GETSTRUCT(pg_type, tuple);
type_oid = array_base_type;
is_array = true;
}
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index 9819e1a45c..8e70d97c9b 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -2997,7 +2997,7 @@ prepare_column_cache(ColumnIOData *column,
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typid);
- type = (Form_pg_type) GETSTRUCT(tup);
+ type = GETSTRUCT(pg_type, tup);
if (type->typtype == TYPTYPE_DOMAIN)
{
diff --git a/src/backend/utils/adt/like_support.c b/src/backend/utils/adt/like_support.c
index 65a57fc3c4..3884c19aef 100644
--- a/src/backend/utils/adt/like_support.c
+++ b/src/backend/utils/adt/like_support.c
@@ -608,7 +608,7 @@ patternsel_common(PlannerInfo *root,
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
nullfrac = stats->stanullfrac;
}
diff --git a/src/backend/utils/adt/multirangetypes_selfuncs.c b/src/backend/utils/adt/multirangetypes_selfuncs.c
index 919c8889d4..8d2a0977e5 100644
--- a/src/backend/utils/adt/multirangetypes_selfuncs.c
+++ b/src/backend/utils/adt/multirangetypes_selfuncs.c
@@ -306,7 +306,7 @@ calc_multirangesel(TypeCacheEntry *typcache, VariableStatData *vardata,
Form_pg_statistic stats;
AttStatsSlot sslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
null_frac = stats->stanullfrac;
/* Try to get fraction of empty multiranges */
diff --git a/src/backend/utils/adt/network_selfuncs.c b/src/backend/utils/adt/network_selfuncs.c
index 49196376a8..33b45e4d99 100644
--- a/src/backend/utils/adt/network_selfuncs.c
+++ b/src/backend/utils/adt/network_selfuncs.c
@@ -127,7 +127,7 @@ networksel(PG_FUNCTION_ARGS)
PG_RETURN_FLOAT8(DEFAULT_SEL(operator));
}
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
nullfrac = stats->stanullfrac;
/*
@@ -283,7 +283,7 @@ networkjoinsel_inner(Oid operator,
if (HeapTupleIsValid(vardata1->statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(vardata1->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata1->statsTuple);
nullfrac1 = stats->stanullfrac;
mcv1_exists = get_attstatsslot(&mcv1_slot, vardata1->statsTuple,
@@ -305,7 +305,7 @@ networkjoinsel_inner(Oid operator,
if (HeapTupleIsValid(vardata2->statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(vardata2->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata2->statsTuple);
nullfrac2 = stats->stanullfrac;
mcv2_exists = get_attstatsslot(&mcv2_slot, vardata2->statsTuple,
@@ -413,7 +413,7 @@ networkjoinsel_semi(Oid operator,
if (HeapTupleIsValid(vardata1->statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(vardata1->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata1->statsTuple);
nullfrac1 = stats->stanullfrac;
mcv1_exists = get_attstatsslot(&mcv1_slot, vardata1->statsTuple,
@@ -435,7 +435,7 @@ networkjoinsel_semi(Oid operator,
if (HeapTupleIsValid(vardata2->statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(vardata2->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata2->statsTuple);
nullfrac2 = stats->stanullfrac;
mcv2_exists = get_attstatsslot(&mcv2_slot, vardata2->statsTuple,
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index 607a4b7340..ec15a5a81a 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -1243,7 +1243,7 @@ lookup_collation_cache(Oid collation, bool set_flags)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collation);
- collform = (Form_pg_collation) GETSTRUCT(tp);
+ collform = GETSTRUCT(pg_collation, tp);
if (collform->collprovider == COLLPROVIDER_LIBC)
{
@@ -1495,7 +1495,7 @@ pg_newlocale_from_collation(Oid collid)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collid);
- collform = (Form_pg_collation) GETSTRUCT(tp);
+ collform = GETSTRUCT(pg_collation, tp);
/* We'll fill in the result struct locally before allocating memory */
memset(&result, 0, sizeof(result));
diff --git a/src/backend/utils/adt/rangetypes_selfuncs.c b/src/backend/utils/adt/rangetypes_selfuncs.c
index c2795f4593..70bdbbdf6c 100644
--- a/src/backend/utils/adt/rangetypes_selfuncs.c
+++ b/src/backend/utils/adt/rangetypes_selfuncs.c
@@ -244,7 +244,7 @@ calc_rangesel(TypeCacheEntry *typcache, VariableStatData *vardata,
Form_pg_statistic stats;
AttStatsSlot sslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
null_frac = stats->stanullfrac;
/* Try to get fraction of empty ranges */
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index 6d4c1c27a5..052374dd23 100644
--- a/src/backend/utils/adt/regproc.c
+++ b/src/backend/utils/adt/regproc.c
@@ -155,7 +155,7 @@ regprocout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(proctup))
{
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, proctup);
char *proname = NameStr(procform->proname);
/*
@@ -356,7 +356,7 @@ format_procedure_extended(Oid procedure_oid, bits16 flags)
if (HeapTupleIsValid(proctup))
{
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, proctup);
char *proname = NameStr(procform->proname);
int nargs = procform->pronargs;
int i;
@@ -436,7 +436,7 @@ format_procedure_parts(Oid procedure_oid, List **objnames, List **objargs,
return;
}
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
nargs = procform->pronargs;
*objnames = list_make2(get_namespace_name_or_temp(procform->pronamespace),
@@ -593,7 +593,7 @@ regoperout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(opertup))
{
- Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operform = GETSTRUCT(pg_operator, opertup);
char *oprname = NameStr(operform->oprname);
/*
@@ -787,7 +787,7 @@ format_operator_extended(Oid operator_oid, bits16 flags)
if (HeapTupleIsValid(opertup))
{
- Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operform = GETSTRUCT(pg_operator, opertup);
char *oprname = NameStr(operform->oprname);
char *nspname;
StringInfoData buf;
@@ -877,7 +877,7 @@ format_operator_parts(Oid operator_oid, List **objnames, List **objargs,
return;
}
- oprForm = (Form_pg_operator) GETSTRUCT(opertup);
+ oprForm = GETSTRUCT(pg_operator, opertup);
*objnames = list_make2(get_namespace_name_or_temp(oprForm->oprnamespace),
pstrdup(NameStr(oprForm->oprname)));
*objargs = NIL;
@@ -1023,7 +1023,7 @@ regclassout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(classtup))
{
- Form_pg_class classform = (Form_pg_class) GETSTRUCT(classtup);
+ Form_pg_class classform = GETSTRUCT(pg_class, classtup);
char *classname = NameStr(classform->relname);
/*
@@ -1174,7 +1174,7 @@ regcollationout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(collationtup))
{
- Form_pg_collation collationform = (Form_pg_collation) GETSTRUCT(collationtup);
+ Form_pg_collation collationform = GETSTRUCT(pg_collation, collationtup);
char *collationname = NameStr(collationform->collname);
/*
@@ -1326,7 +1326,7 @@ regtypeout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(typetup))
{
- Form_pg_type typeform = (Form_pg_type) GETSTRUCT(typetup);
+ Form_pg_type typeform = GETSTRUCT(pg_type, typetup);
/*
* In bootstrap mode, skip the fancy namespace stuff and just return
@@ -1439,7 +1439,7 @@ regconfigout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(cfgtup))
{
- Form_pg_ts_config cfgform = (Form_pg_ts_config) GETSTRUCT(cfgtup);
+ Form_pg_ts_config cfgform = GETSTRUCT(pg_ts_config, cfgtup);
char *cfgname = NameStr(cfgform->cfgname);
char *nspname;
@@ -1550,7 +1550,7 @@ regdictionaryout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(dicttup))
{
- Form_pg_ts_dict dictform = (Form_pg_ts_dict) GETSTRUCT(dicttup);
+ Form_pg_ts_dict dictform = GETSTRUCT(pg_ts_dict, dicttup);
char *dictname = NameStr(dictform->dictname);
char *nspname;
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index 51b3fdc9a0..33e9cfa567 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -1945,7 +1945,7 @@ ri_GenerateQualCollation(StringInfo buf, Oid collation)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collation);
- colltup = (Form_pg_collation) GETSTRUCT(tp);
+ colltup = GETSTRUCT(pg_collation, tp);
collname = NameStr(colltup->collname);
/*
@@ -2134,7 +2134,7 @@ ri_LoadConstraintInfo(Oid constraintOid)
tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constraintOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for constraint %u", constraintOid);
- conForm = (Form_pg_constraint) GETSTRUCT(tup);
+ conForm = GETSTRUCT(pg_constraint, tup);
if (conForm->contype != CONSTRAINT_FOREIGN) /* should not happen */
elog(ERROR, "constraint %u is not a foreign key constraint",
@@ -2197,7 +2197,7 @@ get_ri_constraint_root(Oid constrOid)
tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constrOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", constrOid);
- constrParentOid = ((Form_pg_constraint) GETSTRUCT(tuple))->conparentid;
+ constrParentOid = (GETSTRUCT(pg_constraint, tuple))->conparentid;
ReleaseSysCache(tuple);
if (!OidIsValid(constrParentOid))
break; /* we reached the root constraint */
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 26cf4fa9a0..f1b31fc4e7 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -898,7 +898,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
return NULL;
}
- trigrec = (Form_pg_trigger) GETSTRUCT(ht_trig);
+ trigrec = GETSTRUCT(pg_trigger, ht_trig);
/*
* Start the trigger definition. Note that the trigger's name should never
@@ -1253,7 +1253,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
return NULL;
elog(ERROR, "cache lookup failed for index %u", indexrelid);
}
- idxrec = (Form_pg_index) GETSTRUCT(ht_idx);
+ idxrec = GETSTRUCT(pg_index, ht_idx);
indrelid = idxrec->indrelid;
Assert(indexrelid == idxrec->indexrelid);
@@ -1280,7 +1280,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(indexrelid));
if (!HeapTupleIsValid(ht_idxrel))
elog(ERROR, "cache lookup failed for relation %u", indexrelid);
- idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);
+ idxrelrec = GETSTRUCT(pg_class, ht_idxrel);
/*
* Fetch the pg_am tuple of the index' access method
@@ -1289,7 +1289,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
if (!HeapTupleIsValid(ht_am))
elog(ERROR, "cache lookup failed for access method %u",
idxrelrec->relam);
- amrec = (Form_pg_am) GETSTRUCT(ht_am);
+ amrec = GETSTRUCT(pg_am, ht_am);
/* Fetch the index AM's API struct */
amroutine = GetIndexAmRoutine(amrec->amhandler);
@@ -1637,7 +1637,7 @@ pg_get_statisticsobj_worker(Oid statextid, bool columns_only, bool missing_ok)
/* has the statistics expressions? */
has_exprs = !heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL);
- statextrec = (Form_pg_statistic_ext) GETSTRUCT(statexttup);
+ statextrec = GETSTRUCT(pg_statistic_ext, statexttup);
/*
* Get the statistics expressions, if any. (NOTE: we do not use the
@@ -1821,7 +1821,7 @@ pg_get_statisticsobjdef_expressions(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
- statextrec = (Form_pg_statistic_ext) GETSTRUCT(statexttup);
+ statextrec = GETSTRUCT(pg_statistic_ext, statexttup);
/*
* Get the statistics expressions, and deparse them into text values.
@@ -1919,7 +1919,7 @@ pg_get_partkeydef_worker(Oid relid, int prettyFlags,
elog(ERROR, "cache lookup failed for partition key of %u", relid);
}
- form = (Form_pg_partitioned_table) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_partitioned_table, tuple);
Assert(form->partrelid == relid);
@@ -2197,7 +2197,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
elog(ERROR, "could not find tuple for constraint %u", constraintId);
}
- conForm = (Form_pg_constraint) GETSTRUCT(tup);
+ conForm = GETSTRUCT(pg_constraint, tup);
initStringInfo(&buf);
@@ -2371,7 +2371,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
if (!HeapTupleIsValid(indtup))
elog(ERROR, "cache lookup failed for index %u", indexId);
if (conForm->contype == CONSTRAINT_UNIQUE &&
- ((Form_pg_index) GETSTRUCT(indtup))->indnullsnotdistinct)
+ (GETSTRUCT(pg_index, indtup))->indnullsnotdistinct)
appendStringInfoString(&buf, "NULLS NOT DISTINCT ");
appendStringInfoString(&buf, "(");
@@ -2769,7 +2769,7 @@ pg_get_userbyid(PG_FUNCTION_ARGS)
roletup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(roletup))
{
- role_rec = (Form_pg_authid) GETSTRUCT(roletup);
+ role_rec = GETSTRUCT(pg_authid, roletup);
*result = role_rec->rolname;
ReleaseSysCache(roletup);
}
@@ -2837,7 +2837,7 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend deprec = GETSTRUCT(pg_depend, tup);
/*
* Look for an auto dependency (serial column) or internal dependency
@@ -2905,7 +2905,7 @@ pg_get_functiondef(PG_FUNCTION_ARGS)
if (!HeapTupleIsValid(proctup))
PG_RETURN_NULL();
- proc = (Form_pg_proc) GETSTRUCT(proctup);
+ proc = GETSTRUCT(pg_proc, proctup);
name = NameStr(proc->proname);
if (proc->prokind == PROKIND_AGGREGATE)
@@ -3197,7 +3197,7 @@ pg_get_function_result(PG_FUNCTION_ARGS)
if (!HeapTupleIsValid(proctup))
PG_RETURN_NULL();
- if (((Form_pg_proc) GETSTRUCT(proctup))->prokind == PROKIND_PROCEDURE)
+ if ((GETSTRUCT(pg_proc, proctup))->prokind == PROKIND_PROCEDURE)
{
ReleaseSysCache(proctup);
PG_RETURN_NULL();
@@ -3219,7 +3219,7 @@ pg_get_function_result(PG_FUNCTION_ARGS)
static void
print_function_rettype(StringInfo buf, HeapTuple proctup)
{
- Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc proc = GETSTRUCT(pg_proc, proctup);
int ntabargs = 0;
StringInfoData rbuf;
@@ -3258,7 +3258,7 @@ static int
print_function_arguments(StringInfo buf, HeapTuple proctup,
bool print_table_args, bool print_defaults)
{
- Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc proc = GETSTRUCT(pg_proc, proctup);
int numargs;
Oid *argtypes;
char **argnames;
@@ -3306,7 +3306,7 @@ print_function_arguments(StringInfo buf, HeapTuple proctup,
if (!HeapTupleIsValid(aggtup))
elog(ERROR, "cache lookup failed for aggregate %u",
proc->oid);
- agg = (Form_pg_aggregate) GETSTRUCT(aggtup);
+ agg = GETSTRUCT(pg_aggregate, aggtup);
if (AGGKIND_IS_ORDERED_SET(agg->aggkind))
insertorderbyat = agg->aggnumdirectargs;
ReleaseSysCache(aggtup);
@@ -3491,7 +3491,7 @@ pg_get_function_arg_default(PG_FUNCTION_ARGS)
argdefaults = castNode(List, stringToNode(str));
pfree(str);
- proc = (Form_pg_proc) GETSTRUCT(proctup);
+ proc = GETSTRUCT(pg_proc, proctup);
/*
* Calculate index into proargdefaults: proargdefaults corresponds to the
@@ -3524,7 +3524,7 @@ print_function_sqlbody(StringInfo buf, HeapTuple proctup)
bool isnull;
Node *n;
- dpns.funcname = pstrdup(NameStr(((Form_pg_proc) GETSTRUCT(proctup))->proname));
+ dpns.funcname = pstrdup(NameStr((GETSTRUCT(pg_proc, proctup))->proname));
numargs = get_func_arg_info(proctup,
&argtypes, &argnames, &argmodes);
dpns.numargs = numargs;
@@ -12029,7 +12029,7 @@ get_opclass_name(Oid opclass, Oid actual_datatype,
ht_opc = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(ht_opc))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- opcrec = (Form_pg_opclass) GETSTRUCT(ht_opc);
+ opcrec = GETSTRUCT(pg_opclass, ht_opc);
if (!OidIsValid(actual_datatype) ||
GetDefaultOpClass(actual_datatype, opcrec->opcmethod) != opclass)
@@ -12323,7 +12323,7 @@ generate_relation_name(Oid relid, List *namespaces)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltup = (Form_pg_class) GETSTRUCT(tp);
+ reltup = GETSTRUCT(pg_class, tp);
relname = NameStr(reltup->relname);
/* Check for conflicting CTE name */
@@ -12381,7 +12381,7 @@ generate_qualified_relation_name(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltup = (Form_pg_class) GETSTRUCT(tp);
+ reltup = GETSTRUCT(pg_class, tp);
relname = NameStr(reltup->relname);
nspname = get_namespace_name_or_temp(reltup->relnamespace);
@@ -12434,7 +12434,7 @@ generate_function_name(Oid funcid, int nargs, List *argnames, Oid *argtypes,
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
proname = NameStr(procform->proname);
/*
@@ -12531,7 +12531,7 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2)
opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operid));
if (!HeapTupleIsValid(opertup))
elog(ERROR, "cache lookup failed for operator %u", operid);
- operform = (Form_pg_operator) GETSTRUCT(opertup);
+ operform = GETSTRUCT(pg_operator, opertup);
oprname = NameStr(operform->oprname);
/*
@@ -12607,7 +12607,7 @@ generate_operator_clause(StringInfo buf,
opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(opoid));
if (!HeapTupleIsValid(opertup))
elog(ERROR, "cache lookup failed for operator %u", opoid);
- operform = (Form_pg_operator) GETSTRUCT(opertup);
+ operform = GETSTRUCT(pg_operator, opertup);
Assert(operform->oprkind == 'b');
oprname = NameStr(operform->oprname);
@@ -12644,7 +12644,7 @@ add_cast_to(StringInfo buf, Oid typid)
typetup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(typetup))
elog(ERROR, "cache lookup failed for type %u", typid);
- typform = (Form_pg_type) GETSTRUCT(typetup);
+ typform = GETSTRUCT(pg_type, typetup);
typname = NameStr(typform->typname);
nspname = get_namespace_name_or_temp(typform->typnamespace);
@@ -12676,7 +12676,7 @@ generate_qualified_type_name(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", typid);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
typname = NameStr(typtup->typname);
nspname = get_namespace_name_or_temp(typtup->typnamespace);
@@ -12709,7 +12709,7 @@ generate_collation_name(Oid collid)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collid);
- colltup = (Form_pg_collation) GETSTRUCT(tp);
+ colltup = GETSTRUCT(pg_collation, tp);
collname = NameStr(colltup->collname);
if (!CollationIsVisible(collid))
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index fa1f589fad..81eb913317 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -313,7 +313,7 @@ var_eq_const(VariableStatData *vardata, Oid operator, Oid collation,
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
nullfrac = stats->stanullfrac;
}
@@ -475,7 +475,7 @@ var_eq_non_const(VariableStatData *vardata, Oid operator, Oid collation,
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
nullfrac = stats->stanullfrac;
}
@@ -665,7 +665,7 @@ scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, bool iseq,
/* no stats available, so default result */
return DEFAULT_INEQ_SEL;
}
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
fmgr_info(get_opcode(operator), &opproc);
@@ -990,7 +990,7 @@ generic_restriction_selectivity(PlannerInfo *root, Oid oproid, Oid collation,
/* Don't forget to account for nulls. */
if (HeapTupleIsValid(vardata.statsTuple))
- nullfrac = ((Form_pg_statistic) GETSTRUCT(vardata.statsTuple))->stanullfrac;
+ nullfrac = (GETSTRUCT(pg_statistic, vardata.statsTuple))->stanullfrac;
else
nullfrac = 0.0;
@@ -1548,7 +1548,7 @@ booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg,
double freq_null;
AttStatsSlot sslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
freq_null = stats->stanullfrac;
if (get_attstatsslot(&sslot, vardata.statsTuple,
@@ -1705,7 +1705,7 @@ nulltestsel(PlannerInfo *root, NullTestType nulltesttype, Node *arg,
Form_pg_statistic stats;
double freq_null;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
freq_null = stats->stanullfrac;
switch (nulltesttype)
@@ -2277,7 +2277,7 @@ eqjoinsel(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(vardata1.statsTuple))
{
/* note we allow use of nullfrac regardless of security check */
- stats1 = (Form_pg_statistic) GETSTRUCT(vardata1.statsTuple);
+ stats1 = GETSTRUCT(pg_statistic, vardata1.statsTuple);
if (statistic_proc_security_check(&vardata1, opfuncoid))
have_mcvs1 = get_attstatsslot(&sslot1, vardata1.statsTuple,
STATISTIC_KIND_MCV, InvalidOid,
@@ -2287,7 +2287,7 @@ eqjoinsel(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(vardata2.statsTuple))
{
/* note we allow use of nullfrac regardless of security check */
- stats2 = (Form_pg_statistic) GETSTRUCT(vardata2.statsTuple);
+ stats2 = GETSTRUCT(pg_statistic, vardata2.statsTuple);
if (statistic_proc_security_check(&vardata2, opfuncoid))
have_mcvs2 = get_attstatsslot(&sslot2, vardata2.statsTuple,
STATISTIC_KIND_MCV, InvalidOid,
@@ -2804,7 +2804,7 @@ neqjoinsel(PG_FUNCTION_ARGS)
get_join_variables(root, args, sjinfo, &leftvar, &rightvar, &reversed);
statsTuple = reversed ? rightvar.statsTuple : leftvar.statsTuple;
if (HeapTupleIsValid(statsTuple))
- nullfrac = ((Form_pg_statistic) GETSTRUCT(statsTuple))->stanullfrac;
+ nullfrac = (GETSTRUCT(pg_statistic, statsTuple))->stanullfrac;
else
nullfrac = 0.0;
ReleaseVariableStats(leftvar);
@@ -3162,7 +3162,7 @@ mergejoinscansel(PlannerInfo *root, Node *clause,
if (HeapTupleIsValid(leftvar.statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(leftvar.statsTuple);
+ stats = GETSTRUCT(pg_statistic, leftvar.statsTuple);
*leftstart += stats->stanullfrac;
CLAMP_PROBABILITY(*leftstart);
*leftend += stats->stanullfrac;
@@ -3170,7 +3170,7 @@ mergejoinscansel(PlannerInfo *root, Node *clause,
}
if (HeapTupleIsValid(rightvar.statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(rightvar.statsTuple);
+ stats = GETSTRUCT(pg_statistic, rightvar.statsTuple);
*rightstart += stats->stanullfrac;
CLAMP_PROBABILITY(*rightstart);
*rightend += stats->stanullfrac;
@@ -3830,7 +3830,7 @@ estimate_hash_bucket_stats(PlannerInfo *root, Node *hashkey, double nbuckets,
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
stanullfrac = stats->stanullfrac;
}
else
@@ -5672,7 +5672,7 @@ get_variable_numdistinct(VariableStatData *vardata, bool *isdefault)
/* Use the pg_statistic entry */
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
stadistinct = stats->stadistinct;
stanullfrac = stats->stanullfrac;
}
@@ -5889,7 +5889,7 @@ get_variable_range(PlannerInfo *root, VariableStatData *vardata,
for (i = 0; i < sslot.nnumbers; i++)
sumcommon += sslot.numbers[i];
- nullfrac = ((Form_pg_statistic) GETSTRUCT(vardata->statsTuple))->stanullfrac;
+ nullfrac = (GETSTRUCT(pg_statistic, vardata->statsTuple))->stanullfrac;
if (sumcommon + nullfrac > 0.99999)
use_mcvs = true;
}
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index 60a85c4697..0ce9012784 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -3183,7 +3183,7 @@ map_sql_table_to_xmlschema(TupleDesc tupdesc, Oid relid, bool nulls,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltuple = (Form_pg_class) GETSTRUCT(tuple);
+ reltuple = GETSTRUCT(pg_class, tuple);
xmltn = map_sql_identifier_to_xml_name(NameStr(reltuple->relname),
true, false);
@@ -3483,7 +3483,7 @@ map_sql_type_to_xml_name(Oid typeoid, int typmod)
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", typeoid);
- typtuple = (Form_pg_type) GETSTRUCT(tuple);
+ typtuple = GETSTRUCT(pg_type, tuple);
appendStringInfoString(&result,
map_multipart_sql_identifier_to_xml_name((typtuple->typtype == TYPTYPE_DOMAIN) ? "Domain" : "UDT",
diff --git a/src/backend/utils/cache/evtcache.c b/src/backend/utils/cache/evtcache.c
index f7f7165f7f..a6893f9947 100644
--- a/src/backend/utils/cache/evtcache.c
+++ b/src/backend/utils/cache/evtcache.c
@@ -153,7 +153,7 @@ BuildEventTriggerCache(void)
break;
/* Skip trigger if disabled. */
- form = (Form_pg_event_trigger) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_event_trigger, tup);
if (form->evtenabled == TRIGGER_DISABLED)
continue;
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index eb5782f82a..8e100862bf 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -1259,7 +1259,7 @@ CacheInvalidateHeapTuple(Relation relation,
*/
if (tupleRelId == RelationRelationId)
{
- Form_pg_class classtup = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classtup = GETSTRUCT(pg_class, tuple);
relationId = classtup->oid;
if (classtup->relisshared)
@@ -1269,7 +1269,7 @@ CacheInvalidateHeapTuple(Relation relation,
}
else if (tupleRelId == AttributeRelationId)
{
- Form_pg_attribute atttup = (Form_pg_attribute) GETSTRUCT(tuple);
+ Form_pg_attribute atttup = GETSTRUCT(pg_attribute, tuple);
relationId = atttup->attrelid;
@@ -1287,7 +1287,7 @@ CacheInvalidateHeapTuple(Relation relation,
}
else if (tupleRelId == IndexRelationId)
{
- Form_pg_index indextup = (Form_pg_index) GETSTRUCT(tuple);
+ Form_pg_index indextup = GETSTRUCT(pg_index, tuple);
/*
* When a pg_index row is updated, we should send out a relcache inval
@@ -1300,7 +1300,7 @@ CacheInvalidateHeapTuple(Relation relation,
}
else if (tupleRelId == ConstraintRelationId)
{
- Form_pg_constraint constrtup = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint constrtup = GETSTRUCT(pg_constraint, tuple);
/*
* Foreign keys are part of relcache entries, too, so send out an
@@ -1398,7 +1398,7 @@ CacheInvalidateRelcacheAll(void)
void
CacheInvalidateRelcacheByTuple(HeapTuple classTuple)
{
- Form_pg_class classtup = (Form_pg_class) GETSTRUCT(classTuple);
+ Form_pg_class classtup = GETSTRUCT(pg_class, classTuple);
Oid databaseId;
Oid relationId;
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 1b7e11b93e..e189e5e564 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -90,7 +90,7 @@ get_op_opfamily_strategy(Oid opno, Oid opfamily)
ObjectIdGetDatum(opfamily));
if (!HeapTupleIsValid(tp))
return 0;
- amop_tup = (Form_pg_amop) GETSTRUCT(tp);
+ amop_tup = GETSTRUCT(pg_amop, tp);
result = amop_tup->amopstrategy;
ReleaseSysCache(tp);
return result;
@@ -115,7 +115,7 @@ get_op_opfamily_sortfamily(Oid opno, Oid opfamily)
ObjectIdGetDatum(opfamily));
if (!HeapTupleIsValid(tp))
return InvalidOid;
- amop_tup = (Form_pg_amop) GETSTRUCT(tp);
+ amop_tup = GETSTRUCT(pg_amop, tp);
result = amop_tup->amopsortfamily;
ReleaseSysCache(tp);
return result;
@@ -146,7 +146,7 @@ get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op,
if (!HeapTupleIsValid(tp))
elog(ERROR, "operator %u is not a member of opfamily %u",
opno, opfamily);
- amop_tup = (Form_pg_amop) GETSTRUCT(tp);
+ amop_tup = GETSTRUCT(pg_amop, tp);
*strategy = amop_tup->amopstrategy;
*lefttype = amop_tup->amoplefttype;
*righttype = amop_tup->amoprighttype;
@@ -175,7 +175,7 @@ get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
Int16GetDatum(strategy));
if (!HeapTupleIsValid(tp))
return InvalidOid;
- amop_tup = (Form_pg_amop) GETSTRUCT(tp);
+ amop_tup = GETSTRUCT(pg_amop, tp);
result = amop_tup->amopopr;
ReleaseSysCache(tp);
return result;
@@ -223,7 +223,7 @@ get_ordering_op_properties(Oid opno,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
/* must be btree */
if (aform->amopmethod != BTREE_AM_OID)
@@ -315,7 +315,7 @@ get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
/* must be btree */
if (aform->amopmethod != BTREE_AM_OID)
@@ -376,7 +376,7 @@ get_mergejoin_opfamilies(Oid opno)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
/* must be btree equality */
if (aform->amopmethod == BTREE_AM_OID &&
@@ -428,7 +428,7 @@ get_compatible_hash_operators(Oid opno,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
if (aform->amopmethod == HASH_AM_OID &&
aform->amopstrategy == HTEqualStrategyNumber)
@@ -528,7 +528,7 @@ get_op_hash_functions(Oid opno,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
if (aform->amopmethod == HASH_AM_OID &&
aform->amopstrategy == HTEqualStrategyNumber)
@@ -611,7 +611,7 @@ get_op_btree_interpretation(Oid opno)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
- Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple);
StrategyNumber op_strategy;
/* must be btree */
@@ -649,7 +649,7 @@ get_op_btree_interpretation(Oid opno)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
- Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple);
StrategyNumber op_strategy;
/* must be btree */
@@ -712,7 +712,7 @@ equality_ops_are_compatible(Oid opno1, Oid opno2)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
- Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple);
/* must be btree or hash */
if (op_form->amopmethod == BTREE_AM_OID ||
@@ -763,7 +763,7 @@ comparison_ops_are_compatible(Oid opno1, Oid opno2)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
- Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple);
if (op_form->amopmethod == BTREE_AM_OID)
{
@@ -804,7 +804,7 @@ get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
Int16GetDatum(procnum));
if (!HeapTupleIsValid(tp))
return InvalidOid;
- amproc_tup = (Form_pg_amproc) GETSTRUCT(tp);
+ amproc_tup = GETSTRUCT(pg_amproc, tp);
result = amproc_tup->amproc;
ReleaseSysCache(tp);
return result;
@@ -830,7 +830,7 @@ get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
ObjectIdGetDatum(relid), Int16GetDatum(attnum));
if (HeapTupleIsValid(tp))
{
- Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ Form_pg_attribute att_tup = GETSTRUCT(pg_attribute, tp);
char *result;
result = pstrdup(NameStr(att_tup->attname));
@@ -860,7 +860,7 @@ get_attnum(Oid relid, const char *attname)
tp = SearchSysCacheAttName(relid, attname);
if (HeapTupleIsValid(tp))
{
- Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ Form_pg_attribute att_tup = GETSTRUCT(pg_attribute, tp);
AttrNumber result;
result = att_tup->attnum;
@@ -892,7 +892,7 @@ get_attstattarget(Oid relid, AttrNumber attnum)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ att_tup = GETSTRUCT(pg_attribute, tp);
result = att_tup->attstattarget;
ReleaseSysCache(tp);
return result;
@@ -922,7 +922,7 @@ get_attgenerated(Oid relid, AttrNumber attnum)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ att_tup = GETSTRUCT(pg_attribute, tp);
result = att_tup->attgenerated;
ReleaseSysCache(tp);
return result;
@@ -944,7 +944,7 @@ get_atttype(Oid relid, AttrNumber attnum)
Int16GetDatum(attnum));
if (HeapTupleIsValid(tp))
{
- Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ Form_pg_attribute att_tup = GETSTRUCT(pg_attribute, tp);
Oid result;
result = att_tup->atttypid;
@@ -977,7 +977,7 @@ get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ att_tup = GETSTRUCT(pg_attribute, tp);
*typid = att_tup->atttypid;
*typmod = att_tup->atttypmod;
@@ -1064,7 +1064,7 @@ get_collation_name(Oid colloid)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
if (HeapTupleIsValid(tp))
{
- Form_pg_collation colltup = (Form_pg_collation) GETSTRUCT(tp);
+ Form_pg_collation colltup = GETSTRUCT(pg_collation, tp);
char *result;
result = pstrdup(NameStr(colltup->collname));
@@ -1085,7 +1085,7 @@ get_collation_isdeterministic(Oid colloid)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", colloid);
- colltup = (Form_pg_collation) GETSTRUCT(tp);
+ colltup = GETSTRUCT(pg_collation, tp);
result = colltup->collisdeterministic;
ReleaseSysCache(tp);
return result;
@@ -1110,7 +1110,7 @@ get_constraint_name(Oid conoid)
tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
if (HeapTupleIsValid(tp))
{
- Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp);
+ Form_pg_constraint contup = GETSTRUCT(pg_constraint, tp);
char *result;
result = pstrdup(NameStr(contup->conname));
@@ -1142,7 +1142,7 @@ get_constraint_index(Oid conoid)
tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
if (HeapTupleIsValid(tp))
{
- Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp);
+ Form_pg_constraint contup = GETSTRUCT(pg_constraint, tp);
Oid result;
if (contup->contype == CONSTRAINT_UNIQUE ||
@@ -1168,7 +1168,7 @@ get_language_name(Oid langoid, bool missing_ok)
tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
if (HeapTupleIsValid(tp))
{
- Form_pg_language lantup = (Form_pg_language) GETSTRUCT(tp);
+ Form_pg_language lantup = GETSTRUCT(pg_language, tp);
char *result;
result = pstrdup(NameStr(lantup->lanname));
@@ -1199,7 +1199,7 @@ get_opclass_family(Oid opclass)
tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
+ cla_tup = GETSTRUCT(pg_opclass, tp);
result = cla_tup->opcfamily;
ReleaseSysCache(tp);
@@ -1221,7 +1221,7 @@ get_opclass_input_type(Oid opclass)
tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
+ cla_tup = GETSTRUCT(pg_opclass, tp);
result = cla_tup->opcintype;
ReleaseSysCache(tp);
@@ -1244,7 +1244,7 @@ get_opclass_opfamily_and_input_type(Oid opclass, Oid *opfamily, Oid *opcintype)
if (!HeapTupleIsValid(tp))
return false;
- cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
+ cla_tup = GETSTRUCT(pg_opclass, tp);
*opfamily = cla_tup->opcfamily;
*opcintype = cla_tup->opcintype;
@@ -1270,7 +1270,7 @@ get_opcode(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
RegProcedure result;
result = optup->oprcode;
@@ -1295,7 +1295,7 @@ get_opname(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
char *result;
result = pstrdup(NameStr(optup->oprname));
@@ -1318,7 +1318,7 @@ get_op_rettype(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
Oid result;
result = optup->oprresult;
@@ -1344,7 +1344,7 @@ op_input_types(Oid opno, Oid *lefttype, Oid *righttype)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for operator %u", opno);
- optup = (Form_pg_operator) GETSTRUCT(tp);
+ optup = GETSTRUCT(pg_operator, tp);
*lefttype = optup->oprleft;
*righttype = optup->oprright;
ReleaseSysCache(tp);
@@ -1394,7 +1394,7 @@ op_mergejoinable(Oid opno, Oid inputtype)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
result = optup->oprcanmerge;
ReleaseSysCache(tp);
@@ -1440,7 +1440,7 @@ op_hashjoinable(Oid opno, Oid inputtype)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
result = optup->oprcanhash;
ReleaseSysCache(tp);
@@ -1494,7 +1494,7 @@ get_commutator(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
Oid result;
result = optup->oprcom;
@@ -1518,7 +1518,7 @@ get_negator(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
Oid result;
result = optup->oprnegate;
@@ -1542,7 +1542,7 @@ get_oprrest(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
RegProcedure result;
result = optup->oprrest;
@@ -1566,7 +1566,7 @@ get_oprjoin(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
RegProcedure result;
result = optup->oprjoin;
@@ -1593,7 +1593,7 @@ get_func_name(Oid funcid)
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (HeapTupleIsValid(tp))
{
- Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
+ Form_pg_proc functup = GETSTRUCT(pg_proc, tp);
char *result;
result = pstrdup(NameStr(functup->proname));
@@ -1617,7 +1617,7 @@ get_func_namespace(Oid funcid)
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (HeapTupleIsValid(tp))
{
- Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
+ Form_pg_proc functup = GETSTRUCT(pg_proc, tp);
Oid result;
result = functup->pronamespace;
@@ -1642,7 +1642,7 @@ get_func_rettype(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->prorettype;
+ result = (GETSTRUCT(pg_proc, tp))->prorettype;
ReleaseSysCache(tp);
return result;
}
@@ -1661,7 +1661,7 @@ get_func_nargs(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
+ result = (GETSTRUCT(pg_proc, tp))->pronargs;
ReleaseSysCache(tp);
return result;
}
@@ -1684,7 +1684,7 @@ get_func_signature(Oid funcid, Oid **argtypes, int *nargs)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procstruct = (Form_pg_proc) GETSTRUCT(tp);
+ procstruct = GETSTRUCT(pg_proc, tp);
result = procstruct->prorettype;
*nargs = (int) procstruct->pronargs;
@@ -1710,7 +1710,7 @@ get_func_variadictype(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->provariadic;
+ result = (GETSTRUCT(pg_proc, tp))->provariadic;
ReleaseSysCache(tp);
return result;
}
@@ -1729,7 +1729,7 @@ get_func_retset(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
+ result = (GETSTRUCT(pg_proc, tp))->proretset;
ReleaseSysCache(tp);
return result;
}
@@ -1748,7 +1748,7 @@ func_strict(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
+ result = (GETSTRUCT(pg_proc, tp))->proisstrict;
ReleaseSysCache(tp);
return result;
}
@@ -1767,7 +1767,7 @@ func_volatile(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->provolatile;
+ result = (GETSTRUCT(pg_proc, tp))->provolatile;
ReleaseSysCache(tp);
return result;
}
@@ -1786,7 +1786,7 @@ func_parallel(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
+ result = (GETSTRUCT(pg_proc, tp))->proparallel;
ReleaseSysCache(tp);
return result;
}
@@ -1805,7 +1805,7 @@ get_func_prokind(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->prokind;
+ result = (GETSTRUCT(pg_proc, tp))->prokind;
ReleaseSysCache(tp);
return result;
}
@@ -1824,7 +1824,7 @@ get_func_leakproof(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
+ result = (GETSTRUCT(pg_proc, tp))->proleakproof;
ReleaseSysCache(tp);
return result;
}
@@ -1843,7 +1843,7 @@ get_func_support(Oid funcid)
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (HeapTupleIsValid(tp))
{
- Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
+ Form_pg_proc functup = GETSTRUCT(pg_proc, tp);
RegProcedure result;
result = functup->prosupport;
@@ -1884,7 +1884,7 @@ get_relnatts(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
int result;
result = reltup->relnatts;
@@ -1913,7 +1913,7 @@ get_rel_name(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
char *result;
result = pstrdup(NameStr(reltup->relname));
@@ -1937,7 +1937,7 @@ get_rel_namespace(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
Oid result;
result = reltup->relnamespace;
@@ -1964,7 +1964,7 @@ get_rel_type_id(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
Oid result;
result = reltup->reltype;
@@ -1988,7 +1988,7 @@ get_rel_relkind(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
char result;
result = reltup->relkind;
@@ -2012,7 +2012,7 @@ get_rel_relispartition(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
bool result;
result = reltup->relispartition;
@@ -2039,7 +2039,7 @@ get_rel_tablespace(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
Oid result;
result = reltup->reltablespace;
@@ -2065,7 +2065,7 @@ get_rel_persistence(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltup = (Form_pg_class) GETSTRUCT(tp);
+ reltup = GETSTRUCT(pg_class, tp);
result = reltup->relpersistence;
ReleaseSysCache(tp);
@@ -2088,7 +2088,7 @@ get_transform_fromsql(Oid typid, Oid langid, List *trftypes)
{
Oid funcid;
- funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
+ funcid = (GETSTRUCT(pg_transform, tup))->trffromsql;
ReleaseSysCache(tup);
return funcid;
}
@@ -2109,7 +2109,7 @@ get_transform_tosql(Oid typid, Oid langid, List *trftypes)
{
Oid funcid;
- funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
+ funcid = (GETSTRUCT(pg_transform, tup))->trftosql;
ReleaseSysCache(tup);
return funcid;
}
@@ -2134,7 +2134,7 @@ get_typisdefined(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
bool result;
result = typtup->typisdefined;
@@ -2158,7 +2158,7 @@ get_typlen(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
int16 result;
result = typtup->typlen;
@@ -2183,7 +2183,7 @@ get_typbyval(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
bool result;
result = typtup->typbyval;
@@ -2213,7 +2213,7 @@ get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", typid);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
*typlen = typtup->typlen;
*typbyval = typtup->typbyval;
ReleaseSysCache(tp);
@@ -2234,7 +2234,7 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", typid);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
*typlen = typtup->typlen;
*typbyval = typtup->typbyval;
*typalign = typtup->typalign;
@@ -2259,7 +2259,7 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
Oid
getTypeIOParam(HeapTuple typeTuple)
{
- Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
+ Form_pg_type typeStruct = GETSTRUCT(pg_type, typeTuple);
/*
* Array types get their typelem as parameter; everybody else gets their
@@ -2326,7 +2326,7 @@ get_type_io_data(Oid typid,
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", typid);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
+ typeStruct = GETSTRUCT(pg_type, typeTuple);
*typlen = typeStruct->typlen;
*typbyval = typeStruct->typbyval;
@@ -2360,7 +2360,7 @@ get_typalign(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
char result;
result = typtup->typalign;
@@ -2380,7 +2380,7 @@ get_typstorage(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
char result;
result = typtup->typstorage;
@@ -2413,7 +2413,7 @@ get_typdefault(Oid typid)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", typid);
- type = (Form_pg_type) GETSTRUCT(typeTuple);
+ type = GETSTRUCT(pg_type, typeTuple);
/*
* typdefault and typdefaultbin are potentially null, so don't try to
@@ -2505,7 +2505,7 @@ getBaseTypeAndTypmod(Oid typid, int32 *typmod)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
if (typTup->typtype != TYPTYPE_DOMAIN)
{
/* Not a domain, so done */
@@ -2590,7 +2590,7 @@ get_typtype(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
char result;
result = typtup->typtype;
@@ -2672,7 +2672,7 @@ get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", typid);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
*typcategory = typtup->typcategory;
*typispreferred = typtup->typispreferred;
ReleaseSysCache(tp);
@@ -2692,7 +2692,7 @@ get_typ_typrelid(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
result = typtup->typrelid;
@@ -2720,7 +2720,7 @@ get_element_type(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
if (IsTrueArrayType(typtup))
@@ -2749,7 +2749,7 @@ get_array_type(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
+ result = (GETSTRUCT(pg_type, tp))->typarray;
ReleaseSysCache(tp);
}
return result;
@@ -2799,7 +2799,7 @@ get_base_element_type(Oid typid)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tup))
break;
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
if (typTup->typtype != TYPTYPE_DOMAIN)
{
/* Not a domain, so stop descending */
@@ -2836,7 +2836,7 @@ getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type);
- pt = (Form_pg_type) GETSTRUCT(typeTuple);
+ pt = GETSTRUCT(pg_type, typeTuple);
if (!pt->typisdefined)
ereport(ERROR,
@@ -2869,7 +2869,7 @@ getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type);
- pt = (Form_pg_type) GETSTRUCT(typeTuple);
+ pt = GETSTRUCT(pg_type, typeTuple);
if (!pt->typisdefined)
ereport(ERROR,
@@ -2902,7 +2902,7 @@ getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type);
- pt = (Form_pg_type) GETSTRUCT(typeTuple);
+ pt = GETSTRUCT(pg_type, typeTuple);
if (!pt->typisdefined)
ereport(ERROR,
@@ -2935,7 +2935,7 @@ getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type);
- pt = (Form_pg_type) GETSTRUCT(typeTuple);
+ pt = GETSTRUCT(pg_type, typeTuple);
if (!pt->typisdefined)
ereport(ERROR,
@@ -2967,7 +2967,7 @@ get_typmodin(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
result = typtup->typmodin;
@@ -2992,7 +2992,7 @@ get_typmodout(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
result = typtup->typmodout;
@@ -3017,7 +3017,7 @@ get_typcollation(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
result = typtup->typcollation;
@@ -3058,7 +3058,7 @@ get_typsubscript(Oid typid, Oid *typelemp)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typform = GETSTRUCT(pg_type, tp);
RegProcedure handler = typform->typsubscript;
if (typelemp)
@@ -3129,7 +3129,7 @@ get_attavgwidth(Oid relid, AttrNumber attnum)
BoolGetDatum(false));
if (HeapTupleIsValid(tp))
{
- stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
+ stawidth = (GETSTRUCT(pg_statistic, tp))->stawidth;
ReleaseSysCache(tp);
if (stawidth > 0)
return stawidth;
@@ -3187,7 +3187,7 @@ bool
get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple,
int reqkind, Oid reqop, int flags)
{
- Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
+ Form_pg_statistic stats = GETSTRUCT(pg_statistic, statstuple);
int i;
Datum val;
bool isnull;
@@ -3236,7 +3236,7 @@ get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple,
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
- typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
+ typeForm = GETSTRUCT(pg_type, typeTuple);
/* Deconstruct array into Datum elements; NULLs not expected */
deconstruct_array(statarray,
@@ -3330,7 +3330,7 @@ get_namespace_name(Oid nspid)
tp = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(nspid));
if (HeapTupleIsValid(tp))
{
- Form_pg_namespace nsptup = (Form_pg_namespace) GETSTRUCT(tp);
+ Form_pg_namespace nsptup = GETSTRUCT(pg_namespace, tp);
char *result;
result = pstrdup(NameStr(nsptup->nspname));
@@ -3371,7 +3371,7 @@ get_range_subtype(Oid rangeOid)
tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
if (HeapTupleIsValid(tp))
{
- Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
+ Form_pg_range rngtup = GETSTRUCT(pg_range, tp);
Oid result;
result = rngtup->rngsubtype;
@@ -3397,7 +3397,7 @@ get_range_collation(Oid rangeOid)
tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
if (HeapTupleIsValid(tp))
{
- Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
+ Form_pg_range rngtup = GETSTRUCT(pg_range, tp);
Oid result;
result = rngtup->rngcollation;
@@ -3422,7 +3422,7 @@ get_range_multirange(Oid rangeOid)
tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
if (HeapTupleIsValid(tp))
{
- Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
+ Form_pg_range rngtup = GETSTRUCT(pg_range, tp);
Oid result;
result = rngtup->rngmultitypid;
@@ -3447,7 +3447,7 @@ get_multirange_range(Oid multirangeOid)
tp = SearchSysCache1(RANGEMULTIRANGE, ObjectIdGetDatum(multirangeOid));
if (HeapTupleIsValid(tp))
{
- Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
+ Form_pg_range rngtup = GETSTRUCT(pg_range, tp);
Oid result;
result = rngtup->rngtypid;
@@ -3484,7 +3484,7 @@ get_index_column_opclass(Oid index_oid, int attno)
if (!HeapTupleIsValid(tuple))
return InvalidOid;
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
/* caller is supposed to guarantee this */
Assert(attno > 0 && attno <= rd_index->indnatts);
@@ -3526,7 +3526,7 @@ get_index_isreplident(Oid index_oid)
if (!HeapTupleIsValid(tuple))
return false;
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
result = rd_index->indisreplident;
ReleaseSysCache(tuple);
@@ -3549,7 +3549,7 @@ get_index_isvalid(Oid index_oid)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u", index_oid);
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
isvalid = rd_index->indisvalid;
ReleaseSysCache(tuple);
@@ -3572,7 +3572,7 @@ get_index_isclustered(Oid index_oid)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u", index_oid);
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
isclustered = rd_index->indisclustered;
ReleaseSysCache(tuple);
diff --git a/src/backend/utils/cache/partcache.c b/src/backend/utils/cache/partcache.c
index afa99c5d03..4f8c7c5bde 100644
--- a/src/backend/utils/cache/partcache.c
+++ b/src/backend/utils/cache/partcache.c
@@ -111,7 +111,7 @@ RelationBuildPartitionKey(Relation relation)
sizeof(PartitionKeyData));
/* Fixed-length attributes */
- form = (Form_pg_partitioned_table) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_partitioned_table, tuple);
key->strategy = form->partstrat;
key->partnatts = form->partnatts;
@@ -200,7 +200,7 @@ RelationBuildPartitionKey(Relation relation)
if (!HeapTupleIsValid(opclasstup))
elog(ERROR, "cache lookup failed for opclass %u", opclass->values[i]);
- opclassform = (Form_pg_opclass) GETSTRUCT(opclasstup);
+ opclassform = GETSTRUCT(pg_opclass, opclasstup);
key->partopfamily[i] = opclassform->opcfamily;
key->partopcintype[i] = opclassform->opcintype;
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index bdb771d278..7187de3a4c 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -572,7 +572,7 @@ RelationBuildTupleDesc(Relation relation)
Form_pg_attribute attp;
int attnum;
- attp = (Form_pg_attribute) GETSTRUCT(pg_attribute_tuple);
+ attp = GETSTRUCT(pg_attribute, pg_attribute_tuple);
attnum = attp->attnum;
if (attnum <= 0 || attnum > RelationGetNumberOfAttributes(relation))
@@ -785,7 +785,7 @@ RelationBuildRuleLock(Relation relation)
while (HeapTupleIsValid(rewrite_tuple = systable_getnext(rewrite_scan)))
{
- Form_pg_rewrite rewrite_form = (Form_pg_rewrite) GETSTRUCT(rewrite_tuple);
+ Form_pg_rewrite rewrite_form = GETSTRUCT(pg_rewrite, rewrite_tuple);
bool isnull;
Datum rule_datum;
char *rule_str;
@@ -1111,7 +1111,7 @@ retry:
/*
* get information from the pg_class_tuple
*/
- relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
+ relp = GETSTRUCT(pg_class, pg_class_tuple);
relid = relp->oid;
Assert(relid == targetRelId);
@@ -1349,7 +1349,7 @@ RelationInitPhysicalAddr(Relation relation)
if (!HeapTupleIsValid(phys_tuple))
elog(ERROR, "could not find pg_class entry for %u",
RelationGetRelid(relation));
- physrel = (Form_pg_class) GETSTRUCT(phys_tuple);
+ physrel = GETSTRUCT(pg_class, phys_tuple);
relation->rd_rel->reltablespace = physrel->reltablespace;
relation->rd_rel->relfilenode = physrel->relfilenode;
@@ -1442,7 +1442,7 @@ RelationInitIndexAccessInfo(Relation relation)
RelationGetRelid(relation));
oldcontext = MemoryContextSwitchTo(CacheMemoryContext);
relation->rd_indextuple = heap_copytuple(tuple);
- relation->rd_index = (Form_pg_index) GETSTRUCT(relation->rd_indextuple);
+ relation->rd_index = GETSTRUCT(pg_index, relation->rd_indextuple);
MemoryContextSwitchTo(oldcontext);
ReleaseSysCache(tuple);
@@ -1454,7 +1454,7 @@ RelationInitIndexAccessInfo(Relation relation)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for access method %u",
relation->rd_rel->relam);
- aform = (Form_pg_am) GETSTRUCT(tuple);
+ aform = GETSTRUCT(pg_am, tuple);
relation->rd_amhandler = aform->amhandler;
ReleaseSysCache(tuple);
@@ -1728,7 +1728,7 @@ LookupOpclassInfo(Oid operatorClassOid,
if (HeapTupleIsValid(htup = systable_getnext(scan)))
{
- Form_pg_opclass opclassform = (Form_pg_opclass) GETSTRUCT(htup);
+ Form_pg_opclass opclassform = GETSTRUCT(pg_opclass, htup);
opcentry->opcfamily = opclassform->opcfamily;
opcentry->opcintype = opclassform->opcintype;
@@ -1763,7 +1763,7 @@ LookupOpclassInfo(Oid operatorClassOid,
while (HeapTupleIsValid(htup = systable_getnext(scan)))
{
- Form_pg_amproc amprocform = (Form_pg_amproc) GETSTRUCT(htup);
+ Form_pg_amproc amprocform = GETSTRUCT(pg_amproc, htup);
if (amprocform->amprocnum <= 0 ||
(StrategyNumber) amprocform->amprocnum > numSupport)
@@ -1832,7 +1832,7 @@ RelationInitTableAccessMethod(Relation relation)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for access method %u",
relation->rd_rel->relam);
- aform = (Form_pg_am) GETSTRUCT(tuple);
+ aform = GETSTRUCT(pg_am, tuple);
relation->rd_amhandler = aform->amhandler;
ReleaseSysCache(tuple);
}
@@ -2257,7 +2257,7 @@ RelationReloadIndexInfo(Relation relation)
if (!HeapTupleIsValid(pg_class_tuple))
elog(ERROR, "could not find pg_class tuple for index %u",
RelationGetRelid(relation));
- relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
+ relp = GETSTRUCT(pg_class, pg_class_tuple);
memcpy(relation->rd_rel, relp, CLASS_TUPLE_SIZE);
/* Reload reloptions in case they changed */
if (relation->rd_options)
@@ -2286,7 +2286,7 @@ RelationReloadIndexInfo(Relation relation)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u",
RelationGetRelid(relation));
- index = (Form_pg_index) GETSTRUCT(tuple);
+ index = GETSTRUCT(pg_index, tuple);
/*
* Basically, let's just copy all the bool fields. There are one or
@@ -2378,7 +2378,7 @@ RelationReloadNailed(Relation relation)
pg_class_tuple = ScanPgRelation(RelationGetRelid(relation),
true, false);
- relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
+ relp = GETSTRUCT(pg_class, pg_class_tuple);
memcpy(relation->rd_rel, relp, CLASS_TUPLE_SIZE);
heap_freetuple(pg_class_tuple);
@@ -3721,7 +3721,7 @@ RelationSetNewRelfilenumber(Relation relation, char persistence)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for relation %u",
RelationGetRelid(relation));
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
/*
* Schedule unlinking of the old storage at transaction commit.
@@ -4137,7 +4137,7 @@ RelationCacheInitializePhase3(void)
if (!HeapTupleIsValid(htup))
elog(FATAL, "cache lookup failed for relation %u",
RelationGetRelid(relation));
- relp = (Form_pg_class) GETSTRUCT(htup);
+ relp = GETSTRUCT(pg_class, htup);
/*
* Copy tuple to relation->rd_rel. (See notes in
@@ -4382,7 +4382,7 @@ AttrDefaultFetch(Relation relation, int ndef)
while (HeapTupleIsValid(htup = systable_getnext(adscan)))
{
- Form_pg_attrdef adform = (Form_pg_attrdef) GETSTRUCT(htup);
+ Form_pg_attrdef adform = GETSTRUCT(pg_attrdef, htup);
Datum val;
bool isnull;
@@ -4478,7 +4478,7 @@ CheckConstraintFetch(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(conscan)))
{
- Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(htup);
+ Form_pg_constraint conform = GETSTRUCT(pg_constraint, htup);
Datum val;
bool isnull;
@@ -4602,7 +4602,7 @@ RelationGetFKeyList(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(conscan)))
{
- Form_pg_constraint constraint = (Form_pg_constraint) GETSTRUCT(htup);
+ Form_pg_constraint constraint = GETSTRUCT(pg_constraint, htup);
ForeignKeyCacheInfo *info;
/* consider only foreign keys */
@@ -4709,7 +4709,7 @@ RelationGetIndexList(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(indscan)))
{
- Form_pg_index index = (Form_pg_index) GETSTRUCT(htup);
+ Form_pg_index index = GETSTRUCT(pg_index, htup);
/*
* Ignore any indexes that are currently being dropped. This will
@@ -4828,7 +4828,7 @@ RelationGetStatExtList(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(indscan)))
{
- Oid oid = ((Form_pg_statistic_ext) GETSTRUCT(htup))->oid;
+ Oid oid = (GETSTRUCT(pg_statistic_ext, htup))->oid;
result = lappend_oid(result, oid);
}
@@ -5474,7 +5474,7 @@ RelationGetExclusionInfo(Relation indexRelation,
while (HeapTupleIsValid(htup = systable_getnext(conscan)))
{
- Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(htup);
+ Form_pg_constraint conform = GETSTRUCT(pg_constraint, htup);
Datum val;
bool isnull;
ArrayType *arr;
@@ -5621,7 +5621,7 @@ RelationBuildPublicationDesc(Relation relation, PublicationDesc *pubdesc)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication %u", pubid);
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
pubdesc->pubactions.pubinsert |= pubform->pubinsert;
pubdesc->pubactions.pubupdate |= pubform->pubupdate;
@@ -6088,7 +6088,7 @@ load_relcache_init_file(bool shared)
/* Fix up internal pointers in the tuple -- see heap_copytuple */
rel->rd_indextuple->t_data = (HeapTupleHeader) ((char *) rel->rd_indextuple + HEAPTUPLESIZE);
- rel->rd_index = (Form_pg_index) GETSTRUCT(rel->rd_indextuple);
+ rel->rd_index = GETSTRUCT(pg_index, rel->rd_indextuple);
/*
* prepare index info context --- parameters should match
diff --git a/src/backend/utils/cache/relfilenumbermap.c b/src/backend/utils/cache/relfilenumbermap.c
index c4245d5ccd..7570f5e095 100644
--- a/src/backend/utils/cache/relfilenumbermap.c
+++ b/src/backend/utils/cache/relfilenumbermap.c
@@ -209,7 +209,7 @@ RelidByRelfilenumber(Oid reltablespace, RelFileNumber relfilenumber)
while (HeapTupleIsValid(ntp = systable_getnext(scandesc)))
{
- Form_pg_class classform = (Form_pg_class) GETSTRUCT(ntp);
+ Form_pg_class classform = GETSTRUCT(pg_class, ntp);
if (found)
elog(ERROR,
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index 1912b12146..a8c320ef91 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -1320,7 +1320,7 @@ SearchSysCacheAttName(Oid relid, const char *attname)
CStringGetDatum(attname));
if (!HeapTupleIsValid(tuple))
return NULL;
- if (((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
+ if ((GETSTRUCT(pg_attribute, tuple))->attisdropped)
{
ReleaseSysCache(tuple);
return NULL;
@@ -1383,7 +1383,7 @@ SearchSysCacheAttNum(Oid relid, int16 attnum)
Int16GetDatum(attnum));
if (!HeapTupleIsValid(tuple))
return NULL;
- if (((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
+ if ((GETSTRUCT(pg_attribute, tuple))->attisdropped)
{
ReleaseSysCache(tuple);
return NULL;
diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c
index 24808dfbb1..e1d0dad795 100644
--- a/src/backend/utils/cache/ts_cache.c
+++ b/src/backend/utils/cache/ts_cache.c
@@ -152,7 +152,7 @@ lookup_ts_parser_cache(Oid prsId)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for text search parser %u",
prsId);
- prs = (Form_pg_ts_parser) GETSTRUCT(tp);
+ prs = GETSTRUCT(pg_ts_parser, tp);
/*
* Sanity checks
@@ -254,7 +254,7 @@ lookup_ts_dictionary_cache(Oid dictId)
if (!HeapTupleIsValid(tpdict))
elog(ERROR, "cache lookup failed for text search dictionary %u",
dictId);
- dict = (Form_pg_ts_dict) GETSTRUCT(tpdict);
+ dict = GETSTRUCT(pg_ts_dict, tpdict);
/*
* Sanity checks
@@ -270,7 +270,7 @@ lookup_ts_dictionary_cache(Oid dictId)
if (!HeapTupleIsValid(tptmpl))
elog(ERROR, "cache lookup failed for text search template %u",
dict->dicttemplate);
- template = (Form_pg_ts_template) GETSTRUCT(tptmpl);
+ template = GETSTRUCT(pg_ts_template, tptmpl);
/*
* Sanity checks
@@ -424,7 +424,7 @@ lookup_ts_config_cache(Oid cfgId)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for text search configuration %u",
cfgId);
- cfg = (Form_pg_ts_config) GETSTRUCT(tp);
+ cfg = GETSTRUCT(pg_ts_config, tp);
/*
* Sanity checks
@@ -484,7 +484,7 @@ lookup_ts_config_cache(Oid cfgId)
while ((maptup = systable_getnext_ordered(mapscan, ForwardScanDirection)) != NULL)
{
- Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup);
+ Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup);
int toktype = cfgmap->maptokentype;
if (toktype <= 0 || toktype > MAXTOKENTYPE)
@@ -625,7 +625,7 @@ check_TSCurrentConfig(char **newval, void **extra, GucSource source)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for text search configuration %u",
cfgId);
- cfg = (Form_pg_ts_config) GETSTRUCT(tuple);
+ cfg = GETSTRUCT(pg_ts_config, tuple);
buf = quote_qualified_identifier(get_namespace_name(cfg->cfgnamespace),
NameStr(cfg->cfgname));
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c
index 808f9ebd0d..6b55c4a4e1 100644
--- a/src/backend/utils/cache/typcache.c
+++ b/src/backend/utils/cache/typcache.c
@@ -383,7 +383,7 @@ lookup_type_cache(Oid type_id, int flags)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type with OID %u does not exist", type_id)));
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
if (!typtup->typisdefined)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -438,7 +438,7 @@ lookup_type_cache(Oid type_id, int flags)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type with OID %u does not exist", type_id)));
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
if (!typtup->typisdefined)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -922,7 +922,7 @@ load_rangetype_info(TypeCacheEntry *typentry)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for range type %u",
typentry->type_id);
- pg_range = (Form_pg_range) GETSTRUCT(tup);
+ pg_range = GETSTRUCT(pg_range, tup);
subtypeOid = pg_range->rngsubtype;
typentry->rng_collation = pg_range->rngcollation;
@@ -1032,7 +1032,7 @@ load_domaintype_info(TypeCacheEntry *typentry)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
if (typTup->typtype != TYPTYPE_DOMAIN)
{
@@ -1056,7 +1056,7 @@ load_domaintype_info(TypeCacheEntry *typentry)
while (HeapTupleIsValid(conTup = systable_getnext(scan)))
{
- Form_pg_constraint c = (Form_pg_constraint) GETSTRUCT(conTup);
+ Form_pg_constraint c = GETSTRUCT(pg_constraint, conTup);
Datum val;
bool isNull;
char *constring;
@@ -2592,7 +2592,7 @@ load_enum_cache_data(TypeCacheEntry *tcache)
while (HeapTupleIsValid(enum_tuple = systable_getnext(enum_scan)))
{
- Form_pg_enum en = (Form_pg_enum) GETSTRUCT(enum_tuple);
+ Form_pg_enum en = GETSTRUCT(pg_enum, enum_tuple);
if (numitems >= maxitems)
{
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index a9dd068095..125a175a11 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -181,7 +181,7 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt,
procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId));
if (!HeapTupleIsValid(procedureTuple))
elog(ERROR, "cache lookup failed for function %u", functionId);
- procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
finfo->fn_nargs = procedureStruct->pronargs;
finfo->fn_strict = procedureStruct->proisstrict;
@@ -291,7 +291,7 @@ fmgr_symbol(Oid functionId, char **mod, char **fn)
procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId));
if (!HeapTupleIsValid(procedureTuple))
elog(ERROR, "cache lookup failed for function %u", functionId);
- procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
if (procedureStruct->prosecdef ||
!heap_attisnull(procedureTuple, Anum_pg_proc_proconfig, NULL) ||
@@ -431,7 +431,7 @@ fmgr_info_C_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
static void
fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
{
- Form_pg_proc procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ Form_pg_proc procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
Oid language = procedureStruct->prolang;
HeapTuple languageTuple;
Form_pg_language languageStruct;
@@ -440,7 +440,7 @@ fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
languageTuple = SearchSysCache1(LANGOID, ObjectIdGetDatum(language));
if (!HeapTupleIsValid(languageTuple))
elog(ERROR, "cache lookup failed for language %u", language);
- languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
+ languageStruct = GETSTRUCT(pg_language, languageTuple);
/*
* Look up the language's call handler function, ignoring any attributes
@@ -528,7 +528,7 @@ fetch_finfo_record(void *filehandle, const char *funcname)
static CFuncHashTabEntry *
lookup_C_func(HeapTuple procedureTuple)
{
- Oid fn_oid = ((Form_pg_proc) GETSTRUCT(procedureTuple))->oid;
+ Oid fn_oid = (GETSTRUCT(pg_proc, procedureTuple))->oid;
CFuncHashTabEntry *entry;
if (CFuncHash == NULL)
@@ -553,7 +553,7 @@ static void
record_C_func(HeapTuple procedureTuple,
PGFunction user_fn, const Pg_finfo_record *inforec)
{
- Oid fn_oid = ((Form_pg_proc) GETSTRUCT(procedureTuple))->oid;
+ Oid fn_oid = (GETSTRUCT(pg_proc, procedureTuple))->oid;
CFuncHashTabEntry *entry;
bool found;
@@ -671,7 +671,7 @@ fmgr_security_definer(PG_FUNCTION_ARGS)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u",
fcinfo->flinfo->fn_oid);
- procedureStruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procedureStruct = GETSTRUCT(pg_proc, tuple);
if (procedureStruct->prosecdef)
fcache->userid = procedureStruct->proowner;
@@ -2035,7 +2035,7 @@ CheckFunctionValidatorAccess(Oid validatorOid, Oid functionOid)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function with OID %u does not exist", functionOid)));
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/*
* Fetch pg_language entry to know if this is the correct validation
@@ -2044,7 +2044,7 @@ CheckFunctionValidatorAccess(Oid validatorOid, Oid functionOid)
langTup = SearchSysCache1(LANGOID, ObjectIdGetDatum(procStruct->prolang));
if (!HeapTupleIsValid(langTup))
elog(ERROR, "cache lookup failed for language %u", procStruct->prolang);
- langStruct = (Form_pg_language) GETSTRUCT(langTup);
+ langStruct = GETSTRUCT(pg_language, langTup);
if (langStruct->lanvalidator != validatorOid)
ereport(ERROR,
diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c
index a1fe50ffca..213121461d 100644
--- a/src/backend/utils/fmgr/funcapi.c
+++ b/src/backend/utils/fmgr/funcapi.c
@@ -403,7 +403,7 @@ internal_get_result_type(Oid funcid,
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(tp);
+ procform = GETSTRUCT(pg_proc, tp);
rettype = procform->prorettype;
@@ -1337,7 +1337,7 @@ int
get_func_arg_info(HeapTuple procTup,
Oid **p_argtypes, char ***p_argnames, char **p_argmodes)
{
- Form_pg_proc procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ Form_pg_proc procStruct = GETSTRUCT(pg_proc, procTup);
Datum proallargtypes;
Datum proargmodes;
Datum proargnames;
@@ -1667,7 +1667,7 @@ get_func_result_name(Oid functionId)
TupleDesc
build_function_result_tupdesc_t(HeapTuple procTuple)
{
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(procTuple);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, procTuple);
Datum proallargtypes;
Datum proargmodes;
Datum proargnames;
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index eb43b2c5e5..df10da08b9 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -683,7 +683,7 @@ has_rolreplication(Oid roleid)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolreplication;
+ result = (GETSTRUCT(pg_authid, utup))->rolreplication;
ReleaseSysCache(utup);
}
return result;
@@ -732,7 +732,7 @@ InitializeSessionUserId(const char *rolename, Oid roleid)
errmsg("role with OID %u does not exist", roleid)));
}
- rform = (Form_pg_authid) GETSTRUCT(roleTup);
+ rform = GETSTRUCT(pg_authid, roleTup);
roleid = rform->oid;
rname = NameStr(rform->rolname);
@@ -925,7 +925,7 @@ GetUserNameFromId(Oid roleid, bool noerr)
}
else
{
- result = pstrdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_authid, tuple))->rolname));
ReleaseSysCache(tuple);
}
return result;
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index a5c208a20a..3ddd0d3c66 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -321,7 +321,7 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
tup = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
- dbform = (Form_pg_database) GETSTRUCT(tup);
+ dbform = GETSTRUCT(pg_database, tup);
/* This recheck is strictly paranoia */
if (strcmp(name, NameStr(dbform->datname)) != 0)
@@ -921,7 +921,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", in_dbname)));
- dbform = (Form_pg_database) GETSTRUCT(tuple);
+ dbform = GETSTRUCT(pg_database, tuple);
MyDatabaseId = dbform->oid;
MyDatabaseTableSpace = dbform->dattablespace;
/* take database name from the caller, just for paranoia */
@@ -938,7 +938,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database %u does not exist", dboid)));
- dbform = (Form_pg_database) GETSTRUCT(tuple);
+ dbform = GETSTRUCT(pg_database, tuple);
MyDatabaseId = dbform->oid;
MyDatabaseTableSpace = dbform->dattablespace;
Assert(MyDatabaseId == dboid);
@@ -1021,8 +1021,8 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
tuple = GetDatabaseTuple(dbname);
if (!HeapTupleIsValid(tuple) ||
- MyDatabaseId != ((Form_pg_database) GETSTRUCT(tuple))->oid ||
- MyDatabaseTableSpace != ((Form_pg_database) GETSTRUCT(tuple))->dattablespace)
+ MyDatabaseId != (GETSTRUCT(pg_database, tuple))->oid ||
+ MyDatabaseTableSpace != (GETSTRUCT(pg_database, tuple))->dattablespace)
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", dbname),
diff --git a/src/backend/utils/misc/rls.c b/src/backend/utils/misc/rls.c
index d15880670f..73fd21d843 100644
--- a/src/backend/utils/misc/rls.c
+++ b/src/backend/utils/misc/rls.c
@@ -66,7 +66,7 @@ check_enable_rls(Oid relid, Oid checkAsUser, bool noError)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return RLS_NONE;
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
relrowsecurity = classform->relrowsecurity;
relforcerowsecurity = classform->relforcerowsecurity;
diff --git a/src/backend/utils/misc/superuser.c b/src/backend/utils/misc/superuser.c
index d20e7af797..1902f49d0a 100644
--- a/src/backend/utils/misc/superuser.c
+++ b/src/backend/utils/misc/superuser.c
@@ -70,7 +70,7 @@ superuser_arg(Oid roleid)
rtup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(rtup))
{
- result = ((Form_pg_authid) GETSTRUCT(rtup))->rolsuper;
+ result = (GETSTRUCT(pg_authid, rtup))->rolsuper;
ReleaseSysCache(rtup);
}
else
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 51a60eda08..7310e3b2b8 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -651,7 +651,7 @@ struct MinimalTupleData
/*
* GETSTRUCT - given a HeapTuple pointer, return address of the user data
*/
-#define GETSTRUCT(TUP) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)
+#define GETSTRUCT(CAT, TUP) ((Form_##CAT) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff))
/*
* Accessor macros to be used with HeapTuple pointers.
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index edb93ec1c4..1aa8227afb 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -1994,7 +1994,7 @@ plperl_validator(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- proc = (Form_pg_proc) GETSTRUCT(tuple);
+ proc = GETSTRUCT(pg_proc, tuple);
functyptype = get_typtype(proc->prorettype);
@@ -2717,7 +2717,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(fn_oid));
if (!HeapTupleIsValid(procTup))
elog(ERROR, "cache lookup failed for function %u", fn_oid);
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/*
* Try to find function in plperl_proc_hash. The reason for this
@@ -2818,7 +2818,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
if (!HeapTupleIsValid(langTup))
elog(ERROR, "cache lookup failed for language %u",
procStruct->prolang);
- langStruct = (Form_pg_language) GETSTRUCT(langTup);
+ langStruct = GETSTRUCT(pg_language, langTup);
prodesc->lang_oid = langStruct->oid;
prodesc->lanpltrusted = langStruct->lanpltrusted;
ReleaseSysCache(langTup);
@@ -2834,7 +2834,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettype));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", rettype);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype result, except VOID or RECORD */
if (typeStruct->typtype == TYPTYPE_PSEUDO)
@@ -2883,7 +2883,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(argtype));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", argtype);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype argument, except RECORD */
if (typeStruct->typtype == TYPTYPE_PSEUDO &&
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index 61fbdf0686..41eca1990a 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -149,7 +149,7 @@ plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator)
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(procTup))
elog(ERROR, "cache lookup failed for function %u", funcOid);
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/*
* See if there's already a cache entry for the current FmgrInfo. If not,
@@ -267,7 +267,7 @@ do_compile(FunctionCallInfo fcinfo,
PLpgSQL_func_hashkey *hashkey,
bool forValidator)
{
- Form_pg_proc procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ Form_pg_proc procStruct = GETSTRUCT(pg_proc, procTup);
bool is_dml_trigger = CALLED_AS_TRIGGER(fcinfo);
bool is_event_trigger = CALLED_AS_EVENT_TRIGGER(fcinfo);
Datum prosrcdatum;
@@ -545,7 +545,7 @@ do_compile(FunctionCallInfo fcinfo,
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettypeid));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", rettypeid);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype result, except VOID or RECORD */
/* (note we already replaced polymorphic types) */
@@ -1643,7 +1643,7 @@ plpgsql_parse_wordtype(char *ident)
typeTup = LookupTypeName(NULL, typeName, NULL, false);
if (typeTup)
{
- Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ Form_pg_type typeStruct = GETSTRUCT(pg_type, typeTup);
if (!typeStruct->typisdefined ||
typeStruct->typrelid != InvalidOid)
@@ -1735,7 +1735,7 @@ plpgsql_parse_cwordtype(List *idents)
classtup = SearchSysCache1(RELOID, ObjectIdGetDatum(classOid));
if (!HeapTupleIsValid(classtup))
goto done;
- classStruct = (Form_pg_class) GETSTRUCT(classtup);
+ classStruct = GETSTRUCT(pg_class, classtup);
/*
* It must be a relation, sequence, view, materialized view, composite
@@ -1756,7 +1756,7 @@ plpgsql_parse_cwordtype(List *idents)
attrtup = SearchSysCacheAttName(classOid, fldname);
if (!HeapTupleIsValid(attrtup))
goto done;
- attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup);
+ attrStruct = GETSTRUCT(pg_attribute, attrtup);
typetup = SearchSysCache1(TYPEOID,
ObjectIdGetDatum(attrStruct->atttypid));
@@ -2107,7 +2107,7 @@ static PLpgSQL_type *
build_datatype(HeapTuple typeTup, int32 typmod,
Oid collation, TypeName *origtypname)
{
- Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ Form_pg_type typeStruct = GETSTRUCT(pg_type, typeTup);
PLpgSQL_type *typ;
if (!typeStruct->typisdefined)
diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c
index 190d286f1c..632e4c351d 100644
--- a/src/pl/plpgsql/src/pl_handler.c
+++ b/src/pl/plpgsql/src/pl_handler.c
@@ -460,7 +460,7 @@ plpgsql_validator(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- proc = (Form_pg_proc) GETSTRUCT(tuple);
+ proc = GETSTRUCT(pg_proc, tuple);
functyptype = get_typtype(proc->prorettype);
diff --git a/src/pl/plpython/plpy_main.c b/src/pl/plpython/plpy_main.c
index 0bce106495..ab5fc74c1b 100644
--- a/src/pl/plpython/plpy_main.c
+++ b/src/pl/plpython/plpy_main.c
@@ -177,7 +177,7 @@ plpython3_validator(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- procStruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procStruct = GETSTRUCT(pg_proc, tuple);
is_trigger = PLy_procedure_is_trigger(procStruct);
diff --git a/src/pl/plpython/plpy_procedure.c b/src/pl/plpython/plpy_procedure.c
index 494f109b32..2c91e6df81 100644
--- a/src/pl/plpython/plpy_procedure.c
+++ b/src/pl/plpython/plpy_procedure.c
@@ -140,7 +140,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
int rv;
char *ptr;
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
rv = snprintf(procName, sizeof(procName),
"__plpython_procedure_%s_%u",
NameStr(procStruct->proname),
@@ -211,7 +211,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
rvTypeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettype));
if (!HeapTupleIsValid(rvTypeTup))
elog(ERROR, "cache lookup failed for type %u", rettype);
- rvTypeStruct = (Form_pg_type) GETSTRUCT(rvTypeTup);
+ rvTypeStruct = GETSTRUCT(pg_type, rvTypeTup);
/* Disallow pseudotype result, except for void or record */
if (rvTypeStruct->typtype == TYPTYPE_PSEUDO)
@@ -298,7 +298,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
ObjectIdGetDatum(types[i]));
if (!HeapTupleIsValid(argTypeTup))
elog(ERROR, "cache lookup failed for type %u", types[i]);
- argTypeStruct = (Form_pg_type) GETSTRUCT(argTypeTup);
+ argTypeStruct = GETSTRUCT(pg_type, argTypeTup);
/* disallow pseudotype arguments */
if (argTypeStruct->typtype == TYPTYPE_PSEUDO)
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index 0dd6d8ab2c..0161a9bb9c 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -628,7 +628,7 @@ call_pltcl_start_proc(Oid prolang, bool pltrusted)
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procOid));
if (!HeapTupleIsValid(procTup))
elog(ERROR, "cache lookup failed for function %u", procOid);
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/* It must be same language as the function we're currently calling */
if (procStruct->prolang != prolang)
@@ -1405,7 +1405,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(fn_oid));
if (!HeapTupleIsValid(procTup))
elog(ERROR, "cache lookup failed for function %u", fn_oid);
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/*
* Look up function in pltcl_proc_htab; if it's not there, create an entry
@@ -1527,7 +1527,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettype));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", rettype);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype result, except VOID and RECORD */
if (typeStruct->typtype == TYPTYPE_PSEUDO)
@@ -1575,7 +1575,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(argtype));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", argtype);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype argument, except RECORD */
if (typeStruct->typtype == TYPTYPE_PSEUDO &&
diff --git a/src/test/modules/plsample/plsample.c b/src/test/modules/plsample/plsample.c
index 780db7292a..8cc3118985 100644
--- a/src/test/modules/plsample/plsample.c
+++ b/src/test/modules/plsample/plsample.c
@@ -122,7 +122,7 @@ plsample_func_handler(PG_FUNCTION_ARGS)
* Extract and print the source text of the function. This can be used as
* a base for the function validation and execution.
*/
- pl_struct = (Form_pg_proc) GETSTRUCT(pl_tuple);
+ pl_struct = GETSTRUCT(pg_proc, pl_tuple);
proname = pstrdup(NameStr(pl_struct->proname));
ret = SysCacheGetAttr(PROCOID, pl_tuple, Anum_pg_proc_prosrc, &isnull);
if (isnull)
@@ -157,7 +157,7 @@ plsample_func_handler(PG_FUNCTION_ARGS)
if (!HeapTupleIsValid(type_tuple))
elog(ERROR, "cache lookup failed for type %u", argtype);
- type_struct = (Form_pg_type) GETSTRUCT(type_tuple);
+ type_struct = GETSTRUCT(pg_type, type_tuple);
fmgr_info_cxt(type_struct->typoutput, &(arg_out_func[i]), proc_cxt);
ReleaseSysCache(type_tuple);
@@ -186,7 +186,7 @@ plsample_func_handler(PG_FUNCTION_ARGS)
ObjectIdGetDatum(prorettype));
if (!HeapTupleIsValid(type_tuple))
elog(ERROR, "cache lookup failed for type %u", prorettype);
- pg_type_entry = (Form_pg_type) GETSTRUCT(type_tuple);
+ pg_type_entry = GETSTRUCT(pg_type, type_tuple);
result_typioparam = getTypeIOParam(type_tuple);
fmgr_info_cxt(pg_type_entry->typinput, &result_in_func, proc_cxt);
@@ -239,7 +239,7 @@ plsample_trigger_handler(PG_FUNCTION_ARGS)
* Extract and print the source text of the function. This can be used as
* a base for the function validation and execution.
*/
- pl_struct = (Form_pg_proc) GETSTRUCT(pl_tuple);
+ pl_struct = GETSTRUCT(pg_proc, pl_tuple);
proname = pstrdup(NameStr(pl_struct->proname));
ret = SysCacheGetAttr(PROCOID, pl_tuple, Anum_pg_proc_prosrc, &isnull);
if (isnull)
--
2.36.1
v2-0004-Generate-pg_cast-function-to-deform-tuples-into-s.patchtext/x-patch; charset=US-ASCII; name=v2-0004-Generate-pg_cast-function-to-deform-tuples-into-s.patchDownload
From f8b340580a4bb53b10ab5824227eaf74b9e26813 Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Sun, 17 Jul 2022 12:33:01 +0700
Subject: [PATCH v2 4/4] Generate pg_cast function to deform tuples into
structs
This catalog presents no challenges for alignment padding, but has
few attributes and few GETSTRUCT call sites, so is an easy PoC.
---
src/backend/catalog/genbki.pl | 49 +++++++++++++++++++++++++++--
src/backend/catalog/objectaddress.c | 20 ++++++------
src/backend/parser/parse_coerce.c | 27 +++++++++-------
src/include/access/htup_details.h | 6 ++++
4 files changed, 77 insertions(+), 25 deletions(-)
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index 8ed7d1f92b..27d077bd51 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -476,16 +476,29 @@ EOM
#ifndef %s_DEFORM_H
#define %s_DEFORM_H
+#include "access/tupmacs.h"
+
EOM
# Emit tuple deforming function
- # WIP: the same macro we had before written as a trivial function
- print $deform <<GETSTRUCT;
+ if ($catname eq 'pg_cast')
+ {
+ print $deform <<GETSTRUCT_FUNC;
+static inline void
+Deform_$catname\_tuple(Form_$catname $catname\_struct, char * $catname\_tuple)
+{
+GETSTRUCT_FUNC
+ }
+ else
+ {
+ # WIP: the same macro we had before written as a trivial function
+ print $deform <<GETSTRUCT;
static inline Form_$catname
Deform_$catname\_tuple(char * $catname\_tuple)
{
return (Form_$catname) ($catname\_tuple);
GETSTRUCT
+ }
# Emit OID macros for catalog's OID and rowtype OID, if wanted
printf $def "#define %s %s\n",
@@ -532,10 +545,13 @@ GETSTRUCT
my $schema = $catalog->{columns};
my %attnames;
my $attnum = 0;
+ my $prev_attname;
+ my $prev_ctype;
foreach my $column (@$schema)
{
$attnum++;
my $attname = $column->{attname};
+ my $ctype = $column->{ctype};
my $atttype = $column->{atttype};
# Build hash of column names for use later
@@ -546,7 +562,6 @@ GETSTRUCT
{
print $bki " ,\n";
}
- $first = 0;
print $bki " $attname = $atttype";
@@ -561,6 +576,34 @@ GETSTRUCT
# Emit Anum_* constants
printf $def "#define Anum_%s_%s %s\n", $catname, $attname, $attnum;
+
+ # Emit memcpy statements with the right type lengths and tuple offsets
+ # WIP: one catalog at first, eventually for all of them
+ if ($catname eq 'pg_cast')
+ {
+ if ($first)
+ {
+ printf $deform "#define Aoff_%s_%s 0\n", $catname, $attname;
+ }
+ else
+ {
+ # current offset is the previous offset plus the previous type length,
+ # plus any alignment padding suitable for the current type
+ printf $deform "\n#define Aoff_%s_%s att_align_nominal(Aoff_%s_%s + sizeof(%s), '%s')\n",
+ $catname, $attname,
+ $catname, $prev_attname, $prev_ctype,
+ $types{$atttype}->{typalign};
+ }
+
+ printf $deform "\tmemcpy(&%s_struct->%s, %s_tuple + Aoff_%s_%s, sizeof(%s));\n",
+ $catname, $attname,
+ $catname, $catname, $attname,
+ $ctype;
+ }
+
+ $first = 0;
+ $prev_attname = $attname;
+ $prev_ctype = $ctype;
}
print $bki "\n )\n";
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 4991a76c41..66e98daad1 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -3003,7 +3003,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
ScanKeyData skey[1];
SysScanDesc rcscan;
HeapTuple tup;
- Form_pg_cast castForm;
+ FormData_pg_cast castForm;
castDesc = table_open(CastRelationId, AccessShareLock);
@@ -3028,11 +3028,11 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- castForm = GETSTRUCT(pg_cast, tup);
+ GETSTRUCT_MEMCPY(pg_cast, &castForm, tup);
appendStringInfo(&buffer, _("cast from %s to %s"),
- format_type_be(castForm->castsource),
- format_type_be(castForm->casttarget));
+ format_type_be(castForm.castsource),
+ format_type_be(castForm.casttarget));
systable_endscan(rcscan);
table_close(castDesc, AccessShareLock);
@@ -4853,7 +4853,7 @@ getObjectIdentityParts(const ObjectAddress *object,
{
Relation castRel;
HeapTuple tup;
- Form_pg_cast castForm;
+ FormData_pg_cast castForm;
castRel = table_open(CastRelationId, AccessShareLock);
@@ -4870,16 +4870,16 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- castForm = GETSTRUCT(pg_cast, tup);
+ GETSTRUCT_MEMCPY(pg_cast, &castForm, tup);
appendStringInfo(&buffer, "(%s AS %s)",
- format_type_be_qualified(castForm->castsource),
- format_type_be_qualified(castForm->casttarget));
+ format_type_be_qualified(castForm.castsource),
+ format_type_be_qualified(castForm.casttarget));
if (objname)
{
- *objname = list_make1(format_type_be_qualified(castForm->castsource));
- *objargs = list_make1(format_type_be_qualified(castForm->casttarget));
+ *objname = list_make1(format_type_be_qualified(castForm.castsource));
+ *objargs = list_make1(format_type_be_qualified(castForm.casttarget));
}
table_close(castRel, AccessShareLock);
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index 172d4b2034..0bd90fd5e8 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -2995,7 +2995,7 @@ bool
IsBinaryCoercible(Oid srctype, Oid targettype)
{
HeapTuple tuple;
- Form_pg_cast castForm;
+ FormData_pg_cast castForm;
bool result;
/* Fast path if same type */
@@ -3056,10 +3056,10 @@ IsBinaryCoercible(Oid srctype, Oid targettype)
ObjectIdGetDatum(targettype));
if (!HeapTupleIsValid(tuple))
return false; /* no cast */
- castForm = GETSTRUCT(pg_cast, tuple);
+ GETSTRUCT_MEMCPY(pg_cast, &castForm, tuple);
- result = (castForm->castmethod == COERCION_METHOD_BINARY &&
- castForm->castcontext == COERCION_CODE_IMPLICIT);
+ result = (castForm.castmethod == COERCION_METHOD_BINARY &&
+ castForm.castcontext == COERCION_CODE_IMPLICIT);
ReleaseSysCache(tuple);
@@ -3120,11 +3120,13 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
if (HeapTupleIsValid(tuple))
{
- Form_pg_cast castForm = GETSTRUCT(pg_cast, tuple);
+ FormData_pg_cast castForm;
CoercionContext castcontext;
+ GETSTRUCT_MEMCPY(pg_cast, &castForm, tuple);
+
/* convert char value for castcontext to CoercionContext enum */
- switch (castForm->castcontext)
+ switch (castForm.castcontext)
{
case COERCION_CODE_IMPLICIT:
castcontext = COERCION_IMPLICIT;
@@ -3137,7 +3139,7 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
break;
default:
elog(ERROR, "unrecognized castcontext: %d",
- (int) castForm->castcontext);
+ (int) castForm.castcontext);
castcontext = 0; /* keep compiler quiet */
break;
}
@@ -3145,11 +3147,11 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
/* Rely on ordering of enum for correct behavior here */
if (ccontext >= castcontext)
{
- switch (castForm->castmethod)
+ switch (castForm.castmethod)
{
case COERCION_METHOD_FUNCTION:
result = COERCION_PATH_FUNC;
- *funcid = castForm->castfunc;
+ *funcid = castForm.castfunc;
break;
case COERCION_METHOD_INOUT:
result = COERCION_PATH_COERCEVIAIO;
@@ -3159,7 +3161,7 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
break;
default:
elog(ERROR, "unrecognized castmethod: %d",
- (int) castForm->castmethod);
+ (int) castForm.castmethod);
break;
}
}
@@ -3287,9 +3289,10 @@ find_typmod_coercion_function(Oid typeId,
if (HeapTupleIsValid(tuple))
{
- Form_pg_cast castForm = GETSTRUCT(pg_cast, tuple);
+ FormData_pg_cast castForm;
- *funcid = castForm->castfunc;
+ GETSTRUCT_MEMCPY(pg_cast, &castForm, tuple);
+ *funcid = castForm.castfunc;
ReleaseSysCache(tuple);
}
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 9d5bd76d7b..f300030504 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -653,6 +653,12 @@ struct MinimalTupleData
*/
#define GETSTRUCT(CAT, TUP) Deform_##CAT##_tuple((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)
+/*
+ * GETSTRUCT - given a HeapTuple pointer, deform the user data into the passed struct
+ */
+// WIP: The _MEMCPY suffix is a temporary scaffold to allow partial progress one catalog at a time.
+#define GETSTRUCT_MEMCPY(CAT, STRUCT, TUP) Deform_##CAT##_tuple(STRUCT, (char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)
+
/*
* Accessor macros to be used with HeapTuple pointers.
*/
--
2.36.1
v2-0003-Generate-stubs-for-catalog-tuple-deforming-functi.patchtext/x-patch; charset=US-ASCII; name=v2-0003-Generate-stubs-for-catalog-tuple-deforming-functi.patchDownload
From 7c071ccd6cb4aaf708380d028cc9bd6d6ff8d41d Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Sun, 10 Jul 2022 14:33:51 +0700
Subject: [PATCH v2 3/4] Generate stubs for catalog tuple deforming functions
Include the generated *_deform headers into the corresponding catalog headers
after the Form_* typedef.
These simple have the same macro in function form, but gives some
idea of how the build would work. FormData_pg_sequence_data, is not a catalog
in the usual sense, so just manually write the equivalent macro.
---
src/backend/catalog/Makefile | 2 +-
src/backend/catalog/genbki.pl | 28 ++++++++++++++++++-
src/include/access/htup_details.h | 2 +-
src/include/catalog/pg_aggregate.h | 3 ++
src/include/catalog/pg_am.h | 3 ++
src/include/catalog/pg_amop.h | 3 ++
src/include/catalog/pg_amproc.h | 3 ++
src/include/catalog/pg_attrdef.h | 3 ++
src/include/catalog/pg_attribute.h | 3 ++
src/include/catalog/pg_auth_members.h | 3 ++
src/include/catalog/pg_authid.h | 3 ++
src/include/catalog/pg_cast.h | 3 ++
src/include/catalog/pg_class.h | 3 ++
src/include/catalog/pg_collation.h | 3 ++
src/include/catalog/pg_constraint.h | 3 ++
src/include/catalog/pg_conversion.h | 3 ++
src/include/catalog/pg_database.h | 3 ++
src/include/catalog/pg_db_role_setting.h | 3 ++
src/include/catalog/pg_default_acl.h | 3 ++
src/include/catalog/pg_depend.h | 3 ++
src/include/catalog/pg_description.h | 3 ++
src/include/catalog/pg_enum.h | 3 ++
src/include/catalog/pg_event_trigger.h | 3 ++
src/include/catalog/pg_extension.h | 3 ++
src/include/catalog/pg_foreign_data_wrapper.h | 3 ++
src/include/catalog/pg_foreign_server.h | 3 ++
src/include/catalog/pg_foreign_table.h | 3 ++
src/include/catalog/pg_index.h | 3 ++
src/include/catalog/pg_inherits.h | 3 ++
src/include/catalog/pg_init_privs.h | 3 ++
src/include/catalog/pg_language.h | 3 ++
src/include/catalog/pg_largeobject.h | 3 ++
src/include/catalog/pg_largeobject_metadata.h | 3 ++
src/include/catalog/pg_namespace.h | 3 ++
src/include/catalog/pg_opclass.h | 3 ++
src/include/catalog/pg_operator.h | 3 ++
src/include/catalog/pg_opfamily.h | 3 ++
src/include/catalog/pg_parameter_acl.h | 3 ++
src/include/catalog/pg_partitioned_table.h | 3 ++
src/include/catalog/pg_policy.h | 3 ++
src/include/catalog/pg_proc.h | 3 ++
src/include/catalog/pg_publication.h | 3 ++
.../catalog/pg_publication_namespace.h | 3 ++
src/include/catalog/pg_publication_rel.h | 3 ++
src/include/catalog/pg_range.h | 3 ++
src/include/catalog/pg_replication_origin.h | 3 ++
src/include/catalog/pg_rewrite.h | 3 ++
src/include/catalog/pg_sequence.h | 3 ++
src/include/catalog/pg_shdepend.h | 3 ++
src/include/catalog/pg_shdescription.h | 3 ++
src/include/catalog/pg_shseclabel.h | 3 ++
src/include/catalog/pg_statistic.h | 3 ++
src/include/catalog/pg_statistic_ext.h | 3 ++
src/include/catalog/pg_statistic_ext_data.h | 3 ++
src/include/catalog/pg_subscription.h | 3 ++
src/include/catalog/pg_subscription_rel.h | 3 ++
src/include/catalog/pg_tablespace.h | 3 ++
src/include/catalog/pg_transform.h | 3 ++
src/include/catalog/pg_trigger.h | 3 ++
src/include/catalog/pg_ts_config.h | 3 ++
src/include/catalog/pg_ts_config_map.h | 3 ++
src/include/catalog/pg_ts_dict.h | 3 ++
src/include/catalog/pg_ts_parser.h | 3 ++
src/include/catalog/pg_ts_template.h | 3 ++
src/include/catalog/pg_type.h | 3 ++
src/include/catalog/pg_user_mapping.h | 3 ++
src/include/commands/sequence.h | 3 ++
67 files changed, 221 insertions(+), 3 deletions(-)
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 89a0221ec9..d7bca52391 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -74,7 +74,7 @@ CATALOG_HEADERS := \
pg_sequence.h pg_publication.h pg_publication_namespace.h \
pg_publication_rel.h pg_subscription.h pg_subscription_rel.h
-GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h system_fk_info.h
+GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) $(CATALOG_HEADERS:%.h=%_deform.h) schemapg.h system_fk_info.h
POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/, $(CATALOG_HEADERS))
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index 932f3a9ab5..8ed7d1f92b 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -440,6 +440,11 @@ foreach my $catname (@catnames)
open my $def, '>', $def_file . $tmpext
or die "can't open $def_file$tmpext: $!";
+ # Create one header with the tuple deforming function for each catalog.
+ my $deform_file = $output_path . $catname . '_deform.h';
+ open my $deform, '>', $deform_file . $tmpext
+ or die "can't open $deform_file$tmpext: $!";
+
# Opening boilerplate for pg_*_d.h
printf $def <<EOM, $catname, $catname, uc $catname, uc $catname;
/*-------------------------------------------------------------------------
@@ -464,6 +469,24 @@ foreach my $catname (@catnames)
EOM
+ # Opening boilerplate for pg_*_deform.h
+ printf $deform <<EOM, uc $catname, uc $catname;
+/* generated by src/backend/catalog/genbki.pl, do not edit */
+
+#ifndef %s_DEFORM_H
+#define %s_DEFORM_H
+
+EOM
+
+ # Emit tuple deforming function
+ # WIP: the same macro we had before written as a trivial function
+ print $deform <<GETSTRUCT;
+static inline Form_$catname
+Deform_$catname\_tuple(char * $catname\_tuple)
+{
+ return (Form_$catname) ($catname\_tuple);
+GETSTRUCT
+
# Emit OID macros for catalog's OID and rowtype OID, if wanted
printf $def "#define %s %s\n",
$catalog->{relation_oid_macro}, $catalog->{relation_oid}
@@ -673,10 +696,13 @@ EOM
print $bki "close $catname\n";
printf $def "\n#endif\t\t\t\t\t\t\t/* %s_D_H */\n", uc $catname;
+ printf $deform "}\n\n#endif\t\t\t\t\t\t\t/* %s_DEFORM_H */\n", uc $catname;
- # Close and rename definition header
+ # Close and rename per-catalog headers
close $def;
Catalog::RenameTempFile($def_file, $tmpext);
+ close $deform;
+ Catalog::RenameTempFile($deform_file, $tmpext);
}
# Any information needed for the BKI that is not contained in a pg_*.h header
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 7310e3b2b8..9d5bd76d7b 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -651,7 +651,7 @@ struct MinimalTupleData
/*
* GETSTRUCT - given a HeapTuple pointer, return address of the user data
*/
-#define GETSTRUCT(CAT, TUP) ((Form_##CAT) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff))
+#define GETSTRUCT(CAT, TUP) Deform_##CAT##_tuple((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)
/*
* Accessor macros to be used with HeapTuple pointers.
diff --git a/src/include/catalog/pg_aggregate.h b/src/include/catalog/pg_aggregate.h
index 593da9f76a..dae5116e2f 100644
--- a/src/include/catalog/pg_aggregate.h
+++ b/src/include/catalog/pg_aggregate.h
@@ -108,6 +108,9 @@ CATALOG(pg_aggregate,2600,AggregateRelationId)
*/
typedef FormData_pg_aggregate *Form_pg_aggregate;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_aggregate_deform.h"
+
DECLARE_TOAST(pg_aggregate, 4159, 4160);
DECLARE_UNIQUE_INDEX_PKEY(pg_aggregate_fnoid_index, 2650, AggregateFnoidIndexId, on pg_aggregate using btree(aggfnoid oid_ops));
diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h
index 50a68fe4c3..c3dcb48184 100644
--- a/src/include/catalog/pg_am.h
+++ b/src/include/catalog/pg_am.h
@@ -47,6 +47,9 @@ CATALOG(pg_am,2601,AccessMethodRelationId)
*/
typedef FormData_pg_am *Form_pg_am;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_am_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_am_name_index, 2651, AmNameIndexId, on pg_am using btree(amname name_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_am_oid_index, 2652, AmOidIndexId, on pg_am using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h
index 6c714b61ab..87e83b5760 100644
--- a/src/include/catalog/pg_amop.h
+++ b/src/include/catalog/pg_amop.h
@@ -87,6 +87,9 @@ CATALOG(pg_amop,2602,AccessMethodOperatorRelationId)
*/
typedef FormData_pg_amop *Form_pg_amop;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_amop_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_amop_fam_strat_index, 2653, AccessMethodStrategyIndexId, on pg_amop using btree(amopfamily oid_ops, amoplefttype oid_ops, amoprighttype oid_ops, amopstrategy int2_ops));
DECLARE_UNIQUE_INDEX(pg_amop_opr_fam_index, 2654, AccessMethodOperatorIndexId, on pg_amop using btree(amopopr oid_ops, amoppurpose char_ops, amopfamily oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_amop_oid_index, 2756, AccessMethodOperatorOidIndexId, on pg_amop using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h
index f529fc6053..10026093c8 100644
--- a/src/include/catalog/pg_amproc.h
+++ b/src/include/catalog/pg_amproc.h
@@ -67,6 +67,9 @@ CATALOG(pg_amproc,2603,AccessMethodProcedureRelationId)
*/
typedef FormData_pg_amproc *Form_pg_amproc;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_amproc_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_amproc_fam_proc_index, 2655, AccessMethodProcedureIndexId, on pg_amproc using btree(amprocfamily oid_ops, amproclefttype oid_ops, amprocrighttype oid_ops, amprocnum int2_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_amproc_oid_index, 2757, AccessMethodProcedureOidIndexId, on pg_amproc using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_attrdef.h b/src/include/catalog/pg_attrdef.h
index a21dd3812b..020c70a09e 100644
--- a/src/include/catalog/pg_attrdef.h
+++ b/src/include/catalog/pg_attrdef.h
@@ -48,6 +48,9 @@ CATALOG(pg_attrdef,2604,AttrDefaultRelationId)
*/
typedef FormData_pg_attrdef *Form_pg_attrdef;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_attrdef_deform.h"
+
DECLARE_TOAST(pg_attrdef, 2830, 2831);
DECLARE_UNIQUE_INDEX(pg_attrdef_adrelid_adnum_index, 2656, AttrDefaultIndexId, on pg_attrdef using btree(adrelid oid_ops, adnum int2_ops));
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index 053294c99f..081063afef 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -206,6 +206,9 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
*/
typedef FormData_pg_attribute *Form_pg_attribute;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_attribute_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index, 2658, AttributeRelidNameIndexId, on pg_attribute using btree(attrelid oid_ops, attname name_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_attribute_relid_attnum_index, 2659, AttributeRelidNumIndexId, on pg_attribute using btree(attrelid oid_ops, attnum int2_ops));
diff --git a/src/include/catalog/pg_auth_members.h b/src/include/catalog/pg_auth_members.h
index 1bc027f133..1288694b97 100644
--- a/src/include/catalog/pg_auth_members.h
+++ b/src/include/catalog/pg_auth_members.h
@@ -42,6 +42,9 @@ CATALOG(pg_auth_members,1261,AuthMemRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_
*/
typedef FormData_pg_auth_members *Form_pg_auth_members;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_auth_members_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_auth_members_role_member_index, 2694, AuthMemRoleMemIndexId, on pg_auth_members using btree(roleid oid_ops, member oid_ops));
DECLARE_UNIQUE_INDEX(pg_auth_members_member_role_index, 2695, AuthMemMemRoleIndexId, on pg_auth_members using btree(member oid_ops, roleid oid_ops));
diff --git a/src/include/catalog/pg_authid.h b/src/include/catalog/pg_authid.h
index 3512601c80..08b833198f 100644
--- a/src/include/catalog/pg_authid.h
+++ b/src/include/catalog/pg_authid.h
@@ -55,6 +55,9 @@ CATALOG(pg_authid,1260,AuthIdRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(284
*/
typedef FormData_pg_authid *Form_pg_authid;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_authid_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_authid, 4175, 4176, PgAuthidToastTable, PgAuthidToastIndex);
DECLARE_UNIQUE_INDEX(pg_authid_rolname_index, 2676, AuthIdRolnameIndexId, on pg_authid using btree(rolname name_ops));
diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h
index 3c15df0053..4887ea16bd 100644
--- a/src/include/catalog/pg_cast.h
+++ b/src/include/catalog/pg_cast.h
@@ -56,6 +56,9 @@ CATALOG(pg_cast,2605,CastRelationId)
*/
typedef FormData_pg_cast *Form_pg_cast;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_cast_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_cast_oid_index, 2660, CastOidIndexId, on pg_cast using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_cast_source_target_index, 2661, CastSourceTargetIndexId, on pg_cast using btree(castsource oid_ops, casttarget oid_ops));
diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h
index e1f4eefa22..1405fa07f5 100644
--- a/src/include/catalog/pg_class.h
+++ b/src/include/catalog/pg_class.h
@@ -152,6 +152,9 @@ CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,Relat
*/
typedef FormData_pg_class *Form_pg_class;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_class_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_class_oid_index, 2662, ClassOidIndexId, on pg_class using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_class_relname_nsp_index, 2663, ClassNameNspIndexId, on pg_class using btree(relname name_ops, relnamespace oid_ops));
DECLARE_INDEX(pg_class_tblspc_relfilenode_index, 3455, ClassTblspcRelfilenodeIndexId, on pg_class using btree(reltablespace oid_ops, relfilenode oid_ops));
diff --git a/src/include/catalog/pg_collation.h b/src/include/catalog/pg_collation.h
index 2190ccb5b8..a5f6ab75a1 100644
--- a/src/include/catalog/pg_collation.h
+++ b/src/include/catalog/pg_collation.h
@@ -56,6 +56,9 @@ CATALOG(pg_collation,3456,CollationRelationId)
*/
typedef FormData_pg_collation *Form_pg_collation;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_collation_deform.h"
+
DECLARE_TOAST(pg_collation, 6175, 6176);
DECLARE_UNIQUE_INDEX(pg_collation_name_enc_nsp_index, 3164, CollationNameEncNspIndexId, on pg_collation using btree(collname name_ops, collencoding int4_ops, collnamespace oid_ops));
diff --git a/src/include/catalog/pg_constraint.h b/src/include/catalog/pg_constraint.h
index e7d967f137..184baf88ba 100644
--- a/src/include/catalog/pg_constraint.h
+++ b/src/include/catalog/pg_constraint.h
@@ -164,6 +164,9 @@ CATALOG(pg_constraint,2606,ConstraintRelationId)
*/
typedef FormData_pg_constraint *Form_pg_constraint;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_constraint_deform.h"
+
DECLARE_TOAST(pg_constraint, 2832, 2833);
DECLARE_INDEX(pg_constraint_conname_nsp_index, 2664, ConstraintNameNspIndexId, on pg_constraint using btree(conname name_ops, connamespace oid_ops));
diff --git a/src/include/catalog/pg_conversion.h b/src/include/catalog/pg_conversion.h
index fb26123aa9..b652cc9c8d 100644
--- a/src/include/catalog/pg_conversion.h
+++ b/src/include/catalog/pg_conversion.h
@@ -60,6 +60,9 @@ CATALOG(pg_conversion,2607,ConversionRelationId)
*/
typedef FormData_pg_conversion *Form_pg_conversion;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_conversion_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_conversion_default_index, 2668, ConversionDefaultIndexId, on pg_conversion using btree(connamespace oid_ops, conforencoding int4_ops, contoencoding int4_ops, oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_conversion_name_nsp_index, 2669, ConversionNameNspIndexId, on pg_conversion using btree(conname name_ops, connamespace oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_conversion_oid_index, 2670, ConversionOidIndexId, on pg_conversion using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_database.h b/src/include/catalog/pg_database.h
index 611c95656a..b01375996a 100644
--- a/src/include/catalog/pg_database.h
+++ b/src/include/catalog/pg_database.h
@@ -86,6 +86,9 @@ CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID
*/
typedef FormData_pg_database *Form_pg_database;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_database_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_database, 4177, 4178, PgDatabaseToastTable, PgDatabaseToastIndex);
DECLARE_UNIQUE_INDEX(pg_database_datname_index, 2671, DatabaseNameIndexId, on pg_database using btree(datname name_ops));
diff --git a/src/include/catalog/pg_db_role_setting.h b/src/include/catalog/pg_db_role_setting.h
index 45d478e9e7..519d90dafb 100644
--- a/src/include/catalog/pg_db_role_setting.h
+++ b/src/include/catalog/pg_db_role_setting.h
@@ -46,6 +46,9 @@ CATALOG(pg_db_role_setting,2964,DbRoleSettingRelationId) BKI_SHARED_RELATION
typedef FormData_pg_db_role_setting * Form_pg_db_role_setting;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_db_role_setting_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_db_role_setting, 2966, 2967, PgDbRoleSettingToastTable, PgDbRoleSettingToastIndex);
DECLARE_UNIQUE_INDEX_PKEY(pg_db_role_setting_databaseid_rol_index, 2965, DbRoleSettingDatidRolidIndexId, on pg_db_role_setting using btree(setdatabase oid_ops, setrole oid_ops));
diff --git a/src/include/catalog/pg_default_acl.h b/src/include/catalog/pg_default_acl.h
index 2a79155636..ebd3323930 100644
--- a/src/include/catalog/pg_default_acl.h
+++ b/src/include/catalog/pg_default_acl.h
@@ -49,6 +49,9 @@ CATALOG(pg_default_acl,826,DefaultAclRelationId)
*/
typedef FormData_pg_default_acl *Form_pg_default_acl;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_default_acl_deform.h"
+
DECLARE_TOAST(pg_default_acl, 4143, 4144);
DECLARE_UNIQUE_INDEX(pg_default_acl_role_nsp_obj_index, 827, DefaultAclRoleNspObjIndexId, on pg_default_acl using btree(defaclrole oid_ops, defaclnamespace oid_ops, defaclobjtype char_ops));
diff --git a/src/include/catalog/pg_depend.h b/src/include/catalog/pg_depend.h
index 2f736ecd6c..971718e5f2 100644
--- a/src/include/catalog/pg_depend.h
+++ b/src/include/catalog/pg_depend.h
@@ -71,6 +71,9 @@ CATALOG(pg_depend,2608,DependRelationId)
*/
typedef FormData_pg_depend *Form_pg_depend;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_depend_deform.h"
+
DECLARE_INDEX(pg_depend_depender_index, 2673, DependDependerIndexId, on pg_depend using btree(classid oid_ops, objid oid_ops, objsubid int4_ops));
DECLARE_INDEX(pg_depend_reference_index, 2674, DependReferenceIndexId, on pg_depend using btree(refclassid oid_ops, refobjid oid_ops, refobjsubid int4_ops));
diff --git a/src/include/catalog/pg_description.h b/src/include/catalog/pg_description.h
index 67636ba926..0cb41eabf1 100644
--- a/src/include/catalog/pg_description.h
+++ b/src/include/catalog/pg_description.h
@@ -63,6 +63,9 @@ CATALOG(pg_description,2609,DescriptionRelationId)
*/
typedef FormData_pg_description * Form_pg_description;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_description_deform.h"
+
DECLARE_TOAST(pg_description, 2834, 2835);
DECLARE_UNIQUE_INDEX_PKEY(pg_description_o_c_o_index, 2675, DescriptionObjIndexId, on pg_description using btree(objoid oid_ops, classoid oid_ops, objsubid int4_ops));
diff --git a/src/include/catalog/pg_enum.h b/src/include/catalog/pg_enum.h
index 9c6deddc6a..947368aa96 100644
--- a/src/include/catalog/pg_enum.h
+++ b/src/include/catalog/pg_enum.h
@@ -43,6 +43,9 @@ CATALOG(pg_enum,3501,EnumRelationId)
*/
typedef FormData_pg_enum *Form_pg_enum;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_enum_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_enum_oid_index, 3502, EnumOidIndexId, on pg_enum using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_enum_typid_label_index, 3503, EnumTypIdLabelIndexId, on pg_enum using btree(enumtypid oid_ops, enumlabel name_ops));
DECLARE_UNIQUE_INDEX(pg_enum_typid_sortorder_index, 3534, EnumTypIdSortOrderIndexId, on pg_enum using btree(enumtypid oid_ops, enumsortorder float4_ops));
diff --git a/src/include/catalog/pg_event_trigger.h b/src/include/catalog/pg_event_trigger.h
index 3fe0e8db78..ce3bcab135 100644
--- a/src/include/catalog/pg_event_trigger.h
+++ b/src/include/catalog/pg_event_trigger.h
@@ -49,6 +49,9 @@ CATALOG(pg_event_trigger,3466,EventTriggerRelationId)
*/
typedef FormData_pg_event_trigger *Form_pg_event_trigger;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_event_trigger_deform.h"
+
DECLARE_TOAST(pg_event_trigger, 4145, 4146);
DECLARE_UNIQUE_INDEX(pg_event_trigger_evtname_index, 3467, EventTriggerNameIndexId, on pg_event_trigger using btree(evtname name_ops));
diff --git a/src/include/catalog/pg_extension.h b/src/include/catalog/pg_extension.h
index 43d16d4857..59aeb748a0 100644
--- a/src/include/catalog/pg_extension.h
+++ b/src/include/catalog/pg_extension.h
@@ -51,6 +51,9 @@ CATALOG(pg_extension,3079,ExtensionRelationId)
*/
typedef FormData_pg_extension *Form_pg_extension;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_extension_deform.h"
+
DECLARE_TOAST(pg_extension, 4147, 4148);
DECLARE_UNIQUE_INDEX_PKEY(pg_extension_oid_index, 3080, ExtensionOidIndexId, on pg_extension using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_foreign_data_wrapper.h b/src/include/catalog/pg_foreign_data_wrapper.h
index 86db6546cc..1e1c73b8a9 100644
--- a/src/include/catalog/pg_foreign_data_wrapper.h
+++ b/src/include/catalog/pg_foreign_data_wrapper.h
@@ -50,6 +50,9 @@ CATALOG(pg_foreign_data_wrapper,2328,ForeignDataWrapperRelationId)
*/
typedef FormData_pg_foreign_data_wrapper *Form_pg_foreign_data_wrapper;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_foreign_data_wrapper_deform.h"
+
DECLARE_TOAST(pg_foreign_data_wrapper, 4149, 4150);
DECLARE_UNIQUE_INDEX_PKEY(pg_foreign_data_wrapper_oid_index, 112, ForeignDataWrapperOidIndexId, on pg_foreign_data_wrapper using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_foreign_server.h b/src/include/catalog/pg_foreign_server.h
index dcef33de24..966853bf72 100644
--- a/src/include/catalog/pg_foreign_server.h
+++ b/src/include/catalog/pg_foreign_server.h
@@ -47,6 +47,9 @@ CATALOG(pg_foreign_server,1417,ForeignServerRelationId)
*/
typedef FormData_pg_foreign_server *Form_pg_foreign_server;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_foreign_server_deform.h"
+
DECLARE_TOAST(pg_foreign_server, 4151, 4152);
DECLARE_UNIQUE_INDEX_PKEY(pg_foreign_server_oid_index, 113, ForeignServerOidIndexId, on pg_foreign_server using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_foreign_table.h b/src/include/catalog/pg_foreign_table.h
index 88753cd5f8..4d9101e248 100644
--- a/src/include/catalog/pg_foreign_table.h
+++ b/src/include/catalog/pg_foreign_table.h
@@ -42,6 +42,9 @@ CATALOG(pg_foreign_table,3118,ForeignTableRelationId)
*/
typedef FormData_pg_foreign_table *Form_pg_foreign_table;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_foreign_table_deform.h"
+
DECLARE_TOAST(pg_foreign_table, 4153, 4154);
DECLARE_UNIQUE_INDEX_PKEY(pg_foreign_table_relid_index, 3119, ForeignTableRelidIndexId, on pg_foreign_table using btree(ftrelid oid_ops));
diff --git a/src/include/catalog/pg_index.h b/src/include/catalog/pg_index.h
index f853846ee1..99903d8eff 100644
--- a/src/include/catalog/pg_index.h
+++ b/src/include/catalog/pg_index.h
@@ -69,6 +69,9 @@ CATALOG(pg_index,2610,IndexRelationId) BKI_SCHEMA_MACRO
*/
typedef FormData_pg_index *Form_pg_index;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_index_deform.h"
+
DECLARE_INDEX(pg_index_indrelid_index, 2678, IndexIndrelidIndexId, on pg_index using btree(indrelid oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_index_indexrelid_index, 2679, IndexRelidIndexId, on pg_index using btree(indexrelid oid_ops));
diff --git a/src/include/catalog/pg_inherits.h b/src/include/catalog/pg_inherits.h
index b5a32755a6..c8a25994b7 100644
--- a/src/include/catalog/pg_inherits.h
+++ b/src/include/catalog/pg_inherits.h
@@ -44,6 +44,9 @@ CATALOG(pg_inherits,2611,InheritsRelationId)
*/
typedef FormData_pg_inherits *Form_pg_inherits;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_inherits_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_inherits_relid_seqno_index, 2680, InheritsRelidSeqnoIndexId, on pg_inherits using btree(inhrelid oid_ops, inhseqno int4_ops));
DECLARE_INDEX(pg_inherits_parent_index, 2187, InheritsParentIndexId, on pg_inherits using btree(inhparent oid_ops));
diff --git a/src/include/catalog/pg_init_privs.h b/src/include/catalog/pg_init_privs.h
index c226edc4a4..9697053907 100644
--- a/src/include/catalog/pg_init_privs.h
+++ b/src/include/catalog/pg_init_privs.h
@@ -63,6 +63,9 @@ CATALOG(pg_init_privs,3394,InitPrivsRelationId)
*/
typedef FormData_pg_init_privs * Form_pg_init_privs;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_init_privs_deform.h"
+
DECLARE_TOAST(pg_init_privs, 4155, 4156);
DECLARE_UNIQUE_INDEX_PKEY(pg_init_privs_o_c_o_index, 3395, InitPrivsObjIndexId, on pg_init_privs using btree(objoid oid_ops, classoid oid_ops, objsubid int4_ops));
diff --git a/src/include/catalog/pg_language.h b/src/include/catalog/pg_language.h
index 4b9c259554..8a7dd7eddc 100644
--- a/src/include/catalog/pg_language.h
+++ b/src/include/catalog/pg_language.h
@@ -64,6 +64,9 @@ CATALOG(pg_language,2612,LanguageRelationId)
*/
typedef FormData_pg_language *Form_pg_language;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_language_deform.h"
+
DECLARE_TOAST(pg_language, 4157, 4158);
DECLARE_UNIQUE_INDEX(pg_language_name_index, 2681, LanguageNameIndexId, on pg_language using btree(lanname name_ops));
diff --git a/src/include/catalog/pg_largeobject.h b/src/include/catalog/pg_largeobject.h
index 1fd076d799..c1cf040e00 100644
--- a/src/include/catalog/pg_largeobject.h
+++ b/src/include/catalog/pg_largeobject.h
@@ -44,6 +44,9 @@ CATALOG(pg_largeobject,2613,LargeObjectRelationId)
*/
typedef FormData_pg_largeobject *Form_pg_largeobject;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_largeobject_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_largeobject_loid_pn_index, 2683, LargeObjectLOidPNIndexId, on pg_largeobject using btree(loid oid_ops, pageno int4_ops));
extern Oid LargeObjectCreate(Oid loid);
diff --git a/src/include/catalog/pg_largeobject_metadata.h b/src/include/catalog/pg_largeobject_metadata.h
index ec1c3bf755..22b9b732a9 100644
--- a/src/include/catalog/pg_largeobject_metadata.h
+++ b/src/include/catalog/pg_largeobject_metadata.h
@@ -46,6 +46,9 @@ CATALOG(pg_largeobject_metadata,2995,LargeObjectMetadataRelationId)
*/
typedef FormData_pg_largeobject_metadata *Form_pg_largeobject_metadata;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_largeobject_metadata_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_largeobject_metadata_oid_index, 2996, LargeObjectMetadataOidIndexId, on pg_largeobject_metadata using btree(oid oid_ops));
#endif /* PG_LARGEOBJECT_METADATA_H */
diff --git a/src/include/catalog/pg_namespace.h b/src/include/catalog/pg_namespace.h
index ba56e44d61..d220737615 100644
--- a/src/include/catalog/pg_namespace.h
+++ b/src/include/catalog/pg_namespace.h
@@ -51,6 +51,9 @@ CATALOG(pg_namespace,2615,NamespaceRelationId)
*/
typedef FormData_pg_namespace *Form_pg_namespace;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_namespace_deform.h"
+
DECLARE_TOAST(pg_namespace, 4163, 4164);
DECLARE_UNIQUE_INDEX(pg_namespace_nspname_index, 2684, NamespaceNameIndexId, on pg_namespace using btree(nspname name_ops));
diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h
index 3a3a19b83b..91faa3eebf 100644
--- a/src/include/catalog/pg_opclass.h
+++ b/src/include/catalog/pg_opclass.h
@@ -82,6 +82,9 @@ CATALOG(pg_opclass,2616,OperatorClassRelationId)
*/
typedef FormData_pg_opclass *Form_pg_opclass;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_opclass_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_opclass_am_name_nsp_index, 2686, OpclassAmNameNspIndexId, on pg_opclass using btree(opcmethod oid_ops, opcname name_ops, opcnamespace oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_opclass_oid_index, 2687, OpclassOidIndexId, on pg_opclass using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h
index 51263f550f..873b4f73d7 100644
--- a/src/include/catalog/pg_operator.h
+++ b/src/include/catalog/pg_operator.h
@@ -82,6 +82,9 @@ CATALOG(pg_operator,2617,OperatorRelationId)
*/
typedef FormData_pg_operator *Form_pg_operator;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_operator_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_operator_oid_index, 2688, OperatorOidIndexId, on pg_operator using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_operator_oprname_l_r_n_index, 2689, OperatorNameNspIndexId, on pg_operator using btree(oprname name_ops, oprleft oid_ops, oprright oid_ops, oprnamespace oid_ops));
diff --git a/src/include/catalog/pg_opfamily.h b/src/include/catalog/pg_opfamily.h
index 8dc9ce01bb..7339fd9cd2 100644
--- a/src/include/catalog/pg_opfamily.h
+++ b/src/include/catalog/pg_opfamily.h
@@ -50,6 +50,9 @@ CATALOG(pg_opfamily,2753,OperatorFamilyRelationId)
*/
typedef FormData_pg_opfamily *Form_pg_opfamily;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_opfamily_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_opfamily_am_name_nsp_index, 2754, OpfamilyAmNameNspIndexId, on pg_opfamily using btree(opfmethod oid_ops, opfname name_ops, opfnamespace oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_opfamily_oid_index, 2755, OpfamilyOidIndexId, on pg_opfamily using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_parameter_acl.h b/src/include/catalog/pg_parameter_acl.h
index 4bd52c2d7d..210fd7b2b8 100644
--- a/src/include/catalog/pg_parameter_acl.h
+++ b/src/include/catalog/pg_parameter_acl.h
@@ -48,6 +48,9 @@ CATALOG(pg_parameter_acl,6243,ParameterAclRelationId) BKI_SHARED_RELATION
*/
typedef FormData_pg_parameter_acl * Form_pg_parameter_acl;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_parameter_acl_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_parameter_acl, 6244, 6245, PgParameterAclToastTable, PgParameterAclToastIndex);
DECLARE_UNIQUE_INDEX(pg_parameter_acl_parname_index, 6246, ParameterAclParnameIndexId, on pg_parameter_acl using btree(parname text_ops));
diff --git a/src/include/catalog/pg_partitioned_table.h b/src/include/catalog/pg_partitioned_table.h
index 9b78f84cd5..f2fd24794d 100644
--- a/src/include/catalog/pg_partitioned_table.h
+++ b/src/include/catalog/pg_partitioned_table.h
@@ -64,6 +64,9 @@ CATALOG(pg_partitioned_table,3350,PartitionedRelationId)
*/
typedef FormData_pg_partitioned_table *Form_pg_partitioned_table;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_partitioned_table_deform.h"
+
DECLARE_TOAST(pg_partitioned_table, 4165, 4166);
DECLARE_UNIQUE_INDEX_PKEY(pg_partitioned_table_partrelid_index, 3351, PartitionedRelidIndexId, on pg_partitioned_table using btree(partrelid oid_ops));
diff --git a/src/include/catalog/pg_policy.h b/src/include/catalog/pg_policy.h
index 56b0ea100b..3c294d04f1 100644
--- a/src/include/catalog/pg_policy.h
+++ b/src/include/catalog/pg_policy.h
@@ -50,6 +50,9 @@ CATALOG(pg_policy,3256,PolicyRelationId)
*/
typedef FormData_pg_policy *Form_pg_policy;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_policy_deform.h"
+
DECLARE_TOAST(pg_policy, 4167, 4168);
DECLARE_UNIQUE_INDEX_PKEY(pg_policy_oid_index, 3257, PolicyOidIndexId, on pg_policy using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 76310d4cc9..362edeac08 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -135,6 +135,9 @@ CATALOG(pg_proc,1255,ProcedureRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81,Proce
*/
typedef FormData_pg_proc *Form_pg_proc;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_proc_deform.h"
+
DECLARE_TOAST(pg_proc, 2836, 2837);
DECLARE_UNIQUE_INDEX_PKEY(pg_proc_oid_index, 2690, ProcedureOidIndexId, on pg_proc using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_publication.h b/src/include/catalog/pg_publication.h
index 48205ba429..11106a7227 100644
--- a/src/include/catalog/pg_publication.h
+++ b/src/include/catalog/pg_publication.h
@@ -63,6 +63,9 @@ CATALOG(pg_publication,6104,PublicationRelationId)
*/
typedef FormData_pg_publication *Form_pg_publication;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_publication_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_publication_oid_index, 6110, PublicationObjectIndexId, on pg_publication using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_publication_pubname_index, 6111, PublicationNameIndexId, on pg_publication using btree(pubname name_ops));
diff --git a/src/include/catalog/pg_publication_namespace.h b/src/include/catalog/pg_publication_namespace.h
index d166600b26..930050358f 100644
--- a/src/include/catalog/pg_publication_namespace.h
+++ b/src/include/catalog/pg_publication_namespace.h
@@ -41,6 +41,9 @@ CATALOG(pg_publication_namespace,6237,PublicationNamespaceRelationId)
*/
typedef FormData_pg_publication_namespace *Form_pg_publication_namespace;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_publication_namespace_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_publication_namespace_oid_index, 6238, PublicationNamespaceObjectIndexId, on pg_publication_namespace using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_publication_namespace_pnnspid_pnpubid_index, 6239, PublicationNamespacePnnspidPnpubidIndexId, on pg_publication_namespace using btree(pnnspid oid_ops, pnpubid oid_ops));
diff --git a/src/include/catalog/pg_publication_rel.h b/src/include/catalog/pg_publication_rel.h
index ecd3739f1a..c0cd7dc555 100644
--- a/src/include/catalog/pg_publication_rel.h
+++ b/src/include/catalog/pg_publication_rel.h
@@ -45,6 +45,9 @@ CATALOG(pg_publication_rel,6106,PublicationRelRelationId)
*/
typedef FormData_pg_publication_rel *Form_pg_publication_rel;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_publication_rel_deform.h"
+
DECLARE_TOAST(pg_publication_rel, 6228, 6229);
DECLARE_UNIQUE_INDEX_PKEY(pg_publication_rel_oid_index, 6112, PublicationRelObjectIndexId, on pg_publication_rel using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_range.h b/src/include/catalog/pg_range.h
index faa57e8cea..a1979f7484 100644
--- a/src/include/catalog/pg_range.h
+++ b/src/include/catalog/pg_range.h
@@ -57,6 +57,9 @@ CATALOG(pg_range,3541,RangeRelationId)
*/
typedef FormData_pg_range *Form_pg_range;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_range_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_range_rngtypid_index, 3542, RangeTypidIndexId, on pg_range using btree(rngtypid oid_ops));
DECLARE_UNIQUE_INDEX(pg_range_rngmultitypid_index, 2228, RangeMultirangeTypidIndexId, on pg_range using btree(rngmultitypid oid_ops));
diff --git a/src/include/catalog/pg_replication_origin.h b/src/include/catalog/pg_replication_origin.h
index 3b11cd21cb..7eb9063ac0 100644
--- a/src/include/catalog/pg_replication_origin.h
+++ b/src/include/catalog/pg_replication_origin.h
@@ -54,6 +54,9 @@ CATALOG(pg_replication_origin,6000,ReplicationOriginRelationId) BKI_SHARED_RELAT
typedef FormData_pg_replication_origin *Form_pg_replication_origin;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_replication_origin_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_replication_origin, 4181, 4182, PgReplicationOriginToastTable, PgReplicationOriginToastIndex);
DECLARE_UNIQUE_INDEX_PKEY(pg_replication_origin_roiident_index, 6001, ReplicationOriginIdentIndex, on pg_replication_origin using btree(roident oid_ops));
diff --git a/src/include/catalog/pg_rewrite.h b/src/include/catalog/pg_rewrite.h
index c647f26aca..cace6f2a28 100644
--- a/src/include/catalog/pg_rewrite.h
+++ b/src/include/catalog/pg_rewrite.h
@@ -51,6 +51,9 @@ CATALOG(pg_rewrite,2618,RewriteRelationId)
*/
typedef FormData_pg_rewrite *Form_pg_rewrite;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_rewrite_deform.h"
+
DECLARE_TOAST(pg_rewrite, 2838, 2839);
DECLARE_UNIQUE_INDEX_PKEY(pg_rewrite_oid_index, 2692, RewriteOidIndexId, on pg_rewrite using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_sequence.h b/src/include/catalog/pg_sequence.h
index 82b35aa65b..946d336174 100644
--- a/src/include/catalog/pg_sequence.h
+++ b/src/include/catalog/pg_sequence.h
@@ -39,6 +39,9 @@ CATALOG(pg_sequence,2224,SequenceRelationId)
*/
typedef FormData_pg_sequence *Form_pg_sequence;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_sequence_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_sequence_seqrelid_index, 5002, SequenceRelidIndexId, on pg_sequence using btree(seqrelid oid_ops));
#endif /* PG_SEQUENCE_H */
diff --git a/src/include/catalog/pg_shdepend.h b/src/include/catalog/pg_shdepend.h
index 8119b28e44..68e5fc2021 100644
--- a/src/include/catalog/pg_shdepend.h
+++ b/src/include/catalog/pg_shdepend.h
@@ -72,6 +72,9 @@ CATALOG(pg_shdepend,1214,SharedDependRelationId) BKI_SHARED_RELATION
*/
typedef FormData_pg_shdepend *Form_pg_shdepend;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_shdepend_deform.h"
+
DECLARE_INDEX(pg_shdepend_depender_index, 1232, SharedDependDependerIndexId, on pg_shdepend using btree(dbid oid_ops, classid oid_ops, objid oid_ops, objsubid int4_ops));
DECLARE_INDEX(pg_shdepend_reference_index, 1233, SharedDependReferenceIndexId, on pg_shdepend using btree(refclassid oid_ops, refobjid oid_ops));
diff --git a/src/include/catalog/pg_shdescription.h b/src/include/catalog/pg_shdescription.h
index da2b9f6fdf..5bd5d777f8 100644
--- a/src/include/catalog/pg_shdescription.h
+++ b/src/include/catalog/pg_shdescription.h
@@ -55,6 +55,9 @@ CATALOG(pg_shdescription,2396,SharedDescriptionRelationId) BKI_SHARED_RELATION
*/
typedef FormData_pg_shdescription * Form_pg_shdescription;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_shdescription_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_shdescription, 2846, 2847, PgShdescriptionToastTable, PgShdescriptionToastIndex);
DECLARE_UNIQUE_INDEX_PKEY(pg_shdescription_o_c_index, 2397, SharedDescriptionObjIndexId, on pg_shdescription using btree(objoid oid_ops, classoid oid_ops));
diff --git a/src/include/catalog/pg_shseclabel.h b/src/include/catalog/pg_shseclabel.h
index fc1b97f46f..6cc96bc66e 100644
--- a/src/include/catalog/pg_shseclabel.h
+++ b/src/include/catalog/pg_shseclabel.h
@@ -39,6 +39,9 @@ CATALOG(pg_shseclabel,3592,SharedSecLabelRelationId) BKI_SHARED_RELATION BKI_ROW
typedef FormData_pg_shseclabel * Form_pg_shseclabel;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_shseclabel_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_shseclabel, 4060, 4061, PgShseclabelToastTable, PgShseclabelToastIndex);
DECLARE_UNIQUE_INDEX_PKEY(pg_shseclabel_object_index, 3593, SharedSecLabelObjectIndexId, on pg_shseclabel using btree(objoid oid_ops, classoid oid_ops, provider text_ops));
diff --git a/src/include/catalog/pg_statistic.h b/src/include/catalog/pg_statistic.h
index cdf7448139..dd1c324af8 100644
--- a/src/include/catalog/pg_statistic.h
+++ b/src/include/catalog/pg_statistic.h
@@ -134,6 +134,9 @@ CATALOG(pg_statistic,2619,StatisticRelationId)
*/
typedef FormData_pg_statistic *Form_pg_statistic;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_statistic_deform.h"
+
DECLARE_TOAST(pg_statistic, 2840, 2841);
DECLARE_UNIQUE_INDEX_PKEY(pg_statistic_relid_att_inh_index, 2696, StatisticRelidAttnumInhIndexId, on pg_statistic using btree(starelid oid_ops, staattnum int2_ops, stainherit bool_ops));
diff --git a/src/include/catalog/pg_statistic_ext.h b/src/include/catalog/pg_statistic_ext.h
index b8520ba923..d3b0ae8fde 100644
--- a/src/include/catalog/pg_statistic_ext.h
+++ b/src/include/catalog/pg_statistic_ext.h
@@ -68,6 +68,9 @@ CATALOG(pg_statistic_ext,3381,StatisticExtRelationId)
*/
typedef FormData_pg_statistic_ext *Form_pg_statistic_ext;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_statistic_ext_deform.h"
+
DECLARE_TOAST(pg_statistic_ext, 3439, 3440);
DECLARE_UNIQUE_INDEX_PKEY(pg_statistic_ext_oid_index, 3380, StatisticExtOidIndexId, on pg_statistic_ext using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_statistic_ext_data.h b/src/include/catalog/pg_statistic_ext_data.h
index 0ea3c41b5b..dc4461a0cf 100644
--- a/src/include/catalog/pg_statistic_ext_data.h
+++ b/src/include/catalog/pg_statistic_ext_data.h
@@ -52,6 +52,9 @@ CATALOG(pg_statistic_ext_data,3429,StatisticExtDataRelationId)
*/
typedef FormData_pg_statistic_ext_data *Form_pg_statistic_ext_data;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_statistic_ext_data_deform.h"
+
DECLARE_TOAST(pg_statistic_ext_data, 3430, 3431);
DECLARE_UNIQUE_INDEX_PKEY(pg_statistic_ext_data_stxoid_inh_index, 3433, StatisticExtDataStxoidInhIndexId, on pg_statistic_ext_data using btree(stxoid oid_ops, stxdinherit bool_ops));
diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_subscription.h
index d1260f590c..b3e136e64b 100644
--- a/src/include/catalog/pg_subscription.h
+++ b/src/include/catalog/pg_subscription.h
@@ -92,6 +92,9 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
typedef FormData_pg_subscription *Form_pg_subscription;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_subscription_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_subscription, 4183, 4184, PgSubscriptionToastTable, PgSubscriptionToastIndex);
DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_oid_index, 6114, SubscriptionObjectIndexId, on pg_subscription using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_subscription_rel.h b/src/include/catalog/pg_subscription_rel.h
index 9df99c3418..0ff6a25882 100644
--- a/src/include/catalog/pg_subscription_rel.h
+++ b/src/include/catalog/pg_subscription_rel.h
@@ -49,6 +49,9 @@ CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
typedef FormData_pg_subscription_rel *Form_pg_subscription_rel;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_subscription_rel_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_rel_srrelid_srsubid_index, 6117, SubscriptionRelSrrelidSrsubidIndexId, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));
#ifdef EXPOSE_TO_CLIENT_CODE
diff --git a/src/include/catalog/pg_tablespace.h b/src/include/catalog/pg_tablespace.h
index 572eeeb8a6..74a766f001 100644
--- a/src/include/catalog/pg_tablespace.h
+++ b/src/include/catalog/pg_tablespace.h
@@ -47,6 +47,9 @@ CATALOG(pg_tablespace,1213,TableSpaceRelationId) BKI_SHARED_RELATION
*/
typedef FormData_pg_tablespace *Form_pg_tablespace;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_tablespace_deform.h"
+
DECLARE_TOAST_WITH_MACRO(pg_tablespace, 4185, 4186, PgTablespaceToastTable, PgTablespaceToastIndex);
DECLARE_UNIQUE_INDEX_PKEY(pg_tablespace_oid_index, 2697, TablespaceOidIndexId, on pg_tablespace using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_transform.h b/src/include/catalog/pg_transform.h
index 2a02691510..665e4d0165 100644
--- a/src/include/catalog/pg_transform.h
+++ b/src/include/catalog/pg_transform.h
@@ -42,6 +42,9 @@ CATALOG(pg_transform,3576,TransformRelationId)
*/
typedef FormData_pg_transform *Form_pg_transform;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_transform_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_transform_oid_index, 3574, TransformOidIndexId, on pg_transform using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_transform_type_lang_index, 3575, TransformTypeLangIndexId, on pg_transform using btree(trftype oid_ops, trflang oid_ops));
diff --git a/src/include/catalog/pg_trigger.h b/src/include/catalog/pg_trigger.h
index 194277bca5..bbf6569766 100644
--- a/src/include/catalog/pg_trigger.h
+++ b/src/include/catalog/pg_trigger.h
@@ -79,6 +79,9 @@ CATALOG(pg_trigger,2620,TriggerRelationId)
*/
typedef FormData_pg_trigger *Form_pg_trigger;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_trigger_deform.h"
+
DECLARE_TOAST(pg_trigger, 2336, 2337);
DECLARE_INDEX(pg_trigger_tgconstraint_index, 2699, TriggerConstraintIndexId, on pg_trigger using btree(tgconstraint oid_ops));
diff --git a/src/include/catalog/pg_ts_config.h b/src/include/catalog/pg_ts_config.h
index e5a308475c..6d85628b64 100644
--- a/src/include/catalog/pg_ts_config.h
+++ b/src/include/catalog/pg_ts_config.h
@@ -47,6 +47,9 @@ CATALOG(pg_ts_config,3602,TSConfigRelationId)
typedef FormData_pg_ts_config *Form_pg_ts_config;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_config_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_ts_config_cfgname_index, 3608, TSConfigNameNspIndexId, on pg_ts_config using btree(cfgname name_ops, cfgnamespace oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_ts_config_oid_index, 3712, TSConfigOidIndexId, on pg_ts_config using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_ts_config_map.h b/src/include/catalog/pg_ts_config_map.h
index c10e0c5164..fa4fa584db 100644
--- a/src/include/catalog/pg_ts_config_map.h
+++ b/src/include/catalog/pg_ts_config_map.h
@@ -44,6 +44,9 @@ CATALOG(pg_ts_config_map,3603,TSConfigMapRelationId)
typedef FormData_pg_ts_config_map *Form_pg_ts_config_map;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_config_map_deform.h"
+
DECLARE_UNIQUE_INDEX_PKEY(pg_ts_config_map_index, 3609, TSConfigMapIndexId, on pg_ts_config_map using btree(mapcfg oid_ops, maptokentype int4_ops, mapseqno int4_ops));
#endif /* PG_TS_CONFIG_MAP_H */
diff --git a/src/include/catalog/pg_ts_dict.h b/src/include/catalog/pg_ts_dict.h
index 4b6188f4fa..6311d702c0 100644
--- a/src/include/catalog/pg_ts_dict.h
+++ b/src/include/catalog/pg_ts_dict.h
@@ -51,6 +51,9 @@ CATALOG(pg_ts_dict,3600,TSDictionaryRelationId)
typedef FormData_pg_ts_dict *Form_pg_ts_dict;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_dict_deform.h"
+
DECLARE_TOAST(pg_ts_dict, 4169, 4170);
DECLARE_UNIQUE_INDEX(pg_ts_dict_dictname_index, 3604, TSDictionaryNameNspIndexId, on pg_ts_dict using btree(dictname name_ops, dictnamespace oid_ops));
diff --git a/src/include/catalog/pg_ts_parser.h b/src/include/catalog/pg_ts_parser.h
index c2d474dca7..4f2602ccac 100644
--- a/src/include/catalog/pg_ts_parser.h
+++ b/src/include/catalog/pg_ts_parser.h
@@ -54,6 +54,9 @@ CATALOG(pg_ts_parser,3601,TSParserRelationId)
typedef FormData_pg_ts_parser *Form_pg_ts_parser;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_parser_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_ts_parser_prsname_index, 3606, TSParserNameNspIndexId, on pg_ts_parser using btree(prsname name_ops, prsnamespace oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_ts_parser_oid_index, 3607, TSParserOidIndexId, on pg_ts_parser using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_ts_template.h b/src/include/catalog/pg_ts_template.h
index 2a553fef52..f30f5008dc 100644
--- a/src/include/catalog/pg_ts_template.h
+++ b/src/include/catalog/pg_ts_template.h
@@ -45,6 +45,9 @@ CATALOG(pg_ts_template,3764,TSTemplateRelationId)
typedef FormData_pg_ts_template *Form_pg_ts_template;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_template_deform.h"
+
DECLARE_UNIQUE_INDEX(pg_ts_template_tmplname_index, 3766, TSTemplateNameNspIndexId, on pg_ts_template using btree(tmplname name_ops, tmplnamespace oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_ts_template_oid_index, 3767, TSTemplateOidIndexId, on pg_ts_template using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index 48a2559137..e31425a2a5 100644
--- a/src/include/catalog/pg_type.h
+++ b/src/include/catalog/pg_type.h
@@ -260,6 +260,9 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati
*/
typedef FormData_pg_type *Form_pg_type;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_type_deform.h"
+
DECLARE_TOAST(pg_type, 4171, 4172);
DECLARE_UNIQUE_INDEX_PKEY(pg_type_oid_index, 2703, TypeOidIndexId, on pg_type using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_user_mapping.h b/src/include/catalog/pg_user_mapping.h
index 56150611be..2f29c6dd23 100644
--- a/src/include/catalog/pg_user_mapping.h
+++ b/src/include/catalog/pg_user_mapping.h
@@ -47,6 +47,9 @@ CATALOG(pg_user_mapping,1418,UserMappingRelationId)
*/
typedef FormData_pg_user_mapping *Form_pg_user_mapping;
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_user_mapping_deform.h"
+
DECLARE_TOAST(pg_user_mapping, 4173, 4174);
DECLARE_UNIQUE_INDEX_PKEY(pg_user_mapping_oid_index, 174, UserMappingOidIndexId, on pg_user_mapping using btree(oid oid_ops));
diff --git a/src/include/commands/sequence.h b/src/include/commands/sequence.h
index d38c0e2388..a3876de82b 100644
--- a/src/include/commands/sequence.h
+++ b/src/include/commands/sequence.h
@@ -31,6 +31,9 @@ typedef struct FormData_pg_sequence_data
typedef FormData_pg_sequence_data *Form_pg_sequence_data;
+/* this is not a real catalog, so define by hand */
+#define Deform_pg_sequence_data_tuple(TUP) (Form_pg_sequence_data) (TUP)
+
/*
* Columns of a sequence relation
*/
--
2.36.1
Hi,
On 2022-07-18 09:46:44 +0700, John Naylor wrote:
I've made a small step in this direction.
Thanks for working on this!
0001 is just boilerplate, same as v1
If we were to go for this, I wonder if we should backpatch the cast containing
version of GESTRUCT for less pain backpatching bugfixes. That'd likely require
using a different name for the cast containing one.
0002 teaches Catalog.pm to export both C attr name and SQL attr name, so we
can use "sizeof".
0003 generates static inline functions that work the same as the current
GETSTRUCT macro, i.e. just cast to the right pointer and return it.
It seems likely that inline functions are going to be too large for
this. There's a lot of GESTRUCTs in a lot of files, emitting a copy of the
function every time doesn't seem great.
current offset is the previous offset plus the previous type length, plus
any alignment padding suitable for the current type (there is none here, so
the alignment aspect is not tested). I'm hoping something like this will be
sufficient for what's in the current structs, but of course will need
additional work when expanding those to include pointers to varlen
attributes. I've not yet inspected the emitted assembly language, but
regression tests pass.
Hm. Wouldn't it make sense to just use the normal tuple deforming routines and
then map the results to the structs?
Greetings,
Andres Freund
On Mon, Jul 18, 2022 at 9:58 AM Andres Freund <andres@anarazel.de> wrote:
0001 is just boilerplate, same as v1
If we were to go for this, I wonder if we should backpatch the cast
containing
version of GESTRUCT for less pain backpatching bugfixes. That'd likely
require
using a different name for the cast containing one.
The new version in this series was meant to be temporary scaffolding, but
in the back of my mind I wondered if we should go ahead and keep the simple
cast for catalogs that have no varlenas or alignment issues. It sounds like
you'd be in favor of that.
0003 generates static inline functions that work the same as the current
GETSTRUCT macro, i.e. just cast to the right pointer and return it.It seems likely that inline functions are going to be too large for
this. There's a lot of GESTRUCTs in a lot of files, emitting a copy of the
function every time doesn't seem great.
Ok.
current offset is the previous offset plus the previous type length,
plus
any alignment padding suitable for the current type (there is none
here, so
the alignment aspect is not tested). I'm hoping something like this
will be
sufficient for what's in the current structs, but of course will need
additional work when expanding those to include pointers to varlen
attributes. I've not yet inspected the emitted assembly language, but
regression tests pass.Hm. Wouldn't it make sense to just use the normal tuple deforming
routines and
then map the results to the structs?
I wasn't sure if they'd be suitable for this, but if they are, that'd make
this easier and more maintainable. I'll look into it.
--
John Naylor
EDB: http://www.enterprisedb.com
I wrote:
On Mon, Jul 18, 2022 at 9:58 AM Andres Freund <andres@anarazel.de> wrote:
Hm. Wouldn't it make sense to just use the normal tuple deforming
routines and
then map the results to the structs?
I wasn't sure if they'd be suitable for this, but if they are, that'd
make this easier and more maintainable. I'll look into it.
This would seem to have its own problems: heap_deform_tuple writes to
passed arrays of datums and bools. The lower level parts like fetchatt and
nocachegetattr return datums, so still need some generated boilerplate.
Some of these also assume they can write cached offsets on a passed tuple
descriptor.
I'm thinking where the first few attributes are fixed length, not null, and
(because of AIX) not double-aligned, we can do a single memcpy on multiple
columns at once. That will still be a common pattern after namedata is
varlen. Otherwise, use helper functions/macros similar to the above but
instead of passing a tuple descriptor, use info we have at compile time.
--
John Naylor
EDB: http://www.enterprisedb.com
Hi,
On 2022-07-19 14:30:34 +0700, John Naylor wrote:
I wrote:
On Mon, Jul 18, 2022 at 9:58 AM Andres Freund <andres@anarazel.de> wrote:
Hm. Wouldn't it make sense to just use the normal tuple deforming
routines and
then map the results to the structs?
I wasn't sure if they'd be suitable for this, but if they are, that'd
make this easier and more maintainable. I'll look into it.
This would seem to have its own problems: heap_deform_tuple writes to
passed arrays of datums and bools. The lower level parts like fetchatt and
nocachegetattr return datums, so still need some generated boilerplate.
Some of these also assume they can write cached offsets on a passed tuple
descriptor.
Sure. But that'll just be a form of conversion we do all over, rather than
encoding low-level data layout details. Basically
struct->member1 = DatumGetInt32(values[0]);
struct->member2 = DatumGetChar(values[1]);
etc.
I'm thinking where the first few attributes are fixed length, not null, and
(because of AIX) not double-aligned, we can do a single memcpy on multiple
columns at once. That will still be a common pattern after namedata is
varlen. Otherwise, use helper functions/macros similar to the above but
instead of passing a tuple descriptor, use info we have at compile time.
I think that might be over-optimizing things. I don't think we do these
conversions at a rate that's high enough to warrant it - the common stuff
should be in relcache etc. It's possible that we might want to optimize the
catcache case specifically - but that'd be more optimizing memory usage than
"conversion" imo.
Greetings,
Andres Freund
On Tue, Jul 19, 2022 at 10:57 PM Andres Freund <andres@anarazel.de> wrote:
Hi,
On 2022-07-19 14:30:34 +0700, John Naylor wrote:
I'm thinking where the first few attributes are fixed length, not null,
and
(because of AIX) not double-aligned, we can do a single memcpy on
multiple
columns at once. That will still be a common pattern after namedata is
varlen. Otherwise, use helper functions/macros similar to the above but
instead of passing a tuple descriptor, use info we have at compile time.I think that might be over-optimizing things. I don't think we do these
conversions at a rate that's high enough to warrant it - the common stuff
should be in relcache etc. It's possible that we might want to optimize
the
catcache case specifically - but that'd be more optimizing memory usage
than
"conversion" imo.
Okay, here is a hackish experiment that applies on top of v2 but also
invalidates some of that earlier work. Since there is already a pg_cast.c,
I demoed a new function there which looks like this:
void
Deform_pg_cast_tuple(Form_pg_cast pg_cast_struct, HeapTuple pg_cast_tuple,
TupleDesc pg_cast_desc)
{
Datum values[Natts_pg_cast];
bool isnull[Natts_pg_cast];
heap_deform_tuple(pg_cast_tuple, pg_cast_desc, values, isnull);
pg_cast_struct->oid = DatumGetObjectId(values[Anum_pg_cast_oid - 1]);
pg_cast_struct->castsource =
DatumGetObjectId(values[Anum_pg_cast_castsource - 1]);
pg_cast_struct->casttarget =
DatumGetObjectId(values[Anum_pg_cast_casttarget - 1]);
pg_cast_struct->castfunc =
DatumGetObjectId(values[Anum_pg_cast_castfunc - 1]);
pg_cast_struct->castcontext =
DatumGetChar(values[Anum_pg_cast_castcontext - 1]);
pg_cast_struct->castmethod =
DatumGetChar(values[Anum_pg_cast_castmethod - 1]);
}
For the general case we can use pg_*_deform.c or something like that, with
extern declarations in the main headers. To get this to work, I had to add
a couple pointless table open/close calls to get the tuple descriptor,
since currently the whole tuple is stored in the syscache, but that's not
good even as a temporary measure. Storing the full struct in the syscache
is a good future step, as noted upthread, but to get there without a bunch
more churn, maybe the above function can copy the tuple descriptor into a
local stack variable from an expanded version of schemapg.h. Once the
deformed structs are stored in caches, I imagine most of the times we want
to deform are when we have the table open, and we can pass the descriptor
as above without additional code.
--
John Naylor
EDB: http://www.enterprisedb.com
Attachments:
deform-pg_cast-using-standard-function.patchapplication/x-patch; name=deform-pg_cast-using-standard-function.patchDownload
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 66e98daad1..cdc26b1118 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -3028,7 +3028,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- GETSTRUCT_MEMCPY(pg_cast, &castForm, tup);
+ GETSTRUCT_MEMCPY(pg_cast, &castForm, tup, RelationGetDescr(castDesc));
appendStringInfo(&buffer, _("cast from %s to %s"),
format_type_be(castForm.castsource),
@@ -4870,7 +4870,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- GETSTRUCT_MEMCPY(pg_cast, &castForm, tup);
+ GETSTRUCT_MEMCPY(pg_cast, &castForm, tup, RelationGetDescr(castRel));
appendStringInfo(&buffer, "(%s AS %s)",
format_type_be_qualified(castForm.castsource),
diff --git a/src/backend/catalog/pg_cast.c b/src/backend/catalog/pg_cast.c
index 1812bb7fcc..83379f3505 100644
--- a/src/backend/catalog/pg_cast.c
+++ b/src/backend/catalog/pg_cast.c
@@ -27,6 +27,23 @@
#include "utils/rel.h"
#include "utils/syscache.h"
+// WIP: #include from generated .c file?
+void
+Deform_pg_cast_tuple(Form_pg_cast pg_cast_struct, HeapTuple pg_cast_tuple, TupleDesc pg_cast_desc)
+{
+ Datum values[Natts_pg_cast];
+ bool isnull[Natts_pg_cast];
+
+ heap_deform_tuple(pg_cast_tuple, pg_cast_desc, values, isnull);
+
+ pg_cast_struct->oid = DatumGetObjectId(values[Anum_pg_cast_oid - 1]);
+ pg_cast_struct->castsource = DatumGetObjectId(values[Anum_pg_cast_castsource - 1]);
+ pg_cast_struct->casttarget = DatumGetObjectId(values[Anum_pg_cast_casttarget - 1]);
+ pg_cast_struct->castfunc = DatumGetObjectId(values[Anum_pg_cast_castfunc - 1]);
+ pg_cast_struct->castcontext = DatumGetChar(values[Anum_pg_cast_castcontext - 1]);
+ pg_cast_struct->castmethod = DatumGetChar(values[Anum_pg_cast_castmethod - 1]);
+}
+
/*
* ----------------------------------------------------------------
* CastCreate
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index 0bd90fd5e8..f4bac9d171 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -30,6 +30,9 @@
#include "utils/lsyscache.h"
#include "utils/syscache.h"
#include "utils/typcache.h"
+// WIP
+#include "access/table.h"
+#include "utils/rel.h"
static Node *coerce_type_typmod(Node *node,
@@ -2997,6 +3000,7 @@ IsBinaryCoercible(Oid srctype, Oid targettype)
HeapTuple tuple;
FormData_pg_cast castForm;
bool result;
+ Relation castDesc;
/* Fast path if same type */
if (srctype == targettype)
@@ -3056,12 +3060,15 @@ IsBinaryCoercible(Oid srctype, Oid targettype)
ObjectIdGetDatum(targettype));
if (!HeapTupleIsValid(tuple))
return false; /* no cast */
- GETSTRUCT_MEMCPY(pg_cast, &castForm, tuple);
+
+ castDesc = table_open(CastRelationId, AccessShareLock); // WIP: this would be better with generated "compact tuple descriptors"
+ GETSTRUCT_MEMCPY(pg_cast, &castForm, tuple, RelationGetDescr(castDesc));
result = (castForm.castmethod == COERCION_METHOD_BINARY &&
castForm.castcontext == COERCION_CODE_IMPLICIT);
ReleaseSysCache(tuple);
+ table_close(castDesc, AccessShareLock); // FIXME
return result;
}
@@ -3123,7 +3130,9 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
FormData_pg_cast castForm;
CoercionContext castcontext;
- GETSTRUCT_MEMCPY(pg_cast, &castForm, tuple);
+ // TODO: the syscache should have the deformed struct instead of the tuple
+ Relation castDesc = table_open(CastRelationId, AccessShareLock);
+ GETSTRUCT_MEMCPY(pg_cast, &castForm, tuple, RelationGetDescr(castDesc));
/* convert char value for castcontext to CoercionContext enum */
switch (castForm.castcontext)
@@ -3167,6 +3176,7 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
}
ReleaseSysCache(tuple);
+ table_close(castDesc, AccessShareLock); // FIXME
}
else
{
@@ -3290,10 +3300,12 @@ find_typmod_coercion_function(Oid typeId,
if (HeapTupleIsValid(tuple))
{
FormData_pg_cast castForm;
+ Relation castDesc = table_open(CastRelationId, AccessShareLock); // WIP
- GETSTRUCT_MEMCPY(pg_cast, &castForm, tuple);
+ GETSTRUCT_MEMCPY(pg_cast, &castForm, tuple, RelationGetDescr(castDesc));
*funcid = castForm.castfunc;
ReleaseSysCache(tuple);
+ table_close(castDesc, AccessShareLock); // FIXME
}
if (!OidIsValid(*funcid))
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index f300030504..ac9ecabc52 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -657,7 +657,7 @@ struct MinimalTupleData
* GETSTRUCT - given a HeapTuple pointer, deform the user data into the passed struct
*/
// WIP: The _MEMCPY suffix is a temporary scaffold to allow partial progress one catalog at a time.
-#define GETSTRUCT_MEMCPY(CAT, STRUCT, TUP) Deform_##CAT##_tuple(STRUCT, (char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)
+#define GETSTRUCT_MEMCPY(CAT, STRUCT, TUP, DESC) Deform_##CAT##_tuple((STRUCT), (TUP), (DESC))
/*
* Accessor macros to be used with HeapTuple pointers.
diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h
index 4887ea16bd..fde557477a 100644
--- a/src/include/catalog/pg_cast.h
+++ b/src/include/catalog/pg_cast.h
@@ -56,9 +56,6 @@ CATALOG(pg_cast,2605,CastRelationId)
*/
typedef FormData_pg_cast *Form_pg_cast;
-/* now that we've defined the struct type, include the deform function */
-#include "catalog/pg_cast_deform.h"
-
DECLARE_UNIQUE_INDEX_PKEY(pg_cast_oid_index, 2660, CastOidIndexId, on pg_cast using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_cast_source_target_index, 2661, CastSourceTargetIndexId, on pg_cast using btree(castsource oid_ops, casttarget oid_ops));
@@ -94,6 +91,7 @@ typedef enum CoercionMethod
#endif /* EXPOSE_TO_CLIENT_CODE */
+extern void Deform_pg_cast_tuple(Form_pg_cast pg_cast_struct, HeapTuple pg_cast_tuple, TupleDesc pg_cast_desc);
extern ObjectAddress CastCreate(Oid sourcetypeid,
Oid targettypeid,
Attached is v3, which is mostly putting Andres's suggestion above (use
heap_deform_tuple) into a code generation context. Everything interesting
is in 0002, and again only touches pg_cast as an experiment. Some design
points which could be debatable:
- I thought individual C files would be a pain for the build process, so I
just dumped the new functions into a single file, with the extern
declarations in the pg_*.h files.
- I used `#include "catalog/pg_cast.h"` just for Form_pg_cast, but maybe a
forward declaration would work.
- To get the struct member assignments, I resorted to a Perl hash to map
the attribute types to the DatumGet* macros. That may not be great, but I
don't have a better idea at the moment.
- I directly called this function for the table scan rather than hide it
behind a new variant of GETSTRUCT as I did before. That seems clearer to me
about the intent.
The syscache use of GETSTRUCT still uses a simple cast of the tuple (for
pg_cast those calls live in parse_coerce.c, which is unchanged from master
in v3). Next step I think is to see about the syscache piece -- teaching a
syscache miss to deform the entire tuple into a struct and store it in the
syscache.
--
John Naylor
EDB: http://www.enterprisedb.com
Attachments:
v3-0002-Generate-pg_cast-function-to-deform-tuples-into-s.patchtext/x-patch; charset=US-ASCII; name=v3-0002-Generate-pg_cast-function-to-deform-tuples-into-s.patchDownload
From 8a5509dcefb0f6cf975d2bd8091f7712f43c5512 Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Mon, 1 Aug 2022 17:42:14 +0700
Subject: [PATCH v3 2/2] Generate pg_cast function to deform tuples into
structs
This catalog presents no challenges for alignment padding, but has
few call sites where deforming is done, so is an easy PoC.
In objectaddress.c, use the generated Deform_pg_cast_tuple()
to copy values to a passed struct. For tuples stored in syscaches,
continue to do a simple cast. A future commit will store the struct
in the caches rather than the tuple, at which point we will need
to teach syscache misses to use the appropriate deforming function
as well.
---
src/backend/catalog/Makefile | 1 +
src/backend/catalog/genbki.pl | 56 ++++++++++++++++++++++++++++-
src/backend/catalog/objectaddress.c | 20 +++++------
src/include/catalog/pg_cast.h | 1 +
4 files changed, 67 insertions(+), 11 deletions(-)
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 89a0221ec9..fe2f8ccfbf 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -17,6 +17,7 @@ OBJS = \
aclchk.o \
catalog.o \
dependency.o \
+ deform_catalog_tuple.o \
heap.o \
index.o \
indexing.o \
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index 17b2c5e3f3..6afd2b8f25 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -405,6 +405,10 @@ my %lookup_kind = (
pg_type => \%typeoids,
encoding => \%encids);
+# Map type to DatumGet* macro
+my %datumget = (
+ oid => 'DatumGetObjectId',
+ char => 'DatumGetChar');
# Open temp files
my $tmpext = ".tmp$$";
@@ -420,6 +424,9 @@ open my $fk_info, '>', $fk_info_file . $tmpext
my $constraints_file = $output_path . 'system_constraints.sql';
open my $constraints, '>', $constraints_file . $tmpext
or die "can't open $constraints_file$tmpext: $!";
+my $deform_file = $output_path . 'deform_catalog_tuple.c';
+open my $deform, '>', $deform_file . $tmpext
+ or die "can't open $deform_file$tmpext: $!";
# Generate postgres.bki and pg_*_d.h headers.
@@ -430,6 +437,32 @@ print $bki "# PostgreSQL $major_version\n";
my %schemapg_entries;
my @tables_needing_macros;
+# Opening boilerplate for deform_catalog_tuple.c
+printf $deform <<EOM;
+/*-------------------------------------------------------------------------
+ *
+ * deform_catalog_tuple.c
+ * Tuple deforming functions for the system catalog. Declarations found
+ * in the individual catalog headers.
+ *
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * NOTES
+ * ******************************
+ * *** DO NOT EDIT THIS FILE! ***
+ * ******************************
+ *
+ * It has been GENERATED by src/backend/catalog/genbki.pl
+ *
+ *-------------------------------------------------------------------------
+ */
+#include "postgres.h"
+
+#include "access/htup_details.h"
+
+EOM
+
# produce output, one catalog at a time
foreach my $catname (@catnames)
{
@@ -463,7 +496,19 @@ foreach my $catname (@catnames)
#define %s_D_H
EOM
+if ($catname eq 'pg_cast') { # WIP
+ printf $deform <<EOM, $catname, $catname, $catname, $catname, $catname, $catname, $catname, $catname, $catname, $catname;
+#include "catalog/%s.h"
+void
+Deform_%s_tuple(Form_%s %s_struct, HeapTuple %s_tuple, TupleDesc %s_desc)
+{
+ Datum values[Natts_%s];
+ bool isnull[Natts_%s];
+
+ heap_deform_tuple(%s_tuple, %s_desc, values, isnull);
+EOM
+}
# Emit OID macros for catalog's OID and rowtype OID, if wanted
printf $def "#define %s %s\n",
$catalog->{relation_oid_macro}, $catalog->{relation_oid}
@@ -538,6 +583,11 @@ EOM
# Emit Anum_* constants
printf $def "#define Anum_%s_%s %s\n", $catname, $attname, $attnum;
+
+ if ($catname eq 'pg_cast') { # WIP
+ printf $deform "\t%s_struct->%s = %s(values[Anum_%s_%s - 1]);\n",
+ $catname, $attname, $datumget{$atttype}, $catname, $attname;
+ }
}
print $bki "\n )\n";
@@ -673,7 +723,9 @@ EOM
print $bki "close $catname\n";
printf $def "\n#endif\t\t\t\t\t\t\t/* %s_D_H */\n", uc $catname;
-
+ if ($catname eq 'pg_cast') { # WIP
+ print $deform "}\n\n";
+ }
# Close and rename definition header
close $def;
Catalog::RenameTempFile($def_file, $tmpext);
@@ -807,12 +859,14 @@ close $bki;
close $schemapg;
close $fk_info;
close $constraints;
+close $deform;
# Finally, rename the completed files into place.
Catalog::RenameTempFile($bkifile, $tmpext);
Catalog::RenameTempFile($schemafile, $tmpext);
Catalog::RenameTempFile($fk_info_file, $tmpext);
Catalog::RenameTempFile($constraints_file, $tmpext);
+Catalog::RenameTempFile($deform_file, $tmpext);
exit($num_errors != 0 ? 1 : 0);
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 4991a76c41..de23836037 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -3003,7 +3003,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
ScanKeyData skey[1];
SysScanDesc rcscan;
HeapTuple tup;
- Form_pg_cast castForm;
+ FormData_pg_cast castForm;
castDesc = table_open(CastRelationId, AccessShareLock);
@@ -3028,11 +3028,11 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- castForm = GETSTRUCT(pg_cast, tup);
+ Deform_pg_cast_tuple(&castForm, tup, RelationGetDescr(castDesc));
appendStringInfo(&buffer, _("cast from %s to %s"),
- format_type_be(castForm->castsource),
- format_type_be(castForm->casttarget));
+ format_type_be(castForm.castsource),
+ format_type_be(castForm.casttarget));
systable_endscan(rcscan);
table_close(castDesc, AccessShareLock);
@@ -4853,7 +4853,7 @@ getObjectIdentityParts(const ObjectAddress *object,
{
Relation castRel;
HeapTuple tup;
- Form_pg_cast castForm;
+ FormData_pg_cast castForm;
castRel = table_open(CastRelationId, AccessShareLock);
@@ -4870,16 +4870,16 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- castForm = GETSTRUCT(pg_cast, tup);
+ Deform_pg_cast_tuple(&castForm, tup, RelationGetDescr(castRel));
appendStringInfo(&buffer, "(%s AS %s)",
- format_type_be_qualified(castForm->castsource),
- format_type_be_qualified(castForm->casttarget));
+ format_type_be_qualified(castForm.castsource),
+ format_type_be_qualified(castForm.casttarget));
if (objname)
{
- *objname = list_make1(format_type_be_qualified(castForm->castsource));
- *objargs = list_make1(format_type_be_qualified(castForm->casttarget));
+ *objname = list_make1(format_type_be_qualified(castForm.castsource));
+ *objargs = list_make1(format_type_be_qualified(castForm.casttarget));
}
table_close(castRel, AccessShareLock);
diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h
index 3c15df0053..fde557477a 100644
--- a/src/include/catalog/pg_cast.h
+++ b/src/include/catalog/pg_cast.h
@@ -91,6 +91,7 @@ typedef enum CoercionMethod
#endif /* EXPOSE_TO_CLIENT_CODE */
+extern void Deform_pg_cast_tuple(Form_pg_cast pg_cast_struct, HeapTuple pg_cast_tuple, TupleDesc pg_cast_desc);
extern ObjectAddress CastCreate(Oid sourcetypeid,
Oid targettypeid,
--
2.36.1
v3-0001-Transform-GETSTRUCT-macro-to-pass-the-catalog-nam.patchtext/x-patch; charset=US-ASCII; name=v3-0001-Transform-GETSTRUCT-macro-to-pass-the-catalog-nam.patchDownload
From 767175da99aa128e0677f43720a766528a1c57cb Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Sat, 9 Jul 2022 12:19:18 +0700
Subject: [PATCH v3 1/2] Transform GETSTRUCT macro to pass the catalog name as
a parameter
Preparatory refactoring per suggestion from Andres Freund
---
contrib/bloom/blvalidate.c | 8 +-
contrib/dblink/dblink.c | 2 +-
contrib/intarray/_int_selfuncs.c | 2 +-
contrib/postgres_fdw/deparse.c | 8 +-
contrib/sepgsql/database.c | 2 +-
contrib/sepgsql/dml.c | 4 +-
contrib/sepgsql/label.c | 10 +-
contrib/sepgsql/proc.c | 6 +-
contrib/sepgsql/relation.c | 12 +-
contrib/sepgsql/schema.c | 2 +-
contrib/tcn/tcn.c | 2 +-
src/backend/access/brin/brin_validate.c | 8 +-
src/backend/access/common/reloptions.c | 2 +-
src/backend/access/common/tupdesc.c | 2 +-
src/backend/access/gin/ginvalidate.c | 8 +-
src/backend/access/gist/gistvalidate.c | 8 +-
src/backend/access/hash/hashvalidate.c | 10 +-
src/backend/access/index/amapi.c | 4 +-
src/backend/access/index/amvalidate.c | 14 +-
src/backend/access/nbtree/nbtvalidate.c | 8 +-
src/backend/access/spgist/spgutils.c | 4 +-
src/backend/access/spgist/spgvalidate.c | 8 +-
src/backend/bootstrap/bootstrap.c | 2 +-
src/backend/catalog/aclchk.c | 118 ++++-----
src/backend/catalog/catalog.c | 2 +-
src/backend/catalog/dependency.c | 4 +-
src/backend/catalog/heap.c | 24 +-
src/backend/catalog/index.c | 40 +--
src/backend/catalog/namespace.c | 40 +--
src/backend/catalog/objectaddress.c | 124 ++++-----
src/backend/catalog/partition.c | 8 +-
src/backend/catalog/pg_aggregate.c | 8 +-
src/backend/catalog/pg_attrdef.c | 14 +-
src/backend/catalog/pg_constraint.c | 28 +-
src/backend/catalog/pg_conversion.c | 2 +-
src/backend/catalog/pg_depend.c | 26 +-
src/backend/catalog/pg_enum.c | 20 +-
src/backend/catalog/pg_inherits.c | 14 +-
src/backend/catalog/pg_operator.c | 8 +-
src/backend/catalog/pg_proc.c | 6 +-
src/backend/catalog/pg_publication.c | 22 +-
src/backend/catalog/pg_shdepend.c | 14 +-
src/backend/catalog/pg_subscription.c | 10 +-
src/backend/catalog/pg_type.c | 6 +-
src/backend/catalog/toasting.c | 2 +-
src/backend/commands/alter.c | 16 +-
src/backend/commands/amcmds.c | 4 +-
src/backend/commands/analyze.c | 2 +-
src/backend/commands/cluster.c | 12 +-
src/backend/commands/collationcmds.c | 10 +-
src/backend/commands/dbcommands.c | 28 +-
src/backend/commands/event_trigger.c | 6 +-
src/backend/commands/extension.c | 14 +-
src/backend/commands/foreigncmds.c | 12 +-
src/backend/commands/functioncmds.c | 22 +-
src/backend/commands/indexcmds.c | 24 +-
src/backend/commands/matview.c | 4 +-
src/backend/commands/opclasscmds.c | 20 +-
src/backend/commands/operatorcmds.c | 4 +-
src/backend/commands/policy.c | 16 +-
src/backend/commands/proclang.c | 2 +-
src/backend/commands/publicationcmds.c | 22 +-
src/backend/commands/schemacmds.c | 8 +-
src/backend/commands/sequence.c | 18 +-
src/backend/commands/statscmds.c | 6 +-
src/backend/commands/subscriptioncmds.c | 8 +-
src/backend/commands/tablecmds.c | 240 +++++++++---------
src/backend/commands/tablespace.c | 10 +-
src/backend/commands/trigger.c | 34 +--
src/backend/commands/tsearchcmds.c | 26 +-
src/backend/commands/typecmds.c | 42 +--
src/backend/commands/user.c | 14 +-
src/backend/commands/vacuum.c | 12 +-
src/backend/commands/variable.c | 4 +-
src/backend/executor/execAmi.c | 2 +-
src/backend/executor/functions.c | 4 +-
src/backend/executor/nodeAgg.c | 4 +-
src/backend/executor/nodeWindowAgg.c | 4 +-
src/backend/executor/spi.c | 2 +-
src/backend/foreign/foreign.c | 14 +-
src/backend/optimizer/plan/planagg.c | 2 +-
src/backend/optimizer/plan/subselect.c | 2 +-
src/backend/optimizer/prep/prepagg.c | 2 +-
src/backend/optimizer/util/appendinfo.c | 2 +-
src/backend/optimizer/util/clauses.c | 14 +-
src/backend/optimizer/util/plancat.c | 8 +-
src/backend/parser/parse_clause.c | 2 +-
src/backend/parser/parse_coerce.c | 12 +-
src/backend/parser/parse_func.c | 6 +-
src/backend/parser/parse_oper.c | 10 +-
src/backend/parser/parse_relation.c | 2 +-
src/backend/parser/parse_type.c | 32 +--
src/backend/parser/parse_utilcmd.c | 22 +-
src/backend/postmaster/autovacuum.c | 20 +-
src/backend/replication/logical/launcher.c | 2 +-
src/backend/replication/logical/origin.c | 4 +-
src/backend/replication/logical/proto.c | 4 +-
src/backend/replication/logical/worker.c | 2 +-
src/backend/rewrite/rewriteDefine.c | 10 +-
src/backend/rewrite/rewriteRemove.c | 2 +-
src/backend/rewrite/rewriteSupport.c | 4 +-
src/backend/statistics/extended_stats.c | 6 +-
src/backend/storage/large_object/inv_api.c | 8 +-
src/backend/tcop/fastpath.c | 2 +-
src/backend/tsearch/ts_selfuncs.c | 2 +-
src/backend/utils/adt/acl.c | 16 +-
src/backend/utils/adt/amutils.c | 4 +-
src/backend/utils/adt/array_selfuncs.c | 4 +-
src/backend/utils/adt/dbsize.c | 4 +-
src/backend/utils/adt/domains.c | 2 +-
src/backend/utils/adt/enum.c | 16 +-
src/backend/utils/adt/format_type.c | 4 +-
src/backend/utils/adt/jsonfuncs.c | 2 +-
src/backend/utils/adt/like_support.c | 2 +-
.../utils/adt/multirangetypes_selfuncs.c | 2 +-
src/backend/utils/adt/network_selfuncs.c | 10 +-
src/backend/utils/adt/pg_locale.c | 4 +-
src/backend/utils/adt/rangetypes_selfuncs.c | 2 +-
src/backend/utils/adt/regproc.c | 22 +-
src/backend/utils/adt/ri_triggers.c | 6 +-
src/backend/utils/adt/ruleutils.c | 54 ++--
src/backend/utils/adt/selfuncs.c | 28 +-
src/backend/utils/adt/xml.c | 4 +-
src/backend/utils/cache/evtcache.c | 2 +-
src/backend/utils/cache/inval.c | 10 +-
src/backend/utils/cache/lsyscache.c | 196 +++++++-------
src/backend/utils/cache/partcache.c | 4 +-
src/backend/utils/cache/relcache.c | 44 ++--
src/backend/utils/cache/relfilenumbermap.c | 2 +-
src/backend/utils/cache/syscache.c | 4 +-
src/backend/utils/cache/ts_cache.c | 12 +-
src/backend/utils/cache/typcache.c | 12 +-
src/backend/utils/fmgr/fmgr.c | 18 +-
src/backend/utils/fmgr/funcapi.c | 6 +-
src/backend/utils/init/miscinit.c | 6 +-
src/backend/utils/init/postinit.c | 10 +-
src/backend/utils/misc/rls.c | 2 +-
src/backend/utils/misc/superuser.c | 2 +-
src/include/access/htup_details.h | 2 +-
src/pl/plperl/plperl.c | 10 +-
src/pl/plpgsql/src/pl_comp.c | 14 +-
src/pl/plpgsql/src/pl_handler.c | 2 +-
src/pl/plpython/plpy_main.c | 2 +-
src/pl/plpython/plpy_procedure.c | 6 +-
src/pl/tcl/pltcl.c | 8 +-
src/test/modules/plsample/plsample.c | 8 +-
146 files changed, 1048 insertions(+), 1048 deletions(-)
diff --git a/contrib/bloom/blvalidate.c b/contrib/bloom/blvalidate.c
index 333a35d377..fc9911d6bf 100644
--- a/contrib/bloom/blvalidate.c
+++ b/contrib/bloom/blvalidate.c
@@ -52,7 +52,7 @@ blvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -65,7 +65,7 @@ blvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -77,7 +77,7 @@ blvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/*
@@ -138,7 +138,7 @@ blvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* Check it's allowed strategy for bloom */
if (oprform->amopstrategy < 1 ||
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index e323fdd0e6..faa2a07da2 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -2075,7 +2075,7 @@ get_pkey_attnames(Relation rel, int16 *indnkeyatts)
while (HeapTupleIsValid(indexTuple = systable_getnext(scan)))
{
- Form_pg_index index = (Form_pg_index) GETSTRUCT(indexTuple);
+ Form_pg_index index = GETSTRUCT(pg_index, indexTuple);
/* we're only interested if it is the primary key */
if (index->indisprimary)
diff --git a/contrib/intarray/_int_selfuncs.c b/contrib/intarray/_int_selfuncs.c
index 3d8ff6781b..a66d5fee92 100644
--- a/contrib/intarray/_int_selfuncs.c
+++ b/contrib/intarray/_int_selfuncs.c
@@ -191,7 +191,7 @@ _int_matchsel(PG_FUNCTION_ARGS)
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
nullfrac = stats->stanullfrac;
/*
diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c
index a9766f9734..f709d3d2a2 100644
--- a/contrib/postgres_fdw/deparse.c
+++ b/contrib/postgres_fdw/deparse.c
@@ -3077,7 +3077,7 @@ deparseOpExpr(OpExpr *node, deparse_expr_cxt *context)
tuple = SearchSysCache1(OPEROID, ObjectIdGetDatum(node->opno));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for operator %u", node->opno);
- form = (Form_pg_operator) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_operator, tuple);
oprkind = form->oprkind;
/* Sanity check. */
@@ -3252,7 +3252,7 @@ deparseScalarArrayOpExpr(ScalarArrayOpExpr *node, deparse_expr_cxt *context)
tuple = SearchSysCache1(OPEROID, ObjectIdGetDatum(node->opno));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for operator %u", node->opno);
- form = (Form_pg_operator) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_operator, tuple);
/* Sanity check. */
Assert(list_length(node->args) == 2);
@@ -3591,7 +3591,7 @@ appendOrderBySuffix(Oid sortop, Oid sortcoltype, bool nulls_first,
opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(sortop));
if (!HeapTupleIsValid(opertup))
elog(ERROR, "cache lookup failed for operator %u", sortop);
- operform = (Form_pg_operator) GETSTRUCT(opertup);
+ operform = GETSTRUCT(pg_operator, opertup);
deparseOperatorName(buf, operform);
ReleaseSysCache(opertup);
}
@@ -3806,7 +3806,7 @@ appendFunctionName(Oid funcid, deparse_expr_cxt *context)
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
/* Print schema name only if it's not pg_catalog */
if (procform->pronamespace != PG_CATALOG_NAMESPACE)
diff --git a/contrib/sepgsql/database.c b/contrib/sepgsql/database.c
index dce97859f4..a73d600cb8 100644
--- a/contrib/sepgsql/database.c
+++ b/contrib/sepgsql/database.c
@@ -89,7 +89,7 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for database %u", databaseId);
- datForm = (Form_pg_database) GETSTRUCT(tuple);
+ datForm = GETSTRUCT(pg_database, tuple);
ncontext = sepgsql_compute_create(sepgsql_get_client_label(),
tcontext,
diff --git a/contrib/sepgsql/dml.c b/contrib/sepgsql/dml.c
index 3bb98dfb06..114a46c2db 100644
--- a/contrib/sepgsql/dml.c
+++ b/contrib/sepgsql/dml.c
@@ -52,7 +52,7 @@ fixup_whole_row_references(Oid relOid, Bitmapset *columns)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- natts = ((Form_pg_class) GETSTRUCT(tuple))->relnatts;
+ natts = (GETSTRUCT(pg_class, tuple))->relnatts;
ReleaseSysCache(tuple);
/* remove bit 0 from column set, add in all the non-dropped columns */
@@ -67,7 +67,7 @@ fixup_whole_row_references(Oid relOid, Bitmapset *columns)
if (!HeapTupleIsValid(tuple))
continue; /* unexpected case, should we error? */
- if (!((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
+ if (!(GETSTRUCT(pg_attribute, tuple))->attisdropped)
{
index = attno - FirstLowInvalidHeapAttributeNumber;
result = bms_add_member(result, index);
diff --git a/contrib/sepgsql/label.c b/contrib/sepgsql/label.c
index e4c98b7eae..a7dd60fb90 100644
--- a/contrib/sepgsql/label.c
+++ b/contrib/sepgsql/label.c
@@ -733,7 +733,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
switch (catalogId)
{
case DatabaseRelationId:
- datForm = (Form_pg_database) GETSTRUCT(tuple);
+ datForm = GETSTRUCT(pg_database, tuple);
objtype = SELABEL_DB_DATABASE;
@@ -746,7 +746,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
break;
case NamespaceRelationId:
- nspForm = (Form_pg_namespace) GETSTRUCT(tuple);
+ nspForm = GETSTRUCT(pg_namespace, tuple);
objtype = SELABEL_DB_SCHEMA;
@@ -760,7 +760,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
break;
case RelationRelationId:
- relForm = (Form_pg_class) GETSTRUCT(tuple);
+ relForm = GETSTRUCT(pg_class, tuple);
if (relForm->relkind == RELKIND_RELATION ||
relForm->relkind == RELKIND_PARTITIONED_TABLE)
@@ -785,7 +785,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
break;
case AttributeRelationId:
- attForm = (Form_pg_attribute) GETSTRUCT(tuple);
+ attForm = GETSTRUCT(pg_attribute, tuple);
if (get_rel_relkind(attForm->attrelid) != RELKIND_RELATION &&
get_rel_relkind(attForm->attrelid) != RELKIND_PARTITIONED_TABLE)
@@ -809,7 +809,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
break;
case ProcedureRelationId:
- proForm = (Form_pg_proc) GETSTRUCT(tuple);
+ proForm = GETSTRUCT(pg_proc, tuple);
objtype = SELABEL_DB_PROCEDURE;
diff --git a/contrib/sepgsql/proc.c b/contrib/sepgsql/proc.c
index 45f006ed2a..54446cb02d 100644
--- a/contrib/sepgsql/proc.c
+++ b/contrib/sepgsql/proc.c
@@ -68,7 +68,7 @@ sepgsql_proc_post_create(Oid functionId)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for function %u", functionId);
- proForm = (Form_pg_proc) GETSTRUCT(tuple);
+ proForm = GETSTRUCT(pg_proc, tuple);
/*
* check db_schema:{add_name} permission of the namespace
@@ -260,7 +260,7 @@ sepgsql_proc_setattr(Oid functionId)
newtup = systable_getnext(sscan);
if (!HeapTupleIsValid(newtup))
elog(ERROR, "could not find tuple for function %u", functionId);
- newform = (Form_pg_proc) GETSTRUCT(newtup);
+ newform = GETSTRUCT(pg_proc, newtup);
/*
* Fetch older catalog
@@ -268,7 +268,7 @@ sepgsql_proc_setattr(Oid functionId)
oldtup = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId));
if (!HeapTupleIsValid(oldtup))
elog(ERROR, "cache lookup failed for function %u", functionId);
- oldform = (Form_pg_proc) GETSTRUCT(oldtup);
+ oldform = GETSTRUCT(pg_proc, oldtup);
/*
* Does this ALTER command takes operation to namespace?
diff --git a/contrib/sepgsql/relation.c b/contrib/sepgsql/relation.c
index 8767988c4d..1d79397448 100644
--- a/contrib/sepgsql/relation.c
+++ b/contrib/sepgsql/relation.c
@@ -84,7 +84,7 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
elog(ERROR, "could not find tuple for column %d of relation %u",
attnum, relOid);
- attForm = (Form_pg_attribute) GETSTRUCT(tuple);
+ attForm = GETSTRUCT(pg_attribute, tuple);
scontext = sepgsql_get_client_label();
tcontext = sepgsql_get_label(RelationRelationId, relOid, 0);
@@ -271,7 +271,7 @@ sepgsql_relation_post_create(Oid relOid)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for relation %u", relOid);
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/* ignore indexes on toast tables */
if (classForm->relkind == RELKIND_INDEX &&
@@ -368,7 +368,7 @@ sepgsql_relation_post_create(Oid relOid)
while (HeapTupleIsValid(atup = systable_getnext(ascan)))
{
- attForm = (Form_pg_attribute) GETSTRUCT(atup);
+ attForm = GETSTRUCT(pg_attribute, atup);
resetStringInfo(&audit_name);
appendStringInfo(&audit_name, "%s.%s.%s",
@@ -494,7 +494,7 @@ sepgsql_relation_drop(Oid relOid)
for (i = 0; i < attrList->n_members; i++)
{
atttup = &attrList->members[i]->tuple;
- attForm = (Form_pg_attribute) GETSTRUCT(atttup);
+ attForm = GETSTRUCT(pg_attribute, atttup);
if (attForm->attisdropped)
continue;
@@ -662,7 +662,7 @@ sepgsql_relation_setattr(Oid relOid)
newtup = systable_getnext(sscan);
if (!HeapTupleIsValid(newtup))
elog(ERROR, "could not find tuple for relation %u", relOid);
- newform = (Form_pg_class) GETSTRUCT(newtup);
+ newform = GETSTRUCT(pg_class, newtup);
/*
* Fetch older catalog
@@ -670,7 +670,7 @@ sepgsql_relation_setattr(Oid relOid)
oldtup = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(oldtup))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- oldform = (Form_pg_class) GETSTRUCT(oldtup);
+ oldform = GETSTRUCT(pg_class, oldtup);
/*
* Does this ALTER command takes operation to namespace?
diff --git a/contrib/sepgsql/schema.c b/contrib/sepgsql/schema.c
index fecd02f07a..28c6cb3d03 100644
--- a/contrib/sepgsql/schema.c
+++ b/contrib/sepgsql/schema.c
@@ -67,7 +67,7 @@ sepgsql_schema_post_create(Oid namespaceId)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for namespace %u", namespaceId);
- nspForm = (Form_pg_namespace) GETSTRUCT(tuple);
+ nspForm = GETSTRUCT(pg_namespace, tuple);
nsp_name = NameStr(nspForm->nspname);
if (strncmp(nsp_name, "pg_temp_", 8) == 0)
nsp_name = "pg_temp";
diff --git a/contrib/tcn/tcn.c b/contrib/tcn/tcn.c
index a2de6c385c..ff9990e044 100644
--- a/contrib/tcn/tcn.c
+++ b/contrib/tcn/tcn.c
@@ -134,7 +134,7 @@ triggered_change_notification(PG_FUNCTION_ARGS)
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple)) /* should not happen */
elog(ERROR, "cache lookup failed for index %u", indexoid);
- index = (Form_pg_index) GETSTRUCT(indexTuple);
+ index = GETSTRUCT(pg_index, indexTuple);
/* we're only interested if it is the primary key and valid */
if (index->indisprimary && index->indisvalid)
{
diff --git a/src/backend/access/brin/brin_validate.c b/src/backend/access/brin/brin_validate.c
index c54c874bc0..06c60b6780 100644
--- a/src/backend/access/brin/brin_validate.c
+++ b/src/backend/access/brin/brin_validate.c
@@ -58,7 +58,7 @@ brinvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -68,7 +68,7 @@ brinvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -80,7 +80,7 @@ brinvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/* Check procedure numbers and function signatures */
@@ -146,7 +146,7 @@ brinvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* Check that only allowed strategy numbers exist */
if (oprform->amopstrategy < 1 || oprform->amopstrategy > 63)
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index 609329bb21..e58c1ff436 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -1393,7 +1393,7 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc,
if (isnull)
return NULL;
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/* Parse into appropriate format; don't error out here */
switch (classForm->relkind)
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index d6fb261e20..dfad4a8dfa 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -635,7 +635,7 @@ TupleDescInitEntry(TupleDesc desc,
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(oidtypeid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", oidtypeid);
- typeForm = (Form_pg_type) GETSTRUCT(tuple);
+ typeForm = GETSTRUCT(pg_type, tuple);
att->atttypid = oidtypeid;
att->attlen = typeForm->typlen;
diff --git a/src/backend/access/gin/ginvalidate.c b/src/backend/access/gin/ginvalidate.c
index 44f2ff205d..a873ab8b70 100644
--- a/src/backend/access/gin/ginvalidate.c
+++ b/src/backend/access/gin/ginvalidate.c
@@ -53,7 +53,7 @@ ginvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -66,7 +66,7 @@ ginvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -78,7 +78,7 @@ ginvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/*
@@ -172,7 +172,7 @@ ginvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* TODO: Check that only allowed strategy numbers exist */
if (oprform->amopstrategy < 1 || oprform->amopstrategy > 63)
diff --git a/src/backend/access/gist/gistvalidate.c b/src/backend/access/gist/gistvalidate.c
index 95beca05fe..ce87ea3f9e 100644
--- a/src/backend/access/gist/gistvalidate.c
+++ b/src/backend/access/gist/gistvalidate.c
@@ -54,7 +54,7 @@ gistvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -67,7 +67,7 @@ gistvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -79,7 +79,7 @@ gistvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/*
@@ -174,7 +174,7 @@ gistvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
Oid op_rettype;
/* TODO: Check that only allowed strategy numbers exist */
diff --git a/src/backend/access/hash/hashvalidate.c b/src/backend/access/hash/hashvalidate.c
index 10bf26ce7c..8f8712a552 100644
--- a/src/backend/access/hash/hashvalidate.c
+++ b/src/backend/access/hash/hashvalidate.c
@@ -67,7 +67,7 @@ hashvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -77,7 +77,7 @@ hashvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -89,7 +89,7 @@ hashvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
/*
* All hash functions should be registered with matching left/right
@@ -149,7 +149,7 @@ hashvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* Check that only allowed strategy numbers exist */
if (oprform->amopstrategy < 1 ||
@@ -299,7 +299,7 @@ check_hash_func_signature(Oid funcid, int16 amprocnum, Oid argtype)
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(tp);
+ procform = GETSTRUCT(pg_proc, tp);
if (procform->prorettype != restype || procform->proretset ||
procform->pronargs != nargs)
diff --git a/src/backend/access/index/amapi.c b/src/backend/access/index/amapi.c
index 2b028e1950..243d80c2e5 100644
--- a/src/backend/access/index/amapi.c
+++ b/src/backend/access/index/amapi.c
@@ -68,7 +68,7 @@ GetIndexAmRoutineByAmId(Oid amoid, bool noerror)
elog(ERROR, "cache lookup failed for access method %u",
amoid);
}
- amform = (Form_pg_am) GETSTRUCT(tuple);
+ amform = GETSTRUCT(pg_am, tuple);
/* Check if it's an index access method as opposed to some other AM */
if (amform->amtype != AMTYPE_INDEX)
@@ -123,7 +123,7 @@ amvalidate(PG_FUNCTION_ARGS)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
amoid = classform->opcmethod;
diff --git a/src/backend/access/index/amvalidate.c b/src/backend/access/index/amvalidate.c
index d13054e33f..89b5ade49a 100644
--- a/src/backend/access/index/amvalidate.c
+++ b/src/backend/access/index/amvalidate.c
@@ -62,14 +62,14 @@ identify_opfamily_groups(CatCList *oprlist, CatCList *proclist)
io = ip = 0;
if (io < oprlist->n_members)
{
- oprform = (Form_pg_amop) GETSTRUCT(&oprlist->members[io]->tuple);
+ oprform = GETSTRUCT(pg_amop, &oprlist->members[io]->tuple);
io++;
}
else
oprform = NULL;
if (ip < proclist->n_members)
{
- procform = (Form_pg_amproc) GETSTRUCT(&proclist->members[ip]->tuple);
+ procform = GETSTRUCT(pg_amproc, &proclist->members[ip]->tuple);
ip++;
}
else
@@ -89,7 +89,7 @@ identify_opfamily_groups(CatCList *oprlist, CatCList *proclist)
if (io < oprlist->n_members)
{
- oprform = (Form_pg_amop) GETSTRUCT(&oprlist->members[io]->tuple);
+ oprform = GETSTRUCT(pg_amop, &oprlist->members[io]->tuple);
io++;
}
else
@@ -109,7 +109,7 @@ identify_opfamily_groups(CatCList *oprlist, CatCList *proclist)
if (ip < proclist->n_members)
{
- procform = (Form_pg_amproc) GETSTRUCT(&proclist->members[ip]->tuple);
+ procform = GETSTRUCT(pg_amproc, &proclist->members[ip]->tuple);
ip++;
}
else
@@ -161,7 +161,7 @@ check_amproc_signature(Oid funcid, Oid restype, bool exact,
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(tp);
+ procform = GETSTRUCT(pg_proc, tp);
if (procform->prorettype != restype || procform->proretset ||
procform->pronargs < minargs || procform->pronargs > maxargs)
@@ -212,7 +212,7 @@ check_amop_signature(Oid opno, Oid restype, Oid lefttype, Oid righttype)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for operator %u", opno);
- opform = (Form_pg_operator) GETSTRUCT(tp);
+ opform = GETSTRUCT(pg_operator, tp);
if (opform->oprresult != restype || opform->oprkind != 'b' ||
opform->oprleft != lefttype || opform->oprright != righttype)
@@ -249,7 +249,7 @@ opclass_for_family_datatype(Oid amoid, Oid opfamilyoid, Oid datatypeoid)
for (i = 0; i < opclist->n_members; i++)
{
HeapTuple classtup = &opclist->members[i]->tuple;
- Form_pg_opclass classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ Form_pg_opclass classform = GETSTRUCT(pg_opclass, classtup);
if (classform->opcfamily == opfamilyoid &&
classform->opcintype == datatypeoid)
diff --git a/src/backend/access/nbtree/nbtvalidate.c b/src/backend/access/nbtree/nbtvalidate.c
index 55ed3251d3..05d3c6707e 100644
--- a/src/backend/access/nbtree/nbtvalidate.c
+++ b/src/backend/access/nbtree/nbtvalidate.c
@@ -62,7 +62,7 @@ btvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -72,7 +72,7 @@ btvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -84,7 +84,7 @@ btvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/* Check procedure numbers and function signatures */
@@ -141,7 +141,7 @@ btvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
/* Check that only allowed strategy numbers exist */
if (oprform->amopstrategy < 1 ||
diff --git a/src/backend/access/spgist/spgutils.c b/src/backend/access/spgist/spgutils.c
index 2c661fcf96..93ed425c29 100644
--- a/src/backend/access/spgist/spgutils.c
+++ b/src/backend/access/spgist/spgutils.c
@@ -163,7 +163,7 @@ fillTypeDesc(SpGistTypeDesc *desc, Oid type)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", type);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
desc->attlen = typtup->typlen;
desc->attbyval = typtup->typbyval;
desc->attalign = typtup->typalign;
@@ -1328,7 +1328,7 @@ spgproperty(Oid index_oid, int attno,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple amoptup = &catlist->members[i]->tuple;
- Form_pg_amop amopform = (Form_pg_amop) GETSTRUCT(amoptup);
+ Form_pg_amop amopform = GETSTRUCT(pg_amop, amoptup);
if (amopform->amoppurpose == AMOP_ORDER &&
(amopform->amoplefttype == opcintype ||
diff --git a/src/backend/access/spgist/spgvalidate.c b/src/backend/access/spgist/spgvalidate.c
index 82281f7b83..ab055f9371 100644
--- a/src/backend/access/spgist/spgvalidate.c
+++ b/src/backend/access/spgist/spgvalidate.c
@@ -64,7 +64,7 @@ spgvalidate(Oid opclassoid)
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
+ classform = GETSTRUCT(pg_opclass, classtup);
opfamilyoid = classform->opcfamily;
opcintype = classform->opcintype;
@@ -75,7 +75,7 @@ spgvalidate(Oid opclassoid)
familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
if (!HeapTupleIsValid(familytup))
elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
+ familyform = GETSTRUCT(pg_opfamily, familytup);
opfamilyname = NameStr(familyform->opfname);
@@ -88,7 +88,7 @@ spgvalidate(Oid opclassoid)
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
bool ok;
/*
@@ -210,7 +210,7 @@ spgvalidate(Oid opclassoid)
for (i = 0; i < oprlist->n_members; i++)
{
HeapTuple oprtup = &oprlist->members[i]->tuple;
- Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup);
+ Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup);
Oid op_rettype;
/* TODO: Check that only allowed strategy numbers exist */
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 58752368e7..ffd94bf54f 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -720,7 +720,7 @@ populate_typ_list(void)
old = MemoryContextSwitchTo(TopMemoryContext);
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_type typForm = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typForm = GETSTRUCT(pg_type, tup);
struct typmap *newtyp;
newtyp = (struct typmap *) palloc(sizeof(struct typmap));
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index 17ff617fba..d372d29b09 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -884,7 +884,7 @@ objectsInSchemaToOids(ObjectType objtype, List *nspnames)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Oid oid = ((Form_pg_proc) GETSTRUCT(tuple))->oid;
+ Oid oid = (GETSTRUCT(pg_proc, tuple))->oid;
objects = lappend_oid(objects, oid);
}
@@ -931,7 +931,7 @@ getRelationsInNamespace(Oid namespaceId, char relkind)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Oid oid = ((Form_pg_class) GETSTRUCT(tuple))->oid;
+ Oid oid = (GETSTRUCT(pg_class, tuple))->oid;
relations = lappend_oid(relations, oid);
}
@@ -1330,7 +1330,7 @@ SetDefaultACL(InternalDefaultACL *iacls)
* there shouldn't be anything depending on this entry.
*/
myself.classId = DefaultAclRelationId;
- myself.objectId = ((Form_pg_default_acl) GETSTRUCT(tuple))->oid;
+ myself.objectId = (GETSTRUCT(pg_default_acl, tuple))->oid;
myself.objectSubId = 0;
performDeletion(&myself, DROP_RESTRICT, 0);
@@ -1359,7 +1359,7 @@ SetDefaultACL(InternalDefaultACL *iacls)
}
else
{
- defAclOid = ((Form_pg_default_acl) GETSTRUCT(tuple))->oid;
+ defAclOid = (GETSTRUCT(pg_default_acl, tuple))->oid;
/* update existing entry */
values[Anum_pg_default_acl_defaclacl - 1] = PointerGetDatum(new_acl);
@@ -1455,7 +1455,7 @@ RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for default ACL %u", objid);
- pg_default_acl_tuple = (Form_pg_default_acl) GETSTRUCT(tuple);
+ pg_default_acl_tuple = GETSTRUCT(pg_default_acl, tuple);
iacls.roleid = pg_default_acl_tuple->defaclrole;
iacls.nspid = pg_default_acl_tuple->defaclnamespace;
@@ -1625,7 +1625,7 @@ expand_all_col_privileges(Oid table_oid, Form_pg_class classForm,
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
curr_att, table_oid);
- isdropped = ((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped;
+ isdropped = (GETSTRUCT(pg_attribute, attTuple))->attisdropped;
ReleaseSysCache(attTuple);
@@ -1671,7 +1671,7 @@ ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname,
if (!HeapTupleIsValid(attr_tuple))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relOid);
- pg_attribute_tuple = (Form_pg_attribute) GETSTRUCT(attr_tuple);
+ pg_attribute_tuple = GETSTRUCT(pg_attribute, attr_tuple);
/*
* Get working copy of existing ACL. If there's no ACL, substitute the
@@ -1817,7 +1817,7 @@ ExecGrant_Relation(InternalGrant *istmt)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
+ pg_class_tuple = GETSTRUCT(pg_class, tuple);
/* Not sensible to grant on an index */
if (pg_class_tuple->relkind == RELKIND_INDEX ||
@@ -2151,7 +2151,7 @@ ExecGrant_Database(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for database %u", datId);
- pg_database_tuple = (Form_pg_database) GETSTRUCT(tuple);
+ pg_database_tuple = GETSTRUCT(pg_database, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2268,7 +2268,7 @@ ExecGrant_Fdw(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for foreign-data wrapper %u", fdwid);
- pg_fdw_tuple = (Form_pg_foreign_data_wrapper) GETSTRUCT(tuple);
+ pg_fdw_tuple = GETSTRUCT(pg_foreign_data_wrapper, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2390,7 +2390,7 @@ ExecGrant_ForeignServer(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for foreign server %u", srvid);
- pg_server_tuple = (Form_pg_foreign_server) GETSTRUCT(tuple);
+ pg_server_tuple = GETSTRUCT(pg_foreign_server, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2511,7 +2511,7 @@ ExecGrant_Function(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcId);
- pg_proc_tuple = (Form_pg_proc) GETSTRUCT(tuple);
+ pg_proc_tuple = GETSTRUCT(pg_proc, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2630,7 +2630,7 @@ ExecGrant_Language(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for language %u", langId);
- pg_language_tuple = (Form_pg_language) GETSTRUCT(tuple);
+ pg_language_tuple = GETSTRUCT(pg_language, tuple);
if (!pg_language_tuple->lanpltrusted)
ereport(ERROR,
@@ -2771,7 +2771,7 @@ ExecGrant_Largeobject(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for large object %u", loid);
- form_lo_meta = (Form_pg_largeobject_metadata) GETSTRUCT(tuple);
+ form_lo_meta = GETSTRUCT(pg_largeobject_metadata, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -2893,7 +2893,7 @@ ExecGrant_Namespace(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for namespace %u", nspid);
- pg_namespace_tuple = (Form_pg_namespace) GETSTRUCT(tuple);
+ pg_namespace_tuple = GETSTRUCT(pg_namespace, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -3014,7 +3014,7 @@ ExecGrant_Tablespace(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for tablespace %u", tblId);
- pg_tablespace_tuple = (Form_pg_tablespace) GETSTRUCT(tuple);
+ pg_tablespace_tuple = GETSTRUCT(pg_tablespace, tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
@@ -3130,7 +3130,7 @@ ExecGrant_Type(InternalGrant *istmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", typId);
- pg_type_tuple = (Form_pg_type) GETSTRUCT(tuple);
+ pg_type_tuple = GETSTRUCT(pg_type, tuple);
if (IsTrueArrayType(pg_type_tuple))
ereport(ERROR,
@@ -3906,7 +3906,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
attnum, table_oid)));
}
- attributeForm = (Form_pg_attribute) GETSTRUCT(attTuple);
+ attributeForm = GETSTRUCT(pg_attribute, attTuple);
/* Check dropped columns, too */
if (attributeForm->attisdropped)
@@ -3953,7 +3953,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
ReleaseSysCache(attTuple);
return 0;
}
- classForm = (Form_pg_class) GETSTRUCT(classTuple);
+ classForm = GETSTRUCT(pg_class, classTuple);
ownerId = classForm->relowner;
@@ -4020,7 +4020,7 @@ pg_class_aclmask_ext(Oid table_oid, Oid roleid, AclMode mask,
table_oid)));
}
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/*
* Deny anyone permission to update a system catalog unless
@@ -4131,7 +4131,7 @@ pg_database_aclmask(Oid db_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database with OID %u does not exist", db_oid)));
- ownerId = ((Form_pg_database) GETSTRUCT(tuple))->datdba;
+ ownerId = (GETSTRUCT(pg_database, tuple))->datdba;
aclDatum = SysCacheGetAttr(DATABASEOID, tuple, Anum_pg_database_datacl,
&isNull);
@@ -4300,7 +4300,7 @@ pg_proc_aclmask(Oid proc_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function with OID %u does not exist", proc_oid)));
- ownerId = ((Form_pg_proc) GETSTRUCT(tuple))->proowner;
+ ownerId = (GETSTRUCT(pg_proc, tuple))->proowner;
aclDatum = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_proacl,
&isNull);
@@ -4354,7 +4354,7 @@ pg_language_aclmask(Oid lang_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("language with OID %u does not exist", lang_oid)));
- ownerId = ((Form_pg_language) GETSTRUCT(tuple))->lanowner;
+ ownerId = (GETSTRUCT(pg_language, tuple))->lanowner;
aclDatum = SysCacheGetAttr(LANGOID, tuple, Anum_pg_language_lanacl,
&isNull);
@@ -4433,7 +4433,7 @@ pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("large object %u does not exist", lobj_oid)));
- ownerId = ((Form_pg_largeobject_metadata) GETSTRUCT(tuple))->lomowner;
+ ownerId = (GETSTRUCT(pg_largeobject_metadata, tuple))->lomowner;
aclDatum = heap_getattr(tuple, Anum_pg_largeobject_metadata_lomacl,
RelationGetDescr(pg_lo_meta), &isNull);
@@ -4518,7 +4518,7 @@ pg_namespace_aclmask(Oid nsp_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema with OID %u does not exist", nsp_oid)));
- ownerId = ((Form_pg_namespace) GETSTRUCT(tuple))->nspowner;
+ ownerId = (GETSTRUCT(pg_namespace, tuple))->nspowner;
aclDatum = SysCacheGetAttr(NAMESPACEOID, tuple, Anum_pg_namespace_nspacl,
&isNull);
@@ -4582,7 +4582,7 @@ pg_tablespace_aclmask(Oid spc_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("tablespace with OID %u does not exist", spc_oid)));
- ownerId = ((Form_pg_tablespace) GETSTRUCT(tuple))->spcowner;
+ ownerId = (GETSTRUCT(pg_tablespace, tuple))->spcowner;
aclDatum = SysCacheGetAttr(TABLESPACEOID, tuple,
Anum_pg_tablespace_spcacl,
@@ -4641,7 +4641,7 @@ pg_foreign_data_wrapper_aclmask(Oid fdw_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign-data wrapper with OID %u does not exist",
fdw_oid)));
- fdwForm = (Form_pg_foreign_data_wrapper) GETSTRUCT(tuple);
+ fdwForm = GETSTRUCT(pg_foreign_data_wrapper, tuple);
/*
* Normal case: get the FDW's ACL from pg_foreign_data_wrapper
@@ -4703,7 +4703,7 @@ pg_foreign_server_aclmask(Oid srv_oid, Oid roleid,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign server with OID %u does not exist",
srv_oid)));
- srvForm = (Form_pg_foreign_server) GETSTRUCT(tuple);
+ srvForm = GETSTRUCT(pg_foreign_server, tuple);
/*
* Normal case: get the foreign server's ACL from pg_foreign_server
@@ -4763,7 +4763,7 @@ pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type with OID %u does not exist",
type_oid)));
- typeForm = (Form_pg_type) GETSTRUCT(tuple);
+ typeForm = GETSTRUCT(pg_type, tuple);
/*
* "True" array types don't manage permissions of their own; consult the
@@ -4779,7 +4779,7 @@ pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how)
/* this case is not a user-facing error, so elog not ereport */
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", elttype_oid);
- typeForm = (Form_pg_type) GETSTRUCT(tuple);
+ typeForm = GETSTRUCT(pg_type, tuple);
}
/*
@@ -4884,7 +4884,7 @@ pg_attribute_aclcheck_all(Oid table_oid, Oid roleid, AclMode mode,
classTuple = SearchSysCache1(RELOID, ObjectIdGetDatum(table_oid));
if (!HeapTupleIsValid(classTuple))
return ACLCHECK_NO_PRIV;
- classForm = (Form_pg_class) GETSTRUCT(classTuple);
+ classForm = GETSTRUCT(pg_class, classTuple);
nattrs = classForm->relnatts;
@@ -4908,7 +4908,7 @@ pg_attribute_aclcheck_all(Oid table_oid, Oid roleid, AclMode mode,
continue;
/* ignore dropped columns */
- if (((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped)
+ if ((GETSTRUCT(pg_attribute, attTuple))->attisdropped)
{
ReleaseSysCache(attTuple);
continue;
@@ -5131,7 +5131,7 @@ pg_class_ownercheck(Oid class_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_TABLE),
errmsg("relation with OID %u does not exist", class_oid)));
- ownerId = ((Form_pg_class) GETSTRUCT(tuple))->relowner;
+ ownerId = (GETSTRUCT(pg_class, tuple))->relowner;
ReleaseSysCache(tuple);
@@ -5157,7 +5157,7 @@ pg_type_ownercheck(Oid type_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type with OID %u does not exist", type_oid)));
- ownerId = ((Form_pg_type) GETSTRUCT(tuple))->typowner;
+ ownerId = (GETSTRUCT(pg_type, tuple))->typowner;
ReleaseSysCache(tuple);
@@ -5183,7 +5183,7 @@ pg_oper_ownercheck(Oid oper_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("operator with OID %u does not exist", oper_oid)));
- ownerId = ((Form_pg_operator) GETSTRUCT(tuple))->oprowner;
+ ownerId = (GETSTRUCT(pg_operator, tuple))->oprowner;
ReleaseSysCache(tuple);
@@ -5209,7 +5209,7 @@ pg_proc_ownercheck(Oid proc_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function with OID %u does not exist", proc_oid)));
- ownerId = ((Form_pg_proc) GETSTRUCT(tuple))->proowner;
+ ownerId = (GETSTRUCT(pg_proc, tuple))->proowner;
ReleaseSysCache(tuple);
@@ -5235,7 +5235,7 @@ pg_language_ownercheck(Oid lan_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("language with OID %u does not exist", lan_oid)));
- ownerId = ((Form_pg_language) GETSTRUCT(tuple))->lanowner;
+ ownerId = (GETSTRUCT(pg_language, tuple))->lanowner;
ReleaseSysCache(tuple);
@@ -5280,7 +5280,7 @@ pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("large object %u does not exist", lobj_oid)));
- ownerId = ((Form_pg_largeobject_metadata) GETSTRUCT(tuple))->lomowner;
+ ownerId = (GETSTRUCT(pg_largeobject_metadata, tuple))->lomowner;
systable_endscan(scan);
table_close(pg_lo_meta, AccessShareLock);
@@ -5307,7 +5307,7 @@ pg_namespace_ownercheck(Oid nsp_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema with OID %u does not exist", nsp_oid)));
- ownerId = ((Form_pg_namespace) GETSTRUCT(tuple))->nspowner;
+ ownerId = (GETSTRUCT(pg_namespace, tuple))->nspowner;
ReleaseSysCache(tuple);
@@ -5334,7 +5334,7 @@ pg_tablespace_ownercheck(Oid spc_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("tablespace with OID %u does not exist", spc_oid)));
- spcowner = ((Form_pg_tablespace) GETSTRUCT(spctuple))->spcowner;
+ spcowner = (GETSTRUCT(pg_tablespace, spctuple))->spcowner;
ReleaseSysCache(spctuple);
@@ -5361,7 +5361,7 @@ pg_opclass_ownercheck(Oid opc_oid, Oid roleid)
errmsg("operator class with OID %u does not exist",
opc_oid)));
- ownerId = ((Form_pg_opclass) GETSTRUCT(tuple))->opcowner;
+ ownerId = (GETSTRUCT(pg_opclass, tuple))->opcowner;
ReleaseSysCache(tuple);
@@ -5388,7 +5388,7 @@ pg_opfamily_ownercheck(Oid opf_oid, Oid roleid)
errmsg("operator family with OID %u does not exist",
opf_oid)));
- ownerId = ((Form_pg_opfamily) GETSTRUCT(tuple))->opfowner;
+ ownerId = (GETSTRUCT(pg_opfamily, tuple))->opfowner;
ReleaseSysCache(tuple);
@@ -5415,7 +5415,7 @@ pg_ts_dict_ownercheck(Oid dict_oid, Oid roleid)
errmsg("text search dictionary with OID %u does not exist",
dict_oid)));
- ownerId = ((Form_pg_ts_dict) GETSTRUCT(tuple))->dictowner;
+ ownerId = (GETSTRUCT(pg_ts_dict, tuple))->dictowner;
ReleaseSysCache(tuple);
@@ -5442,7 +5442,7 @@ pg_ts_config_ownercheck(Oid cfg_oid, Oid roleid)
errmsg("text search configuration with OID %u does not exist",
cfg_oid)));
- ownerId = ((Form_pg_ts_config) GETSTRUCT(tuple))->cfgowner;
+ ownerId = (GETSTRUCT(pg_ts_config, tuple))->cfgowner;
ReleaseSysCache(tuple);
@@ -5469,7 +5469,7 @@ pg_foreign_data_wrapper_ownercheck(Oid srv_oid, Oid roleid)
errmsg("foreign-data wrapper with OID %u does not exist",
srv_oid)));
- ownerId = ((Form_pg_foreign_data_wrapper) GETSTRUCT(tuple))->fdwowner;
+ ownerId = (GETSTRUCT(pg_foreign_data_wrapper, tuple))->fdwowner;
ReleaseSysCache(tuple);
@@ -5496,7 +5496,7 @@ pg_foreign_server_ownercheck(Oid srv_oid, Oid roleid)
errmsg("foreign server with OID %u does not exist",
srv_oid)));
- ownerId = ((Form_pg_foreign_server) GETSTRUCT(tuple))->srvowner;
+ ownerId = (GETSTRUCT(pg_foreign_server, tuple))->srvowner;
ReleaseSysCache(tuple);
@@ -5523,7 +5523,7 @@ pg_event_trigger_ownercheck(Oid et_oid, Oid roleid)
errmsg("event trigger with OID %u does not exist",
et_oid)));
- ownerId = ((Form_pg_event_trigger) GETSTRUCT(tuple))->evtowner;
+ ownerId = (GETSTRUCT(pg_event_trigger, tuple))->evtowner;
ReleaseSysCache(tuple);
@@ -5549,7 +5549,7 @@ pg_database_ownercheck(Oid db_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database with OID %u does not exist", db_oid)));
- dba = ((Form_pg_database) GETSTRUCT(tuple))->datdba;
+ dba = (GETSTRUCT(pg_database, tuple))->datdba;
ReleaseSysCache(tuple);
@@ -5575,7 +5575,7 @@ pg_collation_ownercheck(Oid coll_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("collation with OID %u does not exist", coll_oid)));
- ownerId = ((Form_pg_collation) GETSTRUCT(tuple))->collowner;
+ ownerId = (GETSTRUCT(pg_collation, tuple))->collowner;
ReleaseSysCache(tuple);
@@ -5601,7 +5601,7 @@ pg_conversion_ownercheck(Oid conv_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("conversion with OID %u does not exist", conv_oid)));
- ownerId = ((Form_pg_conversion) GETSTRUCT(tuple))->conowner;
+ ownerId = (GETSTRUCT(pg_conversion, tuple))->conowner;
ReleaseSysCache(tuple);
@@ -5642,7 +5642,7 @@ pg_extension_ownercheck(Oid ext_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("extension with OID %u does not exist", ext_oid)));
- ownerId = ((Form_pg_extension) GETSTRUCT(tuple))->extowner;
+ ownerId = (GETSTRUCT(pg_extension, tuple))->extowner;
systable_endscan(scan);
table_close(pg_extension, AccessShareLock);
@@ -5669,7 +5669,7 @@ pg_publication_ownercheck(Oid pub_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("publication with OID %u does not exist", pub_oid)));
- ownerId = ((Form_pg_publication) GETSTRUCT(tuple))->pubowner;
+ ownerId = (GETSTRUCT(pg_publication, tuple))->pubowner;
ReleaseSysCache(tuple);
@@ -5695,7 +5695,7 @@ pg_subscription_ownercheck(Oid sub_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("subscription with OID %u does not exist", sub_oid)));
- ownerId = ((Form_pg_subscription) GETSTRUCT(tuple))->subowner;
+ ownerId = (GETSTRUCT(pg_subscription, tuple))->subowner;
ReleaseSysCache(tuple);
@@ -5722,7 +5722,7 @@ pg_statistics_object_ownercheck(Oid stat_oid, Oid roleid)
errmsg("statistics object with OID %u does not exist",
stat_oid)));
- ownerId = ((Form_pg_statistic_ext) GETSTRUCT(tuple))->stxowner;
+ ownerId = (GETSTRUCT(pg_statistic_ext, tuple))->stxowner;
ReleaseSysCache(tuple);
@@ -5753,7 +5753,7 @@ has_createrole_privilege(Oid roleid)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolcreaterole;
+ result = (GETSTRUCT(pg_authid, utup))->rolcreaterole;
ReleaseSysCache(utup);
}
return result;
@@ -5772,7 +5772,7 @@ has_bypassrls_privilege(Oid roleid)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolbypassrls;
+ result = (GETSTRUCT(pg_authid, utup))->rolbypassrls;
ReleaseSysCache(utup);
}
return result;
@@ -5944,7 +5944,7 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", objoid);
- pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
+ pg_class_tuple = GETSTRUCT(pg_class, tuple);
/*
* Indexes don't have permissions, neither do the pg_class rows for
@@ -5981,7 +5981,7 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
continue;
/* ignore dropped columns */
- if (((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped)
+ if ((GETSTRUCT(pg_attribute, attTuple))->attisdropped)
{
ReleaseSysCache(attTuple);
continue;
@@ -6238,7 +6238,7 @@ removeExtObjInitPriv(Oid objoid, Oid classoid)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", objoid);
- pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
+ pg_class_tuple = GETSTRUCT(pg_class, tuple);
/*
* Indexes don't have permissions, neither do the pg_class rows for
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 6f43870779..31e06aab3e 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -629,7 +629,7 @@ pg_nextoid(PG_FUNCTION_ARGS)
errmsg("column \"%s\" of relation \"%s\" does not exist",
NameStr(*attname), RelationGetRelationName(rel))));
- attform = ((Form_pg_attribute) GETSTRUCT(atttuple));
+ attform = (GETSTRUCT(pg_attribute, atttuple));
attno = attform->attnum;
if (attform->atttypid != OIDOID)
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index e119674b1f..9125ab3305 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -580,7 +580,7 @@ findDependentObjects(const ObjectAddress *object,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend foundDep = GETSTRUCT(pg_depend, tup);
otherObject.classId = foundDep->refclassid;
otherObject.objectId = foundDep->refobjid;
@@ -869,7 +869,7 @@ findDependentObjects(const ObjectAddress *object,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend foundDep = GETSTRUCT(pg_depend, tup);
int subflags;
otherObject.classId = foundDep->classid;
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 9b03579e6e..d2997619f6 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -1664,7 +1664,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- attStruct = (Form_pg_attribute) GETSTRUCT(tuple);
+ attStruct = GETSTRUCT(pg_attribute, tuple);
if (attnum < 0)
{
@@ -1772,7 +1772,7 @@ heap_drop_with_catalog(Oid relid)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- if (((Form_pg_class) GETSTRUCT(tuple))->relispartition)
+ if ((GETSTRUCT(pg_class, tuple))->relispartition)
{
/*
* We have to lock the parent if the partition is being detached,
@@ -1969,7 +1969,7 @@ RelationClearMissing(Relation rel)
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ attrtuple = GETSTRUCT(pg_attribute, tuple);
/* ignore any where atthasmissing is not true */
if (attrtuple->atthasmissing)
@@ -2028,7 +2028,7 @@ SetAttrMissing(Oid relid, char *attname, char *value)
if (!HeapTupleIsValid(atttup))
elog(ERROR, "cache lookup failed for attribute %s of relation %u",
attname, relid);
- attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
+ attStruct = GETSTRUCT(pg_attribute, atttup);
/* get an array value from the value string */
missingval = OidFunctionCall3(F_ARRAY_IN,
@@ -2528,7 +2528,7 @@ MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr,
/* There can be at most one matching row */
if (HeapTupleIsValid(tup = systable_getnext(conscan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tup);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tup);
/* Found it. Conflicts if not identical check constraint */
if (con->contype == CONSTRAINT_CHECK)
@@ -2597,7 +2597,7 @@ MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr,
ccname)));
tup = heap_copytuple(tup);
- con = (Form_pg_constraint) GETSTRUCT(tup);
+ con = GETSTRUCT(pg_constraint, tup);
/*
* In case of partitions, an inherited constraint must be inherited
@@ -2655,7 +2655,7 @@ SetRelationNumChecks(Relation rel, int numchecks)
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(rel));
- relStruct = (Form_pg_class) GETSTRUCT(reltup);
+ relStruct = GETSTRUCT(pg_class, reltup);
if (relStruct->relchecks != numchecks)
{
@@ -2874,7 +2874,7 @@ CopyStatistics(Oid fromrelid, Oid torelid)
/* make a modifiable copy */
tup = heap_copytuple(tup);
- statform = (Form_pg_statistic) GETSTRUCT(tup);
+ statform = GETSTRUCT(pg_statistic, tup);
/* update the copy of the tuple and insert it */
statform->starelid = torelid;
@@ -3199,7 +3199,7 @@ restart:
while (HeapTupleIsValid(tuple = systable_getnext(fkeyScan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
/* Not a foreign key */
if (con->contype != CONSTRAINT_FOREIGN)
@@ -3251,7 +3251,7 @@ restart:
tuple = systable_getnext(fkeyScan);
if (HeapTupleIsValid(tuple))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
/*
* pg_constraint rows always appear for partitioned hierarchies
@@ -3476,7 +3476,7 @@ StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
Form_pg_class classForm;
bool isnull;
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
Assert(!classForm->relispartition);
(void) SysCacheGetAttr(RELOID, tuple, Anum_pg_class_relpartbound,
&isnull);
@@ -3494,7 +3494,7 @@ StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
newtuple = heap_modify_tuple(tuple, RelationGetDescr(classRel),
new_val, new_null, new_repl);
/* Also set the flag */
- ((Form_pg_class) GETSTRUCT(newtuple))->relispartition = true;
+ (GETSTRUCT(pg_class, newtuple))->relispartition = true;
CatalogTupleUpdate(classRel, &newtuple->t_self, newtuple);
heap_freetuple(newtuple);
table_close(classRel, RowExclusiveLock);
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index d7192f35e3..d0f7de0f18 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -170,7 +170,7 @@ relationHasPrimaryKey(Relation rel)
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple)) /* should not happen */
elog(ERROR, "cache lookup failed for index %u", indexoid);
- result = ((Form_pg_index) GETSTRUCT(indexTuple))->indisprimary;
+ result = (GETSTRUCT(pg_index, indexTuple))->indisprimary;
ReleaseSysCache(indexTuple);
if (result)
break;
@@ -251,7 +251,7 @@ index_check_primary_key(Relation heapRel,
if (!HeapTupleIsValid(atttuple))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, RelationGetRelid(heapRel));
- attform = (Form_pg_attribute) GETSTRUCT(atttuple);
+ attform = GETSTRUCT(pg_attribute, atttuple);
if (!attform->attnotnull)
ereport(ERROR,
@@ -369,7 +369,7 @@ ConstructTupleDescriptor(Relation heapRelation,
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(keyType));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", keyType);
- typeTup = (Form_pg_type) GETSTRUCT(tuple);
+ typeTup = GETSTRUCT(pg_type, tuple);
/*
* Assign some of the attributes values. Leave the rest.
@@ -426,7 +426,7 @@ ConstructTupleDescriptor(Relation heapRelation,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for opclass %u",
classObjectId[i]);
- opclassTup = (Form_pg_opclass) GETSTRUCT(tuple);
+ opclassTup = GETSTRUCT(pg_opclass, tuple);
if (OidIsValid(opclassTup->opckeytype))
keyType = opclassTup->opckeytype;
@@ -459,7 +459,7 @@ ConstructTupleDescriptor(Relation heapRelation,
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(keyType));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", keyType);
- typeTup = (Form_pg_type) GETSTRUCT(tuple);
+ typeTup = GETSTRUCT(pg_type, tuple);
to->atttypid = keyType;
to->atttypmod = -1;
@@ -810,7 +810,7 @@ index_create(Relation heapRelation,
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("nondeterministic collations are not supported for operator class \"%s\"",
- NameStr(((Form_pg_opclass) GETSTRUCT(classtup))->opcname))));
+ NameStr((GETSTRUCT(pg_opclass, classtup))->opcname))));
ReleaseSysCache(classtup);
}
}
@@ -1545,8 +1545,8 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
if (!HeapTupleIsValid(newClassTuple))
elog(ERROR, "could not find tuple for relation %u", newIndexId);
- oldClassForm = (Form_pg_class) GETSTRUCT(oldClassTuple);
- newClassForm = (Form_pg_class) GETSTRUCT(newClassTuple);
+ oldClassForm = GETSTRUCT(pg_class, oldClassTuple);
+ newClassForm = GETSTRUCT(pg_class, newClassTuple);
/* Swap the names */
namestrcpy(&newClassForm->relname, NameStr(oldClassForm->relname));
@@ -1575,8 +1575,8 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
if (!HeapTupleIsValid(newIndexTuple))
elog(ERROR, "could not find tuple for relation %u", newIndexId);
- oldIndexForm = (Form_pg_index) GETSTRUCT(oldIndexTuple);
- newIndexForm = (Form_pg_index) GETSTRUCT(newIndexTuple);
+ oldIndexForm = GETSTRUCT(pg_index, oldIndexTuple);
+ newIndexForm = GETSTRUCT(pg_index, newIndexTuple);
/*
* Copy constraint flags from the old index. This is safe because the old
@@ -1639,7 +1639,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
if (!HeapTupleIsValid(constraintTuple))
elog(ERROR, "could not find tuple for constraint %u", constraintOid);
- conForm = ((Form_pg_constraint) GETSTRUCT(constraintTuple));
+ conForm = (GETSTRUCT(pg_constraint, constraintTuple));
if (conForm->conindid == oldIndexId)
{
@@ -1661,14 +1661,14 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
while (HeapTupleIsValid((triggerTuple = systable_getnext(scan))))
{
- Form_pg_trigger tgForm = (Form_pg_trigger) GETSTRUCT(triggerTuple);
+ Form_pg_trigger tgForm = GETSTRUCT(pg_trigger, triggerTuple);
if (tgForm->tgconstrindid != oldIndexId)
continue;
/* Make a modifiable copy */
triggerTuple = heap_copytuple(triggerTuple);
- tgForm = (Form_pg_trigger) GETSTRUCT(triggerTuple);
+ tgForm = GETSTRUCT(pg_trigger, triggerTuple);
tgForm->tgconstrindid = newIndexId;
@@ -1774,7 +1774,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
while (HeapTupleIsValid((attrTuple = systable_getnext(scan))))
{
- Form_pg_attribute att = (Form_pg_attribute) GETSTRUCT(attrTuple);
+ Form_pg_attribute att = GETSTRUCT(pg_attribute, attrTuple);
Datum repl_val[Natts_pg_attribute];
bool repl_null[Natts_pg_attribute];
bool repl_repl[Natts_pg_attribute];
@@ -2076,7 +2076,7 @@ index_constraint_create(Relation heapRelation,
ObjectIdGetDatum(indexRelationId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexRelationId);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
if (mark_as_primary && !indexForm->indisprimary)
{
@@ -2852,7 +2852,7 @@ index_update_stats(Relation rel,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for relation %u", relid);
- rd_rel = (Form_pg_class) GETSTRUCT(tuple);
+ rd_rel = GETSTRUCT(pg_class, tuple);
/* Should this be a more comprehensive test? */
Assert(rd_rel->relkind != RELKIND_PARTITIONED_INDEX);
@@ -3076,7 +3076,7 @@ index_build(Relation heapRelation,
ObjectIdGetDatum(indexId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexId);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
/* If it's a new index, indcheckxmin shouldn't be set ... */
Assert(!indexForm->indcheckxmin);
@@ -3448,7 +3448,7 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
ObjectIdGetDatum(indexId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexId);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
/* Perform the requested state change on the copy */
switch (action)
@@ -3529,7 +3529,7 @@ IndexGetRelation(Oid indexId, bool missing_ok)
return InvalidOid;
elog(ERROR, "cache lookup failed for index %u", indexId);
}
- index = (Form_pg_index) GETSTRUCT(tuple);
+ index = GETSTRUCT(pg_index, tuple);
Assert(index->indexrelid == indexId);
result = index->indrelid;
@@ -3766,7 +3766,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
ObjectIdGetDatum(indexId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexId);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
index_bad = (!indexForm->indisvalid ||
!indexForm->indisready ||
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c
index fafb9349cc..737cc9d64b 100644
--- a/src/backend/catalog/namespace.c
+++ b/src/backend/catalog/namespace.c
@@ -717,7 +717,7 @@ RelationIsVisible(Oid relid)
reltup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", relid);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
recomputeNamespacePath();
@@ -825,7 +825,7 @@ TypeIsVisible(Oid typid)
typtup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(typtup))
elog(ERROR, "cache lookup failed for type %u", typid);
- typform = (Form_pg_type) GETSTRUCT(typtup);
+ typform = GETSTRUCT(pg_type, typtup);
recomputeNamespacePath();
@@ -986,7 +986,7 @@ FuncnameGetCandidates(List *names, int nargs, List *argnames,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple proctup = &catlist->members[i]->tuple;
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, proctup);
Oid *proargtypes = procform->proargtypes.values;
int pronargs = procform->pronargs;
int effective_nargs;
@@ -1349,7 +1349,7 @@ MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
bool include_out_arguments, int pronargs,
int **argnumbers)
{
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, proctup);
int numposargs = nargs - list_length(argnames);
int pronallargs;
Oid *p_argtypes;
@@ -1466,7 +1466,7 @@ FunctionIsVisible(Oid funcid)
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
recomputeNamespacePath();
@@ -1553,7 +1553,7 @@ OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
ObjectIdGetDatum(namespaceId));
if (HeapTupleIsValid(opertup))
{
- Form_pg_operator operclass = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operclass = GETSTRUCT(pg_operator, opertup);
Oid result = operclass->oid;
ReleaseSysCache(opertup);
@@ -1595,7 +1595,7 @@ OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple opertup = &catlist->members[i]->tuple;
- Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operform = GETSTRUCT(pg_operator, opertup);
if (operform->oprnamespace == namespaceId)
{
@@ -1678,7 +1678,7 @@ OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple opertup = &catlist->members[i]->tuple;
- Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operform = GETSTRUCT(pg_operator, opertup);
int pathpos = 0;
FuncCandidateList newResult;
@@ -1800,7 +1800,7 @@ OperatorIsVisible(Oid oprid)
oprtup = SearchSysCache1(OPEROID, ObjectIdGetDatum(oprid));
if (!HeapTupleIsValid(oprtup))
elog(ERROR, "cache lookup failed for operator %u", oprid);
- oprform = (Form_pg_operator) GETSTRUCT(oprtup);
+ oprform = GETSTRUCT(pg_operator, oprtup);
recomputeNamespacePath();
@@ -1886,7 +1886,7 @@ OpclassIsVisible(Oid opcid)
opctup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opcid));
if (!HeapTupleIsValid(opctup))
elog(ERROR, "cache lookup failed for opclass %u", opcid);
- opcform = (Form_pg_opclass) GETSTRUCT(opctup);
+ opcform = GETSTRUCT(pg_opclass, opctup);
recomputeNamespacePath();
@@ -1969,7 +1969,7 @@ OpfamilyIsVisible(Oid opfid)
opftup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfid));
if (!HeapTupleIsValid(opftup))
elog(ERROR, "cache lookup failed for opfamily %u", opfid);
- opfform = (Form_pg_opfamily) GETSTRUCT(opftup);
+ opfform = GETSTRUCT(pg_opfamily, opftup);
recomputeNamespacePath();
@@ -2032,7 +2032,7 @@ lookup_collation(const char *collname, Oid collnamespace, int32 encoding)
ObjectIdGetDatum(collnamespace));
if (!HeapTupleIsValid(colltup))
return InvalidOid;
- collform = (Form_pg_collation) GETSTRUCT(colltup);
+ collform = GETSTRUCT(pg_collation, colltup);
if (collform->collprovider == COLLPROVIDER_ICU)
{
if (is_encoding_supported_by_icu(encoding))
@@ -2101,7 +2101,7 @@ CollationIsVisible(Oid collid)
colltup = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
if (!HeapTupleIsValid(colltup))
elog(ERROR, "cache lookup failed for collation %u", collid);
- collform = (Form_pg_collation) GETSTRUCT(colltup);
+ collform = GETSTRUCT(pg_collation, colltup);
recomputeNamespacePath();
@@ -2184,7 +2184,7 @@ ConversionIsVisible(Oid conid)
contup = SearchSysCache1(CONVOID, ObjectIdGetDatum(conid));
if (!HeapTupleIsValid(contup))
elog(ERROR, "cache lookup failed for conversion %u", conid);
- conform = (Form_pg_conversion) GETSTRUCT(contup);
+ conform = GETSTRUCT(pg_conversion, contup);
recomputeNamespacePath();
@@ -2288,7 +2288,7 @@ StatisticsObjIsVisible(Oid relid)
stxtup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(stxtup))
elog(ERROR, "cache lookup failed for statistics object %u", relid);
- stxform = (Form_pg_statistic_ext) GETSTRUCT(stxtup);
+ stxform = GETSTRUCT(pg_statistic_ext, stxtup);
recomputeNamespacePath();
@@ -2411,7 +2411,7 @@ TSParserIsVisible(Oid prsId)
tup = SearchSysCache1(TSPARSEROID, ObjectIdGetDatum(prsId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search parser %u", prsId);
- form = (Form_pg_ts_parser) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_ts_parser, tup);
recomputeNamespacePath();
@@ -2538,7 +2538,7 @@ TSDictionaryIsVisible(Oid dictId)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search dictionary %u",
dictId);
- form = (Form_pg_ts_dict) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_ts_dict, tup);
recomputeNamespacePath();
@@ -2664,7 +2664,7 @@ TSTemplateIsVisible(Oid tmplId)
tup = SearchSysCache1(TSTEMPLATEOID, ObjectIdGetDatum(tmplId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search template %u", tmplId);
- form = (Form_pg_ts_template) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_ts_template, tup);
recomputeNamespacePath();
@@ -2791,7 +2791,7 @@ TSConfigIsVisible(Oid cfgid)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search configuration %u",
cfgid);
- form = (Form_pg_ts_config) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_ts_config, tup);
recomputeNamespacePath();
@@ -3835,7 +3835,7 @@ recomputeNamespacePath(void)
{
char *rname;
- rname = NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname);
+ rname = NameStr((GETSTRUCT(pg_authid, tuple))->rolname);
namespaceId = get_namespace_oid(rname, true);
ReleaseSysCache(tuple);
if (OidIsValid(namespaceId) &&
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 6080ff8f5f..4991a76c41 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -1643,7 +1643,7 @@ get_object_address_type(ObjectType objtype, TypeName *typename, bool missing_ok)
if (objtype == OBJECT_DOMAIN)
{
- if (((Form_pg_type) GETSTRUCT(tup))->typtype != TYPTYPE_DOMAIN)
+ if ((GETSTRUCT(pg_type, tup))->typtype != TYPTYPE_DOMAIN)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a domain",
@@ -1762,7 +1762,7 @@ get_object_address_opf_member(ObjectType objtype,
}
else
{
- address.objectId = ((Form_pg_amop) GETSTRUCT(tp))->oid;
+ address.objectId = (GETSTRUCT(pg_amop, tp))->oid;
ReleaseSysCache(tp);
}
}
@@ -1793,7 +1793,7 @@ get_object_address_opf_member(ObjectType objtype,
}
else
{
- address.objectId = ((Form_pg_amproc) GETSTRUCT(tp))->oid;
+ address.objectId = (GETSTRUCT(pg_amproc, tp))->oid;
ReleaseSysCache(tp);
}
}
@@ -1840,7 +1840,7 @@ get_object_address_usermapping(List *object, bool missing_ok)
username, servername)));
return address;
}
- userid = ((Form_pg_authid) GETSTRUCT(tp))->oid;
+ userid = (GETSTRUCT(pg_authid, tp))->oid;
ReleaseSysCache(tp);
}
@@ -1867,7 +1867,7 @@ get_object_address_usermapping(List *object, bool missing_ok)
return address;
}
- address.objectId = ((Form_pg_user_mapping) GETSTRUCT(tp))->oid;
+ address.objectId = (GETSTRUCT(pg_user_mapping, tp))->oid;
ReleaseSysCache(tp);
@@ -2040,7 +2040,7 @@ get_object_address_defacl(List *object, bool missing_ok)
CStringGetDatum(username));
if (!HeapTupleIsValid(tp))
goto not_found;
- userid = ((Form_pg_authid) GETSTRUCT(tp))->oid;
+ userid = (GETSTRUCT(pg_authid, tp))->oid;
ReleaseSysCache(tp);
/*
@@ -2064,7 +2064,7 @@ get_object_address_defacl(List *object, bool missing_ok)
if (!HeapTupleIsValid(tp))
goto not_found;
- address.objectId = ((Form_pg_default_acl) GETSTRUCT(tp))->oid;
+ address.objectId = (GETSTRUCT(pg_default_acl, tp))->oid;
ReleaseSysCache(tp);
return address;
@@ -2440,7 +2440,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
elog(ERROR, "constraint with OID %u does not exist",
address.objectId);
- contypid = ((Form_pg_constraint) GETSTRUCT(tuple))->contypid;
+ contypid = (GETSTRUCT(pg_constraint, tuple))->contypid;
ReleaseSysCache(tuple);
@@ -2908,7 +2908,7 @@ getPublicationSchemaInfo(const ObjectAddress *object, bool missing_ok,
return false;
}
- pnform = (Form_pg_publication_namespace) GETSTRUCT(tup);
+ pnform = GETSTRUCT(pg_publication_namespace, tup);
*pubname = get_publication_name(pnform->pnpubid, missing_ok);
if (!(*pubname))
{
@@ -3028,7 +3028,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- castForm = (Form_pg_cast) GETSTRUCT(tup);
+ castForm = GETSTRUCT(pg_cast, tup);
appendStringInfo(&buffer, _("cast from %s to %s"),
format_type_be(castForm->castsource),
@@ -3055,7 +3055,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- coll = (Form_pg_collation) GETSTRUCT(collTup);
+ coll = GETSTRUCT(pg_collation, collTup);
/* Qualify the name if not visible in search path */
if (CollationIsVisible(object->objectId))
@@ -3085,7 +3085,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- con = (Form_pg_constraint) GETSTRUCT(conTup);
+ con = GETSTRUCT(pg_constraint, conTup);
if (OidIsValid(con->conrelid))
{
@@ -3124,7 +3124,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- conv = (Form_pg_conversion) GETSTRUCT(conTup);
+ conv = GETSTRUCT(pg_conversion, conTup);
/* Qualify the name if not visible in search path */
if (ConversionIsVisible(object->objectId))
@@ -3208,14 +3208,14 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- opcForm = (Form_pg_opclass) GETSTRUCT(opcTup);
+ opcForm = GETSTRUCT(pg_opclass, opcTup);
amTup = SearchSysCache1(AMOID,
ObjectIdGetDatum(opcForm->opcmethod));
if (!HeapTupleIsValid(amTup))
elog(ERROR, "cache lookup failed for access method %u",
opcForm->opcmethod);
- amForm = (Form_pg_am) GETSTRUCT(amTup);
+ amForm = GETSTRUCT(pg_am, amTup);
/* Qualify the name if not visible in search path */
if (OpclassIsVisible(object->objectId))
@@ -3252,7 +3252,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
}
appendStringInfo(&buffer, _("access method %s"),
- NameStr(((Form_pg_am) GETSTRUCT(tup))->amname));
+ NameStr((GETSTRUCT(pg_am, tup))->amname));
ReleaseSysCache(tup);
break;
}
@@ -3290,7 +3290,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- amopForm = (Form_pg_amop) GETSTRUCT(tup);
+ amopForm = GETSTRUCT(pg_amop, tup);
initStringInfo(&opfam);
getOpFamilyDescription(&opfam, amopForm->amopfamily, false);
@@ -3347,7 +3347,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- amprocForm = (Form_pg_amproc) GETSTRUCT(tup);
+ amprocForm = GETSTRUCT(pg_amproc, tup);
initStringInfo(&opfam);
getOpFamilyDescription(&opfam, amprocForm->amprocfamily, false);
@@ -3403,7 +3403,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- rule = (Form_pg_rewrite) GETSTRUCT(tup);
+ rule = GETSTRUCT(pg_rewrite, tup);
initStringInfo(&rel);
getRelationDescription(&rel, rule->ev_class, false);
@@ -3449,7 +3449,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- trig = (Form_pg_trigger) GETSTRUCT(tup);
+ trig = GETSTRUCT(pg_trigger, tup);
initStringInfo(&rel);
getRelationDescription(&rel, trig->tgrelid, false);
@@ -3495,7 +3495,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- stxForm = (Form_pg_statistic_ext) GETSTRUCT(stxTup);
+ stxForm = GETSTRUCT(pg_statistic_ext, stxTup);
/* Qualify the name if not visible in search path */
if (StatisticsObjIsVisible(object->objectId))
@@ -3526,7 +3526,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
object->objectId);
break;
}
- prsForm = (Form_pg_ts_parser) GETSTRUCT(tup);
+ prsForm = GETSTRUCT(pg_ts_parser, tup);
/* Qualify the name if not visible in search path */
if (TSParserIsVisible(object->objectId))
@@ -3557,7 +3557,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- dictForm = (Form_pg_ts_dict) GETSTRUCT(tup);
+ dictForm = GETSTRUCT(pg_ts_dict, tup);
/* Qualify the name if not visible in search path */
if (TSDictionaryIsVisible(object->objectId))
@@ -3588,7 +3588,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- tmplForm = (Form_pg_ts_template) GETSTRUCT(tup);
+ tmplForm = GETSTRUCT(pg_ts_template, tup);
/* Qualify the name if not visible in search path */
if (TSTemplateIsVisible(object->objectId))
@@ -3619,7 +3619,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- cfgForm = (Form_pg_ts_config) GETSTRUCT(tup);
+ cfgForm = GETSTRUCT(pg_ts_config, tup);
/* Qualify the name if not visible in search path */
if (TSConfigIsVisible(object->objectId))
@@ -3715,7 +3715,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- umform = (Form_pg_user_mapping) GETSTRUCT(tup);
+ umform = GETSTRUCT(pg_user_mapping, tup);
useid = umform->umuser;
srv = GetForeignServer(umform->umserver);
@@ -3764,7 +3764,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- defacl = (Form_pg_default_acl) GETSTRUCT(tup);
+ defacl = GETSTRUCT(pg_default_acl, tup);
rolename = GetUserNameFromId(defacl->defaclrole, false);
@@ -3869,7 +3869,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
appendStringInfo(&buffer, _("event trigger %s"),
- NameStr(((Form_pg_event_trigger) GETSTRUCT(tup))->evtname));
+ NameStr((GETSTRUCT(pg_event_trigger, tup))->evtname));
ReleaseSysCache(tup);
break;
}
@@ -3932,7 +3932,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- form_policy = (Form_pg_policy) GETSTRUCT(tuple);
+ form_policy = GETSTRUCT(pg_policy, tuple);
initStringInfo(&rel);
getRelationDescription(&rel, form_policy->polrelid, false);
@@ -3989,7 +3989,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- prform = (Form_pg_publication_rel) GETSTRUCT(tup);
+ prform = GETSTRUCT(pg_publication_rel, tup);
pubname = get_publication_name(prform->prpubid, false);
initStringInfo(&rel);
@@ -4028,7 +4028,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
break;
}
- trfForm = (Form_pg_transform) GETSTRUCT(trfTup);
+ trfForm = GETSTRUCT(pg_transform, trfTup);
appendStringInfo(&buffer, _("transform for %s language %s"),
format_type_be(trfForm->trftype),
@@ -4087,7 +4087,7 @@ getRelationDescription(StringInfo buffer, Oid relid, bool missing_ok)
elog(ERROR, "cache lookup failed for relation %u", relid);
return;
}
- relForm = (Form_pg_class) GETSTRUCT(relTup);
+ relForm = GETSTRUCT(pg_class, relTup);
/* Qualify the name if not visible in search path */
if (RelationIsVisible(relid))
@@ -4162,13 +4162,13 @@ getOpFamilyDescription(StringInfo buffer, Oid opfid, bool missing_ok)
elog(ERROR, "cache lookup failed for opfamily %u", opfid);
return;
}
- opfForm = (Form_pg_opfamily) GETSTRUCT(opfTup);
+ opfForm = GETSTRUCT(pg_opfamily, opfTup);
amTup = SearchSysCache1(AMOID, ObjectIdGetDatum(opfForm->opfmethod));
if (!HeapTupleIsValid(amTup))
elog(ERROR, "cache lookup failed for access method %u",
opfForm->opfmethod);
- amForm = (Form_pg_am) GETSTRUCT(amTup);
+ amForm = GETSTRUCT(pg_am, amTup);
/* Qualify the name if not visible in search path */
if (OpfamilyIsVisible(opfid))
@@ -4626,7 +4626,7 @@ getRelationTypeDescription(StringInfo buffer, Oid relid, int32 objectSubId,
appendStringInfoString(buffer, "relation");
return;
}
- relForm = (Form_pg_class) GETSTRUCT(relTup);
+ relForm = GETSTRUCT(pg_class, relTup);
switch (relForm->relkind)
{
@@ -4693,7 +4693,7 @@ getConstraintTypeDescription(StringInfo buffer, Oid constroid, bool missing_ok)
return;
}
- constrForm = (Form_pg_constraint) GETSTRUCT(constrTup);
+ constrForm = GETSTRUCT(pg_constraint, constrTup);
if (OidIsValid(constrForm->conrelid))
appendStringInfoString(buffer, "table constraint");
@@ -4726,7 +4726,7 @@ getProcedureTypeDescription(StringInfo buffer, Oid procid,
appendStringInfoString(buffer, "routine");
return;
}
- procForm = (Form_pg_proc) GETSTRUCT(procTup);
+ procForm = GETSTRUCT(pg_proc, procTup);
if (procForm->prokind == PROKIND_AGGREGATE)
appendStringInfoString(buffer, "aggregate");
@@ -4870,7 +4870,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- castForm = (Form_pg_cast) GETSTRUCT(tup);
+ castForm = GETSTRUCT(pg_cast, tup);
appendStringInfo(&buffer, "(%s AS %s)",
format_type_be_qualified(castForm->castsource),
@@ -4901,7 +4901,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- coll = (Form_pg_collation) GETSTRUCT(collTup);
+ coll = GETSTRUCT(pg_collation, collTup);
schema = get_namespace_name_or_temp(coll->collnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -4927,7 +4927,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- con = (Form_pg_constraint) GETSTRUCT(conTup);
+ con = GETSTRUCT(pg_constraint, conTup);
if (OidIsValid(con->conrelid))
{
@@ -4975,7 +4975,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- conForm = (Form_pg_conversion) GETSTRUCT(conTup);
+ conForm = GETSTRUCT(pg_conversion, conTup);
schema = get_namespace_name_or_temp(conForm->connamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5022,7 +5022,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- langForm = (Form_pg_language) GETSTRUCT(langTup);
+ langForm = GETSTRUCT(pg_language, langTup);
appendStringInfoString(&buffer,
quote_identifier(NameStr(langForm->lanname)));
if (objname)
@@ -5071,7 +5071,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- opcForm = (Form_pg_opclass) GETSTRUCT(opcTup);
+ opcForm = GETSTRUCT(pg_opclass, opcTup);
schema = get_namespace_name_or_temp(opcForm->opcnamespace);
amTup = SearchSysCache1(AMOID,
@@ -5079,7 +5079,7 @@ getObjectIdentityParts(const ObjectAddress *object,
if (!HeapTupleIsValid(amTup))
elog(ERROR, "cache lookup failed for access method %u",
opcForm->opcmethod);
- amForm = (Form_pg_am) GETSTRUCT(amTup);
+ amForm = GETSTRUCT(pg_am, amTup);
appendStringInfo(&buffer, "%s USING %s",
quote_qualified_identifier(schema,
@@ -5153,7 +5153,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- amopForm = (Form_pg_amop) GETSTRUCT(tup);
+ amopForm = GETSTRUCT(pg_amop, tup);
initStringInfo(&opfam);
getOpFamilyIdentity(&opfam, amopForm->amopfamily, objname,
@@ -5215,7 +5215,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- amprocForm = (Form_pg_amproc) GETSTRUCT(tup);
+ amprocForm = GETSTRUCT(pg_amproc, tup);
initStringInfo(&opfam);
getOpFamilyIdentity(&opfam, amprocForm->amprocfamily, objname,
@@ -5263,7 +5263,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- rule = (Form_pg_rewrite) GETSTRUCT(tup);
+ rule = GETSTRUCT(pg_rewrite, tup);
appendStringInfo(&buffer, "%s on ",
quote_identifier(NameStr(rule->rulename)));
@@ -5296,7 +5296,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- trig = (Form_pg_trigger) GETSTRUCT(tup);
+ trig = GETSTRUCT(pg_trigger, tup);
appendStringInfo(&buffer, "%s on ",
quote_identifier(NameStr(trig->tgname)));
@@ -5342,7 +5342,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formStatistic = (Form_pg_statistic_ext) GETSTRUCT(tup);
+ formStatistic = GETSTRUCT(pg_statistic_ext, tup);
schema = get_namespace_name_or_temp(formStatistic->stxnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5369,7 +5369,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formParser = (Form_pg_ts_parser) GETSTRUCT(tup);
+ formParser = GETSTRUCT(pg_ts_parser, tup);
schema = get_namespace_name_or_temp(formParser->prsnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5396,7 +5396,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formDict = (Form_pg_ts_dict) GETSTRUCT(tup);
+ formDict = GETSTRUCT(pg_ts_dict, tup);
schema = get_namespace_name_or_temp(formDict->dictnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5423,7 +5423,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formTmpl = (Form_pg_ts_template) GETSTRUCT(tup);
+ formTmpl = GETSTRUCT(pg_ts_template, tup);
schema = get_namespace_name_or_temp(formTmpl->tmplnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5450,7 +5450,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- formCfg = (Form_pg_ts_config) GETSTRUCT(tup);
+ formCfg = GETSTRUCT(pg_ts_config, tup);
schema = get_namespace_name_or_temp(formCfg->cfgnamespace);
appendStringInfoString(&buffer,
quote_qualified_identifier(schema,
@@ -5562,7 +5562,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- umform = (Form_pg_user_mapping) GETSTRUCT(tup);
+ umform = GETSTRUCT(pg_user_mapping, tup);
useid = umform->umuser;
srv = GetForeignServer(umform->umserver);
@@ -5618,7 +5618,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- defacl = (Form_pg_default_acl) GETSTRUCT(tup);
+ defacl = GETSTRUCT(pg_default_acl, tup);
username = GetUserNameFromId(defacl->defaclrole, false);
appendStringInfo(&buffer,
@@ -5705,7 +5705,7 @@ getObjectIdentityParts(const ObjectAddress *object,
object->objectId);
break;
}
- trigForm = (Form_pg_event_trigger) GETSTRUCT(tup);
+ trigForm = GETSTRUCT(pg_event_trigger, tup);
evtname = pstrdup(NameStr(trigForm->evtname));
appendStringInfoString(&buffer, quote_identifier(evtname));
if (objname)
@@ -5763,7 +5763,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- policy = (Form_pg_policy) GETSTRUCT(tup);
+ policy = GETSTRUCT(pg_policy, tup);
appendStringInfo(&buffer, "%s on ",
quote_identifier(NameStr(policy->polname)));
@@ -5830,7 +5830,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- prform = (Form_pg_publication_rel) GETSTRUCT(tup);
+ prform = GETSTRUCT(pg_publication_rel, tup);
pubname = get_publication_name(prform->prpubid, false);
getRelationIdentity(&buffer, prform->prrelid, objname, false);
@@ -5882,7 +5882,7 @@ getObjectIdentityParts(const ObjectAddress *object,
break;
}
- transform = (Form_pg_transform) GETSTRUCT(tup);
+ transform = GETSTRUCT(pg_transform, tup);
transformType = format_type_be_qualified(transform->trftype);
transformLang = get_language_name(transform->trflang, false);
@@ -5948,13 +5948,13 @@ getOpFamilyIdentity(StringInfo buffer, Oid opfid, List **object,
elog(ERROR, "cache lookup failed for opfamily %u", opfid);
return;
}
- opfForm = (Form_pg_opfamily) GETSTRUCT(opfTup);
+ opfForm = GETSTRUCT(pg_opfamily, opfTup);
amTup = SearchSysCache1(AMOID, ObjectIdGetDatum(opfForm->opfmethod));
if (!HeapTupleIsValid(amTup))
elog(ERROR, "cache lookup failed for access method %u",
opfForm->opfmethod);
- amForm = (Form_pg_am) GETSTRUCT(amTup);
+ amForm = GETSTRUCT(pg_am, amTup);
schema = get_namespace_name_or_temp(opfForm->opfnamespace);
appendStringInfo(buffer, "%s USING %s",
@@ -5994,7 +5994,7 @@ getRelationIdentity(StringInfo buffer, Oid relid, List **object,
*object = NIL;
return;
}
- relForm = (Form_pg_class) GETSTRUCT(relTup);
+ relForm = GETSTRUCT(pg_class, relTup);
schema = get_namespace_name_or_temp(relForm->relnamespace);
appendStringInfoString(buffer,
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c
index c6ec479004..a3d4ebe38d 100644
--- a/src/backend/catalog/partition.c
+++ b/src/backend/catalog/partition.c
@@ -106,7 +106,7 @@ get_partition_parent_worker(Relation inhRel, Oid relid, bool *detach_pending)
tuple = systable_getnext(scan);
if (HeapTupleIsValid(tuple))
{
- Form_pg_inherits form = (Form_pg_inherits) GETSTRUCT(tuple);
+ Form_pg_inherits form = GETSTRUCT(pg_inherits, tuple);
/* Let caller know of partition being detached */
if (form->inhdetachpending)
@@ -187,7 +187,7 @@ index_get_partition(Relation partition, Oid indexId)
tup = SearchSysCache1(RELOID, ObjectIdGetDatum(partIdx));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for relation %u", partIdx);
- classForm = (Form_pg_class) GETSTRUCT(tup);
+ classForm = GETSTRUCT(pg_class, tup);
ispartition = classForm->relispartition;
ReleaseSysCache(tup);
if (!ispartition)
@@ -321,7 +321,7 @@ get_default_partition_oid(Oid parentId)
{
Form_pg_partitioned_table part_table_form;
- part_table_form = (Form_pg_partitioned_table) GETSTRUCT(tuple);
+ part_table_form = GETSTRUCT(pg_partitioned_table, tuple);
defaultPartId = part_table_form->partdefid;
ReleaseSysCache(tuple);
}
@@ -349,7 +349,7 @@ update_default_partition_oid(Oid parentId, Oid defaultPartId)
elog(ERROR, "cache lookup failed for partition key of relation %u",
parentId);
- part_table_form = (Form_pg_partitioned_table) GETSTRUCT(tuple);
+ part_table_form = GETSTRUCT(pg_partitioned_table, tuple);
part_table_form->partdefid = defaultPartId;
CatalogTupleUpdate(pg_partitioned_table, &tuple->t_self, tuple);
diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c
index 0d0daa69b3..392296edbe 100644
--- a/src/backend/catalog/pg_aggregate.c
+++ b/src/backend/catalog/pg_aggregate.c
@@ -250,7 +250,7 @@ AggregateCreate(const char *aggName,
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(transfn));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for function %u", transfn);
- proc = (Form_pg_proc) GETSTRUCT(tup);
+ proc = GETSTRUCT(pg_proc, tup);
/*
* If the transfn is strict and the initval is NULL, make sure first input
@@ -294,7 +294,7 @@ AggregateCreate(const char *aggName,
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(mtransfn));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for function %u", mtransfn);
- proc = (Form_pg_proc) GETSTRUCT(tup);
+ proc = GETSTRUCT(pg_proc, tup);
/*
* If the mtransfn is strict and the minitval is NULL, check first
@@ -339,7 +339,7 @@ AggregateCreate(const char *aggName,
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(minvtransfn));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for function %u", minvtransfn);
- proc = (Form_pg_proc) GETSTRUCT(tup);
+ proc = GETSTRUCT(pg_proc, tup);
/*
* We require the strictness settings of the forward and inverse
@@ -692,7 +692,7 @@ AggregateCreate(const char *aggName,
if (HeapTupleIsValid(oldtup))
{
- Form_pg_aggregate oldagg = (Form_pg_aggregate) GETSTRUCT(oldtup);
+ Form_pg_aggregate oldagg = GETSTRUCT(pg_aggregate, oldtup);
/*
* If we're replacing an existing entry, we need to validate that
diff --git a/src/backend/catalog/pg_attrdef.c b/src/backend/catalog/pg_attrdef.c
index 1a14093a9a..16cabe1776 100644
--- a/src/backend/catalog/pg_attrdef.c
+++ b/src/backend/catalog/pg_attrdef.c
@@ -101,7 +101,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
if (!HeapTupleIsValid(atttup))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, RelationGetRelid(rel));
- attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
+ attStruct = GETSTRUCT(pg_attribute, atttup);
attgenerated = attStruct->attgenerated;
if (!attStruct->atthasdef)
{
@@ -237,7 +237,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
ObjectAddress object;
- Form_pg_attrdef attrtuple = (Form_pg_attrdef) GETSTRUCT(tuple);
+ Form_pg_attrdef attrtuple = GETSTRUCT(pg_attrdef, tuple);
object.classId = AttrDefaultRelationId;
object.objectId = attrtuple->oid;
@@ -292,8 +292,8 @@ RemoveAttrDefaultById(Oid attrdefId)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for attrdef %u", attrdefId);
- myrelid = ((Form_pg_attrdef) GETSTRUCT(tuple))->adrelid;
- myattnum = ((Form_pg_attrdef) GETSTRUCT(tuple))->adnum;
+ myrelid = (GETSTRUCT(pg_attrdef, tuple))->adrelid;
+ myattnum = (GETSTRUCT(pg_attrdef, tuple))->adnum;
/* Get an exclusive lock on the relation owning the attribute */
myrel = relation_open(myrelid, AccessExclusiveLock);
@@ -314,7 +314,7 @@ RemoveAttrDefaultById(Oid attrdefId)
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
myattnum, myrelid);
- ((Form_pg_attribute) GETSTRUCT(tuple))->atthasdef = false;
+ (GETSTRUCT(pg_attribute, tuple))->atthasdef = false;
CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple);
@@ -360,7 +360,7 @@ GetAttrDefaultOid(Oid relid, AttrNumber attnum)
if (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_attrdef atdform = (Form_pg_attrdef) GETSTRUCT(tup);
+ Form_pg_attrdef atdform = GETSTRUCT(pg_attrdef, tup);
result = atdform->oid;
}
@@ -396,7 +396,7 @@ GetAttrDefaultColumnAddress(Oid attrdefoid)
if (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_attrdef atdform = (Form_pg_attrdef) GETSTRUCT(tup);
+ Form_pg_attrdef atdform = GETSTRUCT(pg_attrdef, tup);
result.classId = RelationRelationId;
result.objectId = atdform->adrelid;
diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c
index bb65fb1e0a..48f1653242 100644
--- a/src/backend/catalog/pg_constraint.c
+++ b/src/backend/catalog/pg_constraint.c
@@ -577,7 +577,7 @@ RemoveConstraintById(Oid conId)
tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for constraint %u", conId);
- con = (Form_pg_constraint) GETSTRUCT(tup);
+ con = GETSTRUCT(pg_constraint, tup);
/*
* Special processing depending on what the constraint is for.
@@ -609,7 +609,7 @@ RemoveConstraintById(Oid conId)
if (!HeapTupleIsValid(relTup))
elog(ERROR, "cache lookup failed for relation %u",
con->conrelid);
- classForm = (Form_pg_class) GETSTRUCT(relTup);
+ classForm = GETSTRUCT(pg_class, relTup);
if (classForm->relchecks == 0) /* should not happen */
elog(ERROR, "relation \"%s\" has relchecks = 0",
@@ -668,7 +668,7 @@ RenameConstraintById(Oid conId, const char *newname)
tuple = SearchSysCacheCopy1(CONSTROID, ObjectIdGetDatum(conId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", conId);
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
/*
* For user-friendliness, check whether the name is already in use.
@@ -733,7 +733,7 @@ AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(tup);
+ Form_pg_constraint conform = GETSTRUCT(pg_constraint, tup);
ObjectAddress thisobj;
ObjectAddressSet(thisobj, ConstraintRelationId, conform->oid);
@@ -745,7 +745,7 @@ AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
if (conform->connamespace == oldNspId && oldNspId != newNspId)
{
tup = heap_copytuple(tup);
- conform = (Form_pg_constraint) GETSTRUCT(tup);
+ conform = GETSTRUCT(pg_constraint, tup);
conform->connamespace = newNspId;
@@ -794,7 +794,7 @@ ConstraintSetParentConstraint(Oid childConstrId,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", childConstrId);
newtup = heap_copytuple(tuple);
- constrForm = (Form_pg_constraint) GETSTRUCT(newtup);
+ constrForm = GETSTRUCT(pg_constraint, newtup);
if (OidIsValid(parentConstrId))
{
/* don't allow setting parent for a constraint that already has one */
@@ -875,7 +875,7 @@ get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok)
/* There can be at most one matching row */
if (HeapTupleIsValid(tuple = systable_getnext(scan)))
- conOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ conOid = (GETSTRUCT(pg_constraint, tuple))->oid;
systable_endscan(scan);
@@ -940,7 +940,7 @@ get_relation_constraint_attnos(Oid relid, const char *conname,
Datum adatum;
bool isNull;
- *constraintOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ *constraintOid = (GETSTRUCT(pg_constraint, tuple))->oid;
/* Extract the conkey array, ie, attnums of constrained columns */
adatum = heap_getattr(tuple, Anum_pg_constraint_conkey,
@@ -1010,7 +1010,7 @@ get_relation_idx_constraint_oid(Oid relationId, Oid indexId)
{
Form_pg_constraint constrForm;
- constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ constrForm = GETSTRUCT(pg_constraint, tuple);
if (constrForm->conindid == indexId)
{
constraintId = constrForm->oid;
@@ -1057,7 +1057,7 @@ get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok)
/* There can be at most one matching row */
if (HeapTupleIsValid(tuple = systable_getnext(scan)))
- conOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ conOid = (GETSTRUCT(pg_constraint, tuple))->oid;
systable_endscan(scan);
@@ -1112,7 +1112,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid)
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
Datum adatum;
bool isNull;
ArrayType *arr;
@@ -1137,7 +1137,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid)
RelationGetDescr(pg_constraint), &isNull);
if (isNull)
elog(ERROR, "null conkey for constraint %u",
- ((Form_pg_constraint) GETSTRUCT(tuple))->oid);
+ (GETSTRUCT(pg_constraint, tuple))->oid);
arr = DatumGetArrayTypeP(adatum); /* ensure not toasted */
numkeys = ARR_DIMS(arr)[0];
if (ARR_NDIM(arr) != 1 ||
@@ -1153,7 +1153,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid)
pkattnos = bms_add_member(pkattnos,
attnums[i] - FirstLowInvalidHeapAttributeNumber);
}
- *constraintOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ *constraintOid = (GETSTRUCT(pg_constraint, tuple))->oid;
/* No need to search further */
break;
@@ -1185,7 +1185,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ArrayType *arr;
int numkeys;
- constrId = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+ constrId = (GETSTRUCT(pg_constraint, tuple))->oid;
/*
* We expect the arrays to be 1-D arrays of the right types; verify that.
diff --git a/src/backend/catalog/pg_conversion.c b/src/backend/catalog/pg_conversion.c
index 3d8b86ace7..4a39593d4a 100644
--- a/src/backend/catalog/pg_conversion.c
+++ b/src/backend/catalog/pg_conversion.c
@@ -168,7 +168,7 @@ FindDefaultConversion(Oid name_space, int32 for_encoding, int32 to_encoding)
for (i = 0; i < catlist->n_members; i++)
{
tuple = &catlist->members[i]->tuple;
- body = (Form_pg_conversion) GETSTRUCT(tuple);
+ body = GETSTRUCT(pg_conversion, tuple);
if (body->condefault)
{
proc = body->conproc;
diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c
index e86e5e6898..20ebdcc6e6 100644
--- a/src/backend/catalog/pg_depend.c
+++ b/src/backend/catalog/pg_depend.c
@@ -266,7 +266,7 @@ deleteDependencyRecordsFor(Oid classId, Oid objectId,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
if (skipExtensionDeps &&
- ((Form_pg_depend) GETSTRUCT(tup))->deptype == DEPENDENCY_EXTENSION)
+ (GETSTRUCT(pg_depend, tup))->deptype == DEPENDENCY_EXTENSION)
continue;
CatalogTupleDelete(depRel, &tup->t_self);
@@ -315,7 +315,7 @@ deleteDependencyRecordsForClass(Oid classId, Oid objectId,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == refclassId && depform->deptype == deptype)
{
@@ -362,7 +362,7 @@ deleteDependencyRecordsForSpecific(Oid classId, Oid objectId, char deptype,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == refclassId &&
depform->refobjid == refobjectId &&
@@ -464,7 +464,7 @@ changeDependencyFor(Oid classId, Oid objectId,
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == refClassId &&
depform->refobjid == oldRefObjectId)
@@ -475,7 +475,7 @@ changeDependencyFor(Oid classId, Oid objectId,
{
/* make a modifiable copy */
tup = heap_copytuple(tup);
- depform = (Form_pg_depend) GETSTRUCT(tup);
+ depform = GETSTRUCT(pg_depend, tup);
depform->refobjid = newRefObjectId;
@@ -533,7 +533,7 @@ changeDependenciesOf(Oid classId, Oid oldObjectId,
/* make a modifiable copy */
tup = heap_copytuple(tup);
- depform = (Form_pg_depend) GETSTRUCT(tup);
+ depform = GETSTRUCT(pg_depend, tup);
depform->objid = newObjectId;
@@ -620,7 +620,7 @@ changeDependenciesOn(Oid refClassId, Oid oldRefObjectId,
/* make a modifiable copy */
tup = heap_copytuple(tup);
- depform = (Form_pg_depend) GETSTRUCT(tup);
+ depform = GETSTRUCT(pg_depend, tup);
depform->refobjid = newRefObjectId;
@@ -695,7 +695,7 @@ getExtensionOfObject(Oid classId, Oid objectId)
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == ExtensionRelationId &&
depform->deptype == DEPENDENCY_EXTENSION)
@@ -741,7 +741,7 @@ getAutoExtensionsOfObject(Oid classId, Oid objectId)
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == ExtensionRelationId &&
depform->deptype == DEPENDENCY_AUTO_EXTENSION)
@@ -791,7 +791,7 @@ sequenceIsOwned(Oid seqId, char deptype, Oid *tableId, int32 *colId)
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depform = GETSTRUCT(pg_depend, tup);
if (depform->refclassid == RelationRelationId &&
depform->deptype == deptype)
@@ -845,7 +845,7 @@ getOwnedSequences_internal(Oid relid, AttrNumber attnum, char deptype)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend deprec = GETSTRUCT(pg_depend, tup);
/*
* We assume any auto or internal dependency of a sequence on a column
@@ -937,7 +937,7 @@ get_index_constraint(Oid indexId)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend deprec = GETSTRUCT(pg_depend, tup);
/*
* We assume any internal dependency on a constraint must be what we
@@ -993,7 +993,7 @@ get_index_ref_constraints(Oid indexId)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend deprec = GETSTRUCT(pg_depend, tup);
/*
* We assume any normal dependency from a constraint must be what we
diff --git a/src/backend/catalog/pg_enum.c b/src/backend/catalog/pg_enum.c
index 114715498d..3a518b9122 100644
--- a/src/backend/catalog/pg_enum.c
+++ b/src/backend/catalog/pg_enum.c
@@ -292,7 +292,7 @@ restart:
*/
if (nelems > 0)
{
- Form_pg_enum en = (Form_pg_enum) GETSTRUCT(existing[nelems - 1]);
+ Form_pg_enum en = GETSTRUCT(pg_enum, existing[nelems - 1]);
newelemorder = en->enumsortorder + 1;
}
@@ -310,7 +310,7 @@ restart:
/* Locate the neighbor element */
for (nbr_index = 0; nbr_index < nelems; nbr_index++)
{
- Form_pg_enum en = (Form_pg_enum) GETSTRUCT(existing[nbr_index]);
+ Form_pg_enum en = GETSTRUCT(pg_enum, existing[nbr_index]);
if (strcmp(NameStr(en->enumlabel), neighbor) == 0)
break;
@@ -320,7 +320,7 @@ restart:
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" is not an existing enum label",
neighbor)));
- nbr_en = (Form_pg_enum) GETSTRUCT(existing[nbr_index]);
+ nbr_en = GETSTRUCT(pg_enum, existing[nbr_index]);
/*
* Attempt to assign an appropriate enumsortorder value: one less than
@@ -352,7 +352,7 @@ restart:
*/
volatile float4 midpoint;
- other_nbr_en = (Form_pg_enum) GETSTRUCT(existing[other_nbr_index]);
+ other_nbr_en = GETSTRUCT(pg_enum, existing[other_nbr_index]);
midpoint = (nbr_en->enumsortorder +
other_nbr_en->enumsortorder) / 2;
@@ -418,7 +418,7 @@ restart:
for (i = 0; i < nelems; i++)
{
HeapTuple exists_tup = existing[i];
- Form_pg_enum exists_en = (Form_pg_enum) GETSTRUCT(exists_tup);
+ Form_pg_enum exists_en = GETSTRUCT(pg_enum, exists_tup);
Oid exists_oid = exists_en->oid;
if (exists_oid & 1)
@@ -552,7 +552,7 @@ RenameEnumLabel(Oid enumTypeOid,
for (i = 0; i < nelems; i++)
{
enum_tup = &(list->members[i]->tuple);
- en = (Form_pg_enum) GETSTRUCT(enum_tup);
+ en = GETSTRUCT(pg_enum, enum_tup);
if (strcmp(NameStr(en->enumlabel), oldVal) == 0)
old_tup = enum_tup;
if (strcmp(NameStr(en->enumlabel), newVal) == 0)
@@ -571,7 +571,7 @@ RenameEnumLabel(Oid enumTypeOid,
/* OK, make a writable copy of old tuple */
enum_tup = heap_copytuple(old_tup);
- en = (Form_pg_enum) GETSTRUCT(enum_tup);
+ en = GETSTRUCT(pg_enum, enum_tup);
ReleaseCatCacheList(list);
@@ -656,7 +656,7 @@ RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems)
float4 newsortorder;
newtup = heap_copytuple(existing[i]);
- en = (Form_pg_enum) GETSTRUCT(newtup);
+ en = GETSTRUCT(pg_enum, newtup);
newsortorder = i + 1;
if (en->enumsortorder != newsortorder)
@@ -680,8 +680,8 @@ sort_order_cmp(const void *p1, const void *p2)
{
HeapTuple v1 = *((const HeapTuple *) p1);
HeapTuple v2 = *((const HeapTuple *) p2);
- Form_pg_enum en1 = (Form_pg_enum) GETSTRUCT(v1);
- Form_pg_enum en2 = (Form_pg_enum) GETSTRUCT(v2);
+ Form_pg_enum en1 = GETSTRUCT(pg_enum, v1);
+ Form_pg_enum en2 = GETSTRUCT(pg_enum, v2);
if (en1->enumsortorder < en2->enumsortorder)
return -1;
diff --git a/src/backend/catalog/pg_inherits.c b/src/backend/catalog/pg_inherits.c
index 92afbc2f25..2764c1c35c 100644
--- a/src/backend/catalog/pg_inherits.c
+++ b/src/backend/catalog/pg_inherits.c
@@ -136,7 +136,7 @@ find_inheritance_children_extended(Oid parentrelId, bool omit_detached,
* SERIALIZABLE transactions: such queries use a different snapshot
* than the one used by regular (user) queries.
*/
- if (((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending)
+ if ((GETSTRUCT(pg_inherits, inheritsTuple))->inhdetachpending)
{
if (detached_exist)
*detached_exist = true;
@@ -179,7 +179,7 @@ find_inheritance_children_extended(Oid parentrelId, bool omit_detached,
}
}
- inhrelid = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhrelid;
+ inhrelid = (GETSTRUCT(pg_inherits, inheritsTuple))->inhrelid;
if (numoids >= maxoids)
{
maxoids *= 2;
@@ -362,7 +362,7 @@ has_subclass(Oid relationId)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationId);
- result = ((Form_pg_class) GETSTRUCT(tuple))->relhassubclass;
+ result = (GETSTRUCT(pg_class, tuple))->relhassubclass;
ReleaseSysCache(tuple);
return result;
}
@@ -473,7 +473,7 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId)
while ((inhtup = systable_getnext(inhscan)) != NULL)
{
- Form_pg_inherits inh = (Form_pg_inherits) GETSTRUCT(inhtup);
+ Form_pg_inherits inh = GETSTRUCT(pg_inherits, inhtup);
Oid inhparent = inh->inhparent;
/* If this is the target superclass, we're done */
@@ -575,13 +575,13 @@ DeleteInheritsTuple(Oid inhrelid, Oid inhparent, bool expect_detach_pending,
Oid parent;
/* Compare inhparent if it was given, and do the actual deletion. */
- parent = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhparent;
+ parent = (GETSTRUCT(pg_inherits, inheritsTuple))->inhparent;
if (!OidIsValid(inhparent) || parent == inhparent)
{
bool detach_pending;
detach_pending =
- ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending;
+ (GETSTRUCT(pg_inherits, inheritsTuple))->inhdetachpending;
/*
* Raise error depending on state. This should only happen for
@@ -643,7 +643,7 @@ PartitionHasPendingDetach(Oid partoid)
bool detached;
detached =
- ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending;
+ (GETSTRUCT(pg_inherits, inheritsTuple))->inhdetachpending;
/* Done */
systable_endscan(scan);
diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c
index 630bf3e56c..6b4db2306f 100644
--- a/src/backend/catalog/pg_operator.c
+++ b/src/backend/catalog/pg_operator.c
@@ -143,7 +143,7 @@ OperatorGet(const char *operatorName,
ObjectIdGetDatum(operatorNamespace));
if (HeapTupleIsValid(tup))
{
- Form_pg_operator oprform = (Form_pg_operator) GETSTRUCT(tup);
+ Form_pg_operator oprform = GETSTRUCT(pg_operator, tup);
operatorObjectId = oprform->oid;
*defined = RegProcedureIsValid(oprform->oprcode);
@@ -677,7 +677,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId, bool isDelete)
/* Update the commutator's tuple if need be. */
if (HeapTupleIsValid(tup))
{
- Form_pg_operator t = (Form_pg_operator) GETSTRUCT(tup);
+ Form_pg_operator t = GETSTRUCT(pg_operator, tup);
bool update_commutator = false;
/*
@@ -722,7 +722,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId, bool isDelete)
if (HeapTupleIsValid(tup))
{
- Form_pg_operator t = (Form_pg_operator) GETSTRUCT(tup);
+ Form_pg_operator t = GETSTRUCT(pg_operator, tup);
bool update_negator = false;
/*
@@ -778,7 +778,7 @@ makeOperatorDependencies(HeapTuple tuple,
bool makeExtensionDep,
bool isUpdate)
{
- Form_pg_operator oper = (Form_pg_operator) GETSTRUCT(tuple);
+ Form_pg_operator oper = GETSTRUCT(pg_operator, tuple);
ObjectAddress myself,
referenced;
ObjectAddresses *addrs;
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index a9fe45e347..8eed22b3fb 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -365,7 +365,7 @@ ProcedureCreate(const char *procedureName,
if (HeapTupleIsValid(oldtup))
{
/* There is one; okay to replace it? */
- Form_pg_proc oldproc = (Form_pg_proc) GETSTRUCT(oldtup);
+ Form_pg_proc oldproc = GETSTRUCT(pg_proc, oldtup);
Datum proargnames;
bool isnull;
const char *dropcmd;
@@ -586,7 +586,7 @@ ProcedureCreate(const char *procedureName,
}
- retval = ((Form_pg_proc) GETSTRUCT(tup))->oid;
+ retval = (GETSTRUCT(pg_proc, tup))->oid;
/*
* Create dependencies for the new function. If we are updating an
@@ -842,7 +842,7 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- proc = (Form_pg_proc) GETSTRUCT(tuple);
+ proc = GETSTRUCT(pg_proc, tuple);
/* Disallow pseudotype result */
/* except for RECORD, VOID, or polymorphic */
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index e294bea60c..4239c85289 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -236,7 +236,7 @@ pg_relation_is_publishable(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- result = is_publishable_class(relid, (Form_pg_class) GETSTRUCT(tuple));
+ result = is_publishable_class(relid, GETSTRUCT(pg_class, tuple));
ReleaseSysCache(tuple);
PG_RETURN_BOOL(result);
}
@@ -678,7 +678,7 @@ GetRelationPublications(Oid relid)
for (i = 0; i < pubrellist->n_members; i++)
{
HeapTuple tup = &pubrellist->members[i]->tuple;
- Oid pubid = ((Form_pg_publication_rel) GETSTRUCT(tup))->prpubid;
+ Oid pubid = (GETSTRUCT(pg_publication_rel, tup))->prpubid;
result = lappend_oid(result, pubid);
}
@@ -719,7 +719,7 @@ GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
{
Form_pg_publication_rel pubrel;
- pubrel = (Form_pg_publication_rel) GETSTRUCT(tup);
+ pubrel = GETSTRUCT(pg_publication_rel, tup);
result = GetPubPartitionOptionRelations(result, pub_partopt,
pubrel->prrelid);
}
@@ -760,7 +760,7 @@ GetAllTablesPublications(void)
result = NIL;
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Oid oid = ((Form_pg_publication) GETSTRUCT(tup))->oid;
+ Oid oid = (GETSTRUCT(pg_publication, tup))->oid;
result = lappend_oid(result, oid);
}
@@ -798,7 +798,7 @@ GetAllTablesPublicationRelations(bool pubviaroot)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class relForm = GETSTRUCT(pg_class, tuple);
Oid relid = relForm->oid;
if (is_publishable_class(relid, relForm) &&
@@ -819,7 +819,7 @@ GetAllTablesPublicationRelations(bool pubviaroot)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class relForm = GETSTRUCT(pg_class, tuple);
Oid relid = relForm->oid;
if (is_publishable_class(relid, relForm) &&
@@ -863,7 +863,7 @@ GetPublicationSchemas(Oid pubid)
{
Form_pg_publication_namespace pubsch;
- pubsch = (Form_pg_publication_namespace) GETSTRUCT(tup);
+ pubsch = GETSTRUCT(pg_publication_namespace, tup);
result = lappend_oid(result, pubsch->pnnspid);
}
@@ -890,7 +890,7 @@ GetSchemaPublications(Oid schemaid)
for (i = 0; i < pubschlist->n_members; i++)
{
HeapTuple tup = &pubschlist->members[i]->tuple;
- Oid pubid = ((Form_pg_publication_namespace) GETSTRUCT(tup))->pnpubid;
+ Oid pubid = (GETSTRUCT(pg_publication_namespace, tup))->pnpubid;
result = lappend_oid(result, pubid);
}
@@ -925,7 +925,7 @@ GetSchemaPublicationRelations(Oid schemaid, PublicationPartOpt pub_partopt)
scan = table_beginscan_catalog(classRel, 1, key);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class relForm = GETSTRUCT(pg_class, tuple);
Oid relid = relForm->oid;
char relkind;
@@ -995,7 +995,7 @@ GetPublication(Oid pubid)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication %u", pubid);
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
pub = (Publication *) palloc(sizeof(Publication));
pub->oid = pubid;
@@ -1068,7 +1068,7 @@ get_publication_name(Oid pubid, bool missing_ok)
return NULL;
}
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
pubname = pstrdup(NameStr(pubform->pubname));
ReleaseSysCache(tup);
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index 3e8fa008b9..b0f6ca6f8a 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -242,7 +242,7 @@ shdepChangeDep(Relation sdepRel,
while ((scantup = systable_getnext(scan)) != NULL)
{
/* Ignore if not of the target dependency type */
- if (((Form_pg_shdepend) GETSTRUCT(scantup))->deptype != deptype)
+ if ((GETSTRUCT(pg_shdepend, scantup))->deptype != deptype)
continue;
/* Caller screwed up if multiple matches */
if (oldtup)
@@ -263,7 +263,7 @@ shdepChangeDep(Relation sdepRel,
else if (oldtup)
{
/* Need to update existing entry */
- Form_pg_shdepend shForm = (Form_pg_shdepend) GETSTRUCT(oldtup);
+ Form_pg_shdepend shForm = GETSTRUCT(pg_shdepend, oldtup);
/* Since oldtup is a copy, we can just modify it in-memory */
shForm->refclassid = refclassid;
@@ -692,7 +692,7 @@ checkSharedDependencies(Oid classId, Oid objectId,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tup);
+ Form_pg_shdepend sdepForm = GETSTRUCT(pg_shdepend, tup);
object.classId = sdepForm->classid;
object.objectId = sdepForm->objid;
@@ -907,7 +907,7 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId)
memset(slot[slot_stored_count]->tts_isnull, false,
slot[slot_stored_count]->tts_tupleDescriptor->natts * sizeof(bool));
- shdep = (Form_pg_shdepend) GETSTRUCT(tup);
+ shdep = GETSTRUCT(pg_shdepend, tup);
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_dbid - 1] = ObjectIdGetDatum(newDbId);
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_classid - 1] = shdep->classid;
@@ -1115,7 +1115,7 @@ shdepDropDependency(Relation sdepRel,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_shdepend shdepForm = (Form_pg_shdepend) GETSTRUCT(tup);
+ Form_pg_shdepend shdepForm = GETSTRUCT(pg_shdepend, tup);
/* Filter entries according to additional parameters */
if (OidIsValid(refclassId) && shdepForm->refclassid != refclassId)
@@ -1347,7 +1347,7 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
while ((tuple = systable_getnext(scan)) != NULL)
{
- Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tuple);
+ Form_pg_shdepend sdepForm = GETSTRUCT(pg_shdepend, tuple);
ObjectAddress obj;
/*
@@ -1497,7 +1497,7 @@ shdepReassignOwned(List *roleids, Oid newrole)
while ((tuple = systable_getnext(scan)) != NULL)
{
- Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tuple);
+ Form_pg_shdepend sdepForm = GETSTRUCT(pg_shdepend, tuple);
MemoryContext cxt,
oldcxt;
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c
index c7d2537fb5..462e30ee8f 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_subscription.c
@@ -58,7 +58,7 @@ GetSubscription(Oid subid, bool missing_ok)
elog(ERROR, "cache lookup failed for subscription %u", subid);
}
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = GETSTRUCT(pg_subscription, tup);
sub = (Subscription *) palloc(sizeof(Subscription));
sub->oid = subid;
@@ -247,7 +247,7 @@ get_subscription_name(Oid subid, bool missing_ok)
return NULL;
}
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = GETSTRUCT(pg_subscription, tup);
subname = pstrdup(NameStr(subform->subname));
ReleaseSysCache(tup);
@@ -407,7 +407,7 @@ GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn)
}
/* Get the state. */
- substate = ((Form_pg_subscription_rel) GETSTRUCT(tup))->srsubstate;
+ substate = (GETSTRUCT(pg_subscription_rel, tup))->srsubstate;
/* Get the LSN */
d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
@@ -464,7 +464,7 @@ RemoveSubscriptionRel(Oid subid, Oid relid)
{
Form_pg_subscription_rel subrel;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = GETSTRUCT(pg_subscription_rel, tup);
/*
* We don't allow to drop the relation mapping when the table
@@ -572,7 +572,7 @@ GetSubscriptionRelations(Oid subid, bool not_ready)
Datum d;
bool isnull;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = GETSTRUCT(pg_subscription_rel, tup);
relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index 779bb59f2c..0db0445bd5 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -422,7 +422,7 @@ TypeCreate(Oid newTypeOid,
ObjectIdGetDatum(typeNamespace));
if (HeapTupleIsValid(tup))
{
- Form_pg_type typform = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typform = GETSTRUCT(pg_type, tup);
/*
* check that the type is not already defined. It may exist as a
@@ -560,7 +560,7 @@ GenerateTypeDependencies(HeapTuple typeTuple,
bool makeExtensionDep,
bool rebuild)
{
- Form_pg_type typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
+ Form_pg_type typeForm = GETSTRUCT(pg_type, typeTuple);
Oid typeObjectId = typeForm->oid;
Datum datum;
bool isNull;
@@ -749,7 +749,7 @@ RenameTypeInternal(Oid typeOid, const char *newTypeName, Oid typeNamespace)
tuple = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typ = (Form_pg_type) GETSTRUCT(tuple);
+ typ = GETSTRUCT(pg_type, tuple);
/* We are not supposed to be changing schemas here */
Assert(typeNamespace == typ->typnamespace);
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index 9bc10729b0..5b10baff8a 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -341,7 +341,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- ((Form_pg_class) GETSTRUCT(reltup))->reltoastrelid = toast_relid;
+ (GETSTRUCT(pg_class, reltup))->reltoastrelid = toast_relid;
if (!IsBootstrapProcessingMode())
{
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 5456b8222b..018582b304 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -243,27 +243,27 @@ AlterObjectRename_internal(Relation rel, Oid objectId, const char *new_name)
*/
if (classId == ProcedureRelationId)
{
- Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(oldtup);
+ Form_pg_proc proc = GETSTRUCT(pg_proc, oldtup);
IsThereFunctionInNamespace(new_name, proc->pronargs,
&proc->proargtypes, proc->pronamespace);
}
else if (classId == CollationRelationId)
{
- Form_pg_collation coll = (Form_pg_collation) GETSTRUCT(oldtup);
+ Form_pg_collation coll = GETSTRUCT(pg_collation, oldtup);
IsThereCollationInNamespace(new_name, coll->collnamespace);
}
else if (classId == OperatorClassRelationId)
{
- Form_pg_opclass opc = (Form_pg_opclass) GETSTRUCT(oldtup);
+ Form_pg_opclass opc = GETSTRUCT(pg_opclass, oldtup);
IsThereOpClassInNamespace(new_name, opc->opcmethod,
opc->opcnamespace);
}
else if (classId == OperatorFamilyRelationId)
{
- Form_pg_opfamily opf = (Form_pg_opfamily) GETSTRUCT(oldtup);
+ Form_pg_opfamily opf = GETSTRUCT(pg_opfamily, oldtup);
IsThereOpFamilyInNamespace(new_name, opf->opfmethod,
opf->opfnamespace);
@@ -769,27 +769,27 @@ AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid)
*/
if (classId == ProcedureRelationId)
{
- Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(tup);
+ Form_pg_proc proc = GETSTRUCT(pg_proc, tup);
IsThereFunctionInNamespace(NameStr(proc->proname), proc->pronargs,
&proc->proargtypes, nspOid);
}
else if (classId == CollationRelationId)
{
- Form_pg_collation coll = (Form_pg_collation) GETSTRUCT(tup);
+ Form_pg_collation coll = GETSTRUCT(pg_collation, tup);
IsThereCollationInNamespace(NameStr(coll->collname), nspOid);
}
else if (classId == OperatorClassRelationId)
{
- Form_pg_opclass opc = (Form_pg_opclass) GETSTRUCT(tup);
+ Form_pg_opclass opc = GETSTRUCT(pg_opclass, tup);
IsThereOpClassInNamespace(NameStr(opc->opcname),
opc->opcmethod, nspOid);
}
else if (classId == OperatorFamilyRelationId)
{
- Form_pg_opfamily opf = (Form_pg_opfamily) GETSTRUCT(tup);
+ Form_pg_opfamily opf = GETSTRUCT(pg_opfamily, tup);
IsThereOpFamilyInNamespace(NameStr(opf->opfname),
opf->opfmethod, nspOid);
diff --git a/src/backend/commands/amcmds.c b/src/backend/commands/amcmds.c
index 914cfa4cc7..ea057efe80 100644
--- a/src/backend/commands/amcmds.c
+++ b/src/backend/commands/amcmds.c
@@ -134,7 +134,7 @@ get_am_type_oid(const char *amname, char amtype, bool missing_ok)
tup = SearchSysCache1(AMNAME, CStringGetDatum(amname));
if (HeapTupleIsValid(tup))
{
- Form_pg_am amform = (Form_pg_am) GETSTRUCT(tup);
+ Form_pg_am amform = GETSTRUCT(pg_am, tup);
if (amtype != '\0' &&
amform->amtype != amtype)
@@ -197,7 +197,7 @@ get_am_name(Oid amOid)
tup = SearchSysCache1(AMOID, ObjectIdGetDatum(amOid));
if (HeapTupleIsValid(tup))
{
- Form_pg_am amform = (Form_pg_am) GETSTRUCT(tup);
+ Form_pg_am amform = GETSTRUCT(pg_am, tup);
result = pstrdup(NameStr(amform->amname));
ReleaseSysCache(tup);
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index a7966fff83..fb4f748ee1 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -1057,7 +1057,7 @@ examine_attribute(Relation onerel, int attnum, Node *index_expr)
ObjectIdGetDatum(stats->attrtypid));
if (!HeapTupleIsValid(typtuple))
elog(ERROR, "cache lookup failed for type %u", stats->attrtypid);
- stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple);
+ stats->attrtype = GETSTRUCT(pg_type, typtuple);
stats->anl_context = anl_context;
stats->tupattnum = attnum;
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index dc35b02910..d5163e038e 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -590,7 +590,7 @@ mark_index_clustered(Relation rel, Oid indexOid, bool is_internal)
ObjectIdGetDatum(thisIndexOid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", thisIndexOid);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexForm = GETSTRUCT(pg_index, indexTuple);
/*
* Unset the bit if set. We know it's wrong because we checked this
@@ -1003,7 +1003,7 @@ copy_table_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(OIDNewHeap));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", OIDNewHeap);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
relform->relpages = num_pages;
relform->reltuples = num_tuples;
@@ -1072,12 +1072,12 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
reltup1 = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(r1));
if (!HeapTupleIsValid(reltup1))
elog(ERROR, "cache lookup failed for relation %u", r1);
- relform1 = (Form_pg_class) GETSTRUCT(reltup1);
+ relform1 = GETSTRUCT(pg_class, reltup1);
reltup2 = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(r2));
if (!HeapTupleIsValid(reltup2))
elog(ERROR, "cache lookup failed for relation %u", r2);
- relform2 = (Form_pg_class) GETSTRUCT(reltup2);
+ relform2 = GETSTRUCT(pg_class, reltup2);
relfilenumber1 = relform1->relfilenode;
relfilenumber2 = relform2->relfilenode;
@@ -1515,7 +1515,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(OIDOldHeap));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", OIDOldHeap);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
relform->relfrozenxid = frozenXid;
relform->relminmxid = cutoffMulti;
@@ -1638,7 +1638,7 @@ get_tables_to_cluster(MemoryContext cluster_context)
{
RelToCluster *rtc;
- index = (Form_pg_index) GETSTRUCT(indexTuple);
+ index = GETSTRUCT(pg_index, indexTuple);
if (!pg_class_ownercheck(index->indrelid, GetUserId()))
continue;
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
index fcfc02d2ae..956249259f 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -137,9 +137,9 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collid);
- collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider;
- collisdeterministic = ((Form_pg_collation) GETSTRUCT(tp))->collisdeterministic;
- collencoding = ((Form_pg_collation) GETSTRUCT(tp))->collencoding;
+ collprovider = (GETSTRUCT(pg_collation, tp))->collprovider;
+ collisdeterministic = (GETSTRUCT(pg_collation, tp))->collisdeterministic;
+ collencoding = (GETSTRUCT(pg_collation, tp))->collencoding;
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collcollate, &isnull);
if (!isnull)
@@ -373,7 +373,7 @@ AlterCollation(AlterCollationStmt *stmt)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for collation %u", collOid);
- collForm = (Form_pg_collation) GETSTRUCT(tup);
+ collForm = GETSTRUCT(pg_collation, tup);
datum = SysCacheGetAttr(COLLOID, tup, Anum_pg_collation_collversion, &isnull);
oldversion = isnull ? NULL : TextDatumGetCString(datum);
@@ -438,7 +438,7 @@ pg_collation_actual_version(PG_FUNCTION_ARGS)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("collation with OID %u does not exist", collid)));
- collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider;
+ collprovider = (GETSTRUCT(pg_collation, tp))->collprovider;
if (collprovider != COLLPROVIDER_DEFAULT)
{
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 7bc53f3a0b..d1b80e00d0 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -403,7 +403,7 @@ ScanSourceDatabasePgClassTuple(HeapTupleData *tuple, Oid tbid, Oid dbid,
Form_pg_class classForm;
RelFileNumber relfilenumber = InvalidRelFileNumber;
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/*
* Return NULL if this object does not need to be copied.
@@ -583,7 +583,7 @@ CreateDatabaseUsingFileCopy(Oid src_dboid, Oid dst_dboid, Oid src_tsid,
scan = table_beginscan_catalog(rel, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_tablespace spaceform = (Form_pg_tablespace) GETSTRUCT(tuple);
+ Form_pg_tablespace spaceform = GETSTRUCT(pg_tablespace, tuple);
Oid srctablespace = spaceform->oid;
Oid dsttablespace;
char *srcpath;
@@ -1793,7 +1793,7 @@ RenameDatabase(const char *oldname, const char *newname)
newtup = SearchSysCacheCopy1(DATABASEOID, ObjectIdGetDatum(db_id));
if (!HeapTupleIsValid(newtup))
elog(ERROR, "cache lookup failed for database %u", db_id);
- namestrcpy(&(((Form_pg_database) GETSTRUCT(newtup))->datname), newname);
+ namestrcpy(&((GETSTRUCT(pg_database, newtup))->datname), newname);
CatalogTupleUpdate(rel, &newtup->t_self, newtup);
InvokeObjectPostAlterHook(DatabaseRelationId, db_id, 0);
@@ -2282,7 +2282,7 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", stmt->dbname)));
- datform = (Form_pg_database) GETSTRUCT(tuple);
+ datform = GETSTRUCT(pg_database, tuple);
dboid = datform->oid;
if (!pg_database_ownercheck(dboid, GetUserId()))
@@ -2365,7 +2365,7 @@ AlterDatabaseRefreshColl(AlterDatabaseRefreshCollStmt *stmt)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", stmt->dbname)));
- datForm = (Form_pg_database) GETSTRUCT(tuple);
+ datForm = GETSTRUCT(pg_database, tuple);
db_id = datForm->oid;
if (!pg_database_ownercheck(db_id, GetUserId()))
@@ -2475,7 +2475,7 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", dbname)));
- datForm = (Form_pg_database) GETSTRUCT(tuple);
+ datForm = GETSTRUCT(pg_database, tuple);
db_id = datForm->oid;
/*
@@ -2572,7 +2572,7 @@ pg_database_collation_actual_version(PG_FUNCTION_ARGS)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("database with OID %u does not exist", dbid)));
- datlocprovider = ((Form_pg_database) GETSTRUCT(tp))->datlocprovider;
+ datlocprovider = (GETSTRUCT(pg_database, tp))->datlocprovider;
datum = SysCacheGetAttr(DATABASEOID, tp, datlocprovider == COLLPROVIDER_ICU ? Anum_pg_database_daticulocale : Anum_pg_database_datcollate, &isnull);
if (isnull)
@@ -2648,7 +2648,7 @@ get_db_info(const char *name, LOCKMODE lockmode,
break;
}
- dbOid = ((Form_pg_database) GETSTRUCT(tuple))->oid;
+ dbOid = (GETSTRUCT(pg_database, tuple))->oid;
systable_endscan(scan);
@@ -2666,7 +2666,7 @@ get_db_info(const char *name, LOCKMODE lockmode,
tuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbOid));
if (HeapTupleIsValid(tuple))
{
- Form_pg_database dbform = (Form_pg_database) GETSTRUCT(tuple);
+ Form_pg_database dbform = GETSTRUCT(pg_database, tuple);
if (strcmp(name, NameStr(dbform->datname)) == 0)
{
@@ -2759,7 +2759,7 @@ have_createdb_privilege(void)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(GetUserId()));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolcreatedb;
+ result = (GETSTRUCT(pg_authid, utup))->rolcreatedb;
ReleaseSysCache(utup);
}
return result;
@@ -2787,7 +2787,7 @@ remove_dbtablespaces(Oid db_id)
scan = table_beginscan_catalog(rel, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_tablespace spcform = (Form_pg_tablespace) GETSTRUCT(tuple);
+ Form_pg_tablespace spcform = GETSTRUCT(pg_tablespace, tuple);
Oid dsttablespace = spcform->oid;
char *dstpath;
struct stat st;
@@ -2873,7 +2873,7 @@ check_db_file_conflict(Oid db_id)
scan = table_beginscan_catalog(rel, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_tablespace spcform = (Form_pg_tablespace) GETSTRUCT(tuple);
+ Form_pg_tablespace spcform = GETSTRUCT(pg_tablespace, tuple);
Oid dsttablespace = spcform->oid;
char *dstpath;
struct stat st;
@@ -2959,7 +2959,7 @@ get_database_oid(const char *dbname, bool missing_ok)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(dbtuple))
- oid = ((Form_pg_database) GETSTRUCT(dbtuple))->oid;
+ oid = (GETSTRUCT(pg_database, dbtuple))->oid;
else
oid = InvalidOid;
@@ -2990,7 +2990,7 @@ get_database_name(Oid dbid)
dbtuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbid));
if (HeapTupleIsValid(dbtuple))
{
- result = pstrdup(NameStr(((Form_pg_database) GETSTRUCT(dbtuple))->datname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_database, dbtuple))->datname));
ReleaseSysCache(dbtuple);
}
else
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index eef3e5d56e..a7e342e13b 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -376,7 +376,7 @@ AlterEventTrigger(AlterEventTrigStmt *stmt)
errmsg("event trigger \"%s\" does not exist",
stmt->trigname)));
- evtForm = (Form_pg_event_trigger) GETSTRUCT(tup);
+ evtForm = GETSTRUCT(pg_event_trigger, tup);
trigoid = evtForm->oid;
if (!pg_event_trigger_ownercheck(trigoid, GetUserId()))
@@ -419,7 +419,7 @@ AlterEventTriggerOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("event trigger \"%s\" does not exist", name)));
- evtForm = (Form_pg_event_trigger) GETSTRUCT(tup);
+ evtForm = GETSTRUCT(pg_event_trigger, tup);
evtOid = evtForm->oid;
AlterEventTriggerOwner_internal(rel, tup, newOwnerId);
@@ -466,7 +466,7 @@ AlterEventTriggerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
{
Form_pg_event_trigger form;
- form = (Form_pg_event_trigger) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_event_trigger, tup);
if (form->evtowner == newOwnerId)
return;
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index 6b6720c690..84a01c3828 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -159,7 +159,7 @@ get_extension_oid(const char *extname, bool missing_ok)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = ((Form_pg_extension) GETSTRUCT(tuple))->oid;
+ result = (GETSTRUCT(pg_extension, tuple))->oid;
else
result = InvalidOid;
@@ -204,7 +204,7 @@ get_extension_name(Oid ext_oid)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = pstrdup(NameStr(((Form_pg_extension) GETSTRUCT(tuple))->extname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_extension, tuple))->extname));
else
result = NULL;
@@ -243,7 +243,7 @@ get_extension_schema(Oid ext_oid)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = ((Form_pg_extension) GETSTRUCT(tuple))->extnamespace;
+ result = (GETSTRUCT(pg_extension, tuple))->extnamespace;
else
result = InvalidOid;
@@ -2766,7 +2766,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
/* Copy tuple so we can modify it below */
extTup = heap_copytuple(extTup);
- extForm = (Form_pg_extension) GETSTRUCT(extTup);
+ extForm = GETSTRUCT(pg_extension, extTup);
systable_endscan(extScan);
@@ -2809,7 +2809,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
while (HeapTupleIsValid(depTup = systable_getnext(depScan)))
{
- Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend pg_depend = GETSTRUCT(pg_depend, depTup);
ObjectAddress dep;
Oid dep_oldNspOid;
@@ -2931,7 +2931,7 @@ ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt)
errmsg("extension \"%s\" does not exist",
stmt->extname)));
- extensionOid = ((Form_pg_extension) GETSTRUCT(extTup))->oid;
+ extensionOid = (GETSTRUCT(pg_extension, extTup))->oid;
/*
* Determine the existing version we are updating from
@@ -3083,7 +3083,7 @@ ApplyExtensionUpdates(Oid extensionOid,
elog(ERROR, "could not find tuple for extension %u",
extensionOid);
- extForm = (Form_pg_extension) GETSTRUCT(extTup);
+ extForm = GETSTRUCT(pg_extension, extTup);
/*
* Determine the target schema (set by original install)
diff --git a/src/backend/commands/foreigncmds.c b/src/backend/commands/foreigncmds.c
index ea27857bb8..899e1cceef 100644
--- a/src/backend/commands/foreigncmds.c
+++ b/src/backend/commands/foreigncmds.c
@@ -212,7 +212,7 @@ AlterForeignDataWrapperOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerI
Datum aclDatum;
bool isNull;
- form = (Form_pg_foreign_data_wrapper) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_foreign_data_wrapper, tup);
/* Must be a superuser to change a FDW owner */
if (!superuser())
@@ -290,7 +290,7 @@ AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign-data wrapper \"%s\" does not exist", name)));
- form = (Form_pg_foreign_data_wrapper) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_foreign_data_wrapper, tup);
fdwId = form->oid;
AlterForeignDataWrapperOwner_internal(rel, tup, newOwnerId);
@@ -345,7 +345,7 @@ AlterForeignServerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
Datum aclDatum;
bool isNull;
- form = (Form_pg_foreign_server) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_foreign_server, tup);
if (form->srvowner != newOwnerId)
{
@@ -429,7 +429,7 @@ AlterForeignServerOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("server \"%s\" does not exist", name)));
- form = (Form_pg_foreign_server) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_foreign_server, tup);
servOid = form->oid;
AlterForeignServerOwner_internal(rel, tup, newOwnerId);
@@ -706,7 +706,7 @@ AlterForeignDataWrapper(ParseState *pstate, AlterFdwStmt *stmt)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign-data wrapper \"%s\" does not exist", stmt->fdwname)));
- fdwForm = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp);
+ fdwForm = GETSTRUCT(pg_foreign_data_wrapper, tp);
fdwId = fdwForm->oid;
memset(repl_val, 0, sizeof(repl_val));
@@ -983,7 +983,7 @@ AlterForeignServer(AlterForeignServerStmt *stmt)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("server \"%s\" does not exist", stmt->servername)));
- srvForm = (Form_pg_foreign_server) GETSTRUCT(tp);
+ srvForm = GETSTRUCT(pg_foreign_server, tp);
srvId = srvForm->oid;
/*
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 59e3af626f..7ca8b3518d 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -101,7 +101,7 @@ compute_return_type(TypeName *returnType, Oid languageOid,
if (typtup)
{
- if (!((Form_pg_type) GETSTRUCT(typtup))->typisdefined)
+ if (!(GETSTRUCT(pg_type, typtup))->typisdefined)
{
if (languageOid == SQLlanguageId)
ereport(ERROR,
@@ -241,7 +241,7 @@ interpret_function_parameter_list(ParseState *pstate,
typtup = LookupTypeName(NULL, t, NULL, false);
if (typtup)
{
- if (!((Form_pg_type) GETSTRUCT(typtup))->typisdefined)
+ if (!(GETSTRUCT(pg_type, typtup))->typisdefined)
{
/* As above, hard error if language is SQL */
if (languageOid == SQLlanguageId)
@@ -1106,7 +1106,7 @@ CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
(extension_file_exists(language) ?
errhint("Use CREATE EXTENSION to load the language into the database.") : 0)));
- languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
+ languageStruct = GETSTRUCT(pg_language, languageTuple);
languageOid = languageStruct->oid;
if (languageStruct->lanpltrusted)
@@ -1313,7 +1313,7 @@ RemoveFunctionById(Oid funcOid)
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", funcOid);
- prokind = ((Form_pg_proc) GETSTRUCT(tup))->prokind;
+ prokind = (GETSTRUCT(pg_proc, tup))->prokind;
CatalogTupleDelete(relation, &tup->t_self);
@@ -1377,7 +1377,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", funcOid);
- procForm = (Form_pg_proc) GETSTRUCT(tup);
+ procForm = GETSTRUCT(pg_proc, tup);
/* Permission check: must own function */
if (!pg_proc_ownercheck(funcOid, GetUserId()))
@@ -1600,7 +1600,7 @@ CreateCast(CreateCastStmt *stmt)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procstruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procstruct = GETSTRUCT(pg_proc, tuple);
nargs = procstruct->pronargs;
if (nargs < 1 || nargs > 3)
ereport(ERROR,
@@ -1868,7 +1868,7 @@ CreateTransform(CreateTransformStmt *stmt)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(fromsqlfuncid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", fromsqlfuncid);
- procstruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procstruct = GETSTRUCT(pg_proc, tuple);
if (procstruct->prorettype != INTERNALOID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
@@ -1894,7 +1894,7 @@ CreateTransform(CreateTransformStmt *stmt)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(tosqlfuncid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", tosqlfuncid);
- procstruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procstruct = GETSTRUCT(pg_proc, tuple);
if (procstruct->prorettype != typeid)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
@@ -1920,7 +1920,7 @@ CreateTransform(CreateTransformStmt *stmt)
ObjectIdGetDatum(langid));
if (HeapTupleIsValid(tuple))
{
- Form_pg_transform form = (Form_pg_transform) GETSTRUCT(tuple);
+ Form_pg_transform form = GETSTRUCT(pg_transform, tuple);
if (!stmt->replace)
ereport(ERROR,
@@ -2103,7 +2103,7 @@ ExecuteDoStmt(ParseState *pstate, DoStmt *stmt, bool atomic)
(extension_file_exists(language) ?
errhint("Use CREATE EXTENSION to load the language into the database.") : 0)));
- languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
+ languageStruct = GETSTRUCT(pg_language, languageTuple);
codeblock->langOid = languageStruct->oid;
codeblock->langIsTrusted = languageStruct->lanpltrusted;
codeblock->atomic = atomic;
@@ -2217,7 +2217,7 @@ ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver
* and AbortTransaction() resets the security context. This could be
* reorganized, but right now it doesn't work.
*/
- if (((Form_pg_proc) GETSTRUCT(tp))->prosecdef)
+ if ((GETSTRUCT(pg_proc, tp))->prosecdef)
callcontext->atomic = true;
ReleaseSysCache(tp);
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 15a57ea9c3..039ebc4ec5 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -212,7 +212,7 @@ CheckIndexCompatible(Oid oldId,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("access method \"%s\" does not exist",
accessMethodName)));
- accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
+ accessMethodForm = GETSTRUCT(pg_am, tuple);
accessMethodId = accessMethodForm->oid;
amRoutine = GetIndexAmRoutine(accessMethodForm->amhandler);
ReleaseSysCache(tuple);
@@ -245,7 +245,7 @@ CheckIndexCompatible(Oid oldId,
tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(oldId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u", oldId);
- indexForm = (Form_pg_index) GETSTRUCT(tuple);
+ indexForm = GETSTRUCT(pg_index, tuple);
/*
* We don't assess expressions or predicates; assume incompatibility.
@@ -833,7 +833,7 @@ DefineIndex(Oid relationId,
errmsg("access method \"%s\" does not exist",
accessMethodName)));
}
- accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
+ accessMethodForm = GETSTRUCT(pg_am, tuple);
accessMethodId = accessMethodForm->oid;
amRoutine = GetIndexAmRoutine(accessMethodForm->amhandler);
@@ -1441,7 +1441,7 @@ DefineIndex(Oid relationId,
elog(ERROR, "cache lookup failed for index %u",
indexRelationId);
newtup = heap_copytuple(tup);
- ((Form_pg_index) GETSTRUCT(newtup))->indisvalid = false;
+ (GETSTRUCT(pg_index, newtup))->indisvalid = false;
CatalogTupleUpdate(pg_index, &tup->t_self, newtup);
ReleaseSysCache(tup);
table_close(pg_index, RowExclusiveLock);
@@ -1822,7 +1822,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
errmsg("column \"%s\" does not exist",
attribute->name)));
}
- attform = (Form_pg_attribute) GETSTRUCT(atttuple);
+ attform = GETSTRUCT(pg_attribute, atttuple);
indexInfo->ii_IndexAttrNumbers[attn] = attform->attnum;
atttype = attform->atttypid;
attcollation = attform->attcollation;
@@ -2044,7 +2044,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
if (!HeapTupleIsValid(opftuple))
elog(ERROR, "cache lookup failed for opfamily %u",
opfamily);
- opfform = (Form_pg_opfamily) GETSTRUCT(opftuple);
+ opfform = GETSTRUCT(pg_opfamily, opftuple);
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -2183,7 +2183,7 @@ ResolveOpClass(List *opclass, Oid attrType,
* Verify that the index operator class accepts this datatype. Note we
* will accept binary compatibility.
*/
- opform = (Form_pg_opclass) GETSTRUCT(tuple);
+ opform = GETSTRUCT(pg_opclass, tuple);
opClassId = opform->oid;
opInputType = opform->opcintype;
@@ -2246,7 +2246,7 @@ GetDefaultOpClass(Oid type_id, Oid am_id)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_opclass opclass = (Form_pg_opclass) GETSTRUCT(tup);
+ Form_pg_opclass opclass = GETSTRUCT(pg_opclass, tup);
/* ignore altogether if not a default opclass */
if (!opclass->opcdefault)
@@ -2956,7 +2956,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
scan = table_beginscan_catalog(relationRelation, num_keys, scan_keys);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classtuple = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classtuple = GETSTRUCT(pg_class, tuple);
Oid relid = classtuple->oid;
/*
@@ -4205,7 +4205,7 @@ IndexSetParentIndex(Relation partitionIdx, Oid parentOid)
}
else
{
- Form_pg_inherits inhForm = (Form_pg_inherits) GETSTRUCT(tuple);
+ Form_pg_inherits inhForm = GETSTRUCT(pg_inherits, tuple);
if (parentOid == InvalidOid)
{
@@ -4296,8 +4296,8 @@ update_relispartition(Oid relationId, bool newval)
tup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for relation %u", relationId);
- Assert(((Form_pg_class) GETSTRUCT(tup))->relispartition != newval);
- ((Form_pg_class) GETSTRUCT(tup))->relispartition = newval;
+ Assert((GETSTRUCT(pg_class, tup))->relispartition != newval);
+ (GETSTRUCT(pg_class, tup))->relispartition = newval;
CatalogTupleUpdate(classRel, &tup->t_self, tup);
heap_freetuple(tup);
table_close(classRel, RowExclusiveLock);
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c
index 9ac0383459..0e5e86ccb3 100644
--- a/src/backend/commands/matview.c
+++ b/src/backend/commands/matview.c
@@ -100,7 +100,7 @@ SetMatViewPopulatedState(Relation relation, bool newstate)
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(relation));
- ((Form_pg_class) GETSTRUCT(tuple))->relispopulated = newstate;
+ (GETSTRUCT(pg_class, tuple))->relispopulated = newstate;
CatalogTupleUpdate(pgrel, &tuple->t_self, tuple);
@@ -724,7 +724,7 @@ refresh_by_match_merge(Oid matviewOid, Oid tempOid, Oid relowner,
cla_ht = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(cla_ht))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- cla_tup = (Form_pg_opclass) GETSTRUCT(cla_ht);
+ cla_tup = GETSTRUCT(pg_opclass, cla_ht);
Assert(cla_tup->opcmethod == BTREE_AM_OID);
opfamily = cla_tup->opcfamily;
opcintype = cla_tup->opcintype;
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 7a931ab758..91b782ed0f 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -123,7 +123,7 @@ OpFamilyCacheLookup(Oid amID, List *opfamilyname, bool missing_ok)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("operator family \"%s\" does not exist for access method \"%s\"",
NameListToString(opfamilyname),
- NameStr(((Form_pg_am) GETSTRUCT(amtup))->amname))));
+ NameStr((GETSTRUCT(pg_am, amtup))->amname))));
}
return htup;
@@ -145,7 +145,7 @@ get_opfamily_oid(Oid amID, List *opfamilyname, bool missing_ok)
htup = OpFamilyCacheLookup(amID, opfamilyname, missing_ok);
if (!HeapTupleIsValid(htup))
return InvalidOid;
- opfamform = (Form_pg_opfamily) GETSTRUCT(htup);
+ opfamform = GETSTRUCT(pg_opfamily, htup);
opfID = opfamform->oid;
ReleaseSysCache(htup);
@@ -204,7 +204,7 @@ OpClassCacheLookup(Oid amID, List *opclassname, bool missing_ok)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("operator class \"%s\" does not exist for access method \"%s\"",
NameListToString(opclassname),
- NameStr(((Form_pg_am) GETSTRUCT(amtup))->amname))));
+ NameStr((GETSTRUCT(pg_am, amtup))->amname))));
}
return htup;
@@ -226,7 +226,7 @@ get_opclass_oid(Oid amID, List *opclassname, bool missing_ok)
htup = OpClassCacheLookup(amID, opclassname, missing_ok);
if (!HeapTupleIsValid(htup))
return InvalidOid;
- opcform = (Form_pg_opclass) GETSTRUCT(htup);
+ opcform = GETSTRUCT(pg_opclass, htup);
opcID = opcform->oid;
ReleaseSysCache(htup);
@@ -375,7 +375,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
errmsg("access method \"%s\" does not exist",
stmt->amname)));
- amform = (Form_pg_am) GETSTRUCT(tup);
+ amform = GETSTRUCT(pg_am, tup);
amoid = amform->oid;
amroutine = GetIndexAmRoutineByAmId(amoid, false);
ReleaseSysCache(tup);
@@ -442,7 +442,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
ObjectIdGetDatum(namespaceoid));
if (HeapTupleIsValid(tup))
{
- opfamilyoid = ((Form_pg_opfamily) GETSTRUCT(tup))->oid;
+ opfamilyoid = (GETSTRUCT(pg_opfamily, tup))->oid;
/*
* XXX given the superuser check above, there's no need for an
@@ -630,7 +630,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_opclass opclass = (Form_pg_opclass) GETSTRUCT(tup);
+ Form_pg_opclass opclass = GETSTRUCT(pg_opclass, tup);
if (opclass->opcintype == typeoid && opclass->opcdefault)
ereport(ERROR,
@@ -833,7 +833,7 @@ AlterOpFamily(AlterOpFamilyStmt *stmt)
errmsg("access method \"%s\" does not exist",
stmt->amname)));
- amform = (Form_pg_am) GETSTRUCT(tup);
+ amform = GETSTRUCT(pg_am, tup);
amoid = amform->oid;
amroutine = GetIndexAmRoutineByAmId(amoid, false);
ReleaseSysCache(tup);
@@ -1143,7 +1143,7 @@ assignOperTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
optup = SearchSysCache1(OPEROID, ObjectIdGetDatum(member->object));
if (!HeapTupleIsValid(optup))
elog(ERROR, "cache lookup failed for operator %u", member->object);
- opform = (Form_pg_operator) GETSTRUCT(optup);
+ opform = GETSTRUCT(pg_operator, optup);
/*
* Opfamily operators must be binary.
@@ -1210,7 +1210,7 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid,
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(member->object));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", member->object);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
/* Check the signature of the opclass options parsing function */
if (member->number == opclassOptsProcNum)
diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c
index a5924d7d56..312588f296 100644
--- a/src/backend/commands/operatorcmds.c
+++ b/src/backend/commands/operatorcmds.c
@@ -372,7 +372,7 @@ RemoveOperatorById(Oid operOid)
tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for operator %u", operOid);
- op = (Form_pg_operator) GETSTRUCT(tup);
+ op = GETSTRUCT(pg_operator, tup);
/*
* Reset links from commutator and negator, if any. In case of a
@@ -431,7 +431,7 @@ AlterOperator(AlterOperatorStmt *stmt)
tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for operator %u", oprId);
- oprForm = (Form_pg_operator) GETSTRUCT(tup);
+ oprForm = GETSTRUCT(pg_operator, tup);
/* Process options */
foreach(pl, stmt->options)
diff --git a/src/backend/commands/policy.c b/src/backend/commands/policy.c
index d9dff9ecaa..99e210fb7c 100644
--- a/src/backend/commands/policy.c
+++ b/src/backend/commands/policy.c
@@ -75,7 +75,7 @@ RangeVarCallbackForPolicy(const RangeVar *rv, Oid relid, Oid oldrelid,
if (!HeapTupleIsValid(tuple))
return;
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
relkind = classform->relkind;
/* Must own relation. */
@@ -236,7 +236,7 @@ RelationBuildRowSecurity(Relation relation)
while (HeapTupleIsValid(tuple = systable_getnext(sscan)))
{
- Form_pg_policy policy_form = (Form_pg_policy) GETSTRUCT(tuple);
+ Form_pg_policy policy_form = GETSTRUCT(pg_policy, tuple);
RowSecurityPolicy *policy;
Datum datum;
bool isnull;
@@ -366,7 +366,7 @@ RemovePolicyById(Oid policy_id)
* set of policies the rel has; furthermore we've got to hold the lock
* till commit.)
*/
- relid = ((Form_pg_policy) GETSTRUCT(tuple))->polrelid;
+ relid = (GETSTRUCT(pg_policy, tuple))->polrelid;
rel = table_open(relid, AccessExclusiveLock);
if (rel->rd_rel->relkind != RELKIND_RELATION &&
@@ -455,7 +455,7 @@ RemoveRoleFromObjectPolicy(Oid roleid, Oid classid, Oid policy_id)
elog(ERROR, "could not find tuple for policy %u", policy_id);
/* Identify rel the policy belongs to */
- relid = ((Form_pg_policy) GETSTRUCT(tuple))->polrelid;
+ relid = (GETSTRUCT(pg_policy, tuple))->polrelid;
/* Get the current set of roles */
roles_datum = heap_getattr(tuple,
@@ -917,7 +917,7 @@ AlterPolicy(AlterPolicyStmt *stmt)
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("only WITH CHECK expression allowed for INSERT")));
- policy_id = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid;
+ policy_id = (GETSTRUCT(pg_policy, policy_tuple))->oid;
if (role_ids != NULL)
{
@@ -1169,11 +1169,11 @@ rename_policy(RenameStmt *stmt)
errmsg("policy \"%s\" for table \"%s\" does not exist",
stmt->subname, RelationGetRelationName(target_table))));
- opoloid = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid;
+ opoloid = (GETSTRUCT(pg_policy, policy_tuple))->oid;
policy_tuple = heap_copytuple(policy_tuple);
- namestrcpy(&((Form_pg_policy) GETSTRUCT(policy_tuple))->polname,
+ namestrcpy(&(GETSTRUCT(pg_policy, policy_tuple))->polname,
stmt->newname);
CatalogTupleUpdate(pg_policy_rel, &policy_tuple->t_self, policy_tuple);
@@ -1243,7 +1243,7 @@ get_relation_policy_oid(Oid relid, const char *policy_name, bool missing_ok)
policy_oid = InvalidOid;
}
else
- policy_oid = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid;
+ policy_oid = (GETSTRUCT(pg_policy, policy_tuple))->oid;
/* Clean up. */
systable_endscan(sscan);
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c
index 4a093f45d8..d28274e3c4 100644
--- a/src/backend/commands/proclang.c
+++ b/src/backend/commands/proclang.c
@@ -124,7 +124,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
if (HeapTupleIsValid(oldtup))
{
- Form_pg_language oldform = (Form_pg_language) GETSTRUCT(oldtup);
+ Form_pg_language oldform = GETSTRUCT(pg_language, oldtup);
/* There is one; okay to replace it? */
if (!stmt->replace)
diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index 89a005540f..d9d8cd0e64 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -922,7 +922,7 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt,
&publish_via_partition_root_given,
&publish_via_partition_root);
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
/*
* If the publication doesn't publish changes via the root partitioned
@@ -1038,7 +1038,7 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt,
CommandCounterIncrement();
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
/* Invalidate the relcache. */
if (pubform->puballtables)
@@ -1114,7 +1114,7 @@ AlterPublicationTables(AlterPublicationStmt *stmt, HeapTuple tup,
const char *queryString)
{
List *rels = NIL;
- Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
+ Form_pg_publication pubform = GETSTRUCT(pg_publication, tup);
Oid pubid = pubform->oid;
/*
@@ -1291,7 +1291,7 @@ static void
AlterPublicationSchemas(AlterPublicationStmt *stmt,
HeapTuple tup, List *schemaidlist)
{
- Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
+ Form_pg_publication pubform = GETSTRUCT(pg_publication, tup);
/*
* Nothing to do if no objects, except in SET: for that it is quite
@@ -1355,7 +1355,7 @@ static void
CheckAlterPublication(AlterPublicationStmt *stmt, HeapTuple tup,
List *tables, List *schemaidlist)
{
- Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
+ Form_pg_publication pubform = GETSTRUCT(pg_publication, tup);
if ((stmt->action == AP_AddObjects || stmt->action == AP_SetObjects) &&
schemaidlist && !superuser())
@@ -1407,7 +1407,7 @@ AlterPublication(ParseState *pstate, AlterPublicationStmt *stmt)
errmsg("publication \"%s\" does not exist",
stmt->pubname)));
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
/* must be owner */
if (!pg_publication_ownercheck(pubform->oid, GetUserId()))
@@ -1482,7 +1482,7 @@ RemovePublicationRelById(Oid proid)
elog(ERROR, "cache lookup failed for publication table %u",
proid);
- pubrel = (Form_pg_publication_rel) GETSTRUCT(tup);
+ pubrel = GETSTRUCT(pg_publication_rel, tup);
/*
* Invalidate relcache so that publication info is rebuilt.
@@ -1520,7 +1520,7 @@ RemovePublicationById(Oid pubid)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication %u", pubid);
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
/* Invalidate relcache so that publication info is rebuilt. */
if (pubform->puballtables)
@@ -1551,7 +1551,7 @@ RemovePublicationSchemaById(Oid psoid)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication schema %u", psoid);
- pubsch = (Form_pg_publication_namespace) GETSTRUCT(tup);
+ pubsch = GETSTRUCT(pg_publication_namespace, tup);
/*
* Invalidate relcache so that publication info is rebuilt. See
@@ -1944,7 +1944,7 @@ AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
{
Form_pg_publication form;
- form = (Form_pg_publication) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_publication, tup);
if (form->pubowner == newOwnerId)
return;
@@ -2015,7 +2015,7 @@ AlterPublicationOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("publication \"%s\" does not exist", name)));
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
subid = pubform->oid;
AlterPublicationOwner_internal(rel, tup, newOwnerId);
diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c
index be3925b3b4..204bd066fa 100644
--- a/src/backend/commands/schemacmds.c
+++ b/src/backend/commands/schemacmds.c
@@ -80,7 +80,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for role %u", owner_uid);
schemaName =
- pstrdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname));
+ pstrdup(NameStr((GETSTRUCT(pg_authid, tuple))->rolname));
ReleaseSysCache(tuple);
}
@@ -233,7 +233,7 @@ RenameSchema(const char *oldname, const char *newname)
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema \"%s\" does not exist", oldname)));
- nspform = (Form_pg_namespace) GETSTRUCT(tup);
+ nspform = GETSTRUCT(pg_namespace, tup);
nspOid = nspform->oid;
/* make sure the new name doesn't exist */
@@ -313,7 +313,7 @@ AlterSchemaOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema \"%s\" does not exist", name)));
- nspform = (Form_pg_namespace) GETSTRUCT(tup);
+ nspform = GETSTRUCT(pg_namespace, tup);
nspOid = nspform->oid;
AlterSchemaOwner_internal(tup, rel, newOwnerId);
@@ -335,7 +335,7 @@ AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerId)
Assert(tup->t_tableOid == NamespaceRelationId);
Assert(RelationGetRelid(rel) == NamespaceRelationId);
- nspForm = (Form_pg_namespace) GETSTRUCT(tup);
+ nspForm = GETSTRUCT(pg_namespace, tup);
/*
* If the new owner is the same as the existing owner, consider the
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index b0b211891c..d070904fb1 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -286,7 +286,7 @@ ResetSequence(Oid seq_relid)
pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(seq_relid));
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", seq_relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
startv = pgsform->seqstart;
ReleaseSysCache(pgstuple);
@@ -302,7 +302,7 @@ ResetSequence(Oid seq_relid)
* Modify the copied tuple to execute the restart (compare the RESTART
* action in AlterSequence)
*/
- seq = (Form_pg_sequence_data) GETSTRUCT(tuple);
+ seq = GETSTRUCT(pg_sequence_data, tuple);
seq->last_value = startv;
seq->is_called = false;
seq->log_cnt = 0;
@@ -478,14 +478,14 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
elog(ERROR, "cache lookup failed for sequence %u",
relid);
- seqform = (Form_pg_sequence) GETSTRUCT(seqtuple);
+ seqform = GETSTRUCT(pg_sequence, seqtuple);
/* lock page's buffer and read tuple into new sequence structure */
(void) read_seq_tuple(seqrel, &buf, &datatuple);
/* copy the existing sequence data tuple, so it can be modified locally */
newdatatuple = heap_copytuple(&datatuple);
- newdataform = (Form_pg_sequence_data) GETSTRUCT(newdatatuple);
+ newdataform = GETSTRUCT(pg_sequence_data, newdatatuple);
UnlockReleaseBuffer(buf);
@@ -676,7 +676,7 @@ nextval_internal(Oid relid, bool check_permissions)
pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
incby = pgsform->seqincrement;
maxv = pgsform->seqmax;
minv = pgsform->seqmin;
@@ -964,7 +964,7 @@ do_setval(Oid relid, int64 next, bool iscalled)
pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
maxv = pgsform->seqmax;
minv = pgsform->seqmin;
ReleaseSysCache(pgstuple);
@@ -1232,7 +1232,7 @@ read_seq_tuple(Relation rel, Buffer *buf, HeapTuple seqdatatuple)
MarkBufferDirtyHint(*buf, true);
}
- seq = (Form_pg_sequence_data) GETSTRUCT(seqdatatuple);
+ seq = GETSTRUCT(pg_sequence_data, seqdatatuple);
return seq;
}
@@ -1714,7 +1714,7 @@ sequence_options(Oid relid)
pgstuple = SearchSysCache1(SEQRELID, relid);
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
/* Use makeFloat() for 64-bit integers, like gram.y does. */
options = lappend(options,
@@ -1777,7 +1777,7 @@ pg_sequence_parameters(PG_FUNCTION_ARGS)
pgstuple = SearchSysCache1(SEQRELID, relid);
if (!HeapTupleIsValid(pgstuple))
elog(ERROR, "cache lookup failed for sequence %u", relid);
- pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
+ pgsform = GETSTRUCT(pg_sequence, pgstuple);
values[0] = Int64GetDatum(pgsform->seqstart);
values[1] = Int64GetDatum(pgsform->seqmin);
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index 415016969d..d0a8d94b3b 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -237,7 +237,7 @@ CreateStatistics(CreateStatsStmt *stmt)
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" does not exist",
attname)));
- attForm = (Form_pg_attribute) GETSTRUCT(atttuple);
+ attForm = GETSTRUCT(pg_attribute, atttuple);
/* Disallow use of system attributes in extended stats */
if (attForm->attnum <= 0)
@@ -753,7 +753,7 @@ RemoveStatisticsById(Oid statsOid)
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for statistics object %u", statsOid);
- statext = (Form_pg_statistic_ext) GETSTRUCT(tup);
+ statext = GETSTRUCT(pg_statistic_ext, tup);
relid = statext->stxrelid;
CacheInvalidateRelcacheByRelid(relid);
@@ -884,7 +884,7 @@ StatisticsGetRelation(Oid statId, bool missing_ok)
return InvalidOid;
elog(ERROR, "cache lookup failed for statistics object %u", statId);
}
- stx = (Form_pg_statistic_ext) GETSTRUCT(tuple);
+ stx = GETSTRUCT(pg_statistic_ext, tuple);
Assert(stx->oid == statId);
result = stx->stxrelid;
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index f73dfb6067..7aab53f130 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -1019,7 +1019,7 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt,
errmsg("subscription \"%s\" does not exist",
stmt->subname)));
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_subscription, tup);
subid = form->oid;
/* must be owner */
@@ -1399,7 +1399,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
return;
}
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_subscription, tup);
subid = form->oid;
/* must be owner */
@@ -1689,7 +1689,7 @@ AlterSubscriptionOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
{
Form_pg_subscription form;
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_subscription, tup);
if (form->subowner == newOwnerId)
return;
@@ -1742,7 +1742,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("subscription \"%s\" does not exist", name)));
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_subscription, tup);
subid = form->oid;
AlterSubscriptionOwner_internal(rel, tup, newOwnerId);
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index d22dd44712..43924410ae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -1544,7 +1544,7 @@ RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid, Oid oldRelOid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped, so nothing to do */
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
is_partition = classform->relispartition;
/* Pass back some data to save lookups in RemoveRelations */
@@ -1596,7 +1596,7 @@ RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid, Oid oldRelOid,
return;
}
- indexform = (Form_pg_index) GETSTRUCT(locTuple);
+ indexform = GETSTRUCT(pg_index, locTuple);
indisvalid = indexform->indisvalid;
ReleaseSysCache(locTuple);
@@ -3257,7 +3257,7 @@ SetRelationHasSubclass(Oid relationId, bool relhassubclass)
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationId);
- classtuple = (Form_pg_class) GETSTRUCT(tuple);
+ classtuple = GETSTRUCT(pg_class, tuple);
if (classtuple->relhassubclass != relhassubclass)
{
@@ -3359,7 +3359,7 @@ SetRelationTableSpace(Relation rel,
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(reloid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", reloid);
- rd_rel = (Form_pg_class) GETSTRUCT(tuple);
+ rd_rel = GETSTRUCT(pg_class, tuple);
/* Update the pg_class row. */
rd_rel->reltablespace = (newTableSpaceId == MyDatabaseTableSpace) ?
@@ -3531,7 +3531,7 @@ renameatt_internal(Oid myrelid,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" does not exist",
oldattname)));
- attform = (Form_pg_attribute) GETSTRUCT(atttup);
+ attform = GETSTRUCT(pg_attribute, atttup);
attnum = attform->attnum;
if (attnum <= 0)
@@ -3587,7 +3587,7 @@ RangeVarCallbackForRenameAttribute(const RangeVar *rv, Oid relid, Oid oldrelid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped */
- form = (Form_pg_class) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_class, tuple);
renameatt_check(relid, form, false);
ReleaseSysCache(tuple);
}
@@ -3673,7 +3673,7 @@ rename_constraint_internal(Oid myrelid,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u",
constraintOid);
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
if (myrelid && con->contype == CONSTRAINT_CHECK && !con->connoinherit)
{
@@ -3885,7 +3885,7 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bo
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for relation %u", myrelid);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
if (get_relname_relid(newrelname, namespaceId) != InvalidOid)
ereport(ERROR,
@@ -3960,7 +3960,7 @@ ResetRelRewrite(Oid myrelid)
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for relation %u", myrelid);
- relform = (Form_pg_class) GETSTRUCT(reltup);
+ relform = GETSTRUCT(pg_class, reltup);
/*
* Update pg_class tuple.
@@ -6456,7 +6456,7 @@ find_composite_type_dependencies(Oid typeOid, Relation origRelation,
while (HeapTupleIsValid(depTup = systable_getnext(depScan)))
{
- Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend pg_depend = GETSTRUCT(pg_depend, depTup);
Relation rel;
Form_pg_attribute att;
@@ -6562,7 +6562,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classform = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classform = GETSTRUCT(pg_class, tuple);
if (behavior == DROP_RESTRICT)
ereport(ERROR,
@@ -6594,7 +6594,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
void
check_of_type(HeapTuple typetuple)
{
- Form_pg_type typ = (Form_pg_type) GETSTRUCT(typetuple);
+ Form_pg_type typ = GETSTRUCT(pg_type, typetuple);
bool typeOk = false;
if (typ->typtype == TYPTYPE_COMPOSITE)
@@ -6713,7 +6713,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
tuple = SearchSysCacheCopyAttName(myrelid, colDef->colname);
if (HeapTupleIsValid(tuple))
{
- Form_pg_attribute childatt = (Form_pg_attribute) GETSTRUCT(tuple);
+ Form_pg_attribute childatt = GETSTRUCT(pg_attribute, tuple);
Oid ctypeId;
int32 ctypmod;
Oid ccollid;
@@ -6794,10 +6794,10 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", myrelid);
- relkind = ((Form_pg_class) GETSTRUCT(reltup))->relkind;
+ relkind = (GETSTRUCT(pg_class, reltup))->relkind;
/* Determine the new attribute's number */
- newattnum = ((Form_pg_class) GETSTRUCT(reltup))->relnatts + 1;
+ newattnum = (GETSTRUCT(pg_class, reltup))->relnatts + 1;
if (newattnum > MaxHeapAttributeNumber)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_COLUMNS),
@@ -6805,7 +6805,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
MaxHeapAttributeNumber)));
typeTuple = typenameType(NULL, colDef->typeName, &typmod);
- tform = (Form_pg_type) GETSTRUCT(typeTuple);
+ tform = GETSTRUCT(pg_type, typeTuple);
typeOid = tform->oid;
aclresult = pg_type_aclcheck(typeOid, GetUserId(), ACL_USAGE);
@@ -6860,7 +6860,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
/*
* Update pg_class tuple as appropriate
*/
- ((Form_pg_class) GETSTRUCT(reltup))->relnatts = newattnum;
+ (GETSTRUCT(pg_class, reltup))->relnatts = newattnum;
CatalogTupleUpdate(pgclass, &reltup->t_self, reltup);
@@ -7093,7 +7093,7 @@ check_for_column_name_collision(Relation rel, const char *colname,
if (!HeapTupleIsValid(attTuple))
return true;
- attnum = ((Form_pg_attribute) GETSTRUCT(attTuple))->attnum;
+ attnum = (GETSTRUCT(pg_attribute, attTuple))->attnum;
ReleaseSysCache(attTuple);
/*
@@ -7216,7 +7216,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
/* Prevent them from altering a system attribute */
@@ -7252,7 +7252,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexoid);
- indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexStruct = GETSTRUCT(pg_index, indexTuple);
/*
* If the index is not a primary key or an index used as replica
@@ -7373,7 +7373,7 @@ ATPrepSetNotNull(List **wqueue, Relation rel,
errmsg("column \"%s\" of relation \"%s\" does not exist",
cmd->name, RelationGetRelationName(rel))));
- attnotnull = ((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull;
+ attnotnull = (GETSTRUCT(pg_attribute, tuple))->attnotnull;
ReleaseSysCache(tuple);
if (attnotnull)
return;
@@ -7423,7 +7423,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attnum;
+ attnum = (GETSTRUCT(pg_attribute, tuple))->attnum;
/* Prevent them from altering a system attribute */
if (attnum <= 0)
@@ -7435,9 +7435,9 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
/*
* Okay, actually perform the catalog change ... if needed
*/
- if (!((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull)
+ if (!(GETSTRUCT(pg_attribute, tuple))->attnotnull)
{
- ((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull = true;
+ (GETSTRUCT(pg_attribute, tuple))->attnotnull = true;
CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple);
@@ -7448,7 +7448,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
* already found that we must verify some other NOT NULL constraint.
*/
if (!tab->verify_new_notnull &&
- !NotNullImpliedByRelConstraints(rel, (Form_pg_attribute) GETSTRUCT(tuple)))
+ !NotNullImpliedByRelConstraints(rel, GETSTRUCT(pg_attribute, tuple)))
{
/* Tell Phase 3 it needs to test the constraint */
tab->verify_new_notnull = true;
@@ -7497,7 +7497,7 @@ ATExecCheckNotNull(AlteredTableInfo *tab, Relation rel,
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- if (!((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull)
+ if (!(GETSTRUCT(pg_attribute, tuple))->attnotnull)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("constraint must be added to child tables too"),
@@ -7678,7 +7678,7 @@ ATExecAddIdentity(Relation rel, const char *colName,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
/* Can't alter a system attribute */
@@ -7773,7 +7773,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
if (attnum <= 0)
@@ -7832,7 +7832,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
if (attnum <= 0)
@@ -7921,7 +7921,7 @@ ATPrepDropExpression(Relation rel, AlterTableCmd *cmd, bool recurse, bool recurs
errmsg("column \"%s\" of relation \"%s\" does not exist",
cmd->name, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
if (attTup->attinhcount > 0)
ereport(ERROR,
@@ -7951,7 +7951,7 @@ ATExecDropExpression(Relation rel, const char *colName, bool missing_ok, LOCKMOD
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
if (attnum <= 0)
@@ -8090,7 +8090,7 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa
colNum, RelationGetRelationName(rel))));
}
- attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ attrtuple = GETSTRUCT(pg_attribute, tuple);
attnum = attrtuple->attnum;
if (attnum <= 0)
@@ -8160,7 +8160,7 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ attrtuple = GETSTRUCT(pg_attribute, tuple);
attnum = attrtuple->attnum;
if (attnum <= 0)
@@ -8250,7 +8250,7 @@ SetIndexStorageProperties(Relation rel, Relation attrelation,
if (HeapTupleIsValid(tuple))
{
- Form_pg_attribute attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ Form_pg_attribute attrtuple = GETSTRUCT(pg_attribute, tuple);
if (setstorage)
attrtuple->attstorage = newstorage;
@@ -8294,7 +8294,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attrtuple = (Form_pg_attribute) GETSTRUCT(tuple);
+ attrtuple = GETSTRUCT(pg_attribute, tuple);
attnum = attrtuple->attnum;
if (attnum <= 0)
@@ -8411,7 +8411,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
return InvalidObjectAddress;
}
}
- targetatt = (Form_pg_attribute) GETSTRUCT(tuple);
+ targetatt = GETSTRUCT(pg_attribute, tuple);
attnum = targetatt->attnum;
@@ -8485,7 +8485,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute \"%s\" of relation %u",
colName, childrelid);
- childatt = (Form_pg_attribute) GETSTRUCT(tuple);
+ childatt = GETSTRUCT(pg_attribute, tuple);
if (childatt->attinhcount <= 0) /* shouldn't happen */
elog(ERROR, "relation %u has non-inherited attribute \"%s\"",
@@ -9204,7 +9204,7 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
cla_ht = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclasses[i]));
if (!HeapTupleIsValid(cla_ht))
elog(ERROR, "cache lookup failed for opclass %u", opclasses[i]);
- cla_tup = (Form_pg_opclass) GETSTRUCT(cla_ht);
+ cla_tup = GETSTRUCT(pg_opclass, cla_ht);
amid = cla_tup->opcmethod;
opfamily = cla_tup->opcfamily;
opcintype = cla_tup->opcintype;
@@ -9982,7 +9982,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel)
NULL, 2, key);
while ((tuple = systable_getnext(scan)) != NULL)
{
- Form_pg_constraint constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint constrForm = GETSTRUCT(pg_constraint, tuple);
clone = lappend_oid(clone, constrForm->oid);
}
@@ -10022,7 +10022,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel)
tuple = SearchSysCache1(CONSTROID, constrOid);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", constrOid);
- constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ constrForm = GETSTRUCT(pg_constraint, tuple);
/*
* As explained above: don't try to clone a constraint for which we're
@@ -10209,7 +10209,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u",
parentConstrOid);
- constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ constrForm = GETSTRUCT(pg_constraint, tuple);
/* Don't clone constraints whose parents are being cloned */
if (list_member_oid(clone, constrForm->conparentid))
@@ -10416,7 +10416,7 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk,
ObjectIdGetDatum(parentConstrOid));
if (!HeapTupleIsValid(parentConstrTup))
elog(ERROR, "cache lookup failed for constraint %u", parentConstrOid);
- parentConstr = (Form_pg_constraint) GETSTRUCT(parentConstrTup);
+ parentConstr = GETSTRUCT(pg_constraint, parentConstrTup);
/*
* Do some quick & easy initial checks. If any of these fail, we cannot
@@ -10447,7 +10447,7 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk,
ObjectIdGetDatum(fk->conoid));
if (!HeapTupleIsValid(partcontup))
elog(ERROR, "cache lookup failed for constraint %u", fk->conoid);
- partConstr = (Form_pg_constraint) GETSTRUCT(partcontup);
+ partConstr = GETSTRUCT(pg_constraint, partcontup);
if (OidIsValid(partConstr->conparentid) ||
!partConstr->convalidated ||
partConstr->condeferrable != parentConstr->condeferrable ||
@@ -10479,7 +10479,7 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk,
NULL, 1, &key);
while ((trigtup = systable_getnext(scan)) != NULL)
{
- Form_pg_trigger trgform = (Form_pg_trigger) GETSTRUCT(trigtup);
+ Form_pg_trigger trgform = GETSTRUCT(pg_trigger, trigtup);
ObjectAddress trigger;
if (trgform->tgconstrrelid != fk->conrelid)
@@ -10553,7 +10553,7 @@ GetForeignKeyActionTriggers(Relation trigrel,
NULL, 1, &key);
while ((trigtup = systable_getnext(scan)) != NULL)
{
- Form_pg_trigger trgform = (Form_pg_trigger) GETSTRUCT(trigtup);
+ Form_pg_trigger trgform = GETSTRUCT(pg_trigger, trigtup);
if (trgform->tgconstrrelid != conrelid)
continue;
@@ -10608,7 +10608,7 @@ GetForeignKeyCheckTriggers(Relation trigrel,
NULL, 1, &key);
while ((trigtup = systable_getnext(scan)) != NULL)
{
- Form_pg_trigger trgform = (Form_pg_trigger) GETSTRUCT(trigtup);
+ Form_pg_trigger trgform = GETSTRUCT(pg_trigger, trigtup);
if (trgform->tgconstrrelid != confrelid)
continue;
@@ -10693,7 +10693,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd, bool recurse,
errmsg("constraint \"%s\" of relation \"%s\" does not exist",
cmdcon->conname, RelationGetRelationName(rel))));
- currcon = (Form_pg_constraint) GETSTRUCT(contuple);
+ currcon = GETSTRUCT(pg_constraint, contuple);
if (currcon->contype != CONSTRAINT_FOREIGN)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -10719,7 +10719,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd, bool recurse,
/* Loop to find the topmost constraint */
while (HeapTupleIsValid(tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(parent))))
{
- Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp);
+ Form_pg_constraint contup = GETSTRUCT(pg_constraint, tp);
/* If no parent, this is the constraint we want */
if (!OidIsValid(contup->conparentid))
@@ -10795,7 +10795,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
Oid refrelid;
bool changed = false;
- currcon = (Form_pg_constraint) GETSTRUCT(contuple);
+ currcon = GETSTRUCT(pg_constraint, contuple);
conoid = currcon->oid;
refrelid = currcon->confrelid;
@@ -10815,7 +10815,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
SysScanDesc tgscan;
copyTuple = heap_copytuple(contuple);
- copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple);
+ copy_con = GETSTRUCT(pg_constraint, copyTuple);
copy_con->condeferrable = cmdcon->deferrable;
copy_con->condeferred = cmdcon->initdeferred;
CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple);
@@ -10841,7 +10841,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
NULL, 1, &tgkey);
while (HeapTupleIsValid(tgtuple = systable_getnext(tgscan)))
{
- Form_pg_trigger tgform = (Form_pg_trigger) GETSTRUCT(tgtuple);
+ Form_pg_trigger tgform = GETSTRUCT(pg_trigger, tgtuple);
Form_pg_trigger copy_tg;
HeapTuple copyTuple;
@@ -10868,7 +10868,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
continue;
copyTuple = heap_copytuple(tgtuple);
- copy_tg = (Form_pg_trigger) GETSTRUCT(copyTuple);
+ copy_tg = GETSTRUCT(pg_trigger, copyTuple);
copy_tg->tgdeferrable = cmdcon->deferrable;
copy_tg->tginitdeferred = cmdcon->initdeferred;
@@ -10907,7 +10907,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
while (HeapTupleIsValid(childtup = systable_getnext(pscan)))
{
- Form_pg_constraint childcon = (Form_pg_constraint) GETSTRUCT(childtup);
+ Form_pg_constraint childcon = GETSTRUCT(pg_constraint, childtup);
Relation childrel;
childrel = table_open(childcon->conrelid, lockmode);
@@ -10971,7 +10971,7 @@ ATExecValidateConstraint(List **wqueue, Relation rel, char *constrName,
errmsg("constraint \"%s\" of relation \"%s\" does not exist",
constrName, RelationGetRelationName(rel))));
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
if (con->contype != CONSTRAINT_FOREIGN &&
con->contype != CONSTRAINT_CHECK)
ereport(ERROR,
@@ -11095,7 +11095,7 @@ ATExecValidateConstraint(List **wqueue, Relation rel, char *constrName,
* Now update the catalog, while we have the door open.
*/
copyTuple = heap_copytuple(tuple);
- copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple);
+ copy_con = GETSTRUCT(pg_constraint, copyTuple);
copy_con->convalidated = true;
CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple);
@@ -11145,9 +11145,9 @@ transformColumnNameList(Oid relId, List *colList,
(errcode(ERRCODE_TOO_MANY_COLUMNS),
errmsg("cannot have more than %d keys in a foreign key",
INDEX_MAX_KEYS)));
- attnums[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->attnum;
+ attnums[attnum] = (GETSTRUCT(pg_attribute, atttuple))->attnum;
if (atttypids != NULL)
- atttypids[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->atttypid;
+ atttypids[attnum] = (GETSTRUCT(pg_attribute, atttuple))->atttypid;
ReleaseSysCache(atttuple);
attnum++;
}
@@ -11198,7 +11198,7 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid,
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexoid);
- indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexStruct = GETSTRUCT(pg_index, indexTuple);
if (indexStruct->indisprimary && indexStruct->indisvalid)
{
/*
@@ -11311,7 +11311,7 @@ transformFkeyCheckAttrs(Relation pkrel,
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexoid);
- indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
+ indexStruct = GETSTRUCT(pg_index, indexTuple);
/*
* Must have the right number of columns; must be unique and not a
@@ -11824,7 +11824,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
{
ObjectAddress conobj;
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
/* Don't drop inherited constraints */
if (con->coninhcount > 0 && !recursing)
@@ -11957,7 +11957,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
systable_endscan(scan);
- con = (Form_pg_constraint) GETSTRUCT(copy_tuple);
+ con = GETSTRUCT(pg_constraint, copy_tuple);
/* Right now only CHECK constraints can be inherited */
if (con->contype != CONSTRAINT_CHECK)
@@ -12065,7 +12065,7 @@ ATPrepAlterColumnType(List **wqueue,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+ attTup = GETSTRUCT(pg_attribute, tuple);
attnum = attTup->attnum;
/* Can't alter a system attribute */
@@ -12246,7 +12246,7 @@ ATPrepAlterColumnType(List **wqueue,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(childrel))));
- childattTup = (Form_pg_attribute) GETSTRUCT(childtuple);
+ childattTup = GETSTRUCT(pg_attribute, childtuple);
if (childattTup->attinhcount > numparents)
ereport(ERROR,
@@ -12406,7 +12406,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(heapTup);
+ attTup = GETSTRUCT(pg_attribute, heapTup);
attnum = attTup->attnum;
attOldTup = TupleDescAttr(tab->oldDesc, attnum - 1);
@@ -12420,7 +12420,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
/* Look up the target type (should not fail, since prep found it) */
typeTuple = typenameType(NULL, typeName, &targettypmod);
- tform = (Form_pg_type) GETSTRUCT(typeTuple);
+ tform = GETSTRUCT(pg_type, typeTuple);
targettype = tform->oid;
/* And the collation */
targetcollid = GetColumnDefCollation(NULL, def, targettype);
@@ -12494,7 +12494,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
while (HeapTupleIsValid(depTup = systable_getnext(scan)))
{
- Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend foundDep = GETSTRUCT(pg_depend, depTup);
ObjectAddress foundObject;
foundObject.classId = foundDep->classid;
@@ -12700,7 +12700,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
while (HeapTupleIsValid(depTup = systable_getnext(scan)))
{
- Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend foundDep = GETSTRUCT(pg_depend, depTup);
ObjectAddress foundObject;
foundObject.classId = foundDep->refclassid;
@@ -12784,7 +12784,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
valuesAtt, nullsAtt, replacesAtt);
heap_freetuple(heapTup);
heapTup = newTup;
- attTup = (Form_pg_attribute) GETSTRUCT(heapTup);
+ attTup = GETSTRUCT(pg_attribute, heapTup);
}
}
@@ -13062,7 +13062,7 @@ ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab, LOCKMODE lockmode)
tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(oldId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for constraint %u", oldId);
- con = (Form_pg_constraint) GETSTRUCT(tup);
+ con = GETSTRUCT(pg_constraint, tup);
if (OidIsValid(con->conrelid))
relid = con->conrelid;
else
@@ -13552,7 +13552,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign table \"%s\" does not exist",
RelationGetRelationName(rel))));
- fttableform = (Form_pg_foreign_table) GETSTRUCT(tuple);
+ fttableform = GETSTRUCT(pg_foreign_table, tuple);
server = GetForeignServer(fttableform->ftserver);
fdw = GetForeignDataWrapper(server->fdwid);
@@ -13568,7 +13568,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
colName, RelationGetRelationName(rel))));
/* Prevent them from altering a system attribute */
- atttableform = (Form_pg_attribute) GETSTRUCT(tuple);
+ atttableform = GETSTRUCT(pg_attribute, tuple);
attnum = atttableform->attnum;
if (attnum <= 0)
ereport(ERROR,
@@ -13656,7 +13656,7 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relationOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationOid);
- tuple_class = (Form_pg_class) GETSTRUCT(tuple);
+ tuple_class = GETSTRUCT(pg_class, tuple);
/* Can we change the ownership of this tuple? */
switch (tuple_class->relkind)
@@ -13892,7 +13892,7 @@ change_owner_fix_column_acls(Oid relationOid, Oid oldOwnerId, Oid newOwnerId)
true, NULL, 1, key);
while (HeapTupleIsValid(attributeTuple = systable_getnext(scan)))
{
- Form_pg_attribute att = (Form_pg_attribute) GETSTRUCT(attributeTuple);
+ Form_pg_attribute att = GETSTRUCT(pg_attribute, attributeTuple);
Datum repl_val[Natts_pg_attribute];
bool repl_null[Natts_pg_attribute];
bool repl_repl[Natts_pg_attribute];
@@ -13969,7 +13969,7 @@ change_owner_recurse_to_sequences(Oid relationOid, Oid newOwnerId, LOCKMODE lock
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend depForm = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depForm = GETSTRUCT(pg_depend, tup);
Relation seqRel;
/* skip dependencies other than auto dependencies on columns */
@@ -14512,7 +14512,7 @@ AlterTableMoveAll(AlterTableMoveAllStmt *stmt)
scan = table_beginscan_catalog(rel, 1, key);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class relForm = GETSTRUCT(pg_class, tuple);
Oid relOid = relForm->oid;
/*
@@ -14850,7 +14850,7 @@ CreateInheritance(Relation child_rel, Relation parent_rel)
inhseqno = 0;
while (HeapTupleIsValid(inheritsTuple = systable_getnext(scan)))
{
- Form_pg_inherits inh = (Form_pg_inherits) GETSTRUCT(inheritsTuple);
+ Form_pg_inherits inh = GETSTRUCT(pg_inherits, inheritsTuple);
if (inh->inhparent == RelationGetRelid(parent_rel))
ereport(ERROR,
@@ -14895,7 +14895,7 @@ decompile_conbin(HeapTuple contup, TupleDesc tupdesc)
Datum attr;
Datum expr;
- con = (Form_pg_constraint) GETSTRUCT(contup);
+ con = GETSTRUCT(pg_constraint, contup);
attr = heap_getattr(contup, Anum_pg_constraint_conbin, tupdesc, &isnull);
if (isnull)
elog(ERROR, "null conbin for constraint %u", con->oid);
@@ -14915,8 +14915,8 @@ decompile_conbin(HeapTuple contup, TupleDesc tupdesc)
static bool
constraints_equivalent(HeapTuple a, HeapTuple b, TupleDesc tupleDesc)
{
- Form_pg_constraint acon = (Form_pg_constraint) GETSTRUCT(a);
- Form_pg_constraint bcon = (Form_pg_constraint) GETSTRUCT(b);
+ Form_pg_constraint acon = GETSTRUCT(pg_constraint, a);
+ Form_pg_constraint bcon = GETSTRUCT(pg_constraint, b);
if (acon->condeferrable != bcon->condeferrable ||
acon->condeferred != bcon->condeferred ||
@@ -14976,7 +14976,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
if (HeapTupleIsValid(tuple))
{
/* Check they are same type, typmod, and collation */
- Form_pg_attribute childatt = (Form_pg_attribute) GETSTRUCT(tuple);
+ Form_pg_attribute childatt = GETSTRUCT(pg_attribute, tuple);
if (attribute->atttypid != childatt->atttypid ||
attribute->atttypmod != childatt->atttypmod)
@@ -15139,7 +15139,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
while (HeapTupleIsValid(parent_tuple = systable_getnext(parent_scan)))
{
- Form_pg_constraint parent_con = (Form_pg_constraint) GETSTRUCT(parent_tuple);
+ Form_pg_constraint parent_con = GETSTRUCT(pg_constraint, parent_tuple);
SysScanDesc child_scan;
ScanKeyData child_key;
HeapTuple child_tuple;
@@ -15162,7 +15162,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
while (HeapTupleIsValid(child_tuple = systable_getnext(child_scan)))
{
- Form_pg_constraint child_con = (Form_pg_constraint) GETSTRUCT(child_tuple);
+ Form_pg_constraint child_con = GETSTRUCT(pg_constraint, child_tuple);
HeapTuple child_copy;
if (child_con->contype != CONSTRAINT_CHECK)
@@ -15203,7 +15203,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
* later on, this change will just roll back.)
*/
child_copy = heap_copytuple(child_tuple);
- child_con = (Form_pg_constraint) GETSTRUCT(child_copy);
+ child_con = GETSTRUCT(pg_constraint, child_copy);
child_con->coninhcount++;
/*
@@ -15311,7 +15311,7 @@ MarkInheritDetached(Relation child_rel, Relation parent_rel)
{
Form_pg_inherits inhForm;
- inhForm = (Form_pg_inherits) GETSTRUCT(inheritsTuple);
+ inhForm = GETSTRUCT(pg_inherits, inheritsTuple);
if (inhForm->inhdetachpending)
ereport(ERROR,
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
@@ -15326,7 +15326,7 @@ MarkInheritDetached(Relation child_rel, Relation parent_rel)
HeapTuple newtup;
newtup = heap_copytuple(inheritsTuple);
- ((Form_pg_inherits) GETSTRUCT(newtup))->inhdetachpending = true;
+ (GETSTRUCT(pg_inherits, newtup))->inhdetachpending = true;
CatalogTupleUpdate(catalogRelation,
&inheritsTuple->t_self,
@@ -15415,7 +15415,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
true, NULL, 1, key);
while (HeapTupleIsValid(attributeTuple = systable_getnext(scan)))
{
- Form_pg_attribute att = (Form_pg_attribute) GETSTRUCT(attributeTuple);
+ Form_pg_attribute att = GETSTRUCT(pg_attribute, attributeTuple);
/* Ignore if dropped or not inherited */
if (att->attisdropped)
@@ -15428,7 +15428,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
{
/* Decrement inhcount and possibly set islocal to true */
HeapTuple copyTuple = heap_copytuple(attributeTuple);
- Form_pg_attribute copy_att = (Form_pg_attribute) GETSTRUCT(copyTuple);
+ Form_pg_attribute copy_att = GETSTRUCT(pg_attribute, copyTuple);
copy_att->attinhcount--;
if (copy_att->attinhcount == 0)
@@ -15459,7 +15459,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
while (HeapTupleIsValid(constraintTuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(constraintTuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, constraintTuple);
if (con->contype == CONSTRAINT_CHECK)
connames = lappend(connames, pstrdup(NameStr(con->conname)));
@@ -15477,7 +15477,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
while (HeapTupleIsValid(constraintTuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(constraintTuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, constraintTuple);
bool match;
ListCell *lc;
@@ -15498,7 +15498,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
{
/* Decrement inhcount and possibly set islocal to true */
HeapTuple copyTuple = heap_copytuple(constraintTuple);
- Form_pg_constraint copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple);
+ Form_pg_constraint copy_con = GETSTRUCT(pg_constraint, copyTuple);
if (copy_con->coninhcount <= 0) /* shouldn't happen */
elog(ERROR, "relation %u has non-inherited constraint \"%s\"",
@@ -15567,7 +15567,7 @@ drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid,
while (HeapTupleIsValid(depTuple = systable_getnext(scan)))
{
- Form_pg_depend dep = (Form_pg_depend) GETSTRUCT(depTuple);
+ Form_pg_depend dep = GETSTRUCT(pg_depend, depTuple);
if (dep->refclassid == refclassid &&
dep->refobjid == refobjid &&
@@ -15612,7 +15612,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
/* Validate the type. */
typetuple = typenameType(NULL, ofTypename, NULL);
check_of_type(typetuple);
- typeform = (Form_pg_type) GETSTRUCT(typetuple);
+ typeform = GETSTRUCT(pg_type, typetuple);
typeid = typeform->oid;
/* Fail if the table has any inheritance parents. */
@@ -15713,7 +15713,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
classtuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(classtuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- ((Form_pg_class) GETSTRUCT(classtuple))->reloftype = typeid;
+ (GETSTRUCT(pg_class, classtuple))->reloftype = typeid;
CatalogTupleUpdate(relationRelation, &classtuple->t_self, classtuple);
InvokeObjectPostAlterHook(RelationRelationId, relid, 0);
@@ -15758,7 +15758,7 @@ ATExecDropOf(Relation rel, LOCKMODE lockmode)
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- ((Form_pg_class) GETSTRUCT(tuple))->reloftype = InvalidOid;
+ (GETSTRUCT(pg_class, tuple))->reloftype = InvalidOid;
CatalogTupleUpdate(relationRelation, &tuple->t_self, tuple);
InvokeObjectPostAlterHook(RelationRelationId, relid, 0);
@@ -15795,7 +15795,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
if (!HeapTupleIsValid(pg_class_tuple))
elog(ERROR, "cache lookup failed for relation \"%s\"",
RelationGetRelationName(rel));
- pg_class_form = (Form_pg_class) GETSTRUCT(pg_class_tuple);
+ pg_class_form = GETSTRUCT(pg_class, pg_class_tuple);
if (pg_class_form->relreplident != ri_type)
{
pg_class_form->relreplident = ri_type;
@@ -15815,7 +15815,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
pg_index_tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexOid));
if (!HeapTupleIsValid(pg_index_tuple))
elog(ERROR, "cache lookup failed for index %u", indexOid);
- pg_index_form = (Form_pg_index) GETSTRUCT(pg_index_tuple);
+ pg_index_form = GETSTRUCT(pg_index, pg_index_tuple);
if (pg_index_form->indisreplident)
{
@@ -15839,7 +15839,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
ObjectIdGetDatum(thisIndexOid));
if (!HeapTupleIsValid(pg_index_tuple))
elog(ERROR, "cache lookup failed for index %u", thisIndexOid);
- pg_index_form = (Form_pg_index) GETSTRUCT(pg_index_tuple);
+ pg_index_form = GETSTRUCT(pg_index, pg_index_tuple);
/*
* Unset the bit if set. We know it's wrong because we checked this
@@ -16009,7 +16009,7 @@ ATExecSetRowSecurity(Relation rel, bool rls)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- ((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = rls;
+ (GETSTRUCT(pg_class, tuple))->relrowsecurity = rls;
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
table_close(pg_class, RowExclusiveLock);
@@ -16035,7 +16035,7 @@ ATExecForceNoForceRowSecurity(Relation rel, bool force_rls)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- ((Form_pg_class) GETSTRUCT(tuple))->relforcerowsecurity = force_rls;
+ (GETSTRUCT(pg_class, tuple))->relforcerowsecurity = force_rls;
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
table_close(pg_class, RowExclusiveLock);
@@ -16070,7 +16070,7 @@ ATExecGenericOptions(Relation rel, List *options)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign table \"%s\" does not exist",
RelationGetRelationName(rel))));
- tableform = (Form_pg_foreign_table) GETSTRUCT(tuple);
+ tableform = GETSTRUCT(pg_foreign_table, tuple);
server = GetForeignServer(tableform->ftserver);
fdw = GetForeignDataWrapper(server->fdwid);
@@ -16152,7 +16152,7 @@ ATExecSetCompression(Relation rel,
column, RelationGetRelationName(rel))));
/* prevent them from altering a system attribute */
- atttableform = (Form_pg_attribute) GETSTRUCT(tuple);
+ atttableform = GETSTRUCT(pg_attribute, tuple);
attnum = atttableform->attnum;
if (attnum <= 0)
ereport(ERROR,
@@ -16273,7 +16273,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
if (con->contype == CONSTRAINT_FOREIGN)
{
@@ -16475,7 +16475,7 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(classTup))
elog(ERROR, "cache lookup failed for relation %u", relOid);
- classForm = (Form_pg_class) GETSTRUCT(classTup);
+ classForm = GETSTRUCT(pg_class, classTup);
Assert(classForm->relnamespace == oldNspOid);
@@ -16607,7 +16607,7 @@ AlterSeqNamespaces(Relation classRel, Relation rel,
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend depForm = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend depForm = GETSTRUCT(pg_depend, tup);
Relation seqRel;
/* skip dependencies other than auto dependencies on columns */
@@ -16933,8 +16933,8 @@ RangeVarCallbackForTruncate(const RangeVar *relation,
if (!HeapTupleIsValid(tuple)) /* should not happen */
elog(ERROR, "cache lookup failed for relation %u", relId);
- truncate_check_rel(relId, (Form_pg_class) GETSTRUCT(tuple));
- truncate_check_perms(relId, (Form_pg_class) GETSTRUCT(tuple));
+ truncate_check_rel(relId, GETSTRUCT(pg_class, tuple));
+ truncate_check_perms(relId, GETSTRUCT(pg_class, tuple));
ReleaseSysCache(tuple);
}
@@ -16962,7 +16962,7 @@ RangeVarCallbackOwnsRelation(const RangeVar *relation,
relation->relname);
if (!allowSystemTableMods &&
- IsSystemClass(relId, (Form_pg_class) GETSTRUCT(tuple)))
+ IsSystemClass(relId, GETSTRUCT(pg_class, tuple)))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied: \"%s\" is a system catalog",
@@ -16989,7 +16989,7 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped */
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
relkind = classform->relkind;
/* Must own relation. */
@@ -17213,7 +17213,7 @@ ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNu
errmsg("column \"%s\" named in partition key does not exist",
pelem->name),
parser_errposition(pstate, pelem->location)));
- attform = (Form_pg_attribute) GETSTRUCT(atttuple);
+ attform = GETSTRUCT(pg_attribute, atttuple);
if (attform->attnum <= 0)
ereport(ERROR,
@@ -18121,7 +18121,7 @@ CloneRowTriggersToPartition(Relation parent, Relation partition)
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
- Form_pg_trigger trigForm = (Form_pg_trigger) GETSTRUCT(tuple);
+ Form_pg_trigger trigForm = GETSTRUCT(pg_trigger, tuple);
CreateTrigStmt *trigStmt;
Node *qual = NULL;
Datum value;
@@ -18475,7 +18475,7 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent,
contup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(fk->conoid));
if (!HeapTupleIsValid(contup))
elog(ERROR, "cache lookup failed for constraint %u", fk->conoid);
- conform = (Form_pg_constraint) GETSTRUCT(contup);
+ conform = GETSTRUCT(pg_constraint, contup);
/* consider only the inherited foreign keys */
if (conform->contype != CONSTRAINT_FOREIGN ||
@@ -18580,7 +18580,7 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(partRel));
- Assert(((Form_pg_class) GETSTRUCT(tuple))->relispartition);
+ Assert((GETSTRUCT(pg_class, tuple))->relispartition);
/* Clear relpartbound and reset relispartition */
memset(new_val, 0, sizeof(new_val));
@@ -18592,7 +18592,7 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent,
newtuple = heap_modify_tuple(tuple, RelationGetDescr(classRel),
new_val, new_null, new_repl);
- ((Form_pg_class) GETSTRUCT(newtuple))->relispartition = false;
+ (GETSTRUCT(pg_class, newtuple))->relispartition = false;
CatalogTupleUpdate(classRel, &newtuple->t_self, newtuple);
heap_freetuple(newtuple);
table_close(classRel, RowExclusiveLock);
@@ -18742,7 +18742,7 @@ DropClonedTriggersFromPartition(Oid partitionId)
true, NULL, 1, &skey);
while (HeapTupleIsValid(trigtup = systable_getnext(scan)))
{
- Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(trigtup);
+ Form_pg_trigger pg_trigger = GETSTRUCT(pg_trigger, trigtup);
ObjectAddress trig;
/* Ignore triggers that weren't cloned */
@@ -18829,7 +18829,7 @@ RangeVarCallbackForAttachIndex(const RangeVar *rv, Oid relOid, Oid oldRelOid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped, so nothing to do */
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
if (classform->relkind != RELKIND_PARTITIONED_INDEX &&
classform->relkind != RELKIND_INDEX)
ereport(ERROR,
@@ -19050,7 +19050,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
NULL, 1, &key);
while ((inhTup = systable_getnext(scan)) != NULL)
{
- Form_pg_inherits inhForm = (Form_pg_inherits) GETSTRUCT(inhTup);
+ Form_pg_inherits inhForm = GETSTRUCT(pg_inherits, inhTup);
HeapTuple indTup;
Form_pg_index indexForm;
@@ -19058,7 +19058,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
ObjectIdGetDatum(inhForm->inhrelid));
if (!HeapTupleIsValid(indTup))
elog(ERROR, "cache lookup failed for index %u", inhForm->inhrelid);
- indexForm = (Form_pg_index) GETSTRUCT(indTup);
+ indexForm = GETSTRUCT(pg_index, indTup);
if (indexForm->indisvalid)
tuples += 1;
ReleaseSysCache(indTup);
@@ -19080,7 +19080,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
idxRel = table_open(IndexRelationId, RowExclusiveLock);
newtup = heap_copytuple(partedIdx->rd_indextuple);
- ((Form_pg_index) GETSTRUCT(newtup))->indisvalid = true;
+ (GETSTRUCT(pg_index, newtup))->indisvalid = true;
updated = true;
CatalogTupleUpdate(idxRel, &partedIdx->rd_indextuple->t_self, newtup);
@@ -19150,7 +19150,7 @@ GetParentedForeignKeyRefs(Relation partition)
scan = systable_beginscan(pg_constraint, InvalidOid, true, NULL, 2, key);
while ((tuple = systable_getnext(scan)) != NULL)
{
- Form_pg_constraint constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint constrForm = GETSTRUCT(pg_constraint, tuple);
/*
* We only need to process constraints that are part of larger ones.
@@ -19191,7 +19191,7 @@ ATDetachCheckNoForeignKeyRefs(Relation partition)
tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constrOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", constrOid);
- constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
+ constrForm = GETSTRUCT(pg_constraint, tuple);
Assert(OidIsValid(constrForm->conparentid));
Assert(constrForm->confrelid == RelationGetRelid(partition));
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index 570ce3dbd5..c0989d82fc 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -450,7 +450,7 @@ DropTableSpace(DropTableSpaceStmt *stmt)
return;
}
- spcform = (Form_pg_tablespace) GETSTRUCT(tuple);
+ spcform = GETSTRUCT(pg_tablespace, tuple);
tablespaceoid = spcform->oid;
/* Must be tablespace owner */
@@ -978,7 +978,7 @@ RenameTableSpace(const char *oldname, const char *newname)
oldname)));
newtuple = heap_copytuple(tup);
- newform = (Form_pg_tablespace) GETSTRUCT(newtuple);
+ newform = GETSTRUCT(pg_tablespace, newtuple);
tspId = newform->oid;
table_endscan(scan);
@@ -1066,7 +1066,7 @@ AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt)
errmsg("tablespace \"%s\" does not exist",
stmt->tablespacename)));
- tablespaceoid = ((Form_pg_tablespace) GETSTRUCT(tup))->oid;
+ tablespaceoid = (GETSTRUCT(pg_tablespace, tup))->oid;
/* Must be owner of the existing object */
if (!pg_tablespace_ownercheck(tablespaceoid, GetUserId()))
@@ -1471,7 +1471,7 @@ get_tablespace_oid(const char *tablespacename, bool missing_ok)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = ((Form_pg_tablespace) GETSTRUCT(tuple))->oid;
+ result = (GETSTRUCT(pg_tablespace, tuple))->oid;
else
result = InvalidOid;
@@ -1517,7 +1517,7 @@ get_tablespace_name(Oid spc_oid)
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = pstrdup(NameStr(((Form_pg_tablespace) GETSTRUCT(tuple))->spcname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_tablespace, tuple))->spcname));
else
result = NULL;
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index b8db53b66d..47ef4004fa 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -736,7 +736,7 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
/* There should be at most one matching tuple */
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
- Form_pg_trigger oldtrigger = (Form_pg_trigger) GETSTRUCT(tuple);
+ Form_pg_trigger oldtrigger = GETSTRUCT(pg_trigger, tuple);
trigoid = oldtrigger->oid;
existing_constraint_oid = oldtrigger->tgconstraint;
@@ -1022,9 +1022,9 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(rel));
- if (!((Form_pg_class) GETSTRUCT(tuple))->relhastriggers)
+ if (!(GETSTRUCT(pg_class, tuple))->relhastriggers)
{
- ((Form_pg_class) GETSTRUCT(tuple))->relhastriggers = true;
+ (GETSTRUCT(pg_class, tuple))->relhastriggers = true;
CatalogTupleUpdate(pgrel, &tuple->t_self, tuple);
@@ -1283,7 +1283,7 @@ TriggerSetParentTrigger(Relation trigRel,
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for trigger %u", childTrigId);
newtup = heap_copytuple(tuple);
- trigForm = (Form_pg_trigger) GETSTRUCT(newtup);
+ trigForm = GETSTRUCT(pg_trigger, newtup);
if (OidIsValid(parentTrigId))
{
/* don't allow setting parent for a constraint that already has one */
@@ -1355,7 +1355,7 @@ RemoveTriggerById(Oid trigOid)
/*
* Open and exclusive-lock the relation the trigger belongs to.
*/
- relid = ((Form_pg_trigger) GETSTRUCT(tup))->tgrelid;
+ relid = (GETSTRUCT(pg_trigger, tup))->tgrelid;
rel = table_open(relid, AccessExclusiveLock);
@@ -1443,7 +1443,7 @@ get_trigger_oid(Oid relid, const char *trigname, bool missing_ok)
}
else
{
- oid = ((Form_pg_trigger) GETSTRUCT(tup))->oid;
+ oid = (GETSTRUCT(pg_trigger, tup))->oid;
}
systable_endscan(tgscan);
@@ -1464,7 +1464,7 @@ RangeVarCallbackForRenameTrigger(const RangeVar *rv, Oid relid, Oid oldrelid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped */
- form = (Form_pg_class) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_class, tuple);
/* only tables and views can have triggers */
if (form->relkind != RELKIND_RELATION && form->relkind != RELKIND_VIEW &&
@@ -1551,7 +1551,7 @@ renametrig(RenameStmt *stmt)
{
Form_pg_trigger trigform;
- trigform = (Form_pg_trigger) GETSTRUCT(tuple);
+ trigform = GETSTRUCT(pg_trigger, tuple);
tgoid = trigform->oid;
/*
@@ -1625,7 +1625,7 @@ renametrig_internal(Relation tgrel, Relation targetrel, HeapTuple trigtup,
SysScanDesc tgscan;
/* If the trigger already has the new name, nothing to do. */
- tgform = (Form_pg_trigger) GETSTRUCT(trigtup);
+ tgform = GETSTRUCT(pg_trigger, trigtup);
if (strcmp(NameStr(tgform->tgname), newname) == 0)
return;
@@ -1655,7 +1655,7 @@ renametrig_internal(Relation tgrel, Relation targetrel, HeapTuple trigtup,
* The target name is free; update the existing pg_trigger tuple with it.
*/
tuple = heap_copytuple(trigtup); /* need a modifiable copy */
- tgform = (Form_pg_trigger) GETSTRUCT(tuple);
+ tgform = GETSTRUCT(pg_trigger, tuple);
/*
* If the trigger has a name different from what we expected, let the user
@@ -1707,7 +1707,7 @@ renametrig_partition(Relation tgrel, Oid partitionId, Oid parentTriggerOid,
NULL, 1, &key);
while (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
- Form_pg_trigger tgform = (Form_pg_trigger) GETSTRUCT(tuple);
+ Form_pg_trigger tgform = GETSTRUCT(pg_trigger, tuple);
Relation partitionRel;
if (tgform->tgparentid != parentTriggerOid)
@@ -1794,7 +1794,7 @@ EnableDisableTrigger(Relation rel, const char *tgname,
while (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
- Form_pg_trigger oldtrig = (Form_pg_trigger) GETSTRUCT(tuple);
+ Form_pg_trigger oldtrig = GETSTRUCT(pg_trigger, tuple);
if (oldtrig->tgisinternal)
{
@@ -1814,7 +1814,7 @@ EnableDisableTrigger(Relation rel, const char *tgname,
{
/* need to change this one ... make a copy to scribble on */
HeapTuple newtup = heap_copytuple(tuple);
- Form_pg_trigger newtrig = (Form_pg_trigger) GETSTRUCT(newtup);
+ Form_pg_trigger newtrig = GETSTRUCT(pg_trigger, newtup);
newtrig->tgenabled = fires_when;
@@ -1898,7 +1898,7 @@ RelationBuildTriggers(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(tgscan)))
{
- Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
+ Form_pg_trigger pg_trigger = GETSTRUCT(pg_trigger, htup);
Trigger *build;
Datum datum;
bool isnull;
@@ -5702,7 +5702,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
while (HeapTupleIsValid(tup = systable_getnext(conscan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tup);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tup);
if (con->condeferrable)
conoidlist = lappend_oid(conoidlist, con->oid);
@@ -5758,7 +5758,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
- Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple);
conoidlist = lappend_oid(conoidlist, con->oid);
}
@@ -5791,7 +5791,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
while (HeapTupleIsValid(htup = systable_getnext(tgscan)))
{
- Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
+ Form_pg_trigger pg_trigger = GETSTRUCT(pg_trigger, htup);
/*
* Silently skip triggers that are marked as non-deferrable in
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index 4cc4e3c00f..164379934a 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -130,7 +130,7 @@ get_ts_parser_func(DefElem *defel, int attnum)
static ObjectAddress
makeParserDependencies(HeapTuple tuple)
{
- Form_pg_ts_parser prs = (Form_pg_ts_parser) GETSTRUCT(tuple);
+ Form_pg_ts_parser prs = GETSTRUCT(pg_ts_parser, tuple);
ObjectAddress myself,
referenced;
ObjectAddresses *addrs;
@@ -300,7 +300,7 @@ DefineTSParser(List *names, List *parameters)
static ObjectAddress
makeDictionaryDependencies(HeapTuple tuple)
{
- Form_pg_ts_dict dict = (Form_pg_ts_dict) GETSTRUCT(tuple);
+ Form_pg_ts_dict dict = GETSTRUCT(pg_ts_dict, tuple);
ObjectAddress myself,
referenced;
ObjectAddresses *addrs;
@@ -353,7 +353,7 @@ verify_dictoptions(Oid tmplId, List *dictoptions)
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for text search template %u",
tmplId);
- tform = (Form_pg_ts_template) GETSTRUCT(tup);
+ tform = GETSTRUCT(pg_ts_template, tup);
initmethod = tform->tmplinit;
@@ -552,7 +552,7 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
/*
* Validate
*/
- verify_dictoptions(((Form_pg_ts_dict) GETSTRUCT(tup))->dicttemplate,
+ verify_dictoptions((GETSTRUCT(pg_ts_dict, tup))->dicttemplate,
dictoptions);
/*
@@ -645,7 +645,7 @@ get_ts_template_func(DefElem *defel, int attnum)
static ObjectAddress
makeTSTemplateDependencies(HeapTuple tuple)
{
- Form_pg_ts_template tmpl = (Form_pg_ts_template) GETSTRUCT(tuple);
+ Form_pg_ts_template tmpl = GETSTRUCT(pg_ts_template, tuple);
ObjectAddress myself,
referenced;
ObjectAddresses *addrs;
@@ -806,7 +806,7 @@ static ObjectAddress
makeConfigurationDependencies(HeapTuple tuple, bool removeOld,
Relation mapRel)
{
- Form_pg_ts_config cfg = (Form_pg_ts_config) GETSTRUCT(tuple);
+ Form_pg_ts_config cfg = GETSTRUCT(pg_ts_config, tuple);
ObjectAddresses *addrs;
ObjectAddress myself,
referenced;
@@ -867,7 +867,7 @@ makeConfigurationDependencies(HeapTuple tuple, bool removeOld,
while (HeapTupleIsValid((maptup = systable_getnext(scan))))
{
- Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup);
+ Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup);
referenced.classId = TSDictionaryRelationId;
referenced.objectId = cfgmap->mapdict;
@@ -959,7 +959,7 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied)
elog(ERROR, "cache lookup failed for text search configuration %u",
sourceOid);
- cfg = (Form_pg_ts_config) GETSTRUCT(tup);
+ cfg = GETSTRUCT(pg_ts_config, tup);
/* use source's parser */
prsOid = cfg->cfgparser;
@@ -1017,7 +1017,7 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied)
while (HeapTupleIsValid((maptup = systable_getnext(scan))))
{
- Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup);
+ Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup);
HeapTuple newmaptup;
Datum mapvalues[Natts_pg_ts_config_map];
bool mapnulls[Natts_pg_ts_config_map];
@@ -1121,7 +1121,7 @@ AlterTSConfiguration(AlterTSConfigurationStmt *stmt)
errmsg("text search configuration \"%s\" does not exist",
NameListToString(stmt->cfgname))));
- cfgId = ((Form_pg_ts_config) GETSTRUCT(tup))->oid;
+ cfgId = (GETSTRUCT(pg_ts_config, tup))->oid;
/* must be owner */
if (!pg_ts_config_ownercheck(cfgId, GetUserId()))
@@ -1226,7 +1226,7 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt,
int ndict;
ListCell *c;
- tsform = (Form_pg_ts_config) GETSTRUCT(tup);
+ tsform = GETSTRUCT(pg_ts_config, tup);
cfgId = tsform->oid;
prsId = tsform->cfgparser;
@@ -1293,7 +1293,7 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt,
while (HeapTupleIsValid((maptup = systable_getnext(scan))))
{
- Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup);
+ Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup);
/*
* check if it's one of target token types
@@ -1386,7 +1386,7 @@ DropConfigurationMapping(AlterTSConfigurationStmt *stmt,
int *tokens;
ListCell *c;
- tsform = (Form_pg_ts_config) GETSTRUCT(tup);
+ tsform = GETSTRUCT(pg_ts_config, tup);
cfgId = tsform->oid;
prsId = tsform->cfgparser;
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index d0d87a1184..943ed1ec13 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -345,7 +345,7 @@ DefineType(ParseState *pstate, List *names, List *parameters)
Form_pg_type likeForm;
likeType = typenameType(NULL, defGetTypeName(likeTypeEl), NULL);
- likeForm = (Form_pg_type) GETSTRUCT(likeType);
+ likeForm = GETSTRUCT(pg_type, likeType);
internalLength = likeForm->typlen;
byValue = likeForm->typbyval;
alignment = likeForm->typalign;
@@ -668,7 +668,7 @@ RemoveTypeById(Oid typeOid)
* making dependency entries for those, so it has to be done "by hand"
* here.
*/
- if (((Form_pg_type) GETSTRUCT(tup))->typtype == TYPTYPE_ENUM)
+ if ((GETSTRUCT(pg_type, tup))->typtype == TYPTYPE_ENUM)
EnumValuesDelete(typeOid);
/*
@@ -676,7 +676,7 @@ RemoveTypeById(Oid typeOid)
* with making a dependency entry for that, so it has to be done "by hand"
* here.
*/
- if (((Form_pg_type) GETSTRUCT(tup))->typtype == TYPTYPE_RANGE)
+ if ((GETSTRUCT(pg_type, tup))->typtype == TYPTYPE_RANGE)
RangeDelete(typeOid);
ReleaseSysCache(tup);
@@ -758,7 +758,7 @@ DefineDomain(CreateDomainStmt *stmt)
* Look up the base type.
*/
typeTup = typenameType(NULL, stmt->typeName, &basetypeMod);
- baseType = (Form_pg_type) GETSTRUCT(typeTup);
+ baseType = GETSTRUCT(pg_type, typeTup);
basetypeoid = baseType->oid;
/*
@@ -1308,7 +1308,7 @@ AlterEnum(AlterEnumStmt *stmt)
static void
checkEnumOwner(HeapTuple tup)
{
- Form_pg_type typTup = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typTup = GETSTRUCT(pg_type, tup);
/* Check that this is actually an enum */
if (typTup->typtype != TYPTYPE_ENUM)
@@ -2587,7 +2587,7 @@ AlterDomainDefault(List *names, Node *defaultRaw)
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* Check it's a domain and check user has permission for ALTER DOMAIN */
checkDomainOwner(tup);
@@ -2709,7 +2709,7 @@ AlterDomainNotNull(List *names, bool notNull)
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* Check it's a domain and check user has permission for ALTER DOMAIN */
checkDomainOwner(tup);
@@ -2864,7 +2864,7 @@ AlterDomainDropConstraint(List *names, const char *constrName,
ObjectAddress conobj;
conobj.classId = ConstraintRelationId;
- conobj.objectId = ((Form_pg_constraint) GETSTRUCT(contup))->oid;
+ conobj.objectId = (GETSTRUCT(pg_constraint, contup))->oid;
conobj.objectSubId = 0;
performDeletion(&conobj, behavior, 0);
@@ -2931,7 +2931,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint,
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* Check it's a domain and check user has permission for ALTER DOMAIN */
checkDomainOwner(tup);
@@ -3085,7 +3085,7 @@ AlterDomainValidateConstraint(List *names, const char *constrName)
errmsg("constraint \"%s\" of domain \"%s\" does not exist",
constrName, TypeNameToString(typename))));
- con = (Form_pg_constraint) GETSTRUCT(tuple);
+ con = GETSTRUCT(pg_constraint, tuple);
if (con->contype != CONSTRAINT_CHECK)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -3106,7 +3106,7 @@ AlterDomainValidateConstraint(List *names, const char *constrName)
* Now update the catalog, while we have the door open.
*/
copyTuple = heap_copytuple(tuple);
- copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple);
+ copy_con = GETSTRUCT(pg_constraint, copyTuple);
copy_con->convalidated = true;
CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple);
@@ -3281,7 +3281,7 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
while (HeapTupleIsValid(depTup = systable_getnext(depScan)))
{
- Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup);
+ Form_pg_depend pg_depend = GETSTRUCT(pg_depend, depTup);
RelToCheck *rtc = NULL;
ListCell *rellist;
Form_pg_attribute pg_att;
@@ -3418,7 +3418,7 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
void
checkDomainOwner(HeapTuple tup)
{
- Form_pg_type typTup = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typTup = GETSTRUCT(pg_type, tup);
/* Check that this is actually a domain */
if (typTup->typtype != TYPTYPE_DOMAIN)
@@ -3613,7 +3613,7 @@ RenameType(RenameStmt *stmt)
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* check permissions on type */
if (!pg_type_ownercheck(typeOid, GetUserId()))
@@ -3698,7 +3698,7 @@ AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype)
newtup = heap_copytuple(tup);
ReleaseSysCache(tup);
tup = newtup;
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/* Don't allow ALTER DOMAIN on a type */
if (objecttype == OBJECT_DOMAIN && typTup->typtype != TYPTYPE_DOMAIN)
@@ -3788,7 +3788,7 @@ AlterTypeOwner_oid(Oid typeOid, Oid newOwnerId, bool hasDependEntry)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
/*
* If it's a composite type, invoke ATExecChangeOwner so that we fix up
@@ -3834,7 +3834,7 @@ AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId)
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
memset(repl_null, false, sizeof(repl_null));
memset(repl_repl, false, sizeof(repl_repl));
@@ -3975,7 +3975,7 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typform = (Form_pg_type) GETSTRUCT(tup);
+ typform = GETSTRUCT(pg_type, tup);
oldNspOid = typform->typnamespace;
arrayOid = typform->typarray;
@@ -4109,7 +4109,7 @@ AlterType(AlterTypeStmt *stmt)
tup = typenameType(NULL, typename, NULL);
typeOid = typeTypeId(tup);
- typForm = (Form_pg_type) GETSTRUCT(tup);
+ typForm = GETSTRUCT(pg_type, tup);
/* Process options */
memset(&atparams, 0, sizeof(atparams));
@@ -4423,7 +4423,7 @@ AlterTypeRecurse(Oid typeOid, bool isImplicitArray,
if (!isImplicitArray &&
(atparams->updateTypmodin || atparams->updateTypmodout))
{
- Oid arrtypoid = ((Form_pg_type) GETSTRUCT(newtup))->typarray;
+ Oid arrtypoid = (GETSTRUCT(pg_type, newtup))->typarray;
if (OidIsValid(arrtypoid))
{
@@ -4472,7 +4472,7 @@ AlterTypeRecurse(Oid typeOid, bool isImplicitArray,
while ((domainTup = systable_getnext(scan)) != NULL)
{
- Form_pg_type domainForm = (Form_pg_type) GETSTRUCT(domainTup);
+ Form_pg_type domainForm = GETSTRUCT(pg_type, domainTup);
/*
* Shouldn't have a nonzero typbasetype in a non-domain, but let's
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 94135fdd6b..daa85d448a 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -442,7 +442,7 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
{
RoleSpec *oldrole = lfirst(item);
HeapTuple oldroletup = get_rolespec_tuple(oldrole);
- Form_pg_authid oldroleform = (Form_pg_authid) GETSTRUCT(oldroletup);
+ Form_pg_authid oldroleform = GETSTRUCT(pg_authid, oldroletup);
Oid oldroleid = oldroleform->oid;
char *oldrolename = NameStr(oldroleform->rolname);
@@ -616,7 +616,7 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
pg_authid_dsc = RelationGetDescr(pg_authid_rel);
tuple = get_rolespec_tuple(stmt->role);
- authform = (Form_pg_authid) GETSTRUCT(tuple);
+ authform = GETSTRUCT(pg_authid, tuple);
rolename = pstrdup(NameStr(authform->rolname));
roleid = authform->oid;
@@ -838,7 +838,7 @@ AlterRoleSet(AlterRoleSetStmt *stmt)
"Cannot alter reserved roles.");
roletuple = get_rolespec_tuple(stmt->role);
- roleform = (Form_pg_authid) GETSTRUCT(roletuple);
+ roleform = GETSTRUCT(pg_authid, roletuple);
roleid = roleform->oid;
/*
@@ -962,7 +962,7 @@ DropRole(DropRoleStmt *stmt)
continue;
}
- roleform = (Form_pg_authid) GETSTRUCT(tuple);
+ roleform = GETSTRUCT(pg_authid, tuple);
roleid = roleform->oid;
if (roleid == GetUserId())
@@ -1117,7 +1117,7 @@ RenameRole(const char *oldname, const char *newname)
* effective userid, though.
*/
- authform = (Form_pg_authid) GETSTRUCT(oldtuple);
+ authform = GETSTRUCT(pg_authid, oldtuple);
roleid = authform->oid;
if (roleid == GetSessionUserId())
@@ -1165,7 +1165,7 @@ RenameRole(const char *oldname, const char *newname)
/*
* createrole is enough privilege unless you want to mess with a superuser
*/
- if (((Form_pg_authid) GETSTRUCT(oldtuple))->rolsuper)
+ if ((GETSTRUCT(pg_authid, oldtuple))->rolsuper)
{
if (!superuser())
ereport(ERROR,
@@ -1490,7 +1490,7 @@ AddRoleMems(const char *rolename, Oid roleid,
ObjectIdGetDatum(memberid));
if (HeapTupleIsValid(authmem_tuple) &&
(!admin_opt ||
- ((Form_pg_auth_members) GETSTRUCT(authmem_tuple))->admin_option))
+ (GETSTRUCT(pg_auth_members, authmem_tuple))->admin_option))
{
ereport(NOTICE,
(errmsg("role \"%s\" is already a member of role \"%s\"",
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 8df25f59d8..72a028f21f 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -806,7 +806,7 @@ expand_vacuum_rel(VacuumRelation *vrel, int options)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/*
* Make a returnable VacuumRelation for this rel if user is a proper
@@ -894,7 +894,7 @@ get_all_vacuum_rels(int options)
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classForm = GETSTRUCT(pg_class, tuple);
MemoryContext oldcontext;
Oid relid = classForm->oid;
@@ -1346,7 +1346,7 @@ vac_update_relstats(Relation relation,
if (!HeapTupleIsValid(ctup))
elog(ERROR, "pg_class entry for relid %u vanished during vacuuming",
relid);
- pgcform = (Form_pg_class) GETSTRUCT(ctup);
+ pgcform = GETSTRUCT(pg_class, ctup);
/* Apply statistical updates, if any, to copied tuple */
@@ -1545,7 +1545,7 @@ vac_update_datfrozenxid(void)
while ((classTup = systable_getnext(scan)) != NULL)
{
- Form_pg_class classForm = (Form_pg_class) GETSTRUCT(classTup);
+ Form_pg_class classForm = GETSTRUCT(pg_class, classTup);
/*
* Only consider relations able to hold unfrozen XIDs (anything else
@@ -1639,7 +1639,7 @@ vac_update_datfrozenxid(void)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for database %u", MyDatabaseId);
- dbform = (Form_pg_database) GETSTRUCT(tuple);
+ dbform = GETSTRUCT(pg_database, tuple);
/*
* As in vac_update_relstats(), we ordinarily don't want to let
@@ -1747,7 +1747,7 @@ vac_truncate_clog(TransactionId frozenXID,
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- volatile FormData_pg_database *dbform = (Form_pg_database) GETSTRUCT(tuple);
+ volatile FormData_pg_database *dbform = GETSTRUCT(pg_database, tuple);
TransactionId datfrozenxid = dbform->datfrozenxid;
TransactionId datminmxid = dbform->datminmxid;
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index e5ddcda0b4..49f548d144 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -782,7 +782,7 @@ check_session_authorization(char **newval, void **extra, GucSource source)
return false;
}
- roleform = (Form_pg_authid) GETSTRUCT(roleTup);
+ roleform = GETSTRUCT(pg_authid, roleTup);
roleid = roleform->oid;
is_superuser = roleform->rolsuper;
@@ -869,7 +869,7 @@ check_role(char **newval, void **extra, GucSource source)
return false;
}
- roleform = (Form_pg_authid) GETSTRUCT(roleTup);
+ roleform = GETSTRUCT(pg_authid, roleTup);
roleid = roleform->oid;
is_superuser = roleform->rolsuper;
diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c
index 44b2e0b82d..09c40fa1e1 100644
--- a/src/backend/executor/execAmi.c
+++ b/src/backend/executor/execAmi.c
@@ -612,7 +612,7 @@ IndexSupportsBackwardScan(Oid indexid)
ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(indexid));
if (!HeapTupleIsValid(ht_idxrel))
elog(ERROR, "cache lookup failed for relation %u", indexid);
- idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);
+ idxrelrec = GETSTRUCT(pg_class, ht_idxrel);
/* Fetch the index AM's API struct */
amroutine = GetIndexAmRoutineByAmId(idxrelrec->relam, false);
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index 076226868f..76f18bbbdc 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -178,7 +178,7 @@ prepare_sql_fn_parse_info(HeapTuple procedureTuple,
Oid inputCollation)
{
SQLFunctionParseInfoPtr pinfo;
- Form_pg_proc procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ Form_pg_proc procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
int nargs;
pinfo = (SQLFunctionParseInfoPtr) palloc0(sizeof(SQLFunctionParseInfo));
@@ -621,7 +621,7 @@ init_sql_fcache(FunctionCallInfo fcinfo, Oid collation, bool lazyEvalOK)
procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(foid));
if (!HeapTupleIsValid(procedureTuple))
elog(ERROR, "cache lookup failed for function %u", foid);
- procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
/*
* copy function name immediately for use by error reporting callback, and
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 2fc606cf29..668e3181ac 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -3666,7 +3666,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
if (!HeapTupleIsValid(aggTuple))
elog(ERROR, "cache lookup failed for aggregate %u",
aggref->aggfnoid);
- aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
+ aggform = GETSTRUCT(pg_aggregate, aggTuple);
/* Check permission to call aggregate function */
aclresult = pg_proc_aclcheck(aggref->aggfnoid, GetUserId(),
@@ -3731,7 +3731,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
if (!HeapTupleIsValid(procTuple))
elog(ERROR, "cache lookup failed for function %u",
aggref->aggfnoid);
- aggOwner = ((Form_pg_proc) GETSTRUCT(procTuple))->proowner;
+ aggOwner = (GETSTRUCT(pg_proc, procTuple))->proowner;
ReleaseSysCache(procTuple);
if (OidIsValid(finalfn_oid))
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 4b104c4d98..14b3547309 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -2775,7 +2775,7 @@ initialize_peragg(WindowAggState *winstate, WindowFunc *wfunc,
if (!HeapTupleIsValid(aggTuple))
elog(ERROR, "cache lookup failed for aggregate %u",
wfunc->winfnoid);
- aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
+ aggform = GETSTRUCT(pg_aggregate, aggTuple);
/*
* Figure out whether we want to use the moving-aggregate implementation,
@@ -2836,7 +2836,7 @@ initialize_peragg(WindowAggState *winstate, WindowFunc *wfunc,
if (!HeapTupleIsValid(procTuple))
elog(ERROR, "cache lookup failed for function %u",
wfunc->winfnoid);
- aggOwner = ((Form_pg_proc) GETSTRUCT(procTuple))->proowner;
+ aggOwner = (GETSTRUCT(pg_proc, procTuple))->proowner;
ReleaseSysCache(procTuple);
aclresult = pg_proc_aclcheck(transfn_oid, aggOwner,
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 29bc26669b..72998c71fb 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -1291,7 +1291,7 @@ SPI_gettype(TupleDesc tupdesc, int fnumber)
return NULL;
}
- result = pstrdup(NameStr(((Form_pg_type) GETSTRUCT(typeTuple))->typname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_type, typeTuple))->typname));
ReleaseSysCache(typeTuple);
return result;
}
diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c
index cf222fc3e9..4f52075f03 100644
--- a/src/backend/foreign/foreign.c
+++ b/src/backend/foreign/foreign.c
@@ -62,7 +62,7 @@ GetForeignDataWrapperExtended(Oid fdwid, bits16 flags)
return NULL;
}
- fdwform = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp);
+ fdwform = GETSTRUCT(pg_foreign_data_wrapper, tp);
fdw = (ForeignDataWrapper *) palloc(sizeof(ForeignDataWrapper));
fdw->fdwid = fdwid;
@@ -136,7 +136,7 @@ GetForeignServerExtended(Oid serverid, bits16 flags)
return NULL;
}
- serverform = (Form_pg_foreign_server) GETSTRUCT(tp);
+ serverform = GETSTRUCT(pg_foreign_server, tp);
server = (ForeignServer *) palloc(sizeof(ForeignServer));
server->serverid = serverid;
@@ -222,7 +222,7 @@ GetUserMapping(Oid userid, Oid serverid)
MappingUserName(userid))));
um = (UserMapping *) palloc(sizeof(UserMapping));
- um->umid = ((Form_pg_user_mapping) GETSTRUCT(tp))->oid;
+ um->umid = (GETSTRUCT(pg_user_mapping, tp))->oid;
um->userid = userid;
um->serverid = serverid;
@@ -257,7 +257,7 @@ GetForeignTable(Oid relid)
tp = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign table %u", relid);
- tableform = (Form_pg_foreign_table) GETSTRUCT(tp);
+ tableform = GETSTRUCT(pg_foreign_table, tp);
ft = (ForeignTable *) palloc(sizeof(ForeignTable));
ft->relid = relid;
@@ -347,7 +347,7 @@ GetForeignServerIdByRelId(Oid relid)
tp = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign table %u", relid);
- tableform = (Form_pg_foreign_table) GETSTRUCT(tp);
+ tableform = GETSTRUCT(pg_foreign_table, tp);
serverid = tableform->ftserver;
ReleaseSysCache(tp);
@@ -372,7 +372,7 @@ GetFdwRoutineByServerId(Oid serverid)
tp = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(serverid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign server %u", serverid);
- serverform = (Form_pg_foreign_server) GETSTRUCT(tp);
+ serverform = GETSTRUCT(pg_foreign_server, tp);
fdwid = serverform->srvfdw;
ReleaseSysCache(tp);
@@ -380,7 +380,7 @@ GetFdwRoutineByServerId(Oid serverid)
tp = SearchSysCache1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(fdwid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign-data wrapper %u", fdwid);
- fdwform = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp);
+ fdwform = GETSTRUCT(pg_foreign_data_wrapper, tp);
fdwhandler = fdwform->fdwhandler;
/* Complain if FDW has been set to NO HANDLER. */
diff --git a/src/backend/optimizer/plan/planagg.c b/src/backend/optimizer/plan/planagg.c
index e0e357960f..6512d84b13 100644
--- a/src/backend/optimizer/plan/planagg.c
+++ b/src/backend/optimizer/plan/planagg.c
@@ -505,7 +505,7 @@ fetch_agg_sort_op(Oid aggfnoid)
aggTuple = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(aggfnoid));
if (!HeapTupleIsValid(aggTuple))
return InvalidOid;
- aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
+ aggform = GETSTRUCT(pg_aggregate, aggTuple);
aggsortop = aggform->aggsortop;
ReleaseSysCache(aggTuple);
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c
index df4ca12919..c80434b08c 100644
--- a/src/backend/optimizer/plan/subselect.c
+++ b/src/backend/optimizer/plan/subselect.c
@@ -866,7 +866,7 @@ hash_ok_operator(OpExpr *expr)
tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(opid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for operator %u", opid);
- optup = (Form_pg_operator) GETSTRUCT(tup);
+ optup = GETSTRUCT(pg_operator, tup);
if (!optup->oprcanhash || !func_strict(optup->oprcode))
{
ReleaseSysCache(tup);
diff --git a/src/backend/optimizer/prep/prepagg.c b/src/backend/optimizer/prep/prepagg.c
index 5b12937ead..173fcc908b 100644
--- a/src/backend/optimizer/prep/prepagg.c
+++ b/src/backend/optimizer/prep/prepagg.c
@@ -152,7 +152,7 @@ preprocess_aggref(Aggref *aggref, PlannerInfo *root)
if (!HeapTupleIsValid(aggTuple))
elog(ERROR, "cache lookup failed for aggregate %u",
aggref->aggfnoid);
- aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
+ aggform = GETSTRUCT(pg_aggregate, aggTuple);
aggtransfn = aggform->aggtransfn;
aggfinalfn = aggform->aggfinalfn;
aggcombinefn = aggform->aggcombinefn;
diff --git a/src/backend/optimizer/util/appendinfo.c b/src/backend/optimizer/util/appendinfo.c
index 9d4bb47027..a450c1e69f 100644
--- a/src/backend/optimizer/util/appendinfo.c
+++ b/src/backend/optimizer/util/appendinfo.c
@@ -150,7 +150,7 @@ make_inh_translation_list(Relation oldrelation, Relation newrelation,
if (!HeapTupleIsValid(newtup))
elog(ERROR, "could not find inherited attribute \"%s\" of relation \"%s\"",
attname, RelationGetRelationName(newrelation));
- new_attno = ((Form_pg_attribute) GETSTRUCT(newtup))->attnum - 1;
+ new_attno = (GETSTRUCT(pg_attribute, newtup))->attnum - 1;
Assert(new_attno >= 0 && new_attno < newnatts);
ReleaseSysCache(newtup);
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index 533df86ff7..277218abdc 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -3962,7 +3962,7 @@ simplify_function(Oid funcid, Oid result_type, int32 result_typmod,
func_tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(func_tuple))
elog(ERROR, "cache lookup failed for function %u", funcid);
- func_form = (Form_pg_proc) GETSTRUCT(func_tuple);
+ func_form = GETSTRUCT(pg_proc, func_tuple);
/*
* Process the function arguments, unless the caller did it already.
@@ -4056,7 +4056,7 @@ List *
expand_function_arguments(List *args, bool include_out_arguments,
Oid result_type, HeapTuple func_tuple)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
Oid *proargtypes = funcform->proargtypes.values;
int pronargs = funcform->pronargs;
bool has_named_args = false;
@@ -4136,7 +4136,7 @@ expand_function_arguments(List *args, bool include_out_arguments,
static List *
reorder_function_arguments(List *args, int pronargs, HeapTuple func_tuple)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
int nargsprovided = list_length(args);
Node *argarray[FUNC_MAX_ARGS];
ListCell *lc;
@@ -4267,7 +4267,7 @@ recheck_cast_function_args(List *args, Oid result_type,
Oid *proargtypes, int pronargs,
HeapTuple func_tuple)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
int nargs;
Oid actual_arg_types[FUNC_MAX_ARGS];
Oid declared_arg_types[FUNC_MAX_ARGS];
@@ -4314,7 +4314,7 @@ evaluate_function(Oid funcid, Oid result_type, int32 result_typmod,
HeapTuple func_tuple,
eval_const_expressions_context *context)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
bool has_nonconst_input = false;
bool has_null_input = false;
ListCell *arg;
@@ -4441,7 +4441,7 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid,
HeapTuple func_tuple,
eval_const_expressions_context *context)
{
- Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple);
char *src;
Datum tmp;
bool isNull;
@@ -5034,7 +5034,7 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
func_tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(func_oid));
if (!HeapTupleIsValid(func_tuple))
elog(ERROR, "cache lookup failed for function %u", func_oid);
- funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
+ funcform = GETSTRUCT(pg_proc, func_tuple);
/*
* Forget it if the function is not SQL-language or has other showstopper
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 5012bfe142..c163f1096e 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -1296,7 +1296,7 @@ get_relation_statistics_worker(List **stainfos, RelOptInfo *rel,
if (!HeapTupleIsValid(dtup))
return;
- dataForm = (Form_pg_statistic_ext_data) GETSTRUCT(dtup);
+ dataForm = GETSTRUCT(pg_statistic_ext_data, dtup);
/* add one StatisticExtInfo for each kind built */
if (statext_is_kind_built(dtup, STATS_EXT_NDISTINCT))
@@ -1388,7 +1388,7 @@ get_relation_statistics(RelOptInfo *rel, Relation relation)
htup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statOid));
if (!HeapTupleIsValid(htup))
elog(ERROR, "cache lookup failed for statistics object %u", statOid);
- staForm = (Form_pg_statistic_ext) GETSTRUCT(htup);
+ staForm = GETSTRUCT(pg_statistic_ext, htup);
/*
* First, build the array of columns covered. This is ultimately
@@ -1994,7 +1994,7 @@ add_function_cost(PlannerInfo *root, Oid funcid, Node *node,
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
if (OidIsValid(procform->prosupport))
{
@@ -2055,7 +2055,7 @@ get_function_rows(PlannerInfo *root, Oid funcid, Node *node)
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
Assert(procform->proretset); /* else caller error */
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index 5a18107e79..0c950cf0ad 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -3611,7 +3611,7 @@ transformFrameOffset(ParseState *pstate, int frameOptions,
for (i = 0; i < proclist->n_members; i++)
{
HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
+ Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup);
/* The search will find all support proc types; ignore others */
if (procform->amprocnum != BTINRANGE_PROC)
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index c4e958e4aa..172d4b2034 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -853,7 +853,7 @@ build_coercion_expression(Node *node,
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcId));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcId);
- procstruct = (Form_pg_proc) GETSTRUCT(tp);
+ procstruct = GETSTRUCT(pg_proc, tp);
/*
* These Asserts essentially check that function is a legal coercion
@@ -3056,7 +3056,7 @@ IsBinaryCoercible(Oid srctype, Oid targettype)
ObjectIdGetDatum(targettype));
if (!HeapTupleIsValid(tuple))
return false; /* no cast */
- castForm = (Form_pg_cast) GETSTRUCT(tuple);
+ castForm = GETSTRUCT(pg_cast, tuple);
result = (castForm->castmethod == COERCION_METHOD_BINARY &&
castForm->castcontext == COERCION_CODE_IMPLICIT);
@@ -3120,7 +3120,7 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
if (HeapTupleIsValid(tuple))
{
- Form_pg_cast castForm = (Form_pg_cast) GETSTRUCT(tuple);
+ Form_pg_cast castForm = GETSTRUCT(pg_cast, tuple);
CoercionContext castcontext;
/* convert char value for castcontext to CoercionContext enum */
@@ -3269,7 +3269,7 @@ find_typmod_coercion_function(Oid typeId,
result = COERCION_PATH_FUNC;
targetType = typeidType(typeId);
- typeForm = (Form_pg_type) GETSTRUCT(targetType);
+ typeForm = GETSTRUCT(pg_type, targetType);
/* Check for a "true" array type */
if (IsTrueArrayType(typeForm))
@@ -3287,7 +3287,7 @@ find_typmod_coercion_function(Oid typeId,
if (HeapTupleIsValid(tuple))
{
- Form_pg_cast castForm = (Form_pg_cast) GETSTRUCT(tuple);
+ Form_pg_cast castForm = GETSTRUCT(pg_cast, tuple);
*funcid = castForm->castfunc;
ReleaseSysCache(tuple);
@@ -3335,7 +3335,7 @@ typeIsOfTypedTable(Oid reltypeId, Oid reloftypeId)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltup = (Form_pg_class) GETSTRUCT(tp);
+ reltup = GETSTRUCT(pg_class, tp);
if (reltup->reloftype == reloftypeId)
result = true;
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index f71a682cd6..c9be37c173 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -367,7 +367,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
tup = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for aggregate %u", funcid);
- classForm = (Form_pg_aggregate) GETSTRUCT(tup);
+ classForm = GETSTRUCT(pg_aggregate, tup);
aggkind = classForm->aggkind;
catDirectArgs = classForm->aggnumdirectargs;
ReleaseSysCache(tup);
@@ -1623,7 +1623,7 @@ func_get_detail(List *funcname,
if (!HeapTupleIsValid(ftup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u",
best_candidate->oid);
- pform = (Form_pg_proc) GETSTRUCT(ftup);
+ pform = GETSTRUCT(pg_proc, ftup);
*rettype = pform->prorettype;
*retset = pform->proretset;
*vatype = pform->provariadic;
@@ -1893,7 +1893,7 @@ FuncNameAsType(List *funcname)
if (typtup == NULL)
return InvalidOid;
- if (((Form_pg_type) GETSTRUCT(typtup))->typisdefined &&
+ if ((GETSTRUCT(pg_type, typtup))->typisdefined &&
!OidIsValid(typeTypeRelid(typtup)))
result = typeTypeId(typtup);
else
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index cf64afbd85..2c165bb1be 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -249,14 +249,14 @@ get_sort_group_operators(Oid argtype,
Oid
oprid(Operator op)
{
- return ((Form_pg_operator) GETSTRUCT(op))->oid;
+ return (GETSTRUCT(pg_operator, op))->oid;
}
/* given operator tuple, return the underlying function's OID */
Oid
oprfuncid(Operator op)
{
- Form_pg_operator pgopform = (Form_pg_operator) GETSTRUCT(op);
+ Form_pg_operator pgopform = GETSTRUCT(pg_operator, op);
return pgopform->oprcode;
}
@@ -471,7 +471,7 @@ compatible_oper(ParseState *pstate, List *op, Oid arg1, Oid arg2,
return (Operator) NULL; /* must be noError case */
/* but is it good enough? */
- opform = (Form_pg_operator) GETSTRUCT(optup);
+ opform = GETSTRUCT(pg_operator, optup);
if (IsBinaryCoercible(arg1, opform->oprleft) &&
IsBinaryCoercible(arg2, opform->oprright))
return optup;
@@ -705,7 +705,7 @@ make_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree,
tup = oper(pstate, opname, ltypeId, rtypeId, false, location);
}
- opform = (Form_pg_operator) GETSTRUCT(tup);
+ opform = GETSTRUCT(pg_operator, tup);
/* Check it's not a shell */
if (!RegProcedureIsValid(opform->oprcode))
@@ -819,7 +819,7 @@ make_scalar_array_op(ParseState *pstate, List *opname,
/* Now resolve the operator */
tup = oper(pstate, opname, ltypeId, rtypeId, false, location);
- opform = (Form_pg_operator) GETSTRUCT(tup);
+ opform = GETSTRUCT(pg_operator, tup);
/* Check it's not a shell */
if (!RegProcedureIsValid(opform->oprcode))
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 8d832efc62..bc53e2922d 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -3261,7 +3261,7 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, rte->relid);
- att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ att_tup = GETSTRUCT(pg_attribute, tp);
result = att_tup->attisdropped;
ReleaseSysCache(tp);
}
diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c
index f7ad689459..65f0ab1489 100644
--- a/src/backend/parser/parse_type.c
+++ b/src/backend/parser/parse_type.c
@@ -247,7 +247,7 @@ LookupTypeNameOid(ParseState *pstate, const TypeName *typeName, bool missing_ok)
return InvalidOid;
}
- typoid = ((Form_pg_type) GETSTRUCT(tup))->oid;
+ typoid = (GETSTRUCT(pg_type, tup))->oid;
ReleaseSysCache(tup);
return typoid;
@@ -272,7 +272,7 @@ typenameType(ParseState *pstate, const TypeName *typeName, int32 *typmod_p)
errmsg("type \"%s\" does not exist",
TypeNameToString(typeName)),
parser_errposition(pstate, typeName->location)));
- if (!((Form_pg_type) GETSTRUCT(tup))->typisdefined)
+ if (!(GETSTRUCT(pg_type, tup))->typisdefined)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type \"%s\" is only a shell",
@@ -294,7 +294,7 @@ typenameTypeId(ParseState *pstate, const TypeName *typeName)
Type tup;
tup = typenameType(pstate, typeName, NULL);
- typoid = ((Form_pg_type) GETSTRUCT(tup))->oid;
+ typoid = (GETSTRUCT(pg_type, tup))->oid;
ReleaseSysCache(tup);
return typoid;
@@ -313,7 +313,7 @@ typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName,
Type tup;
tup = typenameType(pstate, typeName, typmod_p);
- *typeid_p = ((Form_pg_type) GETSTRUCT(tup))->oid;
+ *typeid_p = (GETSTRUCT(pg_type, tup))->oid;
ReleaseSysCache(tup);
}
@@ -348,14 +348,14 @@ typenameTypeMod(ParseState *pstate, const TypeName *typeName, Type typ)
* for the shell-type case, since a shell couldn't possibly have a
* typmodin function.
*/
- if (!((Form_pg_type) GETSTRUCT(typ))->typisdefined)
+ if (!(GETSTRUCT(pg_type, typ))->typisdefined)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("type modifier cannot be specified for shell type \"%s\"",
TypeNameToString(typeName)),
parser_errposition(pstate, typeName->location)));
- typmodin = ((Form_pg_type) GETSTRUCT(typ))->typmodin;
+ typmodin = (GETSTRUCT(pg_type, typ))->typmodin;
if (typmodin == InvalidOid)
ereport(ERROR,
@@ -591,7 +591,7 @@ typeTypeId(Type tp)
{
if (tp == NULL) /* probably useless */
elog(ERROR, "typeTypeId() called with NULL type struct");
- return ((Form_pg_type) GETSTRUCT(tp))->oid;
+ return (GETSTRUCT(pg_type, tp))->oid;
}
/* given type (as type struct), return the length of type */
@@ -600,7 +600,7 @@ typeLen(Type t)
{
Form_pg_type typ;
- typ = (Form_pg_type) GETSTRUCT(t);
+ typ = GETSTRUCT(pg_type, t);
return typ->typlen;
}
@@ -610,7 +610,7 @@ typeByVal(Type t)
{
Form_pg_type typ;
- typ = (Form_pg_type) GETSTRUCT(t);
+ typ = GETSTRUCT(pg_type, t);
return typ->typbyval;
}
@@ -620,7 +620,7 @@ typeTypeName(Type t)
{
Form_pg_type typ;
- typ = (Form_pg_type) GETSTRUCT(t);
+ typ = GETSTRUCT(pg_type, t);
/* pstrdup here because result may need to outlive the syscache entry */
return pstrdup(NameStr(typ->typname));
}
@@ -631,7 +631,7 @@ typeTypeRelid(Type typ)
{
Form_pg_type typtup;
- typtup = (Form_pg_type) GETSTRUCT(typ);
+ typtup = GETSTRUCT(pg_type, typ);
return typtup->typrelid;
}
@@ -641,7 +641,7 @@ typeTypeCollation(Type typ)
{
Form_pg_type typtup;
- typtup = (Form_pg_type) GETSTRUCT(typ);
+ typtup = GETSTRUCT(pg_type, typ);
return typtup->typcollation;
}
@@ -653,7 +653,7 @@ typeTypeCollation(Type typ)
Datum
stringTypeDatum(Type tp, char *string, int32 atttypmod)
{
- Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typform = GETSTRUCT(pg_type, tp);
Oid typinput = typform->typinput;
Oid typioparam = getTypeIOParam(tp);
@@ -674,7 +674,7 @@ typeidTypeRelid(Oid type_id)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_id));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type_id);
- type = (Form_pg_type) GETSTRUCT(typeTuple);
+ type = GETSTRUCT(pg_type, typeTuple);
result = type->typrelid;
ReleaseSysCache(typeTuple);
return result;
@@ -697,7 +697,7 @@ typeOrDomainTypeRelid(Oid type_id)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_id));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type_id);
- type = (Form_pg_type) GETSTRUCT(typeTuple);
+ type = GETSTRUCT(pg_type, typeTuple);
if (type->typtype != TYPTYPE_DOMAIN)
{
/* Not a domain, so done looking through domains */
@@ -797,7 +797,7 @@ parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p, bool missing_ok
}
else
{
- Form_pg_type typ = (Form_pg_type) GETSTRUCT(tup);
+ Form_pg_type typ = GETSTRUCT(pg_type, tup);
if (!typ->typisdefined)
ereport(ERROR,
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index b57253463b..417a571529 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -693,7 +693,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
errmsg("identity columns are not supported on partitions")));
ctype = typenameType(cxt->pstate, column->typeName, NULL);
- typeOid = ((Form_pg_type) GETSTRUCT(ctype))->oid;
+ typeOid = (GETSTRUCT(pg_type, ctype))->oid;
ReleaseSysCache(ctype);
if (saw_identity)
@@ -1457,7 +1457,7 @@ transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
tuple = typenameType(NULL, ofTypename, NULL);
check_of_type(tuple);
- ofTypeId = ((Form_pg_type) GETSTRUCT(tuple))->oid;
+ ofTypeId = (GETSTRUCT(pg_type, tuple))->oid;
ofTypename->typeOid = ofTypeId; /* cached for later */
tupdesc = lookup_rowtype_tupdesc(ofTypeId, -1);
@@ -1541,11 +1541,11 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(source_relid));
if (!HeapTupleIsValid(ht_idxrel))
elog(ERROR, "cache lookup failed for relation %u", source_relid);
- idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);
+ idxrelrec = GETSTRUCT(pg_class, ht_idxrel);
/* Fetch pg_index tuple for source index from relcache entry */
ht_idx = source_idx->rd_indextuple;
- idxrec = (Form_pg_index) GETSTRUCT(ht_idx);
+ idxrec = GETSTRUCT(pg_index, ht_idx);
indrelid = idxrec->indrelid;
/* Fetch the pg_am tuple of the index' access method */
@@ -1553,7 +1553,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
if (!HeapTupleIsValid(ht_am))
elog(ERROR, "cache lookup failed for access method %u",
idxrelrec->relam);
- amrec = (Form_pg_am) GETSTRUCT(ht_am);
+ amrec = GETSTRUCT(pg_am, ht_am);
/* Extract indcollation from the pg_index tuple */
datum = SysCacheGetAttr(INDEXRELID, ht_idx,
@@ -1620,7 +1620,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
if (!HeapTupleIsValid(ht_constr))
elog(ERROR, "cache lookup failed for constraint %u",
constraintId);
- conrec = (Form_pg_constraint) GETSTRUCT(ht_constr);
+ conrec = GETSTRUCT(pg_constraint, ht_constr);
index->isconstraint = true;
index->deferrable = conrec->condeferrable;
@@ -1658,7 +1658,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
if (!HeapTupleIsValid(opertup))
elog(ERROR, "cache lookup failed for operator %u",
operid);
- operform = (Form_pg_operator) GETSTRUCT(opertup);
+ operform = GETSTRUCT(pg_operator, opertup);
oprname = pstrdup(NameStr(operform->oprname));
/* For simplicity we always schema-qualify the op name */
nspname = get_namespace_name(operform->oprnamespace);
@@ -1889,7 +1889,7 @@ generateClonedExtStatsStmt(RangeVar *heapRel, Oid heapRelid,
ht_stats = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(source_statsid));
if (!HeapTupleIsValid(ht_stats))
elog(ERROR, "cache lookup failed for statistics object %u", source_statsid);
- statsrec = (Form_pg_statistic_ext) GETSTRUCT(ht_stats);
+ statsrec = GETSTRUCT(pg_statistic_ext, ht_stats);
/* Determine which statistics types exist */
datum = SysCacheGetAttr(STATEXTOID, ht_stats,
@@ -2001,7 +2001,7 @@ get_collation(Oid collation, Oid actual_datatype)
ht_coll = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation));
if (!HeapTupleIsValid(ht_coll))
elog(ERROR, "cache lookup failed for collation %u", collation);
- coll_rec = (Form_pg_collation) GETSTRUCT(ht_coll);
+ coll_rec = GETSTRUCT(pg_collation, ht_coll);
/* For simplicity, we always schema-qualify the name */
nsp_name = get_namespace_name(coll_rec->collnamespace);
@@ -2028,7 +2028,7 @@ get_opclass(Oid opclass, Oid actual_datatype)
ht_opc = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(ht_opc))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- opc_rec = (Form_pg_opclass) GETSTRUCT(ht_opc);
+ opc_rec = GETSTRUCT(pg_opclass, ht_opc);
if (GetDefaultOpClass(actual_datatype, opc_rec->opcmethod) != opclass)
{
@@ -3771,7 +3771,7 @@ transformColumnType(CreateStmtContext *cxt, ColumnDef *column)
if (column->collClause)
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(ctype);
+ Form_pg_type typtup = GETSTRUCT(pg_type, ctype);
LookupCollation(cxt->pstate,
column->collClause->collname,
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 70a9176c54..913dd0cea0 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -1911,7 +1911,7 @@ get_database_list(void)
while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
{
- Form_pg_database pgdatabase = (Form_pg_database) GETSTRUCT(tup);
+ Form_pg_database pgdatabase = GETSTRUCT(pg_database, tup);
avw_dbase *avdb;
MemoryContext oldcxt;
@@ -1998,7 +1998,7 @@ do_autovacuum(void)
tuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
- dbForm = (Form_pg_database) GETSTRUCT(tuple);
+ dbForm = GETSTRUCT(pg_database, tuple);
if (dbForm->datistemplate || !dbForm->datallowconn)
{
@@ -2056,7 +2056,7 @@ do_autovacuum(void)
*/
while ((tuple = heap_getnext(relScan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classForm = GETSTRUCT(pg_class, tuple);
PgStat_StatTabEntry *tabentry;
AutoVacOpts *relopts;
Oid relid;
@@ -2149,7 +2149,7 @@ do_autovacuum(void)
relScan = table_beginscan_catalog(classRel, 1, &key);
while ((tuple = heap_getnext(relScan, ForwardScanDirection)) != NULL)
{
- Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classForm = GETSTRUCT(pg_class, tuple);
PgStat_StatTabEntry *tabentry;
Oid relid;
AutoVacOpts *relopts = NULL;
@@ -2236,7 +2236,7 @@ do_autovacuum(void)
UnlockRelationOid(relid, AccessExclusiveLock);
continue;
}
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
/*
* Make all the same tests made in the loop above. In event of OID
@@ -2341,7 +2341,7 @@ do_autovacuum(void)
classTup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(classTup))
continue; /* somebody deleted the rel, forget it */
- isshared = ((Form_pg_class) GETSTRUCT(classTup))->relisshared;
+ isshared = (GETSTRUCT(pg_class, classTup))->relisshared;
ReleaseSysCache(classTup);
/*
@@ -2727,9 +2727,9 @@ extract_autovac_opts(HeapTuple tup, TupleDesc pg_class_desc)
bytea *relopts;
AutoVacOpts *av;
- Assert(((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_RELATION ||
- ((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_MATVIEW ||
- ((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_TOASTVALUE);
+ Assert((GETSTRUCT(pg_class, tup))->relkind == RELKIND_RELATION ||
+ (GETSTRUCT(pg_class, tup))->relkind == RELKIND_MATVIEW ||
+ (GETSTRUCT(pg_class, tup))->relkind == RELKIND_TOASTVALUE);
relopts = extractRelOptions(tup, pg_class_desc, NULL);
if (relopts == NULL)
@@ -2768,7 +2768,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(classTup))
return NULL;
- classForm = (Form_pg_class) GETSTRUCT(classTup);
+ classForm = GETSTRUCT(pg_class, classTup);
/*
* Get the applicable reloptions. If it is a TOAST table, try to get the
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index 3bbd522724..a7940000fd 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -114,7 +114,7 @@ get_subscription_list(void)
while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
{
- Form_pg_subscription subform = (Form_pg_subscription) GETSTRUCT(tup);
+ Form_pg_subscription subform = GETSTRUCT(pg_subscription, tup);
Subscription *sub;
MemoryContext oldcxt;
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index c72ad6b93d..fcd1dd5858 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -230,7 +230,7 @@ replorigin_by_name(const char *roname, bool missing_ok)
tuple = SearchSysCache1(REPLORIGNAME, roname_d);
if (HeapTupleIsValid(tuple))
{
- ident = (Form_pg_replication_origin) GETSTRUCT(tuple);
+ ident = GETSTRUCT(pg_replication_origin, tuple);
roident = ident->roident;
ReleaseSysCache(tuple);
}
@@ -472,7 +472,7 @@ replorigin_by_oid(RepOriginId roident, bool missing_ok, char **roname)
if (HeapTupleIsValid(tuple))
{
- ric = (Form_pg_replication_origin) GETSTRUCT(tuple);
+ ric = GETSTRUCT(pg_replication_origin, tuple);
*roname = text_to_cstring(&ric->roname);
ReleaseSysCache(tuple);
diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c
index ff8513e2d2..01f38d1b28 100644
--- a/src/backend/replication/logical/proto.c
+++ b/src/backend/replication/logical/proto.c
@@ -736,7 +736,7 @@ logicalrep_write_typ(StringInfo out, TransactionId xid, Oid typoid)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(basetypoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", basetypoid);
- typtup = (Form_pg_type) GETSTRUCT(tup);
+ typtup = GETSTRUCT(pg_type, tup);
/* use Oid as relation identifier */
pq_sendint32(out, typoid);
@@ -827,7 +827,7 @@ logicalrep_write_tuple(StringInfo out, Relation rel, TupleTableSlot *slot,
typtup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(att->atttypid));
if (!HeapTupleIsValid(typtup))
elog(ERROR, "cache lookup failed for type %u", att->atttypid);
- typclass = (Form_pg_type) GETSTRUCT(typtup);
+ typclass = GETSTRUCT(pg_type, typtup);
/*
* Send in binary if requested and type has suitable send function.
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 5f8c541763..a81407daba 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -3941,7 +3941,7 @@ clear_subscription_skip_lsn(XLogRecPtr finish_lsn)
if (!HeapTupleIsValid(tup))
elog(ERROR, "subscription \"%s\" does not exist", MySubscription->name);
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = GETSTRUCT(pg_subscription, tup);
/*
* Clear the subskiplsn. If the user has already changed subskiplsn before
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index a5a1fb887f..83f769ded0 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -126,7 +126,7 @@ InsertRule(const char *rulname,
ReleaseSysCache(oldtup);
- rewriteObjectId = ((Form_pg_rewrite) GETSTRUCT(tup))->oid;
+ rewriteObjectId = (GETSTRUCT(pg_rewrite, tup))->oid;
is_update = true;
}
else
@@ -625,7 +625,7 @@ DefineQueryRewrite(const char *rulename,
classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(event_relid));
if (!HeapTupleIsValid(classTup))
elog(ERROR, "cache lookup failed for relation %u", event_relid);
- classForm = (Form_pg_class) GETSTRUCT(classTup);
+ classForm = GETSTRUCT(pg_class, classTup);
classForm->relam = InvalidOid;
classForm->reltablespace = InvalidOid;
@@ -875,7 +875,7 @@ EnableDisableRule(Relation rel, const char *rulename,
errmsg("rule \"%s\" for relation \"%s\" does not exist",
rulename, get_rel_name(owningRel))));
- ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup);
+ ruleform = GETSTRUCT(pg_rewrite, ruletup);
/*
* Verify that the user has appropriate permissions.
@@ -926,7 +926,7 @@ RangeVarCallbackForRenameRule(const RangeVar *rv, Oid relid, Oid oldrelid,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return; /* concurrently dropped */
- form = (Form_pg_class) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_class, tuple);
/* only tables and views can have rules */
if (form->relkind != RELKIND_RELATION &&
@@ -989,7 +989,7 @@ RenameRewriteRule(RangeVar *relation, const char *oldName,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("rule \"%s\" for relation \"%s\" does not exist",
oldName, RelationGetRelationName(targetrel))));
- ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup);
+ ruleform = GETSTRUCT(pg_rewrite, ruletup);
ruleOid = ruleform->oid;
/* rule with the new name should not already exist */
diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c
index 2b51683f6d..ad845f4124 100644
--- a/src/backend/rewrite/rewriteRemove.c
+++ b/src/backend/rewrite/rewriteRemove.c
@@ -71,7 +71,7 @@ RemoveRewriteRuleById(Oid ruleOid)
* going on that might depend on this rule. (Note: a weaker lock would
* suffice if it's not an ON SELECT rule.)
*/
- eventRelationOid = ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class;
+ eventRelationOid = (GETSTRUCT(pg_rewrite, tuple))->ev_class;
event_relation = table_open(eventRelationOid, AccessExclusiveLock);
if (!allowSystemTableMods && IsSystemRelation(event_relation))
diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c
index 80e2509450..bb8c6c1fbd 100644
--- a/src/backend/rewrite/rewriteSupport.c
+++ b/src/backend/rewrite/rewriteSupport.c
@@ -64,7 +64,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules)
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationId);
- classForm = (Form_pg_class) GETSTRUCT(tuple);
+ classForm = GETSTRUCT(pg_class, tuple);
if (classForm->relhasrules != relHasRules)
{
@@ -109,7 +109,7 @@ get_rewrite_oid(Oid relid, const char *rulename, bool missing_ok)
errmsg("rule \"%s\" for relation \"%s\" does not exist",
rulename, get_rel_name(relid))));
}
- ruleform = (Form_pg_rewrite) GETSTRUCT(tuple);
+ ruleform = GETSTRUCT(pg_rewrite, tuple);
Assert(relid == ruleform->ev_class);
ruleoid = ruleform->oid;
ReleaseSysCache(tuple);
diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index d2aa8d0ca3..9d9bfa1912 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -453,7 +453,7 @@ fetch_statentries_for_relation(Relation pg_statext, Oid relid)
List *exprs = NIL;
entry = palloc0(sizeof(StatExtEntry));
- staForm = (Form_pg_statistic_ext) GETSTRUCT(htup);
+ staForm = GETSTRUCT(pg_statistic_ext, htup);
entry->statOid = staForm->oid;
entry->schema = get_namespace_name(staForm->stxnamespace);
entry->name = pstrdup(NameStr(staForm->stxname));
@@ -561,7 +561,7 @@ examine_attribute(Node *expr)
ObjectIdGetDatum(stats->attrtypid));
if (!HeapTupleIsValid(typtuple))
elog(ERROR, "cache lookup failed for type %u", stats->attrtypid);
- stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple);
+ stats->attrtype = GETSTRUCT(pg_type, typtuple);
/*
* We don't actually analyze individual attributes, so no need to set the
@@ -663,7 +663,7 @@ examine_expression(Node *expr, int stattarget)
if (!HeapTupleIsValid(typtuple))
elog(ERROR, "cache lookup failed for type %u", stats->attrtypid);
- stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple);
+ stats->attrtype = GETSTRUCT(pg_type, typtuple);
stats->anl_context = CurrentMemoryContext; /* XXX should be using
* something else? */
stats->tupattnum = InvalidAttrNumber;
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
index d204482a61..e63c78c20c 100644
--- a/src/backend/storage/large_object/inv_api.c
+++ b/src/backend/storage/large_object/inv_api.c
@@ -412,7 +412,7 @@ inv_getsize(LargeObjectDesc *obj_desc)
if (HeapTupleHasNulls(tuple)) /* paranoia */
elog(ERROR, "null field found in pg_largeobject");
- data = (Form_pg_largeobject) GETSTRUCT(tuple);
+ data = GETSTRUCT(pg_largeobject, tuple);
getdatafield(data, &datafield, &len, &pfreeit);
lastbyte = (uint64) data->pageno * LOBLKSIZE + len;
if (pfreeit)
@@ -534,7 +534,7 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
if (HeapTupleHasNulls(tuple)) /* paranoia */
elog(ERROR, "null field found in pg_largeobject");
- data = (Form_pg_largeobject) GETSTRUCT(tuple);
+ data = GETSTRUCT(pg_largeobject, tuple);
/*
* We expect the indexscan will deliver pages in order. However,
@@ -662,7 +662,7 @@ inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes)
{
if (HeapTupleHasNulls(oldtuple)) /* paranoia */
elog(ERROR, "null field found in pg_largeobject");
- olddata = (Form_pg_largeobject) GETSTRUCT(oldtuple);
+ olddata = GETSTRUCT(pg_largeobject, oldtuple);
Assert(olddata->pageno >= pageno);
}
neednextpage = false;
@@ -848,7 +848,7 @@ inv_truncate(LargeObjectDesc *obj_desc, int64 len)
{
if (HeapTupleHasNulls(oldtuple)) /* paranoia */
elog(ERROR, "null field found in pg_largeobject");
- olddata = (Form_pg_largeobject) GETSTRUCT(oldtuple);
+ olddata = GETSTRUCT(pg_largeobject, oldtuple);
Assert(olddata->pageno >= pageno);
}
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index d429aa4663..2311f1ad05 100644
--- a/src/backend/tcop/fastpath.c
+++ b/src/backend/tcop/fastpath.c
@@ -139,7 +139,7 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function with OID %u does not exist", func_id)));
- pp = (Form_pg_proc) GETSTRUCT(func_htp);
+ pp = GETSTRUCT(pg_proc, func_htp);
/* reject pg_proc entries that are unsafe to call via fastpath */
if (pp->prokind != PROKIND_FUNCTION || pp->proretset)
diff --git a/src/backend/tsearch/ts_selfuncs.c b/src/backend/tsearch/ts_selfuncs.c
index 8f2679f57e..69dcf0f327 100644
--- a/src/backend/tsearch/ts_selfuncs.c
+++ b/src/backend/tsearch/ts_selfuncs.c
@@ -165,7 +165,7 @@ tsquerysel(VariableStatData *vardata, Datum constval)
Form_pg_statistic stats;
AttStatsSlot sslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
/* MCELEM will be an array of TEXT elements for a tsvector column */
if (get_attstatsslot(&sslot, vardata->statsTuple,
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c
index 6fa58dd8eb..c8bc348377 100644
--- a/src/backend/utils/adt/acl.c
+++ b/src/backend/utils/adt/acl.c
@@ -603,7 +603,7 @@ aclitemout(PG_FUNCTION_ARGS)
htup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(aip->ai_grantee));
if (HeapTupleIsValid(htup))
{
- putid(p, NameStr(((Form_pg_authid) GETSTRUCT(htup))->rolname));
+ putid(p, NameStr((GETSTRUCT(pg_authid, htup))->rolname));
ReleaseSysCache(htup);
}
else
@@ -631,7 +631,7 @@ aclitemout(PG_FUNCTION_ARGS)
htup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(aip->ai_grantor));
if (HeapTupleIsValid(htup))
{
- putid(p, NameStr(((Form_pg_authid) GETSTRUCT(htup))->rolname));
+ putid(p, NameStr((GETSTRUCT(pg_authid, htup))->rolname));
ReleaseSysCache(htup);
}
else
@@ -2816,7 +2816,7 @@ convert_column_name(Oid tableoid, text *column)
{
Form_pg_attribute attributeForm;
- attributeForm = (Form_pg_attribute) GETSTRUCT(attTuple);
+ attributeForm = GETSTRUCT(pg_attribute, attTuple);
/* We want to return NULL for dropped columns */
if (attributeForm->attisdropped)
attnum = InvalidAttrNumber;
@@ -4780,7 +4780,7 @@ has_rolinherit(Oid roleid)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolinherit;
+ result = (GETSTRUCT(pg_authid, utup))->rolinherit;
ReleaseSysCache(utup);
}
return result;
@@ -4833,7 +4833,7 @@ roles_is_member_of(Oid roleid, enum RoleRecurseType type,
dbtup = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
if (!HeapTupleIsValid(dbtup))
elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
- dba = ((Form_pg_database) GETSTRUCT(dbtup))->datdba;
+ dba = (GETSTRUCT(pg_database, dbtup))->datdba;
ReleaseSysCache(dbtup);
}
@@ -4865,14 +4865,14 @@ roles_is_member_of(Oid roleid, enum RoleRecurseType type,
for (i = 0; i < memlist->n_members; i++)
{
HeapTuple tup = &memlist->members[i]->tuple;
- Oid otherid = ((Form_pg_auth_members) GETSTRUCT(tup))->roleid;
+ Oid otherid = (GETSTRUCT(pg_auth_members, tup))->roleid;
/*
* While otherid==InvalidOid shouldn't appear in the catalog, the
* OidIsValid() avoids crashing if that arises.
*/
if (otherid == admin_of &&
- ((Form_pg_auth_members) GETSTRUCT(tup))->admin_option &&
+ (GETSTRUCT(pg_auth_members, tup))->admin_option &&
OidIsValid(admin_of))
*is_admin = true;
@@ -5272,7 +5272,7 @@ get_rolespec_name(const RoleSpec *role)
char *rolename;
tp = get_rolespec_tuple(role);
- authForm = (Form_pg_authid) GETSTRUCT(tp);
+ authForm = GETSTRUCT(pg_authid, tp);
rolename = pstrdup(NameStr(authForm->rolname));
ReleaseSysCache(tp);
diff --git a/src/backend/utils/adt/amutils.c b/src/backend/utils/adt/amutils.c
index 9d78a90d69..f04ed870fe 100644
--- a/src/backend/utils/adt/amutils.c
+++ b/src/backend/utils/adt/amutils.c
@@ -174,7 +174,7 @@ indexam_property(FunctionCallInfo fcinfo,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(index_oid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- rd_rel = (Form_pg_class) GETSTRUCT(tuple);
+ rd_rel = GETSTRUCT(pg_class, tuple);
if (rd_rel->relkind != RELKIND_INDEX &&
rd_rel->relkind != RELKIND_PARTITIONED_INDEX)
{
@@ -229,7 +229,7 @@ indexam_property(FunctionCallInfo fcinfo,
tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
Assert(index_oid == rd_index->indexrelid);
Assert(attno > 0 && attno <= rd_index->indnatts);
diff --git a/src/backend/utils/adt/array_selfuncs.c b/src/backend/utils/adt/array_selfuncs.c
index 8cbee1406b..9bac8771c1 100644
--- a/src/backend/utils/adt/array_selfuncs.c
+++ b/src/backend/utils/adt/array_selfuncs.c
@@ -139,7 +139,7 @@ scalararraysel_containment(PlannerInfo *root,
AttStatsSlot sslot;
AttStatsSlot hslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
/* MCELEM will be an array of same type as element */
if (get_attstatsslot(&sslot, vardata.statsTuple,
@@ -362,7 +362,7 @@ calc_arraycontsel(VariableStatData *vardata, Datum constval,
AttStatsSlot sslot;
AttStatsSlot hslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
/* MCELEM will be an array of same type as column */
if (get_attstatsslot(&sslot, vardata->statsTuple,
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c
index 34efa121b4..403cbd0b13 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -857,7 +857,7 @@ pg_relation_filenode(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- relform = (Form_pg_class) GETSTRUCT(tuple);
+ relform = GETSTRUCT(pg_class, tuple);
if (RELKIND_HAS_STORAGE(relform->relkind))
{
@@ -931,7 +931,7 @@ pg_relation_filepath(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
PG_RETURN_NULL();
- relform = (Form_pg_class) GETSTRUCT(tuple);
+ relform = GETSTRUCT(pg_class, tuple);
if (RELKIND_HAS_STORAGE(relform->relkind))
{
diff --git a/src/backend/utils/adt/domains.c b/src/backend/utils/adt/domains.c
index 3de0cb01a2..3d17b1de79 100644
--- a/src/backend/utils/adt/domains.c
+++ b/src/backend/utils/adt/domains.c
@@ -365,7 +365,7 @@ errdatatype(Oid datatypeOid)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(datatypeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", datatypeOid);
- typtup = (Form_pg_type) GETSTRUCT(tup);
+ typtup = GETSTRUCT(pg_type, tup);
err_generic_string(PG_DIAG_SCHEMA_NAME,
get_namespace_name(typtup->typnamespace));
diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c
index 0cc7a6d8ad..bb24bd13fa 100644
--- a/src/backend/utils/adt/enum.c
+++ b/src/backend/utils/adt/enum.c
@@ -63,7 +63,7 @@ static void
check_safe_enum_use(HeapTuple enumval_tup)
{
TransactionId xmin;
- Form_pg_enum en = (Form_pg_enum) GETSTRUCT(enumval_tup);
+ Form_pg_enum en = GETSTRUCT(pg_enum, enumval_tup);
/*
* If the row is hinted as committed, it's surely safe. This provides a
@@ -138,7 +138,7 @@ enum_in(PG_FUNCTION_ARGS)
* This comes from pg_enum.oid and stores system oids in user tables. This
* oid must be preserved by binary upgrades.
*/
- enumoid = ((Form_pg_enum) GETSTRUCT(tup))->oid;
+ enumoid = (GETSTRUCT(pg_enum, tup))->oid;
ReleaseSysCache(tup);
@@ -159,7 +159,7 @@ enum_out(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid internal value for enum: %u",
enumval)));
- en = (Form_pg_enum) GETSTRUCT(tup);
+ en = GETSTRUCT(pg_enum, tup);
result = pstrdup(NameStr(en->enumlabel));
@@ -202,7 +202,7 @@ enum_recv(PG_FUNCTION_ARGS)
/* check it's safe to use in SQL */
check_safe_enum_use(tup);
- enumoid = ((Form_pg_enum) GETSTRUCT(tup))->oid;
+ enumoid = (GETSTRUCT(pg_enum, tup))->oid;
ReleaseSysCache(tup);
@@ -225,7 +225,7 @@ enum_send(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid internal value for enum: %u",
enumval)));
- en = (Form_pg_enum) GETSTRUCT(tup);
+ en = GETSTRUCT(pg_enum, tup);
pq_begintypsend(&buf);
pq_sendtext(&buf, NameStr(en->enumlabel), strlen(NameStr(en->enumlabel)));
@@ -284,7 +284,7 @@ enum_cmp_internal(Oid arg1, Oid arg2, FunctionCallInfo fcinfo)
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid internal value for enum: %u",
arg1)));
- en = (Form_pg_enum) GETSTRUCT(enum_tup);
+ en = GETSTRUCT(pg_enum, enum_tup);
typeoid = en->enumtypid;
ReleaseSysCache(enum_tup);
/* Now locate and remember the typcache entry */
@@ -412,7 +412,7 @@ enum_endpoint(Oid enumtypoid, ScanDirection direction)
{
/* check it's safe to use in SQL */
check_safe_enum_use(enum_tuple);
- minmax = ((Form_pg_enum) GETSTRUCT(enum_tuple))->oid;
+ minmax = (GETSTRUCT(pg_enum, enum_tuple))->oid;
}
else
{
@@ -572,7 +572,7 @@ enum_range_internal(Oid enumtypoid, Oid lower, Oid upper)
while (HeapTupleIsValid(enum_tuple = systable_getnext_ordered(enum_scan, ForwardScanDirection)))
{
- Oid enum_oid = ((Form_pg_enum) GETSTRUCT(enum_tuple))->oid;
+ Oid enum_oid = (GETSTRUCT(pg_enum, enum_tuple))->oid;
if (!left_found && lower == enum_oid)
left_found = true;
diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c
index 060fd7e183..e2e127ac2c 100644
--- a/src/backend/utils/adt/format_type.c
+++ b/src/backend/utils/adt/format_type.c
@@ -136,7 +136,7 @@ format_type_extended(Oid type_oid, int32 typemod, bits16 flags)
else
elog(ERROR, "cache lookup failed for type %u", type_oid);
}
- typeform = (Form_pg_type) GETSTRUCT(tuple);
+ typeform = GETSTRUCT(pg_type, tuple);
/*
* Check if it's a "true" array type. Pseudo-array types such as "name"
@@ -161,7 +161,7 @@ format_type_extended(Oid type_oid, int32 typemod, bits16 flags)
else
elog(ERROR, "cache lookup failed for type %u", type_oid);
}
- typeform = (Form_pg_type) GETSTRUCT(tuple);
+ typeform = GETSTRUCT(pg_type, tuple);
type_oid = array_base_type;
is_array = true;
}
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index 9819e1a45c..8e70d97c9b 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -2997,7 +2997,7 @@ prepare_column_cache(ColumnIOData *column,
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typid);
- type = (Form_pg_type) GETSTRUCT(tup);
+ type = GETSTRUCT(pg_type, tup);
if (type->typtype == TYPTYPE_DOMAIN)
{
diff --git a/src/backend/utils/adt/like_support.c b/src/backend/utils/adt/like_support.c
index 65a57fc3c4..3884c19aef 100644
--- a/src/backend/utils/adt/like_support.c
+++ b/src/backend/utils/adt/like_support.c
@@ -608,7 +608,7 @@ patternsel_common(PlannerInfo *root,
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
nullfrac = stats->stanullfrac;
}
diff --git a/src/backend/utils/adt/multirangetypes_selfuncs.c b/src/backend/utils/adt/multirangetypes_selfuncs.c
index 919c8889d4..8d2a0977e5 100644
--- a/src/backend/utils/adt/multirangetypes_selfuncs.c
+++ b/src/backend/utils/adt/multirangetypes_selfuncs.c
@@ -306,7 +306,7 @@ calc_multirangesel(TypeCacheEntry *typcache, VariableStatData *vardata,
Form_pg_statistic stats;
AttStatsSlot sslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
null_frac = stats->stanullfrac;
/* Try to get fraction of empty multiranges */
diff --git a/src/backend/utils/adt/network_selfuncs.c b/src/backend/utils/adt/network_selfuncs.c
index 49196376a8..33b45e4d99 100644
--- a/src/backend/utils/adt/network_selfuncs.c
+++ b/src/backend/utils/adt/network_selfuncs.c
@@ -127,7 +127,7 @@ networksel(PG_FUNCTION_ARGS)
PG_RETURN_FLOAT8(DEFAULT_SEL(operator));
}
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
nullfrac = stats->stanullfrac;
/*
@@ -283,7 +283,7 @@ networkjoinsel_inner(Oid operator,
if (HeapTupleIsValid(vardata1->statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(vardata1->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata1->statsTuple);
nullfrac1 = stats->stanullfrac;
mcv1_exists = get_attstatsslot(&mcv1_slot, vardata1->statsTuple,
@@ -305,7 +305,7 @@ networkjoinsel_inner(Oid operator,
if (HeapTupleIsValid(vardata2->statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(vardata2->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata2->statsTuple);
nullfrac2 = stats->stanullfrac;
mcv2_exists = get_attstatsslot(&mcv2_slot, vardata2->statsTuple,
@@ -413,7 +413,7 @@ networkjoinsel_semi(Oid operator,
if (HeapTupleIsValid(vardata1->statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(vardata1->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata1->statsTuple);
nullfrac1 = stats->stanullfrac;
mcv1_exists = get_attstatsslot(&mcv1_slot, vardata1->statsTuple,
@@ -435,7 +435,7 @@ networkjoinsel_semi(Oid operator,
if (HeapTupleIsValid(vardata2->statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(vardata2->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata2->statsTuple);
nullfrac2 = stats->stanullfrac;
mcv2_exists = get_attstatsslot(&mcv2_slot, vardata2->statsTuple,
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index 607a4b7340..ec15a5a81a 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -1243,7 +1243,7 @@ lookup_collation_cache(Oid collation, bool set_flags)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collation);
- collform = (Form_pg_collation) GETSTRUCT(tp);
+ collform = GETSTRUCT(pg_collation, tp);
if (collform->collprovider == COLLPROVIDER_LIBC)
{
@@ -1495,7 +1495,7 @@ pg_newlocale_from_collation(Oid collid)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collid);
- collform = (Form_pg_collation) GETSTRUCT(tp);
+ collform = GETSTRUCT(pg_collation, tp);
/* We'll fill in the result struct locally before allocating memory */
memset(&result, 0, sizeof(result));
diff --git a/src/backend/utils/adt/rangetypes_selfuncs.c b/src/backend/utils/adt/rangetypes_selfuncs.c
index c2795f4593..70bdbbdf6c 100644
--- a/src/backend/utils/adt/rangetypes_selfuncs.c
+++ b/src/backend/utils/adt/rangetypes_selfuncs.c
@@ -244,7 +244,7 @@ calc_rangesel(TypeCacheEntry *typcache, VariableStatData *vardata,
Form_pg_statistic stats;
AttStatsSlot sslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
null_frac = stats->stanullfrac;
/* Try to get fraction of empty ranges */
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index 6d4c1c27a5..052374dd23 100644
--- a/src/backend/utils/adt/regproc.c
+++ b/src/backend/utils/adt/regproc.c
@@ -155,7 +155,7 @@ regprocout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(proctup))
{
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, proctup);
char *proname = NameStr(procform->proname);
/*
@@ -356,7 +356,7 @@ format_procedure_extended(Oid procedure_oid, bits16 flags)
if (HeapTupleIsValid(proctup))
{
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, proctup);
char *proname = NameStr(procform->proname);
int nargs = procform->pronargs;
int i;
@@ -436,7 +436,7 @@ format_procedure_parts(Oid procedure_oid, List **objnames, List **objargs,
return;
}
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
nargs = procform->pronargs;
*objnames = list_make2(get_namespace_name_or_temp(procform->pronamespace),
@@ -593,7 +593,7 @@ regoperout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(opertup))
{
- Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operform = GETSTRUCT(pg_operator, opertup);
char *oprname = NameStr(operform->oprname);
/*
@@ -787,7 +787,7 @@ format_operator_extended(Oid operator_oid, bits16 flags)
if (HeapTupleIsValid(opertup))
{
- Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
+ Form_pg_operator operform = GETSTRUCT(pg_operator, opertup);
char *oprname = NameStr(operform->oprname);
char *nspname;
StringInfoData buf;
@@ -877,7 +877,7 @@ format_operator_parts(Oid operator_oid, List **objnames, List **objargs,
return;
}
- oprForm = (Form_pg_operator) GETSTRUCT(opertup);
+ oprForm = GETSTRUCT(pg_operator, opertup);
*objnames = list_make2(get_namespace_name_or_temp(oprForm->oprnamespace),
pstrdup(NameStr(oprForm->oprname)));
*objargs = NIL;
@@ -1023,7 +1023,7 @@ regclassout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(classtup))
{
- Form_pg_class classform = (Form_pg_class) GETSTRUCT(classtup);
+ Form_pg_class classform = GETSTRUCT(pg_class, classtup);
char *classname = NameStr(classform->relname);
/*
@@ -1174,7 +1174,7 @@ regcollationout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(collationtup))
{
- Form_pg_collation collationform = (Form_pg_collation) GETSTRUCT(collationtup);
+ Form_pg_collation collationform = GETSTRUCT(pg_collation, collationtup);
char *collationname = NameStr(collationform->collname);
/*
@@ -1326,7 +1326,7 @@ regtypeout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(typetup))
{
- Form_pg_type typeform = (Form_pg_type) GETSTRUCT(typetup);
+ Form_pg_type typeform = GETSTRUCT(pg_type, typetup);
/*
* In bootstrap mode, skip the fancy namespace stuff and just return
@@ -1439,7 +1439,7 @@ regconfigout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(cfgtup))
{
- Form_pg_ts_config cfgform = (Form_pg_ts_config) GETSTRUCT(cfgtup);
+ Form_pg_ts_config cfgform = GETSTRUCT(pg_ts_config, cfgtup);
char *cfgname = NameStr(cfgform->cfgname);
char *nspname;
@@ -1550,7 +1550,7 @@ regdictionaryout(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(dicttup))
{
- Form_pg_ts_dict dictform = (Form_pg_ts_dict) GETSTRUCT(dicttup);
+ Form_pg_ts_dict dictform = GETSTRUCT(pg_ts_dict, dicttup);
char *dictname = NameStr(dictform->dictname);
char *nspname;
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index 51b3fdc9a0..33e9cfa567 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -1945,7 +1945,7 @@ ri_GenerateQualCollation(StringInfo buf, Oid collation)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collation);
- colltup = (Form_pg_collation) GETSTRUCT(tp);
+ colltup = GETSTRUCT(pg_collation, tp);
collname = NameStr(colltup->collname);
/*
@@ -2134,7 +2134,7 @@ ri_LoadConstraintInfo(Oid constraintOid)
tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constraintOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for constraint %u", constraintOid);
- conForm = (Form_pg_constraint) GETSTRUCT(tup);
+ conForm = GETSTRUCT(pg_constraint, tup);
if (conForm->contype != CONSTRAINT_FOREIGN) /* should not happen */
elog(ERROR, "constraint %u is not a foreign key constraint",
@@ -2197,7 +2197,7 @@ get_ri_constraint_root(Oid constrOid)
tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constrOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", constrOid);
- constrParentOid = ((Form_pg_constraint) GETSTRUCT(tuple))->conparentid;
+ constrParentOid = (GETSTRUCT(pg_constraint, tuple))->conparentid;
ReleaseSysCache(tuple);
if (!OidIsValid(constrParentOid))
break; /* we reached the root constraint */
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index d575aa0066..543fb4a524 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -899,7 +899,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
return NULL;
}
- trigrec = (Form_pg_trigger) GETSTRUCT(ht_trig);
+ trigrec = GETSTRUCT(pg_trigger, ht_trig);
/*
* Start the trigger definition. Note that the trigger's name should never
@@ -1254,7 +1254,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
return NULL;
elog(ERROR, "cache lookup failed for index %u", indexrelid);
}
- idxrec = (Form_pg_index) GETSTRUCT(ht_idx);
+ idxrec = GETSTRUCT(pg_index, ht_idx);
indrelid = idxrec->indrelid;
Assert(indexrelid == idxrec->indexrelid);
@@ -1281,7 +1281,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(indexrelid));
if (!HeapTupleIsValid(ht_idxrel))
elog(ERROR, "cache lookup failed for relation %u", indexrelid);
- idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);
+ idxrelrec = GETSTRUCT(pg_class, ht_idxrel);
/*
* Fetch the pg_am tuple of the index' access method
@@ -1290,7 +1290,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
if (!HeapTupleIsValid(ht_am))
elog(ERROR, "cache lookup failed for access method %u",
idxrelrec->relam);
- amrec = (Form_pg_am) GETSTRUCT(ht_am);
+ amrec = GETSTRUCT(pg_am, ht_am);
/* Fetch the index AM's API struct */
amroutine = GetIndexAmRoutine(amrec->amhandler);
@@ -1638,7 +1638,7 @@ pg_get_statisticsobj_worker(Oid statextid, bool columns_only, bool missing_ok)
/* has the statistics expressions? */
has_exprs = !heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL);
- statextrec = (Form_pg_statistic_ext) GETSTRUCT(statexttup);
+ statextrec = GETSTRUCT(pg_statistic_ext, statexttup);
/*
* Get the statistics expressions, if any. (NOTE: we do not use the
@@ -1822,7 +1822,7 @@ pg_get_statisticsobjdef_expressions(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
- statextrec = (Form_pg_statistic_ext) GETSTRUCT(statexttup);
+ statextrec = GETSTRUCT(pg_statistic_ext, statexttup);
/*
* Get the statistics expressions, and deparse them into text values.
@@ -1920,7 +1920,7 @@ pg_get_partkeydef_worker(Oid relid, int prettyFlags,
elog(ERROR, "cache lookup failed for partition key of %u", relid);
}
- form = (Form_pg_partitioned_table) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_partitioned_table, tuple);
Assert(form->partrelid == relid);
@@ -2198,7 +2198,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
elog(ERROR, "could not find tuple for constraint %u", constraintId);
}
- conForm = (Form_pg_constraint) GETSTRUCT(tup);
+ conForm = GETSTRUCT(pg_constraint, tup);
initStringInfo(&buf);
@@ -2372,7 +2372,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
if (!HeapTupleIsValid(indtup))
elog(ERROR, "cache lookup failed for index %u", indexId);
if (conForm->contype == CONSTRAINT_UNIQUE &&
- ((Form_pg_index) GETSTRUCT(indtup))->indnullsnotdistinct)
+ (GETSTRUCT(pg_index, indtup))->indnullsnotdistinct)
appendStringInfoString(&buf, "NULLS NOT DISTINCT ");
appendStringInfoString(&buf, "(");
@@ -2770,7 +2770,7 @@ pg_get_userbyid(PG_FUNCTION_ARGS)
roletup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(roletup))
{
- role_rec = (Form_pg_authid) GETSTRUCT(roletup);
+ role_rec = GETSTRUCT(pg_authid, roletup);
*result = role_rec->rolname;
ReleaseSysCache(roletup);
}
@@ -2838,7 +2838,7 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
+ Form_pg_depend deprec = GETSTRUCT(pg_depend, tup);
/*
* Look for an auto dependency (serial column) or internal dependency
@@ -2906,7 +2906,7 @@ pg_get_functiondef(PG_FUNCTION_ARGS)
if (!HeapTupleIsValid(proctup))
PG_RETURN_NULL();
- proc = (Form_pg_proc) GETSTRUCT(proctup);
+ proc = GETSTRUCT(pg_proc, proctup);
name = NameStr(proc->proname);
if (proc->prokind == PROKIND_AGGREGATE)
@@ -3198,7 +3198,7 @@ pg_get_function_result(PG_FUNCTION_ARGS)
if (!HeapTupleIsValid(proctup))
PG_RETURN_NULL();
- if (((Form_pg_proc) GETSTRUCT(proctup))->prokind == PROKIND_PROCEDURE)
+ if ((GETSTRUCT(pg_proc, proctup))->prokind == PROKIND_PROCEDURE)
{
ReleaseSysCache(proctup);
PG_RETURN_NULL();
@@ -3220,7 +3220,7 @@ pg_get_function_result(PG_FUNCTION_ARGS)
static void
print_function_rettype(StringInfo buf, HeapTuple proctup)
{
- Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc proc = GETSTRUCT(pg_proc, proctup);
int ntabargs = 0;
StringInfoData rbuf;
@@ -3259,7 +3259,7 @@ static int
print_function_arguments(StringInfo buf, HeapTuple proctup,
bool print_table_args, bool print_defaults)
{
- Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(proctup);
+ Form_pg_proc proc = GETSTRUCT(pg_proc, proctup);
int numargs;
Oid *argtypes;
char **argnames;
@@ -3307,7 +3307,7 @@ print_function_arguments(StringInfo buf, HeapTuple proctup,
if (!HeapTupleIsValid(aggtup))
elog(ERROR, "cache lookup failed for aggregate %u",
proc->oid);
- agg = (Form_pg_aggregate) GETSTRUCT(aggtup);
+ agg = GETSTRUCT(pg_aggregate, aggtup);
if (AGGKIND_IS_ORDERED_SET(agg->aggkind))
insertorderbyat = agg->aggnumdirectargs;
ReleaseSysCache(aggtup);
@@ -3492,7 +3492,7 @@ pg_get_function_arg_default(PG_FUNCTION_ARGS)
argdefaults = castNode(List, stringToNode(str));
pfree(str);
- proc = (Form_pg_proc) GETSTRUCT(proctup);
+ proc = GETSTRUCT(pg_proc, proctup);
/*
* Calculate index into proargdefaults: proargdefaults corresponds to the
@@ -3525,7 +3525,7 @@ print_function_sqlbody(StringInfo buf, HeapTuple proctup)
bool isnull;
Node *n;
- dpns.funcname = pstrdup(NameStr(((Form_pg_proc) GETSTRUCT(proctup))->proname));
+ dpns.funcname = pstrdup(NameStr((GETSTRUCT(pg_proc, proctup))->proname));
numargs = get_func_arg_info(proctup,
&argtypes, &argnames, &argmodes);
dpns.numargs = numargs;
@@ -12065,7 +12065,7 @@ get_opclass_name(Oid opclass, Oid actual_datatype,
ht_opc = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(ht_opc))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- opcrec = (Form_pg_opclass) GETSTRUCT(ht_opc);
+ opcrec = GETSTRUCT(pg_opclass, ht_opc);
if (!OidIsValid(actual_datatype) ||
GetDefaultOpClass(actual_datatype, opcrec->opcmethod) != opclass)
@@ -12359,7 +12359,7 @@ generate_relation_name(Oid relid, List *namespaces)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltup = (Form_pg_class) GETSTRUCT(tp);
+ reltup = GETSTRUCT(pg_class, tp);
relname = NameStr(reltup->relname);
/* Check for conflicting CTE name */
@@ -12417,7 +12417,7 @@ generate_qualified_relation_name(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltup = (Form_pg_class) GETSTRUCT(tp);
+ reltup = GETSTRUCT(pg_class, tp);
relname = NameStr(reltup->relname);
nspname = get_namespace_name_or_temp(reltup->relnamespace);
@@ -12470,7 +12470,7 @@ generate_function_name(Oid funcid, int nargs, List *argnames, Oid *argtypes,
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
+ procform = GETSTRUCT(pg_proc, proctup);
proname = NameStr(procform->proname);
/*
@@ -12567,7 +12567,7 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2)
opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operid));
if (!HeapTupleIsValid(opertup))
elog(ERROR, "cache lookup failed for operator %u", operid);
- operform = (Form_pg_operator) GETSTRUCT(opertup);
+ operform = GETSTRUCT(pg_operator, opertup);
oprname = NameStr(operform->oprname);
/*
@@ -12643,7 +12643,7 @@ generate_operator_clause(StringInfo buf,
opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(opoid));
if (!HeapTupleIsValid(opertup))
elog(ERROR, "cache lookup failed for operator %u", opoid);
- operform = (Form_pg_operator) GETSTRUCT(opertup);
+ operform = GETSTRUCT(pg_operator, opertup);
Assert(operform->oprkind == 'b');
oprname = NameStr(operform->oprname);
@@ -12680,7 +12680,7 @@ add_cast_to(StringInfo buf, Oid typid)
typetup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(typetup))
elog(ERROR, "cache lookup failed for type %u", typid);
- typform = (Form_pg_type) GETSTRUCT(typetup);
+ typform = GETSTRUCT(pg_type, typetup);
typname = NameStr(typform->typname);
nspname = get_namespace_name_or_temp(typform->typnamespace);
@@ -12712,7 +12712,7 @@ generate_qualified_type_name(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", typid);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
typname = NameStr(typtup->typname);
nspname = get_namespace_name_or_temp(typtup->typnamespace);
@@ -12745,7 +12745,7 @@ generate_collation_name(Oid collid)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collid);
- colltup = (Form_pg_collation) GETSTRUCT(tp);
+ colltup = GETSTRUCT(pg_collation, tp);
collname = NameStr(colltup->collname);
if (!CollationIsVisible(collid))
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index d35e5605de..d977e3ad72 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -313,7 +313,7 @@ var_eq_const(VariableStatData *vardata, Oid operator, Oid collation,
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
nullfrac = stats->stanullfrac;
}
@@ -475,7 +475,7 @@ var_eq_non_const(VariableStatData *vardata, Oid operator, Oid collation,
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
nullfrac = stats->stanullfrac;
}
@@ -665,7 +665,7 @@ scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, bool iseq,
/* no stats available, so default result */
return DEFAULT_INEQ_SEL;
}
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
fmgr_info(get_opcode(operator), &opproc);
@@ -990,7 +990,7 @@ generic_restriction_selectivity(PlannerInfo *root, Oid oproid, Oid collation,
/* Don't forget to account for nulls. */
if (HeapTupleIsValid(vardata.statsTuple))
- nullfrac = ((Form_pg_statistic) GETSTRUCT(vardata.statsTuple))->stanullfrac;
+ nullfrac = (GETSTRUCT(pg_statistic, vardata.statsTuple))->stanullfrac;
else
nullfrac = 0.0;
@@ -1548,7 +1548,7 @@ booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg,
double freq_null;
AttStatsSlot sslot;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
freq_null = stats->stanullfrac;
if (get_attstatsslot(&sslot, vardata.statsTuple,
@@ -1705,7 +1705,7 @@ nulltestsel(PlannerInfo *root, NullTestType nulltesttype, Node *arg,
Form_pg_statistic stats;
double freq_null;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
freq_null = stats->stanullfrac;
switch (nulltesttype)
@@ -2277,7 +2277,7 @@ eqjoinsel(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(vardata1.statsTuple))
{
/* note we allow use of nullfrac regardless of security check */
- stats1 = (Form_pg_statistic) GETSTRUCT(vardata1.statsTuple);
+ stats1 = GETSTRUCT(pg_statistic, vardata1.statsTuple);
if (statistic_proc_security_check(&vardata1, opfuncoid))
have_mcvs1 = get_attstatsslot(&sslot1, vardata1.statsTuple,
STATISTIC_KIND_MCV, InvalidOid,
@@ -2287,7 +2287,7 @@ eqjoinsel(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(vardata2.statsTuple))
{
/* note we allow use of nullfrac regardless of security check */
- stats2 = (Form_pg_statistic) GETSTRUCT(vardata2.statsTuple);
+ stats2 = GETSTRUCT(pg_statistic, vardata2.statsTuple);
if (statistic_proc_security_check(&vardata2, opfuncoid))
have_mcvs2 = get_attstatsslot(&sslot2, vardata2.statsTuple,
STATISTIC_KIND_MCV, InvalidOid,
@@ -2804,7 +2804,7 @@ neqjoinsel(PG_FUNCTION_ARGS)
get_join_variables(root, args, sjinfo, &leftvar, &rightvar, &reversed);
statsTuple = reversed ? rightvar.statsTuple : leftvar.statsTuple;
if (HeapTupleIsValid(statsTuple))
- nullfrac = ((Form_pg_statistic) GETSTRUCT(statsTuple))->stanullfrac;
+ nullfrac = (GETSTRUCT(pg_statistic, statsTuple))->stanullfrac;
else
nullfrac = 0.0;
ReleaseVariableStats(leftvar);
@@ -3162,7 +3162,7 @@ mergejoinscansel(PlannerInfo *root, Node *clause,
if (HeapTupleIsValid(leftvar.statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(leftvar.statsTuple);
+ stats = GETSTRUCT(pg_statistic, leftvar.statsTuple);
*leftstart += stats->stanullfrac;
CLAMP_PROBABILITY(*leftstart);
*leftend += stats->stanullfrac;
@@ -3170,7 +3170,7 @@ mergejoinscansel(PlannerInfo *root, Node *clause,
}
if (HeapTupleIsValid(rightvar.statsTuple))
{
- stats = (Form_pg_statistic) GETSTRUCT(rightvar.statsTuple);
+ stats = GETSTRUCT(pg_statistic, rightvar.statsTuple);
*rightstart += stats->stanullfrac;
CLAMP_PROBABILITY(*rightstart);
*rightend += stats->stanullfrac;
@@ -3830,7 +3830,7 @@ estimate_hash_bucket_stats(PlannerInfo *root, Node *hashkey, double nbuckets,
{
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata.statsTuple);
stanullfrac = stats->stanullfrac;
}
else
@@ -5674,7 +5674,7 @@ get_variable_numdistinct(VariableStatData *vardata, bool *isdefault)
/* Use the pg_statistic entry */
Form_pg_statistic stats;
- stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
+ stats = GETSTRUCT(pg_statistic, vardata->statsTuple);
stadistinct = stats->stadistinct;
stanullfrac = stats->stanullfrac;
}
@@ -5891,7 +5891,7 @@ get_variable_range(PlannerInfo *root, VariableStatData *vardata,
for (i = 0; i < sslot.nnumbers; i++)
sumcommon += sslot.numbers[i];
- nullfrac = ((Form_pg_statistic) GETSTRUCT(vardata->statsTuple))->stanullfrac;
+ nullfrac = (GETSTRUCT(pg_statistic, vardata->statsTuple))->stanullfrac;
if (sumcommon + nullfrac > 0.99999)
use_mcvs = true;
}
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index 60a85c4697..0ce9012784 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -3183,7 +3183,7 @@ map_sql_table_to_xmlschema(TupleDesc tupdesc, Oid relid, bool nulls,
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltuple = (Form_pg_class) GETSTRUCT(tuple);
+ reltuple = GETSTRUCT(pg_class, tuple);
xmltn = map_sql_identifier_to_xml_name(NameStr(reltuple->relname),
true, false);
@@ -3483,7 +3483,7 @@ map_sql_type_to_xml_name(Oid typeoid, int typmod)
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", typeoid);
- typtuple = (Form_pg_type) GETSTRUCT(tuple);
+ typtuple = GETSTRUCT(pg_type, tuple);
appendStringInfoString(&result,
map_multipart_sql_identifier_to_xml_name((typtuple->typtype == TYPTYPE_DOMAIN) ? "Domain" : "UDT",
diff --git a/src/backend/utils/cache/evtcache.c b/src/backend/utils/cache/evtcache.c
index f7f7165f7f..a6893f9947 100644
--- a/src/backend/utils/cache/evtcache.c
+++ b/src/backend/utils/cache/evtcache.c
@@ -153,7 +153,7 @@ BuildEventTriggerCache(void)
break;
/* Skip trigger if disabled. */
- form = (Form_pg_event_trigger) GETSTRUCT(tup);
+ form = GETSTRUCT(pg_event_trigger, tup);
if (form->evtenabled == TRIGGER_DISABLED)
continue;
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index eb5782f82a..8e100862bf 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -1259,7 +1259,7 @@ CacheInvalidateHeapTuple(Relation relation,
*/
if (tupleRelId == RelationRelationId)
{
- Form_pg_class classtup = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class classtup = GETSTRUCT(pg_class, tuple);
relationId = classtup->oid;
if (classtup->relisshared)
@@ -1269,7 +1269,7 @@ CacheInvalidateHeapTuple(Relation relation,
}
else if (tupleRelId == AttributeRelationId)
{
- Form_pg_attribute atttup = (Form_pg_attribute) GETSTRUCT(tuple);
+ Form_pg_attribute atttup = GETSTRUCT(pg_attribute, tuple);
relationId = atttup->attrelid;
@@ -1287,7 +1287,7 @@ CacheInvalidateHeapTuple(Relation relation,
}
else if (tupleRelId == IndexRelationId)
{
- Form_pg_index indextup = (Form_pg_index) GETSTRUCT(tuple);
+ Form_pg_index indextup = GETSTRUCT(pg_index, tuple);
/*
* When a pg_index row is updated, we should send out a relcache inval
@@ -1300,7 +1300,7 @@ CacheInvalidateHeapTuple(Relation relation,
}
else if (tupleRelId == ConstraintRelationId)
{
- Form_pg_constraint constrtup = (Form_pg_constraint) GETSTRUCT(tuple);
+ Form_pg_constraint constrtup = GETSTRUCT(pg_constraint, tuple);
/*
* Foreign keys are part of relcache entries, too, so send out an
@@ -1398,7 +1398,7 @@ CacheInvalidateRelcacheAll(void)
void
CacheInvalidateRelcacheByTuple(HeapTuple classTuple)
{
- Form_pg_class classtup = (Form_pg_class) GETSTRUCT(classTuple);
+ Form_pg_class classtup = GETSTRUCT(pg_class, classTuple);
Oid databaseId;
Oid relationId;
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 1b7e11b93e..e189e5e564 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -90,7 +90,7 @@ get_op_opfamily_strategy(Oid opno, Oid opfamily)
ObjectIdGetDatum(opfamily));
if (!HeapTupleIsValid(tp))
return 0;
- amop_tup = (Form_pg_amop) GETSTRUCT(tp);
+ amop_tup = GETSTRUCT(pg_amop, tp);
result = amop_tup->amopstrategy;
ReleaseSysCache(tp);
return result;
@@ -115,7 +115,7 @@ get_op_opfamily_sortfamily(Oid opno, Oid opfamily)
ObjectIdGetDatum(opfamily));
if (!HeapTupleIsValid(tp))
return InvalidOid;
- amop_tup = (Form_pg_amop) GETSTRUCT(tp);
+ amop_tup = GETSTRUCT(pg_amop, tp);
result = amop_tup->amopsortfamily;
ReleaseSysCache(tp);
return result;
@@ -146,7 +146,7 @@ get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op,
if (!HeapTupleIsValid(tp))
elog(ERROR, "operator %u is not a member of opfamily %u",
opno, opfamily);
- amop_tup = (Form_pg_amop) GETSTRUCT(tp);
+ amop_tup = GETSTRUCT(pg_amop, tp);
*strategy = amop_tup->amopstrategy;
*lefttype = amop_tup->amoplefttype;
*righttype = amop_tup->amoprighttype;
@@ -175,7 +175,7 @@ get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
Int16GetDatum(strategy));
if (!HeapTupleIsValid(tp))
return InvalidOid;
- amop_tup = (Form_pg_amop) GETSTRUCT(tp);
+ amop_tup = GETSTRUCT(pg_amop, tp);
result = amop_tup->amopopr;
ReleaseSysCache(tp);
return result;
@@ -223,7 +223,7 @@ get_ordering_op_properties(Oid opno,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
/* must be btree */
if (aform->amopmethod != BTREE_AM_OID)
@@ -315,7 +315,7 @@ get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
/* must be btree */
if (aform->amopmethod != BTREE_AM_OID)
@@ -376,7 +376,7 @@ get_mergejoin_opfamilies(Oid opno)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
/* must be btree equality */
if (aform->amopmethod == BTREE_AM_OID &&
@@ -428,7 +428,7 @@ get_compatible_hash_operators(Oid opno,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
if (aform->amopmethod == HASH_AM_OID &&
aform->amopstrategy == HTEqualStrategyNumber)
@@ -528,7 +528,7 @@ get_op_hash_functions(Oid opno,
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple tuple = &catlist->members[i]->tuple;
- Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
+ Form_pg_amop aform = GETSTRUCT(pg_amop, tuple);
if (aform->amopmethod == HASH_AM_OID &&
aform->amopstrategy == HTEqualStrategyNumber)
@@ -611,7 +611,7 @@ get_op_btree_interpretation(Oid opno)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
- Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple);
StrategyNumber op_strategy;
/* must be btree */
@@ -649,7 +649,7 @@ get_op_btree_interpretation(Oid opno)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
- Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple);
StrategyNumber op_strategy;
/* must be btree */
@@ -712,7 +712,7 @@ equality_ops_are_compatible(Oid opno1, Oid opno2)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
- Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple);
/* must be btree or hash */
if (op_form->amopmethod == BTREE_AM_OID ||
@@ -763,7 +763,7 @@ comparison_ops_are_compatible(Oid opno1, Oid opno2)
for (i = 0; i < catlist->n_members; i++)
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
- Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple);
if (op_form->amopmethod == BTREE_AM_OID)
{
@@ -804,7 +804,7 @@ get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
Int16GetDatum(procnum));
if (!HeapTupleIsValid(tp))
return InvalidOid;
- amproc_tup = (Form_pg_amproc) GETSTRUCT(tp);
+ amproc_tup = GETSTRUCT(pg_amproc, tp);
result = amproc_tup->amproc;
ReleaseSysCache(tp);
return result;
@@ -830,7 +830,7 @@ get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
ObjectIdGetDatum(relid), Int16GetDatum(attnum));
if (HeapTupleIsValid(tp))
{
- Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ Form_pg_attribute att_tup = GETSTRUCT(pg_attribute, tp);
char *result;
result = pstrdup(NameStr(att_tup->attname));
@@ -860,7 +860,7 @@ get_attnum(Oid relid, const char *attname)
tp = SearchSysCacheAttName(relid, attname);
if (HeapTupleIsValid(tp))
{
- Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ Form_pg_attribute att_tup = GETSTRUCT(pg_attribute, tp);
AttrNumber result;
result = att_tup->attnum;
@@ -892,7 +892,7 @@ get_attstattarget(Oid relid, AttrNumber attnum)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ att_tup = GETSTRUCT(pg_attribute, tp);
result = att_tup->attstattarget;
ReleaseSysCache(tp);
return result;
@@ -922,7 +922,7 @@ get_attgenerated(Oid relid, AttrNumber attnum)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ att_tup = GETSTRUCT(pg_attribute, tp);
result = att_tup->attgenerated;
ReleaseSysCache(tp);
return result;
@@ -944,7 +944,7 @@ get_atttype(Oid relid, AttrNumber attnum)
Int16GetDatum(attnum));
if (HeapTupleIsValid(tp))
{
- Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ Form_pg_attribute att_tup = GETSTRUCT(pg_attribute, tp);
Oid result;
result = att_tup->atttypid;
@@ -977,7 +977,7 @@ get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
- att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+ att_tup = GETSTRUCT(pg_attribute, tp);
*typid = att_tup->atttypid;
*typmod = att_tup->atttypmod;
@@ -1064,7 +1064,7 @@ get_collation_name(Oid colloid)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
if (HeapTupleIsValid(tp))
{
- Form_pg_collation colltup = (Form_pg_collation) GETSTRUCT(tp);
+ Form_pg_collation colltup = GETSTRUCT(pg_collation, tp);
char *result;
result = pstrdup(NameStr(colltup->collname));
@@ -1085,7 +1085,7 @@ get_collation_isdeterministic(Oid colloid)
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", colloid);
- colltup = (Form_pg_collation) GETSTRUCT(tp);
+ colltup = GETSTRUCT(pg_collation, tp);
result = colltup->collisdeterministic;
ReleaseSysCache(tp);
return result;
@@ -1110,7 +1110,7 @@ get_constraint_name(Oid conoid)
tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
if (HeapTupleIsValid(tp))
{
- Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp);
+ Form_pg_constraint contup = GETSTRUCT(pg_constraint, tp);
char *result;
result = pstrdup(NameStr(contup->conname));
@@ -1142,7 +1142,7 @@ get_constraint_index(Oid conoid)
tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
if (HeapTupleIsValid(tp))
{
- Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp);
+ Form_pg_constraint contup = GETSTRUCT(pg_constraint, tp);
Oid result;
if (contup->contype == CONSTRAINT_UNIQUE ||
@@ -1168,7 +1168,7 @@ get_language_name(Oid langoid, bool missing_ok)
tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
if (HeapTupleIsValid(tp))
{
- Form_pg_language lantup = (Form_pg_language) GETSTRUCT(tp);
+ Form_pg_language lantup = GETSTRUCT(pg_language, tp);
char *result;
result = pstrdup(NameStr(lantup->lanname));
@@ -1199,7 +1199,7 @@ get_opclass_family(Oid opclass)
tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
+ cla_tup = GETSTRUCT(pg_opclass, tp);
result = cla_tup->opcfamily;
ReleaseSysCache(tp);
@@ -1221,7 +1221,7 @@ get_opclass_input_type(Oid opclass)
tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for opclass %u", opclass);
- cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
+ cla_tup = GETSTRUCT(pg_opclass, tp);
result = cla_tup->opcintype;
ReleaseSysCache(tp);
@@ -1244,7 +1244,7 @@ get_opclass_opfamily_and_input_type(Oid opclass, Oid *opfamily, Oid *opcintype)
if (!HeapTupleIsValid(tp))
return false;
- cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
+ cla_tup = GETSTRUCT(pg_opclass, tp);
*opfamily = cla_tup->opcfamily;
*opcintype = cla_tup->opcintype;
@@ -1270,7 +1270,7 @@ get_opcode(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
RegProcedure result;
result = optup->oprcode;
@@ -1295,7 +1295,7 @@ get_opname(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
char *result;
result = pstrdup(NameStr(optup->oprname));
@@ -1318,7 +1318,7 @@ get_op_rettype(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
Oid result;
result = optup->oprresult;
@@ -1344,7 +1344,7 @@ op_input_types(Oid opno, Oid *lefttype, Oid *righttype)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for operator %u", opno);
- optup = (Form_pg_operator) GETSTRUCT(tp);
+ optup = GETSTRUCT(pg_operator, tp);
*lefttype = optup->oprleft;
*righttype = optup->oprright;
ReleaseSysCache(tp);
@@ -1394,7 +1394,7 @@ op_mergejoinable(Oid opno, Oid inputtype)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
result = optup->oprcanmerge;
ReleaseSysCache(tp);
@@ -1440,7 +1440,7 @@ op_hashjoinable(Oid opno, Oid inputtype)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
result = optup->oprcanhash;
ReleaseSysCache(tp);
@@ -1494,7 +1494,7 @@ get_commutator(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
Oid result;
result = optup->oprcom;
@@ -1518,7 +1518,7 @@ get_negator(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
Oid result;
result = optup->oprnegate;
@@ -1542,7 +1542,7 @@ get_oprrest(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
RegProcedure result;
result = optup->oprrest;
@@ -1566,7 +1566,7 @@ get_oprjoin(Oid opno)
tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
if (HeapTupleIsValid(tp))
{
- Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+ Form_pg_operator optup = GETSTRUCT(pg_operator, tp);
RegProcedure result;
result = optup->oprjoin;
@@ -1593,7 +1593,7 @@ get_func_name(Oid funcid)
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (HeapTupleIsValid(tp))
{
- Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
+ Form_pg_proc functup = GETSTRUCT(pg_proc, tp);
char *result;
result = pstrdup(NameStr(functup->proname));
@@ -1617,7 +1617,7 @@ get_func_namespace(Oid funcid)
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (HeapTupleIsValid(tp))
{
- Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
+ Form_pg_proc functup = GETSTRUCT(pg_proc, tp);
Oid result;
result = functup->pronamespace;
@@ -1642,7 +1642,7 @@ get_func_rettype(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->prorettype;
+ result = (GETSTRUCT(pg_proc, tp))->prorettype;
ReleaseSysCache(tp);
return result;
}
@@ -1661,7 +1661,7 @@ get_func_nargs(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
+ result = (GETSTRUCT(pg_proc, tp))->pronargs;
ReleaseSysCache(tp);
return result;
}
@@ -1684,7 +1684,7 @@ get_func_signature(Oid funcid, Oid **argtypes, int *nargs)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procstruct = (Form_pg_proc) GETSTRUCT(tp);
+ procstruct = GETSTRUCT(pg_proc, tp);
result = procstruct->prorettype;
*nargs = (int) procstruct->pronargs;
@@ -1710,7 +1710,7 @@ get_func_variadictype(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->provariadic;
+ result = (GETSTRUCT(pg_proc, tp))->provariadic;
ReleaseSysCache(tp);
return result;
}
@@ -1729,7 +1729,7 @@ get_func_retset(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
+ result = (GETSTRUCT(pg_proc, tp))->proretset;
ReleaseSysCache(tp);
return result;
}
@@ -1748,7 +1748,7 @@ func_strict(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
+ result = (GETSTRUCT(pg_proc, tp))->proisstrict;
ReleaseSysCache(tp);
return result;
}
@@ -1767,7 +1767,7 @@ func_volatile(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->provolatile;
+ result = (GETSTRUCT(pg_proc, tp))->provolatile;
ReleaseSysCache(tp);
return result;
}
@@ -1786,7 +1786,7 @@ func_parallel(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
+ result = (GETSTRUCT(pg_proc, tp))->proparallel;
ReleaseSysCache(tp);
return result;
}
@@ -1805,7 +1805,7 @@ get_func_prokind(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->prokind;
+ result = (GETSTRUCT(pg_proc, tp))->prokind;
ReleaseSysCache(tp);
return result;
}
@@ -1824,7 +1824,7 @@ get_func_leakproof(Oid funcid)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
+ result = (GETSTRUCT(pg_proc, tp))->proleakproof;
ReleaseSysCache(tp);
return result;
}
@@ -1843,7 +1843,7 @@ get_func_support(Oid funcid)
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (HeapTupleIsValid(tp))
{
- Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
+ Form_pg_proc functup = GETSTRUCT(pg_proc, tp);
RegProcedure result;
result = functup->prosupport;
@@ -1884,7 +1884,7 @@ get_relnatts(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
int result;
result = reltup->relnatts;
@@ -1913,7 +1913,7 @@ get_rel_name(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
char *result;
result = pstrdup(NameStr(reltup->relname));
@@ -1937,7 +1937,7 @@ get_rel_namespace(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
Oid result;
result = reltup->relnamespace;
@@ -1964,7 +1964,7 @@ get_rel_type_id(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
Oid result;
result = reltup->reltype;
@@ -1988,7 +1988,7 @@ get_rel_relkind(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
char result;
result = reltup->relkind;
@@ -2012,7 +2012,7 @@ get_rel_relispartition(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
bool result;
result = reltup->relispartition;
@@ -2039,7 +2039,7 @@ get_rel_tablespace(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (HeapTupleIsValid(tp))
{
- Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+ Form_pg_class reltup = GETSTRUCT(pg_class, tp);
Oid result;
result = reltup->reltablespace;
@@ -2065,7 +2065,7 @@ get_rel_persistence(Oid relid)
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for relation %u", relid);
- reltup = (Form_pg_class) GETSTRUCT(tp);
+ reltup = GETSTRUCT(pg_class, tp);
result = reltup->relpersistence;
ReleaseSysCache(tp);
@@ -2088,7 +2088,7 @@ get_transform_fromsql(Oid typid, Oid langid, List *trftypes)
{
Oid funcid;
- funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
+ funcid = (GETSTRUCT(pg_transform, tup))->trffromsql;
ReleaseSysCache(tup);
return funcid;
}
@@ -2109,7 +2109,7 @@ get_transform_tosql(Oid typid, Oid langid, List *trftypes)
{
Oid funcid;
- funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
+ funcid = (GETSTRUCT(pg_transform, tup))->trftosql;
ReleaseSysCache(tup);
return funcid;
}
@@ -2134,7 +2134,7 @@ get_typisdefined(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
bool result;
result = typtup->typisdefined;
@@ -2158,7 +2158,7 @@ get_typlen(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
int16 result;
result = typtup->typlen;
@@ -2183,7 +2183,7 @@ get_typbyval(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
bool result;
result = typtup->typbyval;
@@ -2213,7 +2213,7 @@ get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", typid);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
*typlen = typtup->typlen;
*typbyval = typtup->typbyval;
ReleaseSysCache(tp);
@@ -2234,7 +2234,7 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", typid);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
*typlen = typtup->typlen;
*typbyval = typtup->typbyval;
*typalign = typtup->typalign;
@@ -2259,7 +2259,7 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
Oid
getTypeIOParam(HeapTuple typeTuple)
{
- Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
+ Form_pg_type typeStruct = GETSTRUCT(pg_type, typeTuple);
/*
* Array types get their typelem as parameter; everybody else gets their
@@ -2326,7 +2326,7 @@ get_type_io_data(Oid typid,
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", typid);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
+ typeStruct = GETSTRUCT(pg_type, typeTuple);
*typlen = typeStruct->typlen;
*typbyval = typeStruct->typbyval;
@@ -2360,7 +2360,7 @@ get_typalign(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
char result;
result = typtup->typalign;
@@ -2380,7 +2380,7 @@ get_typstorage(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
char result;
result = typtup->typstorage;
@@ -2413,7 +2413,7 @@ get_typdefault(Oid typid)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", typid);
- type = (Form_pg_type) GETSTRUCT(typeTuple);
+ type = GETSTRUCT(pg_type, typeTuple);
/*
* typdefault and typdefaultbin are potentially null, so don't try to
@@ -2505,7 +2505,7 @@ getBaseTypeAndTypmod(Oid typid, int32 *typmod)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
if (typTup->typtype != TYPTYPE_DOMAIN)
{
/* Not a domain, so done */
@@ -2590,7 +2590,7 @@ get_typtype(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
char result;
result = typtup->typtype;
@@ -2672,7 +2672,7 @@ get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", typid);
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
*typcategory = typtup->typcategory;
*typispreferred = typtup->typispreferred;
ReleaseSysCache(tp);
@@ -2692,7 +2692,7 @@ get_typ_typrelid(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
result = typtup->typrelid;
@@ -2720,7 +2720,7 @@ get_element_type(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
if (IsTrueArrayType(typtup))
@@ -2749,7 +2749,7 @@ get_array_type(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
+ result = (GETSTRUCT(pg_type, tp))->typarray;
ReleaseSysCache(tp);
}
return result;
@@ -2799,7 +2799,7 @@ get_base_element_type(Oid typid)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tup))
break;
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
if (typTup->typtype != TYPTYPE_DOMAIN)
{
/* Not a domain, so stop descending */
@@ -2836,7 +2836,7 @@ getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type);
- pt = (Form_pg_type) GETSTRUCT(typeTuple);
+ pt = GETSTRUCT(pg_type, typeTuple);
if (!pt->typisdefined)
ereport(ERROR,
@@ -2869,7 +2869,7 @@ getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type);
- pt = (Form_pg_type) GETSTRUCT(typeTuple);
+ pt = GETSTRUCT(pg_type, typeTuple);
if (!pt->typisdefined)
ereport(ERROR,
@@ -2902,7 +2902,7 @@ getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type);
- pt = (Form_pg_type) GETSTRUCT(typeTuple);
+ pt = GETSTRUCT(pg_type, typeTuple);
if (!pt->typisdefined)
ereport(ERROR,
@@ -2935,7 +2935,7 @@ getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena)
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type);
- pt = (Form_pg_type) GETSTRUCT(typeTuple);
+ pt = GETSTRUCT(pg_type, typeTuple);
if (!pt->typisdefined)
ereport(ERROR,
@@ -2967,7 +2967,7 @@ get_typmodin(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
result = typtup->typmodin;
@@ -2992,7 +2992,7 @@ get_typmodout(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
result = typtup->typmodout;
@@ -3017,7 +3017,7 @@ get_typcollation(Oid typid)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typtup = GETSTRUCT(pg_type, tp);
Oid result;
result = typtup->typcollation;
@@ -3058,7 +3058,7 @@ get_typsubscript(Oid typid, Oid *typelemp)
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (HeapTupleIsValid(tp))
{
- Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
+ Form_pg_type typform = GETSTRUCT(pg_type, tp);
RegProcedure handler = typform->typsubscript;
if (typelemp)
@@ -3129,7 +3129,7 @@ get_attavgwidth(Oid relid, AttrNumber attnum)
BoolGetDatum(false));
if (HeapTupleIsValid(tp))
{
- stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
+ stawidth = (GETSTRUCT(pg_statistic, tp))->stawidth;
ReleaseSysCache(tp);
if (stawidth > 0)
return stawidth;
@@ -3187,7 +3187,7 @@ bool
get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple,
int reqkind, Oid reqop, int flags)
{
- Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
+ Form_pg_statistic stats = GETSTRUCT(pg_statistic, statstuple);
int i;
Datum val;
bool isnull;
@@ -3236,7 +3236,7 @@ get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple,
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
- typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
+ typeForm = GETSTRUCT(pg_type, typeTuple);
/* Deconstruct array into Datum elements; NULLs not expected */
deconstruct_array(statarray,
@@ -3330,7 +3330,7 @@ get_namespace_name(Oid nspid)
tp = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(nspid));
if (HeapTupleIsValid(tp))
{
- Form_pg_namespace nsptup = (Form_pg_namespace) GETSTRUCT(tp);
+ Form_pg_namespace nsptup = GETSTRUCT(pg_namespace, tp);
char *result;
result = pstrdup(NameStr(nsptup->nspname));
@@ -3371,7 +3371,7 @@ get_range_subtype(Oid rangeOid)
tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
if (HeapTupleIsValid(tp))
{
- Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
+ Form_pg_range rngtup = GETSTRUCT(pg_range, tp);
Oid result;
result = rngtup->rngsubtype;
@@ -3397,7 +3397,7 @@ get_range_collation(Oid rangeOid)
tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
if (HeapTupleIsValid(tp))
{
- Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
+ Form_pg_range rngtup = GETSTRUCT(pg_range, tp);
Oid result;
result = rngtup->rngcollation;
@@ -3422,7 +3422,7 @@ get_range_multirange(Oid rangeOid)
tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
if (HeapTupleIsValid(tp))
{
- Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
+ Form_pg_range rngtup = GETSTRUCT(pg_range, tp);
Oid result;
result = rngtup->rngmultitypid;
@@ -3447,7 +3447,7 @@ get_multirange_range(Oid multirangeOid)
tp = SearchSysCache1(RANGEMULTIRANGE, ObjectIdGetDatum(multirangeOid));
if (HeapTupleIsValid(tp))
{
- Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
+ Form_pg_range rngtup = GETSTRUCT(pg_range, tp);
Oid result;
result = rngtup->rngtypid;
@@ -3484,7 +3484,7 @@ get_index_column_opclass(Oid index_oid, int attno)
if (!HeapTupleIsValid(tuple))
return InvalidOid;
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
/* caller is supposed to guarantee this */
Assert(attno > 0 && attno <= rd_index->indnatts);
@@ -3526,7 +3526,7 @@ get_index_isreplident(Oid index_oid)
if (!HeapTupleIsValid(tuple))
return false;
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
result = rd_index->indisreplident;
ReleaseSysCache(tuple);
@@ -3549,7 +3549,7 @@ get_index_isvalid(Oid index_oid)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u", index_oid);
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
isvalid = rd_index->indisvalid;
ReleaseSysCache(tuple);
@@ -3572,7 +3572,7 @@ get_index_isclustered(Oid index_oid)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u", index_oid);
- rd_index = (Form_pg_index) GETSTRUCT(tuple);
+ rd_index = GETSTRUCT(pg_index, tuple);
isclustered = rd_index->indisclustered;
ReleaseSysCache(tuple);
diff --git a/src/backend/utils/cache/partcache.c b/src/backend/utils/cache/partcache.c
index afa99c5d03..4f8c7c5bde 100644
--- a/src/backend/utils/cache/partcache.c
+++ b/src/backend/utils/cache/partcache.c
@@ -111,7 +111,7 @@ RelationBuildPartitionKey(Relation relation)
sizeof(PartitionKeyData));
/* Fixed-length attributes */
- form = (Form_pg_partitioned_table) GETSTRUCT(tuple);
+ form = GETSTRUCT(pg_partitioned_table, tuple);
key->strategy = form->partstrat;
key->partnatts = form->partnatts;
@@ -200,7 +200,7 @@ RelationBuildPartitionKey(Relation relation)
if (!HeapTupleIsValid(opclasstup))
elog(ERROR, "cache lookup failed for opclass %u", opclass->values[i]);
- opclassform = (Form_pg_opclass) GETSTRUCT(opclasstup);
+ opclassform = GETSTRUCT(pg_opclass, opclasstup);
key->partopfamily[i] = opclassform->opcfamily;
key->partopcintype[i] = opclassform->opcintype;
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 00dc0f2403..7839b53852 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -573,7 +573,7 @@ RelationBuildTupleDesc(Relation relation)
Form_pg_attribute attp;
int attnum;
- attp = (Form_pg_attribute) GETSTRUCT(pg_attribute_tuple);
+ attp = GETSTRUCT(pg_attribute, pg_attribute_tuple);
attnum = attp->attnum;
if (attnum <= 0 || attnum > RelationGetNumberOfAttributes(relation))
@@ -786,7 +786,7 @@ RelationBuildRuleLock(Relation relation)
while (HeapTupleIsValid(rewrite_tuple = systable_getnext(rewrite_scan)))
{
- Form_pg_rewrite rewrite_form = (Form_pg_rewrite) GETSTRUCT(rewrite_tuple);
+ Form_pg_rewrite rewrite_form = GETSTRUCT(pg_rewrite, rewrite_tuple);
bool isnull;
Datum rule_datum;
char *rule_str;
@@ -1112,7 +1112,7 @@ retry:
/*
* get information from the pg_class_tuple
*/
- relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
+ relp = GETSTRUCT(pg_class, pg_class_tuple);
relid = relp->oid;
Assert(relid == targetRelId);
@@ -1350,7 +1350,7 @@ RelationInitPhysicalAddr(Relation relation)
if (!HeapTupleIsValid(phys_tuple))
elog(ERROR, "could not find pg_class entry for %u",
RelationGetRelid(relation));
- physrel = (Form_pg_class) GETSTRUCT(phys_tuple);
+ physrel = GETSTRUCT(pg_class, phys_tuple);
relation->rd_rel->reltablespace = physrel->reltablespace;
relation->rd_rel->relfilenode = physrel->relfilenode;
@@ -1443,7 +1443,7 @@ RelationInitIndexAccessInfo(Relation relation)
RelationGetRelid(relation));
oldcontext = MemoryContextSwitchTo(CacheMemoryContext);
relation->rd_indextuple = heap_copytuple(tuple);
- relation->rd_index = (Form_pg_index) GETSTRUCT(relation->rd_indextuple);
+ relation->rd_index = GETSTRUCT(pg_index, relation->rd_indextuple);
MemoryContextSwitchTo(oldcontext);
ReleaseSysCache(tuple);
@@ -1455,7 +1455,7 @@ RelationInitIndexAccessInfo(Relation relation)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for access method %u",
relation->rd_rel->relam);
- aform = (Form_pg_am) GETSTRUCT(tuple);
+ aform = GETSTRUCT(pg_am, tuple);
relation->rd_amhandler = aform->amhandler;
ReleaseSysCache(tuple);
@@ -1729,7 +1729,7 @@ LookupOpclassInfo(Oid operatorClassOid,
if (HeapTupleIsValid(htup = systable_getnext(scan)))
{
- Form_pg_opclass opclassform = (Form_pg_opclass) GETSTRUCT(htup);
+ Form_pg_opclass opclassform = GETSTRUCT(pg_opclass, htup);
opcentry->opcfamily = opclassform->opcfamily;
opcentry->opcintype = opclassform->opcintype;
@@ -1764,7 +1764,7 @@ LookupOpclassInfo(Oid operatorClassOid,
while (HeapTupleIsValid(htup = systable_getnext(scan)))
{
- Form_pg_amproc amprocform = (Form_pg_amproc) GETSTRUCT(htup);
+ Form_pg_amproc amprocform = GETSTRUCT(pg_amproc, htup);
if (amprocform->amprocnum <= 0 ||
(StrategyNumber) amprocform->amprocnum > numSupport)
@@ -1833,7 +1833,7 @@ RelationInitTableAccessMethod(Relation relation)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for access method %u",
relation->rd_rel->relam);
- aform = (Form_pg_am) GETSTRUCT(tuple);
+ aform = GETSTRUCT(pg_am, tuple);
relation->rd_amhandler = aform->amhandler;
ReleaseSysCache(tuple);
}
@@ -2258,7 +2258,7 @@ RelationReloadIndexInfo(Relation relation)
if (!HeapTupleIsValid(pg_class_tuple))
elog(ERROR, "could not find pg_class tuple for index %u",
RelationGetRelid(relation));
- relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
+ relp = GETSTRUCT(pg_class, pg_class_tuple);
memcpy(relation->rd_rel, relp, CLASS_TUPLE_SIZE);
/* Reload reloptions in case they changed */
if (relation->rd_options)
@@ -2287,7 +2287,7 @@ RelationReloadIndexInfo(Relation relation)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u",
RelationGetRelid(relation));
- index = (Form_pg_index) GETSTRUCT(tuple);
+ index = GETSTRUCT(pg_index, tuple);
/*
* Basically, let's just copy all the bool fields. There are one or
@@ -2379,7 +2379,7 @@ RelationReloadNailed(Relation relation)
pg_class_tuple = ScanPgRelation(RelationGetRelid(relation),
true, false);
- relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
+ relp = GETSTRUCT(pg_class, pg_class_tuple);
memcpy(relation->rd_rel, relp, CLASS_TUPLE_SIZE);
heap_freetuple(pg_class_tuple);
@@ -3749,7 +3749,7 @@ RelationSetNewRelfilenumber(Relation relation, char persistence)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for relation %u",
RelationGetRelid(relation));
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
/*
* Schedule unlinking of the old storage at transaction commit, except
@@ -4193,7 +4193,7 @@ RelationCacheInitializePhase3(void)
if (!HeapTupleIsValid(htup))
elog(FATAL, "cache lookup failed for relation %u",
RelationGetRelid(relation));
- relp = (Form_pg_class) GETSTRUCT(htup);
+ relp = GETSTRUCT(pg_class, htup);
/*
* Copy tuple to relation->rd_rel. (See notes in
@@ -4438,7 +4438,7 @@ AttrDefaultFetch(Relation relation, int ndef)
while (HeapTupleIsValid(htup = systable_getnext(adscan)))
{
- Form_pg_attrdef adform = (Form_pg_attrdef) GETSTRUCT(htup);
+ Form_pg_attrdef adform = GETSTRUCT(pg_attrdef, htup);
Datum val;
bool isnull;
@@ -4534,7 +4534,7 @@ CheckConstraintFetch(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(conscan)))
{
- Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(htup);
+ Form_pg_constraint conform = GETSTRUCT(pg_constraint, htup);
Datum val;
bool isnull;
@@ -4658,7 +4658,7 @@ RelationGetFKeyList(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(conscan)))
{
- Form_pg_constraint constraint = (Form_pg_constraint) GETSTRUCT(htup);
+ Form_pg_constraint constraint = GETSTRUCT(pg_constraint, htup);
ForeignKeyCacheInfo *info;
/* consider only foreign keys */
@@ -4765,7 +4765,7 @@ RelationGetIndexList(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(indscan)))
{
- Form_pg_index index = (Form_pg_index) GETSTRUCT(htup);
+ Form_pg_index index = GETSTRUCT(pg_index, htup);
/*
* Ignore any indexes that are currently being dropped. This will
@@ -4884,7 +4884,7 @@ RelationGetStatExtList(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(indscan)))
{
- Oid oid = ((Form_pg_statistic_ext) GETSTRUCT(htup))->oid;
+ Oid oid = (GETSTRUCT(pg_statistic_ext, htup))->oid;
result = lappend_oid(result, oid);
}
@@ -5530,7 +5530,7 @@ RelationGetExclusionInfo(Relation indexRelation,
while (HeapTupleIsValid(htup = systable_getnext(conscan)))
{
- Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(htup);
+ Form_pg_constraint conform = GETSTRUCT(pg_constraint, htup);
Datum val;
bool isnull;
ArrayType *arr;
@@ -5677,7 +5677,7 @@ RelationBuildPublicationDesc(Relation relation, PublicationDesc *pubdesc)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication %u", pubid);
- pubform = (Form_pg_publication) GETSTRUCT(tup);
+ pubform = GETSTRUCT(pg_publication, tup);
pubdesc->pubactions.pubinsert |= pubform->pubinsert;
pubdesc->pubactions.pubupdate |= pubform->pubupdate;
@@ -6144,7 +6144,7 @@ load_relcache_init_file(bool shared)
/* Fix up internal pointers in the tuple -- see heap_copytuple */
rel->rd_indextuple->t_data = (HeapTupleHeader) ((char *) rel->rd_indextuple + HEAPTUPLESIZE);
- rel->rd_index = (Form_pg_index) GETSTRUCT(rel->rd_indextuple);
+ rel->rd_index = GETSTRUCT(pg_index, rel->rd_indextuple);
/*
* prepare index info context --- parameters should match
diff --git a/src/backend/utils/cache/relfilenumbermap.c b/src/backend/utils/cache/relfilenumbermap.c
index c4245d5ccd..7570f5e095 100644
--- a/src/backend/utils/cache/relfilenumbermap.c
+++ b/src/backend/utils/cache/relfilenumbermap.c
@@ -209,7 +209,7 @@ RelidByRelfilenumber(Oid reltablespace, RelFileNumber relfilenumber)
while (HeapTupleIsValid(ntp = systable_getnext(scandesc)))
{
- Form_pg_class classform = (Form_pg_class) GETSTRUCT(ntp);
+ Form_pg_class classform = GETSTRUCT(pg_class, ntp);
if (found)
elog(ERROR,
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index 1912b12146..a8c320ef91 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -1320,7 +1320,7 @@ SearchSysCacheAttName(Oid relid, const char *attname)
CStringGetDatum(attname));
if (!HeapTupleIsValid(tuple))
return NULL;
- if (((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
+ if ((GETSTRUCT(pg_attribute, tuple))->attisdropped)
{
ReleaseSysCache(tuple);
return NULL;
@@ -1383,7 +1383,7 @@ SearchSysCacheAttNum(Oid relid, int16 attnum)
Int16GetDatum(attnum));
if (!HeapTupleIsValid(tuple))
return NULL;
- if (((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
+ if ((GETSTRUCT(pg_attribute, tuple))->attisdropped)
{
ReleaseSysCache(tuple);
return NULL;
diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c
index 24808dfbb1..e1d0dad795 100644
--- a/src/backend/utils/cache/ts_cache.c
+++ b/src/backend/utils/cache/ts_cache.c
@@ -152,7 +152,7 @@ lookup_ts_parser_cache(Oid prsId)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for text search parser %u",
prsId);
- prs = (Form_pg_ts_parser) GETSTRUCT(tp);
+ prs = GETSTRUCT(pg_ts_parser, tp);
/*
* Sanity checks
@@ -254,7 +254,7 @@ lookup_ts_dictionary_cache(Oid dictId)
if (!HeapTupleIsValid(tpdict))
elog(ERROR, "cache lookup failed for text search dictionary %u",
dictId);
- dict = (Form_pg_ts_dict) GETSTRUCT(tpdict);
+ dict = GETSTRUCT(pg_ts_dict, tpdict);
/*
* Sanity checks
@@ -270,7 +270,7 @@ lookup_ts_dictionary_cache(Oid dictId)
if (!HeapTupleIsValid(tptmpl))
elog(ERROR, "cache lookup failed for text search template %u",
dict->dicttemplate);
- template = (Form_pg_ts_template) GETSTRUCT(tptmpl);
+ template = GETSTRUCT(pg_ts_template, tptmpl);
/*
* Sanity checks
@@ -424,7 +424,7 @@ lookup_ts_config_cache(Oid cfgId)
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for text search configuration %u",
cfgId);
- cfg = (Form_pg_ts_config) GETSTRUCT(tp);
+ cfg = GETSTRUCT(pg_ts_config, tp);
/*
* Sanity checks
@@ -484,7 +484,7 @@ lookup_ts_config_cache(Oid cfgId)
while ((maptup = systable_getnext_ordered(mapscan, ForwardScanDirection)) != NULL)
{
- Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup);
+ Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup);
int toktype = cfgmap->maptokentype;
if (toktype <= 0 || toktype > MAXTOKENTYPE)
@@ -625,7 +625,7 @@ check_TSCurrentConfig(char **newval, void **extra, GucSource source)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for text search configuration %u",
cfgId);
- cfg = (Form_pg_ts_config) GETSTRUCT(tuple);
+ cfg = GETSTRUCT(pg_ts_config, tuple);
buf = quote_qualified_identifier(get_namespace_name(cfg->cfgnamespace),
NameStr(cfg->cfgname));
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c
index 808f9ebd0d..6b55c4a4e1 100644
--- a/src/backend/utils/cache/typcache.c
+++ b/src/backend/utils/cache/typcache.c
@@ -383,7 +383,7 @@ lookup_type_cache(Oid type_id, int flags)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type with OID %u does not exist", type_id)));
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
if (!typtup->typisdefined)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -438,7 +438,7 @@ lookup_type_cache(Oid type_id, int flags)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type with OID %u does not exist", type_id)));
- typtup = (Form_pg_type) GETSTRUCT(tp);
+ typtup = GETSTRUCT(pg_type, tp);
if (!typtup->typisdefined)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -922,7 +922,7 @@ load_rangetype_info(TypeCacheEntry *typentry)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for range type %u",
typentry->type_id);
- pg_range = (Form_pg_range) GETSTRUCT(tup);
+ pg_range = GETSTRUCT(pg_range, tup);
subtypeOid = pg_range->rngsubtype;
typentry->rng_collation = pg_range->rngcollation;
@@ -1032,7 +1032,7 @@ load_domaintype_info(TypeCacheEntry *typentry)
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
- typTup = (Form_pg_type) GETSTRUCT(tup);
+ typTup = GETSTRUCT(pg_type, tup);
if (typTup->typtype != TYPTYPE_DOMAIN)
{
@@ -1056,7 +1056,7 @@ load_domaintype_info(TypeCacheEntry *typentry)
while (HeapTupleIsValid(conTup = systable_getnext(scan)))
{
- Form_pg_constraint c = (Form_pg_constraint) GETSTRUCT(conTup);
+ Form_pg_constraint c = GETSTRUCT(pg_constraint, conTup);
Datum val;
bool isNull;
char *constring;
@@ -2592,7 +2592,7 @@ load_enum_cache_data(TypeCacheEntry *tcache)
while (HeapTupleIsValid(enum_tuple = systable_getnext(enum_scan)))
{
- Form_pg_enum en = (Form_pg_enum) GETSTRUCT(enum_tuple);
+ Form_pg_enum en = GETSTRUCT(pg_enum, enum_tuple);
if (numitems >= maxitems)
{
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index a9dd068095..125a175a11 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -181,7 +181,7 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt,
procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId));
if (!HeapTupleIsValid(procedureTuple))
elog(ERROR, "cache lookup failed for function %u", functionId);
- procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
finfo->fn_nargs = procedureStruct->pronargs;
finfo->fn_strict = procedureStruct->proisstrict;
@@ -291,7 +291,7 @@ fmgr_symbol(Oid functionId, char **mod, char **fn)
procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId));
if (!HeapTupleIsValid(procedureTuple))
elog(ERROR, "cache lookup failed for function %u", functionId);
- procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
if (procedureStruct->prosecdef ||
!heap_attisnull(procedureTuple, Anum_pg_proc_proconfig, NULL) ||
@@ -431,7 +431,7 @@ fmgr_info_C_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
static void
fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
{
- Form_pg_proc procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
+ Form_pg_proc procedureStruct = GETSTRUCT(pg_proc, procedureTuple);
Oid language = procedureStruct->prolang;
HeapTuple languageTuple;
Form_pg_language languageStruct;
@@ -440,7 +440,7 @@ fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
languageTuple = SearchSysCache1(LANGOID, ObjectIdGetDatum(language));
if (!HeapTupleIsValid(languageTuple))
elog(ERROR, "cache lookup failed for language %u", language);
- languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
+ languageStruct = GETSTRUCT(pg_language, languageTuple);
/*
* Look up the language's call handler function, ignoring any attributes
@@ -528,7 +528,7 @@ fetch_finfo_record(void *filehandle, const char *funcname)
static CFuncHashTabEntry *
lookup_C_func(HeapTuple procedureTuple)
{
- Oid fn_oid = ((Form_pg_proc) GETSTRUCT(procedureTuple))->oid;
+ Oid fn_oid = (GETSTRUCT(pg_proc, procedureTuple))->oid;
CFuncHashTabEntry *entry;
if (CFuncHash == NULL)
@@ -553,7 +553,7 @@ static void
record_C_func(HeapTuple procedureTuple,
PGFunction user_fn, const Pg_finfo_record *inforec)
{
- Oid fn_oid = ((Form_pg_proc) GETSTRUCT(procedureTuple))->oid;
+ Oid fn_oid = (GETSTRUCT(pg_proc, procedureTuple))->oid;
CFuncHashTabEntry *entry;
bool found;
@@ -671,7 +671,7 @@ fmgr_security_definer(PG_FUNCTION_ARGS)
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u",
fcinfo->flinfo->fn_oid);
- procedureStruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procedureStruct = GETSTRUCT(pg_proc, tuple);
if (procedureStruct->prosecdef)
fcache->userid = procedureStruct->proowner;
@@ -2035,7 +2035,7 @@ CheckFunctionValidatorAccess(Oid validatorOid, Oid functionOid)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function with OID %u does not exist", functionOid)));
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/*
* Fetch pg_language entry to know if this is the correct validation
@@ -2044,7 +2044,7 @@ CheckFunctionValidatorAccess(Oid validatorOid, Oid functionOid)
langTup = SearchSysCache1(LANGOID, ObjectIdGetDatum(procStruct->prolang));
if (!HeapTupleIsValid(langTup))
elog(ERROR, "cache lookup failed for language %u", procStruct->prolang);
- langStruct = (Form_pg_language) GETSTRUCT(langTup);
+ langStruct = GETSTRUCT(pg_language, langTup);
if (langStruct->lanvalidator != validatorOid)
ereport(ERROR,
diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c
index a1fe50ffca..213121461d 100644
--- a/src/backend/utils/fmgr/funcapi.c
+++ b/src/backend/utils/fmgr/funcapi.c
@@ -403,7 +403,7 @@ internal_get_result_type(Oid funcid,
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(tp);
+ procform = GETSTRUCT(pg_proc, tp);
rettype = procform->prorettype;
@@ -1337,7 +1337,7 @@ int
get_func_arg_info(HeapTuple procTup,
Oid **p_argtypes, char ***p_argnames, char **p_argmodes)
{
- Form_pg_proc procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ Form_pg_proc procStruct = GETSTRUCT(pg_proc, procTup);
Datum proallargtypes;
Datum proargmodes;
Datum proargnames;
@@ -1667,7 +1667,7 @@ get_func_result_name(Oid functionId)
TupleDesc
build_function_result_tupdesc_t(HeapTuple procTuple)
{
- Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(procTuple);
+ Form_pg_proc procform = GETSTRUCT(pg_proc, procTuple);
Datum proallargtypes;
Datum proargmodes;
Datum proargnames;
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index eb43b2c5e5..df10da08b9 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -683,7 +683,7 @@ has_rolreplication(Oid roleid)
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(utup))
{
- result = ((Form_pg_authid) GETSTRUCT(utup))->rolreplication;
+ result = (GETSTRUCT(pg_authid, utup))->rolreplication;
ReleaseSysCache(utup);
}
return result;
@@ -732,7 +732,7 @@ InitializeSessionUserId(const char *rolename, Oid roleid)
errmsg("role with OID %u does not exist", roleid)));
}
- rform = (Form_pg_authid) GETSTRUCT(roleTup);
+ rform = GETSTRUCT(pg_authid, roleTup);
roleid = rform->oid;
rname = NameStr(rform->rolname);
@@ -925,7 +925,7 @@ GetUserNameFromId(Oid roleid, bool noerr)
}
else
{
- result = pstrdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname));
+ result = pstrdup(NameStr((GETSTRUCT(pg_authid, tuple))->rolname));
ReleaseSysCache(tuple);
}
return result;
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 29f70accb2..5b5a7e262b 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -321,7 +321,7 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
tup = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
- dbform = (Form_pg_database) GETSTRUCT(tup);
+ dbform = GETSTRUCT(pg_database, tup);
/* This recheck is strictly paranoia */
if (strcmp(name, NameStr(dbform->datname)) != 0)
@@ -940,7 +940,7 @@ InitPostgres(const char *in_dbname, Oid dboid,
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", in_dbname)));
- dbform = (Form_pg_database) GETSTRUCT(tuple);
+ dbform = GETSTRUCT(pg_database, tuple);
MyDatabaseId = dbform->oid;
MyDatabaseTableSpace = dbform->dattablespace;
/* take database name from the caller, just for paranoia */
@@ -957,7 +957,7 @@ InitPostgres(const char *in_dbname, Oid dboid,
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database %u does not exist", dboid)));
- dbform = (Form_pg_database) GETSTRUCT(tuple);
+ dbform = GETSTRUCT(pg_database, tuple);
MyDatabaseId = dbform->oid;
MyDatabaseTableSpace = dbform->dattablespace;
Assert(MyDatabaseId == dboid);
@@ -1040,8 +1040,8 @@ InitPostgres(const char *in_dbname, Oid dboid,
tuple = GetDatabaseTuple(dbname);
if (!HeapTupleIsValid(tuple) ||
- MyDatabaseId != ((Form_pg_database) GETSTRUCT(tuple))->oid ||
- MyDatabaseTableSpace != ((Form_pg_database) GETSTRUCT(tuple))->dattablespace)
+ MyDatabaseId != (GETSTRUCT(pg_database, tuple))->oid ||
+ MyDatabaseTableSpace != (GETSTRUCT(pg_database, tuple))->dattablespace)
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", dbname),
diff --git a/src/backend/utils/misc/rls.c b/src/backend/utils/misc/rls.c
index d15880670f..73fd21d843 100644
--- a/src/backend/utils/misc/rls.c
+++ b/src/backend/utils/misc/rls.c
@@ -66,7 +66,7 @@ check_enable_rls(Oid relid, Oid checkAsUser, bool noError)
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
return RLS_NONE;
- classform = (Form_pg_class) GETSTRUCT(tuple);
+ classform = GETSTRUCT(pg_class, tuple);
relrowsecurity = classform->relrowsecurity;
relforcerowsecurity = classform->relforcerowsecurity;
diff --git a/src/backend/utils/misc/superuser.c b/src/backend/utils/misc/superuser.c
index d20e7af797..1902f49d0a 100644
--- a/src/backend/utils/misc/superuser.c
+++ b/src/backend/utils/misc/superuser.c
@@ -70,7 +70,7 @@ superuser_arg(Oid roleid)
rtup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(rtup))
{
- result = ((Form_pg_authid) GETSTRUCT(rtup))->rolsuper;
+ result = (GETSTRUCT(pg_authid, rtup))->rolsuper;
ReleaseSysCache(rtup);
}
else
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 51a60eda08..7310e3b2b8 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -651,7 +651,7 @@ struct MinimalTupleData
/*
* GETSTRUCT - given a HeapTuple pointer, return address of the user data
*/
-#define GETSTRUCT(TUP) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)
+#define GETSTRUCT(CAT, TUP) ((Form_##CAT) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff))
/*
* Accessor macros to be used with HeapTuple pointers.
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index af354a68cc..d90922f95d 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -1993,7 +1993,7 @@ plperl_validator(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- proc = (Form_pg_proc) GETSTRUCT(tuple);
+ proc = GETSTRUCT(pg_proc, tuple);
functyptype = get_typtype(proc->prorettype);
@@ -2716,7 +2716,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(fn_oid));
if (!HeapTupleIsValid(procTup))
elog(ERROR, "cache lookup failed for function %u", fn_oid);
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/*
* Try to find function in plperl_proc_hash. The reason for this
@@ -2817,7 +2817,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
if (!HeapTupleIsValid(langTup))
elog(ERROR, "cache lookup failed for language %u",
procStruct->prolang);
- langStruct = (Form_pg_language) GETSTRUCT(langTup);
+ langStruct = GETSTRUCT(pg_language, langTup);
prodesc->lang_oid = langStruct->oid;
prodesc->lanpltrusted = langStruct->lanpltrusted;
ReleaseSysCache(langTup);
@@ -2833,7 +2833,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettype));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", rettype);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype result, except VOID or RECORD */
if (typeStruct->typtype == TYPTYPE_PSEUDO)
@@ -2882,7 +2882,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(argtype));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", argtype);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype argument, except RECORD */
if (typeStruct->typtype == TYPTYPE_PSEUDO &&
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index 61fbdf0686..41eca1990a 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -149,7 +149,7 @@ plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator)
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(procTup))
elog(ERROR, "cache lookup failed for function %u", funcOid);
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/*
* See if there's already a cache entry for the current FmgrInfo. If not,
@@ -267,7 +267,7 @@ do_compile(FunctionCallInfo fcinfo,
PLpgSQL_func_hashkey *hashkey,
bool forValidator)
{
- Form_pg_proc procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ Form_pg_proc procStruct = GETSTRUCT(pg_proc, procTup);
bool is_dml_trigger = CALLED_AS_TRIGGER(fcinfo);
bool is_event_trigger = CALLED_AS_EVENT_TRIGGER(fcinfo);
Datum prosrcdatum;
@@ -545,7 +545,7 @@ do_compile(FunctionCallInfo fcinfo,
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettypeid));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", rettypeid);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype result, except VOID or RECORD */
/* (note we already replaced polymorphic types) */
@@ -1643,7 +1643,7 @@ plpgsql_parse_wordtype(char *ident)
typeTup = LookupTypeName(NULL, typeName, NULL, false);
if (typeTup)
{
- Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ Form_pg_type typeStruct = GETSTRUCT(pg_type, typeTup);
if (!typeStruct->typisdefined ||
typeStruct->typrelid != InvalidOid)
@@ -1735,7 +1735,7 @@ plpgsql_parse_cwordtype(List *idents)
classtup = SearchSysCache1(RELOID, ObjectIdGetDatum(classOid));
if (!HeapTupleIsValid(classtup))
goto done;
- classStruct = (Form_pg_class) GETSTRUCT(classtup);
+ classStruct = GETSTRUCT(pg_class, classtup);
/*
* It must be a relation, sequence, view, materialized view, composite
@@ -1756,7 +1756,7 @@ plpgsql_parse_cwordtype(List *idents)
attrtup = SearchSysCacheAttName(classOid, fldname);
if (!HeapTupleIsValid(attrtup))
goto done;
- attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup);
+ attrStruct = GETSTRUCT(pg_attribute, attrtup);
typetup = SearchSysCache1(TYPEOID,
ObjectIdGetDatum(attrStruct->atttypid));
@@ -2107,7 +2107,7 @@ static PLpgSQL_type *
build_datatype(HeapTuple typeTup, int32 typmod,
Oid collation, TypeName *origtypname)
{
- Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ Form_pg_type typeStruct = GETSTRUCT(pg_type, typeTup);
PLpgSQL_type *typ;
if (!typeStruct->typisdefined)
diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c
index 190d286f1c..632e4c351d 100644
--- a/src/pl/plpgsql/src/pl_handler.c
+++ b/src/pl/plpgsql/src/pl_handler.c
@@ -460,7 +460,7 @@ plpgsql_validator(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- proc = (Form_pg_proc) GETSTRUCT(tuple);
+ proc = GETSTRUCT(pg_proc, tuple);
functyptype = get_typtype(proc->prorettype);
diff --git a/src/pl/plpython/plpy_main.c b/src/pl/plpython/plpy_main.c
index a4d66f3057..8d03ad8987 100644
--- a/src/pl/plpython/plpy_main.c
+++ b/src/pl/plpython/plpy_main.c
@@ -175,7 +175,7 @@ plpython3_validator(PG_FUNCTION_ARGS)
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- procStruct = (Form_pg_proc) GETSTRUCT(tuple);
+ procStruct = GETSTRUCT(pg_proc, tuple);
is_trigger = PLy_procedure_is_trigger(procStruct);
diff --git a/src/pl/plpython/plpy_procedure.c b/src/pl/plpython/plpy_procedure.c
index 494f109b32..2c91e6df81 100644
--- a/src/pl/plpython/plpy_procedure.c
+++ b/src/pl/plpython/plpy_procedure.c
@@ -140,7 +140,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
int rv;
char *ptr;
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
rv = snprintf(procName, sizeof(procName),
"__plpython_procedure_%s_%u",
NameStr(procStruct->proname),
@@ -211,7 +211,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
rvTypeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettype));
if (!HeapTupleIsValid(rvTypeTup))
elog(ERROR, "cache lookup failed for type %u", rettype);
- rvTypeStruct = (Form_pg_type) GETSTRUCT(rvTypeTup);
+ rvTypeStruct = GETSTRUCT(pg_type, rvTypeTup);
/* Disallow pseudotype result, except for void or record */
if (rvTypeStruct->typtype == TYPTYPE_PSEUDO)
@@ -298,7 +298,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
ObjectIdGetDatum(types[i]));
if (!HeapTupleIsValid(argTypeTup))
elog(ERROR, "cache lookup failed for type %u", types[i]);
- argTypeStruct = (Form_pg_type) GETSTRUCT(argTypeTup);
+ argTypeStruct = GETSTRUCT(pg_type, argTypeTup);
/* disallow pseudotype arguments */
if (argTypeStruct->typtype == TYPTYPE_PSEUDO)
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index eaa98d42c2..58b61ea248 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -627,7 +627,7 @@ call_pltcl_start_proc(Oid prolang, bool pltrusted)
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procOid));
if (!HeapTupleIsValid(procTup))
elog(ERROR, "cache lookup failed for function %u", procOid);
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/* It must be same language as the function we're currently calling */
if (procStruct->prolang != prolang)
@@ -1404,7 +1404,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(fn_oid));
if (!HeapTupleIsValid(procTup))
elog(ERROR, "cache lookup failed for function %u", fn_oid);
- procStruct = (Form_pg_proc) GETSTRUCT(procTup);
+ procStruct = GETSTRUCT(pg_proc, procTup);
/*
* Look up function in pltcl_proc_htab; if it's not there, create an entry
@@ -1526,7 +1526,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettype));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", rettype);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype result, except VOID and RECORD */
if (typeStruct->typtype == TYPTYPE_PSEUDO)
@@ -1574,7 +1574,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(argtype));
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", argtype);
- typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
+ typeStruct = GETSTRUCT(pg_type, typeTup);
/* Disallow pseudotype argument, except RECORD */
if (typeStruct->typtype == TYPTYPE_PSEUDO &&
diff --git a/src/test/modules/plsample/plsample.c b/src/test/modules/plsample/plsample.c
index 780db7292a..8cc3118985 100644
--- a/src/test/modules/plsample/plsample.c
+++ b/src/test/modules/plsample/plsample.c
@@ -122,7 +122,7 @@ plsample_func_handler(PG_FUNCTION_ARGS)
* Extract and print the source text of the function. This can be used as
* a base for the function validation and execution.
*/
- pl_struct = (Form_pg_proc) GETSTRUCT(pl_tuple);
+ pl_struct = GETSTRUCT(pg_proc, pl_tuple);
proname = pstrdup(NameStr(pl_struct->proname));
ret = SysCacheGetAttr(PROCOID, pl_tuple, Anum_pg_proc_prosrc, &isnull);
if (isnull)
@@ -157,7 +157,7 @@ plsample_func_handler(PG_FUNCTION_ARGS)
if (!HeapTupleIsValid(type_tuple))
elog(ERROR, "cache lookup failed for type %u", argtype);
- type_struct = (Form_pg_type) GETSTRUCT(type_tuple);
+ type_struct = GETSTRUCT(pg_type, type_tuple);
fmgr_info_cxt(type_struct->typoutput, &(arg_out_func[i]), proc_cxt);
ReleaseSysCache(type_tuple);
@@ -186,7 +186,7 @@ plsample_func_handler(PG_FUNCTION_ARGS)
ObjectIdGetDatum(prorettype));
if (!HeapTupleIsValid(type_tuple))
elog(ERROR, "cache lookup failed for type %u", prorettype);
- pg_type_entry = (Form_pg_type) GETSTRUCT(type_tuple);
+ pg_type_entry = GETSTRUCT(pg_type, type_tuple);
result_typioparam = getTypeIOParam(type_tuple);
fmgr_info_cxt(pg_type_entry->typinput, &result_in_func, proc_cxt);
@@ -239,7 +239,7 @@ plsample_trigger_handler(PG_FUNCTION_ARGS)
* Extract and print the source text of the function. This can be used as
* a base for the function validation and execution.
*/
- pl_struct = (Form_pg_proc) GETSTRUCT(pl_tuple);
+ pl_struct = GETSTRUCT(pg_proc, pl_tuple);
proname = pstrdup(NameStr(pl_struct->proname));
ret = SysCacheGetAttr(PROCOID, pl_tuple, Anum_pg_proc_prosrc, &isnull);
if (isnull)
--
2.36.1
I wrote:
The syscache use of GETSTRUCT still uses a simple cast of the tuple (for pg_cast those calls live in parse_coerce.c, which is unchanged from master in v3). Next step I think is to see about the syscache piece -- teaching a syscache miss to deform the entire tuple into a struct and store it in the syscache.
v4 is a hackish attempt at getting the syscache to deform the tuple
and store the struct. Using only pg_cast again for ease, it seems to
work for that. It's now about as far as I can get without thinking
about byref types.
0001 just adds copies of some syscache / catcache functions for
private use by pg_cast, as scaffolding.
0002 teaches the temporary CatalogCacheCreateEntry_STRUCT() to call
heap_deform_tuple(). This then calls a for-now handwritten function
(similar to the one generated in v3) which palloc's space for the
struct and copies the fields over. Only this function knows the
catalog struct type, so a future design could call the per-cache
function via a pointer in the catcache control array. Since we already
have the isnull/values array, it's also trivial to copy the datums for
the cache keys. WIP: CatCTup->tuple is still declared a tuple, but the
t_data contents are now bogus, so there is a temporary GETSTRUCT_NEW
that knows it's looking directly at the struct.
Getting to varlen attributes: For one, I think it was mentioned above
that we will need a way to perform a deep copy of structs that contain
pointers to varlen fields. I imagine keeping track of the attributes
length will come up for some types and might be tricky. And before
that, the catalog machinery will need some preprocessor tricks to
declare pointers in the structs.
--
John Naylor
EDB: http://www.enterprisedb.com
Attachments:
v4-0002-Teach-catcache-to-store-structs-for-pg_cast.patchtext/x-patch; charset=US-ASCII; name=v4-0002-Teach-catcache-to-store-structs-for-pg_cast.patchDownload
From 20fba44412e8ef1bb4cd5b051b9d7e82618a6d93 Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Wed, 10 Aug 2022 17:19:24 +0700
Subject: [PATCH v4 2/2] Teach catcache to store structs for pg_cast
---
src/backend/parser/parse_coerce.c | 6 +--
src/backend/utils/cache/catcache.c | 73 ++++++++++++++++++++----------
src/include/access/htup_details.h | 2 +
3 files changed, 55 insertions(+), 26 deletions(-)
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index 39b7e5707b..07a1b047e3 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -3056,7 +3056,7 @@ IsBinaryCoercible(Oid srctype, Oid targettype)
ObjectIdGetDatum(targettype));
if (!HeapTupleIsValid(tuple))
return false; /* no cast */
- castForm = (Form_pg_cast) GETSTRUCT(tuple);
+ castForm = GETSTRUCT_NEW(pg_cast, tuple);
result = (castForm->castmethod == COERCION_METHOD_BINARY &&
castForm->castcontext == COERCION_CODE_IMPLICIT);
@@ -3120,7 +3120,7 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
if (HeapTupleIsValid(tuple))
{
- Form_pg_cast castForm = (Form_pg_cast) GETSTRUCT(tuple);
+ Form_pg_cast castForm = GETSTRUCT_NEW(pg_cast, tuple);
CoercionContext castcontext;
/* convert char value for castcontext to CoercionContext enum */
@@ -3287,7 +3287,7 @@ find_typmod_coercion_function(Oid typeId,
if (HeapTupleIsValid(tuple))
{
- Form_pg_cast castForm = (Form_pg_cast) GETSTRUCT(tuple);
+ Form_pg_cast castForm = GETSTRUCT_NEW(pg_cast, tuple);
*funcid = castForm->castfunc;
ReleaseSysCache(tuple);
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index b1287bb6a0..8ddc109052 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -21,6 +21,7 @@
#include "access/table.h"
#include "access/valid.h"
#include "access/xact.h"
+#include "catalog/pg_cast.h" // fixme
#include "catalog/pg_collation.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_type.h"
@@ -2158,6 +2159,42 @@ CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp, Datum *arguments,
return ct;
}
+// WIP: generated functions would look like this and be called through a pointer
+// FIXME: ct->tuple is no longer a real tuple
+// XXX: for now assume the caller has switched to the right memory context
+static CatCTup *
+CatCArrayGetStruct_pg_cast(HeapTuple pg_cast_tuple, CatCTup *ct, Datum *values, bool *isnull)
+{
+ Form_pg_cast pg_cast_struct;
+
+ /* Allocate memory for CatCTup and the cached struct in one go */
+ ct = (CatCTup *) palloc(sizeof(CatCTup) +
+ MAXIMUM_ALIGNOF + sizeof(FormData_pg_cast));
+
+ /* copy the identification info */
+ // WIP: for caches we only need t_self, can we just have that as a
+ // separate field in CatCTup?
+ ct->tuple.t_len = pg_cast_tuple->t_len;
+ ct->tuple.t_self = pg_cast_tuple->t_self;
+ ct->tuple.t_tableOid = pg_cast_tuple->t_tableOid;
+
+ // WIP: treat t_data as a pointer to the struct
+ ct->tuple.t_data = (HeapTupleHeader)
+ MAXALIGN(((char *) ct) + sizeof(CatCTup));
+ pg_cast_struct = (Form_pg_cast) ct->tuple.t_data;
+
+ /* copy tuple contents */
+ // WIP: we can just assign because there are no varlen attributes
+ pg_cast_struct->oid = DatumGetObjectId(values[Anum_pg_cast_oid - 1]);
+ pg_cast_struct->castsource = DatumGetObjectId(values[Anum_pg_cast_castsource - 1]);
+ pg_cast_struct->casttarget = DatumGetObjectId(values[Anum_pg_cast_casttarget - 1]);
+ pg_cast_struct->castfunc = DatumGetObjectId(values[Anum_pg_cast_castfunc - 1]);
+ pg_cast_struct->castcontext = DatumGetChar(values[Anum_pg_cast_castcontext - 1]);
+ pg_cast_struct->castmethod = DatumGetChar(values[Anum_pg_cast_castmethod - 1]);
+
+ return ct;
+}
+
/*
* CatalogCacheCreateEntry
* Create a new CatCTup entry, copying the given HeapTuple and other
@@ -2176,6 +2213,8 @@ CatalogCacheCreateEntry_STRUCT(CatCache *cache, HeapTuple ntp, Datum *arguments,
if (ntp)
{
int i;
+ Datum *values;
+ bool *isnull;
Assert(!negative);
@@ -2191,37 +2230,25 @@ CatalogCacheCreateEntry_STRUCT(CatCache *cache, HeapTuple ntp, Datum *arguments,
else
dtp = ntp;
- /* Allocate memory for CatCTup and the cached tuple in one go */
- oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
+ /* deform the tuple */
+ values = palloc(cache->cc_tupdesc->natts * sizeof(Datum));
+ isnull = palloc(cache->cc_tupdesc->natts * sizeof(bool));
+ heap_deform_tuple(dtp, cache->cc_tupdesc, values, isnull);
- ct = (CatCTup *) palloc(sizeof(CatCTup) +
- MAXIMUM_ALIGNOF + dtp->t_len);
- ct->tuple.t_len = dtp->t_len;
- ct->tuple.t_self = dtp->t_self;
- ct->tuple.t_tableOid = dtp->t_tableOid;
- ct->tuple.t_data = (HeapTupleHeader)
- MAXALIGN(((char *) ct) + sizeof(CatCTup));
- /* copy tuple contents */
- memcpy((char *) ct->tuple.t_data,
- (const char *) dtp->t_data,
- dtp->t_len);
+ /* copy the tuple-as-struct into the cache */
+ oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
+ ct = CatCArrayGetStruct_pg_cast(dtp, ct, values, isnull);
MemoryContextSwitchTo(oldcxt);
if (dtp != ntp)
heap_freetuple(dtp);
- /* extract keys - they'll point into the tuple if not by-value */
+ /* extract keys */
+ // FIXME: this is broken for varlen attributes -- need a way to copy them
for (i = 0; i < cache->cc_nkeys; i++)
{
- Datum atp;
- bool isnull;
-
- atp = heap_getattr(&ct->tuple,
- cache->cc_keyno[i],
- cache->cc_tupdesc,
- &isnull);
- Assert(!isnull);
- ct->keys[i] = atp;
+ Assert(!isnull[cache->cc_keyno[i]]);
+ ct->keys[i] = values[cache->cc_keyno[i]];
}
}
else
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 51a60eda08..7928c2d133 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -652,6 +652,8 @@ struct MinimalTupleData
* GETSTRUCT - given a HeapTuple pointer, return address of the user data
*/
#define GETSTRUCT(TUP) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)
+// FIXME
+#define GETSTRUCT_NEW(CAT, TUP) ((Form_##CAT) ((char *) (TUP)->t_data))
/*
* Accessor macros to be used with HeapTuple pointers.
--
2.36.1
v4-0001-Make-copies-of-syscache-catcache-routines-for-pg_.patchtext/x-patch; charset=US-ASCII; name=v4-0001-Make-copies-of-syscache-catcache-routines-for-pg_.patchDownload
From 06ca223b1d863ee2cdeafccf5b588a7af03078fe Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Wed, 10 Aug 2022 17:09:47 +0700
Subject: [PATCH v4 1/2] Make copies of syscache / catcache routines for
pg_cast
---
src/backend/parser/parse_coerce.c | 6 +-
src/backend/utils/cache/catcache.c | 366 +++++++++++++++++++++++++++++
src/backend/utils/cache/syscache.c | 11 +
src/include/utils/catcache.h | 2 +
src/include/utils/syscache.h | 2 +
5 files changed, 384 insertions(+), 3 deletions(-)
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index c4e958e4aa..39b7e5707b 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -3051,7 +3051,7 @@ IsBinaryCoercible(Oid srctype, Oid targettype)
return true;
/* Else look in pg_cast */
- tuple = SearchSysCache2(CASTSOURCETARGET,
+ tuple = SearchSysCache2CASTSOURCETARGET(
ObjectIdGetDatum(srctype),
ObjectIdGetDatum(targettype));
if (!HeapTupleIsValid(tuple))
@@ -3114,7 +3114,7 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
return COERCION_PATH_RELABELTYPE;
/* Look in pg_cast */
- tuple = SearchSysCache2(CASTSOURCETARGET,
+ tuple = SearchSysCache2CASTSOURCETARGET(
ObjectIdGetDatum(sourceTypeId),
ObjectIdGetDatum(targetTypeId));
@@ -3281,7 +3281,7 @@ find_typmod_coercion_function(Oid typeId,
ReleaseSysCache(targetType);
/* Look in pg_cast */
- tuple = SearchSysCache2(CASTSOURCETARGET,
+ tuple = SearchSysCache2CASTSOURCETARGET(
ObjectIdGetDatum(typeId),
ObjectIdGetDatum(typeId));
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index 38e943fab2..b1287bb6a0 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -69,6 +69,11 @@ static inline HeapTuple SearchCatCacheInternal(CatCache *cache,
Datum v1, Datum v2,
Datum v3, Datum v4);
+static inline HeapTuple SearchCatCacheInternal_STRUCT(CatCache *cache,
+ int nkeys,
+ Datum v1, Datum v2,
+ Datum v3, Datum v4);
+
static pg_noinline HeapTuple SearchCatCacheMiss(CatCache *cache,
int nkeys,
uint32 hashValue,
@@ -76,6 +81,13 @@ static pg_noinline HeapTuple SearchCatCacheMiss(CatCache *cache,
Datum v1, Datum v2,
Datum v3, Datum v4);
+static pg_noinline HeapTuple SearchCatCacheMiss_STRUCT(CatCache *cache,
+ int nkeys,
+ uint32 hashValue,
+ Index hashIndex,
+ Datum v1, Datum v2,
+ Datum v3, Datum v4);
+
static uint32 CatalogCacheComputeHashValue(CatCache *cache, int nkeys,
Datum v1, Datum v2, Datum v3, Datum v4);
static uint32 CatalogCacheComputeTupleHashValue(CatCache *cache, int nkeys,
@@ -95,6 +107,11 @@ static CatCTup *CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp,
uint32 hashValue, Index hashIndex,
bool negative);
+static CatCTup *CatalogCacheCreateEntry_STRUCT(CatCache *cache, HeapTuple ntp,
+ Datum *arguments,
+ uint32 hashValue, Index hashIndex,
+ bool negative);
+
static void CatCacheFreeKeys(TupleDesc tupdesc, int nkeys, int *attnos,
Datum *keys);
static void CatCacheCopyKeys(TupleDesc tupdesc, int nkeys, int *attnos,
@@ -1172,6 +1189,13 @@ SearchCatCache2(CatCache *cache,
return SearchCatCacheInternal(cache, 2, v1, v2, 0, 0);
}
+HeapTuple
+SearchCatCache2_STRUCT(CatCache *cache,
+ Datum v1, Datum v2)
+{
+ return SearchCatCacheInternal_STRUCT(cache, 2, v1, v2, 0, 0);
+}
+
HeapTuple
SearchCatCache3(CatCache *cache,
@@ -1296,6 +1320,114 @@ SearchCatCacheInternal(CatCache *cache,
return SearchCatCacheMiss(cache, nkeys, hashValue, hashIndex, v1, v2, v3, v4);
}
+/*
+ * Work-horse for SearchCatCache/SearchCatCacheN.
+ */
+static inline HeapTuple
+SearchCatCacheInternal_STRUCT(CatCache *cache,
+ int nkeys,
+ Datum v1,
+ Datum v2,
+ Datum v3,
+ Datum v4)
+{
+ Datum arguments[CATCACHE_MAXKEYS];
+ uint32 hashValue;
+ Index hashIndex;
+ dlist_iter iter;
+ dlist_head *bucket;
+ CatCTup *ct;
+
+ /* Make sure we're in an xact, even if this ends up being a cache hit */
+ Assert(IsTransactionState());
+
+ Assert(cache->cc_nkeys == nkeys);
+
+ /*
+ * one-time startup overhead for each cache
+ */
+ if (unlikely(cache->cc_tupdesc == NULL))
+ CatalogCacheInitializeCache(cache);
+
+#ifdef CATCACHE_STATS
+ cache->cc_searches++;
+#endif
+
+ /* Initialize local parameter array */
+ arguments[0] = v1;
+ arguments[1] = v2;
+ arguments[2] = v3;
+ arguments[3] = v4;
+
+ /*
+ * find the hash bucket in which to look for the tuple
+ */
+ hashValue = CatalogCacheComputeHashValue(cache, nkeys, v1, v2, v3, v4);
+ hashIndex = HASH_INDEX(hashValue, cache->cc_nbuckets);
+
+ /*
+ * scan the hash bucket until we find a match or exhaust our tuples
+ *
+ * Note: it's okay to use dlist_foreach here, even though we modify the
+ * dlist within the loop, because we don't continue the loop afterwards.
+ */
+ bucket = &cache->cc_bucket[hashIndex];
+ dlist_foreach(iter, bucket)
+ {
+ ct = dlist_container(CatCTup, cache_elem, iter.cur);
+
+ if (ct->dead)
+ continue; /* ignore dead entries */
+
+ if (ct->hash_value != hashValue)
+ continue; /* quickly skip entry if wrong hash val */
+
+ if (!CatalogCacheCompareTuple(cache, nkeys, ct->keys, arguments))
+ continue;
+
+ /*
+ * We found a match in the cache. Move it to the front of the list
+ * for its hashbucket, in order to speed subsequent searches. (The
+ * most frequently accessed elements in any hashbucket will tend to be
+ * near the front of the hashbucket's list.)
+ */
+ dlist_move_head(bucket, &ct->cache_elem);
+
+ /*
+ * If it's a positive entry, bump its refcount and return it. If it's
+ * negative, we can report failure to the caller.
+ */
+ if (!ct->negative)
+ {
+ ResourceOwnerEnlargeCatCacheRefs(CurrentResourceOwner);
+ ct->refcount++;
+ ResourceOwnerRememberCatCacheRef(CurrentResourceOwner, &ct->tuple);
+
+ CACHE_elog(DEBUG2, "SearchCatCache(%s): found in bucket %d",
+ cache->cc_relname, hashIndex);
+
+#ifdef CATCACHE_STATS
+ cache->cc_hits++;
+#endif
+
+ return &ct->tuple;
+ }
+ else
+ {
+ CACHE_elog(DEBUG2, "SearchCatCache(%s): found neg entry in bucket %d",
+ cache->cc_relname, hashIndex);
+
+#ifdef CATCACHE_STATS
+ cache->cc_neg_hits++;
+#endif
+
+ return NULL;
+ }
+ }
+
+ return SearchCatCacheMiss_STRUCT(cache, nkeys, hashValue, hashIndex, v1, v2, v3, v4);
+}
+
/*
* Search the actual catalogs, rather than the cache.
*
@@ -1422,6 +1554,132 @@ SearchCatCacheMiss(CatCache *cache,
return &ct->tuple;
}
+/*
+ * Search the actual catalogs, rather than the cache.
+ *
+ * This is kept separate from SearchCatCacheInternal() to keep the fast-path
+ * as small as possible. To avoid that effort being undone by a helpful
+ * compiler, try to explicitly forbid inlining.
+ */
+static pg_noinline HeapTuple
+SearchCatCacheMiss_STRUCT(CatCache *cache,
+ int nkeys,
+ uint32 hashValue,
+ Index hashIndex,
+ Datum v1,
+ Datum v2,
+ Datum v3,
+ Datum v4)
+{
+ ScanKeyData cur_skey[CATCACHE_MAXKEYS];
+ Relation relation;
+ SysScanDesc scandesc;
+ HeapTuple ntp;
+ CatCTup *ct;
+ Datum arguments[CATCACHE_MAXKEYS];
+
+ /* Initialize local parameter array */
+ arguments[0] = v1;
+ arguments[1] = v2;
+ arguments[2] = v3;
+ arguments[3] = v4;
+
+ /*
+ * Ok, need to make a lookup in the relation, copy the scankey and fill
+ * out any per-call fields.
+ */
+ memcpy(cur_skey, cache->cc_skey, sizeof(ScanKeyData) * nkeys);
+ cur_skey[0].sk_argument = v1;
+ cur_skey[1].sk_argument = v2;
+ cur_skey[2].sk_argument = v3;
+ cur_skey[3].sk_argument = v4;
+
+ /*
+ * Tuple was not found in cache, so we have to try to retrieve it directly
+ * from the relation. If found, we will add it to the cache; if not
+ * found, we will add a negative cache entry instead.
+ *
+ * NOTE: it is possible for recursive cache lookups to occur while reading
+ * the relation --- for example, due to shared-cache-inval messages being
+ * processed during table_open(). This is OK. It's even possible for one
+ * of those lookups to find and enter the very same tuple we are trying to
+ * fetch here. If that happens, we will enter a second copy of the tuple
+ * into the cache. The first copy will never be referenced again, and
+ * will eventually age out of the cache, so there's no functional problem.
+ * This case is rare enough that it's not worth expending extra cycles to
+ * detect.
+ */
+ relation = table_open(cache->cc_reloid, AccessShareLock);
+
+ scandesc = systable_beginscan(relation,
+ cache->cc_indexoid,
+ IndexScanOK(cache, cur_skey),
+ NULL,
+ nkeys,
+ cur_skey);
+
+ ct = NULL;
+
+ while (HeapTupleIsValid(ntp = systable_getnext(scandesc)))
+ {
+ ct = CatalogCacheCreateEntry_STRUCT(cache, ntp, arguments,
+ hashValue, hashIndex,
+ false);
+ /* immediately set the refcount to 1 */
+ ResourceOwnerEnlargeCatCacheRefs(CurrentResourceOwner);
+ ct->refcount++;
+ ResourceOwnerRememberCatCacheRef(CurrentResourceOwner, &ct->tuple);
+ break; /* assume only one match */
+ }
+
+ systable_endscan(scandesc);
+
+ table_close(relation, AccessShareLock);
+
+ /*
+ * If tuple was not found, we need to build a negative cache entry
+ * containing a fake tuple. The fake tuple has the correct key columns,
+ * but nulls everywhere else.
+ *
+ * In bootstrap mode, we don't build negative entries, because the cache
+ * invalidation mechanism isn't alive and can't clear them if the tuple
+ * gets created later. (Bootstrap doesn't do UPDATEs, so it doesn't need
+ * cache inval for that.)
+ */
+ if (ct == NULL)
+ {
+ if (IsBootstrapProcessingMode())
+ return NULL;
+
+ ct = CatalogCacheCreateEntry_STRUCT(cache, NULL, arguments,
+ hashValue, hashIndex,
+ true);
+
+ CACHE_elog(DEBUG2, "SearchCatCache(%s): Contains %d/%d tuples",
+ cache->cc_relname, cache->cc_ntup, CacheHdr->ch_ntup);
+ CACHE_elog(DEBUG2, "SearchCatCache(%s): put neg entry in bucket %d",
+ cache->cc_relname, hashIndex);
+
+ /*
+ * We are not returning the negative entry to the caller, so leave its
+ * refcount zero.
+ */
+
+ return NULL;
+ }
+
+ CACHE_elog(DEBUG2, "SearchCatCache(%s): Contains %d/%d tuples",
+ cache->cc_relname, cache->cc_ntup, CacheHdr->ch_ntup);
+ CACHE_elog(DEBUG2, "SearchCatCache(%s): put in bucket %d",
+ cache->cc_relname, hashIndex);
+
+#ifdef CATCACHE_STATS
+ cache->cc_newloads++;
+#endif
+
+ return &ct->tuple;
+}
+
/*
* ReleaseCatCache
*
@@ -1900,6 +2158,114 @@ CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp, Datum *arguments,
return ct;
}
+/*
+ * CatalogCacheCreateEntry
+ * Create a new CatCTup entry, copying the given HeapTuple and other
+ * supplied data into it. The new entry initially has refcount 0.
+ */
+static CatCTup *
+CatalogCacheCreateEntry_STRUCT(CatCache *cache, HeapTuple ntp, Datum *arguments,
+ uint32 hashValue, Index hashIndex,
+ bool negative)
+{
+ CatCTup *ct;
+ HeapTuple dtp;
+ MemoryContext oldcxt;
+
+ /* negative entries have no tuple associated */
+ if (ntp)
+ {
+ int i;
+
+ Assert(!negative);
+
+ /*
+ * If there are any out-of-line toasted fields in the tuple, expand
+ * them in-line. This saves cycles during later use of the catcache
+ * entry, and also protects us against the possibility of the toast
+ * tuples being freed before we attempt to fetch them, in case of
+ * something using a slightly stale catcache entry.
+ */
+ if (HeapTupleHasExternal(ntp))
+ dtp = toast_flatten_tuple(ntp, cache->cc_tupdesc);
+ else
+ dtp = ntp;
+
+ /* Allocate memory for CatCTup and the cached tuple in one go */
+ oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
+
+ ct = (CatCTup *) palloc(sizeof(CatCTup) +
+ MAXIMUM_ALIGNOF + dtp->t_len);
+ ct->tuple.t_len = dtp->t_len;
+ ct->tuple.t_self = dtp->t_self;
+ ct->tuple.t_tableOid = dtp->t_tableOid;
+ ct->tuple.t_data = (HeapTupleHeader)
+ MAXALIGN(((char *) ct) + sizeof(CatCTup));
+ /* copy tuple contents */
+ memcpy((char *) ct->tuple.t_data,
+ (const char *) dtp->t_data,
+ dtp->t_len);
+ MemoryContextSwitchTo(oldcxt);
+
+ if (dtp != ntp)
+ heap_freetuple(dtp);
+
+ /* extract keys - they'll point into the tuple if not by-value */
+ for (i = 0; i < cache->cc_nkeys; i++)
+ {
+ Datum atp;
+ bool isnull;
+
+ atp = heap_getattr(&ct->tuple,
+ cache->cc_keyno[i],
+ cache->cc_tupdesc,
+ &isnull);
+ Assert(!isnull);
+ ct->keys[i] = atp;
+ }
+ }
+ else
+ {
+ Assert(negative);
+ oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
+ ct = (CatCTup *) palloc(sizeof(CatCTup));
+
+ /*
+ * Store keys - they'll point into separately allocated memory if not
+ * by-value.
+ */
+ CatCacheCopyKeys(cache->cc_tupdesc, cache->cc_nkeys, cache->cc_keyno,
+ arguments, ct->keys);
+ MemoryContextSwitchTo(oldcxt);
+ }
+
+ /*
+ * Finish initializing the CatCTup header, and add it to the cache's
+ * linked list and counts.
+ */
+ ct->ct_magic = CT_MAGIC;
+ ct->my_cache = cache;
+ ct->c_list = NULL;
+ ct->refcount = 0; /* for the moment */
+ ct->dead = false;
+ ct->negative = negative;
+ ct->hash_value = hashValue;
+
+ dlist_push_head(&cache->cc_bucket[hashIndex], &ct->cache_elem);
+
+ cache->cc_ntup++;
+ CacheHdr->ch_ntup++;
+
+ /*
+ * If the hash table has become too full, enlarge the buckets array. Quite
+ * arbitrarily, we enlarge when fill factor > 2.
+ */
+ if (cache->cc_ntup > cache->cc_nbuckets * 2)
+ RehashCatCache(cache);
+
+ return ct;
+}
+
/*
* Helper routine that frees keys stored in the keys array.
*/
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index 1912b12146..d333f6f3bd 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -1191,6 +1191,17 @@ SearchSysCache2(int cacheId,
return SearchCatCache2(SysCache[cacheId], key1, key2);
}
+HeapTuple
+SearchSysCache2CASTSOURCETARGET(
+ Datum key1, Datum key2)
+{
+ Assert(CASTSOURCETARGET >= 0 && CASTSOURCETARGET < SysCacheSize &&
+ PointerIsValid(SysCache[CASTSOURCETARGET]));
+ Assert(SysCache[CASTSOURCETARGET]->cc_nkeys == 2);
+
+ return SearchCatCache2_STRUCT(SysCache[CASTSOURCETARGET], key1, key2);
+}
+
HeapTuple
SearchSysCache3(int cacheId,
Datum key1, Datum key2, Datum key3)
diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h
index d81e6fabb7..ad866325d4 100644
--- a/src/include/utils/catcache.h
+++ b/src/include/utils/catcache.h
@@ -202,6 +202,8 @@ extern HeapTuple SearchCatCache1(CatCache *cache,
Datum v1);
extern HeapTuple SearchCatCache2(CatCache *cache,
Datum v1, Datum v2);
+extern HeapTuple SearchCatCache2_STRUCT(CatCache *cache,
+ Datum v1, Datum v2);
extern HeapTuple SearchCatCache3(CatCache *cache,
Datum v1, Datum v2, Datum v3);
extern HeapTuple SearchCatCache4(CatCache *cache,
diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h
index 4463ea66be..3196016a49 100644
--- a/src/include/utils/syscache.h
+++ b/src/include/utils/syscache.h
@@ -132,6 +132,8 @@ extern HeapTuple SearchSysCache1(int cacheId,
Datum key1);
extern HeapTuple SearchSysCache2(int cacheId,
Datum key1, Datum key2);
+extern HeapTuple SearchSysCache2CASTSOURCETARGET(
+ Datum key1, Datum key2);
extern HeapTuple SearchSysCache3(int cacheId,
Datum key1, Datum key2, Datum key3);
extern HeapTuple SearchSysCache4(int cacheId,
--
2.36.1