agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH v48 7/7] Exclude pg_stat directory from base backup 3+ messages / 3 participants [nested] [flat]
* [PATCH v48 7/7] Exclude pg_stat directory from base backup @ 2020-09-29 14:19 Kyotaro Horiguchi <[email protected]> 0 siblings, 0 replies; 3+ messages in thread From: Kyotaro Horiguchi @ 2020-09-29 14:19 UTC (permalink / raw) basebackup sends the content of pg_stat directory, which is doomed to be removed at startup from the backup. Now that pg_stat_statements saves a temporary file into the directory, let exclude pg_stat directory from a base backup. --- src/backend/replication/basebackup.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index f0d75f55bd..f54fcec70a 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -149,6 +149,13 @@ struct exclude_list_item */ static const char *const excludeDirContents[] = { + /* + * Skip statistics files. PGSTAT_STAT_PERMANENT_DIRECTORY must be skipped + * because the files in the directory will be removed at startup from the + * backup. + */ + PGSTAT_STAT_PERMANENT_DIRECTORY, + /* * It is generally not useful to backup the contents of this directory * even if the intention is to restore to another primary. See backup.sgml -- 2.27.0 ----Next_Part(Fri_Mar__5_17_18_56_2021_497)---- ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Partitioned tables and [un]loggedness @ 2024-09-01 05:24 Junwang Zhao <[email protected]> 0 siblings, 0 replies; 3+ messages in thread From: Junwang Zhao @ 2024-09-01 05:24 UTC (permalink / raw) To: Michael Paquier <[email protected]>; +Cc: David G. Johnston <[email protected]>; Nathan Bossart <[email protected]>; Postgres hackers <[email protected]> On Thu, May 2, 2024 at 2:07 PM Michael Paquier <[email protected]> wrote: > > On Thu, Apr 25, 2024 at 08:55:27AM +0900, Michael Paquier wrote: > > On Wed, Apr 24, 2024 at 04:43:58PM -0700, David G. Johnston wrote: > >> My point is that if you feel that treating logged as a copy-able property > >> is OK then doing the following should also just work: > >> > >> postgres=# create temp table parentt ( id integer ) partition by range (id); > >> CREATE TABLE > >> postgres=# create table child10t partition of parentt for values from (0) > >> to (9); > >> ERROR: cannot create a permanent relation as partition of temporary > >> relation "parentt" > >> > >> i.e., child10t should be created as a temporary partition under parentt. > > > > Ah, indeed, I've missed your point here. Lifting the error and > > inheriting temporary in this case would make sense. > > The case of a temporary persistence is actually *very* tricky. The > namespace, where the relation is created, is guessed and locked with > permission checks done based on the RangeVar when the CreateStmt is > transformed, which is before we try to look at its inheritance tree to > find its partitioned parent. So we would somewhat need to shortcut > the existing RangeVar lookup and include the parents in the loop to > find out the correct namespace. And this is much earlier than now. > The code complexity is not trivial, so I am getting cold feet when > trying to support this case in a robust fashion. For now, I have > discarded this case and focused on the main problem with SET LOGGED > and UNLOGGED. > > Switching between logged <-> unlogged does not have such > complications, because the namespace where the relation is created is > going to be the same. So we won't lock or perform permission checks > on an incorrect namespace. > > The addition of LOGGED makes the logic deciding how the loggedness of > a partition table based on its partitioned table or the query quite > easy to follow, but this needs some safety nets in the sequence, view > and CTAS code paths to handle with the case where the query specifies > no relpersistence. > > I have also looked at support for ONLY, and I've been surprised that > it is not that complicated. tablecmds.c has a ATSimpleRecursion() > that is smart enough to do an inheritance tree lookup and apply the > rewrites where they should happen in the step 3 of ALTER TABLE, while > handling ONLY on its own. The relpersistence of partitioned tables is > updated in step 2, with the catalog changes. > > Attached is a new patch series: > - 0001 refactors some code around ATPrepChangePersistence() that I > found confusing after applying the operation to partitioned tables. > - 0002 adds support for a LOGGED keyword. > - 0003 expands ALTER TABLE SET [UN]LOGGED to partitioned tables, > without recursion to partitions. > - 0004 adds the recursion logic, expanding regression tests to show > the difference. > > 0003 and 0004 should be merged together, I think. Still, splitting > them makes reviews a bit easier. > -- > Michael While reviewing the patches, I found a weird error msg: +ALTER TABLE logged_part_1 SET UNLOGGED; -- fails as a foreign-key exists +ERROR: could not change table "logged_part_1" to unlogged because it references logged table "logged_part_2" should this be *it is referenced by* here? The error msg is from ATPrepChangePersistence, and I think we should do something like: diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index b3cc6f8f69..30fbc3836a 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -16986,7 +16986,7 @@ ATPrepChangePersistence(AlteredTableInfo *tab, Relation rel, bool toLogged) if (RelationIsPermanent(foreignrel)) ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), - errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"", + errmsg("could not change table \"%s\" to unlogged because it is referenced by logged table \"%s\"", What do you think? -- Regards Junwang Zhao ^ permalink raw reply [nested|flat] 3+ messages in thread
* [PATCH v2 6/6] Handle pg_get_triggerdef default args in system_functions.sql @ 2025-12-09 19:51 Mark Wong <[email protected]> 0 siblings, 0 replies; 3+ messages in thread From: Mark Wong @ 2025-12-09 19:51 UTC (permalink / raw) Modernize pg_get_triggerdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 14 -------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index a6f7cdf3a36..08b9b68d0cd 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -699,6 +699,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_expr'; +CREATE OR REPLACE FUNCTION + pg_get_triggerdef(trigger oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_triggerdef'; + -- -- 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 305e3e80c41..188d367b113 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -807,20 +807,6 @@ pg_get_viewdef_worker(Oid viewoid, int prettyFlags, int wrapColumn) */ Datum pg_get_triggerdef(PG_FUNCTION_ARGS) -{ - Oid trigid = PG_GETARG_OID(0); - char *res; - - res = pg_get_triggerdef_worker(trigid, false); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_triggerdef_ext(PG_FUNCTION_ARGS) { Oid trigid = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 3a0be2d4b2a..d644a391e0e 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3983,9 +3983,6 @@ proname => 'pg_get_partition_constraintdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_partition_constraintdef' }, -{ oid => '1662', descr => 'trigger description', - proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, { oid => '1665', descr => 'name of sequence for a serial column', proname => 'pg_get_serial_sequence', provolatile => 's', prorettype => 'text', proargtypes => 'text text', prosrc => 'pg_get_serial_sequence' }, @@ -8551,7 +8548,7 @@ prosrc => 'pg_timezone_names' }, { oid => '2730', descr => 'trigger description with pretty-print option', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_triggerdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_triggerdef' }, # asynchronous notifications { oid => '3035', -- 2.43.0 --3/nz5wg6+DYwHsLU-- ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2025-12-09 19:51 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-09-29 14:19 [PATCH v48 7/7] Exclude pg_stat directory from base backup Kyotaro Horiguchi <[email protected]> 2024-09-01 05:24 Re: Partitioned tables and [un]loggedness Junwang Zhao <[email protected]> 2025-12-09 19:51 [PATCH v2 6/6] Handle pg_get_triggerdef 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