($INBOX_DIR/description missing)help / color / mirror / Atom feed
[PATCH] cfe-11-persistent_over_cfe-10-hint squash commit 2+ messages / 2 participants [nested] [flat]
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit @ 2021-03-12 01:02 Bruce Momjian <[email protected]> 0 siblings, 0 replies; 2+ messages in thread From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw) --- src/backend/access/gist/gistutil.c | 2 +- src/backend/access/heap/heapam_handler.c | 2 +- src/backend/catalog/pg_publication.c | 2 +- src/backend/commands/tablecmds.c | 10 +++++----- src/backend/optimizer/util/plancat.c | 3 +-- src/backend/utils/cache/relcache.c | 2 +- src/include/utils/rel.h | 10 ++++++++-- src/include/utils/snapmgr.h | 3 +-- 8 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c index a3ec9f2cfe..1ff1bf816f 100644 --- a/src/backend/access/gist/gistutil.c +++ b/src/backend/access/gist/gistutil.c @@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel) return counter++; } - else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT) + else if (RelationIsPermanent(rel)) { /* * WAL-logging on this relation will start after commit, so its LSNs diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index bd5faf0c1f..0da8f00443 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode) * WAL log creation if the relation is persistent, or this is the * init fork of an unlogged relation. */ - if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT || + if (RelationIsPermanent(rel) || (rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED && forkNum == INIT_FORKNUM)) log_smgrcreate(newrnode, forkNum); diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c index 84d2efcfd2..86e415af89 100644 --- a/src/backend/catalog/pg_publication.c +++ b/src/backend/catalog/pg_publication.c @@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel) errdetail("System tables cannot be added to publications."))); /* UNLOGGED and TEMP relations cannot be part of publication. */ - if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT) + if (!RelationIsPermanent(targetrel)) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("table \"%s\" cannot be replicated", diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..3dcd797cae 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel, switch (rel->rd_rel->relpersistence) { case RELPERSISTENCE_PERMANENT: - if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT) + if (!RelationIsPermanent(pkrel)) ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), errmsg("constraints on permanent tables may reference only permanent tables"))); break; case RELPERSISTENCE_UNLOGGED: - if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT + if (!RelationIsPermanent(pkrel) && pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED) ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), @@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode) * WAL log creation if the relation is persistent, or this is the * init fork of an unlogged relation. */ - if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT || + if (RelationIsPermanent(rel) || (rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED && forkNum == INIT_FORKNUM)) log_smgrcreate(&newrnode, forkNum); @@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged) if (toLogged) { - if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT) + if (!RelationIsPermanent(foreignrel)) ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"", @@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged) } else { - if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT) + if (RelationIsPermanent(foreignrel)) ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"", diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index c5947fa418..7f2e40ae39 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent, relation = table_open(relationObjectId, NoLock); /* Temporary and unlogged relations are inaccessible during recovery. */ - if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT && - RecoveryInProgress()) + if (!RelationIsPermanent(relation) && RecoveryInProgress()) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot access temporary or unlogged relations during recovery"))); diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 7ef510cd01..a4dbc286cb 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -2989,7 +2989,7 @@ static void AssertPendingSyncConsistency(Relation relation) { bool relcache_verdict = - relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT && + RelationIsPermanent(relation) && ((relation->rd_createSubid != InvalidSubTransactionId && RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) || relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId); diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 10b63982c0..9a3a03e520 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -552,6 +552,13 @@ typedef struct ViewOptions (relation)->rd_smgr->smgr_targblock = (targblock); \ } while (0) +/* + * RelationIsPermanent + * True if relation is permanent. + */ +#define RelationIsPermanent(relation) \ + ((relation)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT) + /* * RelationNeedsWAL * True if relation needs WAL. @@ -561,8 +568,7 @@ typedef struct ViewOptions * RelFileNode" in src/backend/access/transam/README. */ #define RelationNeedsWAL(relation) \ - ((relation)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT && \ - (XLogIsNeeded() || \ + (RelationIsPermanent(relation) && (XLogIsNeeded() || \ (relation->rd_createSubid == InvalidSubTransactionId && \ relation->rd_firstRelfilenodeSubid == InvalidSubTransactionId))) diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h index 2c8b881a09..f66ac58188 100644 --- a/src/include/utils/snapmgr.h +++ b/src/include/utils/snapmgr.h @@ -37,8 +37,7 @@ */ #define RelationAllowsEarlyPruning(rel) \ ( \ - (rel)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT \ - && !IsCatalogRelation(rel) \ + RelationIsPermanent(rel) && !IsCatalogRelation(rel) \ && !RelationIsAccessibleInLogicalDecoding(rel) \ ) -- 2.20.1 --LQksG6bCIzRHxTLp Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="cfe-12-gist_over_cfe-11-persistent.diff" ^ permalink raw reply [nested|flat] 2+ messages in thread
* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql @ 2025-12-09 18:02 Mark Wong <[email protected]> 0 siblings, 0 replies; 2+ messages in thread From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw) Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle the optional column and pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 20 -------------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 3 ++- 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 4ddbf194fa8..72f5fdc06f9 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -678,6 +678,13 @@ LANGUAGE INTERNAL PARALLEL RESTRICTED AS 'pg_get_viewdef'; +CREATE OR REPLACE FUNCTION + pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_indexdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 29557f3c9d2..d8b8d7b4d38 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) */ Datum pg_get_indexdef(PG_FUNCTION_ARGS) -{ - Oid indexrelid = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_indexdef_worker(indexrelid, 0, NULL, - false, false, - false, false, - prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_indexdef_ext(PG_FUNCTION_ARGS) { Oid indexrelid = PG_GETARG_OID(0); int32 colno = PG_GETARG_INT32(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 531d0dea7db..fee5efca41e 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3964,9 +3964,6 @@ { oid => '1642', descr => 'role name by OID (with fallback)', proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name', proargtypes => 'oid', prosrc => 'pg_get_userbyid' }, -{ oid => '1643', descr => 'index description', - proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_indexdef' }, { oid => '3415', descr => 'extended statistics object description', proname => 'pg_get_statisticsobjdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', @@ -8517,7 +8514,7 @@ { oid => '2507', descr => 'index description (full create statement or single expression) with pretty-print option', proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' }, + proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index d5d51ddb3e8..768ce980a1d 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -19,6 +19,7 @@ { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, -{ oid => '1641', proname => 'pg_get_viewdef' } +{ oid => '1641', proname => 'pg_get_viewdef' }, +{ oid => '1643', proname => 'pg_get_indexdef' } ] -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch" ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-12-09 18:02 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]> 2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[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