1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-25 13:17:41 +03:00

Add FLUSH_UNLOGGED option to CHECKPOINT command.

This option, which is disabled by default, can be used to request
the checkpoint also flush dirty buffers of unlogged relations.  As
with the MODE option, the server may consolidate the options for
concurrently requested checkpoints.  For example, if one session
uses (FLUSH_UNLOGGED FALSE) and another uses (FLUSH_UNLOGGED TRUE),
the server may perform one checkpoint with FLUSH_UNLOGGED enabled.

Author: Christoph Berg <myon@debian.org>
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Discussion: https://postgr.es/m/aDnaKTEf-0dLiEfz%40msg.df7cb.de
This commit is contained in:
Nathan Bossart
2025-07-11 11:51:25 -05:00
parent 2f698d7f4b
commit 8d33fbacba
5 changed files with 35 additions and 5 deletions

View File

@@ -989,6 +989,7 @@ void
ExecCheckpoint(ParseState *pstate, CheckPointStmt *stmt)
{
bool fast = true;
bool unlogged = false;
foreach_ptr(DefElem, opt, stmt->options)
{
@@ -1004,6 +1005,8 @@ ExecCheckpoint(ParseState *pstate, CheckPointStmt *stmt)
errmsg("unrecognized MODE option \"%s\"", mode),
parser_errposition(pstate, opt->location)));
}
else if (strcmp(opt->defname, "flush_unlogged") == 0)
unlogged = defGetBoolean(opt);
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -1022,6 +1025,7 @@ ExecCheckpoint(ParseState *pstate, CheckPointStmt *stmt)
RequestCheckpoint(CHECKPOINT_WAIT |
(fast ? CHECKPOINT_FAST : 0) |
(unlogged ? CHECKPOINT_FLUSH_UNLOGGED : 0) |
(RecoveryInProgress() ? 0 : CHECKPOINT_FORCE));
}