What to name the current heap after pluggable storage / what to rename?
Hi,
The current pluggable table storage patchset [1]/messages/by-id/20180703070645.wchpu5muyto5n647@alap3.anarazel.de introduces the ability
to specify the access method of a table (CREATE TABLE ... USING
"ident"). The patchset currently names the current storage method
(i.e. heapam.c et al) "heap" (whereas e.g. zheap's in named, drumroll,
zheap).
I'm concerned that naming it heap, and the corresponding functions
fitting with that name, will be confusing. There's a lot of functions
that have a heap_ prefix (or similar) that aren't really dependent on
how the storage works, but much more general infrastructure (consider
e.g. heap_create_with_catalog()).
One solution is to just live with the confusion, add a few header
comments to files like src/backend/catalog/heap.c, explaining that
they're more general than heapam.c (and in the patch heapam_handler.c,
which mostly dispatches to heapam.c).
Another approach would be to come up with a different, potentially
witty, name for the current postgres table access method. Then either
rename a few of the heapam.c et functions, or live with the slightly
more confusing names.
Another would be to be aggressive in renaming, and deconflict by
renaming functions like heap_create[_with_catalog] etc to sound more
accurate. I think that has some appeal, because a lot of those names
aren't describing their tasks particularly well.
Greetings,
Andres Freund
[1]: /messages/by-id/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
On 19/12/2018 05:17, Andres Freund wrote:
I'm concerned that naming it heap, and the corresponding functions
fitting with that name, will be confusing. There's a lot of functions
that have a heap_ prefix (or similar) that aren't really dependent on
how the storage works, but much more general infrastructure (consider
e.g. heap_create_with_catalog()).
I'm wondering where the choice of the name "heap" originally came from
and what it refers to. In "The Design of Postgres"[0]http://db.cs.berkeley.edu/papers/ERL-M85-95.pdf, it is said that
"All relations will be stored as heaps (as in [ASTR76]) with an optional
collection of secondary indexes." But ASTR76[1]http://daslab.seas.harvard.edu/reading-group/papers/astrahan-1976.pdf does not mention the
word "heap", so it doesn't appear to refer to any specific method or
algorithm.
The heap is clearly not the tree data structure. Is it meant in the
sense of memory allocation, a place to store a large amount of stuff in
a mostly unorganized way?
[0]: http://db.cs.berkeley.edu/papers/ERL-M85-95.pdf
[1]: http://daslab.seas.harvard.edu/reading-group/papers/astrahan-1976.pdf
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
I'm wondering where the choice of the name "heap" originally came from
and what it refers to.
It seems to me that "heap" is an Oracle word (as explained here[1]https://docs.oracle.com/en/database/oracle/oracle-database/18/tgsql/optimizer-access-paths.html#GUID-53905BCD-3EAD-4B44-8CCC-C442A80647E8).
By default, a table is organized as a heap, which means that the database
places rows where they fit best rather than in a user-specified order.
[1]: https://docs.oracle.com/en/database/oracle/oracle-database/18/tgsql/optimizer-access-paths.html#GUID-53905BCD-3EAD-4B44-8CCC-C442A80647E8
https://docs.oracle.com/en/database/oracle/oracle-database/18/tgsql/optimizer-access-paths.html#GUID-53905BCD-3EAD-4B44-8CCC-C442A80647E8
--
Adoptez l'éco-attitude
N'imprimez ce mail que si c'est vraiment nécessaire
On Wed, Dec 19, 2018 at 7:44 PM Arkhena <Arkhena@gmail.com> wrote:
I'm wondering where the choice of the name "heap" originally came from
and what it refers to.It seems to me that "heap" is an Oracle word (as explained here[1]).
By default, a table is organized as a heap, which means that the database places rows where they fit best rather than in a user-specified order.
No, it's more widely used than that, and we're using it with the
standard meaning AFAIK:
https://docs.microsoft.com/en-us/sql/relational-databases/indexes/heaps-tables-without-clustered-indexes?view=sql-server-2017
http://docs.actian.com/ingres/10.2/index.html#page/DatabaseAdmin/Heap_Storage_Structure.htm
It just means tuples stored in no particular order (as opposed to eg
btree tables, in systems that support those).
--
Thomas Munro
http://www.enterprisedb.com
On 19/12/2018 11:15, Thomas Munro wrote:
It just means tuples stored in no particular order (as opposed to eg
btree tables, in systems that support those).
So would the proposed pluggable storage API allow index-organized base
storage and other non-heap layouts?
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Hi,
On 2018-12-19 12:02:38 +0100, Peter Eisentraut wrote:
On 19/12/2018 11:15, Thomas Munro wrote:
It just means tuples stored in no particular order (as opposed to eg
btree tables, in systems that support those).So would the proposed pluggable storage API allow index-organized base
storage and other non-heap layouts?
Well, that depends on what "non-heap layouts" you're thinking of. I
think there'd be some further work needed to make efficient IOTs
possible, but the patchset gets us a long way to be able to do that in a
pluggable fashion. Biggest problem would probably be extending the
existing index AMs, for secondary indexes, to point to a key wider than
a tid, without loosing too much efficiency.
Greetings,
Andres Freund
Hi,
On 2018-Dec-19, Andres Freund wrote:
Well, that depends on what "non-heap layouts" you're thinking of. I
think there'd be some further work needed to make efficient IOTs
possible, but the patchset gets us a long way to be able to do that in a
pluggable fashion. Biggest problem would probably be extending the
existing index AMs, for secondary indexes, to point to a key wider than
a tid, without loosing too much efficiency.
I think the important question is will we eventually get the option to
do "CREATE TABLE ... STORAGE indexorg" (or whatever name) rather than
are we already getting that feature, and I think the answer is clearly
yes, so we should keep using the word "heap" in the name as the primary
feature of the historical implementation.
The "zheap" name makes it clear that it is still a heap; the main
difference (if I understand correctly) is how does tuple
updating/deletion work.
The current heap implementation is for "non-overwriting storage
management", but that's a mouthful and acronyms based on
"non-overwriting" don't seem great ("noheap" seems a bit silly. Maybe
"nowheap" is better? How about "nosheap"?)
Maybe we can take the easy way and use something like "stdheap".
Or just "nheap".
--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Call it "pile" and "hoard":
https://www.thesaurus.com/browse/heap
https://www.thesaurus.com/browse/pile
https://www.thesaurus.com/browse/hoard
ср, 19 дек. 2018 г. в 07:17, Andres Freund <andres@anarazel.de>:
Hi,
The current pluggable table storage patchset [1] introduces the ability
to specify the access method of a table (CREATE TABLE ... USING
"ident"). The patchset currently names the current storage method
(i.e. heapam.c et al) "heap" (whereas e.g. zheap's in named, drumroll,
zheap).I'm concerned that naming it heap, and the corresponding functions
fitting with that name, will be confusing. There's a lot of functions
that have a heap_ prefix (or similar) that aren't really dependent on
how the storage works, but much more general infrastructure (consider
e.g. heap_create_with_catalog()).One solution is to just live with the confusion, add a few header
comments to files like src/backend/catalog/heap.c, explaining that
they're more general than heapam.c (and in the patch heapam_handler.c,
which mostly dispatches to heapam.c).Another approach would be to come up with a different, potentially
witty, name for the current postgres table access method. Then either
rename a few of the heapam.c et functions, or live with the slightly
more confusing names.Another would be to be aggressive in renaming, and deconflict by
renaming functions like heap_create[_with_catalog] etc to sound more
accurate. I think that has some appeal, because a lot of those names
aren't describing their tasks particularly well.Greetings,
Andres Freund
[1]
/messages/by-id/20180703070645.wchpu5muyto5n647@alap3.anarazel.de--
Darafei Praliaskouski
Support me: http://patreon.com/komzpa
On Wed, Dec 19, 2018 at 08:32:28AM -0300, Alvaro Herrera wrote:
Hi,
On 2018-Dec-19, Andres Freund wrote:
Well, that depends on what "non-heap layouts" you're thinking of. I
think there'd be some further work needed to make efficient IOTs
possible, but the patchset gets us a long way to be able to do that in a
pluggable fashion. Biggest problem would probably be extending the
existing index AMs, for secondary indexes, to point to a key wider than
a tid, without loosing too much efficiency.I think the important question is will we eventually get the option to
do "CREATE TABLE ... STORAGE indexorg" (or whatever name) rather than
are we already getting that feature, and I think the answer is clearly
yes, so we should keep using the word "heap" in the name as the primary
feature of the historical implementation.The "zheap" name makes it clear that it is still a heap; the main
difference (if I understand correctly) is how does tuple
updating/deletion work.The current heap implementation is for "non-overwriting storage
management", but that's a mouthful and acronyms based on
"non-overwriting" don't seem great ("noheap" seems a bit silly. Maybe
"nowheap" is better? How about "nosheap"?)Maybe we can take the easy way and use something like "stdheap".
Or just "nheap".
oheap for "original?"
Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
On Tue, Dec 18, 2018 at 11:17 PM Andres Freund <andres@anarazel.de> wrote:
The current pluggable table storage patchset [1] introduces the ability
to specify the access method of a table (CREATE TABLE ... USING
"ident"). The patchset currently names the current storage method
(i.e. heapam.c et al) "heap" (whereas e.g. zheap's in named, drumroll,
zheap).
I vote for calling the current heap "heap" - i.e. what the patchset is
currently doing. As others have already noted, that's a perfectly
good word for storing stuff in no particular order, and it's also a
term with a very long history. If we call it "oheap" or "pile" or
something based on a clever pun, then we'll just be making users learn
a new word for, as far as I can see, no real benefit.
Another would be to be aggressive in renaming, and deconflict by
renaming functions like heap_create[_with_catalog] etc to sound more
accurate. I think that has some appeal, because a lot of those names
aren't describing their tasks particularly well.
I like that option.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On 19 Dec 2018, at 20:21, Robert Haas <robertmhaas@gmail.com> wrote:
I vote for calling the current heap "heap" - i.e. what the patchset is
currently doing. As others have already noted, that's a perfectly
good word for storing stuff in no particular order, and it's also a
term with a very long history.
FWIW, +1
cheers ./daniel
Hi,
On 2018-12-19 14:21:29 -0500, Robert Haas wrote:
On Tue, Dec 18, 2018 at 11:17 PM Andres Freund <andres@anarazel.de> wrote:
Another would be to be aggressive in renaming, and deconflict by
renaming functions like heap_create[_with_catalog] etc to sound more
accurate. I think that has some appeal, because a lot of those names
aren't describing their tasks particularly well.I like that option.
I'd like to start doing that by moving the functions in the following
heapam.h block elsewhere:
/* in heap/heapam.c */
extern Relation relation_open(Oid relationId, LOCKMODE lockmode);
extern Relation try_relation_open(Oid relationId, LOCKMODE lockmode);
extern Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode);
extern Relation relation_openrv_extended(const RangeVar *relation,
LOCKMODE lockmode, bool missing_ok);
extern void relation_close(Relation relation, LOCKMODE lockmode);
extern Relation heap_open(Oid relationId, LOCKMODE lockmode);
extern Relation heap_openrv(const RangeVar *relation, LOCKMODE lockmode);
extern Relation heap_openrv_extended(const RangeVar *relation,
LOCKMODE lockmode, bool missing_ok);
ISTM that the first block would best belong into new files like
access/rel[ation].h and access/common/rel[ation].h. I think the second
set should be renamed to be table_open() (with backward compat
redirects, there's way way too many references) and should go into
access/table.h access/table/table.c alongside tableam.[ch], but I could
also see just putting them into relation.[ch].
Comments?
Greetings,
Andres Freund
On Fri, Jan 11, 2019 at 11:05 AM Andres Freund <andres@anarazel.de> wrote:
Hi,
On 2018-12-19 14:21:29 -0500, Robert Haas wrote:
On Tue, Dec 18, 2018 at 11:17 PM Andres Freund <andres@anarazel.de>
wrote:
Another would be to be aggressive in renaming, and deconflict by
renaming functions like heap_create[_with_catalog] etc to sound more
accurate. I think that has some appeal, because a lot of those names
aren't describing their tasks particularly well.I like that option.
I'd like to start doing that by moving the functions in the following
heapam.h block elsewhere:/* in heap/heapam.c */
extern Relation relation_open(Oid relationId, LOCKMODE lockmode);
extern Relation try_relation_open(Oid relationId, LOCKMODE lockmode);
extern Relation relation_openrv(const RangeVar *relation, LOCKMODE
lockmode);
extern Relation relation_openrv_extended(const RangeVar *relation,
LOCKMODE lockmode, bool
missing_ok);
extern void relation_close(Relation relation, LOCKMODE lockmode);extern Relation heap_open(Oid relationId, LOCKMODE lockmode);
extern Relation heap_openrv(const RangeVar *relation, LOCKMODE lockmode);
extern Relation heap_openrv_extended(const RangeVar *relation,
LOCKMODE lockmode, bool
missing_ok);ISTM that the first block would best belong into new files like
access/rel[ation].h and access/common/rel[ation].h. I think the second
set should be renamed to be table_open() (with backward compat
redirects, there's way way too many references) and should go into
access/table.h access/table/table.c alongside tableam.[ch], but I could
also see just putting them into relation.[ch].Comments?
Yes, that will be good.
Regards,
Haribabu Kommi
Fujitsu Australia
On Thu, Jan 10, 2019 at 7:05 PM Andres Freund <andres@anarazel.de> wrote:
ISTM that the first block would best belong into new files like
access/rel[ation].h and access/common/rel[ation].h.
+1.
I think the second
set should be renamed to be table_open() (with backward compat
redirects, there's way way too many references) and should go into
access/table.h access/table/table.c alongside tableam.[ch],
Sounds reasonable.
but I could
also see just putting them into relation.[ch].
I would view that as a less-preferred alternative, but not crazy.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Hi,
On 2019-01-11 12:01:36 -0500, Robert Haas wrote:
On Thu, Jan 10, 2019 at 7:05 PM Andres Freund <andres@anarazel.de> wrote:
ISTM that the first block would best belong into new files like
access/rel[ation].h and access/common/rel[ation].h.+1.
I think the second
set should be renamed to be table_open() (with backward compat
redirects, there's way way too many references) and should go into
access/table.h access/table/table.c alongside tableam.[ch],Sounds reasonable.
but I could
also see just putting them into relation.[ch].I would view that as a less-preferred alternative, but not crazy.
Here's a set of patches. Not commit quality, but enough to discuss.
The first patch, the only really interesting one, splits out
relation_(open|openrv|openrv_extended|close) into access/relation.h and access/common/relation.c
and
heap_(open|openrv|openrv_extended|close) into access/table.h and access/table/table.c
It's worthwhile to note that there's another header named
nodes/relation.h. But there's also utils/rel.h, so I couldn't think of a
another good name.
I'm basically thinking that table.h, even in the post pluggable storage
world, should not contain lower level functionality like dispatching
into table-am (that'll reside in tableam.h). But e.g. a
simple_table_(insert|update|delete) could live there, as well as
potentially some other heap_ functionality strewn around the backend.
I made table.h not include relation.h, which means that a few files
might need both. I'm not sure that's the right choice, but it seems
easier to extend that later if shows to be painful, than to do the
reverse.
I've left the following in table.h:
/*
* heap_ used to be the prefix for these routines, and a lot of code will just
* continue to work without adaptions after the introduction of pluggable
* storage, therefore just map these names.
*/
#define heap_open(r, l) table_open(r, l)
#define heap_openrv(r, l) table_openrv(r, l)
#define heap_openrv_extended(r, l, m) table_openrv_extended(r, l, m)
#define heap_close(r, l) table_close(r, l)
and I think we should leave that in there for the forseeable future.
Patches 0002 replaces includes of heapam.h with relation.h / table.h
where appropriate. 0003 renames all in-core references of
heap_(open|openrv|openrv_extended|close) with the table_ variant.
Does this seem basically sensible? Different ideas?
Greetings,
Andres Freund
Attachments:
v1-0001-WIP-Introduce-access-table.h-access-relation.h.patchtext/x-diff; charset=us-asciiDownload
From e1289c76cb0e2208a8544d9f5fbd8f586d078081 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Sat, 12 Jan 2019 17:14:49 -0800
Subject: [PATCH v1 1/3] WIP: Introduce access/table.h access/relation.h.
---
src/backend/access/Makefile | 2 +-
src/backend/access/common/Makefile | 2 +-
src/backend/access/common/relation.c | 216 +++++++++++++
src/backend/access/heap/heapam.c | 289 ------------------
src/backend/access/{common => table}/Makefile | 9 +-
src/backend/access/table/table.c | 137 +++++++++
src/include/access/heapam.h | 16 +-
src/include/access/relation.h | 29 ++
src/include/access/table.h | 38 +++
9 files changed, 428 insertions(+), 310 deletions(-)
create mode 100644 src/backend/access/common/relation.c
copy src/backend/access/{common => table}/Makefile (56%)
create mode 100644 src/backend/access/table/table.c
create mode 100644 src/include/access/relation.h
create mode 100644 src/include/access/table.h
diff --git a/src/backend/access/Makefile b/src/backend/access/Makefile
index bd93a6a8d1e..0880e0a8bbb 100644
--- a/src/backend/access/Makefile
+++ b/src/backend/access/Makefile
@@ -9,6 +9,6 @@ top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
SUBDIRS = brin common gin gist hash heap index nbtree rmgrdesc spgist \
- tablesample transam
+ table tablesample transam
include $(top_srcdir)/src/backend/common.mk
diff --git a/src/backend/access/common/Makefile b/src/backend/access/common/Makefile
index f130b6e3501..d4695043377 100644
--- a/src/backend/access/common/Makefile
+++ b/src/backend/access/common/Makefile
@@ -13,6 +13,6 @@ top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
OBJS = bufmask.o heaptuple.o indextuple.o printsimple.o printtup.o \
- reloptions.o scankey.o session.o tupconvert.o tupdesc.o
+ relation.o reloptions.o scankey.o session.o tupconvert.o tupdesc.o
include $(top_srcdir)/src/backend/common.mk
diff --git a/src/backend/access/common/relation.c b/src/backend/access/common/relation.c
new file mode 100644
index 00000000000..4b65a47f6f9
--- /dev/null
+++ b/src/backend/access/common/relation.c
@@ -0,0 +1,216 @@
+/*-------------------------------------------------------------------------
+ *
+ * relation.c
+ * generic relation related code
+ *
+ * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *
+ * IDENTIFICATION
+ * src/backend/access/common/relation.c
+ *
+ * NOTES
+ * This file contains relation_ routines that implement access to relations
+ * (tables, indexes, etc). Support that's specific to subtypes of relations
+ * should go into their respective headers, not here.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "postgres.h"
+
+#include "access/relation.h"
+#include "access/xact.h"
+#include "catalog/namespace.h"
+#include "miscadmin.h"
+#include "pgstat.h"
+#include "storage/lmgr.h"
+#include "utils/inval.h"
+#include "utils/syscache.h"
+
+/* ----------------
+ * relation_open - open any relation by relation OID
+ *
+ * If lockmode is not "NoLock", the specified kind of lock is
+ * obtained on the relation. (Generally, NoLock should only be
+ * used if the caller knows it has some appropriate lock on the
+ * relation already.)
+ *
+ * An error is raised if the relation does not exist.
+ *
+ * NB: a "relation" is anything with a pg_class entry. The caller is
+ * expected to check whether the relkind is something it can handle.
+ * ----------------
+ */
+Relation
+relation_open(Oid relationId, LOCKMODE lockmode)
+{
+ Relation r;
+
+ Assert(lockmode >= NoLock && lockmode < MAX_LOCKMODES);
+
+ /* Get the lock before trying to open the relcache entry */
+ if (lockmode != NoLock)
+ LockRelationOid(relationId, lockmode);
+
+ /* The relcache does all the real work... */
+ r = RelationIdGetRelation(relationId);
+
+ if (!RelationIsValid(r))
+ elog(ERROR, "could not open relation with OID %u", relationId);
+
+ /*
+ * If we didn't get the lock ourselves, assert that caller holds one,
+ * except in bootstrap mode where no locks are used.
+ */
+ Assert(lockmode != NoLock ||
+ IsBootstrapProcessingMode() ||
+ CheckRelationLockedByMe(r, AccessShareLock, true));
+
+ /* Make note that we've accessed a temporary relation */
+ if (RelationUsesLocalBuffers(r))
+ MyXactFlags |= XACT_FLAGS_ACCESSEDTEMPREL;
+
+ pgstat_initstats(r);
+
+ return r;
+}
+
+/* ----------------
+ * try_relation_open - open any relation by relation OID
+ *
+ * Same as relation_open, except return NULL instead of failing
+ * if the relation does not exist.
+ * ----------------
+ */
+Relation
+try_relation_open(Oid relationId, LOCKMODE lockmode)
+{
+ Relation r;
+
+ Assert(lockmode >= NoLock && lockmode < MAX_LOCKMODES);
+
+ /* Get the lock first */
+ if (lockmode != NoLock)
+ LockRelationOid(relationId, lockmode);
+
+ /*
+ * Now that we have the lock, probe to see if the relation really exists
+ * or not.
+ */
+ if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(relationId)))
+ {
+ /* Release useless lock */
+ if (lockmode != NoLock)
+ UnlockRelationOid(relationId, lockmode);
+
+ return NULL;
+ }
+
+ /* Should be safe to do a relcache load */
+ r = RelationIdGetRelation(relationId);
+
+ if (!RelationIsValid(r))
+ elog(ERROR, "could not open relation with OID %u", relationId);
+
+ /* If we didn't get the lock ourselves, assert that caller holds one */
+ Assert(lockmode != NoLock ||
+ CheckRelationLockedByMe(r, AccessShareLock, true));
+
+ /* Make note that we've accessed a temporary relation */
+ if (RelationUsesLocalBuffers(r))
+ MyXactFlags |= XACT_FLAGS_ACCESSEDTEMPREL;
+
+ pgstat_initstats(r);
+
+ return r;
+}
+
+/* ----------------
+ * relation_openrv - open any relation specified by a RangeVar
+ *
+ * Same as relation_open, but the relation is specified by a RangeVar.
+ * ----------------
+ */
+Relation
+relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
+{
+ Oid relOid;
+
+ /*
+ * Check for shared-cache-inval messages before trying to open the
+ * relation. This is needed even if we already hold a lock on the
+ * relation, because GRANT/REVOKE are executed without taking any lock on
+ * the target relation, and we want to be sure we see current ACL
+ * information. We can skip this if asked for NoLock, on the assumption
+ * that such a call is not the first one in the current command, and so we
+ * should be reasonably up-to-date already. (XXX this all could stand to
+ * be redesigned, but for the moment we'll keep doing this like it's been
+ * done historically.)
+ */
+ if (lockmode != NoLock)
+ AcceptInvalidationMessages();
+
+ /* Look up and lock the appropriate relation using namespace search */
+ relOid = RangeVarGetRelid(relation, lockmode, false);
+
+ /* Let relation_open do the rest */
+ return relation_open(relOid, NoLock);
+}
+
+/* ----------------
+ * relation_openrv_extended - open any relation specified by a RangeVar
+ *
+ * Same as relation_openrv, but with an additional missing_ok argument
+ * allowing a NULL return rather than an error if the relation is not
+ * found. (Note that some other causes, such as permissions problems,
+ * will still result in an ereport.)
+ * ----------------
+ */
+Relation
+relation_openrv_extended(const RangeVar *relation, LOCKMODE lockmode,
+ bool missing_ok)
+{
+ Oid relOid;
+
+ /*
+ * Check for shared-cache-inval messages before trying to open the
+ * relation. See comments in relation_openrv().
+ */
+ if (lockmode != NoLock)
+ AcceptInvalidationMessages();
+
+ /* Look up and lock the appropriate relation using namespace search */
+ relOid = RangeVarGetRelid(relation, lockmode, missing_ok);
+
+ /* Return NULL on not-found */
+ if (!OidIsValid(relOid))
+ return NULL;
+
+ /* Let relation_open do the rest */
+ return relation_open(relOid, NoLock);
+}
+
+/* ----------------
+ * relation_close - close any relation
+ *
+ * If lockmode is not "NoLock", we then release the specified lock.
+ *
+ * Note that it is often sensible to hold a lock beyond relation_close;
+ * in that case, the lock is released automatically at xact end.
+ * ----------------
+ */
+void
+relation_close(Relation relation, LOCKMODE lockmode)
+{
+ LockRelId relid = relation->rd_lockInfo.lockRelId;
+
+ Assert(lockmode >= NoLock && lockmode < MAX_LOCKMODES);
+
+ /* The relcache does the real work... */
+ RelationClose(relation);
+
+ if (lockmode != NoLock)
+ UnlockRelationId(&relid, lockmode);
+}
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 3a184f2eccb..3415a697398 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -12,12 +12,6 @@
*
*
* INTERFACE ROUTINES
- * relation_open - open any relation by relation OID
- * relation_openrv - open any relation specified by a RangeVar
- * relation_close - close any relation
- * heap_open - open a heap relation by relation OID
- * heap_openrv - open a heap relation specified by a RangeVar
- * heap_close - (now just a macro for relation_close)
* heap_beginscan - begin relation scan
* heap_rescan - restart a relation scan
* heap_endscan - end relation scan
@@ -56,7 +50,6 @@
#include "access/xloginsert.h"
#include "access/xlogutils.h"
#include "catalog/catalog.h"
-#include "catalog/namespace.h"
#include "catalog/index.h"
#include "miscadmin.h"
#include "pgstat.h"
@@ -74,7 +67,6 @@
#include "utils/lsyscache.h"
#include "utils/relcache.h"
#include "utils/snapmgr.h"
-#include "utils/syscache.h"
#include "utils/tqual.h"
#include "utils/memutils.h"
#include "nodes/execnodes.h"
@@ -1107,287 +1099,6 @@ fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
* ----------------------------------------------------------------
*/
-/* ----------------
- * relation_open - open any relation by relation OID
- *
- * If lockmode is not "NoLock", the specified kind of lock is
- * obtained on the relation. (Generally, NoLock should only be
- * used if the caller knows it has some appropriate lock on the
- * relation already.)
- *
- * An error is raised if the relation does not exist.
- *
- * NB: a "relation" is anything with a pg_class entry. The caller is
- * expected to check whether the relkind is something it can handle.
- * ----------------
- */
-Relation
-relation_open(Oid relationId, LOCKMODE lockmode)
-{
- Relation r;
-
- Assert(lockmode >= NoLock && lockmode < MAX_LOCKMODES);
-
- /* Get the lock before trying to open the relcache entry */
- if (lockmode != NoLock)
- LockRelationOid(relationId, lockmode);
-
- /* The relcache does all the real work... */
- r = RelationIdGetRelation(relationId);
-
- if (!RelationIsValid(r))
- elog(ERROR, "could not open relation with OID %u", relationId);
-
- /*
- * If we didn't get the lock ourselves, assert that caller holds one,
- * except in bootstrap mode where no locks are used.
- */
- Assert(lockmode != NoLock ||
- IsBootstrapProcessingMode() ||
- CheckRelationLockedByMe(r, AccessShareLock, true));
-
- /* Make note that we've accessed a temporary relation */
- if (RelationUsesLocalBuffers(r))
- MyXactFlags |= XACT_FLAGS_ACCESSEDTEMPREL;
-
- pgstat_initstats(r);
-
- return r;
-}
-
-/* ----------------
- * try_relation_open - open any relation by relation OID
- *
- * Same as relation_open, except return NULL instead of failing
- * if the relation does not exist.
- * ----------------
- */
-Relation
-try_relation_open(Oid relationId, LOCKMODE lockmode)
-{
- Relation r;
-
- Assert(lockmode >= NoLock && lockmode < MAX_LOCKMODES);
-
- /* Get the lock first */
- if (lockmode != NoLock)
- LockRelationOid(relationId, lockmode);
-
- /*
- * Now that we have the lock, probe to see if the relation really exists
- * or not.
- */
- if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(relationId)))
- {
- /* Release useless lock */
- if (lockmode != NoLock)
- UnlockRelationOid(relationId, lockmode);
-
- return NULL;
- }
-
- /* Should be safe to do a relcache load */
- r = RelationIdGetRelation(relationId);
-
- if (!RelationIsValid(r))
- elog(ERROR, "could not open relation with OID %u", relationId);
-
- /* If we didn't get the lock ourselves, assert that caller holds one */
- Assert(lockmode != NoLock ||
- CheckRelationLockedByMe(r, AccessShareLock, true));
-
- /* Make note that we've accessed a temporary relation */
- if (RelationUsesLocalBuffers(r))
- MyXactFlags |= XACT_FLAGS_ACCESSEDTEMPREL;
-
- pgstat_initstats(r);
-
- return r;
-}
-
-/* ----------------
- * relation_openrv - open any relation specified by a RangeVar
- *
- * Same as relation_open, but the relation is specified by a RangeVar.
- * ----------------
- */
-Relation
-relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
-{
- Oid relOid;
-
- /*
- * Check for shared-cache-inval messages before trying to open the
- * relation. This is needed even if we already hold a lock on the
- * relation, because GRANT/REVOKE are executed without taking any lock on
- * the target relation, and we want to be sure we see current ACL
- * information. We can skip this if asked for NoLock, on the assumption
- * that such a call is not the first one in the current command, and so we
- * should be reasonably up-to-date already. (XXX this all could stand to
- * be redesigned, but for the moment we'll keep doing this like it's been
- * done historically.)
- */
- if (lockmode != NoLock)
- AcceptInvalidationMessages();
-
- /* Look up and lock the appropriate relation using namespace search */
- relOid = RangeVarGetRelid(relation, lockmode, false);
-
- /* Let relation_open do the rest */
- return relation_open(relOid, NoLock);
-}
-
-/* ----------------
- * relation_openrv_extended - open any relation specified by a RangeVar
- *
- * Same as relation_openrv, but with an additional missing_ok argument
- * allowing a NULL return rather than an error if the relation is not
- * found. (Note that some other causes, such as permissions problems,
- * will still result in an ereport.)
- * ----------------
- */
-Relation
-relation_openrv_extended(const RangeVar *relation, LOCKMODE lockmode,
- bool missing_ok)
-{
- Oid relOid;
-
- /*
- * Check for shared-cache-inval messages before trying to open the
- * relation. See comments in relation_openrv().
- */
- if (lockmode != NoLock)
- AcceptInvalidationMessages();
-
- /* Look up and lock the appropriate relation using namespace search */
- relOid = RangeVarGetRelid(relation, lockmode, missing_ok);
-
- /* Return NULL on not-found */
- if (!OidIsValid(relOid))
- return NULL;
-
- /* Let relation_open do the rest */
- return relation_open(relOid, NoLock);
-}
-
-/* ----------------
- * relation_close - close any relation
- *
- * If lockmode is not "NoLock", we then release the specified lock.
- *
- * Note that it is often sensible to hold a lock beyond relation_close;
- * in that case, the lock is released automatically at xact end.
- * ----------------
- */
-void
-relation_close(Relation relation, LOCKMODE lockmode)
-{
- LockRelId relid = relation->rd_lockInfo.lockRelId;
-
- Assert(lockmode >= NoLock && lockmode < MAX_LOCKMODES);
-
- /* The relcache does the real work... */
- RelationClose(relation);
-
- if (lockmode != NoLock)
- UnlockRelationId(&relid, lockmode);
-}
-
-
-/* ----------------
- * heap_open - open a heap relation by relation OID
- *
- * This is essentially relation_open plus check that the relation
- * is not an index nor a composite type. (The caller should also
- * check that it's not a view or foreign table before assuming it has
- * storage.)
- * ----------------
- */
-Relation
-heap_open(Oid relationId, LOCKMODE lockmode)
-{
- Relation r;
-
- r = relation_open(relationId, lockmode);
-
- if (r->rd_rel->relkind == RELKIND_INDEX ||
- r->rd_rel->relkind == RELKIND_PARTITIONED_INDEX)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is an index",
- RelationGetRelationName(r))));
- else if (r->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is a composite type",
- RelationGetRelationName(r))));
-
- return r;
-}
-
-/* ----------------
- * heap_openrv - open a heap relation specified
- * by a RangeVar node
- *
- * As above, but relation is specified by a RangeVar.
- * ----------------
- */
-Relation
-heap_openrv(const RangeVar *relation, LOCKMODE lockmode)
-{
- Relation r;
-
- r = relation_openrv(relation, lockmode);
-
- if (r->rd_rel->relkind == RELKIND_INDEX ||
- r->rd_rel->relkind == RELKIND_PARTITIONED_INDEX)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is an index",
- RelationGetRelationName(r))));
- else if (r->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is a composite type",
- RelationGetRelationName(r))));
-
- return r;
-}
-
-/* ----------------
- * heap_openrv_extended - open a heap relation specified
- * by a RangeVar node
- *
- * As above, but optionally return NULL instead of failing for
- * relation-not-found.
- * ----------------
- */
-Relation
-heap_openrv_extended(const RangeVar *relation, LOCKMODE lockmode,
- bool missing_ok)
-{
- Relation r;
-
- r = relation_openrv_extended(relation, lockmode, missing_ok);
-
- if (r)
- {
- if (r->rd_rel->relkind == RELKIND_INDEX ||
- r->rd_rel->relkind == RELKIND_PARTITIONED_INDEX)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is an index",
- RelationGetRelationName(r))));
- else if (r->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is a composite type",
- RelationGetRelationName(r))));
- }
-
- return r;
-}
-
/* ----------------
* heap_beginscan - begin relation scan
diff --git a/src/backend/access/common/Makefile b/src/backend/access/table/Makefile
similarity index 56%
copy from src/backend/access/common/Makefile
copy to src/backend/access/table/Makefile
index f130b6e3501..ac1de5a52b0 100644
--- a/src/backend/access/common/Makefile
+++ b/src/backend/access/table/Makefile
@@ -1,18 +1,17 @@
#-------------------------------------------------------------------------
#
# Makefile--
-# Makefile for access/common
+# Makefile for access/table
#
# IDENTIFICATION
-# src/backend/access/common/Makefile
+# src/backend/access/table/Makefile
#
#-------------------------------------------------------------------------
-subdir = src/backend/access/common
+subdir = src/backend/access/table
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
-OBJS = bufmask.o heaptuple.o indextuple.o printsimple.o printtup.o \
- reloptions.o scankey.o session.o tupconvert.o tupdesc.o
+OBJS = table.o
include $(top_srcdir)/src/backend/common.mk
diff --git a/src/backend/access/table/table.c b/src/backend/access/table/table.c
new file mode 100644
index 00000000000..dad86ee37ba
--- /dev/null
+++ b/src/backend/access/table/table.c
@@ -0,0 +1,137 @@
+/*-------------------------------------------------------------------------
+ *
+ * table.c
+ * Generic routines for table related code.
+ *
+ * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *
+ * IDENTIFICATION
+ * src/backend/access/table/table.c
+ *
+ *
+ * NOTES
+ * This file contains table_ routines that implement access to tables (in
+ * contrast to other relation types like indexes) that are independent of
+ * individual table access methods.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "postgres.h"
+
+#include "access/relation.h"
+#include "access/table.h"
+#include "access/xact.h"
+#include "storage/lmgr.h"
+
+
+/* ----------------
+ * table_open - open a table relation by relation OID
+ *
+ * This is essentially relation_open plus check that the relation
+ * is not an index nor a composite type. (The caller should also
+ * check that it's not a view or foreign table before assuming it has
+ * storage.)
+ * ----------------
+ */
+Relation
+table_open(Oid relationId, LOCKMODE lockmode)
+{
+ Relation r;
+
+ r = relation_open(relationId, lockmode);
+
+ if (r->rd_rel->relkind == RELKIND_INDEX ||
+ r->rd_rel->relkind == RELKIND_PARTITIONED_INDEX)
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("\"%s\" is an index",
+ RelationGetRelationName(r))));
+ else if (r->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("\"%s\" is a composite type",
+ RelationGetRelationName(r))));
+
+ return r;
+}
+
+/* ----------------
+ * table_openrv - open a table relation specified
+ * by a RangeVar node
+ *
+ * As above, but relation is specified by a RangeVar.
+ * ----------------
+ */
+Relation
+table_openrv(const RangeVar *relation, LOCKMODE lockmode)
+{
+ Relation r;
+
+ r = relation_openrv(relation, lockmode);
+
+ if (r->rd_rel->relkind == RELKIND_INDEX ||
+ r->rd_rel->relkind == RELKIND_PARTITIONED_INDEX)
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("\"%s\" is an index",
+ RelationGetRelationName(r))));
+ else if (r->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("\"%s\" is a composite type",
+ RelationGetRelationName(r))));
+
+ return r;
+}
+
+/* ----------------
+ * table_openrv_extended - open a table relation specified
+ * by a RangeVar node
+ *
+ * As above, but optionally return NULL instead of failing for
+ * relation-not-found.
+ * ----------------
+ */
+Relation
+table_openrv_extended(const RangeVar *relation, LOCKMODE lockmode,
+ bool missing_ok)
+{
+ Relation r;
+
+ r = relation_openrv_extended(relation, lockmode, missing_ok);
+
+ if (r)
+ {
+ if (r->rd_rel->relkind == RELKIND_INDEX ||
+ r->rd_rel->relkind == RELKIND_PARTITIONED_INDEX)
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("\"%s\" is an index",
+ RelationGetRelationName(r))));
+ else if (r->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("\"%s\" is a composite type",
+ RelationGetRelationName(r))));
+ }
+
+ return r;
+}
+
+/* ----------------
+ * table_close - close a table
+ *
+ * If lockmode is not "NoLock", we then release the specified lock.
+ *
+ * Note that it is often sensible to hold a lock beyond relation_close;
+ * in that case, the lock is released automatically at xact end.
+ * ----------------
+ */
+void
+table_close(Relation relation, LOCKMODE lockmode)
+{
+ relation_close(relation, lockmode);
+}
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
index cf2ac151241..f80dc416eb1 100644
--- a/src/include/access/heapam.h
+++ b/src/include/access/heapam.h
@@ -14,8 +14,10 @@
#ifndef HEAPAM_H
#define HEAPAM_H
+#include "access/relation.h"
#include "access/sdir.h"
#include "access/skey.h"
+#include "access/table.h"
#include "nodes/lockoptions.h"
#include "nodes/primnodes.h"
#include "storage/bufpage.h"
@@ -67,20 +69,6 @@ typedef struct HeapUpdateFailureData
* ----------------
*/
-/* in heap/heapam.c */
-extern Relation relation_open(Oid relationId, LOCKMODE lockmode);
-extern Relation try_relation_open(Oid relationId, LOCKMODE lockmode);
-extern Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode);
-extern Relation relation_openrv_extended(const RangeVar *relation,
- LOCKMODE lockmode, bool missing_ok);
-extern void relation_close(Relation relation, LOCKMODE lockmode);
-
-extern Relation heap_open(Oid relationId, LOCKMODE lockmode);
-extern Relation heap_openrv(const RangeVar *relation, LOCKMODE lockmode);
-extern Relation heap_openrv_extended(const RangeVar *relation,
- LOCKMODE lockmode, bool missing_ok);
-
-#define heap_close(r,l) relation_close(r,l)
/* struct definitions appear in relscan.h */
typedef struct HeapScanDescData *HeapScanDesc;
diff --git a/src/include/access/relation.h b/src/include/access/relation.h
new file mode 100644
index 00000000000..1d46e52eacc
--- /dev/null
+++ b/src/include/access/relation.h
@@ -0,0 +1,29 @@
+/*-------------------------------------------------------------------------
+ *
+ * relation.h
+ * POSTGRES relation interface.
+ *
+ *
+ * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/access/relation.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef ACCESS_RELATION_H
+#define ACCESS_RELATION_H
+
+#include "nodes/primnodes.h"
+#include "utils/relcache.h"
+#include "storage/lockdefs.h"
+
+
+extern Relation relation_open(Oid relationId, LOCKMODE lockmode);
+extern Relation try_relation_open(Oid relationId, LOCKMODE lockmode);
+extern Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode);
+extern Relation relation_openrv_extended(const RangeVar *relation,
+ LOCKMODE lockmode, bool missing_ok);
+extern void relation_close(Relation relation, LOCKMODE lockmode);
+
+#endif /* ACCESS_RELATION_H */
diff --git a/src/include/access/table.h b/src/include/access/table.h
new file mode 100644
index 00000000000..453f4dd6a1a
--- /dev/null
+++ b/src/include/access/table.h
@@ -0,0 +1,38 @@
+/*-------------------------------------------------------------------------
+ *
+ * table.h
+ * Generic routines for table related code.
+ *
+ *
+ * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/access/table.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef TABLE_H
+#define TABLE_H
+
+#include "nodes/primnodes.h"
+#include "utils/relcache.h"
+#include "storage/lockdefs.h"
+
+
+extern Relation table_open(Oid relationId, LOCKMODE lockmode);
+extern Relation table_openrv(const RangeVar *relation, LOCKMODE lockmode);
+extern Relation table_openrv_extended(const RangeVar *relation,
+ LOCKMODE lockmode, bool missing_ok);
+extern void table_close(Relation relation, LOCKMODE lockmode);
+
+/*
+ * heap_ used to be the prefix for these routines, and a lot of code will just
+ * continue to work without adaptions after the introduction of pluggable
+ * storage, therefore just map these names.
+ */
+#define heap_open(r, l) table_open(r, l)
+#define heap_openrv(r, l) table_openrv(r, l)
+#define heap_openrv_extended(r, l, m) table_openrv_extended(r, l, m)
+#define heap_close(r, l) table_close(r, l)
+
+#endif /* TABLE_H */
--
2.18.0.rc2.dirty
v1-0002-Replace-heapam.h-includes-with-relation.h-table.h.patchtext/x-diff; charset=us-asciiDownload
From 34b55cc16fdcb421b2a96ee8bc12d9c5ff8e8643 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Sat, 12 Jan 2019 22:05:46 -0800
Subject: [PATCH v1 2/3] Replace heapam.h includes with relation.h / table.h
where applicable.
Author:
Reviewed-By:
Discussion: https://postgr.es/m/
Backpatch:
---
contrib/dblink/dblink.c | 3 ++-
contrib/file_fdw/file_fdw.c | 2 +-
contrib/pageinspect/btreefuncs.c | 2 +-
contrib/pageinspect/heapfuncs.c | 2 +-
contrib/pageinspect/rawpage.c | 2 +-
contrib/pg_freespacemap/pg_freespacemap.c | 2 +-
contrib/pg_prewarm/autoprewarm.c | 2 +-
contrib/pg_prewarm/pg_prewarm.c | 2 +-
contrib/pgstattuple/pgstatapprox.c | 4 ++--
contrib/pgstattuple/pgstatindex.c | 3 ++-
contrib/postgres_fdw/deparse.c | 2 +-
contrib/postgres_fdw/postgres_fdw.c | 2 +-
contrib/sepgsql/database.c | 2 +-
contrib/sepgsql/label.c | 2 +-
contrib/sepgsql/proc.c | 2 +-
contrib/sepgsql/relation.c | 2 +-
contrib/sepgsql/schema.c | 2 +-
src/backend/access/brin/brin.c | 3 ++-
src/backend/catalog/catalog.c | 2 +-
src/backend/catalog/dependency.c | 2 +-
src/backend/catalog/heap.c | 3 ++-
src/backend/catalog/objectaddress.c | 3 ++-
src/backend/catalog/partition.c | 2 +-
src/backend/catalog/pg_aggregate.c | 2 +-
src/backend/catalog/pg_collation.c | 2 +-
src/backend/catalog/pg_constraint.c | 2 +-
src/backend/catalog/pg_depend.c | 2 +-
src/backend/catalog/pg_enum.c | 2 +-
src/backend/catalog/pg_inherits.c | 2 +-
src/backend/catalog/pg_largeobject.c | 2 +-
src/backend/catalog/pg_namespace.c | 2 +-
src/backend/catalog/pg_operator.c | 2 +-
src/backend/catalog/pg_proc.c | 2 +-
src/backend/catalog/pg_range.c | 2 +-
src/backend/catalog/pg_shdepend.c | 2 +-
src/backend/catalog/pg_type.c | 2 +-
src/backend/commands/alter.c | 3 ++-
src/backend/commands/amcmds.c | 2 +-
src/backend/commands/analyze.c | 3 ++-
src/backend/commands/collationcmds.c | 2 +-
src/backend/commands/comment.c | 3 ++-
src/backend/commands/dropcmds.c | 2 +-
src/backend/commands/event_trigger.c | 2 +-
src/backend/commands/extension.c | 3 ++-
src/backend/commands/foreigncmds.c | 2 +-
src/backend/commands/functioncmds.c | 2 +-
src/backend/commands/lockcmds.c | 2 +-
src/backend/commands/opclasscmds.c | 2 +-
src/backend/commands/operatorcmds.c | 2 +-
src/backend/commands/policy.c | 3 ++-
src/backend/commands/proclang.c | 2 +-
src/backend/commands/publicationcmds.c | 2 +-
src/backend/commands/schemacmds.c | 2 +-
src/backend/commands/seclabel.c | 3 ++-
src/backend/commands/sequence.c | 3 ++-
src/backend/commands/statscmds.c | 3 ++-
src/backend/commands/subscriptioncmds.c | 2 +-
src/backend/commands/tsearchcmds.c | 2 +-
src/backend/commands/user.c | 2 +-
src/backend/commands/view.c | 2 +-
src/backend/executor/execPartition.c | 2 +-
src/backend/executor/execUtils.c | 2 +-
src/backend/optimizer/plan/planner.c | 2 +-
src/backend/optimizer/prep/preptlist.c | 2 +-
src/backend/optimizer/util/inherit.c | 2 +-
src/backend/optimizer/util/plancat.c | 2 +-
src/backend/parser/parse_clause.c | 2 +-
src/backend/parser/parse_node.c | 2 +-
src/backend/parser/parse_relation.c | 3 ++-
src/backend/parser/parse_utilcmd.c | 3 ++-
src/backend/replication/logical/origin.c | 2 +-
src/backend/replication/logical/relation.c | 2 +-
src/backend/replication/logical/tablesync.c | 2 +-
src/backend/replication/logical/worker.c | 2 +-
src/backend/rewrite/rewriteHandler.c | 3 ++-
src/backend/rewrite/rewriteRemove.c | 2 +-
src/backend/rewrite/rewriteSupport.c | 2 +-
src/backend/rewrite/rowsecurity.c | 2 +-
src/backend/statistics/extended_stats.c | 2 +-
src/backend/storage/large_object/inv_api.c | 2 +-
src/backend/utils/adt/dbsize.c | 2 +-
src/backend/utils/adt/enum.c | 2 +-
src/backend/utils/adt/misc.c | 2 +-
src/backend/utils/adt/ri_triggers.c | 2 +-
src/backend/utils/adt/ruleutils.c | 3 ++-
src/backend/utils/adt/selfuncs.c | 2 +-
src/backend/utils/adt/xml.c | 2 +-
src/backend/utils/cache/catcache.c | 2 +-
src/backend/utils/cache/evtcache.c | 2 +-
src/backend/utils/cache/partcache.c | 2 +-
src/backend/utils/cache/relcache.c | 2 +-
src/backend/utils/cache/relfilenodemap.c | 2 +-
src/backend/utils/cache/ts_cache.c | 2 +-
src/backend/utils/cache/typcache.c | 3 ++-
src/backend/utils/fmgr/funcapi.c | 2 +-
src/backend/utils/misc/queryenvironment.c | 2 +-
96 files changed, 115 insertions(+), 97 deletions(-)
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index 203f6fd3f01..5092aba3e42 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -37,8 +37,9 @@
#include "libpq-fe.h"
#include "access/htup_details.h"
+#include "access/relation.h"
#include "access/reloptions.h"
-#include "access/heapam.h"
+#include "access/table.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/pg_foreign_data_wrapper.h"
diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c
index ad4da6b5ed4..9b73696e2a7 100644
--- a/contrib/file_fdw/file_fdw.c
+++ b/contrib/file_fdw/file_fdw.c
@@ -18,7 +18,7 @@
#include "access/htup_details.h"
#include "access/reloptions.h"
#include "access/sysattr.h"
-#include "access/heapam.h"
+#include "access/table.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_foreign_table.h"
#include "commands/copy.h"
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 454e488f86a..bfa0c04c2f1 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -30,7 +30,7 @@
#include "pageinspect.h"
#include "access/nbtree.h"
-#include "access/heapam.h"
+#include "access/relation.h"
#include "catalog/namespace.h"
#include "catalog/pg_am.h"
#include "funcapi.h"
diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c
index b98c4881ac5..987d576c011 100644
--- a/contrib/pageinspect/heapfuncs.c
+++ b/contrib/pageinspect/heapfuncs.c
@@ -27,8 +27,8 @@
#include "pageinspect.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/relation.h"
#include "funcapi.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
diff --git a/contrib/pageinspect/rawpage.c b/contrib/pageinspect/rawpage.c
index 2d91954cb7d..03d6670d1fa 100644
--- a/contrib/pageinspect/rawpage.c
+++ b/contrib/pageinspect/rawpage.c
@@ -18,7 +18,7 @@
#include "pageinspect.h"
#include "access/htup_details.h"
-#include "access/heapam.h"
+#include "access/relation.h"
#include "catalog/namespace.h"
#include "catalog/pg_type.h"
#include "funcapi.h"
diff --git a/contrib/pg_freespacemap/pg_freespacemap.c b/contrib/pg_freespacemap/pg_freespacemap.c
index 5ad68005573..b82cab2d97e 100644
--- a/contrib/pg_freespacemap/pg_freespacemap.c
+++ b/contrib/pg_freespacemap/pg_freespacemap.c
@@ -8,7 +8,7 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
+#include "access/relation.h"
#include "funcapi.h"
#include "storage/freespace.h"
diff --git a/contrib/pg_prewarm/autoprewarm.c b/contrib/pg_prewarm/autoprewarm.c
index 45a5a26337e..9cc4b2dc837 100644
--- a/contrib/pg_prewarm/autoprewarm.c
+++ b/contrib/pg_prewarm/autoprewarm.c
@@ -28,7 +28,7 @@
#include <unistd.h>
-#include "access/heapam.h"
+#include "access/relation.h"
#include "access/xact.h"
#include "catalog/pg_class.h"
#include "catalog/pg_type.h"
diff --git a/contrib/pg_prewarm/pg_prewarm.c b/contrib/pg_prewarm/pg_prewarm.c
index f789aabfc62..f3deb47a97b 100644
--- a/contrib/pg_prewarm/pg_prewarm.c
+++ b/contrib/pg_prewarm/pg_prewarm.c
@@ -15,7 +15,7 @@
#include <sys/stat.h>
#include <unistd.h>
-#include "access/heapam.h"
+#include "access/relation.h"
#include "fmgr.h"
#include "miscadmin.h"
#include "storage/bufmgr.h"
diff --git a/contrib/pgstattuple/pgstatapprox.c b/contrib/pgstattuple/pgstatapprox.c
index 9729d8eb1bd..4f449a26c15 100644
--- a/contrib/pgstattuple/pgstatapprox.c
+++ b/contrib/pgstattuple/pgstatapprox.c
@@ -12,9 +12,9 @@
*/
#include "postgres.h"
-#include "access/visibilitymap.h"
-#include "access/heapam.h"
+#include "access/relation.h"
#include "access/transam.h"
+#include "access/visibilitymap.h"
#include "access/xact.h"
#include "access/multixact.h"
#include "access/htup_details.h"
diff --git a/contrib/pgstattuple/pgstatindex.c b/contrib/pgstattuple/pgstatindex.c
index db396c8c4b7..2c807537266 100644
--- a/contrib/pgstattuple/pgstatindex.c
+++ b/contrib/pgstattuple/pgstatindex.c
@@ -28,10 +28,11 @@
#include "postgres.h"
#include "access/gin_private.h"
-#include "access/heapam.h"
#include "access/hash.h"
#include "access/htup_details.h"
#include "access/nbtree.h"
+#include "access/relation.h"
+#include "access/table.h"
#include "catalog/namespace.h"
#include "catalog/pg_am.h"
#include "funcapi.h"
diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c
index 307c0270bb5..20982daef68 100644
--- a/contrib/postgres_fdw/deparse.c
+++ b/contrib/postgres_fdw/deparse.c
@@ -35,9 +35,9 @@
#include "postgres_fdw.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/pg_aggregate.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_namespace.h"
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index 64efbdff082..6200b430200 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -14,9 +14,9 @@
#include "postgres_fdw.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/pg_class.h"
#include "commands/defrem.h"
#include "commands/explain.h"
diff --git a/contrib/sepgsql/database.c b/contrib/sepgsql/database.c
index d49231a4b18..837728e07b0 100644
--- a/contrib/sepgsql/database.c
+++ b/contrib/sepgsql/database.c
@@ -11,9 +11,9 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/pg_database.h"
#include "catalog/indexing.h"
diff --git a/contrib/sepgsql/label.c b/contrib/sepgsql/label.c
index db00b481228..19bbee328e3 100644
--- a/contrib/sepgsql/label.c
+++ b/contrib/sepgsql/label.c
@@ -12,9 +12,9 @@
#include <selinux/label.h>
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/genam.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
diff --git a/contrib/sepgsql/proc.c b/contrib/sepgsql/proc.c
index 94b9dbf6ecd..74487eda03a 100644
--- a/contrib/sepgsql/proc.c
+++ b/contrib/sepgsql/proc.c
@@ -11,9 +11,9 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/pg_namespace.h"
diff --git a/contrib/sepgsql/relation.c b/contrib/sepgsql/relation.c
index 42a4604f24b..12cfebecc64 100644
--- a/contrib/sepgsql/relation.c
+++ b/contrib/sepgsql/relation.c
@@ -11,9 +11,9 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/indexing.h"
#include "catalog/dependency.h"
#include "catalog/pg_attribute.h"
diff --git a/contrib/sepgsql/schema.c b/contrib/sepgsql/schema.c
index 19ca6fa9b0f..752cd56a86a 100644
--- a/contrib/sepgsql/schema.c
+++ b/contrib/sepgsql/schema.c
@@ -11,9 +11,9 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/pg_database.h"
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index 52144271c1c..34f82d46821 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -19,9 +19,10 @@
#include "access/brin_page.h"
#include "access/brin_pageops.h"
#include "access/brin_xlog.h"
-#include "access/heapam.h"
+#include "access/relation.h"
#include "access/reloptions.h"
#include "access/relscan.h"
+#include "access/table.h"
#include "access/xloginsert.h"
#include "catalog/index.h"
#include "catalog/pg_am.h"
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index eb474700f5d..48303926e48 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -21,9 +21,9 @@
#include <unistd.h>
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "access/transam.h"
#include "catalog/catalog.h"
#include "catalog/indexing.h"
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index 35290847bd9..014e49fe77c 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -16,7 +16,7 @@
#include "access/genam.h"
#include "access/htup_details.h"
-#include "access/heapam.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/dependency.h"
#include "catalog/heap.h"
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index d7ccf2bfbef..07e720df2fc 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -30,10 +30,11 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/multixact.h"
+#include "access/relation.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "access/transam.h"
#include "access/xact.h"
#include "access/xlog.h"
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index f9214f8b629..d68e28c9b43 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -16,9 +16,10 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/relation.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/indexing.h"
#include "catalog/objectaddress.h"
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c
index 11b48180375..83ec22cb0fd 100644
--- a/src/backend/catalog/partition.c
+++ b/src/backend/catalog/partition.c
@@ -15,8 +15,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/tupconvert.h"
#include "access/sysattr.h"
#include "catalog/indexing.h"
diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c
index bf73599ba8b..fe953c95ae5 100644
--- a/src/backend/catalog/pg_aggregate.c
+++ b/src/backend/catalog/pg_aggregate.c
@@ -14,8 +14,8 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/pg_aggregate.h"
diff --git a/src/backend/catalog/pg_collation.c b/src/backend/catalog/pg_collation.c
index 467ab5a5e56..57ce7d7205c 100644
--- a/src/backend/catalog/pg_collation.c
+++ b/src/backend/catalog/pg_collation.c
@@ -15,9 +15,9 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c
index 3c960c9423a..a27bcfb3350 100644
--- a/src/backend/catalog/pg_constraint.c
+++ b/src/backend/catalog/pg_constraint.c
@@ -15,9 +15,9 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "access/tupconvert.h"
#include "access/xact.h"
#include "catalog/catalog.h"
diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c
index fde7e170bed..6a46d2e5b18 100644
--- a/src/backend/catalog/pg_depend.c
+++ b/src/backend/catalog/pg_depend.c
@@ -15,8 +15,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/pg_constraint.h"
diff --git a/src/backend/catalog/pg_enum.c b/src/backend/catalog/pg_enum.c
index 4921287f78d..77b1b9fb27f 100644
--- a/src/backend/catalog/pg_enum.c
+++ b/src/backend/catalog/pg_enum.c
@@ -14,8 +14,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/binary_upgrade.h"
#include "catalog/catalog.h"
diff --git a/src/backend/catalog/pg_inherits.c b/src/backend/catalog/pg_inherits.c
index 978ff20d877..d07bbba34d3 100644
--- a/src/backend/catalog/pg_inherits.c
+++ b/src/backend/catalog/pg_inherits.c
@@ -20,8 +20,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/indexing.h"
#include "catalog/pg_inherits.h"
#include "parser/parse_type.h"
diff --git a/src/backend/catalog/pg_largeobject.c b/src/backend/catalog/pg_largeobject.c
index 1b4ced47827..1d068ca0beb 100644
--- a/src/backend/catalog/pg_largeobject.c
+++ b/src/backend/catalog/pg_largeobject.c
@@ -15,9 +15,9 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
diff --git a/src/backend/catalog/pg_namespace.c b/src/backend/catalog/pg_namespace.c
index 349840b0ece..763a0b75ab1 100644
--- a/src/backend/catalog/pg_namespace.c
+++ b/src/backend/catalog/pg_namespace.c
@@ -14,8 +14,8 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c
index 7a973216bd4..dbe89c51710 100644
--- a/src/backend/catalog/pg_operator.c
+++ b/src/backend/catalog/pg_operator.c
@@ -17,8 +17,8 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index 8c2e42d7590..32887e548b8 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -15,7 +15,7 @@
#include "postgres.h"
#include "access/htup_details.h"
-#include "access/heapam.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
diff --git a/src/backend/catalog/pg_range.c b/src/backend/catalog/pg_range.c
index 8044807c2c0..dc83727d9dc 100644
--- a/src/backend/catalog/pg_range.c
+++ b/src/backend/catalog/pg_range.c
@@ -15,8 +15,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/pg_collation.h"
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index 8343fce408a..a8db901bcb8 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -15,8 +15,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index b69cf832994..b14beae9e13 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -14,8 +14,8 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/binary_upgrade.h"
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 3c53178f75c..08c2cf3569f 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -14,9 +14,10 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/relation.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
diff --git a/src/backend/commands/amcmds.c b/src/backend/commands/amcmds.c
index 1ab2e469ee7..a720d14df06 100644
--- a/src/backend/commands/amcmds.c
+++ b/src/backend/commands/amcmds.c
@@ -13,8 +13,8 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 99e3f2a672a..ac40bd793d1 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -17,9 +17,10 @@
#include <math.h>
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/multixact.h"
+#include "access/relation.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "access/transam.h"
#include "access/tupconvert.h"
#include "access/tuptoaster.h"
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
index e6a5c3a5554..d9a3088ac27 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -14,8 +14,8 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c
index 2327632a09d..d4714a5c1f8 100644
--- a/src/backend/commands/comment.c
+++ b/src/backend/commands/comment.c
@@ -15,8 +15,9 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/relation.h"
+#include "access/table.h"
#include "catalog/indexing.h"
#include "catalog/objectaddress.h"
#include "catalog/pg_description.h"
diff --git a/src/backend/commands/dropcmds.c b/src/backend/commands/dropcmds.c
index 1dc1c746f1f..7c31890ba51 100644
--- a/src/backend/commands/dropcmds.c
+++ b/src/backend/commands/dropcmds.c
@@ -14,8 +14,8 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/namespace.h"
#include "catalog/objectaddress.h"
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index e5083349814..9735fde9711 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -13,8 +13,8 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index e381a307601..48dfbc33766 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -30,9 +30,10 @@
#include <unistd.h>
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/relation.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
diff --git a/src/backend/commands/foreigncmds.c b/src/backend/commands/foreigncmds.c
index 5ada4a85940..03976f0454f 100644
--- a/src/backend/commands/foreigncmds.c
+++ b/src/backend/commands/foreigncmds.c
@@ -13,9 +13,9 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/reloptions.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 8b291cf1858..9a8d388909f 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -33,8 +33,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/sysattr.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c
index 1b33be18958..1470ffe1d17 100644
--- a/src/backend/commands/lockcmds.c
+++ b/src/backend/commands/lockcmds.c
@@ -14,6 +14,7 @@
*/
#include "postgres.h"
+#include "access/table.h"
#include "catalog/namespace.h"
#include "catalog/pg_inherits.h"
#include "commands/lockcmds.h"
@@ -24,7 +25,6 @@
#include "utils/lsyscache.h"
#include "utils/syscache.h"
#include "rewrite/rewriteHandler.h"
-#include "access/heapam.h"
#include "nodes/nodeFuncs.h"
static void LockTableRecurse(Oid reloid, LOCKMODE lockmode, bool nowait, Oid userid);
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 5a160450260..e1b1a7e3169 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -19,10 +19,10 @@
#include "access/genam.h"
#include "access/hash.h"
-#include "access/heapam.h"
#include "access/nbtree.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c
index f7c00e2f48e..9733d6c7bda 100644
--- a/src/backend/commands/operatorcmds.c
+++ b/src/backend/commands/operatorcmds.c
@@ -34,8 +34,8 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/objectaccess.h"
diff --git a/src/backend/commands/policy.c b/src/backend/commands/policy.c
index 0adae130432..8465de0e1dd 100644
--- a/src/backend/commands/policy.c
+++ b/src/backend/commands/policy.c
@@ -13,9 +13,10 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup.h"
#include "access/htup_details.h"
+#include "access/relation.h"
+#include "access/table.h"
#include "access/sysattr.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c
index b010d23466a..572a5d5bdea 100644
--- a/src/backend/commands/proclang.c
+++ b/src/backend/commands/proclang.c
@@ -14,8 +14,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index 5dc84fe41ad..e431e58f0e6 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -19,8 +19,8 @@
#include "access/genam.h"
#include "access/hash.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c
index c3029465255..8367261fbe8 100644
--- a/src/backend/commands/schemacmds.c
+++ b/src/backend/commands/schemacmds.c
@@ -15,7 +15,7 @@
#include "postgres.h"
#include "access/htup_details.h"
-#include "access/heapam.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
diff --git a/src/backend/commands/seclabel.c b/src/backend/commands/seclabel.c
index 325bcaada19..1e31dc1f678 100644
--- a/src/backend/commands/seclabel.c
+++ b/src/backend/commands/seclabel.c
@@ -11,8 +11,9 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/relation.h"
+#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/indexing.h"
#include "catalog/pg_seclabel.h"
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 1df2df8ff55..5554e883d80 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -15,9 +15,10 @@
#include "postgres.h"
#include "access/bufmask.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/multixact.h"
+#include "access/relation.h"
+#include "access/table.h"
#include "access/transam.h"
#include "access/xact.h"
#include "access/xlog.h"
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index 86a96ac05dc..970fdb712d6 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -14,8 +14,9 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
+#include "access/relation.h"
#include "access/relscan.h"
+#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 160c4fc6597..bd0f4cd1a15 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -16,8 +16,8 @@
#include "miscadmin.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index cda21675f02..3f727f2744c 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -18,8 +18,8 @@
#include <ctype.h>
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 30399407f88..938c7d0ed0a 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -13,8 +13,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/binary_upgrade.h"
#include "catalog/catalog.h"
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c
index c346630267c..65f4b40b38f 100644
--- a/src/backend/commands/view.c
+++ b/src/backend/commands/view.c
@@ -14,7 +14,7 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
+#include "access/relation.h"
#include "access/xact.h"
#include "catalog/namespace.h"
#include "commands/defrem.h"
diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c
index 7415dfa45eb..93e4b287970 100644
--- a/src/backend/executor/execPartition.c
+++ b/src/backend/executor/execPartition.c
@@ -13,7 +13,7 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
+#include "access/table.h"
#include "catalog/partition.h"
#include "catalog/pg_inherits.h"
#include "catalog/pg_type.h"
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index d914d4b5006..146ca6e0532 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -45,9 +45,9 @@
#include "postgres.h"
-#include "access/heapam.h"
#include "access/parallel.h"
#include "access/relscan.h"
+#include "access/table.h"
#include "access/transam.h"
#include "executor/executor.h"
#include "jit/jit.h"
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index 5ba612922f9..cce762515d7 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -19,10 +19,10 @@
#include <math.h>
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/parallel.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/pg_constraint.h"
#include "catalog/pg_proc.h"
diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c
index f8bc2dd257d..8d9315a4547 100644
--- a/src/backend/optimizer/prep/preptlist.c
+++ b/src/backend/optimizer/prep/preptlist.c
@@ -40,8 +40,8 @@
#include "postgres.h"
-#include "access/heapam.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/pg_type.h"
#include "nodes/makefuncs.h"
#include "optimizer/prep.h"
diff --git a/src/backend/optimizer/util/inherit.c b/src/backend/optimizer/util/inherit.c
index 350e6afe270..52354eab5ba 100644
--- a/src/backend/optimizer/util/inherit.c
+++ b/src/backend/optimizer/util/inherit.c
@@ -14,7 +14,7 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
+#include "access/table.h"
#include "catalog/partition.h"
#include "catalog/pg_inherits.h"
#include "miscadmin.h"
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 48ffc5f2543..a6029f56373 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -18,10 +18,10 @@
#include <math.h>
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/nbtree.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "access/transam.h"
#include "access/xlog.h"
#include "catalog/catalog.h"
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index 6963922b0eb..2d740b5f52c 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -17,9 +17,9 @@
#include "miscadmin.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/nbtree.h"
+#include "access/table.h"
#include "access/tsmapi.h"
#include "catalog/catalog.h"
#include "catalog/heap.h"
diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c
index 8befe15e7d6..0562e6ecc80 100644
--- a/src/backend/parser/parse_node.c
+++ b/src/backend/parser/parse_node.c
@@ -14,8 +14,8 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/pg_type.h"
#include "mb/pg_wchar.h"
#include "nodes/makefuncs.h"
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index e6af7a431f7..0f8175d39f3 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -16,9 +16,10 @@
#include <ctype.h>
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/relation.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/heap.h"
#include "catalog/namespace.h"
#include "catalog/pg_type.h"
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index bebee9d540b..ef3865d8ee7 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -27,9 +27,10 @@
#include "postgres.h"
#include "access/amapi.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/relation.h"
#include "access/reloptions.h"
+#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/heap.h"
#include "catalog/index.h"
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index ca51318dbb4..0ca89911844 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -74,8 +74,8 @@
#include "miscadmin.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/indexing.h"
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index 57ca4290682..81087ac9033 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -16,8 +16,8 @@
#include "postgres.h"
-#include "access/heapam.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/namespace.h"
#include "catalog/pg_subscription_rel.h"
#include "executor/executor.h"
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index d87cf8afe56..20ab1122064 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -88,7 +88,7 @@
#include "miscadmin.h"
#include "pgstat.h"
-#include "access/heapam.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/pg_subscription_rel.h"
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index de23ced9aff..0612e424dee 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -27,7 +27,7 @@
#include "pgstat.h"
#include "funcapi.h"
-#include "access/heapam.h"
+#include "access/table.h"
#include "access/xact.h"
#include "access/xlog_internal.h"
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index 4e5dcabf160..0fade10268a 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -20,8 +20,9 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
+#include "access/relation.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/pg_type.h"
#include "commands/trigger.h"
diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c
index 17919abd524..e6b4b9da284 100644
--- a/src/backend/rewrite/rewriteRemove.c
+++ b/src/backend/rewrite/rewriteRemove.c
@@ -15,9 +15,9 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c
index c26147fb863..ec314051fa7 100644
--- a/src/backend/rewrite/rewriteSupport.c
+++ b/src/backend/rewrite/rewriteSupport.c
@@ -14,8 +14,8 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/indexing.h"
#include "catalog/pg_rewrite.h"
#include "rewrite/rewriteSupport.h"
diff --git a/src/backend/rewrite/rowsecurity.c b/src/backend/rewrite/rowsecurity.c
index b0d6e9af817..26a3ca3f7b9 100644
--- a/src/backend/rewrite/rowsecurity.c
+++ b/src/backend/rewrite/rowsecurity.c
@@ -34,9 +34,9 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/pg_class.h"
#include "catalog/pg_inherits.h"
#include "catalog/pg_policy.h"
diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index 9b3e819d61f..51659a51dde 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -17,8 +17,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/indexing.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_statistic_ext.h"
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
index c51ec1f9a28..b0dddab47a3 100644
--- a/src/backend/storage/large_object/inv_api.c
+++ b/src/backend/storage/large_object/inv_api.c
@@ -33,8 +33,8 @@
#include <limits.h>
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "access/tuptoaster.h"
#include "access/xact.h"
#include "catalog/dependency.h"
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c
index 0d89cbe18f6..a87e7214e9f 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -13,8 +13,8 @@
#include <sys/stat.h>
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/relation.h"
#include "catalog/catalog.h"
#include "catalog/namespace.h"
#include "catalog/pg_authid.h"
diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c
index 610685db4cf..de6a08ba555 100644
--- a/src/backend/utils/adt/enum.c
+++ b/src/backend/utils/adt/enum.c
@@ -14,8 +14,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/indexing.h"
#include "catalog/pg_enum.h"
#include "libpq/pqformat.h"
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index f4d3eab2ea8..91de57e5ceb 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -19,8 +19,8 @@
#include <math.h>
#include <unistd.h>
-#include "access/heapam.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index e606eb342fd..049585f211c 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -30,9 +30,9 @@
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_constraint.h"
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 8ed72bd2683..97eeabc8f04 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -20,9 +20,10 @@
#include <fcntl.h>
#include "access/amapi.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/relation.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/pg_aggregate.h"
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 27e5bfef36c..71cfe6499ca 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -103,9 +103,9 @@
#include "access/brin.h"
#include "access/gin.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "catalog/index.h"
#include "catalog/pg_am.h"
#include "catalog/pg_collation.h"
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index 1db560cd66d..7c04586ad5e 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -67,8 +67,8 @@
#endif
#endif /* USE_LIBXML */
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/namespace.h"
#include "catalog/pg_class.h"
#include "catalog/pg_type.h"
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index 8152f7e21e2..2123117f8b0 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -16,9 +16,9 @@
#include "access/genam.h"
#include "access/hash.h"
-#include "access/heapam.h"
#include "access/relscan.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "access/tuptoaster.h"
#include "access/valid.h"
#include "access/xact.h"
diff --git a/src/backend/utils/cache/evtcache.c b/src/backend/utils/cache/evtcache.c
index 37e2ebc9f58..88b0969b890 100644
--- a/src/backend/utils/cache/evtcache.c
+++ b/src/backend/utils/cache/evtcache.c
@@ -14,8 +14,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/relation.h"
#include "catalog/pg_event_trigger.h"
#include "catalog/indexing.h"
#include "catalog/pg_type.h"
diff --git a/src/backend/utils/cache/partcache.c b/src/backend/utils/cache/partcache.c
index 2004f2d4676..2404073bc86 100644
--- a/src/backend/utils/cache/partcache.c
+++ b/src/backend/utils/cache/partcache.c
@@ -15,9 +15,9 @@
#include "postgres.h"
#include "access/hash.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/nbtree.h"
+#include "access/relation.h"
#include "catalog/partition.h"
#include "catalog/pg_inherits.h"
#include "catalog/pg_opclass.h"
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index df30bff6c99..93856e30875 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -31,12 +31,12 @@
#include <unistd.h>
#include "access/hash.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/multixact.h"
#include "access/nbtree.h"
#include "access/reloptions.h"
#include "access/sysattr.h"
+#include "access/table.h"
#include "access/tupdesc_details.h"
#include "access/xact.h"
#include "access/xlog.h"
diff --git a/src/backend/utils/cache/relfilenodemap.c b/src/backend/utils/cache/relfilenodemap.c
index 29ee86acd6d..b766dbb21c0 100644
--- a/src/backend/utils/cache/relfilenodemap.c
+++ b/src/backend/utils/cache/relfilenodemap.c
@@ -14,8 +14,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "catalog/indexing.h"
#include "catalog/pg_class.h"
#include "catalog/pg_tablespace.h"
diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c
index f7fc6c15581..4e0fdb7b55a 100644
--- a/src/backend/utils/cache/ts_cache.c
+++ b/src/backend/utils/cache/ts_cache.c
@@ -27,8 +27,8 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/table.h"
#include "access/xact.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c
index 0fdd1ebef1f..b1931dad95e 100644
--- a/src/backend/utils/cache/typcache.c
+++ b/src/backend/utils/cache/typcache.c
@@ -43,11 +43,12 @@
#include <limits.h>
#include "access/hash.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/nbtree.h"
#include "access/parallel.h"
+#include "access/relation.h"
#include "access/session.h"
+#include "access/table.h"
#include "catalog/indexing.h"
#include "catalog/pg_am.h"
#include "catalog/pg_constraint.h"
diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c
index 8fba7791cf8..a5e77a208ef 100644
--- a/src/backend/utils/fmgr/funcapi.c
+++ b/src/backend/utils/fmgr/funcapi.c
@@ -13,8 +13,8 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/relation.h"
#include "catalog/namespace.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
diff --git a/src/backend/utils/misc/queryenvironment.c b/src/backend/utils/misc/queryenvironment.c
index 29d45cc368b..165e819e47a 100644
--- a/src/backend/utils/misc/queryenvironment.c
+++ b/src/backend/utils/misc/queryenvironment.c
@@ -22,7 +22,7 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
+#include "access/table.h"
#include "utils/queryenvironment.h"
#include "utils/rel.h"
--
2.18.0.rc2.dirty
v1-0003-Replace-uses-of-heap_open-et-al-with-table_open-e.patchtext/x-diff; charset=us-asciiDownload
From f072de90684c41fe6863aed1150ae3249778d796 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Mon, 14 Jan 2019 18:30:31 -0800
Subject: [PATCH v1 3/3] Replace uses of heap_open et al with table_open et al.
Author:
Reviewed-By:
Discussion: https://postgr.es/m/
Backpatch:
---
contrib/amcheck/verify_nbtree.c | 4 +-
contrib/dblink/dblink.c | 6 +-
contrib/file_fdw/file_fdw.c | 8 +-
contrib/pgrowlocks/pgrowlocks.c | 2 +-
contrib/postgres_fdw/deparse.c | 12 +-
contrib/postgres_fdw/postgres_fdw.c | 8 +-
contrib/sepgsql/database.c | 4 +-
contrib/sepgsql/label.c | 4 +-
contrib/sepgsql/proc.c | 8 +-
contrib/sepgsql/relation.c | 20 +-
contrib/sepgsql/schema.c | 4 +-
src/backend/access/brin/brin.c | 12 +-
src/backend/access/heap/heapam.c | 4 +-
src/backend/access/heap/tuptoaster.c | 24 +-
src/backend/access/nbtree/nbtsort.c | 4 +-
src/backend/bootstrap/bootstrap.c | 16 +-
src/backend/catalog/aclchk.c | 82 ++---
src/backend/catalog/catalog.c | 4 +-
src/backend/catalog/dependency.c | 16 +-
src/backend/catalog/heap.c | 102 +++---
src/backend/catalog/index.c | 64 ++--
src/backend/catalog/objectaddress.c | 80 ++---
src/backend/catalog/partition.c | 12 +-
src/backend/catalog/pg_aggregate.c | 4 +-
src/backend/catalog/pg_collation.c | 12 +-
src/backend/catalog/pg_constraint.c | 76 ++--
src/backend/catalog/pg_conversion.c | 8 +-
src/backend/catalog/pg_db_role_setting.c | 8 +-
src/backend/catalog/pg_depend.c | 36 +-
src/backend/catalog/pg_enum.c | 16 +-
src/backend/catalog/pg_inherits.c | 20 +-
src/backend/catalog/pg_largeobject.c | 16 +-
src/backend/catalog/pg_namespace.c | 4 +-
src/backend/catalog/pg_operator.c | 12 +-
src/backend/catalog/pg_proc.c | 4 +-
src/backend/catalog/pg_publication.c | 18 +-
src/backend/catalog/pg_range.c | 8 +-
src/backend/catalog/pg_shdepend.c | 40 +--
src/backend/catalog/pg_subscription.c | 30 +-
src/backend/catalog/pg_type.c | 16 +-
src/backend/catalog/toasting.c | 18 +-
src/backend/commands/alter.c | 18 +-
src/backend/commands/amcmds.c | 8 +-
src/backend/commands/analyze.c | 16 +-
src/backend/commands/cluster.c | 44 +--
src/backend/commands/collationcmds.c | 4 +-
src/backend/commands/comment.c | 20 +-
src/backend/commands/copy.c | 6 +-
src/backend/commands/createas.c | 4 +-
src/backend/commands/dbcommands.c | 48 +--
src/backend/commands/dropcmds.c | 2 +-
src/backend/commands/event_trigger.c | 30 +-
src/backend/commands/extension.c | 46 +--
src/backend/commands/foreigncmds.c | 60 ++--
src/backend/commands/functioncmds.c | 36 +-
src/backend/commands/indexcmds.c | 32 +-
src/backend/commands/lockcmds.c | 4 +-
src/backend/commands/matview.c | 20 +-
src/backend/commands/opclasscmds.c | 32 +-
src/backend/commands/operatorcmds.c | 8 +-
src/backend/commands/policy.c | 36 +-
src/backend/commands/proclang.c | 12 +-
src/backend/commands/publicationcmds.c | 34 +-
src/backend/commands/schemacmds.c | 16 +-
src/backend/commands/seclabel.c | 24 +-
src/backend/commands/sequence.c | 16 +-
src/backend/commands/statscmds.c | 6 +-
src/backend/commands/subscriptioncmds.c | 24 +-
src/backend/commands/tablecmds.c | 364 ++++++++++----------
src/backend/commands/tablespace.c | 26 +-
src/backend/commands/trigger.c | 54 +--
src/backend/commands/tsearchcmds.c | 48 +--
src/backend/commands/typecmds.c | 68 ++--
src/backend/commands/user.c | 32 +-
src/backend/commands/vacuum.c | 20 +-
src/backend/executor/execMain.c | 6 +-
src/backend/executor/execPartition.c | 8 +-
src/backend/executor/execUtils.c | 6 +-
src/backend/optimizer/plan/planner.c | 4 +-
src/backend/optimizer/prep/preptlist.c | 4 +-
src/backend/optimizer/util/inherit.c | 14 +-
src/backend/optimizer/util/plancat.c | 26 +-
src/backend/parser/parse_clause.c | 4 +-
src/backend/parser/parse_node.c | 2 +-
src/backend/parser/parse_relation.c | 18 +-
src/backend/parser/parse_utilcmd.c | 16 +-
src/backend/partitioning/partbounds.c | 8 +-
src/backend/postmaster/autovacuum.c | 8 +-
src/backend/postmaster/pgstat.c | 4 +-
src/backend/replication/logical/launcher.c | 4 +-
src/backend/replication/logical/origin.c | 8 +-
src/backend/replication/logical/relation.c | 6 +-
src/backend/replication/logical/tablesync.c | 4 +-
src/backend/rewrite/rewriteDefine.c | 20 +-
src/backend/rewrite/rewriteHandler.c | 20 +-
src/backend/rewrite/rewriteRemove.c | 8 +-
src/backend/rewrite/rewriteSupport.c | 4 +-
src/backend/rewrite/rowsecurity.c | 4 +-
src/backend/statistics/extended_stats.c | 4 +-
src/backend/storage/large_object/inv_api.c | 8 +-
src/backend/utils/adt/enum.c | 8 +-
src/backend/utils/adt/misc.c | 4 +-
src/backend/utils/adt/ri_triggers.c | 34 +-
src/backend/utils/adt/ruleutils.c | 24 +-
src/backend/utils/adt/selfuncs.c | 4 +-
src/backend/utils/adt/tid.c | 10 +-
src/backend/utils/adt/xml.c | 16 +-
src/backend/utils/cache/catcache.c | 14 +-
src/backend/utils/cache/relcache.c | 48 +--
src/backend/utils/cache/relfilenodemap.c | 4 +-
src/backend/utils/cache/ts_cache.c | 4 +-
src/backend/utils/cache/typcache.c | 8 +-
src/backend/utils/init/postinit.c | 16 +-
src/backend/utils/misc/queryenvironment.c | 4 +-
114 files changed, 1240 insertions(+), 1240 deletions(-)
diff --git a/contrib/amcheck/verify_nbtree.c b/contrib/amcheck/verify_nbtree.c
index 055bfa05707..1c7466c8158 100644
--- a/contrib/amcheck/verify_nbtree.c
+++ b/contrib/amcheck/verify_nbtree.c
@@ -219,7 +219,7 @@ bt_index_check_internal(Oid indrelid, bool parentcheck, bool heapallindexed)
*/
heapid = IndexGetRelation(indrelid, true);
if (OidIsValid(heapid))
- heaprel = heap_open(heapid, lockmode);
+ heaprel = table_open(heapid, lockmode);
else
heaprel = NULL;
@@ -261,7 +261,7 @@ bt_index_check_internal(Oid indrelid, bool parentcheck, bool heapallindexed)
*/
index_close(indrel, lockmode);
if (heaprel)
- heap_close(heaprel, lockmode);
+ table_close(heaprel, lockmode);
}
/*
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index 5092aba3e42..6f5f0a7fa57 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -2050,7 +2050,7 @@ get_pkey_attnames(Relation rel, int16 *indnkeyatts)
tupdesc = rel->rd_att;
/* Prepare to scan pg_index for entries having indrelid = this rel. */
- indexRelation = heap_open(IndexRelationId, AccessShareLock);
+ indexRelation = table_open(IndexRelationId, AccessShareLock);
ScanKeyInit(&skey,
Anum_pg_index_indrelid,
BTEqualStrategyNumber, F_OIDEQ,
@@ -2079,7 +2079,7 @@ get_pkey_attnames(Relation rel, int16 *indnkeyatts)
}
systable_endscan(scan);
- heap_close(indexRelation, AccessShareLock);
+ table_close(indexRelation, AccessShareLock);
return result;
}
@@ -2503,7 +2503,7 @@ get_rel_from_relname(text *relname_text, LOCKMODE lockmode, AclMode aclmode)
AclResult aclresult;
relvar = makeRangeVarFromNameList(textToQualifiedNameList(relname_text));
- rel = heap_openrv(relvar, lockmode);
+ rel = table_openrv(relvar, lockmode);
aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
aclmode);
diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c
index 9b73696e2a7..e7db83d3fbb 100644
--- a/contrib/file_fdw/file_fdw.c
+++ b/contrib/file_fdw/file_fdw.c
@@ -439,7 +439,7 @@ get_file_fdw_attribute_options(Oid relid)
List *options = NIL;
- rel = heap_open(relid, AccessShareLock);
+ rel = table_open(relid, AccessShareLock);
tupleDesc = RelationGetDescr(rel);
natts = tupleDesc->natts;
@@ -481,7 +481,7 @@ get_file_fdw_attribute_options(Oid relid)
}
}
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
/*
* Return DefElem only when some column(s) have force_not_null /
@@ -892,7 +892,7 @@ check_selective_binary_conversion(RelOptInfo *baserel,
}
/* Convert attribute numbers to column names. */
- rel = heap_open(foreigntableid, AccessShareLock);
+ rel = table_open(foreigntableid, AccessShareLock);
tupleDesc = RelationGetDescr(rel);
while ((attnum = bms_first_member(attrs_used)) >= 0)
@@ -934,7 +934,7 @@ check_selective_binary_conversion(RelOptInfo *baserel,
numattrs++;
}
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
/* If there's a whole-row reference, fail: we need all the columns. */
if (has_wholerow)
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index fffee6e27e0..2cb3d1ca3bc 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -307,7 +307,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
}
heap_endscan(scan);
- heap_close(mydata->rel, AccessShareLock);
+ table_close(mydata->rel, AccessShareLock);
SRF_RETURN_DONE(funcctx);
}
diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c
index 20982daef68..f368d4b31fb 100644
--- a/contrib/postgres_fdw/deparse.c
+++ b/contrib/postgres_fdw/deparse.c
@@ -1048,11 +1048,11 @@ deparseSelectSql(List *tlist, bool is_subquery, List **retrieved_attrs,
* Core code already has some lock on each rel being planned, so we
* can use NoLock here.
*/
- Relation rel = heap_open(rte->relid, NoLock);
+ Relation rel = table_open(rte->relid, NoLock);
deparseTargetList(buf, rte, foreignrel->relid, rel, false,
fpinfo->attrs_used, false, retrieved_attrs);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
}
@@ -1543,7 +1543,7 @@ deparseFromExprForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel,
* Core code already has some lock on each rel being planned, so we
* can use NoLock here.
*/
- Relation rel = heap_open(rte->relid, NoLock);
+ Relation rel = table_open(rte->relid, NoLock);
deparseRelation(buf, rel);
@@ -1555,7 +1555,7 @@ deparseFromExprForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel,
if (use_alias)
appendStringInfo(buf, " %s%d", REL_ALIAS_PREFIX, foreignrel->relid);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
}
@@ -2097,7 +2097,7 @@ deparseColumnRef(StringInfo buf, int varno, int varattno, RangeTblEntry *rte,
* The lock on the relation will be held by upper callers, so it's
* fine to open it with no lock here.
*/
- rel = heap_open(rte->relid, NoLock);
+ rel = table_open(rte->relid, NoLock);
/*
* The local name of the foreign table can not be recognized by the
@@ -2132,7 +2132,7 @@ deparseColumnRef(StringInfo buf, int varno, int varattno, RangeTblEntry *rte,
if (qualify_col)
appendStringInfoString(buf, " END");
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
bms_free(attrs_used);
}
else
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index 6200b430200..16ccfb188c0 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -1611,7 +1611,7 @@ postgresPlanForeignModify(PlannerInfo *root,
* Core code already has some lock on each rel being planned, so we can
* use NoLock here.
*/
- rel = heap_open(rte->relid, NoLock);
+ rel = table_open(rte->relid, NoLock);
/*
* In an INSERT, we transmit all columns that are defined in the foreign
@@ -1701,7 +1701,7 @@ postgresPlanForeignModify(PlannerInfo *root,
break;
}
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
/*
* Build the fdw_private list that will be available to the executor.
@@ -2290,7 +2290,7 @@ postgresPlanDirectModify(PlannerInfo *root,
* Core code already has some lock on each rel being planned, so we can
* use NoLock here.
*/
- rel = heap_open(rte->relid, NoLock);
+ rel = table_open(rte->relid, NoLock);
/*
* Recall the qual clauses that must be evaluated remotely. (These are
@@ -2376,7 +2376,7 @@ postgresPlanDirectModify(PlannerInfo *root,
rebuild_fdw_scan_tlist(fscan, returningList);
}
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return true;
}
diff --git a/contrib/sepgsql/database.c b/contrib/sepgsql/database.c
index 837728e07b0..b2419f0d811 100644
--- a/contrib/sepgsql/database.c
+++ b/contrib/sepgsql/database.c
@@ -77,7 +77,7 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
* XXX - uncoming version of libselinux supports to take object name to
* handle special treatment on default security label.
*/
- rel = heap_open(DatabaseRelationId, AccessShareLock);
+ rel = table_open(DatabaseRelationId, AccessShareLock);
ScanKeyInit(&skey,
Anum_pg_database_oid,
@@ -110,7 +110,7 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
true);
systable_endscan(sscan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
/*
* Assign the default security label on the new database
diff --git a/contrib/sepgsql/label.c b/contrib/sepgsql/label.c
index 19bbee328e3..d7f5d20d63d 100644
--- a/contrib/sepgsql/label.c
+++ b/contrib/sepgsql/label.c
@@ -727,7 +727,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
* Open the target catalog. We don't want to allow writable accesses by
* other session during initial labeling.
*/
- rel = heap_open(catalogId, AccessShareLock);
+ rel = table_open(catalogId, AccessShareLock);
sscan = systable_beginscan(rel, InvalidOid, false,
NULL, 0, NULL);
@@ -881,7 +881,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
}
systable_endscan(sscan);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
/*
diff --git a/contrib/sepgsql/proc.c b/contrib/sepgsql/proc.c
index 74487eda03a..a4038dfd1b8 100644
--- a/contrib/sepgsql/proc.c
+++ b/contrib/sepgsql/proc.c
@@ -56,7 +56,7 @@ sepgsql_proc_post_create(Oid functionId)
* Fetch namespace of the new procedure. Because pg_proc entry is not
* visible right now, we need to scan the catalog using SnapshotSelf.
*/
- rel = heap_open(ProcedureRelationId, AccessShareLock);
+ rel = table_open(ProcedureRelationId, AccessShareLock);
ScanKeyInit(&skey,
Anum_pg_proc_oid,
@@ -141,7 +141,7 @@ sepgsql_proc_post_create(Oid functionId)
* Cleanup
*/
systable_endscan(sscan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
pfree(audit_name.data);
pfree(tcontext);
@@ -250,7 +250,7 @@ sepgsql_proc_setattr(Oid functionId)
/*
* Fetch newer catalog
*/
- rel = heap_open(ProcedureRelationId, AccessShareLock);
+ rel = table_open(ProcedureRelationId, AccessShareLock);
ScanKeyInit(&skey,
Anum_pg_proc_oid,
@@ -305,7 +305,7 @@ sepgsql_proc_setattr(Oid functionId)
ReleaseSysCache(oldtup);
systable_endscan(sscan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
}
/*
diff --git a/contrib/sepgsql/relation.c b/contrib/sepgsql/relation.c
index 12cfebecc64..6842d2a42b7 100644
--- a/contrib/sepgsql/relation.c
+++ b/contrib/sepgsql/relation.c
@@ -67,7 +67,7 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
* Compute a default security label of the new column underlying the
* specified relation, and check permission to create it.
*/
- rel = heap_open(AttributeRelationId, AccessShareLock);
+ rel = table_open(AttributeRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_attribute_attrelid,
@@ -120,7 +120,7 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
SetSecurityLabel(&object, SEPGSQL_LABEL_TAG, ncontext);
systable_endscan(sscan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
pfree(tcontext);
pfree(ncontext);
@@ -259,7 +259,7 @@ sepgsql_relation_post_create(Oid relOid)
* Fetch catalog record of the new relation. Because pg_class entry is not
* visible right now, we need to scan the catalog using SnapshotSelf.
*/
- rel = heap_open(RelationRelationId, AccessShareLock);
+ rel = table_open(RelationRelationId, AccessShareLock);
ScanKeyInit(&skey,
Anum_pg_class_oid,
@@ -358,7 +358,7 @@ sepgsql_relation_post_create(Oid relOid)
HeapTuple atup;
Form_pg_attribute attForm;
- arel = heap_open(AttributeRelationId, AccessShareLock);
+ arel = table_open(AttributeRelationId, AccessShareLock);
ScanKeyInit(&akey,
Anum_pg_attribute_attrelid,
@@ -400,13 +400,13 @@ sepgsql_relation_post_create(Oid relOid)
pfree(ccontext);
}
systable_endscan(ascan);
- heap_close(arel, AccessShareLock);
+ table_close(arel, AccessShareLock);
}
pfree(rcontext);
out:
systable_endscan(sscan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
}
/*
@@ -611,7 +611,7 @@ sepgsql_relation_setattr(Oid relOid)
/*
* Fetch newer catalog
*/
- rel = heap_open(RelationRelationId, AccessShareLock);
+ rel = table_open(RelationRelationId, AccessShareLock);
ScanKeyInit(&skey,
Anum_pg_class_oid,
@@ -667,7 +667,7 @@ sepgsql_relation_setattr(Oid relOid)
ReleaseSysCache(oldtup);
systable_endscan(sscan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
}
/*
@@ -723,7 +723,7 @@ sepgsql_relation_setattr_extra(Relation catalog,
static void
sepgsql_index_modify(Oid indexOid)
{
- Relation catalog = heap_open(IndexRelationId, AccessShareLock);
+ Relation catalog = table_open(IndexRelationId, AccessShareLock);
/* check db_table:{setattr} permission of the table being indexed */
sepgsql_relation_setattr_extra(catalog,
@@ -731,5 +731,5 @@ sepgsql_index_modify(Oid indexOid)
indexOid,
Anum_pg_index_indrelid,
Anum_pg_index_indexrelid);
- heap_close(catalog, AccessShareLock);
+ table_close(catalog, AccessShareLock);
}
diff --git a/contrib/sepgsql/schema.c b/contrib/sepgsql/schema.c
index 752cd56a86a..668d65e70f5 100644
--- a/contrib/sepgsql/schema.c
+++ b/contrib/sepgsql/schema.c
@@ -56,7 +56,7 @@ sepgsql_schema_post_create(Oid namespaceId)
* handle special treatment on default security label; such as special
* label on "pg_temp" schema.
*/
- rel = heap_open(NamespaceRelationId, AccessShareLock);
+ rel = table_open(NamespaceRelationId, AccessShareLock);
ScanKeyInit(&skey,
Anum_pg_namespace_oid,
@@ -93,7 +93,7 @@ sepgsql_schema_post_create(Oid namespaceId)
audit_name.data,
true);
systable_endscan(sscan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
/*
* Assign the default security label on a new procedure
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index 34f82d46821..621b6cdad7d 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -390,9 +390,9 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
* iterate on the revmap.
*/
heapOid = IndexGetRelation(RelationGetRelid(idxRel), false);
- heapRel = heap_open(heapOid, AccessShareLock);
+ heapRel = table_open(heapOid, AccessShareLock);
nblocks = RelationGetNumberOfBlocks(heapRel);
- heap_close(heapRel, AccessShareLock);
+ table_close(heapRel, AccessShareLock);
/*
* Make room for the consistent support procedures of indexed columns. We
@@ -799,7 +799,7 @@ brinvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
stats->num_pages = RelationGetNumberOfBlocks(info->index);
/* rest of stats is initialized by zeroing */
- heapRel = heap_open(IndexGetRelation(RelationGetRelid(info->index), false),
+ heapRel = table_open(IndexGetRelation(RelationGetRelid(info->index), false),
AccessShareLock);
brin_vacuum_scan(info->index, info->strategy);
@@ -807,7 +807,7 @@ brinvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
brinsummarize(info->index, heapRel, BRIN_ALL_BLOCKRANGES, false,
&stats->num_index_tuples, &stats->num_index_tuples);
- heap_close(heapRel, AccessShareLock);
+ table_close(heapRel, AccessShareLock);
return stats;
}
@@ -897,7 +897,7 @@ brin_summarize_range(PG_FUNCTION_ARGS)
*/
heapoid = IndexGetRelation(indexoid, true);
if (OidIsValid(heapoid))
- heapRel = heap_open(heapoid, ShareUpdateExclusiveLock);
+ heapRel = table_open(heapoid, ShareUpdateExclusiveLock);
else
heapRel = NULL;
@@ -974,7 +974,7 @@ brin_desummarize_range(PG_FUNCTION_ARGS)
*/
heapoid = IndexGetRelation(indexoid, true);
if (OidIsValid(heapoid))
- heapRel = heap_open(heapoid, ShareUpdateExclusiveLock);
+ heapRel = table_open(heapoid, ShareUpdateExclusiveLock);
else
heapRel = NULL;
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 3415a697398..220c28146ac 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -9082,10 +9082,10 @@ heap_sync(Relation rel)
{
Relation toastrel;
- toastrel = heap_open(rel->rd_rel->reltoastrelid, AccessShareLock);
+ toastrel = table_open(rel->rd_rel->reltoastrelid, AccessShareLock);
FlushRelationBuffers(toastrel);
smgrimmedsync(toastrel->rd_smgr, MAIN_FORKNUM);
- heap_close(toastrel, AccessShareLock);
+ table_close(toastrel, AccessShareLock);
}
}
diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c
index 0ffc5392a6d..6763fb920c2 100644
--- a/src/backend/access/heap/tuptoaster.c
+++ b/src/backend/access/heap/tuptoaster.c
@@ -1422,7 +1422,7 @@ toast_get_valid_index(Oid toastoid, LOCKMODE lock)
Relation toastrel;
/* Open the toast relation */
- toastrel = heap_open(toastoid, lock);
+ toastrel = table_open(toastoid, lock);
/* Look for the valid index of the toast relation */
validIndex = toast_open_indexes(toastrel,
@@ -1433,7 +1433,7 @@ toast_get_valid_index(Oid toastoid, LOCKMODE lock)
/* Close the toast relation and all its indexes */
toast_close_indexes(toastidxs, num_indexes, lock);
- heap_close(toastrel, lock);
+ table_close(toastrel, lock);
return validIndexOid;
}
@@ -1487,7 +1487,7 @@ toast_save_datum(Relation rel, Datum value,
* uniqueness of the OID we assign to the toasted item, even though it has
* additional columns besides OID.
*/
- toastrel = heap_open(rel->rd_rel->reltoastrelid, RowExclusiveLock);
+ toastrel = table_open(rel->rd_rel->reltoastrelid, RowExclusiveLock);
toasttupDesc = toastrel->rd_att;
/* Open all the toast indexes and look for the valid one */
@@ -1692,7 +1692,7 @@ toast_save_datum(Relation rel, Datum value,
* Done - close toast relation and its indexes
*/
toast_close_indexes(toastidxs, num_indexes, RowExclusiveLock);
- heap_close(toastrel, RowExclusiveLock);
+ table_close(toastrel, RowExclusiveLock);
/*
* Create the TOAST pointer value that we'll return
@@ -1734,7 +1734,7 @@ toast_delete_datum(Relation rel, Datum value, bool is_speculative)
/*
* Open the toast relation and its indexes
*/
- toastrel = heap_open(toast_pointer.va_toastrelid, RowExclusiveLock);
+ toastrel = table_open(toast_pointer.va_toastrelid, RowExclusiveLock);
/* Fetch valid relation used for process */
validIndex = toast_open_indexes(toastrel,
@@ -1774,7 +1774,7 @@ toast_delete_datum(Relation rel, Datum value, bool is_speculative)
*/
systable_endscan_ordered(toastscan);
toast_close_indexes(toastidxs, num_indexes, RowExclusiveLock);
- heap_close(toastrel, RowExclusiveLock);
+ table_close(toastrel, RowExclusiveLock);
}
@@ -1840,11 +1840,11 @@ toastid_valueid_exists(Oid toastrelid, Oid valueid)
bool result;
Relation toastrel;
- toastrel = heap_open(toastrelid, AccessShareLock);
+ toastrel = table_open(toastrelid, AccessShareLock);
result = toastrel_valueid_exists(toastrel, valueid);
- heap_close(toastrel, AccessShareLock);
+ table_close(toastrel, AccessShareLock);
return result;
}
@@ -1899,7 +1899,7 @@ toast_fetch_datum(struct varlena *attr)
/*
* Open the toast relation and its indexes
*/
- toastrel = heap_open(toast_pointer.va_toastrelid, AccessShareLock);
+ toastrel = table_open(toast_pointer.va_toastrelid, AccessShareLock);
toasttupDesc = toastrel->rd_att;
/* Look for the valid index of the toast relation */
@@ -2016,7 +2016,7 @@ toast_fetch_datum(struct varlena *attr)
*/
systable_endscan_ordered(toastscan);
toast_close_indexes(toastidxs, num_indexes, AccessShareLock);
- heap_close(toastrel, AccessShareLock);
+ table_close(toastrel, AccessShareLock);
return result;
}
@@ -2102,7 +2102,7 @@ toast_fetch_datum_slice(struct varlena *attr, int32 sliceoffset, int32 length)
/*
* Open the toast relation and its indexes
*/
- toastrel = heap_open(toast_pointer.va_toastrelid, AccessShareLock);
+ toastrel = table_open(toast_pointer.va_toastrelid, AccessShareLock);
toasttupDesc = toastrel->rd_att;
/* Look for the valid index of toast relation */
@@ -2249,7 +2249,7 @@ toast_fetch_datum_slice(struct varlena *attr, int32 sliceoffset, int32 length)
*/
systable_endscan_ordered(toastscan);
toast_close_indexes(toastidxs, num_indexes, AccessShareLock);
- heap_close(toastrel, AccessShareLock);
+ table_close(toastrel, AccessShareLock);
return result;
}
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
index 83966dc4d41..d9de2be5a88 100644
--- a/src/backend/access/nbtree/nbtsort.c
+++ b/src/backend/access/nbtree/nbtsort.c
@@ -1557,7 +1557,7 @@ _bt_parallel_build_main(dsm_segment *seg, shm_toc *toc)
}
/* Open relations within worker */
- heapRel = heap_open(btshared->heaprelid, heapLockmode);
+ heapRel = table_open(btshared->heaprelid, heapLockmode);
indexRel = index_open(btshared->indexrelid, indexLockmode);
/* Initialize worker's own spool */
@@ -1602,7 +1602,7 @@ _bt_parallel_build_main(dsm_segment *seg, shm_toc *toc)
#endif /* BTREE_BUILD_STATS */
index_close(indexRel, indexLockmode);
- heap_close(heapRel, heapLockmode);
+ table_close(heapRel, heapLockmode);
}
/*
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 63bb1349496..bec0a93e438 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -604,7 +604,7 @@ boot_openrel(char *relname)
if (Typ == NULL)
{
/* We can now load the pg_type data */
- rel = heap_open(TypeRelationId, NoLock);
+ rel = table_open(TypeRelationId, NoLock);
scan = heap_beginscan_catalog(rel, 0, NULL);
i = 0;
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
@@ -625,7 +625,7 @@ boot_openrel(char *relname)
app++;
}
heap_endscan(scan);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
if (boot_reldesc != NULL)
@@ -634,7 +634,7 @@ boot_openrel(char *relname)
elog(DEBUG4, "open relation %s, attrsize %d",
relname, (int) ATTRIBUTE_FIXED_PART_SIZE);
- boot_reldesc = heap_openrv(makeRangeVar(NULL, relname, -1), NoLock);
+ boot_reldesc = table_openrv(makeRangeVar(NULL, relname, -1), NoLock);
numattr = RelationGetNumberOfAttributes(boot_reldesc);
for (i = 0; i < numattr; i++)
{
@@ -680,7 +680,7 @@ closerel(char *name)
{
elog(DEBUG4, "close relation %s",
RelationGetRelationName(boot_reldesc));
- heap_close(boot_reldesc, NoLock);
+ table_close(boot_reldesc, NoLock);
boot_reldesc = NULL;
}
}
@@ -939,7 +939,7 @@ gettype(char *type)
return i;
}
elog(DEBUG4, "external type: %s", type);
- rel = heap_open(TypeRelationId, NoLock);
+ rel = table_open(TypeRelationId, NoLock);
scan = heap_beginscan_catalog(rel, 0, NULL);
i = 0;
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
@@ -959,7 +959,7 @@ gettype(char *type)
sizeof((*app)->am_typ));
}
heap_endscan(scan);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return gettype(type);
}
elog(ERROR, "unrecognized type \"%s\"", type);
@@ -1128,12 +1128,12 @@ build_indices(void)
Relation ind;
/* need not bother with locks during bootstrap */
- heap = heap_open(ILHead->il_heap, NoLock);
+ heap = table_open(ILHead->il_heap, NoLock);
ind = index_open(ILHead->il_ind, NoLock);
index_build(heap, ind, ILHead->il_info, false, false, false);
index_close(ind, NoLock);
- heap_close(heap, NoLock);
+ table_close(heap, NoLock);
}
}
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index b4f3bd49993..fc7e0297f9b 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -843,7 +843,7 @@ objectsInSchemaToOids(ObjectType objtype, List *nspnames)
BTEqualStrategyNumber, F_CHAREQ,
CharGetDatum(PROKIND_PROCEDURE));
- rel = heap_open(ProcedureRelationId, AccessShareLock);
+ rel = table_open(ProcedureRelationId, AccessShareLock);
scan = heap_beginscan_catalog(rel, keycount, key);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
@@ -854,7 +854,7 @@ objectsInSchemaToOids(ObjectType objtype, List *nspnames)
}
heap_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
}
break;
default:
@@ -890,7 +890,7 @@ getRelationsInNamespace(Oid namespaceId, char relkind)
BTEqualStrategyNumber, F_CHAREQ,
CharGetDatum(relkind));
- rel = heap_open(RelationRelationId, AccessShareLock);
+ rel = table_open(RelationRelationId, AccessShareLock);
scan = heap_beginscan_catalog(rel, 2, key);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
@@ -901,7 +901,7 @@ getRelationsInNamespace(Oid namespaceId, char relkind)
}
heap_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
return relations;
}
@@ -1166,7 +1166,7 @@ SetDefaultACL(InternalDefaultACL *iacls)
Oid *oldmembers;
Oid *newmembers;
- rel = heap_open(DefaultAclRelationId, RowExclusiveLock);
+ rel = table_open(DefaultAclRelationId, RowExclusiveLock);
/*
* The default for a global entry is the hard-wired default ACL for the
@@ -1390,7 +1390,7 @@ SetDefaultACL(InternalDefaultACL *iacls)
if (HeapTupleIsValid(tuple))
ReleaseSysCache(tuple);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
@@ -1412,7 +1412,7 @@ RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid)
HeapTuple tuple;
/* first fetch info needed by SetDefaultACL */
- rel = heap_open(DefaultAclRelationId, AccessShareLock);
+ rel = table_open(DefaultAclRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_default_acl_oid,
@@ -1457,7 +1457,7 @@ RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid)
}
systable_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
iacls.is_grant = false;
iacls.all_privs = true;
@@ -1535,7 +1535,7 @@ RemoveDefaultACLById(Oid defaclOid)
SysScanDesc scan;
HeapTuple tuple;
- rel = heap_open(DefaultAclRelationId, RowExclusiveLock);
+ rel = table_open(DefaultAclRelationId, RowExclusiveLock);
ScanKeyInit(&skey[0],
Anum_pg_default_acl_oid,
@@ -1553,7 +1553,7 @@ RemoveDefaultACLById(Oid defaclOid)
CatalogTupleDelete(rel, &tuple->t_self);
systable_endscan(scan);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
@@ -1798,8 +1798,8 @@ ExecGrant_Relation(InternalGrant *istmt)
Relation attRelation;
ListCell *cell;
- relation = heap_open(RelationRelationId, RowExclusiveLock);
- attRelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ relation = table_open(RelationRelationId, RowExclusiveLock);
+ attRelation = table_open(AttributeRelationId, RowExclusiveLock);
foreach(cell, istmt->objects)
{
@@ -2119,8 +2119,8 @@ ExecGrant_Relation(InternalGrant *istmt)
CommandCounterIncrement();
}
- heap_close(attRelation, RowExclusiveLock);
- heap_close(relation, RowExclusiveLock);
+ table_close(attRelation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
static void
@@ -2132,7 +2132,7 @@ ExecGrant_Database(InternalGrant *istmt)
if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
istmt->privileges = ACL_ALL_RIGHTS_DATABASE;
- relation = heap_open(DatabaseRelationId, RowExclusiveLock);
+ relation = table_open(DatabaseRelationId, RowExclusiveLock);
foreach(cell, istmt->objects)
{
@@ -2240,7 +2240,7 @@ ExecGrant_Database(InternalGrant *istmt)
CommandCounterIncrement();
}
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
static void
@@ -2252,7 +2252,7 @@ ExecGrant_Fdw(InternalGrant *istmt)
if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
istmt->privileges = ACL_ALL_RIGHTS_FDW;
- relation = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
+ relation = table_open(ForeignDataWrapperRelationId, RowExclusiveLock);
foreach(cell, istmt->objects)
{
@@ -2367,7 +2367,7 @@ ExecGrant_Fdw(InternalGrant *istmt)
CommandCounterIncrement();
}
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
static void
@@ -2379,7 +2379,7 @@ ExecGrant_ForeignServer(InternalGrant *istmt)
if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
istmt->privileges = ACL_ALL_RIGHTS_FOREIGN_SERVER;
- relation = heap_open(ForeignServerRelationId, RowExclusiveLock);
+ relation = table_open(ForeignServerRelationId, RowExclusiveLock);
foreach(cell, istmt->objects)
{
@@ -2492,7 +2492,7 @@ ExecGrant_ForeignServer(InternalGrant *istmt)
CommandCounterIncrement();
}
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
static void
@@ -2504,7 +2504,7 @@ ExecGrant_Function(InternalGrant *istmt)
if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
istmt->privileges = ACL_ALL_RIGHTS_FUNCTION;
- relation = heap_open(ProcedureRelationId, RowExclusiveLock);
+ relation = table_open(ProcedureRelationId, RowExclusiveLock);
foreach(cell, istmt->objects)
{
@@ -2615,7 +2615,7 @@ ExecGrant_Function(InternalGrant *istmt)
CommandCounterIncrement();
}
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
static void
@@ -2627,7 +2627,7 @@ ExecGrant_Language(InternalGrant *istmt)
if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
istmt->privileges = ACL_ALL_RIGHTS_LANGUAGE;
- relation = heap_open(LanguageRelationId, RowExclusiveLock);
+ relation = table_open(LanguageRelationId, RowExclusiveLock);
foreach(cell, istmt->objects)
{
@@ -2746,7 +2746,7 @@ ExecGrant_Language(InternalGrant *istmt)
CommandCounterIncrement();
}
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
static void
@@ -2758,7 +2758,7 @@ ExecGrant_Largeobject(InternalGrant *istmt)
if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
istmt->privileges = ACL_ALL_RIGHTS_LARGEOBJECT;
- relation = heap_open(LargeObjectMetadataRelationId,
+ relation = table_open(LargeObjectMetadataRelationId,
RowExclusiveLock);
foreach(cell, istmt->objects)
@@ -2886,7 +2886,7 @@ ExecGrant_Largeobject(InternalGrant *istmt)
CommandCounterIncrement();
}
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
static void
@@ -2898,7 +2898,7 @@ ExecGrant_Namespace(InternalGrant *istmt)
if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
istmt->privileges = ACL_ALL_RIGHTS_SCHEMA;
- relation = heap_open(NamespaceRelationId, RowExclusiveLock);
+ relation = table_open(NamespaceRelationId, RowExclusiveLock);
foreach(cell, istmt->objects)
{
@@ -3010,7 +3010,7 @@ ExecGrant_Namespace(InternalGrant *istmt)
CommandCounterIncrement();
}
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
static void
@@ -3022,7 +3022,7 @@ ExecGrant_Tablespace(InternalGrant *istmt)
if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
istmt->privileges = ACL_ALL_RIGHTS_TABLESPACE;
- relation = heap_open(TableSpaceRelationId, RowExclusiveLock);
+ relation = table_open(TableSpaceRelationId, RowExclusiveLock);
foreach(cell, istmt->objects)
{
@@ -3130,7 +3130,7 @@ ExecGrant_Tablespace(InternalGrant *istmt)
CommandCounterIncrement();
}
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
static void
@@ -3142,7 +3142,7 @@ ExecGrant_Type(InternalGrant *istmt)
if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
istmt->privileges = ACL_ALL_RIGHTS_TYPE;
- relation = heap_open(TypeRelationId, RowExclusiveLock);
+ relation = table_open(TypeRelationId, RowExclusiveLock);
foreach(cell, istmt->objects)
{
@@ -3267,7 +3267,7 @@ ExecGrant_Type(InternalGrant *istmt)
CommandCounterIncrement();
}
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
@@ -4116,7 +4116,7 @@ pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid,
/*
* Get the largeobject's ACL from pg_language_metadata
*/
- pg_lo_meta = heap_open(LargeObjectMetadataRelationId,
+ pg_lo_meta = table_open(LargeObjectMetadataRelationId,
AccessShareLock);
ScanKeyInit(&entry[0],
@@ -4159,7 +4159,7 @@ pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid,
systable_endscan(scan);
- heap_close(pg_lo_meta, AccessShareLock);
+ table_close(pg_lo_meta, AccessShareLock);
return result;
}
@@ -4898,7 +4898,7 @@ pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid)
return true;
/* There's no syscache for pg_largeobject_metadata */
- pg_lo_meta = heap_open(LargeObjectMetadataRelationId,
+ pg_lo_meta = table_open(LargeObjectMetadataRelationId,
AccessShareLock);
ScanKeyInit(&entry[0],
@@ -4919,7 +4919,7 @@ pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid)
ownerId = ((Form_pg_largeobject_metadata) GETSTRUCT(tuple))->lomowner;
systable_endscan(scan);
- heap_close(pg_lo_meta, AccessShareLock);
+ table_close(pg_lo_meta, AccessShareLock);
return has_privs_of_role(roleid, ownerId);
}
@@ -5261,7 +5261,7 @@ pg_extension_ownercheck(Oid ext_oid, Oid roleid)
return true;
/* There's no syscache for pg_extension, so do it the hard way */
- pg_extension = heap_open(ExtensionRelationId, AccessShareLock);
+ pg_extension = table_open(ExtensionRelationId, AccessShareLock);
ScanKeyInit(&entry[0],
Anum_pg_extension_oid,
@@ -5281,7 +5281,7 @@ pg_extension_ownercheck(Oid ext_oid, Oid roleid)
ownerId = ((Form_pg_extension) GETSTRUCT(tuple))->extowner;
systable_endscan(scan);
- heap_close(pg_extension, AccessShareLock);
+ table_close(pg_extension, AccessShareLock);
return has_privs_of_role(roleid, ownerId);
}
@@ -5726,7 +5726,7 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
SysScanDesc scan;
Relation relation;
- relation = heap_open(LargeObjectMetadataRelationId, RowExclusiveLock);
+ relation = table_open(LargeObjectMetadataRelationId, RowExclusiveLock);
/* There's no syscache for pg_largeobject_metadata */
ScanKeyInit(&entry[0],
@@ -5968,7 +5968,7 @@ recordExtensionInitPrivWorker(Oid objoid, Oid classoid, int objsubid, Acl *new_a
HeapTuple tuple;
HeapTuple oldtuple;
- relation = heap_open(InitPrivsRelationId, RowExclusiveLock);
+ relation = table_open(InitPrivsRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_init_privs_objoid,
@@ -6054,5 +6054,5 @@ recordExtensionInitPrivWorker(Oid objoid, Oid classoid, int objsubid, Acl *new_a
/* prevent error when processing objects multiple times */
CommandCounterIncrement();
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 48303926e48..a9d2621a7ee 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -481,7 +481,7 @@ pg_nextoid(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to call pg_nextoid")));
- rel = heap_open(reloid, RowExclusiveLock);
+ rel = table_open(reloid, RowExclusiveLock);
idx = index_open(idxoid, RowExclusiveLock);
if (!IsSystemRelation(rel))
@@ -523,7 +523,7 @@ pg_nextoid(PG_FUNCTION_ARGS)
newoid = GetNewOidWithIndex(rel, idxoid, attno);
ReleaseSysCache(atttuple);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
index_close(idx, RowExclusiveLock);
return newoid;
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index 014e49fe77c..d23fc382801 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -309,7 +309,7 @@ performDeletion(const ObjectAddress *object,
* We save some cycles by opening pg_depend just once and passing the
* Relation pointer down to all the recursive deletion steps.
*/
- depRel = heap_open(DependRelationId, RowExclusiveLock);
+ depRel = table_open(DependRelationId, RowExclusiveLock);
/*
* Acquire deletion lock on the target object. (Ideally the caller has
@@ -345,7 +345,7 @@ performDeletion(const ObjectAddress *object,
/* And clean up */
free_object_addresses(targetObjects);
- heap_close(depRel, RowExclusiveLock);
+ table_close(depRel, RowExclusiveLock);
}
/*
@@ -373,7 +373,7 @@ performMultipleDeletions(const ObjectAddresses *objects,
* We save some cycles by opening pg_depend just once and passing the
* Relation pointer down to all the recursive deletion steps.
*/
- depRel = heap_open(DependRelationId, RowExclusiveLock);
+ depRel = table_open(DependRelationId, RowExclusiveLock);
/*
* Construct a list of objects to delete (ie, the given objects plus
@@ -421,7 +421,7 @@ performMultipleDeletions(const ObjectAddresses *objects,
/* And clean up */
free_object_addresses(targetObjects);
- heap_close(depRel, RowExclusiveLock);
+ table_close(depRel, RowExclusiveLock);
}
/*
@@ -1024,7 +1024,7 @@ deleteOneObject(const ObjectAddress *object, Relation *depRel, int flags)
* relation open across doDeletion().
*/
if (flags & PERFORM_DELETION_CONCURRENTLY)
- heap_close(*depRel, RowExclusiveLock);
+ table_close(*depRel, RowExclusiveLock);
/*
* Delete the object itself, in an object-type-dependent way.
@@ -1041,7 +1041,7 @@ deleteOneObject(const ObjectAddress *object, Relation *depRel, int flags)
* Reopen depRel if we closed it above
*/
if (flags & PERFORM_DELETION_CONCURRENTLY)
- *depRel = heap_open(DependRelationId, RowExclusiveLock);
+ *depRel = table_open(DependRelationId, RowExclusiveLock);
/*
* Now remove any pg_depend records that link from this object to others.
@@ -2558,7 +2558,7 @@ DeleteInitPrivs(const ObjectAddress *object)
SysScanDesc scan;
HeapTuple oldtuple;
- relation = heap_open(InitPrivsRelationId, RowExclusiveLock);
+ relation = table_open(InitPrivsRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_init_privs_objoid,
@@ -2581,5 +2581,5 @@ DeleteInitPrivs(const ObjectAddress *object)
systable_endscan(scan);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 07e720df2fc..c11bbd19c71 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -713,7 +713,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
/*
* open pg_attribute and its indexes.
*/
- rel = heap_open(AttributeRelationId, RowExclusiveLock);
+ rel = table_open(AttributeRelationId, RowExclusiveLock);
indstate = CatalogOpenIndexes(rel);
@@ -776,7 +776,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
*/
CatalogCloseIndexes(indstate);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/* --------------------------------
@@ -1070,7 +1070,7 @@ heap_create_with_catalog(const char *relname,
ObjectAddress new_type_addr;
Oid new_array_oid = InvalidOid;
- pg_class_desc = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class_desc = table_open(RelationRelationId, RowExclusiveLock);
/*
* sanity checks
@@ -1376,8 +1376,8 @@ heap_create_with_catalog(const char *relname,
* ok, the relation has been cataloged, so close our relations and return
* the OID of the newly created relation.
*/
- heap_close(new_rel_desc, NoLock); /* do not unlock till end of xact */
- heap_close(pg_class_desc, RowExclusiveLock);
+ table_close(new_rel_desc, NoLock); /* do not unlock till end of xact */
+ table_close(pg_class_desc, RowExclusiveLock);
return relid;
}
@@ -1420,7 +1420,7 @@ RelationRemoveInheritance(Oid relid)
ScanKeyData key;
HeapTuple tuple;
- catalogRelation = heap_open(InheritsRelationId, RowExclusiveLock);
+ catalogRelation = table_open(InheritsRelationId, RowExclusiveLock);
ScanKeyInit(&key,
Anum_pg_inherits_inhrelid,
@@ -1434,7 +1434,7 @@ RelationRemoveInheritance(Oid relid)
CatalogTupleDelete(catalogRelation, &tuple->t_self);
systable_endscan(scan);
- heap_close(catalogRelation, RowExclusiveLock);
+ table_close(catalogRelation, RowExclusiveLock);
}
/*
@@ -1452,7 +1452,7 @@ DeleteRelationTuple(Oid relid)
HeapTuple tup;
/* Grab an appropriate lock on the pg_class relation */
- pg_class_desc = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class_desc = table_open(RelationRelationId, RowExclusiveLock);
tup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tup))
@@ -1463,7 +1463,7 @@ DeleteRelationTuple(Oid relid)
ReleaseSysCache(tup);
- heap_close(pg_class_desc, RowExclusiveLock);
+ table_close(pg_class_desc, RowExclusiveLock);
}
/*
@@ -1483,7 +1483,7 @@ DeleteAttributeTuples(Oid relid)
HeapTuple atttup;
/* Grab an appropriate lock on the pg_attribute relation */
- attrel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrel = table_open(AttributeRelationId, RowExclusiveLock);
/* Use the index to scan only attributes of the target relation */
ScanKeyInit(&key[0],
@@ -1500,7 +1500,7 @@ DeleteAttributeTuples(Oid relid)
/* Clean up after the scan */
systable_endscan(scan);
- heap_close(attrel, RowExclusiveLock);
+ table_close(attrel, RowExclusiveLock);
}
/*
@@ -1520,7 +1520,7 @@ DeleteSystemAttributeTuples(Oid relid)
HeapTuple atttup;
/* Grab an appropriate lock on the pg_attribute relation */
- attrel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrel = table_open(AttributeRelationId, RowExclusiveLock);
/* Use the index to scan only system attributes of the target relation */
ScanKeyInit(&key[0],
@@ -1541,7 +1541,7 @@ DeleteSystemAttributeTuples(Oid relid)
/* Clean up after the scan */
systable_endscan(scan);
- heap_close(attrel, RowExclusiveLock);
+ table_close(attrel, RowExclusiveLock);
}
/*
@@ -1570,7 +1570,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
*/
rel = relation_open(relid, AccessExclusiveLock);
- attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy2(ATTNUM,
ObjectIdGetDatum(relid),
@@ -1649,7 +1649,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
* backends of the change.
*/
- heap_close(attr_rel, RowExclusiveLock);
+ table_close(attr_rel, RowExclusiveLock);
if (attnum > 0)
RemoveStatistics(relid, attnum);
@@ -1673,7 +1673,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
HeapTuple tuple;
bool found = false;
- attrdef_rel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
+ attrdef_rel = table_open(AttrDefaultRelationId, RowExclusiveLock);
ScanKeyInit(&scankeys[0],
Anum_pg_attrdef_adrelid,
@@ -1704,7 +1704,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
}
systable_endscan(scan);
- heap_close(attrdef_rel, RowExclusiveLock);
+ table_close(attrdef_rel, RowExclusiveLock);
if (complain && !found)
elog(ERROR, "could not find attrdef tuple for relation %u attnum %d",
@@ -1731,7 +1731,7 @@ RemoveAttrDefaultById(Oid attrdefId)
AttrNumber myattnum;
/* Grab an appropriate lock on the pg_attrdef relation */
- attrdef_rel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
+ attrdef_rel = table_open(AttrDefaultRelationId, RowExclusiveLock);
/* Find the pg_attrdef tuple */
ScanKeyInit(&scankeys[0],
@@ -1756,10 +1756,10 @@ RemoveAttrDefaultById(Oid attrdefId)
CatalogTupleDelete(attrdef_rel, &tuple->t_self);
systable_endscan(scan);
- heap_close(attrdef_rel, RowExclusiveLock);
+ table_close(attrdef_rel, RowExclusiveLock);
/* Fix the pg_attribute row */
- attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy2(ATTNUM,
ObjectIdGetDatum(myrelid),
@@ -1776,7 +1776,7 @@ RemoveAttrDefaultById(Oid attrdefId)
* Our update of the pg_attribute row will force a relcache rebuild, so
* there's nothing else to do here.
*/
- heap_close(attr_rel, RowExclusiveLock);
+ table_close(attr_rel, RowExclusiveLock);
/* Keep lock on attribute's rel until end of xact */
relation_close(myrel, NoLock);
@@ -1856,7 +1856,7 @@ heap_drop_with_catalog(Oid relid)
Relation rel;
HeapTuple tuple;
- rel = heap_open(ForeignTableRelationId, RowExclusiveLock);
+ rel = table_open(ForeignTableRelationId, RowExclusiveLock);
tuple = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
@@ -1865,7 +1865,7 @@ heap_drop_with_catalog(Oid relid)
CatalogTupleDelete(rel, &tuple->t_self);
ReleaseSysCache(tuple);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
@@ -1994,7 +1994,7 @@ RelationClearMissing(Relation rel)
/* Get a lock on pg_attribute */
- attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
/* process each non-system attribute, including any dropped columns */
for (attnum = 1; attnum <= natts; attnum++)
@@ -2026,7 +2026,7 @@ RelationClearMissing(Relation rel)
* Our update of the pg_attribute rows will force a relcache rebuild, so
* there's nothing else to do here.
*/
- heap_close(attr_rel, RowExclusiveLock);
+ table_close(attr_rel, RowExclusiveLock);
}
/*
@@ -2050,10 +2050,10 @@ SetAttrMissing(Oid relid, char *attname, char *value)
newtup;
/* lock the table the attribute belongs to */
- tablerel = heap_open(relid, AccessExclusiveLock);
+ tablerel = table_open(relid, AccessExclusiveLock);
/* Lock the attribute row and get the data */
- attrrel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrrel = table_open(AttributeRelationId, RowExclusiveLock);
atttup = SearchSysCacheAttName(relid, attname);
if (!HeapTupleIsValid(atttup))
elog(ERROR, "cache lookup failed for attribute %s of relation %u",
@@ -2082,8 +2082,8 @@ SetAttrMissing(Oid relid, char *attname, char *value)
/* clean up */
ReleaseSysCache(atttup);
- heap_close(attrrel, RowExclusiveLock);
- heap_close(tablerel, AccessExclusiveLock);
+ table_close(attrrel, RowExclusiveLock);
+ table_close(tablerel, AccessExclusiveLock);
}
/*
@@ -2113,7 +2113,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
ObjectAddress colobject,
defobject;
- adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
+ adrel = table_open(AttrDefaultRelationId, RowExclusiveLock);
/*
* Flatten expression to string form for storage.
@@ -2137,7 +2137,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
defobject.objectId = attrdefOid;
defobject.objectSubId = 0;
- heap_close(adrel, RowExclusiveLock);
+ table_close(adrel, RowExclusiveLock);
/* now can free some of the stuff allocated above */
pfree(DatumGetPointer(values[Anum_pg_attrdef_adbin - 1]));
@@ -2148,7 +2148,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
* Update the pg_attribute entry for the column to show that a default
* exists.
*/
- attrrel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrrel = table_open(AttributeRelationId, RowExclusiveLock);
atttup = SearchSysCacheCopy2(ATTNUM,
ObjectIdGetDatum(RelationGetRelid(rel)),
Int16GetDatum(attnum));
@@ -2222,7 +2222,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
pfree(DatumGetPointer(missingval));
}
- heap_close(attrrel, RowExclusiveLock);
+ table_close(attrrel, RowExclusiveLock);
heap_freetuple(atttup);
/*
@@ -2699,7 +2699,7 @@ MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr,
HeapTuple tup;
/* Search for a pg_constraint entry with same name and relation */
- conDesc = heap_open(ConstraintRelationId, RowExclusiveLock);
+ conDesc = table_open(ConstraintRelationId, RowExclusiveLock);
found = false;
@@ -2821,7 +2821,7 @@ MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr,
}
systable_endscan(conscan);
- heap_close(conDesc, RowExclusiveLock);
+ table_close(conDesc, RowExclusiveLock);
return found;
}
@@ -2843,7 +2843,7 @@ SetRelationNumChecks(Relation rel, int numchecks)
HeapTuple reltup;
Form_pg_class relStruct;
- relrel = heap_open(RelationRelationId, RowExclusiveLock);
+ relrel = table_open(RelationRelationId, RowExclusiveLock);
reltup = SearchSysCacheCopy1(RELOID,
ObjectIdGetDatum(RelationGetRelid(rel)));
if (!HeapTupleIsValid(reltup))
@@ -2864,7 +2864,7 @@ SetRelationNumChecks(Relation rel, int numchecks)
}
heap_freetuple(reltup);
- heap_close(relrel, RowExclusiveLock);
+ table_close(relrel, RowExclusiveLock);
}
/*
@@ -3001,7 +3001,7 @@ RemoveStatistics(Oid relid, AttrNumber attnum)
int nkeys;
HeapTuple tuple;
- pgstatistic = heap_open(StatisticRelationId, RowExclusiveLock);
+ pgstatistic = table_open(StatisticRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_statistic_starelid,
@@ -3028,7 +3028,7 @@ RemoveStatistics(Oid relid, AttrNumber attnum)
systable_endscan(scan);
- heap_close(pgstatistic, RowExclusiveLock);
+ table_close(pgstatistic, RowExclusiveLock);
}
@@ -3092,7 +3092,7 @@ heap_truncate(List *relids)
Oid rid = lfirst_oid(cell);
Relation rel;
- rel = heap_open(rid, AccessExclusiveLock);
+ rel = table_open(rid, AccessExclusiveLock);
relations = lappend(relations, rel);
}
@@ -3108,7 +3108,7 @@ heap_truncate(List *relids)
heap_truncate_one_rel(rel);
/* Close the relation, but keep exclusive lock on it until commit */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
}
@@ -3143,12 +3143,12 @@ heap_truncate_one_rel(Relation rel)
toastrelid = rel->rd_rel->reltoastrelid;
if (OidIsValid(toastrelid))
{
- Relation toastrel = heap_open(toastrelid, AccessExclusiveLock);
+ Relation toastrel = table_open(toastrelid, AccessExclusiveLock);
RelationTruncate(toastrel, 0);
RelationTruncateIndexes(toastrel);
/* keep the lock... */
- heap_close(toastrel, NoLock);
+ table_close(toastrel, NoLock);
}
}
@@ -3272,7 +3272,7 @@ heap_truncate_find_FKs(List *relationIds)
* Must scan pg_constraint. Right now, it is a seqscan because there is
* no available index on confrelid.
*/
- fkeyRel = heap_open(ConstraintRelationId, AccessShareLock);
+ fkeyRel = table_open(ConstraintRelationId, AccessShareLock);
fkeyScan = systable_beginscan(fkeyRel, InvalidOid, false,
NULL, 0, NULL);
@@ -3295,7 +3295,7 @@ heap_truncate_find_FKs(List *relationIds)
}
systable_endscan(fkeyScan);
- heap_close(fkeyRel, AccessShareLock);
+ table_close(fkeyRel, AccessShareLock);
return result;
}
@@ -3384,7 +3384,7 @@ StorePartitionKey(Relation rel,
else
partexprDatum = (Datum) 0;
- pg_partitioned_table = heap_open(PartitionedRelationId, RowExclusiveLock);
+ pg_partitioned_table = table_open(PartitionedRelationId, RowExclusiveLock);
MemSet(nulls, false, sizeof(nulls));
@@ -3404,7 +3404,7 @@ StorePartitionKey(Relation rel,
tuple = heap_form_tuple(RelationGetDescr(pg_partitioned_table), values, nulls);
CatalogTupleInsert(pg_partitioned_table, tuple);
- heap_close(pg_partitioned_table, RowExclusiveLock);
+ table_close(pg_partitioned_table, RowExclusiveLock);
/* Mark this relation as dependent on a few things as follows */
myself.classId = RelationRelationId;
@@ -3462,7 +3462,7 @@ RemovePartitionKeyByRelId(Oid relid)
Relation rel;
HeapTuple tuple;
- rel = heap_open(PartitionedRelationId, RowExclusiveLock);
+ rel = table_open(PartitionedRelationId, RowExclusiveLock);
tuple = SearchSysCache1(PARTRELID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
@@ -3472,7 +3472,7 @@ RemovePartitionKeyByRelId(Oid relid)
CatalogTupleDelete(rel, &tuple->t_self);
ReleaseSysCache(tuple);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
@@ -3499,7 +3499,7 @@ StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
Oid defaultPartOid;
/* Update pg_class tuple */
- classRel = heap_open(RelationRelationId, RowExclusiveLock);
+ classRel = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID,
ObjectIdGetDatum(RelationGetRelid(rel)));
if (!HeapTupleIsValid(tuple))
@@ -3532,7 +3532,7 @@ StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
((Form_pg_class) GETSTRUCT(newtuple))->relispartition = true;
CatalogTupleUpdate(classRel, &newtuple->t_self, newtuple);
heap_freetuple(newtuple);
- heap_close(classRel, RowExclusiveLock);
+ table_close(classRel, RowExclusiveLock);
/*
* If we're storing bounds for the default partition, update
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 761218f0574..dbee60c1be3 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -528,7 +528,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
/*
* open the attribute relation and its indexes
*/
- pg_attribute = heap_open(AttributeRelationId, RowExclusiveLock);
+ pg_attribute = table_open(AttributeRelationId, RowExclusiveLock);
indstate = CatalogOpenIndexes(pg_attribute);
@@ -548,7 +548,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
CatalogCloseIndexes(indstate);
- heap_close(pg_attribute, RowExclusiveLock);
+ table_close(pg_attribute, RowExclusiveLock);
}
/* ----------------------------------------------------------------
@@ -626,7 +626,7 @@ UpdateIndexRelation(Oid indexoid,
/*
* open the system catalog index relation
*/
- pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+ pg_index = table_open(IndexRelationId, RowExclusiveLock);
/*
* Build a pg_index tuple
@@ -668,7 +668,7 @@ UpdateIndexRelation(Oid indexoid,
/*
* close the relation and free the tuple
*/
- heap_close(pg_index, RowExclusiveLock);
+ table_close(pg_index, RowExclusiveLock);
heap_freetuple(tuple);
}
@@ -766,7 +766,7 @@ index_create(Relation heapRelation,
relkind = partitioned ? RELKIND_PARTITIONED_INDEX : RELKIND_INDEX;
is_exclusion = (indexInfo->ii_ExclusionOps != NULL);
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
/*
* The index will be in the same namespace as its parent table, and is
@@ -840,7 +840,7 @@ index_create(Relation heapRelation,
(errcode(ERRCODE_DUPLICATE_TABLE),
errmsg("relation \"%s\" already exists, skipping",
indexRelationName)));
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
return InvalidOid;
}
@@ -945,7 +945,7 @@ index_create(Relation heapRelation,
reloptions);
/* done with pg_class */
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
/*
* now update the object id's of all the attribute tuple forms in the
@@ -1404,7 +1404,7 @@ index_constraint_create(Relation heapRelation,
Form_pg_index indexForm;
bool dirty = false;
- pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+ pg_index = table_open(IndexRelationId, RowExclusiveLock);
indexTuple = SearchSysCacheCopy1(INDEXRELID,
ObjectIdGetDatum(indexRelationId));
@@ -1433,7 +1433,7 @@ index_constraint_create(Relation heapRelation,
}
heap_freetuple(indexTuple);
- heap_close(pg_index, RowExclusiveLock);
+ table_close(pg_index, RowExclusiveLock);
}
return referenced;
@@ -1479,7 +1479,7 @@ index_drop(Oid indexId, bool concurrent)
*/
heapId = IndexGetRelation(indexId, false);
lockmode = concurrent ? ShareUpdateExclusiveLock : AccessExclusiveLock;
- userHeapRelation = heap_open(heapId, lockmode);
+ userHeapRelation = table_open(heapId, lockmode);
userIndexRelation = index_open(indexId, lockmode);
/*
@@ -1556,7 +1556,7 @@ index_drop(Oid indexId, bool concurrent)
SET_LOCKTAG_RELATION(heaplocktag, heaprelid.dbId, heaprelid.relId);
indexrelid = userIndexRelation->rd_lockInfo.lockRelId;
- heap_close(userHeapRelation, NoLock);
+ table_close(userHeapRelation, NoLock);
index_close(userIndexRelation, NoLock);
/*
@@ -1599,7 +1599,7 @@ index_drop(Oid indexId, bool concurrent)
* conflicts with existing predicate locks, so now is the time to move
* them to the heap relation.
*/
- userHeapRelation = heap_open(heapId, ShareUpdateExclusiveLock);
+ userHeapRelation = table_open(heapId, ShareUpdateExclusiveLock);
userIndexRelation = index_open(indexId, ShareUpdateExclusiveLock);
TransferPredicateLocksToHeapRelation(userIndexRelation);
@@ -1621,7 +1621,7 @@ index_drop(Oid indexId, bool concurrent)
/*
* Close the relations again, though still holding session lock.
*/
- heap_close(userHeapRelation, NoLock);
+ table_close(userHeapRelation, NoLock);
index_close(userIndexRelation, NoLock);
/*
@@ -1644,7 +1644,7 @@ index_drop(Oid indexId, bool concurrent)
* leave nothing to chance and grab AccessExclusiveLock on the index
* before the physical deletion.
*/
- userHeapRelation = heap_open(heapId, ShareUpdateExclusiveLock);
+ userHeapRelation = table_open(heapId, ShareUpdateExclusiveLock);
userIndexRelation = index_open(indexId, AccessExclusiveLock);
}
else
@@ -1671,7 +1671,7 @@ index_drop(Oid indexId, bool concurrent)
/*
* fix INDEX relation, and check for expressional index
*/
- indexRelation = heap_open(IndexRelationId, RowExclusiveLock);
+ indexRelation = table_open(IndexRelationId, RowExclusiveLock);
tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexId));
if (!HeapTupleIsValid(tuple))
@@ -1683,7 +1683,7 @@ index_drop(Oid indexId, bool concurrent)
CatalogTupleDelete(indexRelation, &tuple->t_self);
ReleaseSysCache(tuple);
- heap_close(indexRelation, RowExclusiveLock);
+ table_close(indexRelation, RowExclusiveLock);
/*
* if it has any expression columns, we might have stored statistics about
@@ -1720,7 +1720,7 @@ index_drop(Oid indexId, bool concurrent)
/*
* Close owning rel, but keep lock
*/
- heap_close(userHeapRelation, NoLock);
+ table_close(userHeapRelation, NoLock);
/*
* Release the session locks before we go.
@@ -2120,7 +2120,7 @@ index_update_stats(Relation rel,
* what's really important.
*/
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
/*
* Make a copy of the tuple to update. Normally we use the syscache, but
@@ -2209,7 +2209,7 @@ index_update_stats(Relation rel,
heap_freetuple(tuple);
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
}
@@ -2350,7 +2350,7 @@ index_build(Relation heapRelation,
HeapTuple indexTuple;
Form_pg_index indexForm;
- pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+ pg_index = table_open(IndexRelationId, RowExclusiveLock);
indexTuple = SearchSysCacheCopy1(INDEXRELID,
ObjectIdGetDatum(indexId));
@@ -2365,7 +2365,7 @@ index_build(Relation heapRelation,
CatalogTupleUpdate(pg_index, &indexTuple->t_self, indexTuple);
heap_freetuple(indexTuple);
- heap_close(pg_index, RowExclusiveLock);
+ table_close(pg_index, RowExclusiveLock);
}
/*
@@ -3133,7 +3133,7 @@ validate_index(Oid heapId, Oid indexId, Snapshot snapshot)
int save_nestlevel;
/* Open and lock the parent heap relation */
- heapRelation = heap_open(heapId, ShareUpdateExclusiveLock);
+ heapRelation = table_open(heapId, ShareUpdateExclusiveLock);
/* And the target index relation */
indexRelation = index_open(indexId, RowExclusiveLock);
@@ -3209,7 +3209,7 @@ validate_index(Oid heapId, Oid indexId, Snapshot snapshot)
/* Close rels, but keep locks */
index_close(indexRelation, NoLock);
- heap_close(heapRelation, NoLock);
+ table_close(heapRelation, NoLock);
}
/*
@@ -3531,7 +3531,7 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
Assert(GetTopTransactionIdIfAny() == InvalidTransactionId);
/* Open pg_index and fetch a writable copy of the index's tuple */
- pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+ pg_index = table_open(IndexRelationId, RowExclusiveLock);
indexTuple = SearchSysCacheCopy1(INDEXRELID,
ObjectIdGetDatum(indexId));
@@ -3591,7 +3591,7 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
/* ... and write it back in-place */
heap_inplace_update(pg_index, indexTuple);
- heap_close(pg_index, RowExclusiveLock);
+ table_close(pg_index, RowExclusiveLock);
}
@@ -3642,7 +3642,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
* we only need to be sure no schema or data changes are going on.
*/
heapId = IndexGetRelation(indexId, false);
- heapRelation = heap_open(heapId, ShareLock);
+ heapRelation = table_open(heapId, ShareLock);
/*
* Open the target index relation and get an exclusive lock on it, to
@@ -3756,7 +3756,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
bool index_bad;
bool early_pruning_enabled = EarlyPruningEnabled(heapRelation);
- pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+ pg_index = table_open(IndexRelationId, RowExclusiveLock);
indexTuple = SearchSysCacheCopy1(INDEXRELID,
ObjectIdGetDatum(indexId));
@@ -3790,7 +3790,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
CacheInvalidateRelcache(heapRelation);
}
- heap_close(pg_index, RowExclusiveLock);
+ table_close(pg_index, RowExclusiveLock);
}
/* Log what we did */
@@ -3803,7 +3803,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
/* Close rels, but keep locks */
index_close(iRel, NoLock);
- heap_close(heapRelation, NoLock);
+ table_close(heapRelation, NoLock);
}
/*
@@ -3855,7 +3855,7 @@ reindex_relation(Oid relid, int flags, int options)
* to prevent schema and data changes in it. The lock level used here
* should match ReindexTable().
*/
- rel = heap_open(relid, ShareLock);
+ rel = table_open(relid, ShareLock);
/*
* This may be useful when implemented someday; but that day is not today.
@@ -3869,7 +3869,7 @@ reindex_relation(Oid relid, int flags, int options)
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("REINDEX of partitioned tables is not yet implemented, skipping \"%s\"",
RelationGetRelationName(rel))));
- heap_close(rel, ShareLock);
+ table_close(rel, ShareLock);
return false;
}
@@ -3970,7 +3970,7 @@ reindex_relation(Oid relid, int flags, int options)
/*
* Close rel, but continue to hold the lock.
*/
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
result = (indexIds != NIL);
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index d68e28c9b43..5f66f177d1a 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -1338,7 +1338,7 @@ get_object_address_relobject(ObjectType objtype, List *object,
/* Extract relation name and open relation. */
relname = list_truncate(list_copy(object), nnames - 1);
- relation = heap_openrv_extended(makeRangeVarFromNameList(relname),
+ relation = table_openrv_extended(makeRangeVarFromNameList(relname),
AccessShareLock,
missing_ok);
@@ -1380,7 +1380,7 @@ get_object_address_relobject(ObjectType objtype, List *object,
if (!OidIsValid(address.objectId))
{
if (relation != NULL)
- heap_close(relation, AccessShareLock);
+ table_close(relation, AccessShareLock);
relation = NULL; /* department of accident prevention */
return address;
@@ -2767,7 +2767,7 @@ getObjectDescription(const ObjectAddress *object)
HeapTuple tup;
Form_pg_cast castForm;
- castDesc = heap_open(CastRelationId, AccessShareLock);
+ castDesc = table_open(CastRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_cast_oid,
@@ -2790,7 +2790,7 @@ getObjectDescription(const ObjectAddress *object)
format_type_be(castForm->casttarget));
systable_endscan(rcscan);
- heap_close(castDesc, AccessShareLock);
+ table_close(castDesc, AccessShareLock);
break;
}
@@ -2888,7 +2888,7 @@ getObjectDescription(const ObjectAddress *object)
Form_pg_attrdef attrdef;
ObjectAddress colobject;
- attrdefDesc = heap_open(AttrDefaultRelationId, AccessShareLock);
+ attrdefDesc = table_open(AttrDefaultRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_attrdef_oid,
@@ -2915,7 +2915,7 @@ getObjectDescription(const ObjectAddress *object)
getObjectDescription(&colobject));
systable_endscan(adscan);
- heap_close(attrdefDesc, AccessShareLock);
+ table_close(attrdefDesc, AccessShareLock);
break;
}
@@ -3000,7 +3000,7 @@ getObjectDescription(const ObjectAddress *object)
Form_pg_amop amopForm;
StringInfoData opfam;
- amopDesc = heap_open(AccessMethodOperatorRelationId,
+ amopDesc = table_open(AccessMethodOperatorRelationId,
AccessShareLock);
ScanKeyInit(&skey[0],
@@ -3037,7 +3037,7 @@ getObjectDescription(const ObjectAddress *object)
pfree(opfam.data);
systable_endscan(amscan);
- heap_close(amopDesc, AccessShareLock);
+ table_close(amopDesc, AccessShareLock);
break;
}
@@ -3050,7 +3050,7 @@ getObjectDescription(const ObjectAddress *object)
Form_pg_amproc amprocForm;
StringInfoData opfam;
- amprocDesc = heap_open(AccessMethodProcedureRelationId,
+ amprocDesc = table_open(AccessMethodProcedureRelationId,
AccessShareLock);
ScanKeyInit(&skey[0],
@@ -3087,7 +3087,7 @@ getObjectDescription(const ObjectAddress *object)
pfree(opfam.data);
systable_endscan(amscan);
- heap_close(amprocDesc, AccessShareLock);
+ table_close(amprocDesc, AccessShareLock);
break;
}
@@ -3100,7 +3100,7 @@ getObjectDescription(const ObjectAddress *object)
Form_pg_rewrite rule;
StringInfoData rel;
- ruleDesc = heap_open(RewriteRelationId, AccessShareLock);
+ ruleDesc = table_open(RewriteRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_rewrite_oid,
@@ -3125,7 +3125,7 @@ getObjectDescription(const ObjectAddress *object)
NameStr(rule->rulename), rel.data);
pfree(rel.data);
systable_endscan(rcscan);
- heap_close(ruleDesc, AccessShareLock);
+ table_close(ruleDesc, AccessShareLock);
break;
}
@@ -3138,7 +3138,7 @@ getObjectDescription(const ObjectAddress *object)
Form_pg_trigger trig;
StringInfoData rel;
- trigDesc = heap_open(TriggerRelationId, AccessShareLock);
+ trigDesc = table_open(TriggerRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_trigger_oid,
@@ -3163,7 +3163,7 @@ getObjectDescription(const ObjectAddress *object)
NameStr(trig->tgname), rel.data);
pfree(rel.data);
systable_endscan(tgscan);
- heap_close(trigDesc, AccessShareLock);
+ table_close(trigDesc, AccessShareLock);
break;
}
@@ -3398,7 +3398,7 @@ getObjectDescription(const ObjectAddress *object)
char *rolename;
char *nspname;
- defaclrel = heap_open(DefaultAclRelationId, AccessShareLock);
+ defaclrel = table_open(DefaultAclRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_default_acl_oid,
@@ -3485,7 +3485,7 @@ getObjectDescription(const ObjectAddress *object)
}
systable_endscan(rcscan);
- heap_close(defaclrel, AccessShareLock);
+ table_close(defaclrel, AccessShareLock);
break;
}
@@ -3525,7 +3525,7 @@ getObjectDescription(const ObjectAddress *object)
Form_pg_policy form_policy;
StringInfoData rel;
- policy_rel = heap_open(PolicyRelationId, AccessShareLock);
+ policy_rel = table_open(PolicyRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_policy_oid,
@@ -3550,7 +3550,7 @@ getObjectDescription(const ObjectAddress *object)
NameStr(form_policy->polname), rel.data);
pfree(rel.data);
systable_endscan(sscan);
- heap_close(policy_rel, AccessShareLock);
+ table_close(policy_rel, AccessShareLock);
break;
}
@@ -3817,7 +3817,7 @@ pg_identify_object(PG_FUNCTION_ARGS)
if (is_objectclass_supported(address.classId))
{
HeapTuple objtup;
- Relation catalog = heap_open(address.classId, AccessShareLock);
+ Relation catalog = table_open(address.classId, AccessShareLock);
objtup = get_catalog_object_by_oid(catalog,
get_object_attnum_oid(address.classId),
@@ -3859,7 +3859,7 @@ pg_identify_object(PG_FUNCTION_ARGS)
}
}
- heap_close(catalog, AccessShareLock);
+ table_close(catalog, AccessShareLock);
}
/* object type */
@@ -4197,7 +4197,7 @@ getConstraintTypeDescription(StringInfo buffer, Oid constroid)
HeapTuple constrTup;
Form_pg_constraint constrForm;
- constrRel = heap_open(ConstraintRelationId, AccessShareLock);
+ constrRel = table_open(ConstraintRelationId, AccessShareLock);
constrTup = get_catalog_object_by_oid(constrRel, Anum_pg_constraint_oid,
constroid);
if (!HeapTupleIsValid(constrTup))
@@ -4212,7 +4212,7 @@ getConstraintTypeDescription(StringInfo buffer, Oid constroid)
else
elog(ERROR, "invalid constraint %u", constrForm->oid);
- heap_close(constrRel, AccessShareLock);
+ table_close(constrRel, AccessShareLock);
}
/*
@@ -4321,7 +4321,7 @@ getObjectIdentityParts(const ObjectAddress *object,
HeapTuple tup;
Form_pg_cast castForm;
- castRel = heap_open(CastRelationId, AccessShareLock);
+ castRel = table_open(CastRelationId, AccessShareLock);
tup = get_catalog_object_by_oid(castRel, Anum_pg_cast_oid,
object->objectId);
@@ -4342,7 +4342,7 @@ getObjectIdentityParts(const ObjectAddress *object,
*objargs = list_make1(format_type_be_qualified(castForm->casttarget));
}
- heap_close(castRel, AccessShareLock);
+ table_close(castRel, AccessShareLock);
break;
}
@@ -4443,7 +4443,7 @@ getObjectIdentityParts(const ObjectAddress *object,
Form_pg_attrdef attrdef;
ObjectAddress colobject;
- attrdefDesc = heap_open(AttrDefaultRelationId, AccessShareLock);
+ attrdefDesc = table_open(AttrDefaultRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_attrdef_oid,
@@ -4470,7 +4470,7 @@ getObjectIdentityParts(const ObjectAddress *object,
objname, objargs));
systable_endscan(adscan);
- heap_close(attrdefDesc, AccessShareLock);
+ table_close(attrdefDesc, AccessShareLock);
break;
}
@@ -4572,7 +4572,7 @@ getObjectIdentityParts(const ObjectAddress *object,
char *ltype;
char *rtype;
- amopDesc = heap_open(AccessMethodOperatorRelationId,
+ amopDesc = table_open(AccessMethodOperatorRelationId,
AccessShareLock);
ScanKeyInit(&skey[0],
@@ -4611,7 +4611,7 @@ getObjectIdentityParts(const ObjectAddress *object,
pfree(opfam.data);
systable_endscan(amscan);
- heap_close(amopDesc, AccessShareLock);
+ table_close(amopDesc, AccessShareLock);
break;
}
@@ -4626,7 +4626,7 @@ getObjectIdentityParts(const ObjectAddress *object,
char *ltype;
char *rtype;
- amprocDesc = heap_open(AccessMethodProcedureRelationId,
+ amprocDesc = table_open(AccessMethodProcedureRelationId,
AccessShareLock);
ScanKeyInit(&skey[0],
@@ -4665,7 +4665,7 @@ getObjectIdentityParts(const ObjectAddress *object,
pfree(opfam.data);
systable_endscan(amscan);
- heap_close(amprocDesc, AccessShareLock);
+ table_close(amprocDesc, AccessShareLock);
break;
}
@@ -4675,7 +4675,7 @@ getObjectIdentityParts(const ObjectAddress *object,
HeapTuple tup;
Form_pg_rewrite rule;
- ruleDesc = heap_open(RewriteRelationId, AccessShareLock);
+ ruleDesc = table_open(RewriteRelationId, AccessShareLock);
tup = get_catalog_object_by_oid(ruleDesc, Anum_pg_rewrite_oid,
object->objectId);
@@ -4692,7 +4692,7 @@ getObjectIdentityParts(const ObjectAddress *object,
if (objname)
*objname = lappend(*objname, pstrdup(NameStr(rule->rulename)));
- heap_close(ruleDesc, AccessShareLock);
+ table_close(ruleDesc, AccessShareLock);
break;
}
@@ -4702,7 +4702,7 @@ getObjectIdentityParts(const ObjectAddress *object,
HeapTuple tup;
Form_pg_trigger trig;
- trigDesc = heap_open(TriggerRelationId, AccessShareLock);
+ trigDesc = table_open(TriggerRelationId, AccessShareLock);
tup = get_catalog_object_by_oid(trigDesc, Anum_pg_trigger_oid,
object->objectId);
@@ -4719,7 +4719,7 @@ getObjectIdentityParts(const ObjectAddress *object,
if (objname)
*objname = lappend(*objname, pstrdup(NameStr(trig->tgname)));
- heap_close(trigDesc, AccessShareLock);
+ table_close(trigDesc, AccessShareLock);
break;
}
@@ -4964,7 +4964,7 @@ getObjectIdentityParts(const ObjectAddress *object,
char *schema;
char *username;
- defaclrel = heap_open(DefaultAclRelationId, AccessShareLock);
+ defaclrel = table_open(DefaultAclRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_default_acl_oid,
@@ -5030,7 +5030,7 @@ getObjectIdentityParts(const ObjectAddress *object,
}
systable_endscan(rcscan);
- heap_close(defaclrel, AccessShareLock);
+ table_close(defaclrel, AccessShareLock);
break;
}
@@ -5075,7 +5075,7 @@ getObjectIdentityParts(const ObjectAddress *object,
HeapTuple tup;
Form_pg_policy policy;
- polDesc = heap_open(PolicyRelationId, AccessShareLock);
+ polDesc = table_open(PolicyRelationId, AccessShareLock);
tup = get_catalog_object_by_oid(polDesc, Anum_pg_policy_oid,
object->objectId);
@@ -5092,7 +5092,7 @@ getObjectIdentityParts(const ObjectAddress *object,
if (objname)
*objname = lappend(*objname, pstrdup(NameStr(policy->polname)));
- heap_close(polDesc, AccessShareLock);
+ table_close(polDesc, AccessShareLock);
break;
}
@@ -5153,7 +5153,7 @@ getObjectIdentityParts(const ObjectAddress *object,
char *transformLang;
char *transformType;
- transformDesc = heap_open(TransformRelationId, AccessShareLock);
+ transformDesc = table_open(TransformRelationId, AccessShareLock);
tup = get_catalog_object_by_oid(transformDesc,
Anum_pg_transform_oid,
@@ -5177,7 +5177,7 @@ getObjectIdentityParts(const ObjectAddress *object,
*objargs = list_make1(pstrdup(transformLang));
}
- heap_close(transformDesc, AccessShareLock);
+ table_close(transformDesc, AccessShareLock);
}
break;
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c
index 83ec22cb0fd..62d1ec60ba5 100644
--- a/src/backend/catalog/partition.c
+++ b/src/backend/catalog/partition.c
@@ -55,14 +55,14 @@ get_partition_parent(Oid relid)
Relation catalogRelation;
Oid result;
- catalogRelation = heap_open(InheritsRelationId, AccessShareLock);
+ catalogRelation = table_open(InheritsRelationId, AccessShareLock);
result = get_partition_parent_worker(catalogRelation, relid);
if (!OidIsValid(result))
elog(ERROR, "could not find tuple for parent of relation %u", relid);
- heap_close(catalogRelation, AccessShareLock);
+ table_close(catalogRelation, AccessShareLock);
return result;
}
@@ -120,11 +120,11 @@ get_partition_ancestors(Oid relid)
List *result = NIL;
Relation inhRel;
- inhRel = heap_open(InheritsRelationId, AccessShareLock);
+ inhRel = table_open(InheritsRelationId, AccessShareLock);
get_partition_ancestors_worker(inhRel, relid, &result);
- heap_close(inhRel, AccessShareLock);
+ table_close(inhRel, AccessShareLock);
return result;
}
@@ -310,7 +310,7 @@ update_default_partition_oid(Oid parentId, Oid defaultPartId)
Relation pg_partitioned_table;
Form_pg_partitioned_table part_table_form;
- pg_partitioned_table = heap_open(PartitionedRelationId, RowExclusiveLock);
+ pg_partitioned_table = table_open(PartitionedRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(PARTRELID, ObjectIdGetDatum(parentId));
@@ -323,7 +323,7 @@ update_default_partition_oid(Oid parentId, Oid defaultPartId)
CatalogTupleUpdate(pg_partitioned_table, &tuple->t_self, tuple);
heap_freetuple(tuple);
- heap_close(pg_partitioned_table, RowExclusiveLock);
+ table_close(pg_partitioned_table, RowExclusiveLock);
}
/*
diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c
index fe953c95ae5..cc3806e85d5 100644
--- a/src/backend/catalog/pg_aggregate.c
+++ b/src/backend/catalog/pg_aggregate.c
@@ -639,7 +639,7 @@ AggregateCreate(const char *aggName,
/*
* Okay to create the pg_aggregate entry.
*/
- aggdesc = heap_open(AggregateRelationId, RowExclusiveLock);
+ aggdesc = table_open(AggregateRelationId, RowExclusiveLock);
tupDesc = aggdesc->rd_att;
/* initialize nulls and values */
@@ -680,7 +680,7 @@ AggregateCreate(const char *aggName,
tup = heap_form_tuple(tupDesc, values, nulls);
CatalogTupleInsert(aggdesc, tup);
- heap_close(aggdesc, RowExclusiveLock);
+ table_close(aggdesc, RowExclusiveLock);
/*
* Create dependencies for the aggregate (above and beyond those already
diff --git a/src/backend/catalog/pg_collation.c b/src/backend/catalog/pg_collation.c
index 57ce7d7205c..ea6777f902e 100644
--- a/src/backend/catalog/pg_collation.c
+++ b/src/backend/catalog/pg_collation.c
@@ -107,7 +107,7 @@ CollationCreate(const char *collname, Oid collnamespace,
}
/* open pg_collation; see below about the lock level */
- rel = heap_open(CollationRelationId, ShareRowExclusiveLock);
+ rel = table_open(CollationRelationId, ShareRowExclusiveLock);
/*
* Also forbid a specific-encoding collation shadowing an any-encoding
@@ -129,12 +129,12 @@ CollationCreate(const char *collname, Oid collnamespace,
{
if (quiet)
{
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return InvalidOid;
}
else if (if_not_exists)
{
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
ereport(NOTICE,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("collation \"%s\" already exists, skipping",
@@ -198,7 +198,7 @@ CollationCreate(const char *collname, Oid collnamespace,
InvokeObjectPostCreateHook(CollationRelationId, oid, 0);
heap_freetuple(tup);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return oid;
}
@@ -217,7 +217,7 @@ RemoveCollationById(Oid collationOid)
SysScanDesc scandesc;
HeapTuple tuple;
- rel = heap_open(CollationRelationId, RowExclusiveLock);
+ rel = table_open(CollationRelationId, RowExclusiveLock);
ScanKeyInit(&scanKeyData,
Anum_pg_collation_oid,
@@ -236,5 +236,5 @@ RemoveCollationById(Oid collationOid)
systable_endscan(scandesc);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c
index a27bcfb3350..eab5a14dbc2 100644
--- a/src/backend/catalog/pg_constraint.c
+++ b/src/backend/catalog/pg_constraint.c
@@ -99,7 +99,7 @@ CreateConstraintEntry(const char *constraintName,
int i;
ObjectAddress conobject;
- conDesc = heap_open(ConstraintRelationId, RowExclusiveLock);
+ conDesc = table_open(ConstraintRelationId, RowExclusiveLock);
Assert(constraintName);
namestrcpy(&cname, constraintName);
@@ -234,7 +234,7 @@ CreateConstraintEntry(const char *constraintName,
conobject.objectId = conOid;
conobject.objectSubId = 0;
- heap_close(conDesc, RowExclusiveLock);
+ table_close(conDesc, RowExclusiveLock);
if (OidIsValid(relId))
{
@@ -400,10 +400,10 @@ CloneForeignKeyConstraints(Oid parentId, Oid relationId, List **cloned)
HeapTuple tuple;
List *clone = NIL;
- parentRel = heap_open(parentId, NoLock); /* already got lock */
+ parentRel = table_open(parentId, NoLock); /* already got lock */
/* see ATAddForeignKeyConstraint about lock level */
- rel = heap_open(relationId, AccessExclusiveLock);
- pg_constraint = heap_open(ConstraintRelationId, RowShareLock);
+ rel = table_open(relationId, AccessExclusiveLock);
+ pg_constraint = table_open(ConstraintRelationId, RowShareLock);
/* Obtain the list of constraints to clone or attach */
ScanKeyInit(&key,
@@ -423,9 +423,9 @@ CloneForeignKeyConstraints(Oid parentId, Oid relationId, List **cloned)
clone_fk_constraints(pg_constraint, parentRel, rel, clone, cloned);
/* We're done. Clean up */
- heap_close(parentRel, NoLock);
- heap_close(rel, NoLock); /* keep lock till commit */
- heap_close(pg_constraint, RowShareLock);
+ table_close(parentRel, NoLock);
+ table_close(rel, NoLock); /* keep lock till commit */
+ table_close(pg_constraint, RowShareLock);
}
/*
@@ -754,13 +754,13 @@ clone_fk_constraints(Relation pg_constraint, Relation parentRel,
{
Relation childRel;
- childRel = heap_open(partdesc->oids[i], AccessExclusiveLock);
+ childRel = table_open(partdesc->oids[i], AccessExclusiveLock);
clone_fk_constraints(pg_constraint,
partRel,
childRel,
subclone,
cloned);
- heap_close(childRel, NoLock); /* keep lock till commit */
+ table_close(childRel, NoLock); /* keep lock till commit */
}
}
}
@@ -786,7 +786,7 @@ ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId,
SysScanDesc conscan;
ScanKeyData skey[3];
- conDesc = heap_open(ConstraintRelationId, AccessShareLock);
+ conDesc = table_open(ConstraintRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_constraint_conrelid,
@@ -810,7 +810,7 @@ ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId,
found = (HeapTupleIsValid(systable_getnext(conscan)));
systable_endscan(conscan);
- heap_close(conDesc, AccessShareLock);
+ table_close(conDesc, AccessShareLock);
return found;
}
@@ -830,7 +830,7 @@ ConstraintNameExists(const char *conname, Oid namespaceid)
SysScanDesc conscan;
ScanKeyData skey[2];
- conDesc = heap_open(ConstraintRelationId, AccessShareLock);
+ conDesc = table_open(ConstraintRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_constraint_conname,
@@ -848,7 +848,7 @@ ConstraintNameExists(const char *conname, Oid namespaceid)
found = (HeapTupleIsValid(systable_getnext(conscan)));
systable_endscan(conscan);
- heap_close(conDesc, AccessShareLock);
+ table_close(conDesc, AccessShareLock);
return found;
}
@@ -890,7 +890,7 @@ ChooseConstraintName(const char *name1, const char *name2,
bool found;
ListCell *l;
- conDesc = heap_open(ConstraintRelationId, AccessShareLock);
+ conDesc = table_open(ConstraintRelationId, AccessShareLock);
/* try the unmodified label first */
StrNCpy(modlabel, label, sizeof(modlabel));
@@ -938,7 +938,7 @@ ChooseConstraintName(const char *name1, const char *name2,
snprintf(modlabel, sizeof(modlabel), "%s%d", label, ++pass);
}
- heap_close(conDesc, AccessShareLock);
+ table_close(conDesc, AccessShareLock);
return conname;
}
@@ -953,7 +953,7 @@ RemoveConstraintById(Oid conId)
HeapTuple tup;
Form_pg_constraint con;
- conDesc = heap_open(ConstraintRelationId, RowExclusiveLock);
+ conDesc = table_open(ConstraintRelationId, RowExclusiveLock);
tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conId));
if (!HeapTupleIsValid(tup)) /* should not happen */
@@ -971,7 +971,7 @@ RemoveConstraintById(Oid conId)
* If the constraint is for a relation, open and exclusive-lock the
* relation it's for.
*/
- rel = heap_open(con->conrelid, AccessExclusiveLock);
+ rel = table_open(con->conrelid, AccessExclusiveLock);
/*
* We need to update the relcheck count if it is a check constraint
@@ -984,7 +984,7 @@ RemoveConstraintById(Oid conId)
HeapTuple relTup;
Form_pg_class classForm;
- pgrel = heap_open(RelationRelationId, RowExclusiveLock);
+ pgrel = table_open(RelationRelationId, RowExclusiveLock);
relTup = SearchSysCacheCopy1(RELOID,
ObjectIdGetDatum(con->conrelid));
if (!HeapTupleIsValid(relTup))
@@ -1001,11 +1001,11 @@ RemoveConstraintById(Oid conId)
heap_freetuple(relTup);
- heap_close(pgrel, RowExclusiveLock);
+ table_close(pgrel, RowExclusiveLock);
}
/* Keep lock on constraint's rel until end of xact */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
else if (OidIsValid(con->contypid))
{
@@ -1024,7 +1024,7 @@ RemoveConstraintById(Oid conId)
/* Clean up */
ReleaseSysCache(tup);
- heap_close(conDesc, RowExclusiveLock);
+ table_close(conDesc, RowExclusiveLock);
}
/*
@@ -1044,7 +1044,7 @@ RenameConstraintById(Oid conId, const char *newname)
HeapTuple tuple;
Form_pg_constraint con;
- conDesc = heap_open(ConstraintRelationId, RowExclusiveLock);
+ conDesc = table_open(ConstraintRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(CONSTROID, ObjectIdGetDatum(conId));
if (!HeapTupleIsValid(tuple))
@@ -1079,7 +1079,7 @@ RenameConstraintById(Oid conId, const char *newname)
InvokeObjectPostAlterHook(ConstraintRelationId, conId, 0);
heap_freetuple(tuple);
- heap_close(conDesc, RowExclusiveLock);
+ table_close(conDesc, RowExclusiveLock);
}
/*
@@ -1098,7 +1098,7 @@ AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
SysScanDesc scan;
HeapTuple tup;
- conRel = heap_open(ConstraintRelationId, RowExclusiveLock);
+ conRel = table_open(ConstraintRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_constraint_conrelid,
@@ -1148,7 +1148,7 @@ AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
systable_endscan(scan);
- heap_close(conRel, RowExclusiveLock);
+ table_close(conRel, RowExclusiveLock);
}
/*
@@ -1168,7 +1168,7 @@ ConstraintSetParentConstraint(Oid childConstrId, Oid parentConstrId)
ObjectAddress depender;
ObjectAddress referenced;
- constrRel = heap_open(ConstraintRelationId, RowExclusiveLock);
+ constrRel = table_open(ConstraintRelationId, RowExclusiveLock);
tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(childConstrId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for constraint %u", childConstrId);
@@ -1201,7 +1201,7 @@ ConstraintSetParentConstraint(Oid childConstrId, Oid parentConstrId)
}
ReleaseSysCache(tuple);
- heap_close(constrRel, RowExclusiveLock);
+ table_close(constrRel, RowExclusiveLock);
}
@@ -1219,7 +1219,7 @@ get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok)
ScanKeyData skey[3];
Oid conOid = InvalidOid;
- pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
+ pg_constraint = table_open(ConstraintRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_constraint_conrelid,
@@ -1250,7 +1250,7 @@ get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok)
errmsg("constraint \"%s\" for table \"%s\" does not exist",
conname, get_rel_name(relid))));
- heap_close(pg_constraint, AccessShareLock);
+ table_close(pg_constraint, AccessShareLock);
return conOid;
}
@@ -1280,7 +1280,7 @@ get_relation_constraint_attnos(Oid relid, const char *conname,
/* Set *constraintOid, to avoid complaints about uninitialized vars */
*constraintOid = InvalidOid;
- pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
+ pg_constraint = table_open(ConstraintRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_constraint_conrelid,
@@ -1343,7 +1343,7 @@ get_relation_constraint_attnos(Oid relid, const char *conname,
errmsg("constraint \"%s\" for table \"%s\" does not exist",
conname, get_rel_name(relid))));
- heap_close(pg_constraint, AccessShareLock);
+ table_close(pg_constraint, AccessShareLock);
return conattnos;
}
@@ -1361,7 +1361,7 @@ get_relation_idx_constraint_oid(Oid relationId, Oid indexId)
HeapTuple tuple;
Oid constraintId = InvalidOid;
- pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
+ pg_constraint = table_open(ConstraintRelationId, AccessShareLock);
ScanKeyInit(&key,
Anum_pg_constraint_conrelid,
@@ -1383,7 +1383,7 @@ get_relation_idx_constraint_oid(Oid relationId, Oid indexId)
}
systable_endscan(scan);
- heap_close(pg_constraint, AccessShareLock);
+ table_close(pg_constraint, AccessShareLock);
return constraintId;
}
@@ -1401,7 +1401,7 @@ get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok)
ScanKeyData skey[3];
Oid conOid = InvalidOid;
- pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
+ pg_constraint = table_open(ConstraintRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_constraint_conrelid,
@@ -1432,7 +1432,7 @@ get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok)
errmsg("constraint \"%s\" for domain %s does not exist",
conname, format_type_be(typid))));
- heap_close(pg_constraint, AccessShareLock);
+ table_close(pg_constraint, AccessShareLock);
return conOid;
}
@@ -1464,7 +1464,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid)
*constraintOid = InvalidOid;
/* Scan pg_constraint for constraints of the target rel */
- pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
+ pg_constraint = table_open(ConstraintRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_constraint_conrelid,
@@ -1525,7 +1525,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid)
systable_endscan(scan);
- heap_close(pg_constraint, AccessShareLock);
+ table_close(pg_constraint, AccessShareLock);
return pkattnos;
}
diff --git a/src/backend/catalog/pg_conversion.c b/src/backend/catalog/pg_conversion.c
index 9ca81dc8606..4e6399a9e63 100644
--- a/src/backend/catalog/pg_conversion.c
+++ b/src/backend/catalog/pg_conversion.c
@@ -83,7 +83,7 @@ ConversionCreate(const char *conname, Oid connamespace,
}
/* open pg_conversion */
- rel = heap_open(ConversionRelationId, RowExclusiveLock);
+ rel = table_open(ConversionRelationId, RowExclusiveLock);
tupDesc = rel->rd_att;
/* initialize nulls and values */
@@ -137,7 +137,7 @@ ConversionCreate(const char *conname, Oid connamespace,
InvokeObjectPostCreateHook(ConversionRelationId, oid, 0);
heap_freetuple(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return myself;
}
@@ -162,7 +162,7 @@ RemoveConversionById(Oid conversionOid)
ObjectIdGetDatum(conversionOid));
/* open pg_conversion */
- rel = heap_open(ConversionRelationId, RowExclusiveLock);
+ rel = table_open(ConversionRelationId, RowExclusiveLock);
scan = heap_beginscan_catalog(rel, 1, &scanKeyData);
@@ -172,7 +172,7 @@ RemoveConversionById(Oid conversionOid)
else
elog(ERROR, "could not find tuple for conversion %u", conversionOid);
heap_endscan(scan);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
diff --git a/src/backend/catalog/pg_db_role_setting.c b/src/backend/catalog/pg_db_role_setting.c
index efcc59f3c08..3a634de8dce 100644
--- a/src/backend/catalog/pg_db_role_setting.c
+++ b/src/backend/catalog/pg_db_role_setting.c
@@ -33,7 +33,7 @@ AlterSetting(Oid databaseid, Oid roleid, VariableSetStmt *setstmt)
/* Get the old tuple, if any. */
- rel = heap_open(DbRoleSettingRelationId, RowExclusiveLock);
+ rel = table_open(DbRoleSettingRelationId, RowExclusiveLock);
ScanKeyInit(&scankey[0],
Anum_pg_db_role_setting_setdatabase,
BTEqualStrategyNumber, F_OIDEQ,
@@ -158,7 +158,7 @@ AlterSetting(Oid databaseid, Oid roleid, VariableSetStmt *setstmt)
systable_endscan(scan);
/* Close pg_db_role_setting, but keep lock till commit */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
/*
@@ -175,7 +175,7 @@ DropSetting(Oid databaseid, Oid roleid)
HeapTuple tup;
int numkeys = 0;
- relsetting = heap_open(DbRoleSettingRelationId, RowExclusiveLock);
+ relsetting = table_open(DbRoleSettingRelationId, RowExclusiveLock);
if (OidIsValid(databaseid))
{
@@ -203,7 +203,7 @@ DropSetting(Oid databaseid, Oid roleid)
}
heap_endscan(scan);
- heap_close(relsetting, RowExclusiveLock);
+ table_close(relsetting, RowExclusiveLock);
}
/*
diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c
index 6a46d2e5b18..5d34937ea8f 100644
--- a/src/backend/catalog/pg_depend.c
+++ b/src/backend/catalog/pg_depend.c
@@ -75,7 +75,7 @@ recordMultipleDependencies(const ObjectAddress *depender,
if (IsBootstrapProcessingMode())
return;
- dependDesc = heap_open(DependRelationId, RowExclusiveLock);
+ dependDesc = table_open(DependRelationId, RowExclusiveLock);
/* Don't open indexes unless we need to make an update */
indstate = NULL;
@@ -120,7 +120,7 @@ recordMultipleDependencies(const ObjectAddress *depender,
if (indstate != NULL)
CatalogCloseIndexes(indstate);
- heap_close(dependDesc, RowExclusiveLock);
+ table_close(dependDesc, RowExclusiveLock);
}
/*
@@ -197,7 +197,7 @@ deleteDependencyRecordsFor(Oid classId, Oid objectId,
SysScanDesc scan;
HeapTuple tup;
- depRel = heap_open(DependRelationId, RowExclusiveLock);
+ depRel = table_open(DependRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_depend_classid,
@@ -223,7 +223,7 @@ deleteDependencyRecordsFor(Oid classId, Oid objectId,
systable_endscan(scan);
- heap_close(depRel, RowExclusiveLock);
+ table_close(depRel, RowExclusiveLock);
return count;
}
@@ -247,7 +247,7 @@ deleteDependencyRecordsForClass(Oid classId, Oid objectId,
SysScanDesc scan;
HeapTuple tup;
- depRel = heap_open(DependRelationId, RowExclusiveLock);
+ depRel = table_open(DependRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_depend_classid,
@@ -274,7 +274,7 @@ deleteDependencyRecordsForClass(Oid classId, Oid objectId,
systable_endscan(scan);
- heap_close(depRel, RowExclusiveLock);
+ table_close(depRel, RowExclusiveLock);
return count;
}
@@ -304,7 +304,7 @@ changeDependencyFor(Oid classId, Oid objectId,
ObjectAddress objAddr;
bool newIsPinned;
- depRel = heap_open(DependRelationId, RowExclusiveLock);
+ depRel = table_open(DependRelationId, RowExclusiveLock);
/*
* If oldRefObjectId is pinned, there won't be any dependency entries on
@@ -371,7 +371,7 @@ changeDependencyFor(Oid classId, Oid objectId,
systable_endscan(scan);
- heap_close(depRel, RowExclusiveLock);
+ table_close(depRel, RowExclusiveLock);
return count;
}
@@ -452,7 +452,7 @@ getExtensionOfObject(Oid classId, Oid objectId)
SysScanDesc scan;
HeapTuple tup;
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_classid,
@@ -480,7 +480,7 @@ getExtensionOfObject(Oid classId, Oid objectId)
systable_endscan(scan);
- heap_close(depRel, AccessShareLock);
+ table_close(depRel, AccessShareLock);
return result;
}
@@ -505,7 +505,7 @@ sequenceIsOwned(Oid seqId, char deptype, Oid *tableId, int32 *colId)
SysScanDesc scan;
HeapTuple tup;
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_classid,
@@ -535,7 +535,7 @@ sequenceIsOwned(Oid seqId, char deptype, Oid *tableId, int32 *colId)
systable_endscan(scan);
- heap_close(depRel, AccessShareLock);
+ table_close(depRel, AccessShareLock);
return ret;
}
@@ -553,7 +553,7 @@ getOwnedSequences(Oid relid, AttrNumber attnum)
SysScanDesc scan;
HeapTuple tup;
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
@@ -593,7 +593,7 @@ getOwnedSequences(Oid relid, AttrNumber attnum)
systable_endscan(scan);
- heap_close(depRel, AccessShareLock);
+ table_close(depRel, AccessShareLock);
return result;
}
@@ -632,7 +632,7 @@ get_constraint_index(Oid constraintId)
HeapTuple tup;
/* Search the dependency table for the dependent index */
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
@@ -675,7 +675,7 @@ get_constraint_index(Oid constraintId)
}
systable_endscan(scan);
- heap_close(depRel, AccessShareLock);
+ table_close(depRel, AccessShareLock);
return indexId;
}
@@ -695,7 +695,7 @@ get_index_constraint(Oid indexId)
HeapTuple tup;
/* Search the dependency table for the index */
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_classid,
@@ -731,7 +731,7 @@ get_index_constraint(Oid indexId)
}
systable_endscan(scan);
- heap_close(depRel, AccessShareLock);
+ table_close(depRel, AccessShareLock);
return constraintId;
}
diff --git a/src/backend/catalog/pg_enum.c b/src/backend/catalog/pg_enum.c
index 77b1b9fb27f..0cdec168c3b 100644
--- a/src/backend/catalog/pg_enum.c
+++ b/src/backend/catalog/pg_enum.c
@@ -79,7 +79,7 @@ EnumValuesCreate(Oid enumTypeOid, List *vals)
* probably not worth trying harder.
*/
- pg_enum = heap_open(EnumRelationId, RowExclusiveLock);
+ pg_enum = table_open(EnumRelationId, RowExclusiveLock);
/*
* Allocate OIDs for the enum's members.
@@ -146,7 +146,7 @@ EnumValuesCreate(Oid enumTypeOid, List *vals)
/* clean up */
pfree(oids);
- heap_close(pg_enum, RowExclusiveLock);
+ table_close(pg_enum, RowExclusiveLock);
}
@@ -162,7 +162,7 @@ EnumValuesDelete(Oid enumTypeOid)
SysScanDesc scan;
HeapTuple tup;
- pg_enum = heap_open(EnumRelationId, RowExclusiveLock);
+ pg_enum = table_open(EnumRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_enum_enumtypid,
@@ -179,7 +179,7 @@ EnumValuesDelete(Oid enumTypeOid)
systable_endscan(scan);
- heap_close(pg_enum, RowExclusiveLock);
+ table_close(pg_enum, RowExclusiveLock);
}
/*
@@ -269,7 +269,7 @@ AddEnumLabel(Oid enumTypeOid,
newVal)));
}
- pg_enum = heap_open(EnumRelationId, RowExclusiveLock);
+ pg_enum = table_open(EnumRelationId, RowExclusiveLock);
/* If we have to renumber the existing members, we restart from here */
restart:
@@ -491,7 +491,7 @@ restart:
CatalogTupleInsert(pg_enum, enum_tup);
heap_freetuple(enum_tup);
- heap_close(pg_enum, RowExclusiveLock);
+ table_close(pg_enum, RowExclusiveLock);
/* Set up the blacklist hash if not already done in this transaction */
if (enum_blacklist == NULL)
@@ -537,7 +537,7 @@ RenameEnumLabel(Oid enumTypeOid,
*/
LockDatabaseObject(TypeRelationId, enumTypeOid, 0, ExclusiveLock);
- pg_enum = heap_open(EnumRelationId, RowExclusiveLock);
+ pg_enum = table_open(EnumRelationId, RowExclusiveLock);
/* Get the list of existing members of the enum */
list = SearchSysCacheList1(ENUMTYPOIDNAME,
@@ -582,7 +582,7 @@ RenameEnumLabel(Oid enumTypeOid,
CatalogTupleUpdate(pg_enum, &enum_tup->t_self, enum_tup);
heap_freetuple(enum_tup);
- heap_close(pg_enum, RowExclusiveLock);
+ table_close(pg_enum, RowExclusiveLock);
}
diff --git a/src/backend/catalog/pg_inherits.c b/src/backend/catalog/pg_inherits.c
index d07bbba34d3..d3f98b32076 100644
--- a/src/backend/catalog/pg_inherits.c
+++ b/src/backend/catalog/pg_inherits.c
@@ -80,7 +80,7 @@ find_inheritance_children(Oid parentrelId, LOCKMODE lockmode)
oidarr = (Oid *) palloc(maxoids * sizeof(Oid));
numoids = 0;
- relation = heap_open(InheritsRelationId, AccessShareLock);
+ relation = table_open(InheritsRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_inherits_inhparent,
@@ -103,7 +103,7 @@ find_inheritance_children(Oid parentrelId, LOCKMODE lockmode)
systable_endscan(scan);
- heap_close(relation, AccessShareLock);
+ table_close(relation, AccessShareLock);
/*
* If we found more than one child, sort them by OID. This ensures
@@ -285,14 +285,14 @@ has_superclass(Oid relationId)
ScanKeyData skey;
bool result;
- catalog = heap_open(InheritsRelationId, AccessShareLock);
+ catalog = table_open(InheritsRelationId, AccessShareLock);
ScanKeyInit(&skey, Anum_pg_inherits_inhrelid, BTEqualStrategyNumber,
F_OIDEQ, ObjectIdGetDatum(relationId));
scan = systable_beginscan(catalog, InheritsRelidSeqnoIndexId, true,
NULL, 1, &skey);
result = HeapTupleIsValid(systable_getnext(scan));
systable_endscan(scan);
- heap_close(catalog, AccessShareLock);
+ table_close(catalog, AccessShareLock);
return result;
}
@@ -335,7 +335,7 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId)
queue = list_make1_oid(subclassRelid);
visited = NIL;
- inhrel = heap_open(InheritsRelationId, AccessShareLock);
+ inhrel = table_open(InheritsRelationId, AccessShareLock);
/*
* Use queue to do a breadth-first traversal of the inheritance graph from
@@ -397,7 +397,7 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId)
}
/* clean up ... */
- heap_close(inhrel, AccessShareLock);
+ table_close(inhrel, AccessShareLock);
list_free(visited);
list_free(queue);
@@ -416,7 +416,7 @@ StoreSingleInheritance(Oid relationId, Oid parentOid, int32 seqNumber)
HeapTuple tuple;
Relation inhRelation;
- inhRelation = heap_open(InheritsRelationId, RowExclusiveLock);
+ inhRelation = table_open(InheritsRelationId, RowExclusiveLock);
/*
* Make the pg_inherits entry
@@ -433,7 +433,7 @@ StoreSingleInheritance(Oid relationId, Oid parentOid, int32 seqNumber)
heap_freetuple(tuple);
- heap_close(inhRelation, RowExclusiveLock);
+ table_close(inhRelation, RowExclusiveLock);
}
/*
@@ -457,7 +457,7 @@ DeleteInheritsTuple(Oid inhrelid, Oid inhparent)
/*
* Find pg_inherits entries by inhrelid.
*/
- catalogRelation = heap_open(InheritsRelationId, RowExclusiveLock);
+ catalogRelation = table_open(InheritsRelationId, RowExclusiveLock);
ScanKeyInit(&key,
Anum_pg_inherits_inhrelid,
BTEqualStrategyNumber, F_OIDEQ,
@@ -480,7 +480,7 @@ DeleteInheritsTuple(Oid inhrelid, Oid inhparent)
/* Done */
systable_endscan(scan);
- heap_close(catalogRelation, RowExclusiveLock);
+ table_close(catalogRelation, RowExclusiveLock);
return found;
}
diff --git a/src/backend/catalog/pg_largeobject.c b/src/backend/catalog/pg_largeobject.c
index 1d068ca0beb..f933ba5f38a 100644
--- a/src/backend/catalog/pg_largeobject.c
+++ b/src/backend/catalog/pg_largeobject.c
@@ -46,7 +46,7 @@ LargeObjectCreate(Oid loid)
Datum values[Natts_pg_largeobject_metadata];
bool nulls[Natts_pg_largeobject_metadata];
- pg_lo_meta = heap_open(LargeObjectMetadataRelationId,
+ pg_lo_meta = table_open(LargeObjectMetadataRelationId,
RowExclusiveLock);
/*
@@ -74,7 +74,7 @@ LargeObjectCreate(Oid loid)
heap_freetuple(ntup);
- heap_close(pg_lo_meta, RowExclusiveLock);
+ table_close(pg_lo_meta, RowExclusiveLock);
return loid_new;
}
@@ -92,10 +92,10 @@ LargeObjectDrop(Oid loid)
SysScanDesc scan;
HeapTuple tuple;
- pg_lo_meta = heap_open(LargeObjectMetadataRelationId,
+ pg_lo_meta = table_open(LargeObjectMetadataRelationId,
RowExclusiveLock);
- pg_largeobject = heap_open(LargeObjectRelationId,
+ pg_largeobject = table_open(LargeObjectRelationId,
RowExclusiveLock);
/*
@@ -138,9 +138,9 @@ LargeObjectDrop(Oid loid)
systable_endscan(scan);
- heap_close(pg_largeobject, RowExclusiveLock);
+ table_close(pg_largeobject, RowExclusiveLock);
- heap_close(pg_lo_meta, RowExclusiveLock);
+ table_close(pg_lo_meta, RowExclusiveLock);
}
/*
@@ -169,7 +169,7 @@ LargeObjectExists(Oid loid)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(loid));
- pg_lo_meta = heap_open(LargeObjectMetadataRelationId,
+ pg_lo_meta = table_open(LargeObjectMetadataRelationId,
AccessShareLock);
sd = systable_beginscan(pg_lo_meta,
@@ -182,7 +182,7 @@ LargeObjectExists(Oid loid)
systable_endscan(sd);
- heap_close(pg_lo_meta, AccessShareLock);
+ table_close(pg_lo_meta, AccessShareLock);
return retval;
}
diff --git a/src/backend/catalog/pg_namespace.c b/src/backend/catalog/pg_namespace.c
index 763a0b75ab1..81958813b18 100644
--- a/src/backend/catalog/pg_namespace.c
+++ b/src/backend/catalog/pg_namespace.c
@@ -69,7 +69,7 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
else
nspacl = NULL;
- nspdesc = heap_open(NamespaceRelationId, RowExclusiveLock);
+ nspdesc = table_open(NamespaceRelationId, RowExclusiveLock);
tupDesc = nspdesc->rd_att;
/* initialize nulls and values */
@@ -96,7 +96,7 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
CatalogTupleInsert(nspdesc, tup);
Assert(OidIsValid(nspoid));
- heap_close(nspdesc, RowExclusiveLock);
+ table_close(nspdesc, RowExclusiveLock);
/* Record dependencies */
myself.classId = NamespaceRelationId;
diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c
index dbe89c51710..0f9a12b35c2 100644
--- a/src/backend/catalog/pg_operator.c
+++ b/src/backend/catalog/pg_operator.c
@@ -222,7 +222,7 @@ OperatorShellMake(const char *operatorName,
/*
* open pg_operator
*/
- pg_operator_desc = heap_open(OperatorRelationId, RowExclusiveLock);
+ pg_operator_desc = table_open(OperatorRelationId, RowExclusiveLock);
tupDesc = pg_operator_desc->rd_att;
/*
@@ -283,7 +283,7 @@ OperatorShellMake(const char *operatorName,
/*
* close the operator relation and return the oid.
*/
- heap_close(pg_operator_desc, RowExclusiveLock);
+ table_close(pg_operator_desc, RowExclusiveLock);
return operatorObjectId;
}
@@ -506,7 +506,7 @@ OperatorCreate(const char *operatorName,
values[Anum_pg_operator_oprrest - 1] = ObjectIdGetDatum(restrictionId);
values[Anum_pg_operator_oprjoin - 1] = ObjectIdGetDatum(joinId);
- pg_operator_desc = heap_open(OperatorRelationId, RowExclusiveLock);
+ pg_operator_desc = table_open(OperatorRelationId, RowExclusiveLock);
/*
* If we are replacing an operator shell, update; else insert
@@ -551,7 +551,7 @@ OperatorCreate(const char *operatorName,
/* Post creation hook for new operator */
InvokeObjectPostCreateHook(OperatorRelationId, operatorObjectId, 0);
- heap_close(pg_operator_desc, RowExclusiveLock);
+ table_close(pg_operator_desc, RowExclusiveLock);
/*
* If a commutator and/or negator link is provided, update the other
@@ -666,7 +666,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId, bool isDelete)
CommandCounterIncrement();
/* Open the relation. */
- pg_operator_desc = heap_open(OperatorRelationId, RowExclusiveLock);
+ pg_operator_desc = table_open(OperatorRelationId, RowExclusiveLock);
/* Get a writable copy of the commutator's tuple. */
if (OidIsValid(commId))
@@ -758,7 +758,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId, bool isDelete)
}
/* Close relation and release catalog lock. */
- heap_close(pg_operator_desc, RowExclusiveLock);
+ table_close(pg_operator_desc, RowExclusiveLock);
}
/*
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index 32887e548b8..db780616e62 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -362,7 +362,7 @@ ProcedureCreate(const char *procedureName,
nulls[Anum_pg_proc_proconfig - 1] = true;
/* proacl will be determined later */
- rel = heap_open(ProcedureRelationId, RowExclusiveLock);
+ rel = table_open(ProcedureRelationId, RowExclusiveLock);
tupDesc = RelationGetDescr(rel);
/* Check for pre-existing definition */
@@ -673,7 +673,7 @@ ProcedureCreate(const char *procedureName,
/* Post creation hook for new function */
InvokeObjectPostCreateHook(ProcedureRelationId, retval, 0);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
/* Verify function body */
if (OidIsValid(languageValidator))
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 72a4d2b17fe..96f92750728 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -155,7 +155,7 @@ publication_add_relation(Oid pubid, Relation targetrel,
ObjectAddress myself,
referenced;
- rel = heap_open(PublicationRelRelationId, RowExclusiveLock);
+ rel = table_open(PublicationRelRelationId, RowExclusiveLock);
/*
* Check for duplicates. Note that this does not really prevent
@@ -165,7 +165,7 @@ publication_add_relation(Oid pubid, Relation targetrel,
if (SearchSysCacheExists2(PUBLICATIONRELMAP, ObjectIdGetDatum(relid),
ObjectIdGetDatum(pubid)))
{
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
if (if_not_exists)
return InvalidObjectAddress;
@@ -207,7 +207,7 @@ publication_add_relation(Oid pubid, Relation targetrel,
recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO);
/* Close the table. */
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
/* Invalidate relcache so that publication info is rebuilt. */
CacheInvalidateRelcache(targetrel);
@@ -258,7 +258,7 @@ GetPublicationRelations(Oid pubid)
HeapTuple tup;
/* Find all publications associated with the relation. */
- pubrelsrel = heap_open(PublicationRelRelationId, AccessShareLock);
+ pubrelsrel = table_open(PublicationRelRelationId, AccessShareLock);
ScanKeyInit(&scankey,
Anum_pg_publication_rel_prpubid,
@@ -279,7 +279,7 @@ GetPublicationRelations(Oid pubid)
}
systable_endscan(scan);
- heap_close(pubrelsrel, AccessShareLock);
+ table_close(pubrelsrel, AccessShareLock);
return result;
}
@@ -297,7 +297,7 @@ GetAllTablesPublications(void)
HeapTuple tup;
/* Find all publications that are marked as for all tables. */
- rel = heap_open(PublicationRelationId, AccessShareLock);
+ rel = table_open(PublicationRelationId, AccessShareLock);
ScanKeyInit(&scankey,
Anum_pg_publication_puballtables,
@@ -316,7 +316,7 @@ GetAllTablesPublications(void)
}
systable_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
return result;
}
@@ -333,7 +333,7 @@ GetAllTablesPublicationRelations(void)
HeapTuple tuple;
List *result = NIL;
- classRel = heap_open(RelationRelationId, AccessShareLock);
+ classRel = table_open(RelationRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_class_relkind,
@@ -352,7 +352,7 @@ GetAllTablesPublicationRelations(void)
}
heap_endscan(scan);
- heap_close(classRel, AccessShareLock);
+ table_close(classRel, AccessShareLock);
return result;
}
diff --git a/src/backend/catalog/pg_range.c b/src/backend/catalog/pg_range.c
index dc83727d9dc..08fb13bc474 100644
--- a/src/backend/catalog/pg_range.c
+++ b/src/backend/catalog/pg_range.c
@@ -45,7 +45,7 @@ RangeCreate(Oid rangeTypeOid, Oid rangeSubType, Oid rangeCollation,
ObjectAddress myself;
ObjectAddress referenced;
- pg_range = heap_open(RangeRelationId, RowExclusiveLock);
+ pg_range = table_open(RangeRelationId, RowExclusiveLock);
memset(nulls, 0, sizeof(nulls));
@@ -101,7 +101,7 @@ RangeCreate(Oid rangeTypeOid, Oid rangeSubType, Oid rangeCollation,
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
}
- heap_close(pg_range, RowExclusiveLock);
+ table_close(pg_range, RowExclusiveLock);
}
@@ -117,7 +117,7 @@ RangeDelete(Oid rangeTypeOid)
SysScanDesc scan;
HeapTuple tup;
- pg_range = heap_open(RangeRelationId, RowExclusiveLock);
+ pg_range = table_open(RangeRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_range_rngtypid,
@@ -134,5 +134,5 @@ RangeDelete(Oid rangeTypeOid)
systable_endscan(scan);
- heap_close(pg_range, RowExclusiveLock);
+ table_close(pg_range, RowExclusiveLock);
}
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index a8db901bcb8..064bafb8002 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -131,7 +131,7 @@ recordSharedDependencyOn(ObjectAddress *depender,
if (IsBootstrapProcessingMode())
return;
- sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+ sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
/* If the referenced object is pinned, do nothing. */
if (!isSharedObjectPinned(referenced->classId, referenced->objectId,
@@ -143,7 +143,7 @@ recordSharedDependencyOn(ObjectAddress *depender,
deptype);
}
- heap_close(sdepRel, RowExclusiveLock);
+ table_close(sdepRel, RowExclusiveLock);
}
/*
@@ -305,7 +305,7 @@ changeDependencyOnOwner(Oid classId, Oid objectId, Oid newOwnerId)
{
Relation sdepRel;
- sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+ sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
/* Adjust the SHARED_DEPENDENCY_OWNER entry */
shdepChangeDep(sdepRel,
@@ -336,7 +336,7 @@ changeDependencyOnOwner(Oid classId, Oid objectId, Oid newOwnerId)
AuthIdRelationId, newOwnerId,
SHARED_DEPENDENCY_ACL);
- heap_close(sdepRel, RowExclusiveLock);
+ table_close(sdepRel, RowExclusiveLock);
}
/*
@@ -436,7 +436,7 @@ updateAclDependencies(Oid classId, Oid objectId, int32 objsubId,
if (noldmembers > 0 || nnewmembers > 0)
{
- sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+ sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
/* Add new dependencies that weren't already present */
for (i = 0; i < nnewmembers; i++)
@@ -479,7 +479,7 @@ updateAclDependencies(Oid classId, Oid objectId, int32 objsubId,
SHARED_DEPENDENCY_ACL);
}
- heap_close(sdepRel, RowExclusiveLock);
+ table_close(sdepRel, RowExclusiveLock);
}
if (oldmembers)
@@ -545,7 +545,7 @@ checkSharedDependencies(Oid classId, Oid objectId,
initStringInfo(&descs);
initStringInfo(&alldescs);
- sdepRel = heap_open(SharedDependRelationId, AccessShareLock);
+ sdepRel = table_open(SharedDependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_shdepend_refclassid,
@@ -646,7 +646,7 @@ checkSharedDependencies(Oid classId, Oid objectId,
systable_endscan(scan);
- heap_close(sdepRel, AccessShareLock);
+ table_close(sdepRel, AccessShareLock);
/*
* Summarize dependencies in remote databases.
@@ -720,7 +720,7 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId)
bool nulls[Natts_pg_shdepend];
bool replace[Natts_pg_shdepend];
- sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+ sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
sdepDesc = RelationGetDescr(sdepRel);
indstate = CatalogOpenIndexes(sdepRel);
@@ -762,7 +762,7 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId)
systable_endscan(scan);
CatalogCloseIndexes(indstate);
- heap_close(sdepRel, RowExclusiveLock);
+ table_close(sdepRel, RowExclusiveLock);
}
/*
@@ -779,7 +779,7 @@ dropDatabaseDependencies(Oid databaseId)
SysScanDesc scan;
HeapTuple tup;
- sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+ sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
/*
* First, delete all the entries that have the database Oid in the dbid
@@ -806,7 +806,7 @@ dropDatabaseDependencies(Oid databaseId)
InvalidOid, InvalidOid,
SHARED_DEPENDENCY_INVALID);
- heap_close(sdepRel, RowExclusiveLock);
+ table_close(sdepRel, RowExclusiveLock);
}
/*
@@ -824,14 +824,14 @@ deleteSharedDependencyRecordsFor(Oid classId, Oid objectId, int32 objectSubId)
{
Relation sdepRel;
- sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+ sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
shdepDropDependency(sdepRel, classId, objectId, objectSubId,
(objectSubId == 0),
InvalidOid, InvalidOid,
SHARED_DEPENDENCY_INVALID);
- heap_close(sdepRel, RowExclusiveLock);
+ table_close(sdepRel, RowExclusiveLock);
}
/*
@@ -1173,7 +1173,7 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
* acquire RowExclusiveLock. Better get that right now to avoid potential
* deadlock failures.
*/
- sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+ sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
/*
* For each role, find the dependent objects and drop them using the
@@ -1270,7 +1270,7 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
/* the dependency mechanism does the actual work */
performMultipleDeletions(deleteobjs, behavior, 0);
- heap_close(sdepRel, RowExclusiveLock);
+ table_close(sdepRel, RowExclusiveLock);
free_object_addresses(deleteobjs);
}
@@ -1292,7 +1292,7 @@ shdepReassignOwned(List *roleids, Oid newrole)
* acquire RowExclusiveLock. Better get that right now to avoid potential
* deadlock problems.
*/
- sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
+ sdepRel = table_open(SharedDependRelationId, RowExclusiveLock);
foreach(cell, roleids)
{
@@ -1428,12 +1428,12 @@ shdepReassignOwned(List *roleids, Oid newrole)
if (classId == LargeObjectRelationId)
classId = LargeObjectMetadataRelationId;
- catalog = heap_open(classId, RowExclusiveLock);
+ catalog = table_open(classId, RowExclusiveLock);
AlterObjectOwner_internal(catalog, sdepForm->objid,
newrole);
- heap_close(catalog, NoLock);
+ table_close(catalog, NoLock);
}
break;
@@ -1448,5 +1448,5 @@ shdepReassignOwned(List *roleids, Oid newrole)
systable_endscan(scan);
}
- heap_close(sdepRel, RowExclusiveLock);
+ table_close(sdepRel, RowExclusiveLock);
}
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c
index 24548f777b1..935d7670e42 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_subscription.c
@@ -123,7 +123,7 @@ CountDBSubscriptions(Oid dbid)
SysScanDesc scan;
HeapTuple tup;
- rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
+ rel = table_open(SubscriptionRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
Anum_pg_subscription_subdbid,
@@ -138,7 +138,7 @@ CountDBSubscriptions(Oid dbid)
systable_endscan(scan);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return nsubs;
}
@@ -247,7 +247,7 @@ AddSubscriptionRelState(Oid subid, Oid relid, char state,
LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
- rel = heap_open(SubscriptionRelRelationId, RowExclusiveLock);
+ rel = table_open(SubscriptionRelRelationId, RowExclusiveLock);
/* Try finding existing mapping. */
tup = SearchSysCacheCopy2(SUBSCRIPTIONRELMAP,
@@ -276,7 +276,7 @@ AddSubscriptionRelState(Oid subid, Oid relid, char state,
heap_freetuple(tup);
/* Cleanup. */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
/*
@@ -294,7 +294,7 @@ UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
- rel = heap_open(SubscriptionRelRelationId, RowExclusiveLock);
+ rel = table_open(SubscriptionRelRelationId, RowExclusiveLock);
/* Try finding existing mapping. */
tup = SearchSysCacheCopy2(SUBSCRIPTIONRELMAP,
@@ -325,7 +325,7 @@ UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
CatalogTupleUpdate(rel, &tup->t_self, tup);
/* Cleanup. */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
/*
@@ -343,7 +343,7 @@ GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn,
bool isnull;
Datum d;
- rel = heap_open(SubscriptionRelRelationId, AccessShareLock);
+ rel = table_open(SubscriptionRelRelationId, AccessShareLock);
/* Try finding the mapping. */
tup = SearchSysCache2(SUBSCRIPTIONRELMAP,
@@ -354,7 +354,7 @@ GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn,
{
if (missing_ok)
{
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
*sublsn = InvalidXLogRecPtr;
return SUBREL_STATE_UNKNOWN;
}
@@ -377,7 +377,7 @@ GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn,
/* Cleanup */
ReleaseSysCache(tup);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
return substate;
}
@@ -395,7 +395,7 @@ RemoveSubscriptionRel(Oid subid, Oid relid)
HeapTuple tup;
int nkeys = 0;
- rel = heap_open(SubscriptionRelRelationId, RowExclusiveLock);
+ rel = table_open(SubscriptionRelRelationId, RowExclusiveLock);
if (OidIsValid(subid))
{
@@ -423,7 +423,7 @@ RemoveSubscriptionRel(Oid subid, Oid relid)
}
heap_endscan(scan);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
@@ -442,7 +442,7 @@ GetSubscriptionRelations(Oid subid)
ScanKeyData skey[2];
SysScanDesc scan;
- rel = heap_open(SubscriptionRelRelationId, AccessShareLock);
+ rel = table_open(SubscriptionRelRelationId, AccessShareLock);
ScanKeyInit(&skey[nkeys++],
Anum_pg_subscription_rel_srsubid,
@@ -469,7 +469,7 @@ GetSubscriptionRelations(Oid subid)
/* Cleanup */
systable_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
return res;
}
@@ -489,7 +489,7 @@ GetSubscriptionNotReadyRelations(Oid subid)
ScanKeyData skey[2];
SysScanDesc scan;
- rel = heap_open(SubscriptionRelRelationId, AccessShareLock);
+ rel = table_open(SubscriptionRelRelationId, AccessShareLock);
ScanKeyInit(&skey[nkeys++],
Anum_pg_subscription_rel_srsubid,
@@ -521,7 +521,7 @@ GetSubscriptionNotReadyRelations(Oid subid)
/* Cleanup */
systable_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
return res;
}
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index b14beae9e13..2a51501d8d9 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -70,7 +70,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
/*
* open pg_type
*/
- pg_type_desc = heap_open(TypeRelationId, RowExclusiveLock);
+ pg_type_desc = table_open(TypeRelationId, RowExclusiveLock);
tupDesc = pg_type_desc->rd_att;
/*
@@ -173,7 +173,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
* clean up and return the type-oid
*/
heap_freetuple(tup);
- heap_close(pg_type_desc, RowExclusiveLock);
+ table_close(pg_type_desc, RowExclusiveLock);
return address;
}
@@ -408,7 +408,7 @@ TypeCreate(Oid newTypeOid,
* NOTE: updating will not work correctly in bootstrap mode; but we don't
* expect to be overwriting any shell types in bootstrap mode.
*/
- pg_type_desc = heap_open(TypeRelationId, RowExclusiveLock);
+ pg_type_desc = table_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy2(TYPENAMENSP,
CStringGetDatum(typeName),
@@ -506,7 +506,7 @@ TypeCreate(Oid newTypeOid,
/*
* finish up
*/
- heap_close(pg_type_desc, RowExclusiveLock);
+ table_close(pg_type_desc, RowExclusiveLock);
return address;
}
@@ -714,7 +714,7 @@ RenameTypeInternal(Oid typeOid, const char *newTypeName, Oid typeNamespace)
Oid arrayOid;
Oid oldTypeOid;
- pg_type_desc = heap_open(TypeRelationId, RowExclusiveLock);
+ pg_type_desc = table_open(TypeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tuple))
@@ -757,7 +757,7 @@ RenameTypeInternal(Oid typeOid, const char *newTypeName, Oid typeNamespace)
InvokeObjectPostAlterHook(TypeRelationId, typeOid, 0);
heap_freetuple(tuple);
- heap_close(pg_type_desc, RowExclusiveLock);
+ table_close(pg_type_desc, RowExclusiveLock);
/*
* If the type has an array type, recurse to handle that. But we don't
@@ -792,7 +792,7 @@ makeArrayTypeName(const char *typeName, Oid typeNamespace)
* The idea is to prepend underscores as needed until we make a name that
* doesn't collide with anything...
*/
- pg_type_desc = heap_open(TypeRelationId, AccessShareLock);
+ pg_type_desc = table_open(TypeRelationId, AccessShareLock);
for (i = 1; i < NAMEDATALEN - 1; i++)
{
@@ -810,7 +810,7 @@ makeArrayTypeName(const char *typeName, Oid typeNamespace)
break;
}
- heap_close(pg_type_desc, AccessShareLock);
+ table_close(pg_type_desc, AccessShareLock);
if (i >= NAMEDATALEN - 1)
ereport(ERROR,
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index 827e1c82dd6..77be19175a6 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -79,12 +79,12 @@ CheckAndCreateToastTable(Oid relOid, Datum reloptions, LOCKMODE lockmode, bool c
{
Relation rel;
- rel = heap_open(relOid, lockmode);
+ rel = table_open(relOid, lockmode);
/* create_toast_table does all the work */
(void) create_toast_table(rel, InvalidOid, InvalidOid, reloptions, lockmode, check);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
/*
@@ -97,7 +97,7 @@ BootstrapToastTable(char *relName, Oid toastOid, Oid toastIndexOid)
{
Relation rel;
- rel = heap_openrv(makeRangeVar(NULL, relName, -1), AccessExclusiveLock);
+ rel = table_openrv(makeRangeVar(NULL, relName, -1), AccessExclusiveLock);
if (rel->rd_rel->relkind != RELKIND_RELATION &&
rel->rd_rel->relkind != RELKIND_MATVIEW)
@@ -112,7 +112,7 @@ BootstrapToastTable(char *relName, Oid toastOid, Oid toastIndexOid)
elog(ERROR, "\"%s\" does not require a toast table",
relName);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
@@ -282,11 +282,11 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
NULL);
Assert(toast_relid != InvalidOid);
- /* make the toast relation visible, else heap_open will fail */
+ /* make the toast relation visible, else table_open will fail */
CommandCounterIncrement();
/* ShareLock is not really needed here, but take it anyway */
- toast_rel = heap_open(toast_relid, ShareLock);
+ toast_rel = table_open(toast_relid, ShareLock);
/*
* Create unique index on chunk_id, chunk_seq.
@@ -339,12 +339,12 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
collationObjectId, classObjectId, coloptions, (Datum) 0,
INDEX_CREATE_IS_PRIMARY, 0, true, true, NULL);
- heap_close(toast_rel, NoLock);
+ table_close(toast_rel, NoLock);
/*
* Store the toast table's OID in the parent relation's pg_class row
*/
- class_rel = heap_open(RelationRelationId, RowExclusiveLock);
+ class_rel = table_open(RelationRelationId, RowExclusiveLock);
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(reltup))
@@ -365,7 +365,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
heap_freetuple(reltup);
- heap_close(class_rel, RowExclusiveLock);
+ table_close(class_rel, RowExclusiveLock);
/*
* Register dependency from the toast table to the master, so that the
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 08c2cf3569f..848eee0123e 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -400,11 +400,11 @@ ExecRenameStmt(RenameStmt *stmt)
AccessExclusiveLock, false);
Assert(relation == NULL);
- catalog = heap_open(address.classId, RowExclusiveLock);
+ catalog = table_open(address.classId, RowExclusiveLock);
AlterObjectRename_internal(catalog,
address.objectId,
stmt->newname);
- heap_close(catalog, RowExclusiveLock);
+ table_close(catalog, RowExclusiveLock);
return address;
}
@@ -439,7 +439,7 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
* don't need the relation here, but we'll retain the lock until commit.
*/
if (rel)
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
refAddr = get_object_address(OBJECT_EXTENSION, (Node *) stmt->extname,
&rel, AccessExclusiveLock, false);
@@ -519,12 +519,12 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
false);
Assert(relation == NULL);
classId = address.classId;
- catalog = heap_open(classId, RowExclusiveLock);
+ catalog = table_open(classId, RowExclusiveLock);
nspOid = LookupCreationNamespace(stmt->newschema);
oldNspOid = AlterObjectNamespace_internal(catalog, address.objectId,
nspOid);
- heap_close(catalog, RowExclusiveLock);
+ table_close(catalog, RowExclusiveLock);
}
break;
@@ -599,12 +599,12 @@ AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid,
{
Relation catalog;
- catalog = heap_open(classId, RowExclusiveLock);
+ catalog = table_open(classId, RowExclusiveLock);
oldNspOid = AlterObjectNamespace_internal(catalog, objid,
nspOid);
- heap_close(catalog, RowExclusiveLock);
+ table_close(catalog, RowExclusiveLock);
}
break;
@@ -876,10 +876,10 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
if (classId == LargeObjectRelationId)
classId = LargeObjectMetadataRelationId;
- catalog = heap_open(classId, RowExclusiveLock);
+ catalog = table_open(classId, RowExclusiveLock);
AlterObjectOwner_internal(catalog, address.objectId, newowner);
- heap_close(catalog, RowExclusiveLock);
+ table_close(catalog, RowExclusiveLock);
return address;
}
diff --git a/src/backend/commands/amcmds.c b/src/backend/commands/amcmds.c
index a720d14df06..c84507b5d03 100644
--- a/src/backend/commands/amcmds.c
+++ b/src/backend/commands/amcmds.c
@@ -50,7 +50,7 @@ CreateAccessMethod(CreateAmStmt *stmt)
Datum values[Natts_pg_am];
HeapTuple tup;
- rel = heap_open(AccessMethodRelationId, RowExclusiveLock);
+ rel = table_open(AccessMethodRelationId, RowExclusiveLock);
/* Must be super user */
if (!superuser())
@@ -107,7 +107,7 @@ CreateAccessMethod(CreateAmStmt *stmt)
recordDependencyOnCurrentExtension(&myself, false);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return myself;
}
@@ -126,7 +126,7 @@ RemoveAccessMethodById(Oid amOid)
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to drop access methods")));
- relation = heap_open(AccessMethodRelationId, RowExclusiveLock);
+ relation = table_open(AccessMethodRelationId, RowExclusiveLock);
tup = SearchSysCache1(AMOID, ObjectIdGetDatum(amOid));
if (!HeapTupleIsValid(tup))
@@ -136,7 +136,7 @@ RemoveAccessMethodById(Oid amOid)
ReleaseSysCache(tup);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
/*
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index ac40bd793d1..83625d10e75 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -1352,14 +1352,14 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
BlockNumber relpages = 0;
/* We already got the needed lock */
- childrel = heap_open(childOID, NoLock);
+ childrel = table_open(childOID, NoLock);
/* Ignore if temp table of another backend */
if (RELATION_IS_OTHER_TEMP(childrel))
{
/* ... but release the lock on it */
Assert(childrel != onerel);
- heap_close(childrel, AccessShareLock);
+ table_close(childrel, AccessShareLock);
continue;
}
@@ -1391,7 +1391,7 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
{
/* ignore, but release the lock on it */
Assert(childrel != onerel);
- heap_close(childrel, AccessShareLock);
+ table_close(childrel, AccessShareLock);
continue;
}
}
@@ -1403,9 +1403,9 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
*/
Assert(childrel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
if (childrel != onerel)
- heap_close(childrel, AccessShareLock);
+ table_close(childrel, AccessShareLock);
else
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
continue;
}
@@ -1501,7 +1501,7 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
* Note: we cannot release the child-table locks, since we may have
* pointers to their TOAST tables in the sampled rows.
*/
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
}
return numrows;
@@ -1539,7 +1539,7 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
if (natts <= 0)
return; /* nothing to do */
- sd = heap_open(StatisticRelationId, RowExclusiveLock);
+ sd = table_open(StatisticRelationId, RowExclusiveLock);
for (attno = 0; attno < natts; attno++)
{
@@ -1660,7 +1660,7 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
heap_freetuple(stup);
}
- heap_close(sd, RowExclusiveLock);
+ table_close(sd, RowExclusiveLock);
}
/*
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index a89210808b3..99e25cd50fb 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -118,7 +118,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
AccessExclusiveLock,
0,
RangeVarCallbackOwnsTable, NULL);
- rel = heap_open(tableOid, NoLock);
+ rel = table_open(tableOid, NoLock);
/*
* Reject clustering a remote temp table ... their local buffer
@@ -184,7 +184,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
}
/* close relation, keep lock till commit */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
/* Do the job. */
cluster_rel(tableOid, indexOid, stmt->options);
@@ -415,7 +415,7 @@ cluster_rel(Oid tableOid, Oid indexOid, int options)
/* rebuild_relation does all the dirty work */
rebuild_relation(OldHeap, indexOid, verbose);
- /* NB: rebuild_relation does heap_close() on OldHeap */
+ /* NB: rebuild_relation does table_close() on OldHeap */
}
/*
@@ -522,7 +522,7 @@ mark_index_clustered(Relation rel, Oid indexOid, bool is_internal)
/*
* Check each index of the relation and set/clear the bit as needed.
*/
- pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+ pg_index = table_open(IndexRelationId, RowExclusiveLock);
foreach(index, RelationGetIndexList(rel))
{
@@ -558,7 +558,7 @@ mark_index_clustered(Relation rel, Oid indexOid, bool is_internal)
heap_freetuple(indexTuple);
}
- heap_close(pg_index, RowExclusiveLock);
+ table_close(pg_index, RowExclusiveLock);
}
/*
@@ -590,7 +590,7 @@ rebuild_relation(Relation OldHeap, Oid indexOid, bool verbose)
is_system_catalog = IsSystemRelation(OldHeap);
/* Close relcache entry, but keep lock until transaction commit */
- heap_close(OldHeap, NoLock);
+ table_close(OldHeap, NoLock);
/* Create the transient table that will receive the re-ordered data */
OIDNewHeap = make_new_heap(tableOid, tableSpace,
@@ -636,7 +636,7 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, char relpersistence,
bool isNull;
Oid namespaceid;
- OldHeap = heap_open(OIDOldHeap, lockmode);
+ OldHeap = table_open(OIDOldHeap, lockmode);
OldHeapDesc = RelationGetDescr(OldHeap);
/*
@@ -702,7 +702,7 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, char relpersistence,
/*
* Advance command counter so that the newly-created relation's catalog
- * tuples will be visible to heap_open.
+ * tuples will be visible to table_open.
*/
CommandCounterIncrement();
@@ -734,7 +734,7 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, char relpersistence,
ReleaseSysCache(tuple);
}
- heap_close(OldHeap, NoLock);
+ table_close(OldHeap, NoLock);
return OIDNewHeap;
}
@@ -785,8 +785,8 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
/*
* Open the relations we need.
*/
- NewHeap = heap_open(OIDNewHeap, AccessExclusiveLock);
- OldHeap = heap_open(OIDOldHeap, AccessExclusiveLock);
+ NewHeap = table_open(OIDNewHeap, AccessExclusiveLock);
+ OldHeap = table_open(OIDOldHeap, AccessExclusiveLock);
if (OidIsValid(OIDOldIndex))
OldIndex = index_open(OIDOldIndex, AccessExclusiveLock);
else
@@ -1120,11 +1120,11 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
if (OldIndex != NULL)
index_close(OldIndex, NoLock);
- heap_close(OldHeap, NoLock);
- heap_close(NewHeap, NoLock);
+ table_close(OldHeap, NoLock);
+ table_close(NewHeap, NoLock);
/* Update pg_class to reflect the correct values of pages and tuples. */
- relRelation = heap_open(RelationRelationId, RowExclusiveLock);
+ relRelation = table_open(RelationRelationId, RowExclusiveLock);
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(OIDNewHeap));
if (!HeapTupleIsValid(reltup))
@@ -1142,7 +1142,7 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
/* Clean up. */
heap_freetuple(reltup);
- heap_close(relRelation, RowExclusiveLock);
+ table_close(relRelation, RowExclusiveLock);
/* Make the update visible */
CommandCounterIncrement();
@@ -1193,7 +1193,7 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
char swptmpchr;
/* We need writable copies of both pg_class tuples. */
- relRelation = heap_open(RelationRelationId, RowExclusiveLock);
+ relRelation = table_open(RelationRelationId, RowExclusiveLock);
reltup1 = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(r1));
if (!HeapTupleIsValid(reltup1))
@@ -1487,7 +1487,7 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
heap_freetuple(reltup1);
heap_freetuple(reltup2);
- heap_close(relRelation, RowExclusiveLock);
+ table_close(relRelation, RowExclusiveLock);
/*
* Close both relcache entries' smgr links. We need this kluge because
@@ -1595,7 +1595,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
HeapTuple reltup;
Form_pg_class relform;
- relRelation = heap_open(RelationRelationId, RowExclusiveLock);
+ relRelation = table_open(RelationRelationId, RowExclusiveLock);
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(OIDOldHeap));
if (!HeapTupleIsValid(reltup))
@@ -1607,7 +1607,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
CatalogTupleUpdate(relRelation, &reltup->t_self, reltup);
- heap_close(relRelation, RowExclusiveLock);
+ table_close(relRelation, RowExclusiveLock);
}
/* Destroy new heap with old filenode */
@@ -1646,7 +1646,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
{
Relation newrel;
- newrel = heap_open(OIDOldHeap, NoLock);
+ newrel = table_open(OIDOldHeap, NoLock);
if (OidIsValid(newrel->rd_rel->reltoastrelid))
{
Oid toastidx;
@@ -1677,7 +1677,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
{
Relation newrel;
- newrel = heap_open(OIDOldHeap, NoLock);
+ newrel = table_open(OIDOldHeap, NoLock);
RelationClearMissing(newrel);
relation_close(newrel, NoLock);
}
@@ -1708,7 +1708,7 @@ get_tables_to_cluster(MemoryContext cluster_context)
* have indisclustered set, because CLUSTER will refuse to set it when
* called with one of them as argument.
*/
- indRelation = heap_open(IndexRelationId, AccessShareLock);
+ indRelation = table_open(IndexRelationId, AccessShareLock);
ScanKeyInit(&entry,
Anum_pg_index_indisclustered,
BTEqualStrategyNumber, F_BOOLEQ,
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
index d9a3088ac27..ed3f1c12e57 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -273,7 +273,7 @@ AlterCollation(AlterCollationStmt *stmt)
char *newversion;
ObjectAddress address;
- rel = heap_open(CollationRelationId, RowExclusiveLock);
+ rel = table_open(CollationRelationId, RowExclusiveLock);
collOid = get_collation_oid(stmt->collname, false);
if (!pg_collation_ownercheck(collOid, GetUserId()))
@@ -325,7 +325,7 @@ AlterCollation(AlterCollationStmt *stmt)
ObjectAddressSet(address, CollationRelationId, collOid);
heap_freetuple(tup);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return address;
}
diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c
index d4714a5c1f8..98b4b3e7b16 100644
--- a/src/backend/commands/comment.c
+++ b/src/backend/commands/comment.c
@@ -185,7 +185,7 @@ CreateComments(Oid oid, Oid classoid, int32 subid, const char *comment)
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(subid));
- description = heap_open(DescriptionRelationId, RowExclusiveLock);
+ description = table_open(DescriptionRelationId, RowExclusiveLock);
sd = systable_beginscan(description, DescriptionObjIndexId, true,
NULL, 3, skey);
@@ -222,7 +222,7 @@ CreateComments(Oid oid, Oid classoid, int32 subid, const char *comment)
/* Done */
- heap_close(description, NoLock);
+ table_close(description, NoLock);
}
/*
@@ -275,7 +275,7 @@ CreateSharedComments(Oid oid, Oid classoid, const char *comment)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(classoid));
- shdescription = heap_open(SharedDescriptionRelationId, RowExclusiveLock);
+ shdescription = table_open(SharedDescriptionRelationId, RowExclusiveLock);
sd = systable_beginscan(shdescription, SharedDescriptionObjIndexId, true,
NULL, 2, skey);
@@ -312,7 +312,7 @@ CreateSharedComments(Oid oid, Oid classoid, const char *comment)
/* Done */
- heap_close(shdescription, NoLock);
+ table_close(shdescription, NoLock);
}
/*
@@ -353,7 +353,7 @@ DeleteComments(Oid oid, Oid classoid, int32 subid)
else
nkeys = 2;
- description = heap_open(DescriptionRelationId, RowExclusiveLock);
+ description = table_open(DescriptionRelationId, RowExclusiveLock);
sd = systable_beginscan(description, DescriptionObjIndexId, true,
NULL, nkeys, skey);
@@ -364,7 +364,7 @@ DeleteComments(Oid oid, Oid classoid, int32 subid)
/* Done */
systable_endscan(sd);
- heap_close(description, RowExclusiveLock);
+ table_close(description, RowExclusiveLock);
}
/*
@@ -389,7 +389,7 @@ DeleteSharedComments(Oid oid, Oid classoid)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(classoid));
- shdescription = heap_open(SharedDescriptionRelationId, RowExclusiveLock);
+ shdescription = table_open(SharedDescriptionRelationId, RowExclusiveLock);
sd = systable_beginscan(shdescription, SharedDescriptionObjIndexId, true,
NULL, 2, skey);
@@ -400,7 +400,7 @@ DeleteSharedComments(Oid oid, Oid classoid)
/* Done */
systable_endscan(sd);
- heap_close(shdescription, RowExclusiveLock);
+ table_close(shdescription, RowExclusiveLock);
}
/*
@@ -431,7 +431,7 @@ GetComment(Oid oid, Oid classoid, int32 subid)
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(subid));
- description = heap_open(DescriptionRelationId, AccessShareLock);
+ description = table_open(DescriptionRelationId, AccessShareLock);
tupdesc = RelationGetDescr(description);
sd = systable_beginscan(description, DescriptionObjIndexId, true,
@@ -453,7 +453,7 @@ GetComment(Oid oid, Oid classoid, int32 subid)
systable_endscan(sd);
/* Done */
- heap_close(description, AccessShareLock);
+ table_close(description, AccessShareLock);
return comment;
}
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index a61a6284711..770b25f713e 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -845,7 +845,7 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
Assert(!stmt->query);
/* Open and lock the relation, using the appropriate lock type. */
- rel = heap_openrv(stmt->relation, lockmode);
+ rel = table_openrv(stmt->relation, lockmode);
relid = RelationGetRelid(rel);
@@ -973,7 +973,7 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
*
* We'll reopen it later as part of the query-based COPY.
*/
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
rel = NULL;
}
}
@@ -1019,7 +1019,7 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
* ensure that updates will be committed before lock is released.
*/
if (rel != NULL)
- heap_close(rel, (is_from ? NoLock : AccessShareLock));
+ table_close(rel, (is_from ? NoLock : AccessShareLock));
}
/*
diff --git a/src/backend/commands/createas.c b/src/backend/commands/createas.c
index 5947996d673..2bc8f928eab 100644
--- a/src/backend/commands/createas.c
+++ b/src/backend/commands/createas.c
@@ -504,7 +504,7 @@ intorel_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
/*
* Finally we can open the target table
*/
- intoRelationDesc = heap_open(intoRelationAddr.objectId, AccessExclusiveLock);
+ intoRelationDesc = table_open(intoRelationAddr.objectId, AccessExclusiveLock);
/*
* Check INSERT permission on the constructed table.
@@ -605,7 +605,7 @@ intorel_shutdown(DestReceiver *self)
heap_sync(myState->rel);
/* close rel, but keep lock until commit */
- heap_close(myState->rel, NoLock);
+ table_close(myState->rel, NoLock);
myState->rel = NULL;
}
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 1208fdf33ff..6de8f98e727 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -500,7 +500,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
* filename conflict with anything already existing in the tablespace
* directories.
*/
- pg_database_rel = heap_open(DatabaseRelationId, RowExclusiveLock);
+ pg_database_rel = table_open(DatabaseRelationId, RowExclusiveLock);
do
{
@@ -589,7 +589,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
* Iterate through all tablespaces of the template database, and copy
* each one to the new database.
*/
- rel = heap_open(TableSpaceRelationId, AccessShareLock);
+ rel = table_open(TableSpaceRelationId, AccessShareLock);
scan = heap_beginscan_catalog(rel, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
@@ -645,7 +645,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
}
}
heap_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
/*
* We force a checkpoint before committing. This effectively means
@@ -681,7 +681,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
/*
* Close pg_database, but keep lock till commit.
*/
- heap_close(pg_database_rel, NoLock);
+ table_close(pg_database_rel, NoLock);
/*
* Force synchronous commit, thus minimizing the window between
@@ -797,7 +797,7 @@ dropdb(const char *dbname, bool missing_ok)
* using it as a CREATE DATABASE template or trying to delete it for
* themselves.
*/
- pgdbrel = heap_open(DatabaseRelationId, RowExclusiveLock);
+ pgdbrel = table_open(DatabaseRelationId, RowExclusiveLock);
if (!get_db_info(dbname, AccessExclusiveLock, &db_id, NULL, NULL,
&db_istemplate, NULL, NULL, NULL, NULL, NULL, NULL, NULL))
@@ -811,7 +811,7 @@ dropdb(const char *dbname, bool missing_ok)
else
{
/* Close pg_database, release the lock, since we changed nothing */
- heap_close(pgdbrel, RowExclusiveLock);
+ table_close(pgdbrel, RowExclusiveLock);
ereport(NOTICE,
(errmsg("database \"%s\" does not exist, skipping",
dbname)));
@@ -959,7 +959,7 @@ dropdb(const char *dbname, bool missing_ok)
/*
* Close pg_database, but keep lock till commit.
*/
- heap_close(pgdbrel, NoLock);
+ table_close(pgdbrel, NoLock);
/*
* Force synchronous commit, thus minimizing the window between removal of
@@ -988,7 +988,7 @@ RenameDatabase(const char *oldname, const char *newname)
* Look up the target database's OID, and get exclusive lock on it. We
* need this for the same reasons as DROP DATABASE.
*/
- rel = heap_open(DatabaseRelationId, RowExclusiveLock);
+ rel = table_open(DatabaseRelationId, RowExclusiveLock);
if (!get_db_info(oldname, AccessExclusiveLock, &db_id, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL))
@@ -1054,7 +1054,7 @@ RenameDatabase(const char *oldname, const char *newname)
/*
* Close pg_database, but keep lock till commit.
*/
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return address;
}
@@ -1092,7 +1092,7 @@ movedb(const char *dbname, const char *tblspcname)
* we are moving it, and that no one is using it as a CREATE DATABASE
* template or trying to delete it.
*/
- pgdbrel = heap_open(DatabaseRelationId, RowExclusiveLock);
+ pgdbrel = table_open(DatabaseRelationId, RowExclusiveLock);
if (!get_db_info(dbname, AccessExclusiveLock, &db_id, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, &src_tblspcoid, NULL, NULL))
@@ -1151,7 +1151,7 @@ movedb(const char *dbname, const char *tblspcname)
*/
if (src_tblspcoid == dst_tblspcoid)
{
- heap_close(pgdbrel, NoLock);
+ table_close(pgdbrel, NoLock);
UnlockSharedObjectForSession(DatabaseRelationId, db_id, 0,
AccessExclusiveLock);
return;
@@ -1325,7 +1325,7 @@ movedb(const char *dbname, const char *tblspcname)
/*
* Close pg_database, but keep lock till commit.
*/
- heap_close(pgdbrel, NoLock);
+ table_close(pgdbrel, NoLock);
}
PG_END_ENSURE_ERROR_CLEANUP(movedb_failure_callback,
PointerGetDatum(&fparms));
@@ -1500,7 +1500,7 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
* because we're not going to do anything that would mess up incoming
* connections.
*/
- rel = heap_open(DatabaseRelationId, RowExclusiveLock);
+ rel = table_open(DatabaseRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
@@ -1563,7 +1563,7 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
systable_endscan(scan);
/* Close pg_database, but keep lock till commit */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return dboid;
}
@@ -1614,7 +1614,7 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
* because we're not going to do anything that would mess up incoming
* connections.
*/
- rel = heap_open(DatabaseRelationId, RowExclusiveLock);
+ rel = table_open(DatabaseRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
@@ -1705,7 +1705,7 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
systable_endscan(scan);
/* Close pg_database, but keep lock till commit */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return address;
}
@@ -1735,7 +1735,7 @@ get_db_info(const char *name, LOCKMODE lockmode,
AssertArg(name);
/* Caller may wish to grab a better lock on pg_database beforehand... */
- relation = heap_open(DatabaseRelationId, AccessShareLock);
+ relation = table_open(DatabaseRelationId, AccessShareLock);
/*
* Loop covers the rare case where the database is renamed before we can
@@ -1836,7 +1836,7 @@ get_db_info(const char *name, LOCKMODE lockmode,
UnlockSharedObject(DatabaseRelationId, dbOid, 0, lockmode);
}
- heap_close(relation, AccessShareLock);
+ table_close(relation, AccessShareLock);
return result;
}
@@ -1874,7 +1874,7 @@ remove_dbtablespaces(Oid db_id)
HeapScanDesc scan;
HeapTuple tuple;
- rel = heap_open(TableSpaceRelationId, AccessShareLock);
+ rel = table_open(TableSpaceRelationId, AccessShareLock);
scan = heap_beginscan_catalog(rel, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
@@ -1919,7 +1919,7 @@ remove_dbtablespaces(Oid db_id)
}
heap_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
}
/*
@@ -1942,7 +1942,7 @@ check_db_file_conflict(Oid db_id)
HeapScanDesc scan;
HeapTuple tuple;
- rel = heap_open(TableSpaceRelationId, AccessShareLock);
+ rel = table_open(TableSpaceRelationId, AccessShareLock);
scan = heap_beginscan_catalog(rel, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
@@ -1969,7 +1969,7 @@ check_db_file_conflict(Oid db_id)
}
heap_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
return result;
}
@@ -2020,7 +2020,7 @@ get_database_oid(const char *dbname, bool missing_ok)
* There's no syscache for pg_database indexed by name, so we must look
* the hard way.
*/
- pg_database = heap_open(DatabaseRelationId, AccessShareLock);
+ pg_database = table_open(DatabaseRelationId, AccessShareLock);
ScanKeyInit(&entry[0],
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
@@ -2037,7 +2037,7 @@ get_database_oid(const char *dbname, bool missing_ok)
oid = InvalidOid;
systable_endscan(scan);
- heap_close(pg_database, AccessShareLock);
+ table_close(pg_database, AccessShareLock);
if (!OidIsValid(oid) && !missing_ok)
ereport(ERROR,
diff --git a/src/backend/commands/dropcmds.c b/src/backend/commands/dropcmds.c
index 7c31890ba51..c66aa55a359 100644
--- a/src/backend/commands/dropcmds.c
+++ b/src/backend/commands/dropcmds.c
@@ -109,7 +109,7 @@ RemoveObjects(DropStmt *stmt)
/* Release any relcache reference count, but keep lock until commit. */
if (relation)
- heap_close(relation, NoLock);
+ table_close(relation, NoLock);
add_exact_object_address(&address, objects);
}
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index 9735fde9711..5b4502bd7fc 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -390,7 +390,7 @@ insert_event_trigger_tuple(const char *trigname, const char *eventname, Oid evtO
referenced;
/* Open pg_event_trigger. */
- tgrel = heap_open(EventTriggerRelationId, RowExclusiveLock);
+ tgrel = table_open(EventTriggerRelationId, RowExclusiveLock);
/* Build the new pg_trigger tuple. */
trigoid = GetNewOidWithIndex(tgrel, EventTriggerOidIndexId,
@@ -435,7 +435,7 @@ insert_event_trigger_tuple(const char *trigname, const char *eventname, Oid evtO
InvokeObjectPostCreateHook(EventTriggerRelationId, trigoid, 0);
/* Close pg_event_trigger. */
- heap_close(tgrel, RowExclusiveLock);
+ table_close(tgrel, RowExclusiveLock);
return trigoid;
}
@@ -486,7 +486,7 @@ RemoveEventTriggerById(Oid trigOid)
Relation tgrel;
HeapTuple tup;
- tgrel = heap_open(EventTriggerRelationId, RowExclusiveLock);
+ tgrel = table_open(EventTriggerRelationId, RowExclusiveLock);
tup = SearchSysCache1(EVENTTRIGGEROID, ObjectIdGetDatum(trigOid));
if (!HeapTupleIsValid(tup))
@@ -496,7 +496,7 @@ RemoveEventTriggerById(Oid trigOid)
ReleaseSysCache(tup);
- heap_close(tgrel, RowExclusiveLock);
+ table_close(tgrel, RowExclusiveLock);
}
/*
@@ -511,7 +511,7 @@ AlterEventTrigger(AlterEventTrigStmt *stmt)
Form_pg_event_trigger evtForm;
char tgenabled = stmt->tgenabled;
- tgrel = heap_open(EventTriggerRelationId, RowExclusiveLock);
+ tgrel = table_open(EventTriggerRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(EVENTTRIGGERNAME,
CStringGetDatum(stmt->trigname));
@@ -538,7 +538,7 @@ AlterEventTrigger(AlterEventTrigStmt *stmt)
/* clean up */
heap_freetuple(tup);
- heap_close(tgrel, RowExclusiveLock);
+ table_close(tgrel, RowExclusiveLock);
return trigoid;
}
@@ -555,7 +555,7 @@ AlterEventTriggerOwner(const char *name, Oid newOwnerId)
Relation rel;
ObjectAddress address;
- rel = heap_open(EventTriggerRelationId, RowExclusiveLock);
+ rel = table_open(EventTriggerRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(EVENTTRIGGERNAME, CStringGetDatum(name));
@@ -573,7 +573,7 @@ AlterEventTriggerOwner(const char *name, Oid newOwnerId)
heap_freetuple(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return address;
}
@@ -587,7 +587,7 @@ AlterEventTriggerOwner_oid(Oid trigOid, Oid newOwnerId)
HeapTuple tup;
Relation rel;
- rel = heap_open(EventTriggerRelationId, RowExclusiveLock);
+ rel = table_open(EventTriggerRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(EVENTTRIGGEROID, ObjectIdGetDatum(trigOid));
@@ -600,7 +600,7 @@ AlterEventTriggerOwner_oid(Oid trigOid, Oid newOwnerId)
heap_freetuple(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
@@ -1364,7 +1364,7 @@ EventTriggerSQLDropAddObject(const ObjectAddress *object, bool original, bool no
Relation catalog;
HeapTuple tuple;
- catalog = heap_open(obj->address.classId, AccessShareLock);
+ catalog = table_open(obj->address.classId, AccessShareLock);
tuple = get_catalog_object_by_oid(catalog,
get_object_attnum_oid(object->classId),
obj->address.objectId);
@@ -1394,7 +1394,7 @@ EventTriggerSQLDropAddObject(const ObjectAddress *object, bool original, bool no
else if (isAnyTempNamespace(namespaceId))
{
pfree(obj);
- heap_close(catalog, AccessShareLock);
+ table_close(catalog, AccessShareLock);
MemoryContextSwitchTo(oldcxt);
return;
}
@@ -1420,7 +1420,7 @@ EventTriggerSQLDropAddObject(const ObjectAddress *object, bool original, bool no
}
}
- heap_close(catalog, AccessShareLock);
+ table_close(catalog, AccessShareLock);
}
else
{
@@ -2114,7 +2114,7 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
Oid schema_oid;
bool isnull;
- catalog = heap_open(addr.classId, AccessShareLock);
+ catalog = table_open(addr.classId, AccessShareLock);
objtup = get_catalog_object_by_oid(catalog,
get_object_attnum_oid(addr.classId),
addr.objectId);
@@ -2134,7 +2134,7 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
else
schema = get_namespace_name(schema_oid);
- heap_close(catalog, AccessShareLock);
+ table_close(catalog, AccessShareLock);
}
}
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index 48dfbc33766..ab07432a75e 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -144,7 +144,7 @@ get_extension_oid(const char *extname, bool missing_ok)
HeapTuple tuple;
ScanKeyData entry[1];
- rel = heap_open(ExtensionRelationId, AccessShareLock);
+ rel = table_open(ExtensionRelationId, AccessShareLock);
ScanKeyInit(&entry[0],
Anum_pg_extension_extname,
@@ -164,7 +164,7 @@ get_extension_oid(const char *extname, bool missing_ok)
systable_endscan(scandesc);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
if (!OidIsValid(result) && !missing_ok)
ereport(ERROR,
@@ -189,7 +189,7 @@ get_extension_name(Oid ext_oid)
HeapTuple tuple;
ScanKeyData entry[1];
- rel = heap_open(ExtensionRelationId, AccessShareLock);
+ rel = table_open(ExtensionRelationId, AccessShareLock);
ScanKeyInit(&entry[0],
Anum_pg_extension_oid,
@@ -209,7 +209,7 @@ get_extension_name(Oid ext_oid)
systable_endscan(scandesc);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
return result;
}
@@ -228,7 +228,7 @@ get_extension_schema(Oid ext_oid)
HeapTuple tuple;
ScanKeyData entry[1];
- rel = heap_open(ExtensionRelationId, AccessShareLock);
+ rel = table_open(ExtensionRelationId, AccessShareLock);
ScanKeyInit(&entry[0],
Anum_pg_extension_oid,
@@ -248,7 +248,7 @@ get_extension_schema(Oid ext_oid)
systable_endscan(scandesc);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
return result;
}
@@ -1757,7 +1757,7 @@ InsertExtensionTuple(const char *extName, Oid extOwner,
/*
* Build and insert the pg_extension tuple
*/
- rel = heap_open(ExtensionRelationId, RowExclusiveLock);
+ rel = table_open(ExtensionRelationId, RowExclusiveLock);
memset(values, 0, sizeof(values));
memset(nulls, 0, sizeof(nulls));
@@ -1787,7 +1787,7 @@ InsertExtensionTuple(const char *extName, Oid extOwner,
CatalogTupleInsert(rel, tuple);
heap_freetuple(tuple);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
/*
* Record dependencies on owner, schema, and prerequisite extensions
@@ -1852,7 +1852,7 @@ RemoveExtensionById(Oid extId)
errmsg("cannot drop extension \"%s\" because it is being modified",
get_extension_name(extId))));
- rel = heap_open(ExtensionRelationId, RowExclusiveLock);
+ rel = table_open(ExtensionRelationId, RowExclusiveLock);
ScanKeyInit(&entry[0],
Anum_pg_extension_oid,
@@ -1869,7 +1869,7 @@ RemoveExtensionById(Oid extId)
systable_endscan(scandesc);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
@@ -2380,7 +2380,7 @@ pg_extension_config_dump(PG_FUNCTION_ARGS)
*/
/* Find the pg_extension tuple */
- extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
+ extRel = table_open(ExtensionRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_extension_oid,
@@ -2499,7 +2499,7 @@ pg_extension_config_dump(PG_FUNCTION_ARGS)
systable_endscan(extScan);
- heap_close(extRel, RowExclusiveLock);
+ table_close(extRel, RowExclusiveLock);
PG_RETURN_VOID();
}
@@ -2528,7 +2528,7 @@ extension_config_remove(Oid extensionoid, Oid tableoid)
ArrayType *a;
/* Find the pg_extension tuple */
- extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
+ extRel = table_open(ExtensionRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_extension_oid,
@@ -2586,7 +2586,7 @@ extension_config_remove(Oid extensionoid, Oid tableoid)
if (arrayIndex < 0)
{
systable_endscan(extScan);
- heap_close(extRel, RowExclusiveLock);
+ table_close(extRel, RowExclusiveLock);
return;
}
@@ -2674,7 +2674,7 @@ extension_config_remove(Oid extensionoid, Oid tableoid)
systable_endscan(extScan);
- heap_close(extRel, RowExclusiveLock);
+ table_close(extRel, RowExclusiveLock);
}
/*
@@ -2727,7 +2727,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
extensionName, newschema)));
/* Locate the pg_extension tuple */
- extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
+ extRel = table_open(ExtensionRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_extension_oid,
@@ -2755,7 +2755,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
*/
if (extForm->extnamespace == nspOid)
{
- heap_close(extRel, RowExclusiveLock);
+ table_close(extRel, RowExclusiveLock);
return InvalidObjectAddress;
}
@@ -2772,7 +2772,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
* Scan pg_depend to find objects that depend directly on the extension,
* and alter each one's schema.
*/
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
@@ -2846,7 +2846,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
CatalogTupleUpdate(extRel, &extTup->t_self, extTup);
- heap_close(extRel, RowExclusiveLock);
+ table_close(extRel, RowExclusiveLock);
/* update dependencies to point to the new schema */
changeDependencyFor(ExtensionRelationId, extensionOid,
@@ -2892,7 +2892,7 @@ ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt)
/*
* Look up the extension --- it must already exist in pg_extension
*/
- extRel = heap_open(ExtensionRelationId, AccessShareLock);
+ extRel = table_open(ExtensionRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_extension_extname,
@@ -2923,7 +2923,7 @@ ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt)
systable_endscan(extScan);
- heap_close(extRel, AccessShareLock);
+ table_close(extRel, AccessShareLock);
/* Permission check: must own extension */
if (!pg_extension_ownercheck(extensionOid, GetUserId()))
@@ -3049,7 +3049,7 @@ ApplyExtensionUpdates(Oid extensionOid,
control = read_extension_aux_control_file(pcontrol, versionName);
/* Find the pg_extension tuple */
- extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
+ extRel = table_open(ExtensionRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_extension_oid,
@@ -3094,7 +3094,7 @@ ApplyExtensionUpdates(Oid extensionOid,
systable_endscan(extScan);
- heap_close(extRel, RowExclusiveLock);
+ table_close(extRel, RowExclusiveLock);
/*
* Look up the prerequisite extensions for this version, install them
diff --git a/src/backend/commands/foreigncmds.c b/src/backend/commands/foreigncmds.c
index 03976f0454f..413ce3fcb66 100644
--- a/src/backend/commands/foreigncmds.c
+++ b/src/backend/commands/foreigncmds.c
@@ -284,7 +284,7 @@ AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId)
Form_pg_foreign_data_wrapper form;
- rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
+ rel = table_open(ForeignDataWrapperRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(FOREIGNDATAWRAPPERNAME, CStringGetDatum(name));
@@ -302,7 +302,7 @@ AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId)
heap_freetuple(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return address;
}
@@ -318,7 +318,7 @@ AlterForeignDataWrapperOwner_oid(Oid fwdId, Oid newOwnerId)
HeapTuple tup;
Relation rel;
- rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
+ rel = table_open(ForeignDataWrapperRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(fwdId));
@@ -331,7 +331,7 @@ AlterForeignDataWrapperOwner_oid(Oid fwdId, Oid newOwnerId)
heap_freetuple(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
@@ -423,7 +423,7 @@ AlterForeignServerOwner(const char *name, Oid newOwnerId)
ObjectAddress address;
Form_pg_foreign_server form;
- rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
+ rel = table_open(ForeignServerRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(FOREIGNSERVERNAME, CStringGetDatum(name));
@@ -441,7 +441,7 @@ AlterForeignServerOwner(const char *name, Oid newOwnerId)
heap_freetuple(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return address;
}
@@ -455,7 +455,7 @@ AlterForeignServerOwner_oid(Oid srvId, Oid newOwnerId)
HeapTuple tup;
Relation rel;
- rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
+ rel = table_open(ForeignServerRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(FOREIGNSERVEROID, ObjectIdGetDatum(srvId));
@@ -468,7 +468,7 @@ AlterForeignServerOwner_oid(Oid srvId, Oid newOwnerId)
heap_freetuple(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
@@ -579,7 +579,7 @@ CreateForeignDataWrapper(CreateFdwStmt *stmt)
ObjectAddress myself;
ObjectAddress referenced;
- rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
+ rel = table_open(ForeignDataWrapperRelationId, RowExclusiveLock);
/* Must be super user */
if (!superuser())
@@ -669,7 +669,7 @@ CreateForeignDataWrapper(CreateFdwStmt *stmt)
/* Post creation hook for new foreign data wrapper */
InvokeObjectPostCreateHook(ForeignDataWrapperRelationId, fdwId, 0);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return myself;
}
@@ -696,7 +696,7 @@ AlterForeignDataWrapper(AlterFdwStmt *stmt)
Oid fdwvalidator;
ObjectAddress myself;
- rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
+ rel = table_open(ForeignDataWrapperRelationId, RowExclusiveLock);
/* Must be super user */
if (!superuser())
@@ -833,7 +833,7 @@ AlterForeignDataWrapper(AlterFdwStmt *stmt)
InvokeObjectPostAlterHook(ForeignDataWrapperRelationId, fdwId, 0);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return myself;
}
@@ -848,7 +848,7 @@ RemoveForeignDataWrapperById(Oid fdwId)
HeapTuple tp;
Relation rel;
- rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
+ rel = table_open(ForeignDataWrapperRelationId, RowExclusiveLock);
tp = SearchSysCache1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(fdwId));
@@ -859,7 +859,7 @@ RemoveForeignDataWrapperById(Oid fdwId)
ReleaseSysCache(tp);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
@@ -881,7 +881,7 @@ CreateForeignServer(CreateForeignServerStmt *stmt)
ObjectAddress referenced;
ForeignDataWrapper *fdw;
- rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
+ rel = table_open(ForeignServerRelationId, RowExclusiveLock);
/* For now the owner cannot be specified on create. Use effective user ID. */
ownerId = GetUserId();
@@ -898,7 +898,7 @@ CreateForeignServer(CreateForeignServerStmt *stmt)
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("server \"%s\" already exists, skipping",
stmt->servername)));
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return InvalidObjectAddress;
}
else
@@ -984,7 +984,7 @@ CreateForeignServer(CreateForeignServerStmt *stmt)
/* Post creation hook for new foreign server */
InvokeObjectPostCreateHook(ForeignServerRelationId, srvId, 0);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return myself;
}
@@ -1005,7 +1005,7 @@ AlterForeignServer(AlterForeignServerStmt *stmt)
Form_pg_foreign_server srvForm;
ObjectAddress address;
- rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
+ rel = table_open(ForeignServerRelationId, RowExclusiveLock);
tp = SearchSysCacheCopy1(FOREIGNSERVERNAME,
CStringGetDatum(stmt->servername));
@@ -1083,7 +1083,7 @@ AlterForeignServer(AlterForeignServerStmt *stmt)
heap_freetuple(tp);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return address;
}
@@ -1098,7 +1098,7 @@ RemoveForeignServerById(Oid srvId)
HeapTuple tp;
Relation rel;
- rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
+ rel = table_open(ForeignServerRelationId, RowExclusiveLock);
tp = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(srvId));
@@ -1109,7 +1109,7 @@ RemoveForeignServerById(Oid srvId)
ReleaseSysCache(tp);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
@@ -1159,7 +1159,7 @@ CreateUserMapping(CreateUserMappingStmt *stmt)
ForeignDataWrapper *fdw;
RoleSpec *role = (RoleSpec *) stmt->user;
- rel = heap_open(UserMappingRelationId, RowExclusiveLock);
+ rel = table_open(UserMappingRelationId, RowExclusiveLock);
if (role->roletype == ROLESPEC_PUBLIC)
useId = ACL_ID_PUBLIC;
@@ -1188,7 +1188,7 @@ CreateUserMapping(CreateUserMappingStmt *stmt)
MappingUserName(useId),
stmt->servername)));
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return InvalidObjectAddress;
}
else
@@ -1256,7 +1256,7 @@ CreateUserMapping(CreateUserMappingStmt *stmt)
/* Post creation hook for new user mapping */
InvokeObjectPostCreateHook(UserMappingRelationId, umId, 0);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return myself;
}
@@ -1279,7 +1279,7 @@ AlterUserMapping(AlterUserMappingStmt *stmt)
ObjectAddress address;
RoleSpec *role = (RoleSpec *) stmt->user;
- rel = heap_open(UserMappingRelationId, RowExclusiveLock);
+ rel = table_open(UserMappingRelationId, RowExclusiveLock);
if (role->roletype == ROLESPEC_PUBLIC)
useId = ACL_ID_PUBLIC;
@@ -1351,7 +1351,7 @@ AlterUserMapping(AlterUserMappingStmt *stmt)
heap_freetuple(tp);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return address;
}
@@ -1443,7 +1443,7 @@ RemoveUserMappingById(Oid umId)
HeapTuple tp;
Relation rel;
- rel = heap_open(UserMappingRelationId, RowExclusiveLock);
+ rel = table_open(UserMappingRelationId, RowExclusiveLock);
tp = SearchSysCache1(USERMAPPINGOID, ObjectIdGetDatum(umId));
@@ -1454,7 +1454,7 @@ RemoveUserMappingById(Oid umId)
ReleaseSysCache(tp);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
@@ -1482,7 +1482,7 @@ CreateForeignTable(CreateForeignTableStmt *stmt, Oid relid)
*/
CommandCounterIncrement();
- ftrel = heap_open(ForeignTableRelationId, RowExclusiveLock);
+ ftrel = table_open(ForeignTableRelationId, RowExclusiveLock);
/*
* For now the owner cannot be specified on create. Use effective user ID.
@@ -1535,7 +1535,7 @@ CreateForeignTable(CreateForeignTableStmt *stmt, Oid relid)
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
- heap_close(ftrel, RowExclusiveLock);
+ table_close(ftrel, RowExclusiveLock);
}
/*
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 9a8d388909f..dbe96f8d7a9 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -1135,7 +1135,7 @@ RemoveFunctionById(Oid funcOid)
/*
* Delete the pg_proc tuple.
*/
- relation = heap_open(ProcedureRelationId, RowExclusiveLock);
+ relation = table_open(ProcedureRelationId, RowExclusiveLock);
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
@@ -1147,14 +1147,14 @@ RemoveFunctionById(Oid funcOid)
ReleaseSysCache(tup);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
/*
* If there's a pg_aggregate tuple, delete that too.
*/
if (prokind == PROKIND_AGGREGATE)
{
- relation = heap_open(AggregateRelationId, RowExclusiveLock);
+ relation = table_open(AggregateRelationId, RowExclusiveLock);
tup = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
@@ -1164,7 +1164,7 @@ RemoveFunctionById(Oid funcOid)
ReleaseSysCache(tup);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
}
@@ -1192,7 +1192,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
DefElem *parallel_item = NULL;
ObjectAddress address;
- rel = heap_open(ProcedureRelationId, RowExclusiveLock);
+ rel = table_open(ProcedureRelationId, RowExclusiveLock);
funcOid = LookupFuncWithArgs(stmt->objtype, stmt->func, false);
@@ -1312,7 +1312,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
ObjectAddressSet(address, ProcedureRelationId, funcOid);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
heap_freetuple(tup);
return address;
@@ -1334,7 +1334,7 @@ SetFunctionReturnType(Oid funcOid, Oid newRetType)
ObjectAddress func_address;
ObjectAddress type_address;
- pg_proc_rel = heap_open(ProcedureRelationId, RowExclusiveLock);
+ pg_proc_rel = table_open(ProcedureRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
@@ -1350,7 +1350,7 @@ SetFunctionReturnType(Oid funcOid, Oid newRetType)
/* update the catalog and its indexes */
CatalogTupleUpdate(pg_proc_rel, &tup->t_self, tup);
- heap_close(pg_proc_rel, RowExclusiveLock);
+ table_close(pg_proc_rel, RowExclusiveLock);
/*
* Also update the dependency to the new type. Opaque is a pinned type, so
@@ -1376,7 +1376,7 @@ SetFunctionArgType(Oid funcOid, int argIndex, Oid newArgType)
ObjectAddress func_address;
ObjectAddress type_address;
- pg_proc_rel = heap_open(ProcedureRelationId, RowExclusiveLock);
+ pg_proc_rel = table_open(ProcedureRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
@@ -1393,7 +1393,7 @@ SetFunctionArgType(Oid funcOid, int argIndex, Oid newArgType)
/* update the catalog and its indexes */
CatalogTupleUpdate(pg_proc_rel, &tup->t_self, tup);
- heap_close(pg_proc_rel, RowExclusiveLock);
+ table_close(pg_proc_rel, RowExclusiveLock);
/*
* Also update the dependency to the new type. Opaque is a pinned type, so
@@ -1651,7 +1651,7 @@ CreateCast(CreateCastStmt *stmt)
break;
}
- relation = heap_open(CastRelationId, RowExclusiveLock);
+ relation = table_open(CastRelationId, RowExclusiveLock);
/*
* Check for duplicate. This is just to give a friendly error message,
@@ -1717,7 +1717,7 @@ CreateCast(CreateCastStmt *stmt)
heap_freetuple(tuple);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
return myself;
}
@@ -1753,7 +1753,7 @@ DropCastById(Oid castOid)
SysScanDesc scan;
HeapTuple tuple;
- relation = heap_open(CastRelationId, RowExclusiveLock);
+ relation = table_open(CastRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
Anum_pg_cast_oid,
@@ -1768,7 +1768,7 @@ DropCastById(Oid castOid)
CatalogTupleDelete(relation, &tuple->t_self);
systable_endscan(scan);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
@@ -1921,7 +1921,7 @@ CreateTransform(CreateTransformStmt *stmt)
MemSet(nulls, false, sizeof(nulls));
- relation = heap_open(TransformRelationId, RowExclusiveLock);
+ relation = table_open(TransformRelationId, RowExclusiveLock);
tuple = SearchSysCache2(TRFTYPELANG,
ObjectIdGetDatum(typeid),
@@ -2002,7 +2002,7 @@ CreateTransform(CreateTransformStmt *stmt)
heap_freetuple(newtuple);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
return myself;
}
@@ -2040,7 +2040,7 @@ DropTransformById(Oid transformOid)
SysScanDesc scan;
HeapTuple tuple;
- relation = heap_open(TransformRelationId, RowExclusiveLock);
+ relation = table_open(TransformRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
Anum_pg_transform_oid,
@@ -2055,7 +2055,7 @@ DropTransformById(Oid transformOid)
CatalogTupleDelete(relation, &tuple->t_self);
systable_endscan(scan);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 1959e8a82ee..aa5c6ca872b 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -414,7 +414,7 @@ DefineIndex(Oid relationId,
* functions will need to be updated, too.
*/
lockmode = stmt->concurrent ? ShareUpdateExclusiveLock : ShareLock;
- rel = heap_open(relationId, lockmode);
+ rel = table_open(relationId, lockmode);
namespaceId = RelationGetNamespace(rel);
@@ -866,7 +866,7 @@ DefineIndex(Oid relationId,
if (!OidIsValid(indexRelationId))
{
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return address;
}
@@ -899,7 +899,7 @@ DefineIndex(Oid relationId,
for (i = 0; i < numberOfKeyAttributes; i++)
opfamOids[i] = get_opclass_family(classObjectId[i]);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
/*
* For each partition, scan all existing indexes; if one matches
@@ -919,7 +919,7 @@ DefineIndex(Oid relationId,
bool found = false;
int maplen;
- childrel = heap_open(childRelid, lockmode);
+ childrel = table_open(childRelid, lockmode);
childidxs = RelationGetIndexList(childrel);
attmap =
convert_tuples_by_name_map(RelationGetDescr(childrel),
@@ -989,7 +989,7 @@ DefineIndex(Oid relationId,
}
list_free(childidxs);
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
/*
* If no matching index was found, create our own.
@@ -1051,7 +1051,7 @@ DefineIndex(Oid relationId,
*/
if (invalidate_parent)
{
- Relation pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+ Relation pg_index = table_open(IndexRelationId, RowExclusiveLock);
HeapTuple tup,
newtup;
@@ -1064,12 +1064,12 @@ DefineIndex(Oid relationId,
((Form_pg_index) GETSTRUCT(newtup))->indisvalid = false;
CatalogTupleUpdate(pg_index, &tup->t_self, newtup);
ReleaseSysCache(tup);
- heap_close(pg_index, RowExclusiveLock);
+ table_close(pg_index, RowExclusiveLock);
heap_freetuple(newtup);
}
}
else
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
/*
* Indexes on partitioned tables are not themselves built, so we're
@@ -1081,14 +1081,14 @@ DefineIndex(Oid relationId,
if (!stmt->concurrent)
{
/* Close the heap and we're done, in the non-concurrent case */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return address;
}
/* save lockrelid and locktag for below, then close rel */
heaprelid = rel->rd_lockInfo.lockRelId;
SET_LOCKTAG_RELATION(heaplocktag, heaprelid.dbId, heaprelid.relId);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
/*
* For a concurrent build, it's important to make the catalog entries
@@ -1154,7 +1154,7 @@ DefineIndex(Oid relationId,
*/
/* Open and lock the parent heap relation */
- rel = heap_open(relationId, ShareUpdateExclusiveLock);
+ rel = table_open(relationId, ShareUpdateExclusiveLock);
/* And the target index relation */
indexRelation = index_open(indexRelationId, RowExclusiveLock);
@@ -1172,7 +1172,7 @@ DefineIndex(Oid relationId,
index_build(rel, indexRelation, indexInfo, stmt->primary, false, true);
/* Close both the relations, but keep the locks */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
index_close(indexRelation, NoLock);
/*
@@ -1857,7 +1857,7 @@ GetDefaultOpClass(Oid type_id, Oid am_id)
* we need a tiebreaker.) If we find more than one exact match, then
* someone put bogus entries in pg_opclass.
*/
- rel = heap_open(OperatorClassRelationId, AccessShareLock);
+ rel = table_open(OperatorClassRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_opclass_opcmethod,
@@ -1897,7 +1897,7 @@ GetDefaultOpClass(Oid type_id, Oid am_id)
systable_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
/* raise error if pg_opclass contains inconsistent data */
if (nexact > 1)
@@ -2411,7 +2411,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
* We only consider plain relations and materialized views here (toast
* rels will be processed indirectly by reindex_relation).
*/
- relationRelation = heap_open(RelationRelationId, AccessShareLock);
+ relationRelation = table_open(RelationRelationId, AccessShareLock);
scan = heap_beginscan_catalog(relationRelation, num_keys, scan_keys);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
@@ -2472,7 +2472,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
MemoryContextSwitchTo(old);
}
heap_endscan(scan);
- heap_close(relationRelation, AccessShareLock);
+ table_close(relationRelation, AccessShareLock);
/* Now reindex each rel in a separate transaction */
PopActiveSnapshot();
diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c
index 1470ffe1d17..0fd0457eab6 100644
--- a/src/backend/commands/lockcmds.c
+++ b/src/backend/commands/lockcmds.c
@@ -263,7 +263,7 @@ LockViewRecurse(Oid reloid, LOCKMODE lockmode, bool nowait, List *ancestor_views
Relation view;
Query *viewquery;
- view = heap_open(reloid, NoLock);
+ view = table_open(reloid, NoLock);
viewquery = get_view_query(view);
context.lockmode = lockmode;
@@ -276,7 +276,7 @@ LockViewRecurse(Oid reloid, LOCKMODE lockmode, bool nowait, List *ancestor_views
ancestor_views = list_delete_oid(ancestor_views, reloid);
- heap_close(view, NoLock);
+ table_close(view, NoLock);
}
/*
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c
index 416051a8e30..5a47be4b33c 100644
--- a/src/backend/commands/matview.c
+++ b/src/backend/commands/matview.c
@@ -92,7 +92,7 @@ SetMatViewPopulatedState(Relation relation, bool newstate)
* (and this one too!) are sent SI message to make them rebuild relcache
* entries.
*/
- pgrel = heap_open(RelationRelationId, RowExclusiveLock);
+ pgrel = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID,
ObjectIdGetDatum(RelationGetRelid(relation)));
if (!HeapTupleIsValid(tuple))
@@ -104,7 +104,7 @@ SetMatViewPopulatedState(Relation relation, bool newstate)
CatalogTupleUpdate(pgrel, &tuple->t_self, tuple);
heap_freetuple(tuple);
- heap_close(pgrel, RowExclusiveLock);
+ table_close(pgrel, RowExclusiveLock);
/*
* Advance command counter to make the updated pg_class row locally
@@ -165,7 +165,7 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
matviewOid = RangeVarGetRelidExtended(stmt->relation,
lockmode, 0,
RangeVarCallbackOwnsTable, NULL);
- matviewRel = heap_open(matviewOid, NoLock);
+ matviewRel = table_open(matviewOid, NoLock);
/* Make sure it is a materialized view. */
if (matviewRel->rd_rel->relkind != RELKIND_MATVIEW)
@@ -345,7 +345,7 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
pgstat_count_heap_insert(matviewRel, processed);
}
- heap_close(matviewRel, NoLock);
+ table_close(matviewRel, NoLock);
/* Roll back any GUC changes */
AtEOXact_GUC(false, save_nestlevel);
@@ -449,7 +449,7 @@ transientrel_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
DR_transientrel *myState = (DR_transientrel *) self;
Relation transientrel;
- transientrel = heap_open(myState->transientoid, NoLock);
+ transientrel = table_open(myState->transientoid, NoLock);
/*
* Fill private fields of myState for use by later routines
@@ -514,7 +514,7 @@ transientrel_shutdown(DestReceiver *self)
heap_sync(myState->transientrel);
/* close transientrel, but keep lock until commit */
- heap_close(myState->transientrel, NoLock);
+ table_close(myState->transientrel, NoLock);
myState->transientrel = NULL;
}
@@ -596,10 +596,10 @@ refresh_by_match_merge(Oid matviewOid, Oid tempOid, Oid relowner,
Oid *opUsedForQual;
initStringInfo(&querybuf);
- matviewRel = heap_open(matviewOid, NoLock);
+ matviewRel = table_open(matviewOid, NoLock);
matviewname = quote_qualified_identifier(get_namespace_name(RelationGetNamespace(matviewRel)),
RelationGetRelationName(matviewRel));
- tempRel = heap_open(tempOid, NoLock);
+ tempRel = table_open(tempOid, NoLock);
tempname = quote_qualified_identifier(get_namespace_name(RelationGetNamespace(tempRel)),
RelationGetRelationName(tempRel));
diffname = make_temptable_name_n(tempname, 2);
@@ -827,8 +827,8 @@ refresh_by_match_merge(Oid matviewOid, Oid tempOid, Oid relowner,
/* We're done maintaining the materialized view. */
CloseMatViewIncrementalMaintenance();
- heap_close(tempRel, NoLock);
- heap_close(matviewRel, NoLock);
+ table_close(tempRel, NoLock);
+ table_close(matviewRel, NoLock);
/* Clean up temp tables. */
resetStringInfo(&querybuf);
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index e1b1a7e3169..950f3bc4862 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -255,7 +255,7 @@ CreateOpFamily(const char *amname, const char *opfname, Oid namespaceoid, Oid am
ObjectAddress myself,
referenced;
- rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);
+ rel = table_open(OperatorFamilyRelationId, RowExclusiveLock);
/*
* Make sure there is no existing opfamily of this name (this is just to
@@ -319,7 +319,7 @@ CreateOpFamily(const char *amname, const char *opfname, Oid namespaceoid, Oid am
/* Post creation hook for new operator family */
InvokeObjectPostCreateHook(OperatorFamilyRelationId, opfamilyoid, 0);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return myself;
}
@@ -587,7 +587,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
stmt->amname)));
}
- rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
+ rel = table_open(OperatorClassRelationId, RowExclusiveLock);
/*
* Make sure there is no existing opclass of this name (this is just to
@@ -718,7 +718,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
/* Post creation hook for new operator class */
InvokeObjectPostCreateHook(OperatorClassRelationId, opclassoid, 0);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return myself;
}
@@ -1317,7 +1317,7 @@ storeOperators(List *opfamilyname, Oid amoid,
referenced;
ListCell *l;
- rel = heap_open(AccessMethodOperatorRelationId, RowExclusiveLock);
+ rel = table_open(AccessMethodOperatorRelationId, RowExclusiveLock);
foreach(l, operators)
{
@@ -1411,7 +1411,7 @@ storeOperators(List *opfamilyname, Oid amoid,
entryoid, 0);
}
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
@@ -1435,7 +1435,7 @@ storeProcedures(List *opfamilyname, Oid amoid,
referenced;
ListCell *l;
- rel = heap_open(AccessMethodProcedureRelationId, RowExclusiveLock);
+ rel = table_open(AccessMethodProcedureRelationId, RowExclusiveLock);
foreach(l, procedures)
{
@@ -1514,7 +1514,7 @@ storeProcedures(List *opfamilyname, Oid amoid,
entryoid, 0);
}
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
@@ -1607,7 +1607,7 @@ RemoveOpFamilyById(Oid opfamilyOid)
Relation rel;
HeapTuple tup;
- rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);
+ rel = table_open(OperatorFamilyRelationId, RowExclusiveLock);
tup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
@@ -1617,7 +1617,7 @@ RemoveOpFamilyById(Oid opfamilyOid)
ReleaseSysCache(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
void
@@ -1626,7 +1626,7 @@ RemoveOpClassById(Oid opclassOid)
Relation rel;
HeapTuple tup;
- rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
+ rel = table_open(OperatorClassRelationId, RowExclusiveLock);
tup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
@@ -1636,7 +1636,7 @@ RemoveOpClassById(Oid opclassOid)
ReleaseSysCache(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
void
@@ -1652,7 +1652,7 @@ RemoveAmOpEntryById(Oid entryOid)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(entryOid));
- rel = heap_open(AccessMethodOperatorRelationId, RowExclusiveLock);
+ rel = table_open(AccessMethodOperatorRelationId, RowExclusiveLock);
scan = systable_beginscan(rel, AccessMethodOperatorOidIndexId, true,
NULL, 1, skey);
@@ -1665,7 +1665,7 @@ RemoveAmOpEntryById(Oid entryOid)
CatalogTupleDelete(rel, &tup->t_self);
systable_endscan(scan);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
void
@@ -1681,7 +1681,7 @@ RemoveAmProcEntryById(Oid entryOid)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(entryOid));
- rel = heap_open(AccessMethodProcedureRelationId, RowExclusiveLock);
+ rel = table_open(AccessMethodProcedureRelationId, RowExclusiveLock);
scan = systable_beginscan(rel, AccessMethodProcedureOidIndexId, true,
NULL, 1, skey);
@@ -1694,7 +1694,7 @@ RemoveAmProcEntryById(Oid entryOid)
CatalogTupleDelete(rel, &tup->t_self);
systable_endscan(scan);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c
index 9733d6c7bda..7b98e4b910c 100644
--- a/src/backend/commands/operatorcmds.c
+++ b/src/backend/commands/operatorcmds.c
@@ -345,7 +345,7 @@ RemoveOperatorById(Oid operOid)
HeapTuple tup;
Form_pg_operator op;
- relation = heap_open(OperatorRelationId, RowExclusiveLock);
+ relation = table_open(OperatorRelationId, RowExclusiveLock);
tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
@@ -374,7 +374,7 @@ RemoveOperatorById(Oid operOid)
ReleaseSysCache(tup);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
/*
@@ -405,7 +405,7 @@ AlterOperator(AlterOperatorStmt *stmt)
/* Look up the operator */
oprId = LookupOperWithArgs(stmt->opername, false);
- catalog = heap_open(OperatorRelationId, RowExclusiveLock);
+ catalog = table_open(OperatorRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId));
if (tup == NULL)
elog(ERROR, "cache lookup failed for operator %u", oprId);
@@ -524,7 +524,7 @@ AlterOperator(AlterOperatorStmt *stmt)
InvokeObjectPostAlterHook(OperatorRelationId, oprId, 0);
- heap_close(catalog, NoLock);
+ table_close(catalog, NoLock);
return address;
}
diff --git a/src/backend/commands/policy.c b/src/backend/commands/policy.c
index 8465de0e1dd..6a85e143691 100644
--- a/src/backend/commands/policy.c
+++ b/src/backend/commands/policy.c
@@ -221,7 +221,7 @@ RelationBuildRowSecurity(Relation relation)
rsdesc = MemoryContextAllocZero(rscxt, sizeof(RowSecurityDesc));
rsdesc->rscxt = rscxt;
- catalog = heap_open(PolicyRelationId, AccessShareLock);
+ catalog = table_open(PolicyRelationId, AccessShareLock);
ScanKeyInit(&skey,
Anum_pg_policy_polrelid,
@@ -328,7 +328,7 @@ RelationBuildRowSecurity(Relation relation)
}
systable_endscan(sscan);
- heap_close(catalog, AccessShareLock);
+ table_close(catalog, AccessShareLock);
}
PG_CATCH();
{
@@ -360,7 +360,7 @@ RemovePolicyById(Oid policy_id)
Oid relid;
Relation rel;
- pg_policy_rel = heap_open(PolicyRelationId, RowExclusiveLock);
+ pg_policy_rel = table_open(PolicyRelationId, RowExclusiveLock);
/*
* Find the policy to delete.
@@ -387,7 +387,7 @@ RemovePolicyById(Oid policy_id)
*/
relid = ((Form_pg_policy) GETSTRUCT(tuple))->polrelid;
- rel = heap_open(relid, AccessExclusiveLock);
+ rel = table_open(relid, AccessExclusiveLock);
if (rel->rd_rel->relkind != RELKIND_RELATION &&
rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
ereport(ERROR,
@@ -415,10 +415,10 @@ RemovePolicyById(Oid policy_id)
*/
CacheInvalidateRelcache(rel);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
/* Clean up */
- heap_close(pg_policy_rel, RowExclusiveLock);
+ table_close(pg_policy_rel, RowExclusiveLock);
}
/*
@@ -452,7 +452,7 @@ RemoveRoleFromObjectPolicy(Oid roleid, Oid classid, Oid policy_id)
Assert(classid == PolicyRelationId);
- pg_policy_rel = heap_open(PolicyRelationId, RowExclusiveLock);
+ pg_policy_rel = table_open(PolicyRelationId, RowExclusiveLock);
/*
* Find the policy to update.
@@ -675,7 +675,7 @@ RemoveRoleFromObjectPolicy(Oid roleid, Oid classid, Oid policy_id)
relation_close(rel, NoLock);
- heap_close(pg_policy_rel, RowExclusiveLock);
+ table_close(pg_policy_rel, RowExclusiveLock);
return (noperm || num_roles > 0);
}
@@ -781,7 +781,7 @@ CreatePolicy(CreatePolicyStmt *stmt)
assign_expr_collations(with_check_pstate, with_check_qual);
/* Open pg_policy catalog */
- pg_policy_rel = heap_open(PolicyRelationId, RowExclusiveLock);
+ pg_policy_rel = table_open(PolicyRelationId, RowExclusiveLock);
/* Set key - policy's relation id. */
ScanKeyInit(&skey[0],
@@ -875,7 +875,7 @@ CreatePolicy(CreatePolicyStmt *stmt)
free_parsestate(with_check_pstate);
systable_endscan(sscan);
relation_close(target_table, NoLock);
- heap_close(pg_policy_rel, RowExclusiveLock);
+ table_close(pg_policy_rel, RowExclusiveLock);
return myself;
}
@@ -983,7 +983,7 @@ AlterPolicy(AlterPolicyStmt *stmt)
memset(isnull, 0, sizeof(isnull));
/* Find policy to update. */
- pg_policy_rel = heap_open(PolicyRelationId, RowExclusiveLock);
+ pg_policy_rel = table_open(PolicyRelationId, RowExclusiveLock);
/* Set key - policy's relation id. */
ScanKeyInit(&skey[0],
@@ -1205,7 +1205,7 @@ AlterPolicy(AlterPolicyStmt *stmt)
/* Clean up. */
systable_endscan(sscan);
relation_close(target_table, NoLock);
- heap_close(pg_policy_rel, RowExclusiveLock);
+ table_close(pg_policy_rel, RowExclusiveLock);
return myself;
}
@@ -1234,7 +1234,7 @@ rename_policy(RenameStmt *stmt)
target_table = relation_open(table_id, NoLock);
- pg_policy_rel = heap_open(PolicyRelationId, RowExclusiveLock);
+ pg_policy_rel = table_open(PolicyRelationId, RowExclusiveLock);
/* First pass -- check for conflict */
@@ -1310,7 +1310,7 @@ rename_policy(RenameStmt *stmt)
/* Clean up. */
systable_endscan(sscan);
- heap_close(pg_policy_rel, RowExclusiveLock);
+ table_close(pg_policy_rel, RowExclusiveLock);
relation_close(target_table, NoLock);
return address;
@@ -1331,7 +1331,7 @@ get_relation_policy_oid(Oid relid, const char *policy_name, bool missing_ok)
HeapTuple policy_tuple;
Oid policy_oid;
- pg_policy_rel = heap_open(PolicyRelationId, AccessShareLock);
+ pg_policy_rel = table_open(PolicyRelationId, AccessShareLock);
/* Add key - policy's relation id. */
ScanKeyInit(&skey[0],
@@ -1366,7 +1366,7 @@ get_relation_policy_oid(Oid relid, const char *policy_name, bool missing_ok)
/* Clean up. */
systable_endscan(sscan);
- heap_close(pg_policy_rel, AccessShareLock);
+ table_close(pg_policy_rel, AccessShareLock);
return policy_oid;
}
@@ -1383,7 +1383,7 @@ relation_has_policies(Relation rel)
HeapTuple policy_tuple;
bool ret = false;
- catalog = heap_open(PolicyRelationId, AccessShareLock);
+ catalog = table_open(PolicyRelationId, AccessShareLock);
ScanKeyInit(&skey,
Anum_pg_policy_polrelid,
BTEqualStrategyNumber, F_OIDEQ,
@@ -1395,7 +1395,7 @@ relation_has_policies(Relation rel)
ret = true;
systable_endscan(sscan);
- heap_close(catalog, AccessShareLock);
+ table_close(catalog, AccessShareLock);
return ret;
}
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c
index 572a5d5bdea..52eb37d60af 100644
--- a/src/backend/commands/proclang.c
+++ b/src/backend/commands/proclang.c
@@ -335,7 +335,7 @@ create_proc_lang(const char *languageName, bool replace,
ObjectAddress myself,
referenced;
- rel = heap_open(LanguageRelationId, RowExclusiveLock);
+ rel = table_open(LanguageRelationId, RowExclusiveLock);
tupDesc = RelationGetDescr(rel);
/* Prepare data to be inserted */
@@ -444,7 +444,7 @@ create_proc_lang(const char *languageName, bool replace,
/* Post creation hook for new procedural language */
InvokeObjectPostCreateHook(LanguageRelationId, myself.objectId, 0);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return myself;
}
@@ -461,7 +461,7 @@ find_language_template(const char *languageName)
ScanKeyData key;
HeapTuple tup;
- rel = heap_open(PLTemplateRelationId, AccessShareLock);
+ rel = table_open(PLTemplateRelationId, AccessShareLock);
ScanKeyInit(&key,
Anum_pg_pltemplate_tmplname,
@@ -511,7 +511,7 @@ find_language_template(const char *languageName)
systable_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
return result;
}
@@ -535,7 +535,7 @@ DropProceduralLanguageById(Oid langOid)
Relation rel;
HeapTuple langTup;
- rel = heap_open(LanguageRelationId, RowExclusiveLock);
+ rel = table_open(LanguageRelationId, RowExclusiveLock);
langTup = SearchSysCache1(LANGOID, ObjectIdGetDatum(langOid));
if (!HeapTupleIsValid(langTup)) /* should not happen */
@@ -545,7 +545,7 @@ DropProceduralLanguageById(Oid langOid)
ReleaseSysCache(langTup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index e431e58f0e6..d105c2709e3 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -165,7 +165,7 @@ CreatePublication(CreatePublicationStmt *stmt)
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
(errmsg("must be superuser to create FOR ALL TABLES publication"))));
- rel = heap_open(PublicationRelationId, RowExclusiveLock);
+ rel = table_open(PublicationRelationId, RowExclusiveLock);
/* Check if name is used */
puboid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
@@ -229,7 +229,7 @@ CreatePublication(CreatePublicationStmt *stmt)
CloseTableList(rels);
}
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
InvokeObjectPostCreateHook(PublicationRelationId, puboid, 0);
@@ -377,7 +377,7 @@ AlterPublicationTables(AlterPublicationStmt *stmt, Relation rel,
if (!found)
{
- Relation oldrel = heap_open(oldrelid,
+ Relation oldrel = table_open(oldrelid,
ShareUpdateExclusiveLock);
delrels = lappend(delrels, oldrel);
@@ -412,7 +412,7 @@ AlterPublication(AlterPublicationStmt *stmt)
HeapTuple tup;
Form_pg_publication pubform;
- rel = heap_open(PublicationRelationId, RowExclusiveLock);
+ rel = table_open(PublicationRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(PUBLICATIONNAME,
CStringGetDatum(stmt->pubname));
@@ -437,7 +437,7 @@ AlterPublication(AlterPublicationStmt *stmt)
/* Cleanup. */
heap_freetuple(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
@@ -449,7 +449,7 @@ RemovePublicationById(Oid pubid)
Relation rel;
HeapTuple tup;
- rel = heap_open(PublicationRelationId, RowExclusiveLock);
+ rel = table_open(PublicationRelationId, RowExclusiveLock);
tup = SearchSysCache1(PUBLICATIONOID, ObjectIdGetDatum(pubid));
@@ -460,7 +460,7 @@ RemovePublicationById(Oid pubid)
ReleaseSysCache(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
@@ -473,7 +473,7 @@ RemovePublicationRelById(Oid proid)
HeapTuple tup;
Form_pg_publication_rel pubrel;
- rel = heap_open(PublicationRelRelationId, RowExclusiveLock);
+ rel = table_open(PublicationRelRelationId, RowExclusiveLock);
tup = SearchSysCache1(PUBLICATIONREL, ObjectIdGetDatum(proid));
@@ -490,7 +490,7 @@ RemovePublicationRelById(Oid proid)
ReleaseSysCache(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
@@ -517,7 +517,7 @@ OpenTableList(List *tables)
/* Allow query cancel in case this takes a long time */
CHECK_FOR_INTERRUPTS();
- rel = heap_openrv(rv, ShareUpdateExclusiveLock);
+ rel = table_openrv(rv, ShareUpdateExclusiveLock);
myrelid = RelationGetRelid(rel);
/*
@@ -529,7 +529,7 @@ OpenTableList(List *tables)
*/
if (list_member_oid(relids, myrelid))
{
- heap_close(rel, ShareUpdateExclusiveLock);
+ table_close(rel, ShareUpdateExclusiveLock);
continue;
}
@@ -560,7 +560,7 @@ OpenTableList(List *tables)
continue;
/* find_all_inheritors already got lock */
- rel = heap_open(childrelid, NoLock);
+ rel = table_open(childrelid, NoLock);
rels = lappend(rels, rel);
relids = lappend_oid(relids, childrelid);
}
@@ -584,7 +584,7 @@ CloseTableList(List *rels)
{
Relation rel = (Relation) lfirst(lc);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
}
@@ -718,7 +718,7 @@ AlterPublicationOwner(const char *name, Oid newOwnerId)
ObjectAddress address;
Form_pg_publication pubform;
- rel = heap_open(PublicationRelationId, RowExclusiveLock);
+ rel = table_open(PublicationRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(PUBLICATIONNAME, CStringGetDatum(name));
@@ -736,7 +736,7 @@ AlterPublicationOwner(const char *name, Oid newOwnerId)
heap_freetuple(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return address;
}
@@ -750,7 +750,7 @@ AlterPublicationOwner_oid(Oid subid, Oid newOwnerId)
HeapTuple tup;
Relation rel;
- rel = heap_open(PublicationRelationId, RowExclusiveLock);
+ rel = table_open(PublicationRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(PUBLICATIONOID, ObjectIdGetDatum(subid));
@@ -763,5 +763,5 @@ AlterPublicationOwner_oid(Oid subid, Oid newOwnerId)
heap_freetuple(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c
index 8367261fbe8..6cf94a3140b 100644
--- a/src/backend/commands/schemacmds.c
+++ b/src/backend/commands/schemacmds.c
@@ -220,7 +220,7 @@ RemoveSchemaById(Oid schemaOid)
Relation relation;
HeapTuple tup;
- relation = heap_open(NamespaceRelationId, RowExclusiveLock);
+ relation = table_open(NamespaceRelationId, RowExclusiveLock);
tup = SearchSysCache1(NAMESPACEOID,
ObjectIdGetDatum(schemaOid));
@@ -231,7 +231,7 @@ RemoveSchemaById(Oid schemaOid)
ReleaseSysCache(tup);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
@@ -248,7 +248,7 @@ RenameSchema(const char *oldname, const char *newname)
ObjectAddress address;
Form_pg_namespace nspform;
- rel = heap_open(NamespaceRelationId, RowExclusiveLock);
+ rel = table_open(NamespaceRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(NAMESPACENAME, CStringGetDatum(oldname));
if (!HeapTupleIsValid(tup))
@@ -290,7 +290,7 @@ RenameSchema(const char *oldname, const char *newname)
ObjectAddressSet(address, NamespaceRelationId, nspOid);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
heap_freetuple(tup);
return address;
@@ -302,7 +302,7 @@ AlterSchemaOwner_oid(Oid oid, Oid newOwnerId)
HeapTuple tup;
Relation rel;
- rel = heap_open(NamespaceRelationId, RowExclusiveLock);
+ rel = table_open(NamespaceRelationId, RowExclusiveLock);
tup = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(oid));
if (!HeapTupleIsValid(tup))
@@ -312,7 +312,7 @@ AlterSchemaOwner_oid(Oid oid, Oid newOwnerId)
ReleaseSysCache(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
@@ -328,7 +328,7 @@ AlterSchemaOwner(const char *name, Oid newOwnerId)
ObjectAddress address;
Form_pg_namespace nspform;
- rel = heap_open(NamespaceRelationId, RowExclusiveLock);
+ rel = table_open(NamespaceRelationId, RowExclusiveLock);
tup = SearchSysCache1(NAMESPACENAME, CStringGetDatum(name));
if (!HeapTupleIsValid(tup))
@@ -345,7 +345,7 @@ AlterSchemaOwner(const char *name, Oid newOwnerId)
ReleaseSysCache(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return address;
}
diff --git a/src/backend/commands/seclabel.c b/src/backend/commands/seclabel.c
index 1e31dc1f678..645a0bf16b3 100644
--- a/src/backend/commands/seclabel.c
+++ b/src/backend/commands/seclabel.c
@@ -168,7 +168,7 @@ GetSharedSecurityLabel(const ObjectAddress *object, const char *provider)
BTEqualStrategyNumber, F_TEXTEQ,
CStringGetTextDatum(provider));
- pg_shseclabel = heap_open(SharedSecLabelRelationId, AccessShareLock);
+ pg_shseclabel = table_open(SharedSecLabelRelationId, AccessShareLock);
scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true,
NULL, 3, keys);
@@ -183,7 +183,7 @@ GetSharedSecurityLabel(const ObjectAddress *object, const char *provider)
}
systable_endscan(scan);
- heap_close(pg_shseclabel, AccessShareLock);
+ table_close(pg_shseclabel, AccessShareLock);
return seclabel;
}
@@ -225,7 +225,7 @@ GetSecurityLabel(const ObjectAddress *object, const char *provider)
BTEqualStrategyNumber, F_TEXTEQ,
CStringGetTextDatum(provider));
- pg_seclabel = heap_open(SecLabelRelationId, AccessShareLock);
+ pg_seclabel = table_open(SecLabelRelationId, AccessShareLock);
scan = systable_beginscan(pg_seclabel, SecLabelObjectIndexId, true,
NULL, 4, keys);
@@ -240,7 +240,7 @@ GetSecurityLabel(const ObjectAddress *object, const char *provider)
}
systable_endscan(scan);
- heap_close(pg_seclabel, AccessShareLock);
+ table_close(pg_seclabel, AccessShareLock);
return seclabel;
}
@@ -285,7 +285,7 @@ SetSharedSecurityLabel(const ObjectAddress *object,
BTEqualStrategyNumber, F_TEXTEQ,
CStringGetTextDatum(provider));
- pg_shseclabel = heap_open(SharedSecLabelRelationId, RowExclusiveLock);
+ pg_shseclabel = table_open(SharedSecLabelRelationId, RowExclusiveLock);
scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true,
NULL, 3, keys);
@@ -316,7 +316,7 @@ SetSharedSecurityLabel(const ObjectAddress *object,
if (newtup != NULL)
heap_freetuple(newtup);
- heap_close(pg_shseclabel, RowExclusiveLock);
+ table_close(pg_shseclabel, RowExclusiveLock);
}
/*
@@ -372,7 +372,7 @@ SetSecurityLabel(const ObjectAddress *object,
BTEqualStrategyNumber, F_TEXTEQ,
CStringGetTextDatum(provider));
- pg_seclabel = heap_open(SecLabelRelationId, RowExclusiveLock);
+ pg_seclabel = table_open(SecLabelRelationId, RowExclusiveLock);
scan = systable_beginscan(pg_seclabel, SecLabelObjectIndexId, true,
NULL, 4, keys);
@@ -404,7 +404,7 @@ SetSecurityLabel(const ObjectAddress *object,
if (newtup != NULL)
heap_freetuple(newtup);
- heap_close(pg_seclabel, RowExclusiveLock);
+ table_close(pg_seclabel, RowExclusiveLock);
}
/*
@@ -428,7 +428,7 @@ DeleteSharedSecurityLabel(Oid objectId, Oid classId)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(classId));
- pg_shseclabel = heap_open(SharedSecLabelRelationId, RowExclusiveLock);
+ pg_shseclabel = table_open(SharedSecLabelRelationId, RowExclusiveLock);
scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true,
NULL, 2, skey);
@@ -436,7 +436,7 @@ DeleteSharedSecurityLabel(Oid objectId, Oid classId)
CatalogTupleDelete(pg_shseclabel, &oldtup->t_self);
systable_endscan(scan);
- heap_close(pg_shseclabel, RowExclusiveLock);
+ table_close(pg_shseclabel, RowExclusiveLock);
}
/*
@@ -479,7 +479,7 @@ DeleteSecurityLabel(const ObjectAddress *object)
else
nkeys = 2;
- pg_seclabel = heap_open(SecLabelRelationId, RowExclusiveLock);
+ pg_seclabel = table_open(SecLabelRelationId, RowExclusiveLock);
scan = systable_beginscan(pg_seclabel, SecLabelObjectIndexId, true,
NULL, nkeys, skey);
@@ -487,7 +487,7 @@ DeleteSecurityLabel(const ObjectAddress *object)
CatalogTupleDelete(pg_seclabel, &oldtup->t_self);
systable_endscan(scan);
- heap_close(pg_seclabel, RowExclusiveLock);
+ table_close(pg_seclabel, RowExclusiveLock);
}
void
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 5554e883d80..574b46a2812 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -217,7 +217,7 @@ DefineSequence(ParseState *pstate, CreateSeqStmt *seq)
seqoid = address.objectId;
Assert(seqoid != InvalidOid);
- rel = heap_open(seqoid, AccessExclusiveLock);
+ rel = table_open(seqoid, AccessExclusiveLock);
tupDesc = RelationGetDescr(rel);
/* now initialize the sequence's data */
@@ -228,10 +228,10 @@ DefineSequence(ParseState *pstate, CreateSeqStmt *seq)
if (owned_by)
process_owned_by(rel, owned_by, seq->for_identity);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
/* fill in pg_sequence */
- rel = heap_open(SequenceRelationId, RowExclusiveLock);
+ rel = table_open(SequenceRelationId, RowExclusiveLock);
tupDesc = RelationGetDescr(rel);
memset(pgs_nulls, 0, sizeof(pgs_nulls));
@@ -249,7 +249,7 @@ DefineSequence(ParseState *pstate, CreateSeqStmt *seq)
CatalogTupleInsert(rel, tuple);
heap_freetuple(tuple);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return address;
}
@@ -446,7 +446,7 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
init_sequence(relid, &elm, &seqrel);
- rel = heap_open(SequenceRelationId, RowExclusiveLock);
+ rel = table_open(SequenceRelationId, RowExclusiveLock);
seqtuple = SearchSysCacheCopy1(SEQRELID,
ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(seqtuple))
@@ -506,7 +506,7 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
ObjectAddressSet(address, RelationRelationId, relid);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
relation_close(seqrel, NoLock);
return address;
@@ -518,7 +518,7 @@ DeleteSequenceTuple(Oid relid)
Relation rel;
HeapTuple tuple;
- rel = heap_open(SequenceRelationId, RowExclusiveLock);
+ rel = table_open(SequenceRelationId, RowExclusiveLock);
tuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
@@ -527,7 +527,7 @@ DeleteSequenceTuple(Oid relid)
CatalogTupleDelete(rel, &tuple->t_self);
ReleaseSysCache(tuple);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index 970fdb712d6..50762e2d51a 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -308,7 +308,7 @@ CreateStatistics(CreateStatsStmt *stmt)
Assert(ntypes > 0 && ntypes <= lengthof(types));
stxkind = construct_array(types, ntypes, CHAROID, 1, true, 'c');
- statrel = heap_open(StatisticExtRelationId, RowExclusiveLock);
+ statrel = table_open(StatisticExtRelationId, RowExclusiveLock);
/*
* Everything seems fine, so let's build the pg_statistic_ext tuple.
@@ -396,7 +396,7 @@ RemoveStatisticsById(Oid statsOid)
* Delete the pg_statistic_ext tuple. Also send out a cache inval on the
* associated table, so that dependent plans will be rebuilt.
*/
- relation = heap_open(StatisticExtRelationId, RowExclusiveLock);
+ relation = table_open(StatisticExtRelationId, RowExclusiveLock);
tup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statsOid));
@@ -412,7 +412,7 @@ RemoveStatisticsById(Oid statsOid)
ReleaseSysCache(tup);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
/*
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index bd0f4cd1a15..a60a15193a4 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -347,7 +347,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
(errmsg("must be superuser to create subscriptions"))));
- rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
+ rel = table_open(SubscriptionRelationId, RowExclusiveLock);
/* Check if name is used */
subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
@@ -491,7 +491,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
"ALTER SUBSCRIPTION ... REFRESH PUBLICATION to "
"subscribe the tables")));
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
if (enabled)
ApplyLauncherWakeupAtCommit();
@@ -626,7 +626,7 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
Subscription *sub;
Form_pg_subscription form;
- rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
+ rel = table_open(SubscriptionRelationId, RowExclusiveLock);
/* Fetch the existing tuple. */
tup = SearchSysCacheCopy2(SUBSCRIPTIONNAME, MyDatabaseId,
@@ -799,7 +799,7 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
heap_freetuple(tup);
}
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
ObjectAddressSet(myself, SubscriptionRelationId, subid);
@@ -836,14 +836,14 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
* Lock pg_subscription with AccessExclusiveLock to ensure that the
* launcher doesn't restart new worker during dropping the subscription
*/
- rel = heap_open(SubscriptionRelationId, AccessExclusiveLock);
+ rel = table_open(SubscriptionRelationId, AccessExclusiveLock);
tup = SearchSysCache2(SUBSCRIPTIONNAME, MyDatabaseId,
CStringGetDatum(stmt->subname));
if (!HeapTupleIsValid(tup))
{
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
if (!stmt->missing_ok)
ereport(ERROR,
@@ -962,7 +962,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
*/
if (!slotname)
{
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return;
}
@@ -1014,7 +1014,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
pfree(cmd.data);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
/*
@@ -1066,7 +1066,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
ObjectAddress address;
Form_pg_subscription form;
- rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
+ rel = table_open(SubscriptionRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy2(SUBSCRIPTIONNAME, MyDatabaseId,
CStringGetDatum(name));
@@ -1085,7 +1085,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
heap_freetuple(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return address;
}
@@ -1099,7 +1099,7 @@ AlterSubscriptionOwner_oid(Oid subid, Oid newOwnerId)
HeapTuple tup;
Relation rel;
- rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
+ rel = table_open(SubscriptionRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
@@ -1112,7 +1112,7 @@ AlterSubscriptionOwner_oid(Oid subid, Oid newOwnerId)
heap_freetuple(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index d2781cbf194..68eb0c7105f 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -829,7 +829,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
defaultRel = NULL;
/* Already have strong enough lock on the parent */
- parent = heap_open(parentId, NoLock);
+ parent = table_open(parentId, NoLock);
/*
* We are going to try to validate the partition bound specification
@@ -863,7 +863,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
defaultPartOid =
get_default_oid_from_partdesc(RelationGetPartitionDesc(parent));
if (OidIsValid(defaultPartOid))
- defaultRel = heap_open(defaultPartOid, AccessExclusiveLock);
+ defaultRel = table_open(defaultPartOid, AccessExclusiveLock);
/* Transform the bound values */
pstate = make_parsestate(NULL);
@@ -888,13 +888,13 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
{
check_default_partition_contents(parent, defaultRel, bound);
/* Keep the lock until commit. */
- heap_close(defaultRel, NoLock);
+ table_close(defaultRel, NoLock);
}
/* Update the pg_class entry. */
StorePartitionBound(rel, parent, bound);
- heap_close(parent, NoLock);
+ table_close(parent, NoLock);
}
/* Store inheritance information for new rel. */
@@ -961,7 +961,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
ListCell *cell;
/* Already have strong enough lock on the parent */
- parent = heap_open(parentId, NoLock);
+ parent = table_open(parentId, NoLock);
idxlist = RelationGetIndexList(parent);
/*
@@ -1006,7 +1006,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
*/
CloneForeignKeyConstraints(parentId, relationId, NULL);
- heap_close(parent, NoLock);
+ table_close(parent, NoLock);
}
/*
@@ -1380,12 +1380,12 @@ ExecuteTruncate(TruncateStmt *stmt)
NULL);
/* open the relation, we already hold a lock on it */
- rel = heap_open(myrelid, NoLock);
+ rel = table_open(myrelid, NoLock);
/* don't throw error for "TRUNCATE foo, foo" */
if (list_member_oid(relids, myrelid))
{
- heap_close(rel, lockmode);
+ table_close(rel, lockmode);
continue;
}
@@ -1416,7 +1416,7 @@ ExecuteTruncate(TruncateStmt *stmt)
continue;
/* find_all_inheritors already got lock */
- rel = heap_open(childrelid, NoLock);
+ rel = table_open(childrelid, NoLock);
/*
* It is possible that the parent table has children that are
@@ -1429,7 +1429,7 @@ ExecuteTruncate(TruncateStmt *stmt)
*/
if (RELATION_IS_OTHER_TEMP(rel))
{
- heap_close(rel, lockmode);
+ table_close(rel, lockmode);
continue;
}
@@ -1458,7 +1458,7 @@ ExecuteTruncate(TruncateStmt *stmt)
{
Relation rel = (Relation) lfirst(cell);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
}
@@ -1514,7 +1514,7 @@ ExecuteTruncateGuts(List *explicit_rels, List *relids, List *relids_logged,
Oid relid = lfirst_oid(cell);
Relation rel;
- rel = heap_open(relid, AccessExclusiveLock);
+ rel = table_open(relid, AccessExclusiveLock);
ereport(NOTICE,
(errmsg("truncate cascades to table \"%s\"",
RelationGetRelationName(rel))));
@@ -1683,7 +1683,7 @@ ExecuteTruncateGuts(List *explicit_rels, List *relids, List *relids_logged,
RecentXmin, minmulti);
if (toastrel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED)
heap_create_init_fork(toastrel);
- heap_close(toastrel, NoLock);
+ table_close(toastrel, NoLock);
}
/*
@@ -1767,7 +1767,7 @@ ExecuteTruncateGuts(List *explicit_rels, List *relids, List *relids_logged,
{
Relation rel = (Relation) lfirst(cell);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
}
@@ -2022,7 +2022,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
AttrNumber parent_attno;
/* caller already got lock */
- relation = heap_open(parent, NoLock);
+ relation = table_open(parent, NoLock);
/*
* Check for active uses of the parent partitioned table in the
@@ -2313,7 +2313,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
* That will prevent someone else from deleting or ALTERing the parent
* before the child is committed.
*/
- heap_close(relation, NoLock);
+ table_close(relation, NoLock);
}
/*
@@ -2591,7 +2591,7 @@ StoreCatalogInheritance(Oid relationId, List *supers,
* and then entered into pg_ipl. Since that catalog doesn't exist
* anymore, there's no need to look for indirect ancestors.)
*/
- relation = heap_open(InheritsRelationId, RowExclusiveLock);
+ relation = table_open(InheritsRelationId, RowExclusiveLock);
seqNumber = 1;
foreach(entry, supers)
@@ -2603,7 +2603,7 @@ StoreCatalogInheritance(Oid relationId, List *supers,
seqNumber++;
}
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
/*
@@ -2697,7 +2697,7 @@ SetRelationHasSubclass(Oid relationId, bool relhassubclass)
/*
* Fetch a modifiable copy of the tuple, modify it, update pg_class.
*/
- relationRelation = heap_open(RelationRelationId, RowExclusiveLock);
+ relationRelation = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationId);
@@ -2715,7 +2715,7 @@ SetRelationHasSubclass(Oid relationId, bool relhassubclass)
}
heap_freetuple(tuple);
- heap_close(relationRelation, RowExclusiveLock);
+ table_close(relationRelation, RowExclusiveLock);
}
/*
@@ -2860,7 +2860,7 @@ renameatt_internal(Oid myrelid,
renameatt_internal(lfirst_oid(lo), oldattname, newattname, true, true, 0, behavior);
}
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
atttup = SearchSysCacheCopyAttName(myrelid, oldattname);
if (!HeapTupleIsValid(atttup))
@@ -2904,7 +2904,7 @@ renameatt_internal(Oid myrelid,
heap_freetuple(atttup);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
relation_close(targetrelation, NoLock); /* close rel but keep lock */
@@ -3090,13 +3090,13 @@ RenameConstraint(RenameStmt *stmt)
HeapTuple tup;
typid = typenameTypeId(NULL, makeTypeNameFromNameList(castNode(List, stmt->object)));
- rel = heap_open(TypeRelationId, RowExclusiveLock);
+ rel = table_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typid);
checkDomainOwner(tup);
ReleaseSysCache(tup);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
else
{
@@ -3194,7 +3194,7 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bo
/*
* Find relation's pg_class tuple, and make sure newrelname isn't in use.
*/
- relrelation = heap_open(RelationRelationId, RowExclusiveLock);
+ relrelation = table_open(RelationRelationId, RowExclusiveLock);
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup)) /* shouldn't happen */
@@ -3219,7 +3219,7 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bo
InvalidOid, is_internal);
heap_freetuple(reltup);
- heap_close(relrelation, RowExclusiveLock);
+ table_close(relrelation, RowExclusiveLock);
/*
* Also rename the associated type, if any.
@@ -4368,9 +4368,9 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
{
Relation rel;
- rel = heap_open(tab->relid, NoLock);
+ rel = table_open(tab->relid, NoLock);
find_composite_type_dependencies(rel->rd_rel->reltype, rel, NULL);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
/*
@@ -4393,7 +4393,7 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
Oid NewTableSpace;
char persistence;
- OldHeap = heap_open(tab->relid, NoLock);
+ OldHeap = table_open(tab->relid, NoLock);
/*
* We don't support rewriting of system catalogs; there are too
@@ -4437,7 +4437,7 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
persistence = tab->chgPersistence ?
tab->newrelpersistence : OldHeap->rd_rel->relpersistence;
- heap_close(OldHeap, NoLock);
+ table_close(OldHeap, NoLock);
/*
* Fire off an Event Trigger now, before actually rewriting the
@@ -4538,10 +4538,10 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
if (rel == NULL)
{
/* Long since locked, no need for another */
- rel = heap_open(tab->relid, NoLock);
+ rel = table_open(tab->relid, NoLock);
}
- refrel = heap_open(con->refrelid, RowShareLock);
+ refrel = table_open(con->refrelid, RowShareLock);
validateForeignKeyConstraint(fkconstraint->conname, rel, refrel,
con->refindid,
@@ -4552,12 +4552,12 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
* that when we inserted the row earlier.
*/
- heap_close(refrel, NoLock);
+ table_close(refrel, NoLock);
}
}
if (rel)
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
}
@@ -4587,12 +4587,12 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
* Open the relation(s). We have surely already locked the existing
* table.
*/
- oldrel = heap_open(tab->relid, NoLock);
+ oldrel = table_open(tab->relid, NoLock);
oldTupDesc = tab->oldDesc;
newTupDesc = RelationGetDescr(oldrel); /* includes all mods */
if (OidIsValid(OIDNewHeap))
- newrel = heap_open(OIDNewHeap, lockmode);
+ newrel = table_open(OIDNewHeap, lockmode);
else
newrel = NULL;
@@ -4868,7 +4868,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
FreeExecutorState(estate);
- heap_close(oldrel, NoLock);
+ table_close(oldrel, NoLock);
if (newrel)
{
FreeBulkInsertState(bistate);
@@ -4877,7 +4877,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
if (hi_options & HEAP_INSERT_SKIP_WAL)
heap_sync(newrel);
- heap_close(newrel, NoLock);
+ table_close(newrel, NoLock);
}
}
@@ -5147,7 +5147,7 @@ find_composite_type_dependencies(Oid typeOid, Relation origRelation,
* We scan pg_depend to find those things that depend on the given type.
* (We assume we can ignore refobjsubid for a type.)
*/
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
@@ -5258,7 +5258,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
HeapTuple tuple;
List *result = NIL;
- classRel = heap_open(RelationRelationId, AccessShareLock);
+ classRel = table_open(RelationRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_class_reloftype,
@@ -5282,7 +5282,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
}
heap_endscan(scan);
- heap_close(classRel, AccessShareLock);
+ table_close(classRel, AccessShareLock);
return result;
}
@@ -5394,7 +5394,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot add column to a partition")));
- attrdesc = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrdesc = table_open(AttributeRelationId, RowExclusiveLock);
/*
* Are we adding the column to a recursion child? If so, check whether to
@@ -5444,12 +5444,12 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
(errmsg("merging definition of column \"%s\" for child \"%s\"",
colDef->colname, RelationGetRelationName(rel))));
- heap_close(attrdesc, RowExclusiveLock);
+ table_close(attrdesc, RowExclusiveLock);
return InvalidObjectAddress;
}
}
- pgclass = heap_open(RelationRelationId, RowExclusiveLock);
+ pgclass = table_open(RelationRelationId, RowExclusiveLock);
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup))
@@ -5470,9 +5470,9 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
/* skip if the name already exists and if_not_exists is true */
if (!check_for_column_name_collision(rel, colDef->colname, if_not_exists))
{
- heap_close(attrdesc, RowExclusiveLock);
+ table_close(attrdesc, RowExclusiveLock);
heap_freetuple(reltup);
- heap_close(pgclass, RowExclusiveLock);
+ table_close(pgclass, RowExclusiveLock);
return InvalidObjectAddress;
}
@@ -5525,7 +5525,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
InsertPgAttributeTuple(attrdesc, &attribute, NULL);
- heap_close(attrdesc, RowExclusiveLock);
+ table_close(attrdesc, RowExclusiveLock);
/*
* Update pg_class tuple as appropriate
@@ -5539,7 +5539,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
/* Post creation hook for new attribute */
InvokeObjectPostCreateHook(RelationRelationId, myrelid, newattnum);
- heap_close(pgclass, RowExclusiveLock);
+ table_close(pgclass, RowExclusiveLock);
/* Make the attribute's catalog entry visible */
CommandCounterIncrement();
@@ -5715,7 +5715,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
AlteredTableInfo *childtab;
/* find_inheritance_children already got lock */
- childrel = heap_open(childrelid, NoLock);
+ childrel = table_open(childrelid, NoLock);
CheckTableNotInUse(childrel, "ALTER TABLE");
/* Find or create work queue entry for this table */
@@ -5726,7 +5726,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
colDef, recurse, true,
if_not_exists, lockmode);
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
}
ObjectAddressSubSet(address, RelationRelationId, myrelid, newattnum);
@@ -5867,7 +5867,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
/*
* lookup the attribute
*/
- attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
if (!HeapTupleIsValid(tuple))
@@ -5938,7 +5938,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
if (rel->rd_rel->relispartition)
{
Oid parentId = get_partition_parent(RelationGetRelid(rel));
- Relation parent = heap_open(parentId, AccessShareLock);
+ Relation parent = table_open(parentId, AccessShareLock);
TupleDesc tupDesc = RelationGetDescr(parent);
AttrNumber parent_attnum;
@@ -5948,7 +5948,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("column \"%s\" is marked NOT NULL in parent table",
colName)));
- heap_close(parent, AccessShareLock);
+ table_close(parent, AccessShareLock);
}
/*
@@ -5969,7 +5969,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel), attnum);
- heap_close(attr_rel, RowExclusiveLock);
+ table_close(attr_rel, RowExclusiveLock);
return address;
}
@@ -6014,7 +6014,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
/*
* lookup the attribute
*/
- attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
@@ -6054,7 +6054,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
InvokeObjectPostAlterHook(RelationRelationId,
RelationGetRelid(rel), attnum);
- heap_close(attr_rel, RowExclusiveLock);
+ table_close(attr_rel, RowExclusiveLock);
return address;
}
@@ -6147,7 +6147,7 @@ ATExecAddIdentity(Relation rel, const char *colName,
ObjectAddress address;
ColumnDef *cdef = castNode(ColumnDef, def);
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
if (!HeapTupleIsValid(tuple))
@@ -6198,7 +6198,7 @@ ATExecAddIdentity(Relation rel, const char *colName,
RelationGetRelid(rel), attnum);
heap_freetuple(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
return address;
}
@@ -6242,7 +6242,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
* there.
*/
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
@@ -6280,7 +6280,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
address = InvalidObjectAddress;
heap_freetuple(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
return address;
}
@@ -6301,7 +6301,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
Oid seqid;
ObjectAddress seqaddress;
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
@@ -6331,7 +6331,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
(errmsg("column \"%s\" of relation \"%s\" is not an identity column, skipping",
colName, RelationGetRelationName(rel))));
heap_freetuple(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
return InvalidObjectAddress;
}
}
@@ -6346,7 +6346,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
RelationGetRelid(rel), attnum);
heap_freetuple(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
/* drop the internal sequence */
seqid = getOwnedSequence(RelationGetRelid(rel), attnum);
@@ -6436,7 +6436,7 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa
newtarget)));
}
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
if (colName)
{
@@ -6495,7 +6495,7 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa
RelationGetRelid(rel), attnum);
heap_freetuple(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
return address;
}
@@ -6520,7 +6520,7 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
bool repl_null[Natts_pg_attribute];
bool repl_repl[Natts_pg_attribute];
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheAttName(RelationGetRelid(rel), colName);
@@ -6571,7 +6571,7 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
ReleaseSysCache(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
return address;
}
@@ -6612,7 +6612,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
newstorage = 0; /* keep compiler quiet */
}
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
@@ -6650,7 +6650,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
heap_freetuple(tuple);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
ObjectAddressSubSet(address, RelationRelationId,
RelationGetRelid(rel), attnum);
@@ -6781,7 +6781,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
errmsg("cannot drop column from only the partitioned table when partitions exist"),
errhint("Do not specify the ONLY keyword.")));
- attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
foreach(child, children)
{
Oid childrelid = lfirst_oid(child);
@@ -6789,7 +6789,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
Form_pg_attribute childatt;
/* find_inheritance_children already got lock */
- childrel = heap_open(childrelid, NoLock);
+ childrel = table_open(childrelid, NoLock);
CheckTableNotInUse(childrel, "ALTER TABLE");
tuple = SearchSysCacheCopyAttName(childrelid, colName);
@@ -6845,9 +6845,9 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
heap_freetuple(tuple);
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
}
- heap_close(attr_rel, RowExclusiveLock);
+ table_close(attr_rel, RowExclusiveLock);
}
/*
@@ -7202,7 +7202,7 @@ ATAddCheckConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
AlteredTableInfo *childtab;
/* find_inheritance_children already got lock */
- childrel = heap_open(childrelid, NoLock);
+ childrel = table_open(childrelid, NoLock);
CheckTableNotInUse(childrel, "ALTER TABLE");
/* Find or create work queue entry for this table */
@@ -7212,7 +7212,7 @@ ATAddCheckConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
ATAddCheckConstraint(wqueue, childtab, childrel,
constr, recurse, true, is_readd, lockmode);
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
}
return address;
@@ -7254,9 +7254,9 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
* delete rows out from under us.
*/
if (OidIsValid(fkconstraint->old_pktable_oid))
- pkrel = heap_open(fkconstraint->old_pktable_oid, ShareRowExclusiveLock);
+ pkrel = table_open(fkconstraint->old_pktable_oid, ShareRowExclusiveLock);
else
- pkrel = heap_openrv(fkconstraint->pktable, ShareRowExclusiveLock);
+ pkrel = table_openrv(fkconstraint->pktable, ShareRowExclusiveLock);
/*
* Validity checks (permission checks wait till we have the column
@@ -7660,7 +7660,7 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
for (i = 0; i < partdesc->nparts; i++)
{
Oid partitionId = partdesc->oids[i];
- Relation partition = heap_open(partitionId, lockmode);
+ Relation partition = table_open(partitionId, lockmode);
AlteredTableInfo *childtab;
ObjectAddress childAddr;
@@ -7677,14 +7677,14 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
/* Record this constraint as dependent on the parent one */
recordDependencyOn(&childAddr, &address, DEPENDENCY_INTERNAL_AUTO);
- heap_close(partition, NoLock);
+ table_close(partition, NoLock);
}
}
/*
* Close pk table, but keep lock until we've committed.
*/
- heap_close(pkrel, NoLock);
+ table_close(pkrel, NoLock);
return address;
}
@@ -7716,7 +7716,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd,
cmdcon = castNode(Constraint, cmd->def);
- conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
+ conrel = table_open(ConstraintRelationId, RowExclusiveLock);
/*
* Find and check the target constraint
@@ -7780,7 +7780,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd,
* Now we need to update the multiple entries in pg_trigger that
* implement the constraint.
*/
- tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
+ tgrel = table_open(TriggerRelationId, RowExclusiveLock);
ScanKeyInit(&tgkey,
Anum_pg_trigger_tgconstraint,
@@ -7831,7 +7831,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd,
systable_endscan(tgscan);
- heap_close(tgrel, RowExclusiveLock);
+ table_close(tgrel, RowExclusiveLock);
/*
* Invalidate relcache so that others see the new attributes. We must
@@ -7852,7 +7852,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd,
systable_endscan(scan);
- heap_close(conrel, RowExclusiveLock);
+ table_close(conrel, RowExclusiveLock);
return address;
}
@@ -7879,7 +7879,7 @@ ATExecValidateConstraint(Relation rel, char *constrName, bool recurse,
Form_pg_constraint con;
ObjectAddress address;
- conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
+ conrel = table_open(ConstraintRelationId, RowExclusiveLock);
/*
* Find and check the target constraint
@@ -7931,12 +7931,12 @@ ATExecValidateConstraint(Relation rel, char *constrName, bool recurse,
* might need to fire triggers to perform the check, so we take a
* lock at RowShareLock level just in case.
*/
- refrel = heap_open(con->confrelid, RowShareLock);
+ refrel = table_open(con->confrelid, RowShareLock);
validateForeignKeyConstraint(constrName, rel, refrel,
con->conindid,
con->oid);
- heap_close(refrel, NoLock);
+ table_close(refrel, NoLock);
/*
* We disallow creating invalid foreign keys to or from
@@ -7984,11 +7984,11 @@ ATExecValidateConstraint(Relation rel, char *constrName, bool recurse,
errmsg("constraint must be validated on child tables too")));
/* find_all_inheritors already got lock */
- childrel = heap_open(childoid, NoLock);
+ childrel = table_open(childoid, NoLock);
ATExecValidateConstraint(childrel, constrName, false,
true, lockmode);
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
}
validateCheckConstraint(rel, tuple);
@@ -8019,7 +8019,7 @@ ATExecValidateConstraint(Relation rel, char *constrName, bool recurse,
systable_endscan(scan);
- heap_close(conrel, RowExclusiveLock);
+ table_close(conrel, RowExclusiveLock);
return address;
}
@@ -8776,7 +8776,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
if (recursing)
ATSimplePermissions(rel, ATT_TABLE | ATT_FOREIGN_TABLE);
- conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
+ conrel = table_open(ConstraintRelationId, RowExclusiveLock);
/*
* Find and drop the target constraint
@@ -8825,9 +8825,9 @@ ATExecDropConstraint(Relation rel, const char *constrName,
Relation frel;
/* Must match lock taken by RemoveTriggerById: */
- frel = heap_open(con->confrelid, AccessExclusiveLock);
+ frel = table_open(con->confrelid, AccessExclusiveLock);
CheckTableNotInUse(frel, "ALTER TABLE");
- heap_close(frel, NoLock);
+ table_close(frel, NoLock);
}
/*
@@ -8858,7 +8858,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
ereport(NOTICE,
(errmsg("constraint \"%s\" of relation \"%s\" does not exist, skipping",
constrName, RelationGetRelationName(rel))));
- heap_close(conrel, RowExclusiveLock);
+ table_close(conrel, RowExclusiveLock);
return;
}
}
@@ -8892,7 +8892,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
HeapTuple copy_tuple;
/* find_inheritance_children already got lock */
- childrel = heap_open(childrelid, NoLock);
+ childrel = table_open(childrelid, NoLock);
CheckTableNotInUse(childrel, "ALTER TABLE");
ScanKeyInit(&skey[0],
@@ -8973,10 +8973,10 @@ ATExecDropConstraint(Relation rel, const char *constrName,
heap_freetuple(copy_tuple);
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
}
- heap_close(conrel, RowExclusiveLock);
+ table_close(conrel, RowExclusiveLock);
}
/*
@@ -9293,14 +9293,14 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
{
Relation newrel;
- newrel = heap_open(RelationGetRelid(rel), NoLock);
+ newrel = table_open(RelationGetRelid(rel), NoLock);
RelationClearMissing(newrel);
relation_close(newrel, NoLock);
/* make sure we don't conflict with later attribute modifications */
CommandCounterIncrement();
}
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrelation = table_open(AttributeRelationId, RowExclusiveLock);
/* Look up the target column */
heapTup = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
@@ -9374,7 +9374,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
* that implements a constraint will not show a direct dependency on the
* column.
*/
- depRel = heap_open(DependRelationId, RowExclusiveLock);
+ depRel = table_open(DependRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
@@ -9611,7 +9611,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
systable_endscan(scan);
- heap_close(depRel, RowExclusiveLock);
+ table_close(depRel, RowExclusiveLock);
/*
* Here we go --- change the recorded column type and collation. (Note
@@ -9695,7 +9695,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
CatalogTupleUpdate(attrelation, &heapTup->t_self, heapTup);
- heap_close(attrelation, RowExclusiveLock);
+ table_close(attrelation, RowExclusiveLock);
/* Install dependencies on new datatype and collation */
add_column_datatype_dependency(RelationGetRelid(rel), attnum, targettype);
@@ -9769,7 +9769,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
return InvalidObjectAddress;
/* First, determine FDW validator associated to the foreign table. */
- ftrel = heap_open(ForeignTableRelationId, AccessShareLock);
+ ftrel = table_open(ForeignTableRelationId, AccessShareLock);
tuple = SearchSysCache1(FOREIGNTABLEREL, rel->rd_id);
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
@@ -9780,10 +9780,10 @@ ATExecAlterColumnGenericOptions(Relation rel,
server = GetForeignServer(fttableform->ftserver);
fdw = GetForeignDataWrapper(server->fdwid);
- heap_close(ftrel, AccessShareLock);
+ table_close(ftrel, AccessShareLock);
ReleaseSysCache(tuple);
- attrel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrel = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheAttName(RelationGetRelid(rel), colName);
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
@@ -9841,7 +9841,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
ReleaseSysCache(tuple);
- heap_close(attrel, RowExclusiveLock);
+ table_close(attrel, RowExclusiveLock);
heap_freetuple(newtuple);
@@ -10270,7 +10270,7 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
target_rel = relation_open(relationOid, lockmode);
/* Get its pg_class tuple, too */
- class_rel = heap_open(RelationRelationId, RowExclusiveLock);
+ class_rel = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relationOid));
if (!HeapTupleIsValid(tuple))
@@ -10484,7 +10484,7 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
InvokeObjectPostAlterHook(RelationRelationId, relationOid, 0);
ReleaseSysCache(tuple);
- heap_close(class_rel, RowExclusiveLock);
+ table_close(class_rel, RowExclusiveLock);
relation_close(target_rel, NoLock);
}
@@ -10502,7 +10502,7 @@ change_owner_fix_column_acls(Oid relationOid, Oid oldOwnerId, Oid newOwnerId)
ScanKeyData key[1];
HeapTuple attributeTuple;
- attRelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ attRelation = table_open(AttributeRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_attribute_attrelid,
BTEqualStrategyNumber, F_OIDEQ,
@@ -10549,7 +10549,7 @@ change_owner_fix_column_acls(Oid relationOid, Oid oldOwnerId, Oid newOwnerId)
heap_freetuple(newtuple);
}
systable_endscan(scan);
- heap_close(attRelation, RowExclusiveLock);
+ table_close(attRelation, RowExclusiveLock);
}
/*
@@ -10571,7 +10571,7 @@ change_owner_recurse_to_sequences(Oid relationOid, Oid newOwnerId, LOCKMODE lock
* SERIAL sequences are those having an auto dependency on one of the
* table's columns (we don't care *which* column, exactly).
*/
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
@@ -10718,7 +10718,7 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
if (defList == NIL && operation != AT_ReplaceRelOptions)
return; /* nothing to do */
- pgclass = heap_open(RelationRelationId, RowExclusiveLock);
+ pgclass = table_open(RelationRelationId, RowExclusiveLock);
/* Fetch heap tuple */
relid = RelationGetRelid(rel);
@@ -10836,7 +10836,7 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
Relation toastrel;
Oid toastid = rel->rd_rel->reltoastrelid;
- toastrel = heap_open(toastid, lockmode);
+ toastrel = table_open(toastid, lockmode);
/* Fetch heap tuple */
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(toastid));
@@ -10889,10 +10889,10 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
ReleaseSysCache(tuple);
- heap_close(toastrel, NoLock);
+ table_close(toastrel, NoLock);
}
- heap_close(pgclass, RowExclusiveLock);
+ table_close(pgclass, RowExclusiveLock);
}
/*
@@ -10970,7 +10970,7 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
}
/* Get a modifiable copy of the relation's pg_class row */
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(tableOid));
if (!HeapTupleIsValid(tuple))
@@ -11046,7 +11046,7 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
heap_freetuple(tuple);
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
relation_close(rel, NoLock);
@@ -11103,7 +11103,7 @@ ATExecSetTableSpaceNoStorage(Relation rel, Oid newTableSpace)
}
/* Get a modifiable copy of the relation's pg_class row */
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(reloid));
if (!HeapTupleIsValid(tuple))
@@ -11118,7 +11118,7 @@ ATExecSetTableSpaceNoStorage(Relation rel, Oid newTableSpace)
heap_freetuple(tuple);
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
/* Make sure the reltablespace change is visible */
CommandCounterIncrement();
@@ -11207,7 +11207,7 @@ AlterTableMoveAll(AlterTableMoveAllStmt *stmt)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(orig_tablespaceoid));
- rel = heap_open(RelationRelationId, AccessShareLock);
+ rel = table_open(RelationRelationId, AccessShareLock);
scan = heap_beginscan_catalog(rel, 1, key);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
@@ -11268,7 +11268,7 @@ AlterTableMoveAll(AlterTableMoveAllStmt *stmt)
}
heap_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
if (relations == NIL)
ereport(NOTICE,
@@ -11448,7 +11448,7 @@ ATExecAddInherit(Relation child_rel, RangeVar *parent, LOCKMODE lockmode)
* A self-exclusive lock is needed here. See the similar case in
* MergeAttributes() for a full explanation.
*/
- parent_rel = heap_openrv(parent, ShareUpdateExclusiveLock);
+ parent_rel = table_openrv(parent, ShareUpdateExclusiveLock);
/*
* Must be owner of both parent and child -- child was checked by
@@ -11536,7 +11536,7 @@ ATExecAddInherit(Relation child_rel, RangeVar *parent, LOCKMODE lockmode)
RelationGetRelid(parent_rel));
/* keep our lock on the parent relation until commit */
- heap_close(parent_rel, NoLock);
+ table_close(parent_rel, NoLock);
return address;
}
@@ -11558,7 +11558,7 @@ CreateInheritance(Relation child_rel, Relation parent_rel)
int32 inhseqno;
/* Note: get RowExclusiveLock because we will write pg_inherits below. */
- catalogRelation = heap_open(InheritsRelationId, RowExclusiveLock);
+ catalogRelation = table_open(InheritsRelationId, RowExclusiveLock);
/*
* Check for duplicates in the list of parents, and determine the highest
@@ -11610,7 +11610,7 @@ CreateInheritance(Relation child_rel, Relation parent_rel)
RELKIND_PARTITIONED_TABLE);
/* Now we're done with pg_inherits */
- heap_close(catalogRelation, RowExclusiveLock);
+ table_close(catalogRelation, RowExclusiveLock);
}
/*
@@ -11681,7 +11681,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
HeapTuple tuple;
bool child_is_partition = false;
- attrrel = heap_open(AttributeRelationId, RowExclusiveLock);
+ attrrel = table_open(AttributeRelationId, RowExclusiveLock);
tupleDesc = RelationGetDescr(parent_rel);
parent_natts = tupleDesc->natts;
@@ -11762,7 +11762,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
}
}
- heap_close(attrrel, RowExclusiveLock);
+ table_close(attrrel, RowExclusiveLock);
}
/*
@@ -11792,7 +11792,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
HeapTuple parent_tuple;
bool child_is_partition = false;
- catalog_relation = heap_open(ConstraintRelationId, RowExclusiveLock);
+ catalog_relation = table_open(ConstraintRelationId, RowExclusiveLock);
tuple_desc = RelationGetDescr(catalog_relation);
/* If parent_rel is a partitioned table, child_rel must be a partition */
@@ -11904,7 +11904,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
}
systable_endscan(parent_scan);
- heap_close(catalog_relation, RowExclusiveLock);
+ table_close(catalog_relation, RowExclusiveLock);
}
/*
@@ -11928,7 +11928,7 @@ ATExecDropInherit(Relation rel, RangeVar *parent, LOCKMODE lockmode)
* TABLE doesn't lock parent tables at all. We need some lock since we'll
* be inspecting the parent's schema.
*/
- parent_rel = heap_openrv(parent, AccessShareLock);
+ parent_rel = table_openrv(parent, AccessShareLock);
/*
* We don't bother to check ownership of the parent table --- ownership of
@@ -11942,7 +11942,7 @@ ATExecDropInherit(Relation rel, RangeVar *parent, LOCKMODE lockmode)
RelationGetRelid(parent_rel));
/* keep our lock on the parent relation until commit */
- heap_close(parent_rel, NoLock);
+ table_close(parent_rel, NoLock);
return address;
}
@@ -12002,7 +12002,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel)
/*
* Search through child columns looking for ones matching parent rel
*/
- catalogRelation = heap_open(AttributeRelationId, RowExclusiveLock);
+ catalogRelation = table_open(AttributeRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_attribute_attrelid,
BTEqualStrategyNumber, F_OIDEQ,
@@ -12035,7 +12035,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel)
}
}
systable_endscan(scan);
- heap_close(catalogRelation, RowExclusiveLock);
+ table_close(catalogRelation, RowExclusiveLock);
/*
* Likewise, find inherited check constraints and disinherit them. To do
@@ -12043,7 +12043,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel)
* constraints. (We cheat a bit by only checking for name matches,
* assuming that the expressions will match.)
*/
- catalogRelation = heap_open(ConstraintRelationId, RowExclusiveLock);
+ catalogRelation = table_open(ConstraintRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_constraint_conrelid,
BTEqualStrategyNumber, F_OIDEQ,
@@ -12110,7 +12110,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel)
}
systable_endscan(scan);
- heap_close(catalogRelation, RowExclusiveLock);
+ table_close(catalogRelation, RowExclusiveLock);
drop_parent_dependency(RelationGetRelid(child_rel),
RelationRelationId,
@@ -12143,7 +12143,7 @@ drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid,
ScanKeyData key[3];
HeapTuple depTuple;
- catalogRelation = heap_open(DependRelationId, RowExclusiveLock);
+ catalogRelation = table_open(DependRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
Anum_pg_depend_classid,
@@ -12173,7 +12173,7 @@ drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid,
}
systable_endscan(scan);
- heap_close(catalogRelation, RowExclusiveLock);
+ table_close(catalogRelation, RowExclusiveLock);
}
/*
@@ -12212,7 +12212,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
typeid = typeform->oid;
/* Fail if the table has any inheritance parents. */
- inheritsRelation = heap_open(InheritsRelationId, AccessShareLock);
+ inheritsRelation = table_open(InheritsRelationId, AccessShareLock);
ScanKeyInit(&key,
Anum_pg_inherits_inhrelid,
BTEqualStrategyNumber, F_OIDEQ,
@@ -12224,7 +12224,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("typed tables cannot inherit")));
systable_endscan(scan);
- heap_close(inheritsRelation, AccessShareLock);
+ table_close(inheritsRelation, AccessShareLock);
/*
* Check the tuple descriptors for compatibility. Unlike inheritance, we
@@ -12305,7 +12305,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
recordDependencyOn(&tableobj, &typeobj, DEPENDENCY_NORMAL);
/* Update pg_class.reloftype */
- relationRelation = heap_open(RelationRelationId, RowExclusiveLock);
+ relationRelation = table_open(RelationRelationId, RowExclusiveLock);
classtuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(classtuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
@@ -12315,7 +12315,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
InvokeObjectPostAlterHook(RelationRelationId, relid, 0);
heap_freetuple(classtuple);
- heap_close(relationRelation, RowExclusiveLock);
+ table_close(relationRelation, RowExclusiveLock);
ReleaseSysCache(typetuple);
@@ -12350,7 +12350,7 @@ ATExecDropOf(Relation rel, LOCKMODE lockmode)
DEPENDENCY_NORMAL);
/* Clear pg_class.reloftype */
- relationRelation = heap_open(RelationRelationId, RowExclusiveLock);
+ relationRelation = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
@@ -12360,7 +12360,7 @@ ATExecDropOf(Relation rel, LOCKMODE lockmode)
InvokeObjectPostAlterHook(RelationRelationId, relid, 0);
heap_freetuple(tuple);
- heap_close(relationRelation, RowExclusiveLock);
+ table_close(relationRelation, RowExclusiveLock);
}
/*
@@ -12385,7 +12385,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
/*
* Check whether relreplident has changed, and update it if so.
*/
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
pg_class_tuple = SearchSysCacheCopy1(RELOID,
ObjectIdGetDatum(RelationGetRelid(rel)));
if (!HeapTupleIsValid(pg_class_tuple))
@@ -12397,7 +12397,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
pg_class_form->relreplident = ri_type;
CatalogTupleUpdate(pg_class, &pg_class_tuple->t_self, pg_class_tuple);
}
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
heap_freetuple(pg_class_tuple);
/*
@@ -12425,7 +12425,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
* Clear the indisreplident flag from any index that had it previously,
* and set it for any index that should have it now.
*/
- pg_index = heap_open(IndexRelationId, RowExclusiveLock);
+ pg_index = table_open(IndexRelationId, RowExclusiveLock);
foreach(index, RelationGetIndexList(rel))
{
Oid thisIndexOid = lfirst_oid(index);
@@ -12461,7 +12461,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
heap_freetuple(pg_index_tuple);
}
- heap_close(pg_index, RowExclusiveLock);
+ table_close(pg_index, RowExclusiveLock);
}
/*
@@ -12591,7 +12591,7 @@ ATExecEnableRowSecurity(Relation rel)
relid = RelationGetRelid(rel);
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
@@ -12601,7 +12601,7 @@ ATExecEnableRowSecurity(Relation rel)
((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = true;
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
heap_freetuple(tuple);
}
@@ -12615,7 +12615,7 @@ ATExecDisableRowSecurity(Relation rel)
relid = RelationGetRelid(rel);
/* Pull the record for this relation and update it */
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
@@ -12625,7 +12625,7 @@ ATExecDisableRowSecurity(Relation rel)
((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = false;
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
heap_freetuple(tuple);
}
@@ -12641,7 +12641,7 @@ ATExecForceNoForceRowSecurity(Relation rel, bool force_rls)
relid = RelationGetRelid(rel);
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
@@ -12651,7 +12651,7 @@ ATExecForceNoForceRowSecurity(Relation rel, bool force_rls)
((Form_pg_class) GETSTRUCT(tuple))->relforcerowsecurity = force_rls;
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
heap_freetuple(tuple);
}
@@ -12675,7 +12675,7 @@ ATExecGenericOptions(Relation rel, List *options)
if (options == NIL)
return;
- ftrel = heap_open(ForeignTableRelationId, RowExclusiveLock);
+ ftrel = table_open(ForeignTableRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(FOREIGNTABLEREL, rel->rd_id);
if (!HeapTupleIsValid(tuple))
@@ -12728,7 +12728,7 @@ ATExecGenericOptions(Relation rel, List *options)
InvokeObjectPostAlterHook(ForeignTableRelationId,
RelationGetRelid(rel), 0);
- heap_close(ftrel, RowExclusiveLock);
+ table_close(ftrel, RowExclusiveLock);
heap_freetuple(tuple);
}
@@ -12794,7 +12794,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
* permanent tables cannot reference unlogged ones. Self-referencing
* foreign keys can safely be ignored.
*/
- pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
+ pg_constraint = table_open(ConstraintRelationId, AccessShareLock);
/*
* Scan conrelid if changing to permanent, else confrelid. This also
@@ -12854,7 +12854,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
systable_endscan(scan);
- heap_close(pg_constraint, AccessShareLock);
+ table_close(pg_constraint, AccessShareLock);
return true;
}
@@ -12942,7 +12942,7 @@ AlterTableNamespaceInternal(Relation rel, Oid oldNspOid, Oid nspOid,
Assert(objsMoved != NULL);
/* OK, modify the pg_class row and pg_depend entry */
- classRel = heap_open(RelationRelationId, RowExclusiveLock);
+ classRel = table_open(RelationRelationId, RowExclusiveLock);
AlterRelationNamespaceInternal(classRel, RelationGetRelid(rel), oldNspOid,
nspOid, true, objsMoved);
@@ -12963,7 +12963,7 @@ AlterTableNamespaceInternal(Relation rel, Oid oldNspOid, Oid nspOid,
false, objsMoved);
}
- heap_close(classRel, RowExclusiveLock);
+ table_close(classRel, RowExclusiveLock);
}
/*
@@ -13100,7 +13100,7 @@ AlterSeqNamespaces(Relation classRel, Relation rel,
* SERIAL sequences are those having an auto dependency on one of the
* table's columns (we don't care *which* column, exactly).
*/
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
@@ -14055,7 +14055,7 @@ QueuePartitionConstraintValidation(List **wqueue, Relation scanrel,
/*
* This is the minimum lock we need to prevent deadlocks.
*/
- part_rel = heap_open(partdesc->oids[i], AccessExclusiveLock);
+ part_rel = table_open(partdesc->oids[i], AccessExclusiveLock);
/*
* Adjust the constraint for scanrel so that it matches this
@@ -14071,7 +14071,7 @@ QueuePartitionConstraintValidation(List **wqueue, Relation scanrel,
QueuePartitionConstraintValidation(wqueue, part_rel,
thisPartConstraint,
validate_default);
- heap_close(part_rel, NoLock); /* keep lock till commit */
+ table_close(part_rel, NoLock); /* keep lock till commit */
}
}
}
@@ -14110,7 +14110,7 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
if (OidIsValid(defaultPartOid))
LockRelationOid(defaultPartOid, AccessExclusiveLock);
- attachrel = heap_openrv(cmd->name, AccessExclusiveLock);
+ attachrel = table_openrv(cmd->name, AccessExclusiveLock);
/*
* XXX I think it'd be a good idea to grab locks on all tables referenced
@@ -14139,7 +14139,7 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
* Table being attached should not already be part of inheritance; either
* as a child table...
*/
- catalog = heap_open(InheritsRelationId, AccessShareLock);
+ catalog = table_open(InheritsRelationId, AccessShareLock);
ScanKeyInit(&skey,
Anum_pg_inherits_inhrelid,
BTEqualStrategyNumber, F_OIDEQ,
@@ -14165,7 +14165,7 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot attach inheritance parent as partition")));
systable_endscan(scan);
- heap_close(catalog, AccessShareLock);
+ table_close(catalog, AccessShareLock);
/*
* Prevent circularity by seeing if rel is a partition of attachrel. (In
@@ -14363,20 +14363,20 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
Assert(!cmd->bound->is_default);
/* we already hold a lock on the default partition */
- defaultrel = heap_open(defaultPartOid, NoLock);
+ defaultrel = table_open(defaultPartOid, NoLock);
defPartConstraint =
get_proposed_default_constraint(partBoundConstraint);
QueuePartitionConstraintValidation(wqueue, defaultrel,
defPartConstraint, true);
/* keep our lock until commit. */
- heap_close(defaultrel, NoLock);
+ table_close(defaultrel, NoLock);
}
ObjectAddressSet(address, RelationRelationId, RelationGetRelid(attachrel));
/* keep our lock until commit */
- heap_close(attachrel, NoLock);
+ table_close(attachrel, NoLock);
return address;
}
@@ -14546,7 +14546,7 @@ CloneRowTriggersToPartition(Relation parent, Relation partition)
ScanKeyInit(&key, Anum_pg_trigger_tgrelid, BTEqualStrategyNumber,
F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(parent)));
- pg_trigger = heap_open(TriggerRelationId, RowExclusiveLock);
+ pg_trigger = table_open(TriggerRelationId, RowExclusiveLock);
scan = systable_beginscan(pg_trigger, TriggerRelidNameIndexId,
true, NULL, 1, &key);
@@ -14652,7 +14652,7 @@ CloneRowTriggersToPartition(Relation parent, Relation partition)
MemoryContextDelete(perTupCxt);
systable_endscan(scan);
- heap_close(pg_trigger, RowExclusiveLock);
+ table_close(pg_trigger, RowExclusiveLock);
}
/*
@@ -14685,13 +14685,13 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
if (OidIsValid(defaultPartOid))
LockRelationOid(defaultPartOid, AccessExclusiveLock);
- partRel = heap_openrv(name, ShareUpdateExclusiveLock);
+ partRel = table_openrv(name, ShareUpdateExclusiveLock);
/* All inheritance related checks are performed within the function */
RemoveInheritance(partRel, rel);
/* Update pg_class tuple */
- classRel = heap_open(RelationRelationId, RowExclusiveLock);
+ classRel = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID,
ObjectIdGetDatum(RelationGetRelid(partRel)));
if (!HeapTupleIsValid(tuple))
@@ -14747,7 +14747,7 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
update_relispartition(classRel, idxid, false);
index_close(idx, NoLock);
}
- heap_close(classRel, RowExclusiveLock);
+ table_close(classRel, RowExclusiveLock);
/* Detach foreign keys */
fks = copyObject(RelationGetFKeyList(partRel));
@@ -14775,7 +14775,7 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
ObjectAddressSet(address, RelationRelationId, RelationGetRelid(partRel));
/* keep our lock until commit */
- heap_close(partRel, NoLock);
+ table_close(partRel, NoLock);
return address;
}
@@ -15008,7 +15008,7 @@ refuseDupeIndexAttach(Relation parentIdx, Relation partIdx, Relation partitionTb
HeapTuple tuple;
SysScanDesc scan;
- pg_inherits = heap_open(InheritsRelationId, AccessShareLock);
+ pg_inherits = table_open(InheritsRelationId, AccessShareLock);
ScanKeyInit(&key, Anum_pg_inherits_inhparent,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(parentIdx)));
@@ -15032,7 +15032,7 @@ refuseDupeIndexAttach(Relation parentIdx, Relation partIdx, Relation partitionTb
}
systable_endscan(scan);
- heap_close(pg_inherits, AccessShareLock);
+ table_close(pg_inherits, AccessShareLock);
}
/*
@@ -15058,7 +15058,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
* (verifying the pg_index entry for each), and if we reach the total
* amount we expect, we can mark this parent index as valid.
*/
- inheritsRel = heap_open(InheritsRelationId, AccessShareLock);
+ inheritsRel = table_open(InheritsRelationId, AccessShareLock);
ScanKeyInit(&key, Anum_pg_inherits_inhparent,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(partedIdx)));
@@ -15083,7 +15083,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
/* Done with pg_inherits */
systable_endscan(scan);
- heap_close(inheritsRel, AccessShareLock);
+ table_close(inheritsRel, AccessShareLock);
/*
* If we found as many inherited indexes as the partitioned table has
@@ -15094,7 +15094,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
Relation idxRel;
HeapTuple newtup;
- idxRel = heap_open(IndexRelationId, RowExclusiveLock);
+ idxRel = table_open(IndexRelationId, RowExclusiveLock);
newtup = heap_copytuple(partedIdx->rd_indextuple);
((Form_pg_index) GETSTRUCT(newtup))->indisvalid = true;
@@ -15102,7 +15102,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
CatalogTupleUpdate(idxRel, &partedIdx->rd_indextuple->t_self, newtup);
- heap_close(idxRel, RowExclusiveLock);
+ table_close(idxRel, RowExclusiveLock);
}
/*
@@ -15148,7 +15148,7 @@ update_relispartition(Relation classRel, Oid relationId, bool newval)
if (classRel == NULL)
{
- classRel = heap_open(RelationRelationId, RowExclusiveLock);
+ classRel = table_open(RelationRelationId, RowExclusiveLock);
opened = true;
}
@@ -15161,5 +15161,5 @@ update_relispartition(Relation classRel, Oid relationId, bool newval)
ReleaseSysCache(tup);
if (opened)
- heap_close(classRel, RowExclusiveLock);
+ table_close(classRel, RowExclusiveLock);
}
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index 946e1b99767..f5ad9f7becc 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -323,7 +323,7 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
* lock the proposed tablename against other would-be creators. The
* insertion will roll back if we find problems below.
*/
- rel = heap_open(TableSpaceRelationId, RowExclusiveLock);
+ rel = table_open(TableSpaceRelationId, RowExclusiveLock);
MemSet(nulls, false, sizeof(nulls));
@@ -385,7 +385,7 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
pfree(location);
/* We keep the lock on pg_tablespace until commit */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return tablespaceoid;
#else /* !HAVE_SYMLINK */
@@ -416,7 +416,7 @@ DropTableSpace(DropTableSpaceStmt *stmt)
/*
* Find the target tuple
*/
- rel = heap_open(TableSpaceRelationId, RowExclusiveLock);
+ rel = table_open(TableSpaceRelationId, RowExclusiveLock);
ScanKeyInit(&entry[0],
Anum_pg_tablespace_spcname,
@@ -441,7 +441,7 @@ DropTableSpace(DropTableSpaceStmt *stmt)
tablespacename)));
/* XXX I assume I need one or both of these next two calls */
heap_endscan(scandesc);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
return;
}
@@ -551,7 +551,7 @@ DropTableSpace(DropTableSpaceStmt *stmt)
LWLockRelease(TablespaceCreateLock);
/* We keep the lock on pg_tablespace until commit */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
#else /* !HAVE_SYMLINK */
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -926,7 +926,7 @@ RenameTableSpace(const char *oldname, const char *newname)
ObjectAddress address;
/* Search pg_tablespace */
- rel = heap_open(TableSpaceRelationId, RowExclusiveLock);
+ rel = table_open(TableSpaceRelationId, RowExclusiveLock);
ScanKeyInit(&entry[0],
Anum_pg_tablespace_spcname,
@@ -981,7 +981,7 @@ RenameTableSpace(const char *oldname, const char *newname)
ObjectAddressSet(address, TableSpaceRelationId, tspId);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return address;
}
@@ -1006,7 +1006,7 @@ AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt)
HeapTuple newtuple;
/* Search pg_tablespace */
- rel = heap_open(TableSpaceRelationId, RowExclusiveLock);
+ rel = table_open(TableSpaceRelationId, RowExclusiveLock);
ScanKeyInit(&entry[0],
Anum_pg_tablespace_spcname,
@@ -1055,7 +1055,7 @@ AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt)
/* Conclude heap scan. */
heap_endscan(scandesc);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return tablespaceoid;
}
@@ -1397,7 +1397,7 @@ get_tablespace_oid(const char *tablespacename, bool missing_ok)
* index on name, on the theory that pg_tablespace will usually have just
* a few entries and so an indexed lookup is a waste of effort.
*/
- rel = heap_open(TableSpaceRelationId, AccessShareLock);
+ rel = table_open(TableSpaceRelationId, AccessShareLock);
ScanKeyInit(&entry[0],
Anum_pg_tablespace_spcname,
@@ -1413,7 +1413,7 @@ get_tablespace_oid(const char *tablespacename, bool missing_ok)
result = InvalidOid;
heap_endscan(scandesc);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
if (!OidIsValid(result) && !missing_ok)
ereport(ERROR,
@@ -1443,7 +1443,7 @@ get_tablespace_name(Oid spc_oid)
* index on oid, on the theory that pg_tablespace will usually have just a
* few entries and so an indexed lookup is a waste of effort.
*/
- rel = heap_open(TableSpaceRelationId, AccessShareLock);
+ rel = table_open(TableSpaceRelationId, AccessShareLock);
ScanKeyInit(&entry[0],
Anum_pg_tablespace_oid,
@@ -1459,7 +1459,7 @@ get_tablespace_name(Oid spc_oid)
result = NULL;
heap_endscan(scandesc);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
return result;
}
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 2daffae8cd6..48054572209 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -189,9 +189,9 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
bool partition_recurse;
if (OidIsValid(relOid))
- rel = heap_open(relOid, ShareRowExclusiveLock);
+ rel = table_open(relOid, ShareRowExclusiveLock);
else
- rel = heap_openrv(stmt->relation, ShareRowExclusiveLock);
+ rel = table_openrv(stmt->relation, ShareRowExclusiveLock);
/*
* Triggers must be on tables or views, and there are additional
@@ -712,7 +712,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
RI_FKey_trigger_type(funcoid) != RI_TRIGGER_NONE)
{
/* Keep lock on target rel until end of xact */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
ConvertTriggerToFK(stmt, funcoid);
@@ -762,7 +762,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
* Generate the trigger's OID now, so that we can use it in the name if
* needed.
*/
- tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
+ tgrel = table_open(TriggerRelationId, RowExclusiveLock);
trigoid = GetNewOidWithIndex(tgrel, TriggerOidIndexId,
Anum_pg_trigger_oid);
@@ -948,7 +948,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
CatalogTupleInsert(tgrel, tuple);
heap_freetuple(tuple);
- heap_close(tgrel, RowExclusiveLock);
+ table_close(tgrel, RowExclusiveLock);
pfree(DatumGetPointer(values[Anum_pg_trigger_tgname - 1]));
pfree(DatumGetPointer(values[Anum_pg_trigger_tgargs - 1]));
@@ -962,7 +962,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
* Update relation's pg_class entry; if necessary; and if not, send an SI
* message to make other backends (and this one) rebuild relcache entries.
*/
- pgrel = heap_open(RelationRelationId, RowExclusiveLock);
+ pgrel = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID,
ObjectIdGetDatum(RelationGetRelid(rel)));
if (!HeapTupleIsValid(tuple))
@@ -980,7 +980,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
CacheInvalidateRelcacheByTuple(tuple);
heap_freetuple(tuple);
- heap_close(pgrel, RowExclusiveLock);
+ table_close(pgrel, RowExclusiveLock);
/*
* Record dependencies for trigger. Always place a normal dependency on
@@ -1128,7 +1128,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
Node *qual;
bool found_whole_row;
- childTbl = heap_open(partdesc->oids[i], ShareRowExclusiveLock);
+ childTbl = table_open(partdesc->oids[i], ShareRowExclusiveLock);
/* Find which of the child indexes is the one on this partition */
if (OidIsValid(indexOid))
@@ -1177,7 +1177,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
funcoid, trigoid, qual,
isInternal, true);
- heap_close(childTbl, NoLock);
+ table_close(childTbl, NoLock);
MemoryContextReset(perChildCxt);
}
@@ -1189,7 +1189,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
}
/* Keep lock on target rel until end of xact */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return myself;
}
@@ -1487,7 +1487,7 @@ RemoveTriggerById(Oid trigOid)
Oid relid;
Relation rel;
- tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
+ tgrel = table_open(TriggerRelationId, RowExclusiveLock);
/*
* Find the trigger to delete.
@@ -1509,7 +1509,7 @@ RemoveTriggerById(Oid trigOid)
*/
relid = ((Form_pg_trigger) GETSTRUCT(tup))->tgrelid;
- rel = heap_open(relid, AccessExclusiveLock);
+ rel = table_open(relid, AccessExclusiveLock);
if (rel->rd_rel->relkind != RELKIND_RELATION &&
rel->rd_rel->relkind != RELKIND_VIEW &&
@@ -1532,7 +1532,7 @@ RemoveTriggerById(Oid trigOid)
CatalogTupleDelete(tgrel, &tup->t_self);
systable_endscan(tgscan);
- heap_close(tgrel, RowExclusiveLock);
+ table_close(tgrel, RowExclusiveLock);
/*
* We do not bother to try to determine whether any other triggers remain,
@@ -1546,7 +1546,7 @@ RemoveTriggerById(Oid trigOid)
CacheInvalidateRelcache(rel);
/* Keep lock on trigger's rel until end of xact */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
/*
@@ -1567,7 +1567,7 @@ get_trigger_oid(Oid relid, const char *trigname, bool missing_ok)
/*
* Find the trigger, verify permissions, set up object address
*/
- tgrel = heap_open(TriggerRelationId, AccessShareLock);
+ tgrel = table_open(TriggerRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_trigger_tgrelid,
@@ -1598,7 +1598,7 @@ get_trigger_oid(Oid relid, const char *trigname, bool missing_ok)
}
systable_endscan(tgscan);
- heap_close(tgrel, AccessShareLock);
+ table_close(tgrel, AccessShareLock);
return oid;
}
@@ -1684,7 +1684,7 @@ renametrig(RenameStmt *stmt)
* NOTE that this is cool only because we have AccessExclusiveLock on the
* relation, so the trigger set won't be changing underneath us.
*/
- tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
+ tgrel = table_open(TriggerRelationId, RowExclusiveLock);
/*
* First pass -- look for name conflict
@@ -1757,7 +1757,7 @@ renametrig(RenameStmt *stmt)
systable_endscan(tgscan);
- heap_close(tgrel, RowExclusiveLock);
+ table_close(tgrel, RowExclusiveLock);
/*
* Close rel, but keep exclusive lock!
@@ -1798,7 +1798,7 @@ EnableDisableTrigger(Relation rel, const char *tgname,
bool changed;
/* Scan the relevant entries in pg_triggers */
- tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
+ tgrel = table_open(TriggerRelationId, RowExclusiveLock);
ScanKeyInit(&keys[0],
Anum_pg_trigger_tgrelid,
@@ -1867,7 +1867,7 @@ EnableDisableTrigger(Relation rel, const char *tgname,
part = relation_open(partdesc->oids[i], lockmode);
EnableDisableTrigger(part, NameStr(oldtrig->tgname),
fires_when, skip_system, lockmode);
- heap_close(part, NoLock); /* keep lock till commit */
+ table_close(part, NoLock); /* keep lock till commit */
}
}
@@ -1880,7 +1880,7 @@ EnableDisableTrigger(Relation rel, const char *tgname,
systable_endscan(tgscan);
- heap_close(tgrel, RowExclusiveLock);
+ table_close(tgrel, RowExclusiveLock);
if (tgname && !found)
ereport(ERROR,
@@ -1941,7 +1941,7 @@ RelationBuildTriggers(Relation relation)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
- tgrel = heap_open(TriggerRelationId, AccessShareLock);
+ tgrel = table_open(TriggerRelationId, AccessShareLock);
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true,
NULL, 1, &skey);
@@ -2031,7 +2031,7 @@ RelationBuildTriggers(Relation relation)
}
systable_endscan(tgscan);
- heap_close(tgrel, AccessShareLock);
+ table_close(tgrel, AccessShareLock);
/* There might not be any triggers */
if (numtrigs == 0)
@@ -5403,7 +5403,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
* A constraint in a partitioned table may have corresponding
* constraints in the partitions. Grab those too.
*/
- conrel = heap_open(ConstraintRelationId, AccessShareLock);
+ conrel = table_open(ConstraintRelationId, AccessShareLock);
foreach(lc, stmt->constraints)
{
@@ -5525,13 +5525,13 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
systable_endscan(scan);
}
- heap_close(conrel, AccessShareLock);
+ table_close(conrel, AccessShareLock);
/*
* Now, locate the trigger(s) implementing each of these constraints,
* and make a list of their OIDs.
*/
- tgrel = heap_open(TriggerRelationId, AccessShareLock);
+ tgrel = table_open(TriggerRelationId, AccessShareLock);
foreach(lc, conoidlist)
{
@@ -5575,7 +5575,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
conoid);
}
- heap_close(tgrel, AccessShareLock);
+ table_close(tgrel, AccessShareLock);
/*
* Now we can set the trigger states of individual triggers for this
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index 3f727f2744c..d812413864f 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -192,7 +192,7 @@ DefineTSParser(List *names, List *parameters)
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to create text search parsers")));
- prsRel = heap_open(TSParserRelationId, RowExclusiveLock);
+ prsRel = table_open(TSParserRelationId, RowExclusiveLock);
/* Convert list of names to a name and namespace */
namespaceoid = QualifiedNameGetCreationNamespace(names, &prsname);
@@ -284,7 +284,7 @@ DefineTSParser(List *names, List *parameters)
heap_freetuple(tup);
- heap_close(prsRel, RowExclusiveLock);
+ table_close(prsRel, RowExclusiveLock);
return address;
}
@@ -298,7 +298,7 @@ RemoveTSParserById(Oid prsId)
Relation relation;
HeapTuple tup;
- relation = heap_open(TSParserRelationId, RowExclusiveLock);
+ relation = table_open(TSParserRelationId, RowExclusiveLock);
tup = SearchSysCache1(TSPARSEROID, ObjectIdGetDatum(prsId));
@@ -309,7 +309,7 @@ RemoveTSParserById(Oid prsId)
ReleaseSysCache(tup);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
/* ---------------------- TS Dictionary commands -----------------------*/
@@ -464,7 +464,7 @@ DefineTSDictionary(List *names, List *parameters)
verify_dictoptions(templId, dictoptions);
- dictRel = heap_open(TSDictionaryRelationId, RowExclusiveLock);
+ dictRel = table_open(TSDictionaryRelationId, RowExclusiveLock);
/*
* Looks good, insert
@@ -497,7 +497,7 @@ DefineTSDictionary(List *names, List *parameters)
heap_freetuple(tup);
- heap_close(dictRel, RowExclusiveLock);
+ table_close(dictRel, RowExclusiveLock);
return address;
}
@@ -511,7 +511,7 @@ RemoveTSDictionaryById(Oid dictId)
Relation relation;
HeapTuple tup;
- relation = heap_open(TSDictionaryRelationId, RowExclusiveLock);
+ relation = table_open(TSDictionaryRelationId, RowExclusiveLock);
tup = SearchSysCache1(TSDICTOID, ObjectIdGetDatum(dictId));
@@ -523,7 +523,7 @@ RemoveTSDictionaryById(Oid dictId)
ReleaseSysCache(tup);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
/*
@@ -547,7 +547,7 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
dictId = get_ts_dict_oid(stmt->dictname, false);
- rel = heap_open(TSDictionaryRelationId, RowExclusiveLock);
+ rel = table_open(TSDictionaryRelationId, RowExclusiveLock);
tup = SearchSysCache1(TSDICTOID, ObjectIdGetDatum(dictId));
@@ -639,7 +639,7 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
heap_freetuple(newtup);
ReleaseSysCache(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return address;
}
@@ -756,7 +756,7 @@ DefineTSTemplate(List *names, List *parameters)
/* Convert list of names to a name and namespace */
namespaceoid = QualifiedNameGetCreationNamespace(names, &tmplname);
- tmplRel = heap_open(TSTemplateRelationId, RowExclusiveLock);
+ tmplRel = table_open(TSTemplateRelationId, RowExclusiveLock);
for (i = 0; i < Natts_pg_ts_template; i++)
{
@@ -819,7 +819,7 @@ DefineTSTemplate(List *names, List *parameters)
heap_freetuple(tup);
- heap_close(tmplRel, RowExclusiveLock);
+ table_close(tmplRel, RowExclusiveLock);
return address;
}
@@ -833,7 +833,7 @@ RemoveTSTemplateById(Oid tmplId)
Relation relation;
HeapTuple tup;
- relation = heap_open(TSTemplateRelationId, RowExclusiveLock);
+ relation = table_open(TSTemplateRelationId, RowExclusiveLock);
tup = SearchSysCache1(TSTEMPLATEOID, ObjectIdGetDatum(tmplId));
@@ -845,7 +845,7 @@ RemoveTSTemplateById(Oid tmplId)
ReleaseSysCache(tup);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
/* ---------------------- TS Configuration commands -----------------------*/
@@ -1052,7 +1052,7 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied)
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("text search parser is required")));
- cfgRel = heap_open(TSConfigRelationId, RowExclusiveLock);
+ cfgRel = table_open(TSConfigRelationId, RowExclusiveLock);
/*
* Looks good, build tuple and insert
@@ -1082,7 +1082,7 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied)
SysScanDesc scan;
HeapTuple maptup;
- mapRel = heap_open(TSConfigMapRelationId, RowExclusiveLock);
+ mapRel = table_open(TSConfigMapRelationId, RowExclusiveLock);
ScanKeyInit(&skey,
Anum_pg_ts_config_map_mapcfg,
@@ -1125,8 +1125,8 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied)
heap_freetuple(tup);
if (mapRel)
- heap_close(mapRel, RowExclusiveLock);
- heap_close(cfgRel, RowExclusiveLock);
+ table_close(mapRel, RowExclusiveLock);
+ table_close(cfgRel, RowExclusiveLock);
return address;
}
@@ -1144,7 +1144,7 @@ RemoveTSConfigurationById(Oid cfgId)
SysScanDesc scan;
/* Remove the pg_ts_config entry */
- relCfg = heap_open(TSConfigRelationId, RowExclusiveLock);
+ relCfg = table_open(TSConfigRelationId, RowExclusiveLock);
tup = SearchSysCache1(TSCONFIGOID, ObjectIdGetDatum(cfgId));
@@ -1156,10 +1156,10 @@ RemoveTSConfigurationById(Oid cfgId)
ReleaseSysCache(tup);
- heap_close(relCfg, RowExclusiveLock);
+ table_close(relCfg, RowExclusiveLock);
/* Remove any pg_ts_config_map entries */
- relMap = heap_open(TSConfigMapRelationId, RowExclusiveLock);
+ relMap = table_open(TSConfigMapRelationId, RowExclusiveLock);
ScanKeyInit(&skey,
Anum_pg_ts_config_map_mapcfg,
@@ -1176,7 +1176,7 @@ RemoveTSConfigurationById(Oid cfgId)
systable_endscan(scan);
- heap_close(relMap, RowExclusiveLock);
+ table_close(relMap, RowExclusiveLock);
}
/*
@@ -1205,7 +1205,7 @@ AlterTSConfiguration(AlterTSConfigurationStmt *stmt)
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TSCONFIGURATION,
NameListToString(stmt->cfgname));
- relMap = heap_open(TSConfigMapRelationId, RowExclusiveLock);
+ relMap = table_open(TSConfigMapRelationId, RowExclusiveLock);
/* Add or drop mappings */
if (stmt->dicts)
@@ -1220,7 +1220,7 @@ AlterTSConfiguration(AlterTSConfigurationStmt *stmt)
ObjectAddressSet(address, TSConfigRelationId, cfgId);
- heap_close(relMap, RowExclusiveLock);
+ table_close(relMap, RowExclusiveLock);
ReleaseSysCache(tup);
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 9ca30b0443c..35a6485118f 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -691,7 +691,7 @@ RemoveTypeById(Oid typeOid)
Relation relation;
HeapTuple tup;
- relation = heap_open(TypeRelationId, RowExclusiveLock);
+ relation = table_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
@@ -717,7 +717,7 @@ RemoveTypeById(Oid typeOid)
ReleaseSysCache(tup);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
}
@@ -2091,11 +2091,11 @@ AssignTypeArrayOid(void)
}
else
{
- Relation pg_type = heap_open(TypeRelationId, AccessShareLock);
+ Relation pg_type = table_open(TypeRelationId, AccessShareLock);
type_array_oid = GetNewOidWithIndex(pg_type, TypeOidIndexId,
Anum_pg_type_oid);
- heap_close(pg_type, AccessShareLock);
+ table_close(pg_type, AccessShareLock);
}
return type_array_oid;
@@ -2198,7 +2198,7 @@ AlterDomainDefault(List *names, Node *defaultRaw)
domainoid = typenameTypeId(NULL, typename);
/* Look up the domain in the type table */
- rel = heap_open(TypeRelationId, RowExclusiveLock);
+ rel = table_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
@@ -2300,7 +2300,7 @@ AlterDomainDefault(List *names, Node *defaultRaw)
ObjectAddressSet(address, TypeRelationId, domainoid);
/* Clean up */
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
heap_freetuple(newtuple);
return address;
@@ -2328,7 +2328,7 @@ AlterDomainNotNull(List *names, bool notNull)
domainoid = typenameTypeId(NULL, typename);
/* Look up the domain in the type table */
- typrel = heap_open(TypeRelationId, RowExclusiveLock);
+ typrel = table_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
@@ -2341,7 +2341,7 @@ AlterDomainNotNull(List *names, bool notNull)
/* Is the domain already set to the desired constraint? */
if (typTup->typnotnull == notNull)
{
- heap_close(typrel, RowExclusiveLock);
+ table_close(typrel, RowExclusiveLock);
return address;
}
@@ -2401,7 +2401,7 @@ AlterDomainNotNull(List *names, bool notNull)
UnregisterSnapshot(snapshot);
/* Close each rel after processing, but keep lock */
- heap_close(testrel, NoLock);
+ table_close(testrel, NoLock);
}
}
@@ -2419,7 +2419,7 @@ AlterDomainNotNull(List *names, bool notNull)
/* Clean up */
heap_freetuple(tup);
- heap_close(typrel, RowExclusiveLock);
+ table_close(typrel, RowExclusiveLock);
return address;
}
@@ -2451,7 +2451,7 @@ AlterDomainDropConstraint(List *names, const char *constrName,
domainoid = typenameTypeId(NULL, typename);
/* Look up the domain in the type table */
- rel = heap_open(TypeRelationId, RowExclusiveLock);
+ rel = table_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
@@ -2461,7 +2461,7 @@ AlterDomainDropConstraint(List *names, const char *constrName,
checkDomainOwner(tup);
/* Grab an appropriate lock on the pg_constraint relation */
- conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
+ conrel = table_open(ConstraintRelationId, RowExclusiveLock);
/* Find and remove the target constraint */
ScanKeyInit(&skey[0],
@@ -2495,7 +2495,7 @@ AlterDomainDropConstraint(List *names, const char *constrName,
/* Clean up after the scan */
systable_endscan(conscan);
- heap_close(conrel, RowExclusiveLock);
+ table_close(conrel, RowExclusiveLock);
if (!found)
{
@@ -2520,7 +2520,7 @@ AlterDomainDropConstraint(List *names, const char *constrName,
ObjectAddressSet(address, TypeRelationId, domainoid);
/* Clean up */
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return address;
}
@@ -2548,7 +2548,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint,
domainoid = typenameTypeId(NULL, typename);
/* Look up the domain in the type table */
- typrel = heap_open(TypeRelationId, RowExclusiveLock);
+ typrel = table_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
@@ -2636,7 +2636,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint,
ObjectAddressSet(address, TypeRelationId, domainoid);
/* Clean up */
- heap_close(typrel, RowExclusiveLock);
+ table_close(typrel, RowExclusiveLock);
return address;
}
@@ -2670,7 +2670,7 @@ AlterDomainValidateConstraint(List *names, const char *constrName)
domainoid = typenameTypeId(NULL, typename);
/* Look up the domain in the type table */
- typrel = heap_open(TypeRelationId, AccessShareLock);
+ typrel = table_open(TypeRelationId, AccessShareLock);
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
@@ -2682,7 +2682,7 @@ AlterDomainValidateConstraint(List *names, const char *constrName)
/*
* Find and check the target constraint
*/
- conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
+ conrel = table_open(ConstraintRelationId, RowExclusiveLock);
ScanKeyInit(&skey[0],
Anum_pg_constraint_conrelid,
@@ -2740,8 +2740,8 @@ AlterDomainValidateConstraint(List *names, const char *constrName)
systable_endscan(scan);
- heap_close(typrel, AccessShareLock);
- heap_close(conrel, RowExclusiveLock);
+ table_close(typrel, AccessShareLock);
+ table_close(conrel, RowExclusiveLock);
ReleaseSysCache(tup);
@@ -2829,7 +2829,7 @@ validateDomainConstraint(Oid domainoid, char *ccbin)
UnregisterSnapshot(snapshot);
/* Hold relation lock till commit (XXX bad for concurrency) */
- heap_close(testrel, NoLock);
+ table_close(testrel, NoLock);
}
FreeExecutorState(estate);
@@ -2885,7 +2885,7 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
* We scan pg_depend to find those things that depend on the domain. (We
* assume we can ignore refobjsubid for a domain.)
*/
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
@@ -3227,7 +3227,7 @@ RenameType(RenameStmt *stmt)
typeOid = typenameTypeId(NULL, typename);
/* Look up the type in the type table */
- rel = heap_open(TypeRelationId, RowExclusiveLock);
+ rel = table_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
@@ -3280,7 +3280,7 @@ RenameType(RenameStmt *stmt)
ObjectAddressSet(address, TypeRelationId, typeOid);
/* Clean up */
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return address;
}
@@ -3300,7 +3300,7 @@ AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype)
AclResult aclresult;
ObjectAddress address;
- rel = heap_open(TypeRelationId, RowExclusiveLock);
+ rel = table_open(TypeRelationId, RowExclusiveLock);
/* Make a TypeName so we can use standard type lookup machinery */
typename = makeTypeNameFromNameList(names);
@@ -3381,7 +3381,7 @@ AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype)
ObjectAddressSet(address, TypeRelationId, typeOid);
/* Clean up */
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
return address;
}
@@ -3404,7 +3404,7 @@ AlterTypeOwner_oid(Oid typeOid, Oid newOwnerId, bool hasDependEntry)
HeapTuple tup;
Form_pg_type typTup;
- rel = heap_open(TypeRelationId, RowExclusiveLock);
+ rel = table_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
@@ -3428,7 +3428,7 @@ AlterTypeOwner_oid(Oid typeOid, Oid newOwnerId, bool hasDependEntry)
InvokeObjectPostAlterHook(TypeRelationId, typeOid, 0);
ReleaseSysCache(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
@@ -3450,7 +3450,7 @@ AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId)
Datum aclDatum;
bool isNull;
- rel = heap_open(TypeRelationId, RowExclusiveLock);
+ rel = table_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
@@ -3486,7 +3486,7 @@ AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId)
AlterTypeOwnerInternal(typTup->typarray, newOwnerId);
/* Clean up */
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
}
/*
@@ -3591,7 +3591,7 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
if (object_address_present(&thisobj, objsMoved))
return InvalidOid;
- rel = heap_open(TypeRelationId, RowExclusiveLock);
+ rel = table_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
@@ -3652,13 +3652,13 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
{
Relation classRel;
- classRel = heap_open(RelationRelationId, RowExclusiveLock);
+ classRel = table_open(RelationRelationId, RowExclusiveLock);
AlterRelationNamespaceInternal(classRel, typform->typrelid,
oldNspOid, nspOid,
false, objsMoved);
- heap_close(classRel, RowExclusiveLock);
+ table_close(classRel, RowExclusiveLock);
/*
* Check for constraints associated with the composite type (we don't
@@ -3691,7 +3691,7 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
heap_freetuple(tup);
- heap_close(rel, RowExclusiveLock);
+ table_close(rel, RowExclusiveLock);
add_exact_object_address(&thisobj, objsMoved);
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 938c7d0ed0a..34c81d5c040 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -331,7 +331,7 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
* Check the pg_authid relation to be certain the role doesn't already
* exist.
*/
- pg_authid_rel = heap_open(AuthIdRelationId, RowExclusiveLock);
+ pg_authid_rel = table_open(AuthIdRelationId, RowExclusiveLock);
pg_authid_dsc = RelationGetDescr(pg_authid_rel);
if (OidIsValid(get_role_oid(stmt->role, true)))
@@ -495,7 +495,7 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
/*
* Close pg_authid, but keep lock till commit.
*/
- heap_close(pg_authid_rel, NoLock);
+ table_close(pg_authid_rel, NoLock);
return roleid;
}
@@ -681,7 +681,7 @@ AlterRole(AlterRoleStmt *stmt)
/*
* Scan the pg_authid relation to be certain the user exists.
*/
- pg_authid_rel = heap_open(AuthIdRelationId, RowExclusiveLock);
+ pg_authid_rel = table_open(AuthIdRelationId, RowExclusiveLock);
pg_authid_dsc = RelationGetDescr(pg_authid_rel);
tuple = get_rolespec_tuple(stmt->role);
@@ -881,7 +881,7 @@ AlterRole(AlterRoleStmt *stmt)
/*
* Close pg_authid, but keep lock till commit.
*/
- heap_close(pg_authid_rel, NoLock);
+ table_close(pg_authid_rel, NoLock);
return roleid;
}
@@ -987,8 +987,8 @@ DropRole(DropRoleStmt *stmt)
* Scan the pg_authid relation to find the Oid of the role(s) to be
* deleted.
*/
- pg_authid_rel = heap_open(AuthIdRelationId, RowExclusiveLock);
- pg_auth_members_rel = heap_open(AuthMemRelationId, RowExclusiveLock);
+ pg_authid_rel = table_open(AuthIdRelationId, RowExclusiveLock);
+ pg_auth_members_rel = table_open(AuthMemRelationId, RowExclusiveLock);
foreach(item, stmt->roles)
{
@@ -1142,8 +1142,8 @@ DropRole(DropRoleStmt *stmt)
/*
* Now we can clean up; but keep locks until commit.
*/
- heap_close(pg_auth_members_rel, NoLock);
- heap_close(pg_authid_rel, NoLock);
+ table_close(pg_auth_members_rel, NoLock);
+ table_close(pg_authid_rel, NoLock);
}
/*
@@ -1166,7 +1166,7 @@ RenameRole(const char *oldname, const char *newname)
ObjectAddress address;
Form_pg_authid authform;
- rel = heap_open(AuthIdRelationId, RowExclusiveLock);
+ rel = table_open(AuthIdRelationId, RowExclusiveLock);
dsc = RelationGetDescr(rel);
oldtuple = SearchSysCache1(AUTHNAME, CStringGetDatum(oldname));
@@ -1270,7 +1270,7 @@ RenameRole(const char *oldname, const char *newname)
/*
* Close pg_authid, but keep lock till commit.
*/
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
return address;
}
@@ -1296,7 +1296,7 @@ GrantRole(GrantRoleStmt *stmt)
grantee_ids = roleSpecsToIds(stmt->grantee_roles);
/* AccessShareLock is enough since we aren't modifying pg_authid */
- pg_authid_rel = heap_open(AuthIdRelationId, AccessShareLock);
+ pg_authid_rel = table_open(AuthIdRelationId, AccessShareLock);
/*
* Step through all of the granted roles and add/remove entries for the
@@ -1331,7 +1331,7 @@ GrantRole(GrantRoleStmt *stmt)
/*
* Close pg_authid, but keep lock till commit.
*/
- heap_close(pg_authid_rel, NoLock);
+ table_close(pg_authid_rel, NoLock);
}
/*
@@ -1483,7 +1483,7 @@ AddRoleMems(const char *rolename, Oid roleid,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to set grantor")));
- pg_authmem_rel = heap_open(AuthMemRelationId, RowExclusiveLock);
+ pg_authmem_rel = table_open(AuthMemRelationId, RowExclusiveLock);
pg_authmem_dsc = RelationGetDescr(pg_authmem_rel);
forboth(specitem, memberSpecs, iditem, memberIds)
@@ -1561,7 +1561,7 @@ AddRoleMems(const char *rolename, Oid roleid,
/*
* Close pg_authmem, but keep lock till commit.
*/
- heap_close(pg_authmem_rel, NoLock);
+ table_close(pg_authmem_rel, NoLock);
}
/*
@@ -1612,7 +1612,7 @@ DelRoleMems(const char *rolename, Oid roleid,
rolename)));
}
- pg_authmem_rel = heap_open(AuthMemRelationId, RowExclusiveLock);
+ pg_authmem_rel = table_open(AuthMemRelationId, RowExclusiveLock);
pg_authmem_dsc = RelationGetDescr(pg_authmem_rel);
forboth(specitem, memberSpecs, iditem, memberIds)
@@ -1671,5 +1671,5 @@ DelRoleMems(const char *rolename, Oid roleid,
/*
* Close pg_authmem, but keep lock till commit.
*/
- heap_close(pg_authmem_rel, NoLock);
+ table_close(pg_authmem_rel, NoLock);
}
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index ff1e178bc34..37065d39c4b 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -749,7 +749,7 @@ get_all_vacuum_rels(int options)
HeapScanDesc scan;
HeapTuple tuple;
- pgclass = heap_open(RelationRelationId, AccessShareLock);
+ pgclass = table_open(RelationRelationId, AccessShareLock);
scan = heap_beginscan_catalog(pgclass, 0, NULL);
@@ -786,7 +786,7 @@ get_all_vacuum_rels(int options)
}
heap_endscan(scan);
- heap_close(pgclass, AccessShareLock);
+ table_close(pgclass, AccessShareLock);
return vacrels;
}
@@ -1097,7 +1097,7 @@ vac_update_relstats(Relation relation,
Form_pg_class pgcform;
bool dirty;
- rd = heap_open(RelationRelationId, RowExclusiveLock);
+ rd = table_open(RelationRelationId, RowExclusiveLock);
/* Fetch a copy of the tuple to scribble on */
ctup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
@@ -1188,7 +1188,7 @@ vac_update_relstats(Relation relation,
if (dirty)
heap_inplace_update(rd, ctup);
- heap_close(rd, RowExclusiveLock);
+ table_close(rd, RowExclusiveLock);
}
@@ -1251,7 +1251,7 @@ vac_update_datfrozenxid(void)
* We must seqscan pg_class to find the minimum Xid, because there is no
* index that can help us here.
*/
- relation = heap_open(RelationRelationId, AccessShareLock);
+ relation = table_open(RelationRelationId, AccessShareLock);
scan = systable_beginscan(relation, InvalidOid, false,
NULL, 0, NULL);
@@ -1296,7 +1296,7 @@ vac_update_datfrozenxid(void)
/* we're done with pg_class */
systable_endscan(scan);
- heap_close(relation, AccessShareLock);
+ table_close(relation, AccessShareLock);
/* chicken out if bogus data found */
if (bogus)
@@ -1306,7 +1306,7 @@ vac_update_datfrozenxid(void)
Assert(MultiXactIdIsValid(newMinMulti));
/* Now fetch the pg_database tuple we need to update. */
- relation = heap_open(DatabaseRelationId, RowExclusiveLock);
+ relation = table_open(DatabaseRelationId, RowExclusiveLock);
/* Fetch a copy of the tuple to scribble on */
tuple = SearchSysCacheCopy1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
@@ -1344,7 +1344,7 @@ vac_update_datfrozenxid(void)
heap_inplace_update(relation, tuple);
heap_freetuple(tuple);
- heap_close(relation, RowExclusiveLock);
+ table_close(relation, RowExclusiveLock);
/*
* If we were able to advance datfrozenxid or datminmxid, see if we can
@@ -1411,7 +1411,7 @@ vac_truncate_clog(TransactionId frozenXID,
* worst possible outcome is that pg_xact is not truncated as aggressively
* as it could be.
*/
- relation = heap_open(DatabaseRelationId, AccessShareLock);
+ relation = table_open(DatabaseRelationId, AccessShareLock);
scan = heap_beginscan_catalog(relation, 0, NULL);
@@ -1454,7 +1454,7 @@ vac_truncate_clog(TransactionId frozenXID,
heap_endscan(scan);
- heap_close(relation, AccessShareLock);
+ table_close(relation, AccessShareLock);
/*
* Do not truncate CLOG if we seem to have suffered wraparound already;
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index ed0330056bf..8ac4e56ce80 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -1423,7 +1423,7 @@ ExecGetTriggerResultRel(EState *estate, Oid relid)
* event got queued, so we need take no new lock here. Also, we need not
* recheck the relkind, so no need for CheckValidResultRel.
*/
- rel = heap_open(relid, NoLock);
+ rel = table_open(relid, NoLock);
/*
* Make the new entry in the right context.
@@ -1472,7 +1472,7 @@ ExecCleanUpTriggerState(EState *estate)
*/
Assert(resultRelInfo->ri_NumIndices == 0);
- heap_close(resultRelInfo->ri_RelationDesc, NoLock);
+ table_close(resultRelInfo->ri_RelationDesc, NoLock);
}
}
@@ -1578,7 +1578,7 @@ ExecEndPlan(PlanState *planstate, EState *estate)
for (i = 0; i < num_relations; i++)
{
if (estate->es_relations[i])
- heap_close(estate->es_relations[i], NoLock);
+ table_close(estate->es_relations[i], NoLock);
}
/* likewise close any trigger target relations */
diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c
index 93e4b287970..2a7bc015630 100644
--- a/src/backend/executor/execPartition.c
+++ b/src/backend/executor/execPartition.c
@@ -514,7 +514,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
* We locked all the partitions in ExecSetupPartitionTupleRouting
* including the leaf partitions.
*/
- partrel = heap_open(dispatch->partdesc->oids[partidx], NoLock);
+ partrel = table_open(dispatch->partdesc->oids[partidx], NoLock);
leaf_part_rri = makeNode(ResultRelInfo);
InitResultRelInfo(leaf_part_rri,
@@ -983,7 +983,7 @@ ExecInitPartitionDispatchInfo(PartitionTupleRouting *proute, Oid partoid,
oldcxt = MemoryContextSwitchTo(proute->memcxt);
if (partoid != RelationGetRelid(proute->partition_root))
- rel = heap_open(partoid, NoLock);
+ rel = table_open(partoid, NoLock);
else
rel = proute->partition_root;
partdesc = RelationGetPartitionDesc(rel);
@@ -1087,7 +1087,7 @@ ExecCleanupTupleRouting(ModifyTableState *mtstate,
{
PartitionDispatch pd = proute->partition_dispatch_info[i];
- heap_close(pd->reldesc, NoLock);
+ table_close(pd->reldesc, NoLock);
if (pd->tupslot)
ExecDropSingleTupleTableSlot(pd->tupslot);
@@ -1120,7 +1120,7 @@ ExecCleanupTupleRouting(ModifyTableState *mtstate,
resultRelInfo);
ExecCloseIndices(resultRelInfo);
- heap_close(resultRelInfo->ri_RelationDesc, NoLock);
+ table_close(resultRelInfo->ri_RelationDesc, NoLock);
}
}
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index 146ca6e0532..312a0dc8056 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -776,11 +776,11 @@ ExecGetRangeTableRelation(EState *estate, Index rti)
/*
* In a normal query, we should already have the appropriate lock,
* but verify that through an Assert. Since there's already an
- * Assert inside heap_open that insists on holding some lock, it
+ * Assert inside table_open that insists on holding some lock, it
* seems sufficient to check this only when rellockmode is higher
* than the minimum.
*/
- rel = heap_open(rte->relid, NoLock);
+ rel = table_open(rte->relid, NoLock);
Assert(rte->rellockmode == AccessShareLock ||
CheckRelationLockedByMe(rel, rte->rellockmode, false));
}
@@ -791,7 +791,7 @@ ExecGetRangeTableRelation(EState *estate, Index rti)
* lock on the relation. This ensures sane behavior in case the
* parent process exits before we do.
*/
- rel = heap_open(rte->relid, rte->rellockmode);
+ rel = table_open(rte->relid, rte->rellockmode);
}
estate->es_relations[rti - 1] = rel;
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index cce762515d7..4465f002c8f 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -6192,7 +6192,7 @@ plan_create_index_workers(Oid tableOid, Oid indexOid)
/* Build RelOptInfo */
rel = build_simple_rel(root, 1, NULL);
- heap = heap_open(tableOid, NoLock);
+ heap = table_open(tableOid, NoLock);
index = index_open(indexOid, NoLock);
/*
@@ -6253,7 +6253,7 @@ plan_create_index_workers(Oid tableOid, Oid indexOid)
done:
index_close(index, NoLock);
- heap_close(heap, NoLock);
+ table_close(heap, NoLock);
return parallel_workers;
}
diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c
index 8d9315a4547..0e045f171af 100644
--- a/src/backend/optimizer/prep/preptlist.c
+++ b/src/backend/optimizer/prep/preptlist.c
@@ -94,7 +94,7 @@ preprocess_targetlist(PlannerInfo *root)
if (target_rte->rtekind != RTE_RELATION)
elog(ERROR, "result relation must be a regular relation");
- target_relation = heap_open(target_rte->relid, NoLock);
+ target_relation = table_open(target_rte->relid, NoLock);
}
else
Assert(command_type == CMD_SELECT);
@@ -233,7 +233,7 @@ preprocess_targetlist(PlannerInfo *root)
target_relation);
if (target_relation)
- heap_close(target_relation, NoLock);
+ table_close(target_relation, NoLock);
return tlist;
}
diff --git a/src/backend/optimizer/util/inherit.c b/src/backend/optimizer/util/inherit.c
index 52354eab5ba..f24c8efd2dd 100644
--- a/src/backend/optimizer/util/inherit.c
+++ b/src/backend/optimizer/util/inherit.c
@@ -155,7 +155,7 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
* Must open the parent relation to examine its tupdesc. We need not lock
* it; we assume the rewriter already did.
*/
- oldrelation = heap_open(parentOID, NoLock);
+ oldrelation = table_open(parentOID, NoLock);
/* Scan the inheritance set and expand it */
if (RelationGetPartitionDesc(oldrelation) != NULL)
@@ -188,7 +188,7 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
/* Open rel if needed; we already have required locks */
if (childOID != parentOID)
- newrelation = heap_open(childOID, NoLock);
+ newrelation = table_open(childOID, NoLock);
else
newrelation = oldrelation;
@@ -200,7 +200,7 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
*/
if (childOID != parentOID && RELATION_IS_OTHER_TEMP(newrelation))
{
- heap_close(newrelation, lockmode);
+ table_close(newrelation, lockmode);
continue;
}
@@ -211,7 +211,7 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
/* Close child relations, but keep locks */
if (childOID != parentOID)
- heap_close(newrelation, NoLock);
+ table_close(newrelation, NoLock);
}
/*
@@ -229,7 +229,7 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
}
- heap_close(oldrelation, NoLock);
+ table_close(oldrelation, NoLock);
}
/*
@@ -286,7 +286,7 @@ expand_partitioned_rtentry(PlannerInfo *root, RangeTblEntry *parentrte,
Relation childrel;
/* Open rel; we already have required locks */
- childrel = heap_open(childOID, NoLock);
+ childrel = table_open(childOID, NoLock);
/*
* Temporary partitions belonging to other sessions should have been
@@ -307,7 +307,7 @@ expand_partitioned_rtentry(PlannerInfo *root, RangeTblEntry *parentrte,
appinfos);
/* Close child relation, but keep locks */
- heap_close(childrel, NoLock);
+ table_close(childrel, NoLock);
}
}
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index a6029f56373..ab35055c596 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -118,7 +118,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
* the rewriter or when expand_inherited_rtentry() added it to the query's
* rangetable.
*/
- relation = heap_open(relationObjectId, NoLock);
+ relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
if (!RelationNeedsWAL(relation) && RecoveryInProgress())
@@ -450,7 +450,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
if (inhparent && relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
set_relation_partition_info(root, rel, relation);
- heap_close(relation, NoLock);
+ table_close(relation, NoLock);
/*
* Allow a plugin to editorialize on the info we obtained from the
@@ -621,7 +621,7 @@ infer_arbiter_indexes(PlannerInfo *root)
relationObjectId = rt_fetch(root->parse->resultRelation,
root->parse->rtable)->relid;
- relation = heap_open(relationObjectId, NoLock);
+ relation = table_open(relationObjectId, NoLock);
/*
* Build normalized/BMS representation of plain indexed attributes, as
@@ -720,7 +720,7 @@ infer_arbiter_indexes(PlannerInfo *root)
results = lappend_oid(results, idxForm->indexrelid);
list_free(indexList);
index_close(idxRel, NoLock);
- heap_close(relation, NoLock);
+ table_close(relation, NoLock);
return results;
}
else if (indexOidFromConstraint != InvalidOid)
@@ -815,7 +815,7 @@ next:
}
list_free(indexList);
- heap_close(relation, NoLock);
+ table_close(relation, NoLock);
if (results == NIL)
ereport(ERROR,
@@ -1143,11 +1143,11 @@ get_relation_data_width(Oid relid, int32 *attr_widths)
Relation relation;
/* As above, assume relation is already locked */
- relation = heap_open(relid, NoLock);
+ relation = table_open(relid, NoLock);
result = get_rel_data_width(relation, attr_widths);
- heap_close(relation, NoLock);
+ table_close(relation, NoLock);
return result;
}
@@ -1183,7 +1183,7 @@ get_relation_constraints(PlannerInfo *root,
/*
* We assume the relation has already been safely locked.
*/
- relation = heap_open(relationObjectId, NoLock);
+ relation = table_open(relationObjectId, NoLock);
constr = relation->rd_att->constr;
if (constr != NULL)
@@ -1294,7 +1294,7 @@ get_relation_constraints(PlannerInfo *root,
}
}
- heap_close(relation, NoLock);
+ table_close(relation, NoLock);
return result;
}
@@ -1571,7 +1571,7 @@ build_physical_tlist(PlannerInfo *root, RelOptInfo *rel)
{
case RTE_RELATION:
/* Assume we already have adequate lock */
- relation = heap_open(rte->relid, NoLock);
+ relation = table_open(rte->relid, NoLock);
numattrs = RelationGetNumberOfAttributes(relation);
for (attrno = 1; attrno <= numattrs; attrno++)
@@ -1600,7 +1600,7 @@ build_physical_tlist(PlannerInfo *root, RelOptInfo *rel)
false));
}
- heap_close(relation, NoLock);
+ table_close(relation, NoLock);
break;
case RTE_SUBQUERY:
@@ -1857,7 +1857,7 @@ has_row_triggers(PlannerInfo *root, Index rti, CmdType event)
bool result = false;
/* Assume we already have adequate lock */
- relation = heap_open(rte->relid, NoLock);
+ relation = table_open(rte->relid, NoLock);
trigDesc = relation->trigdesc;
switch (event)
@@ -1885,7 +1885,7 @@ has_row_triggers(PlannerInfo *root, Index rti, CmdType event)
break;
}
- heap_close(relation, NoLock);
+ table_close(relation, NoLock);
return result;
}
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index 2d740b5f52c..8805543da74 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -201,13 +201,13 @@ setTargetTable(ParseState *pstate, RangeVar *relation,
/* Close old target; this could only happen for multi-action rules */
if (pstate->p_target_relation != NULL)
- heap_close(pstate->p_target_relation, NoLock);
+ table_close(pstate->p_target_relation, NoLock);
/*
* Open target rel and grab suitable lock (which we will hold till end of
* transaction).
*
- * free_parsestate() will eventually do the corresponding heap_close(),
+ * free_parsestate() will eventually do the corresponding table_close(),
* but *not* release the lock.
*/
pstate->p_target_relation = parserOpenTable(pstate, relation,
diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c
index 0562e6ecc80..ece81697e6a 100644
--- a/src/backend/parser/parse_node.c
+++ b/src/backend/parser/parse_node.c
@@ -88,7 +88,7 @@ free_parsestate(ParseState *pstate)
MaxTupleAttributeNumber)));
if (pstate->p_target_relation != NULL)
- heap_close(pstate->p_target_relation, NoLock);
+ table_close(pstate->p_target_relation, NoLock);
pfree(pstate);
}
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 0f8175d39f3..09fbb588af4 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -1137,7 +1137,7 @@ chooseScalarFunctionAlias(Node *funcexpr, char *funcname,
/*
* Open a table during parse analysis
*
- * This is essentially just the same as heap_openrv(), except that it caters
+ * This is essentially just the same as table_openrv(), except that it caters
* to some parser-specific error reporting needs, notably that it arranges
* to include the RangeVar's parse location in any resulting error.
*
@@ -1152,7 +1152,7 @@ parserOpenTable(ParseState *pstate, const RangeVar *relation, int lockmode)
ParseCallbackState pcbstate;
setup_parser_errposition_callback(&pcbstate, pstate, relation->location);
- rel = heap_openrv_extended(relation, lockmode, true);
+ rel = table_openrv_extended(relation, lockmode, true);
if (rel == NULL)
{
if (relation->schemaname)
@@ -1240,7 +1240,7 @@ addRangeTableEntry(ParseState *pstate,
* so that the table can't be deleted or have its schema modified
* underneath us.
*/
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
/*
* Set flags and access permissions.
@@ -3096,7 +3096,7 @@ get_parse_rowmark(Query *qry, Index rtindex)
* Returns InvalidAttrNumber if the attr doesn't exist (or is dropped).
*
* This should only be used if the relation is already
- * heap_open()'ed. Use the cache version get_attnum()
+ * table_open()'ed. Use the cache version get_attnum()
* for access to non-opened relations.
*/
int
@@ -3146,7 +3146,7 @@ specialAttNum(const char *attname)
* given attribute id, return name of that attribute
*
* This should only be used if the relation is already
- * heap_open()'ed. Use the cache version get_atttype()
+ * table_open()'ed. Use the cache version get_atttype()
* for access to non-opened relations.
*/
const NameData *
@@ -3168,7 +3168,7 @@ attnumAttName(Relation rd, int attid)
* given attribute id, return type of that attribute
*
* This should only be used if the relation is already
- * heap_open()'ed. Use the cache version get_atttype()
+ * table_open()'ed. Use the cache version get_atttype()
* for access to non-opened relations.
*/
Oid
@@ -3189,7 +3189,7 @@ attnumTypeId(Relation rd, int attid)
/*
* given attribute id, return collation of that attribute
*
- * This should only be used if the relation is already heap_open()'ed.
+ * This should only be used if the relation is already table_open()'ed.
*/
Oid
attnumCollationId(Relation rd, int attid)
@@ -3361,10 +3361,10 @@ isQueryUsingTempRelation_walker(Node *node, void *context)
if (rte->rtekind == RTE_RELATION)
{
- Relation rel = heap_open(rte->relid, AccessShareLock);
+ Relation rel = table_open(rte->relid, AccessShareLock);
char relpersistence = rel->rd_rel->relpersistence;
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
if (relpersistence == RELPERSISTENCE_TEMP)
return true;
}
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index ef3865d8ee7..404569f7df4 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -1200,7 +1200,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
* commit. That will prevent someone else from deleting or ALTERing the
* parent before the child is committed.
*/
- heap_close(relation, NoLock);
+ table_close(relation, NoLock);
}
static void
@@ -2157,7 +2157,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
Relation rel;
int count;
- rel = heap_openrv(inh, AccessShareLock);
+ rel = table_openrv(inh, AccessShareLock);
/* check user requested inheritance from valid relkind */
if (rel->rd_rel->relkind != RELKIND_RELATION &&
rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
@@ -2187,7 +2187,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
break;
}
}
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
if (found)
break;
}
@@ -2280,7 +2280,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
Relation rel;
int count;
- rel = heap_openrv(inh, AccessShareLock);
+ rel = table_openrv(inh, AccessShareLock);
/* check user requested inheritance from valid relkind */
if (rel->rd_rel->relkind != RELKIND_RELATION &&
rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
@@ -2310,7 +2310,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
break;
}
}
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
if (found)
break;
}
@@ -2550,7 +2550,7 @@ transformIndexStmt(Oid relid, IndexStmt *stmt, const char *queryString)
free_parsestate(pstate);
/* Close relation */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
/* Mark statement as successfully transformed */
stmt->transformed = true;
@@ -2586,7 +2586,7 @@ transformRuleStmt(RuleStmt *stmt, const char *queryString,
* DefineQueryRewrite(), and we don't want to grab a lesser lock
* beforehand.
*/
- rel = heap_openrv(stmt->relation, AccessExclusiveLock);
+ rel = table_openrv(stmt->relation, AccessExclusiveLock);
if (rel->rd_rel->relkind == RELKIND_MATVIEW)
ereport(ERROR,
@@ -2864,7 +2864,7 @@ transformRuleStmt(RuleStmt *stmt, const char *queryString,
free_parsestate(pstate);
/* Close relation, but keep the exclusive lock */
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
diff --git a/src/backend/partitioning/partbounds.c b/src/backend/partitioning/partbounds.c
index 60993c3a7a5..f21c9b32a60 100644
--- a/src/backend/partitioning/partbounds.c
+++ b/src/backend/partitioning/partbounds.c
@@ -1213,7 +1213,7 @@ check_default_partition_contents(Relation parent, Relation default_rel,
/* Lock already taken above. */
if (part_relid != RelationGetRelid(default_rel))
{
- part_rel = heap_open(part_relid, NoLock);
+ part_rel = table_open(part_relid, NoLock);
/*
* If the partition constraints on default partition child imply
@@ -1227,7 +1227,7 @@ check_default_partition_contents(Relation parent, Relation default_rel,
(errmsg("updated partition constraint for default partition \"%s\" is implied by existing constraints",
RelationGetRelationName(part_rel))));
- heap_close(part_rel, NoLock);
+ table_close(part_rel, NoLock);
continue;
}
}
@@ -1248,7 +1248,7 @@ check_default_partition_contents(Relation parent, Relation default_rel,
RelationGetRelationName(default_rel))));
if (RelationGetRelid(default_rel) != RelationGetRelid(part_rel))
- heap_close(part_rel, NoLock);
+ table_close(part_rel, NoLock);
continue;
}
@@ -1296,7 +1296,7 @@ check_default_partition_contents(Relation parent, Relation default_rel,
FreeExecutorState(estate);
if (RelationGetRelid(default_rel) != RelationGetRelid(part_rel))
- heap_close(part_rel, NoLock); /* keep the lock until commit */
+ table_close(part_rel, NoLock); /* keep the lock until commit */
}
}
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 4cf67873b17..975256ba622 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -1883,7 +1883,7 @@ get_database_list(void)
StartTransactionCommand();
(void) GetTransactionSnapshot();
- rel = heap_open(DatabaseRelationId, AccessShareLock);
+ rel = table_open(DatabaseRelationId, AccessShareLock);
scan = heap_beginscan_catalog(rel, 0, NULL);
while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
@@ -1914,7 +1914,7 @@ get_database_list(void)
}
heap_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
CommitTransactionCommand();
@@ -2015,7 +2015,7 @@ do_autovacuum(void)
/* The database hash where pgstat keeps shared relations */
shared = pgstat_fetch_stat_dbentry(InvalidOid);
- classRel = heap_open(RelationRelationId, AccessShareLock);
+ classRel = table_open(RelationRelationId, AccessShareLock);
/* create a copy so we can use it after closing pg_class */
pg_class_desc = CreateTupleDescCopy(RelationGetDescr(classRel));
@@ -2189,7 +2189,7 @@ do_autovacuum(void)
}
heap_endscan(relScan);
- heap_close(classRel, AccessShareLock);
+ table_close(classRel, AccessShareLock);
/*
* Recheck orphan temporary tables, and if they still seem orphaned, drop
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 13da412c59c..f207c35be94 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -1219,7 +1219,7 @@ pgstat_collect_oids(Oid catalogid, AttrNumber anum_oid)
&hash_ctl,
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
- rel = heap_open(catalogid, AccessShareLock);
+ rel = table_open(catalogid, AccessShareLock);
snapshot = RegisterSnapshot(GetLatestSnapshot());
scan = heap_beginscan(rel, snapshot, 0, NULL);
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
@@ -1236,7 +1236,7 @@ pgstat_collect_oids(Oid catalogid, AttrNumber anum_oid)
}
heap_endscan(scan);
UnregisterSnapshot(snapshot);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
return htab;
}
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index 2b0d889c3b7..55b91b5e12c 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -135,7 +135,7 @@ get_subscription_list(void)
StartTransactionCommand();
(void) GetTransactionSnapshot();
- rel = heap_open(SubscriptionRelationId, AccessShareLock);
+ rel = table_open(SubscriptionRelationId, AccessShareLock);
scan = heap_beginscan_catalog(rel, 0, NULL);
while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
@@ -165,7 +165,7 @@ get_subscription_list(void)
}
heap_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
CommitTransactionCommand();
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index 0ca89911844..7a102a7ad38 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -270,7 +270,7 @@ replorigin_create(char *roname)
*/
InitDirtySnapshot(SnapshotDirty);
- rel = heap_open(ReplicationOriginRelationId, ExclusiveLock);
+ rel = table_open(ReplicationOriginRelationId, ExclusiveLock);
for (roident = InvalidOid + 1; roident < PG_UINT16_MAX; roident++)
{
@@ -313,7 +313,7 @@ replorigin_create(char *roname)
}
/* now release lock again, */
- heap_close(rel, ExclusiveLock);
+ table_close(rel, ExclusiveLock);
if (tuple == NULL)
ereport(ERROR,
@@ -343,7 +343,7 @@ replorigin_drop(RepOriginId roident, bool nowait)
* To interlock against concurrent drops, we hold ExclusiveLock on
* pg_replication_origin throughout this function.
*/
- rel = heap_open(ReplicationOriginRelationId, ExclusiveLock);
+ rel = table_open(ReplicationOriginRelationId, ExclusiveLock);
/*
* First, clean up the slot state info, if there is any matching slot.
@@ -419,7 +419,7 @@ restart:
CommandCounterIncrement();
/* now release lock again */
- heap_close(rel, ExclusiveLock);
+ table_close(rel, ExclusiveLock);
}
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index 81087ac9033..1d918d2c428 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -254,7 +254,7 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("logical replication target relation \"%s.%s\" does not exist",
remoterel->nspname, remoterel->relname)));
- entry->localrel = heap_open(relid, NoLock);
+ entry->localrel = table_open(relid, NoLock);
/* Check for supported relkind. */
CheckSubscriptionRelkind(entry->localrel->rd_rel->relkind,
@@ -350,7 +350,7 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
entry->localreloid = relid;
}
else
- entry->localrel = heap_open(entry->localreloid, lockmode);
+ entry->localrel = table_open(entry->localreloid, lockmode);
if (entry->state != SUBREL_STATE_READY)
entry->state = GetSubscriptionRelState(MySubscription->oid,
@@ -367,7 +367,7 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
void
logicalrep_rel_close(LogicalRepRelMapEntry *rel, LOCKMODE lockmode)
{
- heap_close(rel->localrel, lockmode);
+ table_close(rel->localrel, lockmode);
rel->localrel = NULL;
}
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index 20ab1122064..28f5fc23aac 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -877,7 +877,7 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
* working and it has to open the relation in RowExclusiveLock
* when remapping remote relation id to local one.
*/
- rel = heap_open(MyLogicalRepWorker->relid, RowExclusiveLock);
+ rel = table_open(MyLogicalRepWorker->relid, RowExclusiveLock);
/*
* Create a temporary slot for the sync process. We do this
@@ -915,7 +915,7 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
errdetail("The error was: %s", res->err)));
walrcv_clear_result(res);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
/* Make the copy visible. */
CommandCounterIncrement();
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index 0755f3eed80..2da8486e638 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -95,7 +95,7 @@ InsertRule(const char *rulname,
/*
* Ready to store new pg_rewrite tuple
*/
- pg_rewrite_desc = heap_open(RewriteRelationId, RowExclusiveLock);
+ pg_rewrite_desc = table_open(RewriteRelationId, RowExclusiveLock);
/*
* Check to see if we are replacing an existing tuple
@@ -186,7 +186,7 @@ InsertRule(const char *rulname,
/* Post creation hook for new rule */
InvokeObjectPostCreateHook(RewriteRelationId, rewriteObjectId, 0);
- heap_close(pg_rewrite_desc, RowExclusiveLock);
+ table_close(pg_rewrite_desc, RowExclusiveLock);
return rewriteObjectId;
}
@@ -255,7 +255,7 @@ DefineQueryRewrite(const char *rulename,
*
* Note that this lock level should match the one used in DefineRule.
*/
- event_relation = heap_open(event_relid, AccessExclusiveLock);
+ event_relation = table_open(event_relid, AccessExclusiveLock);
/*
* Verify relation is of a type that rules can sensibly be applied to.
@@ -565,7 +565,7 @@ DefineQueryRewrite(const char *rulename,
HeapTuple classTup;
Form_pg_class classForm;
- relationRelation = heap_open(RelationRelationId, RowExclusiveLock);
+ relationRelation = table_open(RelationRelationId, RowExclusiveLock);
toastrelid = event_relation->rd_rel->reltoastrelid;
/* drop storage while table still looks like a table */
@@ -629,13 +629,13 @@ DefineQueryRewrite(const char *rulename,
CatalogTupleUpdate(relationRelation, &classTup->t_self, classTup);
heap_freetuple(classTup);
- heap_close(relationRelation, RowExclusiveLock);
+ table_close(relationRelation, RowExclusiveLock);
}
ObjectAddressSet(address, RewriteRelationId, ruleId);
/* Close rel, but keep lock till commit... */
- heap_close(event_relation, NoLock);
+ table_close(event_relation, NoLock);
return address;
}
@@ -852,7 +852,7 @@ EnableDisableRule(Relation rel, const char *rulename,
/*
* Find the rule tuple to change.
*/
- pg_rewrite_desc = heap_open(RewriteRelationId, RowExclusiveLock);
+ pg_rewrite_desc = table_open(RewriteRelationId, RowExclusiveLock);
ruletup = SearchSysCacheCopy2(RULERELNAME,
ObjectIdGetDatum(owningRel),
PointerGetDatum(rulename));
@@ -888,7 +888,7 @@ EnableDisableRule(Relation rel, const char *rulename,
InvokeObjectPostAlterHook(RewriteRelationId, ruleform->oid, 0);
heap_freetuple(ruletup);
- heap_close(pg_rewrite_desc, RowExclusiveLock);
+ table_close(pg_rewrite_desc, RowExclusiveLock);
/*
* If we changed anything, broadcast a SI inval message to force each
@@ -964,7 +964,7 @@ RenameRewriteRule(RangeVar *relation, const char *oldName,
targetrel = relation_open(relid, NoLock);
/* Prepare to modify pg_rewrite */
- pg_rewrite_desc = heap_open(RewriteRelationId, RowExclusiveLock);
+ pg_rewrite_desc = table_open(RewriteRelationId, RowExclusiveLock);
/* Fetch the rule's entry (it had better exist) */
ruletup = SearchSysCacheCopy2(RULERELNAME,
@@ -1000,7 +1000,7 @@ RenameRewriteRule(RangeVar *relation, const char *oldName,
CatalogTupleUpdate(pg_rewrite_desc, &ruletup->t_self, ruletup);
heap_freetuple(ruletup);
- heap_close(pg_rewrite_desc, RowExclusiveLock);
+ table_close(pg_rewrite_desc, RowExclusiveLock);
/*
* Invalidate relation's relcache entry so that other backends (and this
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index 0fade10268a..1eca69873b2 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -180,7 +180,7 @@ AcquireRewriteLocks(Query *parsetree,
else
lockmode = rte->rellockmode;
- rel = heap_open(rte->relid, lockmode);
+ rel = table_open(rte->relid, lockmode);
/*
* While we have the relation open, update the RTE's relkind,
@@ -188,7 +188,7 @@ AcquireRewriteLocks(Query *parsetree,
*/
rte->relkind = rel->rd_rel->relkind;
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
break;
case RTE_JOIN:
@@ -1813,7 +1813,7 @@ fireRIRrules(Query *parsetree, List *activeRIRs)
* We can use NoLock here since either the parser or
* AcquireRewriteLocks should have locked the rel already.
*/
- rel = heap_open(rte->relid, NoLock);
+ rel = table_open(rte->relid, NoLock);
/*
* Collect the RIR rules that we must apply
@@ -1860,7 +1860,7 @@ fireRIRrules(Query *parsetree, List *activeRIRs)
}
}
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
/* Recurse into subqueries in WITH */
@@ -1904,7 +1904,7 @@ fireRIRrules(Query *parsetree, List *activeRIRs)
rte->relkind != RELKIND_PARTITIONED_TABLE))
continue;
- rel = heap_open(rte->relid, NoLock);
+ rel = table_open(rte->relid, NoLock);
/*
* Fetch any new security quals that must be applied to this RTE.
@@ -1979,7 +1979,7 @@ fireRIRrules(Query *parsetree, List *activeRIRs)
if (hasSubLinks)
parsetree->hasSubLinks = true;
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
return parsetree;
@@ -2896,7 +2896,7 @@ rewriteTargetView(Query *parsetree, Relation view)
* already have the right lock!) Since it will become the query target
* relation, RowExclusiveLock is always the right thing.
*/
- base_rel = heap_open(base_rte->relid, RowExclusiveLock);
+ base_rel = table_open(base_rte->relid, RowExclusiveLock);
/*
* While we have the relation open, update the RTE's relkind, just in case
@@ -3281,7 +3281,7 @@ rewriteTargetView(Query *parsetree, Relation view)
}
}
- heap_close(base_rel, NoLock);
+ table_close(base_rel, NoLock);
return parsetree;
}
@@ -3391,7 +3391,7 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
* We can use NoLock here since either the parser or
* AcquireRewriteLocks should have locked the rel already.
*/
- rt_entry_relation = heap_open(rt_entry->relid, NoLock);
+ rt_entry_relation = table_open(rt_entry->relid, NoLock);
/*
* Rewrite the targetlist as needed for the command type.
@@ -3616,7 +3616,7 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("INSERT with ON CONFLICT clause cannot be used with table that has INSERT or UPDATE rules")));
- heap_close(rt_entry_relation, NoLock);
+ table_close(rt_entry_relation, NoLock);
}
/*
diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c
index e6b4b9da284..4c1d9c43d09 100644
--- a/src/backend/rewrite/rewriteRemove.c
+++ b/src/backend/rewrite/rewriteRemove.c
@@ -47,7 +47,7 @@ RemoveRewriteRuleById(Oid ruleOid)
/*
* Open the pg_rewrite relation.
*/
- RewriteRelation = heap_open(RewriteRelationId, RowExclusiveLock);
+ RewriteRelation = table_open(RewriteRelationId, RowExclusiveLock);
/*
* Find the tuple for the target rule.
@@ -71,7 +71,7 @@ RemoveRewriteRuleById(Oid ruleOid)
* suffice if it's not an ON SELECT rule.)
*/
eventRelationOid = ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class;
- event_relation = heap_open(eventRelationOid, AccessExclusiveLock);
+ event_relation = table_open(eventRelationOid, AccessExclusiveLock);
/*
* Now delete the pg_rewrite tuple for the rule
@@ -80,7 +80,7 @@ RemoveRewriteRuleById(Oid ruleOid)
systable_endscan(rcscan);
- heap_close(RewriteRelation, RowExclusiveLock);
+ table_close(RewriteRelation, RowExclusiveLock);
/*
* Issue shared-inval notice to force all backends (including me!) to
@@ -89,5 +89,5 @@ RemoveRewriteRuleById(Oid ruleOid)
CacheInvalidateRelcache(event_relation);
/* Close rel, but keep lock till commit... */
- heap_close(event_relation, NoLock);
+ table_close(event_relation, NoLock);
}
diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c
index ec314051fa7..1f74c90ad7a 100644
--- a/src/backend/rewrite/rewriteSupport.c
+++ b/src/backend/rewrite/rewriteSupport.c
@@ -61,7 +61,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules)
/*
* Find the tuple to update in pg_class, using syscache for the lookup.
*/
- relationRelation = heap_open(RelationRelationId, RowExclusiveLock);
+ relationRelation = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationId);
@@ -81,7 +81,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules)
}
heap_freetuple(tuple);
- heap_close(relationRelation, RowExclusiveLock);
+ table_close(relationRelation, RowExclusiveLock);
}
/*
diff --git a/src/backend/rewrite/rowsecurity.c b/src/backend/rewrite/rowsecurity.c
index 26a3ca3f7b9..835540cd334 100644
--- a/src/backend/rewrite/rowsecurity.c
+++ b/src/backend/rewrite/rowsecurity.c
@@ -162,7 +162,7 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
* for example in UPDATE t1 ... FROM t2 we need to apply t1's UPDATE
* policies and t2's SELECT policies.
*/
- rel = heap_open(rte->relid, NoLock);
+ rel = table_open(rte->relid, NoLock);
commandType = rt_index == root->resultRelation ?
root->commandType : CMD_SELECT;
@@ -379,7 +379,7 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
}
}
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
/*
* Mark this query as having row security, so plancache can invalidate it
diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index 51659a51dde..7f13e434a87 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -79,7 +79,7 @@ BuildRelationExtStatistics(Relation onerel, double totalrows,
ALLOCSET_DEFAULT_SIZES);
oldcxt = MemoryContextSwitchTo(cxt);
- pg_stext = heap_open(StatisticExtRelationId, RowExclusiveLock);
+ pg_stext = table_open(StatisticExtRelationId, RowExclusiveLock);
stats = fetch_statentries_for_relation(pg_stext, RelationGetRelid(onerel));
foreach(lc, stats)
@@ -130,7 +130,7 @@ BuildRelationExtStatistics(Relation onerel, double totalrows,
statext_store(pg_stext, stat->statOid, ndistinct, dependencies, stats);
}
- heap_close(pg_stext, RowExclusiveLock);
+ table_close(pg_stext, RowExclusiveLock);
MemoryContextSwitchTo(oldcxt);
MemoryContextDelete(cxt);
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
index b0dddab47a3..ea22b2a04ca 100644
--- a/src/backend/storage/large_object/inv_api.c
+++ b/src/backend/storage/large_object/inv_api.c
@@ -84,7 +84,7 @@ open_lo_relation(void)
/* Use RowExclusiveLock since we might either read or write */
if (lo_heap_r == NULL)
- lo_heap_r = heap_open(LargeObjectRelationId, RowExclusiveLock);
+ lo_heap_r = table_open(LargeObjectRelationId, RowExclusiveLock);
if (lo_index_r == NULL)
lo_index_r = index_open(LargeObjectLOidPNIndexId, RowExclusiveLock);
@@ -113,7 +113,7 @@ close_lo_relation(bool isCommit)
if (lo_index_r)
index_close(lo_index_r, NoLock);
if (lo_heap_r)
- heap_close(lo_heap_r, NoLock);
+ table_close(lo_heap_r, NoLock);
CurrentResourceOwner = currentOwner;
}
@@ -141,7 +141,7 @@ myLargeObjectExists(Oid loid, Snapshot snapshot)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(loid));
- pg_lo_meta = heap_open(LargeObjectMetadataRelationId,
+ pg_lo_meta = table_open(LargeObjectMetadataRelationId,
AccessShareLock);
sd = systable_beginscan(pg_lo_meta,
@@ -154,7 +154,7 @@ myLargeObjectExists(Oid loid, Snapshot snapshot)
systable_endscan(sd);
- heap_close(pg_lo_meta, AccessShareLock);
+ table_close(pg_lo_meta, AccessShareLock);
return retval;
}
diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c
index de6a08ba555..3402ff860d3 100644
--- a/src/backend/utils/adt/enum.c
+++ b/src/backend/utils/adt/enum.c
@@ -403,7 +403,7 @@ enum_endpoint(Oid enumtypoid, ScanDirection direction)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(enumtypoid));
- enum_rel = heap_open(EnumRelationId, AccessShareLock);
+ enum_rel = table_open(EnumRelationId, AccessShareLock);
enum_idx = index_open(EnumTypIdSortOrderIndexId, AccessShareLock);
enum_scan = systable_beginscan_ordered(enum_rel, enum_idx, NULL,
1, &skey);
@@ -423,7 +423,7 @@ enum_endpoint(Oid enumtypoid, ScanDirection direction)
systable_endscan_ordered(enum_scan);
index_close(enum_idx, AccessShareLock);
- heap_close(enum_rel, AccessShareLock);
+ table_close(enum_rel, AccessShareLock);
return minmax;
}
@@ -562,7 +562,7 @@ enum_range_internal(Oid enumtypoid, Oid lower, Oid upper)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(enumtypoid));
- enum_rel = heap_open(EnumRelationId, AccessShareLock);
+ enum_rel = table_open(EnumRelationId, AccessShareLock);
enum_idx = index_open(EnumTypIdSortOrderIndexId, AccessShareLock);
enum_scan = systable_beginscan_ordered(enum_rel, enum_idx, NULL, 1, &skey);
@@ -598,7 +598,7 @@ enum_range_internal(Oid enumtypoid, Oid lower, Oid upper)
systable_endscan_ordered(enum_scan);
index_close(enum_idx, AccessShareLock);
- heap_close(enum_rel, AccessShareLock);
+ table_close(enum_rel, AccessShareLock);
/* and build the result array */
/* note this hardwires some details about the representation of Oid */
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 91de57e5ceb..d330a88e3c1 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -822,9 +822,9 @@ pg_get_replica_identity_index(PG_FUNCTION_ARGS)
Oid idxoid;
Relation rel;
- rel = heap_open(reloid, AccessShareLock);
+ rel = table_open(reloid, AccessShareLock);
idxoid = RelationGetReplicaIndex(rel);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
if (OidIsValid(idxoid))
PG_RETURN_OID(idxoid);
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index 049585f211c..e1ce907a4bc 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -301,7 +301,7 @@ RI_FKey_check(TriggerData *trigdata)
* SELECT FOR KEY SHARE will get on it.
*/
fk_rel = trigdata->tg_relation;
- pk_rel = heap_open(riinfo->pk_relid, RowShareLock);
+ pk_rel = table_open(riinfo->pk_relid, RowShareLock);
if (riinfo->confmatchtype == FKCONSTR_MATCH_PARTIAL)
ereport(ERROR,
@@ -316,7 +316,7 @@ RI_FKey_check(TriggerData *trigdata)
* No further check needed - an all-NULL key passes every type of
* foreign key constraint.
*/
- heap_close(pk_rel, RowShareLock);
+ table_close(pk_rel, RowShareLock);
return PointerGetDatum(NULL);
case RI_KEYS_SOME_NULL:
@@ -341,7 +341,7 @@ RI_FKey_check(TriggerData *trigdata)
errdetail("MATCH FULL does not allow mixing of null and nonnull key values."),
errtableconstraint(fk_rel,
NameStr(riinfo->conname))));
- heap_close(pk_rel, RowShareLock);
+ table_close(pk_rel, RowShareLock);
return PointerGetDatum(NULL);
case FKCONSTR_MATCH_SIMPLE:
@@ -350,7 +350,7 @@ RI_FKey_check(TriggerData *trigdata)
* MATCH SIMPLE - if ANY column is null, the key passes
* the constraint.
*/
- heap_close(pk_rel, RowShareLock);
+ table_close(pk_rel, RowShareLock);
return PointerGetDatum(NULL);
case FKCONSTR_MATCH_PARTIAL:
@@ -364,7 +364,7 @@ RI_FKey_check(TriggerData *trigdata)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("MATCH PARTIAL not yet implemented")));
- heap_close(pk_rel, RowShareLock);
+ table_close(pk_rel, RowShareLock);
return PointerGetDatum(NULL);
default:
@@ -445,7 +445,7 @@ RI_FKey_check(TriggerData *trigdata)
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "SPI_finish failed");
- heap_close(pk_rel, RowShareLock);
+ table_close(pk_rel, RowShareLock);
return PointerGetDatum(NULL);
}
@@ -707,7 +707,7 @@ ri_restrict(TriggerData *trigdata, bool is_no_action)
* fk_rel is opened in RowShareLock mode since that's what our eventual
* SELECT FOR KEY SHARE will get on it.
*/
- fk_rel = heap_open(riinfo->fk_relid, RowShareLock);
+ fk_rel = table_open(riinfo->fk_relid, RowShareLock);
pk_rel = trigdata->tg_relation;
old_row = trigdata->tg_trigtuple;
@@ -735,7 +735,7 @@ ri_restrict(TriggerData *trigdata, bool is_no_action)
if (is_no_action &&
ri_Check_Pk_Match(pk_rel, fk_rel, old_row, riinfo))
{
- heap_close(fk_rel, RowShareLock);
+ table_close(fk_rel, RowShareLock);
return PointerGetDatum(NULL);
}
@@ -808,7 +808,7 @@ ri_restrict(TriggerData *trigdata, bool is_no_action)
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "SPI_finish failed");
- heap_close(fk_rel, RowShareLock);
+ table_close(fk_rel, RowShareLock);
return PointerGetDatum(NULL);
@@ -867,7 +867,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
* fk_rel is opened in RowExclusiveLock mode since that's what our
* eventual DELETE will get on it.
*/
- fk_rel = heap_open(riinfo->fk_relid, RowExclusiveLock);
+ fk_rel = table_open(riinfo->fk_relid, RowExclusiveLock);
pk_rel = trigdata->tg_relation;
old_row = trigdata->tg_trigtuple;
@@ -948,7 +948,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "SPI_finish failed");
- heap_close(fk_rel, RowExclusiveLock);
+ table_close(fk_rel, RowExclusiveLock);
return PointerGetDatum(NULL);
@@ -1010,7 +1010,7 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
* fk_rel is opened in RowExclusiveLock mode since that's what our
* eventual UPDATE will get on it.
*/
- fk_rel = heap_open(riinfo->fk_relid, RowExclusiveLock);
+ fk_rel = table_open(riinfo->fk_relid, RowExclusiveLock);
pk_rel = trigdata->tg_relation;
new_row = trigdata->tg_newtuple;
old_row = trigdata->tg_trigtuple;
@@ -1104,7 +1104,7 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "SPI_finish failed");
- heap_close(fk_rel, RowExclusiveLock);
+ table_close(fk_rel, RowExclusiveLock);
return PointerGetDatum(NULL);
@@ -1197,7 +1197,7 @@ ri_setnull(TriggerData *trigdata)
* fk_rel is opened in RowExclusiveLock mode since that's what our
* eventual UPDATE will get on it.
*/
- fk_rel = heap_open(riinfo->fk_relid, RowExclusiveLock);
+ fk_rel = table_open(riinfo->fk_relid, RowExclusiveLock);
pk_rel = trigdata->tg_relation;
old_row = trigdata->tg_trigtuple;
@@ -1291,7 +1291,7 @@ ri_setnull(TriggerData *trigdata)
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "SPI_finish failed");
- heap_close(fk_rel, RowExclusiveLock);
+ table_close(fk_rel, RowExclusiveLock);
return PointerGetDatum(NULL);
@@ -1383,7 +1383,7 @@ ri_setdefault(TriggerData *trigdata)
* fk_rel is opened in RowExclusiveLock mode since that's what our
* eventual UPDATE will get on it.
*/
- fk_rel = heap_open(riinfo->fk_relid, RowExclusiveLock);
+ fk_rel = table_open(riinfo->fk_relid, RowExclusiveLock);
pk_rel = trigdata->tg_relation;
old_row = trigdata->tg_trigtuple;
@@ -1478,7 +1478,7 @@ ri_setdefault(TriggerData *trigdata)
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "SPI_finish failed");
- heap_close(fk_rel, RowExclusiveLock);
+ table_close(fk_rel, RowExclusiveLock);
/*
* If we just deleted or updated the PK row whose key was equal to
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 97eeabc8f04..2461d7f35ee 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -842,7 +842,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
/*
* Fetch the pg_trigger tuple by the Oid of the trigger
*/
- tgrel = heap_open(TriggerRelationId, AccessShareLock);
+ tgrel = table_open(TriggerRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
Anum_pg_trigger_oid,
@@ -857,7 +857,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
if (!HeapTupleIsValid(ht_trig))
{
systable_endscan(tgscan);
- heap_close(tgrel, AccessShareLock);
+ table_close(tgrel, AccessShareLock);
return NULL;
}
@@ -1078,7 +1078,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
/* Clean up */
systable_endscan(tgscan);
- heap_close(tgrel, AccessShareLock);
+ table_close(tgrel, AccessShareLock);
return buf.data;
}
@@ -1882,7 +1882,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
SysScanDesc scandesc;
ScanKeyData scankey[1];
Snapshot snapshot = RegisterSnapshot(GetTransactionSnapshot());
- Relation relation = heap_open(ConstraintRelationId, AccessShareLock);
+ Relation relation = table_open(ConstraintRelationId, AccessShareLock);
ScanKeyInit(&scankey[0],
Anum_pg_constraint_oid,
@@ -1909,7 +1909,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
if (missing_ok)
{
systable_endscan(scandesc);
- heap_close(relation, AccessShareLock);
+ table_close(relation, AccessShareLock);
return NULL;
}
elog(ERROR, "could not find tuple for constraint %u", constraintId);
@@ -2260,7 +2260,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
/* Cleanup */
systable_endscan(scandesc);
- heap_close(relation, AccessShareLock);
+ table_close(relation, AccessShareLock);
return buf.data;
}
@@ -2471,7 +2471,7 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
column, tablerv->relname)));
/* Search the dependency table for the dependent sequence */
- depRel = heap_open(DependRelationId, AccessShareLock);
+ depRel = table_open(DependRelationId, AccessShareLock);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
@@ -2510,7 +2510,7 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
}
systable_endscan(scan);
- heap_close(depRel, AccessShareLock);
+ table_close(depRel, AccessShareLock);
if (OidIsValid(sequenceId))
{
@@ -4790,7 +4790,7 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc,
if (ev_action != NULL)
actions = (List *) stringToNode(ev_action);
- ev_relation = heap_open(ev_class, AccessShareLock);
+ ev_relation = table_open(ev_class, AccessShareLock);
/*
* Build the rules definition text
@@ -4924,7 +4924,7 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc,
appendStringInfoChar(buf, ';');
}
- heap_close(ev_relation, AccessShareLock);
+ table_close(ev_relation, AccessShareLock);
}
@@ -4991,13 +4991,13 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc,
return;
}
- ev_relation = heap_open(ev_class, AccessShareLock);
+ ev_relation = table_open(ev_class, AccessShareLock);
get_query_def(query, buf, NIL, RelationGetDescr(ev_relation),
prettyFlags, wrapColumn, 0);
appendStringInfoChar(buf, ';');
- heap_close(ev_relation, AccessShareLock);
+ table_close(ev_relation, AccessShareLock);
}
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 71cfe6499ca..bdb7d708279 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -5547,7 +5547,7 @@ get_actual_variable_range(PlannerInfo *root, VariableStatData *vardata,
* already have at least AccessShareLock on the table, but not
* necessarily on the index.
*/
- heapRel = heap_open(rte->relid, NoLock);
+ heapRel = table_open(rte->relid, NoLock);
indexRel = index_open(index->indexoid, AccessShareLock);
/* extract index key information from the index's pg_index info */
@@ -5668,7 +5668,7 @@ get_actual_variable_range(PlannerInfo *root, VariableStatData *vardata,
ExecDropSingleTupleTableSlot(slot);
index_close(indexRel, AccessShareLock);
- heap_close(heapRel, NoLock);
+ table_close(heapRel, NoLock);
MemoryContextSwitchTo(oldcontext);
FreeExecutorState(estate);
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index b016ab3c6c9..8097097f7bb 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -337,7 +337,7 @@ currtid_for_view(Relation viewrel, ItemPointer tid)
rte = rt_fetch(var->varno, query->rtable);
if (rte)
{
- heap_close(viewrel, AccessShareLock);
+ table_close(viewrel, AccessShareLock);
return DirectFunctionCall2(currtid_byreloid, ObjectIdGetDatum(rte->relid), PointerGetDatum(tid));
}
}
@@ -366,7 +366,7 @@ currtid_byreloid(PG_FUNCTION_ARGS)
PG_RETURN_ITEMPOINTER(result);
}
- rel = heap_open(reloid, AccessShareLock);
+ rel = table_open(reloid, AccessShareLock);
aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
ACL_SELECT);
@@ -383,7 +383,7 @@ currtid_byreloid(PG_FUNCTION_ARGS)
heap_get_latest_tid(rel, snapshot, result);
UnregisterSnapshot(snapshot);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
PG_RETURN_ITEMPOINTER(result);
}
@@ -400,7 +400,7 @@ currtid_byrelname(PG_FUNCTION_ARGS)
Snapshot snapshot;
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
- rel = heap_openrv(relrv, AccessShareLock);
+ rel = table_openrv(relrv, AccessShareLock);
aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
ACL_SELECT);
@@ -418,7 +418,7 @@ currtid_byrelname(PG_FUNCTION_ARGS)
heap_get_latest_tid(rel, snapshot, result);
UnregisterSnapshot(snapshot);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
PG_RETURN_ITEMPOINTER(result);
}
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index 7c04586ad5e..11a5d706fd8 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -2584,10 +2584,10 @@ table_to_xmlschema(PG_FUNCTION_ARGS)
const char *result;
Relation rel;
- rel = heap_open(relid, AccessShareLock);
+ rel = table_open(relid, AccessShareLock);
result = map_sql_table_to_xmlschema(rel->rd_att, relid, nulls,
tableforest, targetns);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
PG_RETURN_XML_P(cstring_to_xmltype(result));
}
@@ -2658,10 +2658,10 @@ table_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
Relation rel;
const char *xmlschema;
- rel = heap_open(relid, AccessShareLock);
+ rel = table_open(relid, AccessShareLock);
xmlschema = map_sql_table_to_xmlschema(rel->rd_att, relid, nulls,
tableforest, targetns);
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
PG_RETURN_XML_P(stringinfo_to_xmltype(table_to_xml_internal(relid,
xmlschema, nulls, tableforest,
@@ -2819,9 +2819,9 @@ schema_to_xmlschema_internal(const char *schemaname, bool nulls,
{
Relation rel;
- rel = heap_open(lfirst_oid(cell), AccessShareLock);
+ rel = table_open(lfirst_oid(cell), AccessShareLock);
tupdesc_list = lappend(tupdesc_list, CreateTupleDescCopy(rel->rd_att));
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
appendStringInfoString(result,
@@ -2959,9 +2959,9 @@ database_to_xmlschema_internal(bool nulls, bool tableforest,
{
Relation rel;
- rel = heap_open(lfirst_oid(cell), AccessShareLock);
+ rel = table_open(lfirst_oid(cell), AccessShareLock);
tupdesc_list = lappend(tupdesc_list, CreateTupleDescCopy(rel->rd_att));
- heap_close(rel, NoLock);
+ table_close(rel, NoLock);
}
appendStringInfoString(result,
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index 2123117f8b0..231c370c6b7 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -938,7 +938,7 @@ CatalogCacheInitializeCache(CatCache *cache)
CatalogCacheInitializeCache_DEBUG1;
- relation = heap_open(cache->cc_reloid, AccessShareLock);
+ relation = table_open(cache->cc_reloid, AccessShareLock);
/*
* switch to the cache context so our allocations do not vanish at the end
@@ -965,7 +965,7 @@ CatalogCacheInitializeCache(CatCache *cache)
*/
MemoryContextSwitchTo(oldcxt);
- heap_close(relation, AccessShareLock);
+ table_close(relation, AccessShareLock);
CACHE3_elog(DEBUG2, "CatalogCacheInitializeCache: %s, %d keys",
cache->cc_relname, cache->cc_nkeys);
@@ -1357,7 +1357,7 @@ SearchCatCacheMiss(CatCache *cache,
*
* 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 heap_open(). This is OK. It's even possible for one
+ * 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
@@ -1365,7 +1365,7 @@ SearchCatCacheMiss(CatCache *cache,
* This case is rare enough that it's not worth expending extra cycles to
* detect.
*/
- relation = heap_open(cache->cc_reloid, AccessShareLock);
+ relation = table_open(cache->cc_reloid, AccessShareLock);
scandesc = systable_beginscan(relation,
cache->cc_indexoid,
@@ -1390,7 +1390,7 @@ SearchCatCacheMiss(CatCache *cache,
systable_endscan(scandesc);
- heap_close(relation, AccessShareLock);
+ table_close(relation, AccessShareLock);
/*
* If tuple was not found, we need to build a negative cache entry
@@ -1638,7 +1638,7 @@ SearchCatCacheList(CatCache *cache,
cur_skey[2].sk_argument = v3;
cur_skey[3].sk_argument = v4;
- relation = heap_open(cache->cc_reloid, AccessShareLock);
+ relation = table_open(cache->cc_reloid, AccessShareLock);
scandesc = systable_beginscan(relation,
cache->cc_indexoid,
@@ -1705,7 +1705,7 @@ SearchCatCacheList(CatCache *cache,
systable_endscan(scandesc);
- heap_close(relation, AccessShareLock);
+ table_close(relation, AccessShareLock);
/* Now we can build the CatCList entry. */
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 93856e30875..9a0980570ed 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -338,7 +338,7 @@ ScanPgRelation(Oid targetRelId, bool indexOK, bool force_non_historic)
* without a pg_internal.init file). The caller can also force a heap
* scan by setting indexOK == false.
*/
- pg_class_desc = heap_open(RelationRelationId, AccessShareLock);
+ pg_class_desc = table_open(RelationRelationId, AccessShareLock);
/*
* The caller might need a tuple that's newer than the one the historic
@@ -365,7 +365,7 @@ ScanPgRelation(Oid targetRelId, bool indexOK, bool force_non_historic)
/* all done */
systable_endscan(pg_class_scan);
- heap_close(pg_class_desc, AccessShareLock);
+ table_close(pg_class_desc, AccessShareLock);
return pg_class_tuple;
}
@@ -528,7 +528,7 @@ RelationBuildTupleDesc(Relation relation)
* built the critical relcache entries (this includes initdb and startup
* without a pg_internal.init file).
*/
- pg_attribute_desc = heap_open(AttributeRelationId, AccessShareLock);
+ pg_attribute_desc = table_open(AttributeRelationId, AccessShareLock);
pg_attribute_scan = systable_beginscan(pg_attribute_desc,
AttributeRelidNumIndexId,
criticalRelcachesBuilt,
@@ -635,7 +635,7 @@ RelationBuildTupleDesc(Relation relation)
* end the scan and close the attribute relation
*/
systable_endscan(pg_attribute_scan);
- heap_close(pg_attribute_desc, AccessShareLock);
+ table_close(pg_attribute_desc, AccessShareLock);
if (need != 0)
elog(ERROR, "catalog is missing %d attribute(s) for relid %u",
@@ -769,7 +769,7 @@ RelationBuildRuleLock(Relation relation)
* emergency-recovery operations (ie, IgnoreSystemIndexes). This in turn
* ensures that rules will be fired in name order.
*/
- rewrite_desc = heap_open(RewriteRelationId, AccessShareLock);
+ rewrite_desc = table_open(RewriteRelationId, AccessShareLock);
rewrite_tupdesc = RelationGetDescr(rewrite_desc);
rewrite_scan = systable_beginscan(rewrite_desc,
RewriteRelRulenameIndexId,
@@ -850,7 +850,7 @@ RelationBuildRuleLock(Relation relation)
* end the scan and close the attribute relation
*/
systable_endscan(rewrite_scan);
- heap_close(rewrite_desc, AccessShareLock);
+ table_close(rewrite_desc, AccessShareLock);
/*
* there might not be any rules (if relhasrules is out-of-date)
@@ -1646,7 +1646,7 @@ LookupOpclassInfo(Oid operatorClassOid,
Anum_pg_opclass_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(operatorClassOid));
- rel = heap_open(OperatorClassRelationId, AccessShareLock);
+ rel = table_open(OperatorClassRelationId, AccessShareLock);
scan = systable_beginscan(rel, OpclassOidIndexId, indexOK,
NULL, 1, skey);
@@ -1661,7 +1661,7 @@ LookupOpclassInfo(Oid operatorClassOid,
elog(ERROR, "could not find tuple for opclass %u", operatorClassOid);
systable_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
/*
* Scan pg_amproc to obtain support procs for the opclass. We only fetch
@@ -1681,7 +1681,7 @@ LookupOpclassInfo(Oid operatorClassOid,
Anum_pg_amproc_amprocrighttype,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(opcentry->opcintype));
- rel = heap_open(AccessMethodProcedureRelationId, AccessShareLock);
+ rel = table_open(AccessMethodProcedureRelationId, AccessShareLock);
scan = systable_beginscan(rel, AccessMethodProcedureIndexId, indexOK,
NULL, 3, skey);
@@ -1699,7 +1699,7 @@ LookupOpclassInfo(Oid operatorClassOid,
}
systable_endscan(scan);
- heap_close(rel, AccessShareLock);
+ table_close(rel, AccessShareLock);
}
opcentry->valid = true;
@@ -3352,7 +3352,7 @@ RelationSetNewRelfilenode(Relation relation, char persistence,
/*
* Get a writable copy of the pg_class tuple for the given relation.
*/
- pg_class = heap_open(RelationRelationId, RowExclusiveLock);
+ pg_class = table_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy1(RELOID,
ObjectIdGetDatum(RelationGetRelid(relation)));
@@ -3406,7 +3406,7 @@ RelationSetNewRelfilenode(Relation relation, char persistence,
heap_freetuple(tuple);
- heap_close(pg_class, RowExclusiveLock);
+ table_close(pg_class, RowExclusiveLock);
/*
* Make the pg_class row change visible, as well as the relation map
@@ -3942,7 +3942,7 @@ AttrDefaultFetch(Relation relation)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
- adrel = heap_open(AttrDefaultRelationId, AccessShareLock);
+ adrel = table_open(AttrDefaultRelationId, AccessShareLock);
adscan = systable_beginscan(adrel, AttrDefaultIndexId, true,
NULL, 1, &skey);
found = 0;
@@ -3987,7 +3987,7 @@ AttrDefaultFetch(Relation relation)
}
systable_endscan(adscan);
- heap_close(adrel, AccessShareLock);
+ table_close(adrel, AccessShareLock);
}
/*
@@ -4009,7 +4009,7 @@ CheckConstraintFetch(Relation relation)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
- conrel = heap_open(ConstraintRelationId, AccessShareLock);
+ conrel = table_open(ConstraintRelationId, AccessShareLock);
conscan = systable_beginscan(conrel, ConstraintRelidTypidNameIndexId, true,
NULL, 1, skey);
@@ -4050,7 +4050,7 @@ CheckConstraintFetch(Relation relation)
}
systable_endscan(conscan);
- heap_close(conrel, AccessShareLock);
+ table_close(conrel, AccessShareLock);
if (found != ncheck)
elog(ERROR, "%d constraint record(s) missing for rel %s",
@@ -4121,7 +4121,7 @@ RelationGetFKeyList(Relation relation)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
- conrel = heap_open(ConstraintRelationId, AccessShareLock);
+ conrel = table_open(ConstraintRelationId, AccessShareLock);
conscan = systable_beginscan(conrel, ConstraintRelidTypidNameIndexId, true,
NULL, 1, &skey);
@@ -4201,7 +4201,7 @@ RelationGetFKeyList(Relation relation)
}
systable_endscan(conscan);
- heap_close(conrel, AccessShareLock);
+ table_close(conrel, AccessShareLock);
/* Now save a copy of the completed list in the relcache entry. */
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
@@ -4279,7 +4279,7 @@ RelationGetIndexList(Relation relation)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
- indrel = heap_open(IndexRelationId, AccessShareLock);
+ indrel = table_open(IndexRelationId, AccessShareLock);
indscan = systable_beginscan(indrel, IndexIndrelidIndexId, true,
NULL, 1, &skey);
@@ -4320,7 +4320,7 @@ RelationGetIndexList(Relation relation)
systable_endscan(indscan);
- heap_close(indrel, AccessShareLock);
+ table_close(indrel, AccessShareLock);
/* Now save a copy of the completed list in the relcache entry. */
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
@@ -4395,7 +4395,7 @@ RelationGetStatExtList(Relation relation)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
- indrel = heap_open(StatisticExtRelationId, AccessShareLock);
+ indrel = table_open(StatisticExtRelationId, AccessShareLock);
indscan = systable_beginscan(indrel, StatisticExtRelidIndexId, true,
NULL, 1, &skey);
@@ -4408,7 +4408,7 @@ RelationGetStatExtList(Relation relation)
systable_endscan(indscan);
- heap_close(indrel, AccessShareLock);
+ table_close(indrel, AccessShareLock);
/* Now save a copy of the completed list in the relcache entry. */
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
@@ -5060,7 +5060,7 @@ RelationGetExclusionInfo(Relation indexRelation,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(indexRelation->rd_index->indrelid));
- conrel = heap_open(ConstraintRelationId, AccessShareLock);
+ conrel = table_open(ConstraintRelationId, AccessShareLock);
conscan = systable_beginscan(conrel, ConstraintRelidTypidNameIndexId, true,
NULL, 1, skey);
found = false;
@@ -5104,7 +5104,7 @@ RelationGetExclusionInfo(Relation indexRelation,
}
systable_endscan(conscan);
- heap_close(conrel, AccessShareLock);
+ table_close(conrel, AccessShareLock);
if (!found)
elog(ERROR, "exclusion constraint record missing for rel %s",
diff --git a/src/backend/utils/cache/relfilenodemap.c b/src/backend/utils/cache/relfilenodemap.c
index b766dbb21c0..c506dc9dec4 100644
--- a/src/backend/utils/cache/relfilenodemap.c
+++ b/src/backend/utils/cache/relfilenodemap.c
@@ -192,7 +192,7 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
*/
/* check for plain relations by looking in pg_class */
- relation = heap_open(RelationRelationId, AccessShareLock);
+ relation = table_open(RelationRelationId, AccessShareLock);
/* copy scankey to local copy, it will be modified during the scan */
memcpy(skey, relfilenode_skey, sizeof(skey));
@@ -226,7 +226,7 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
}
systable_endscan(scandesc);
- heap_close(relation, AccessShareLock);
+ table_close(relation, AccessShareLock);
/* check for tables that are mapped but not shared */
if (!found)
diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c
index 4e0fdb7b55a..417c494cd05 100644
--- a/src/backend/utils/cache/ts_cache.c
+++ b/src/backend/utils/cache/ts_cache.c
@@ -481,7 +481,7 @@ lookup_ts_config_cache(Oid cfgId)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(cfgId));
- maprel = heap_open(TSConfigMapRelationId, AccessShareLock);
+ maprel = table_open(TSConfigMapRelationId, AccessShareLock);
mapidx = index_open(TSConfigMapIndexId, AccessShareLock);
mapscan = systable_beginscan_ordered(maprel, mapidx,
NULL, 1, &mapskey);
@@ -522,7 +522,7 @@ lookup_ts_config_cache(Oid cfgId)
systable_endscan_ordered(mapscan);
index_close(mapidx, AccessShareLock);
- heap_close(maprel, AccessShareLock);
+ table_close(maprel, AccessShareLock);
if (ndicts > 0)
{
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c
index b1931dad95e..bca2dc118d9 100644
--- a/src/backend/utils/cache/typcache.c
+++ b/src/backend/utils/cache/typcache.c
@@ -915,7 +915,7 @@ load_domaintype_info(TypeCacheEntry *typentry)
* constraints for not just this domain, but any ancestor domains, so the
* outer loop crawls up the domain stack.
*/
- conRel = heap_open(ConstraintRelationId, AccessShareLock);
+ conRel = table_open(ConstraintRelationId, AccessShareLock);
for (;;)
{
@@ -1056,7 +1056,7 @@ load_domaintype_info(TypeCacheEntry *typentry)
ReleaseSysCache(tup);
}
- heap_close(conRel, AccessShareLock);
+ table_close(conRel, AccessShareLock);
/*
* Only need to add one NOT NULL check regardless of how many domains in
@@ -2347,7 +2347,7 @@ load_enum_cache_data(TypeCacheEntry *tcache)
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(tcache->type_id));
- enum_rel = heap_open(EnumRelationId, AccessShareLock);
+ enum_rel = table_open(EnumRelationId, AccessShareLock);
enum_scan = systable_beginscan(enum_rel,
EnumTypIdLabelIndexId,
true, NULL,
@@ -2368,7 +2368,7 @@ load_enum_cache_data(TypeCacheEntry *tcache)
}
systable_endscan(enum_scan);
- heap_close(enum_rel, AccessShareLock);
+ table_close(enum_rel, AccessShareLock);
/* Sort the items into OID order */
qsort(items, numitems, sizeof(EnumItem), enum_oid_cmp);
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 7415c4faabc..5dc1d99f78e 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -113,7 +113,7 @@ GetDatabaseTuple(const char *dbname)
* built the critical shared relcache entries (i.e., we're starting up
* without a shared relcache cache file).
*/
- relation = heap_open(DatabaseRelationId, AccessShareLock);
+ relation = table_open(DatabaseRelationId, AccessShareLock);
scan = systable_beginscan(relation, DatabaseNameIndexId,
criticalSharedRelcachesBuilt,
NULL,
@@ -127,7 +127,7 @@ GetDatabaseTuple(const char *dbname)
/* all done */
systable_endscan(scan);
- heap_close(relation, AccessShareLock);
+ table_close(relation, AccessShareLock);
return tuple;
}
@@ -156,7 +156,7 @@ GetDatabaseTupleByOid(Oid dboid)
* built the critical shared relcache entries (i.e., we're starting up
* without a shared relcache cache file).
*/
- relation = heap_open(DatabaseRelationId, AccessShareLock);
+ relation = table_open(DatabaseRelationId, AccessShareLock);
scan = systable_beginscan(relation, DatabaseOidIndexId,
criticalSharedRelcachesBuilt,
NULL,
@@ -170,7 +170,7 @@ GetDatabaseTupleByOid(Oid dboid)
/* all done */
systable_endscan(scan);
- heap_close(relation, AccessShareLock);
+ table_close(relation, AccessShareLock);
return tuple;
}
@@ -1158,7 +1158,7 @@ process_settings(Oid databaseid, Oid roleid)
if (!IsUnderPostmaster)
return;
- relsetting = heap_open(DbRoleSettingRelationId, AccessShareLock);
+ relsetting = table_open(DbRoleSettingRelationId, AccessShareLock);
/* read all the settings under the same snapshot for efficiency */
snapshot = RegisterSnapshot(GetCatalogSnapshot(DbRoleSettingRelationId));
@@ -1170,7 +1170,7 @@ process_settings(Oid databaseid, Oid roleid)
ApplySetting(snapshot, InvalidOid, InvalidOid, relsetting, PGC_S_GLOBAL);
UnregisterSnapshot(snapshot);
- heap_close(relsetting, AccessShareLock);
+ table_close(relsetting, AccessShareLock);
}
/*
@@ -1250,13 +1250,13 @@ ThereIsAtLeastOneRole(void)
HeapScanDesc scan;
bool result;
- pg_authid_rel = heap_open(AuthIdRelationId, AccessShareLock);
+ pg_authid_rel = table_open(AuthIdRelationId, AccessShareLock);
scan = heap_beginscan_catalog(pg_authid_rel, 0, NULL);
result = (heap_getnext(scan, ForwardScanDirection) != NULL);
heap_endscan(scan);
- heap_close(pg_authid_rel, AccessShareLock);
+ table_close(pg_authid_rel, AccessShareLock);
return result;
}
diff --git a/src/backend/utils/misc/queryenvironment.c b/src/backend/utils/misc/queryenvironment.c
index 165e819e47a..25001600282 100644
--- a/src/backend/utils/misc/queryenvironment.c
+++ b/src/backend/utils/misc/queryenvironment.c
@@ -135,9 +135,9 @@ ENRMetadataGetTupDesc(EphemeralNamedRelationMetadata enrmd)
{
Relation relation;
- relation = heap_open(enrmd->reliddesc, NoLock);
+ relation = table_open(enrmd->reliddesc, NoLock);
tupdesc = relation->rd_att;
- heap_close(relation, NoLock);
+ table_close(relation, NoLock);
}
return tupdesc;
--
2.18.0.rc2.dirty
On Tue, Jan 15, 2019 at 1:43 PM Andres Freund <andres@anarazel.de> wrote:
Hi,
On 2019-01-11 12:01:36 -0500, Robert Haas wrote:
On Thu, Jan 10, 2019 at 7:05 PM Andres Freund <andres@anarazel.de>
wrote:
ISTM that the first block would best belong into new files like
access/rel[ation].h and access/common/rel[ation].h.+1.
I think the second
set should be renamed to be table_open() (with backward compat
redirects, there's way way too many references) and should go into
access/table.h access/table/table.c alongside tableam.[ch],Sounds reasonable.
but I could
also see just putting them into relation.[ch].I would view that as a less-preferred alternative, but not crazy.
Here's a set of patches. Not commit quality, but enough to discuss.
The first patch, the only really interesting one, splits out
relation_(open|openrv|openrv_extended|close) into access/relation.h and
access/common/relation.c
and
heap_(open|openrv|openrv_extended|close) into access/table.h and
access/table/table.cIt's worthwhile to note that there's another header named
nodes/relation.h. But there's also utils/rel.h, so I couldn't think of a
another good name.
access/relation.[c|h] name is fine. Or how about access/rel.[c|h],
because nodes/relation.h is related to planner. utils/rel.h is some how
related to relation caches.
I'm basically thinking that table.h, even in the post pluggable storage
world, should not contain lower level functionality like dispatching
into table-am (that'll reside in tableam.h). But e.g. a
simple_table_(insert|update|delete) could live there, as well as
potentially some other heap_ functionality strewn around the backend.I made table.h not include relation.h, which means that a few files
might need both. I'm not sure that's the right choice, but it seems
easier to extend that later if shows to be painful, than to do the
reverse.
The need of both relation.h and table.h into a single file is because of
use of both relation_open table_open functions. when I checked one
of the file where both headers are included, I found that it simply used
the relation_open function even the type of the relation is known.
I didn't check whether it is possible or not? In case if the kind of the
relation
is known at every caller of relation_open, it can be replaced with either
table_open or index_open or composite_type_open functions. So that
there may not need any of the relation functions needs to be exposed.
I've left the following in table.h:
/*
* heap_ used to be the prefix for these routines, and a lot of code will
just
* continue to work without adaptions after the introduction of pluggable
* storage, therefore just map these names.
*/
#define heap_open(r, l) table_open(r, l)
#define heap_openrv(r, l) table_openrv(r, l)
#define heap_openrv_extended(r, l, m) table_openrv_extended(r, l, m)
#define heap_close(r, l) table_close(r, l)and I think we should leave that in there for the forseeable future.
Above typedefs are good. They are useful to avoid any third party
extensions.
Regards,
Haribabu Kommi
Fujitsu Australia
On Tue, Jan 15, 2019 at 10:23 PM Haribabu Kommi
<kommi.haribabu@gmail.com> wrote:
access/relation.[c|h] name is fine. Or how about access/rel.[c|h],
because nodes/relation.h is related to planner. utils/rel.h is some how
related to relation caches.
Insofar as we can reasonably do so, I'd rather pick unique names for
header files. I know that there's no law that rules out having both
nodes/relation.h and access/relation.h, or likewise utils/rel.h and
access/rel.h; the computer won't be confused. But it might create
some confusion among human beings, so my vote is for avoiding that
sort of thing if we can.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Robert Haas <robertmhaas@gmail.com> writes:
On Tue, Jan 15, 2019 at 10:23 PM Haribabu Kommi
<kommi.haribabu@gmail.com> wrote:access/relation.[c|h] name is fine. Or how about access/rel.[c|h],
because nodes/relation.h is related to planner. utils/rel.h is some how
related to relation caches.
Insofar as we can reasonably do so, I'd rather pick unique names for
header files.
+1
regards, tom lane
On January 16, 2019 8:08:09 AM PST, Robert Haas <robertmhaas@gmail.com> wrote:
On Tue, Jan 15, 2019 at 10:23 PM Haribabu Kommi
<kommi.haribabu@gmail.com> wrote:access/relation.[c|h] name is fine. Or how about access/rel.[c|h],
because nodes/relation.h is related to planner. utils/rel.h is somehow
related to relation caches.
Insofar as we can reasonably do so, I'd rather pick unique names for
header files. I know that there's no law that rules out having both
nodes/relation.h and access/relation.h, or likewise utils/rel.h and
access/rel.h; the computer won't be confused. But it might create
some confusion among human beings, so my vote is for avoiding that
sort of thing if we can.
I prefer that too - if the new name isn't worse enough to make it hard to remember. I'd welcome suggestions that don't conflict...
Andres
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Hi,
On 2019-01-16 08:20:37 -0800, Andres Freund wrote:
On January 16, 2019 8:08:09 AM PST, Robert Haas <robertmhaas@gmail.com> wrote:
On Tue, Jan 15, 2019 at 10:23 PM Haribabu Kommi
<kommi.haribabu@gmail.com> wrote:access/relation.[c|h] name is fine. Or how about access/rel.[c|h],
because nodes/relation.h is related to planner. utils/rel.h is somehow
related to relation caches.
Insofar as we can reasonably do so, I'd rather pick unique names for
header files. I know that there's no law that rules out having both
nodes/relation.h and access/relation.h, or likewise utils/rel.h and
access/rel.h; the computer won't be confused. But it might create
some confusion among human beings, so my vote is for avoiding that
sort of thing if we can.I prefer that too - if the new name isn't worse enough to make it hard
to remember. I'd welcome suggestions that don't conflict...
Unless somebody comes up with a better suggestion I'm planning to press
ahead with this one. It's large enough to be a bit of a pain to maintain
over time... I'm absolutely not wedded to access/relation.h, so I'm
happy with another good suggestion, or somebody revising it subsequently.
Greetings,
Andres Freund
On 2019-01-18 14:19:41 -0800, Andres Freund wrote:
Hi,
On 2019-01-16 08:20:37 -0800, Andres Freund wrote:
On January 16, 2019 8:08:09 AM PST, Robert Haas <robertmhaas@gmail.com> wrote:
On Tue, Jan 15, 2019 at 10:23 PM Haribabu Kommi
<kommi.haribabu@gmail.com> wrote:access/relation.[c|h] name is fine. Or how about access/rel.[c|h],
because nodes/relation.h is related to planner. utils/rel.h is somehow
related to relation caches.
Insofar as we can reasonably do so, I'd rather pick unique names for
header files. I know that there's no law that rules out having both
nodes/relation.h and access/relation.h, or likewise utils/rel.h and
access/rel.h; the computer won't be confused. But it might create
some confusion among human beings, so my vote is for avoiding that
sort of thing if we can.I prefer that too - if the new name isn't worse enough to make it hard
to remember. I'd welcome suggestions that don't conflict...Unless somebody comes up with a better suggestion I'm planning to press
ahead with this one. It's large enough to be a bit of a pain to maintain
over time... I'm absolutely not wedded to access/relation.h, so I'm
happy with another good suggestion, or somebody revising it subsequently.
And pushed. If somebody is interested in renaming/splitting nodes/relation.h, I
think that'd be good, but if not, it's also not terrible.
- Andres
On 2018-12-19 14:21:29 -0500, Robert Haas wrote:
On Tue, Dec 18, 2018 at 11:17 PM Andres Freund <andres@anarazel.de> wrote:
The current pluggable table storage patchset [1] introduces the ability
to specify the access method of a table (CREATE TABLE ... USING
"ident"). The patchset currently names the current storage method
(i.e. heapam.c et al) "heap" (whereas e.g. zheap's in named, drumroll,
zheap).I vote for calling the current heap "heap" - i.e. what the patchset is
currently doing. As others have already noted, that's a perfectly
good word for storing stuff in no particular order, and it's also a
term with a very long history. If we call it "oheap" or "pile" or
something based on a clever pun, then we'll just be making users learn
a new word for, as far as I can see, no real benefit.Another would be to be aggressive in renaming, and deconflict by
renaming functions like heap_create[_with_catalog] etc to sound more
accurate. I think that has some appeal, because a lot of those names
aren't describing their tasks particularly well.I like that option.
In that vein, does anybody have an opinion about the naming of
a) HeapUpdateFailureData, which will be used for different AMs
b) HTSU_Result itself, which'll be the return parameter for
update/delete via tableam
c) Naming of HTSU_Result members (like HeapTupleBeingUpdated)
I can see us doing several things:
1) Live with the old names, explain the naming as historical baggage
2) Replace names, but add typedefs / #defines for backward compatibility
3) Rename without backward compatibility
If we were to go with 2) or 3), does anybody want to make a case for
renaming the HTSU_Result members? They've been confusing people for a
long while...
In the patch it's currently:
typedef enum
{
HeapTupleMayBeUpdated, /* or deleted */
HeapTupleInvisible,
HeapTupleSelfUpdated, /* or deleted */
HeapTupleUpdated,
HeapTupleDeleted,
HeapTupleBeingUpdated, /* or deleted */
HeapTupleWouldBlock /* can be returned by heap_tuple_lock */
} HTSU_Result;
Greetings,
Andres Freund
On Tue, Mar 12, 2019 at 8:39 PM Andres Freund <andres@anarazel.de> wrote:
I like that option.
In that vein, does anybody have an opinion about the naming of
a) HeapUpdateFailureData, which will be used for different AMs
b) HTSU_Result itself, which'll be the return parameter for
update/delete via tableam
c) Naming of HTSU_Result members (like HeapTupleBeingUpdated)I can see us doing several things:
1) Live with the old names, explain the naming as historical baggage
2) Replace names, but add typedefs / #defines for backward compatibility
3) Rename without backward compatibility
I think I have a mild preference for renaming HeapUpdateFailureData to
TableUpdateFailureData, but I'm less excited about renaming
HTSU_Result or its members. I don't care if you want to do
s/HeapTuple/TableTuple/g and s/HTSU_Result/TTSU_Result/g though.
If we were to go with 2) or 3), does anybody want to make a case for
renaming the HTSU_Result members? They've been confusing people for a
long while...In the patch it's currently:
typedef enum
{
HeapTupleMayBeUpdated, /* or deleted */
HeapTupleInvisible,
HeapTupleSelfUpdated, /* or deleted */
HeapTupleUpdated,
HeapTupleDeleted,
HeapTupleBeingUpdated, /* or deleted */
HeapTupleWouldBlock /* can be returned by heap_tuple_lock */
} HTSU_Result;
I think you're getting at the idea that HeapTupleMayBeUpdated really
means NoProblemsFound, but I would be inclined to leave that alone.
It's confusing, but the people who need to know what it means probably
have the current name figured out, and would have to learn what some
new name means.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Hi,
On 2019-03-13 08:29:47 -0400, Robert Haas wrote:
On Tue, Mar 12, 2019 at 8:39 PM Andres Freund <andres@anarazel.de> wrote:
I like that option.
In that vein, does anybody have an opinion about the naming of
a) HeapUpdateFailureData, which will be used for different AMs
b) HTSU_Result itself, which'll be the return parameter for
update/delete via tableam
c) Naming of HTSU_Result members (like HeapTupleBeingUpdated)I can see us doing several things:
1) Live with the old names, explain the naming as historical baggage
2) Replace names, but add typedefs / #defines for backward compatibility
3) Rename without backward compatibilityI think I have a mild preference for renaming HeapUpdateFailureData to
TableUpdateFailureData, but I'm less excited about renaming
HTSU_Result or its members. I don't care if you want to do
s/HeapTuple/TableTuple/g and s/HTSU_Result/TTSU_Result/g though.
Anybody else got an opion on those? I personally don't have meaningful
feelings on this. I'm mildly inclined to the renamings suggested
above.
If we were to go with 2) or 3), does anybody want to make a case for
renaming the HTSU_Result members? They've been confusing people for a
long while...In the patch it's currently:
typedef enum
{
HeapTupleMayBeUpdated, /* or deleted */
HeapTupleInvisible,
HeapTupleSelfUpdated, /* or deleted */
HeapTupleUpdated,
HeapTupleDeleted,
HeapTupleBeingUpdated, /* or deleted */
HeapTupleWouldBlock /* can be returned by heap_tuple_lock */
} HTSU_Result;I think you're getting at the idea that HeapTupleMayBeUpdated really
means NoProblemsFound, but I would be inclined to leave that alone.
It's confusing, but the people who need to know what it means probably
have the current name figured out, and would have to learn what some
new name means.
That, and that HeapTupleMayBeUpdated, HeapTupleBeingUpdated also can
mean that the tuple is actually being deleted, not updated. The patch
currently adds HeapTupleDeleted (which is currently subsumed in
HeapTupleUpdated), to allow callsites to distinguish between those two
cases - but we don't need callsites to distinguish between
HeapTupleMayBeUpdated / Deleted (there's no meaningful difference imo),
and HeapTupleBeingUpdated / Deleted currently also isn't necessary,
although there's certainly a meaningful difference.
Greetings,
Andres Freund
On 2019-03-18 16:24:40 -0700, Andres Freund wrote:
Hi,
On 2019-03-13 08:29:47 -0400, Robert Haas wrote:
On Tue, Mar 12, 2019 at 8:39 PM Andres Freund <andres@anarazel.de> wrote:
I like that option.
In that vein, does anybody have an opinion about the naming of
a) HeapUpdateFailureData, which will be used for different AMs
b) HTSU_Result itself, which'll be the return parameter for
update/delete via tableam
c) Naming of HTSU_Result members (like HeapTupleBeingUpdated)I can see us doing several things:
1) Live with the old names, explain the naming as historical baggage
2) Replace names, but add typedefs / #defines for backward compatibility
3) Rename without backward compatibilityI think I have a mild preference for renaming HeapUpdateFailureData to
TableUpdateFailureData, but I'm less excited about renaming
HTSU_Result or its members. I don't care if you want to do
s/HeapTuple/TableTuple/g and s/HTSU_Result/TTSU_Result/g though.Anybody else got an opion on those? I personally don't have meaningful
feelings on this. I'm mildly inclined to the renamings suggested
above.
What I now have is:
/*
* Result codes for table_{update,delete,lock}_tuple, and for visibility
* routines inside table AMs.
*/
typedef enum TM_Result
{
/* Signals that the action succeeded (i.e. update/delete performed) */
TableTupleMayBeModified,
/* The affected tuple wasn't visible to the relevant snapshot */
TableTupleInvisible,
/* The affected tuple was already modified by the calling backend */
TableTupleSelfModified,
/* The affected tuple was updated by another transaction */
TableTupleUpdated,
/* The affected tuple was deleted by another transaction */
TableTupleDeleted,
/*
* The affected tuple is currently being modified by another session. This
* will only be returned if (update/delete/lock)_tuple are instructed not
* to wait.
*/
TableTupleBeingModified,
/* lock couldn't be acquired, action skipped. Only used by lock_tuple */
TableTupleWouldBlock
} TM_Result;
I got rid of the SU part of the prefix, because SatisfiesUpdate isn't
actually exposed outside of the AMs.
I'm kinda wondering about replacing the TableTuple prefix with TableMod,
seems less confusing to me. I'm also wondering about replacing
*MayBeModified with *OK.
Right now I have
typedef enum TM_Result HTSU_Result;
#define HeapTupleMayBeUpdated TableTupleMayBeModified
#define HeapTupleInvisible TableTupleInvisible
#define HeapTupleSelfUpdated TableTupleSelfModified
#define HeapTupleUpdated TableTupleUpdated
#define HeapTupleDeleted TableTupleDeleted
#define HeapTupleBeingUpdated TableTupleBeingModified
#define HeapTupleWouldBlock TableTupleWouldBlock
in heapam.h (whereas the above is in tableam.h), for backward
compat. But I'm not sure it's worth it.
Greetings,
Andres Freund
On Tue, Mar 19, 2019 at 2:32 PM Andres Freund <andres@anarazel.de> wrote:
On 2019-03-18 16:24:40 -0700, Andres Freund wrote:
Hi,
On 2019-03-13 08:29:47 -0400, Robert Haas wrote:
On Tue, Mar 12, 2019 at 8:39 PM Andres Freund <andres@anarazel.de>
wrote:
I like that option.
In that vein, does anybody have an opinion about the naming of
a) HeapUpdateFailureData, which will be used for different AMs
b) HTSU_Result itself, which'll be the return parameter for
update/delete via tableam
c) Naming of HTSU_Result members (like HeapTupleBeingUpdated)I can see us doing several things:
1) Live with the old names, explain the naming as historical baggage
2) Replace names, but add typedefs / #defines for backwardcompatibility
3) Rename without backward compatibility
I think I have a mild preference for renaming HeapUpdateFailureData to
TableUpdateFailureData, but I'm less excited about renaming
HTSU_Result or its members. I don't care if you want to do
s/HeapTuple/TableTuple/g and s/HTSU_Result/TTSU_Result/g though.Anybody else got an opion on those? I personally don't have meaningful
feelings on this. I'm mildly inclined to the renamings suggested
above.What I now have is:
/*
* Result codes for table_{update,delete,lock}_tuple, and for visibility
* routines inside table AMs.
*/
typedef enum TM_Result
{
/* Signals that the action succeeded (i.e. update/delete
performed) */
TableTupleMayBeModified,/* The affected tuple wasn't visible to the relevant snapshot */
TableTupleInvisible,/* The affected tuple was already modified by the calling backend
*/
TableTupleSelfModified,/* The affected tuple was updated by another transaction */
TableTupleUpdated,/* The affected tuple was deleted by another transaction */
TableTupleDeleted,/*
* The affected tuple is currently being modified by another
session. This
* will only be returned if (update/delete/lock)_tuple are
instructed not
* to wait.
*/
TableTupleBeingModified,/* lock couldn't be acquired, action skipped. Only used by
lock_tuple */
TableTupleWouldBlock
} TM_Result;
With the above structure, it is easy to understand where and how these
values
are used.
so +1 to go with this change.
I'm kinda wondering about replacing the TableTuple prefix with TableMod,
seems less confusing to me.
One more way, how about just TupleUpdated and etc. Removing of Table?
The structure name also suggests as TM (IMO, it is TupleModication?)
I'm also wondering about replacing
*MayBeModified with *OK.
How about TupleModified? I am fine with *OK also.
Right now I have
typedef enum TM_Result HTSU_Result;
#define HeapTupleMayBeUpdated TableTupleMayBeModified
#define HeapTupleInvisible TableTupleInvisible
#define HeapTupleSelfUpdated TableTupleSelfModified
#define HeapTupleUpdated TableTupleUpdated
#define HeapTupleDeleted TableTupleDeleted
#define HeapTupleBeingUpdated TableTupleBeingModified
#define HeapTupleWouldBlock TableTupleWouldBlockin heapam.h (whereas the above is in tableam.h), for backward
compat. But I'm not sure it's worth it.
These old macros are pretty much used in the internal code, and I doubt
that any one depends directly on those macros. I vote for removal of
these backward compatibility macros.
Regards,
Haribabu Kommi
Fujitsu Australia
Hi,
On 2019-03-19 15:25:44 +1100, Haribabu Kommi wrote:
On Tue, Mar 19, 2019 at 2:32 PM Andres Freund <andres@anarazel.de> wrote:
I'm kinda wondering about replacing the TableTuple prefix with TableMod,
seems less confusing to me.
One more way, how about just TupleUpdated and etc. Removing of Table?
The structure name also suggests as TM (IMO, it is TupleModication?)
Enum members are in the global namespace. I could go for a TM_ prefix
however.
I'm also wondering about replacing
*MayBeModified with *OK.
How about TupleModified? I am fine with *OK also.
Hm, OK just seems nicer for lock_tuple, that's why I was wondering
about it, but I think my concern there is a bit pedantic.
Right now I have
typedef enum TM_Result HTSU_Result;
#define HeapTupleMayBeUpdated TableTupleMayBeModified
#define HeapTupleInvisible TableTupleInvisible
#define HeapTupleSelfUpdated TableTupleSelfModified
#define HeapTupleUpdated TableTupleUpdated
#define HeapTupleDeleted TableTupleDeleted
#define HeapTupleBeingUpdated TableTupleBeingModified
#define HeapTupleWouldBlock TableTupleWouldBlockin heapam.h (whereas the above is in tableam.h), for backward
compat. But I'm not sure it's worth it.These old macros are pretty much used in the internal code, and I doubt
that any one depends directly on those macros. I vote for removal of
these backward compatibility macros.
Cool.
Greetings,
Andres Freund