public inbox for [email protected]
help / color / mirror / Atom feed[PATCH 2/5] Allow composite types in bootstrap
3+ messages / 2 participants
[nested] [flat]
* [PATCH 2/5] Allow composite types in bootstrap
@ 2020-11-17 15:28 Justin Pryzby <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: Justin Pryzby @ 2020-11-17 15:28 UTC (permalink / raw)
---
src/backend/bootstrap/bootstrap.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 18eb62ca47..e4fc75ab84 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -916,6 +916,7 @@ gettype(char *type)
{
if (Typ != NIL)
{
+ static bool did_reread PG_USED_FOR_ASSERTS_ONLY = false; /* Already reread pg_types */
ListCell *lc;
foreach (lc, Typ)
@@ -927,6 +928,33 @@ gettype(char *type)
return app->am_oid;
}
}
+
+ /*
+ * The type wasn't known; check again to handle composite
+ * types, added since first populating the array.
+ */
+
+ /*
+ * Once all the types are populated and we handled composite
+ * types, shouldn't need to do that again.
+ */
+ Assert(!did_reread);
+ did_reread = true;
+
+ list_free_deep(Typ);
+ Typ = NULL;
+ populate_typ_array();
+
+ /* Need to avoid infinite recursion... */
+ foreach (lc, Typ)
+ {
+ struct typmap *app = lfirst(lc);
+ if (strncmp(NameStr(app->am_typ.typname), type, NAMEDATALEN) == 0)
+ {
+ Ap = app;
+ return app->am_oid;
+ }
+ }
}
else
{
--
2.26.2
--------------614DDB87AFFED893713AC0E9
Content-Type: text/x-patch; charset=UTF-8;
name="0003-Extended-statistics-on-expressions-20210304.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="0003-Extended-statistics-on-expressions-20210304.patch"
^ permalink raw reply [nested|flat] 3+ messages in thread
* One-off with syscache ID in get_catalog_object_by_oid_extended()
@ 2026-02-17 22:30 Michael Paquier <[email protected]>
2026-02-17 22:51 ` Re: One-off with syscache ID in get_catalog_object_by_oid_extended() Michael Paquier <[email protected]>
0 siblings, 1 reply; 3+ messages in thread
From: Michael Paquier @ 2026-02-17 22:30 UTC (permalink / raw)
To: Postgres hackers <[email protected]>
Hi all,
While reviewing the syscache code, I have bumped into the following
funny bit in objectaddress.c:
if (oidCacheId > 0)
{
if (locktup)
tuple = SearchSysCacheLockedCopy1(oidCacheId,
ObjectIdGetDatum(objectId));
else
tuple = SearchSysCacheCopy1(oidCacheId,
ObjectIdGetDatum(objectId));
if (!HeapTupleIsValid(tuple)) /* should not happen */
return NULL;
}
This is wrong, because SysCacheIdentifier starts at 0. This has no
consequence currently, because the first value in the enum is
AGGFNOID, something that we don't rely on for object type lookups.
Even if this code had the idea to use an ID of 0, the logic would just
get back to a systable lookup, that would still work, that's just less
efficient.
Simple patch attached, planned for a backpatch quickly as I am playing
with a different patch that reworks a bit this code.
Regards,
--
Michael
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 02af64b82c68..198caf641a5e 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -2808,7 +2808,7 @@ get_catalog_object_by_oid_extended(Relation catalog,
Oid classId = RelationGetRelid(catalog);
int oidCacheId = get_object_catcache_oid(classId);
- if (oidCacheId > 0)
+ if (oidCacheId >= 0)
{
if (locktup)
tuple = SearchSysCacheLockedCopy1(oidCacheId,
Attachments:
[text/plain] cacheid-oneoff.patch (503B, ../../[email protected]/2-cacheid-oneoff.patch)
download | inline diff:
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 02af64b82c68..198caf641a5e 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -2808,7 +2808,7 @@ get_catalog_object_by_oid_extended(Relation catalog,
Oid classId = RelationGetRelid(catalog);
int oidCacheId = get_object_catcache_oid(classId);
- if (oidCacheId > 0)
+ if (oidCacheId >= 0)
{
if (locktup)
tuple = SearchSysCacheLockedCopy1(oidCacheId,
[application/pgp-signature] signature.asc (833B, ../../[email protected]/3-signature.asc)
download
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: One-off with syscache ID in get_catalog_object_by_oid_extended()
2026-02-17 22:30 One-off with syscache ID in get_catalog_object_by_oid_extended() Michael Paquier <[email protected]>
@ 2026-02-17 22:51 ` Michael Paquier <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: Michael Paquier @ 2026-02-17 22:51 UTC (permalink / raw)
To: Postgres hackers <[email protected]>
On Wed, Feb 18, 2026 at 07:30:21AM +0900, Michael Paquier wrote:
> Simple patch attached, planned for a backpatch quickly as I am playing
> with a different patch that reworks a bit this code.
Err, actually, with next week's release planned next week in mind,
I'll fix that only on HEAD.
--
Michael
Attachments:
[application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc)
download
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-02-17 22:51 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17 15:28 [PATCH 2/5] Allow composite types in bootstrap Justin Pryzby <[email protected]>
2026-02-17 22:30 One-off with syscache ID in get_catalog_object_by_oid_extended() Michael Paquier <[email protected]>
2026-02-17 22:51 ` Re: One-off with syscache ID in get_catalog_object_by_oid_extended() Michael Paquier <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox