pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedObsolete reference to pg_relation in comment
9+ messages / 5 participants
[nested] [flat]
Commits from this thread:
2023-09-26 441bbd2988 doc: correct reference to pg_relation in comment
* Obsolete reference to pg_relation in comment
@ 2023-07-26 17:48 Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2023-07-26 18:53 ` Re: Obsolete reference to pg_relation in comment Nathan Bossart <nathandbossart@gmail.com>
2023-07-26 20:50 ` Re: Obsolete reference to pg_relation in comment Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 2 replies; 9+ messages in thread
From: Dagfinn Ilmari Mannsåker @ 2023-07-26 17:48 UTC (permalink / raw)
To: pgsql-hackers
Hi hackers,
Triggered by a discussion on IRC, I noticed that there's a stray
reference to pg_relation in a comment that was added long after it was
renamed to pg_class. Here's a patch to bring that up to speed.
- ilmari
Attachments:
0001-Fix-obsolete-reference-to-pg_relation-in-comment.patch (text/x-diff, 1.2K) download
From e395f8cb293f674f45eb3847534de07c7124e738 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Wed, 26 Jul 2023 18:31:51 +0100
Subject: [PATCH] Fix obsolete reference to pg_relation in comment
pg_relation was renamed to pg_class in 1991, but this comment (added
in 2004) missed the memo
---
src/backend/storage/large_object/inv_api.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
index 84e543e731..a56912700b 100644
--- a/src/backend/storage/large_object/inv_api.c
+++ b/src/backend/storage/large_object/inv_api.c
@@ -59,7 +59,7 @@ bool lo_compat_privileges;
/*
* All accesses to pg_largeobject and its index make use of a single Relation
- * reference, so that we only need to open pg_relation once per transaction.
+ * reference, so that we only need to open pg_class once per transaction.
* To avoid problems when the first such reference occurs inside a
* subtransaction, we execute a slightly klugy maneuver to assign ownership of
* the Relation reference to TopTransactionResourceOwner.
--
2.39.2
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Obsolete reference to pg_relation in comment
2023-07-26 17:48 Obsolete reference to pg_relation in comment Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
@ 2023-07-26 18:53 ` Nathan Bossart <nathandbossart@gmail.com>
2023-07-26 19:11 ` Re: Obsolete reference to pg_relation in comment Nathan Bossart <nathandbossart@gmail.com>
1 sibling, 1 reply; 9+ messages in thread
From: Nathan Bossart @ 2023-07-26 18:53 UTC (permalink / raw)
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>; +Cc: pgsql-hackers
On Wed, Jul 26, 2023 at 06:48:51PM +0100, Dagfinn Ilmari Mannsåker wrote:
> Triggered by a discussion on IRC, I noticed that there's a stray
> reference to pg_relation in a comment that was added long after it was
> renamed to pg_class. Here's a patch to bring that up to speed.
> pg_relation was renamed to pg_class in 1991, but this comment (added
> in 2004) missed the memo
Huh, interesting! I dug around the Berkeley archives [0] and found
comments indicating that pg_relation was renamed to pg_class in Februrary
1990. However, it looks like the file was named pg_relation.h until
Postgres95 v0.01, which has the following comment in pg_class.h:
* ``pg_relation'' is being replaced by ``pg_class''. currently
* we are only changing the name in the catalogs but someday the
* code will be changed too. -cim 2/26/90
* [it finally happens. -ay 11/5/94]
[0] https://dsf.berkeley.edu/postgres.html
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Obsolete reference to pg_relation in comment
2023-07-26 17:48 Obsolete reference to pg_relation in comment Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2023-07-26 18:53 ` Re: Obsolete reference to pg_relation in comment Nathan Bossart <nathandbossart@gmail.com>
@ 2023-07-26 19:11 ` Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 0 replies; 9+ messages in thread
From: Nathan Bossart @ 2023-07-26 19:11 UTC (permalink / raw)
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>; +Cc: pgsql-hackers
On Wed, Jul 26, 2023 at 11:53:06AM -0700, Nathan Bossart wrote:
> On Wed, Jul 26, 2023 at 06:48:51PM +0100, Dagfinn Ilmari Mannsåker wrote:
>> Triggered by a discussion on IRC, I noticed that there's a stray
>> reference to pg_relation in a comment that was added long after it was
>> renamed to pg_class. Here's a patch to bring that up to speed.
>
>> pg_relation was renamed to pg_class in 1991, but this comment (added
>> in 2004) missed the memo
>
> Huh, interesting! I dug around the Berkeley archives [0] and found
> comments indicating that pg_relation was renamed to pg_class in Februrary
> 1990. However, it looks like the file was named pg_relation.h until
> Postgres95 v0.01, which has the following comment in pg_class.h:
>
> * ``pg_relation'' is being replaced by ``pg_class''. currently
> * we are only changing the name in the catalogs but someday the
> * code will be changed too. -cim 2/26/90
> * [it finally happens. -ay 11/5/94]
This comment actually lived in Postgres until 9cf80f2 (June 2000), too.
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Obsolete reference to pg_relation in comment
2023-07-26 17:48 Obsolete reference to pg_relation in comment Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
@ 2023-07-26 20:50 ` Nathan Bossart <nathandbossart@gmail.com>
2023-07-26 21:14 ` Re: Obsolete reference to pg_relation in comment Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 9+ messages in thread
From: Nathan Bossart @ 2023-07-26 20:50 UTC (permalink / raw)
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>; +Cc: pgsql-hackers
Okay, now looking at the patch...
On Wed, Jul 26, 2023 at 06:48:51PM +0100, Dagfinn Ilmari Mannsåker wrote:
> * All accesses to pg_largeobject and its index make use of a single Relation
> - * reference, so that we only need to open pg_relation once per transaction.
> + * reference, so that we only need to open pg_class once per transaction.
> * To avoid problems when the first such reference occurs inside a
> * subtransaction, we execute a slightly klugy maneuver to assign ownership of
> * the Relation reference to TopTransactionResourceOwner.
Hm. Are you sure this is actually referring to pg_class? It seems
unlikely given pg_relation was renamed 14 years before this comment was
added, and the code appears to be ensuring that pg_largeobject and its
index are opened at most once per transaction. I couldn't find the
original thread for this comment, unfortunately, but ISTM we might want to
replace "pg_relation" with "them" instead.
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Obsolete reference to pg_relation in comment
2023-07-26 17:48 Obsolete reference to pg_relation in comment Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2023-07-26 20:50 ` Re: Obsolete reference to pg_relation in comment Nathan Bossart <nathandbossart@gmail.com>
@ 2023-07-26 21:14 ` Tom Lane <tgl@sss.pgh.pa.us>
2023-07-26 21:20 ` Re: Obsolete reference to pg_relation in comment Nathan Bossart <nathandbossart@gmail.com>
2023-09-06 19:13 ` Re: Obsolete reference to pg_relation in comment Bruce Momjian <bruce@momjian.us>
0 siblings, 2 replies; 9+ messages in thread
From: Tom Lane @ 2023-07-26 21:14 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>; pgsql-hackers
Nathan Bossart <nathandbossart@gmail.com> writes:
> On Wed, Jul 26, 2023 at 06:48:51PM +0100, Dagfinn Ilmari Mannsåker wrote:
>> * All accesses to pg_largeobject and its index make use of a single Relation
>> - * reference, so that we only need to open pg_relation once per transaction.
>> + * reference, so that we only need to open pg_class once per transaction.
>> * To avoid problems when the first such reference occurs inside a
>> * subtransaction, we execute a slightly klugy maneuver to assign ownership of
>> * the Relation reference to TopTransactionResourceOwner.
> Hm. Are you sure this is actually referring to pg_class? It seems
> unlikely given pg_relation was renamed 14 years before this comment was
> added, and the code appears to be ensuring that pg_largeobject and its
> index are opened at most once per transaction.
I believe it is just a typo/thinko for pg_class, but there's more not
to like about this comment. First, once we've made a relcache entry
it would typically stay valid across uses, so it's far from clear that
this coding actually prevents many catalog accesses in typical cases.
Second, when we do have to rebuild the relcache entry, there's a lot
more involved than just a pg_class fetch; we at least need to read
pg_attribute, and I think there may be other catalogs that we'd read
along the way, even for a system catalog that lacks complicated
features. (pg_index would presumably get looked at, for instance.)
I think we should reword this to just generically claim that holding
the Relation reference open for the whole transaction reduces overhead.
regards, tom lane
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Obsolete reference to pg_relation in comment
2023-07-26 17:48 Obsolete reference to pg_relation in comment Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2023-07-26 20:50 ` Re: Obsolete reference to pg_relation in comment Nathan Bossart <nathandbossart@gmail.com>
2023-07-26 21:14 ` Re: Obsolete reference to pg_relation in comment Tom Lane <tgl@sss.pgh.pa.us>
@ 2023-07-26 21:20 ` Nathan Bossart <nathandbossart@gmail.com>
1 sibling, 0 replies; 9+ messages in thread
From: Nathan Bossart @ 2023-07-26 21:20 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>; pgsql-hackers
On Wed, Jul 26, 2023 at 05:14:08PM -0400, Tom Lane wrote:
> I think we should reword this to just generically claim that holding
> the Relation reference open for the whole transaction reduces overhead.
WFM
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Obsolete reference to pg_relation in comment
2023-07-26 17:48 Obsolete reference to pg_relation in comment Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2023-07-26 20:50 ` Re: Obsolete reference to pg_relation in comment Nathan Bossart <nathandbossart@gmail.com>
2023-07-26 21:14 ` Re: Obsolete reference to pg_relation in comment Tom Lane <tgl@sss.pgh.pa.us>
@ 2023-09-06 19:13 ` Bruce Momjian <bruce@momjian.us>
2023-09-07 08:44 ` Re: Obsolete reference to pg_relation in comment Daniel Gustafsson <daniel@yesql.se>
1 sibling, 1 reply; 9+ messages in thread
From: Bruce Momjian @ 2023-09-06 19:13 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>; pgsql-hackers
On Wed, Jul 26, 2023 at 05:14:08PM -0400, Tom Lane wrote:
> Nathan Bossart <nathandbossart@gmail.com> writes:
> > On Wed, Jul 26, 2023 at 06:48:51PM +0100, Dagfinn Ilmari Mannsåker wrote:
> >> * All accesses to pg_largeobject and its index make use of a single Relation
> >> - * reference, so that we only need to open pg_relation once per transaction.
> >> + * reference, so that we only need to open pg_class once per transaction.
> >> * To avoid problems when the first such reference occurs inside a
> >> * subtransaction, we execute a slightly klugy maneuver to assign ownership of
> >> * the Relation reference to TopTransactionResourceOwner.
>
> > Hm. Are you sure this is actually referring to pg_class? It seems
> > unlikely given pg_relation was renamed 14 years before this comment was
> > added, and the code appears to be ensuring that pg_largeobject and its
> > index are opened at most once per transaction.
>
> I believe it is just a typo/thinko for pg_class, but there's more not
> to like about this comment. First, once we've made a relcache entry
> it would typically stay valid across uses, so it's far from clear that
> this coding actually prevents many catalog accesses in typical cases.
> Second, when we do have to rebuild the relcache entry, there's a lot
> more involved than just a pg_class fetch; we at least need to read
> pg_attribute, and I think there may be other catalogs that we'd read
> along the way, even for a system catalog that lacks complicated
> features. (pg_index would presumably get looked at, for instance.)
>
> I think we should reword this to just generically claim that holding
> the Relation reference open for the whole transaction reduces overhead.
How is this attached patch?
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com
Only you can decide what is important to you.
Attachments:
pg_relation.diff (text/x-diff, 1.2K) download
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
new file mode 100644
index 84e543e..cc9c335
*** a/src/backend/storage/large_object/inv_api.c
--- b/src/backend/storage/large_object/inv_api.c
***************
*** 58,68 ****
bool lo_compat_privileges;
/*
! * All accesses to pg_largeobject and its index make use of a single Relation
! * reference, so that we only need to open pg_relation once per transaction.
! * To avoid problems when the first such reference occurs inside a
! * subtransaction, we execute a slightly klugy maneuver to assign ownership of
! * the Relation reference to TopTransactionResourceOwner.
*/
static Relation lo_heap_r = NULL;
static Relation lo_index_r = NULL;
--- 58,68 ----
bool lo_compat_privileges;
/*
! * All accesses to pg_largeobject and its index make use of a single
! * Relation reference. To guarantee that the relcache entry remains
! * in the cache, on the first reference inside a subtransaction, we
! * execute a slightly klugy maneuver to assign ownership of the
! * Relation reference to TopTransactionResourceOwner.
*/
static Relation lo_heap_r = NULL;
static Relation lo_index_r = NULL;
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Obsolete reference to pg_relation in comment
2023-07-26 17:48 Obsolete reference to pg_relation in comment Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2023-07-26 20:50 ` Re: Obsolete reference to pg_relation in comment Nathan Bossart <nathandbossart@gmail.com>
2023-07-26 21:14 ` Re: Obsolete reference to pg_relation in comment Tom Lane <tgl@sss.pgh.pa.us>
2023-09-06 19:13 ` Re: Obsolete reference to pg_relation in comment Bruce Momjian <bruce@momjian.us>
@ 2023-09-07 08:44 ` Daniel Gustafsson <daniel@yesql.se>
2023-09-26 21:07 ` Re: Obsolete reference to pg_relation in comment Bruce Momjian <bruce@momjian.us>
0 siblings, 1 reply; 9+ messages in thread
From: Daniel Gustafsson @ 2023-09-07 08:44 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Nathan Bossart <nathandbossart@gmail.com>; Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>; pgsql-hackers
> On 6 Sep 2023, at 21:13, Bruce Momjian <bruce@momjian.us> wrote:
> On Wed, Jul 26, 2023 at 05:14:08PM -0400, Tom Lane wrote:
>> I think we should reword this to just generically claim that holding
>> the Relation reference open for the whole transaction reduces overhead.
>
> How is this attached patch?
Reads good to me, +1.
--
Daniel Gustafsson
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Obsolete reference to pg_relation in comment
2023-07-26 17:48 Obsolete reference to pg_relation in comment Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2023-07-26 20:50 ` Re: Obsolete reference to pg_relation in comment Nathan Bossart <nathandbossart@gmail.com>
2023-07-26 21:14 ` Re: Obsolete reference to pg_relation in comment Tom Lane <tgl@sss.pgh.pa.us>
2023-09-06 19:13 ` Re: Obsolete reference to pg_relation in comment Bruce Momjian <bruce@momjian.us>
2023-09-07 08:44 ` Re: Obsolete reference to pg_relation in comment Daniel Gustafsson <daniel@yesql.se>
@ 2023-09-26 21:07 ` Bruce Momjian <bruce@momjian.us>
0 siblings, 0 replies; 9+ messages in thread
From: Bruce Momjian @ 2023-09-26 21:07 UTC (permalink / raw)
To: Daniel Gustafsson <daniel@yesql.se>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Nathan Bossart <nathandbossart@gmail.com>; Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>; pgsql-hackers
On Thu, Sep 7, 2023 at 10:44:25AM +0200, Daniel Gustafsson wrote:
> > On 6 Sep 2023, at 21:13, Bruce Momjian <bruce@momjian.us> wrote:
> > On Wed, Jul 26, 2023 at 05:14:08PM -0400, Tom Lane wrote:
>
> >> I think we should reword this to just generically claim that holding
> >> the Relation reference open for the whole transaction reduces overhead.
> >
> > How is this attached patch?
>
> Reads good to me, +1.
Patch applied to master. I didn't think backpatching it made much sense
since it is so localized.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com
Only you can decide what is important to you.
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2023-09-26 21:07 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-07-26 17:48 Obsolete reference to pg_relation in comment Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2023-07-26 18:53 ` Nathan Bossart <nathandbossart@gmail.com>
2023-07-26 19:11 ` Nathan Bossart <nathandbossart@gmail.com>
2023-07-26 20:50 ` Nathan Bossart <nathandbossart@gmail.com>
2023-07-26 21:14 ` Tom Lane <tgl@sss.pgh.pa.us>
2023-07-26 21:20 ` Nathan Bossart <nathandbossart@gmail.com>
2023-09-06 19:13 ` Bruce Momjian <bruce@momjian.us>
2023-09-07 08:44 ` Daniel Gustafsson <daniel@yesql.se>
2023-09-26 21:07 ` Bruce Momjian <bruce@momjian.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox