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 <
[email protected]>
Reviewed-by: Laurenz Albe <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Reviewed-by: Dilip Kumar <[email protected]>
Discussion: https://postgr.es/m/aDnaKTEf-0dLiEfz%40msg.df7cb.de
<phrase>where <replaceable class="parameter">option</replaceable> can be one of:</phrase>
+ FLUSH_UNLOGGED [ <replaceable class="parameter">boolean</replaceable> ]
MODE { FAST | SPREAD }
</synopsis>
</refsynopsisdiv>
<title>Parameters</title>
<variablelist>
+ <varlistentry>
+ <term><literal>FLUSH_UNLOGGED</literal></term>
+ <listitem>
+ <para>
+ Normally, <command>CHECKPOINT</command> does not flush dirty buffers of
+ unlogged relations. This option, which is disabled by default, enables
+ flushing unlogged relations to disk.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><literal>MODE</literal></term>
<listitem>
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">boolean</replaceable></term>
+ <listitem>
+ <para>
+ Specifies whether the selected option should be turned on or off.
+ You can write <literal>TRUE</literal>, <literal>ON</literal>, or
+ <literal>1</literal> to enable the option, and <literal>FALSE</literal>,
+ <literal>OFF</literal>, or <literal>0</literal> to disable it. The
+ <replaceable class="parameter">boolean</replaceable> value can also
+ be omitted, in which case <literal>TRUE</literal> is assumed.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
ExecCheckpoint(ParseState *pstate, CheckPointStmt *stmt)
{
bool fast = true;
+ bool unlogged = false;
foreach_ptr(DefElem, opt, stmt->options)
{
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),
RequestCheckpoint(CHECKPOINT_WAIT |
(fast ? CHECKPOINT_FAST : 0) |
+ (unlogged ? CHECKPOINT_FLUSH_UNLOGGED : 0) |
(RecoveryInProgress() ? 0 : CHECKPOINT_FORCE));
}
* one word, so the above test is correct.
*/
if (ends_with(prev_wd, '(') || ends_with(prev_wd, ','))
- COMPLETE_WITH("MODE");
+ COMPLETE_WITH("MODE", "FLUSH_UNLOGGED");
else if (TailMatches("MODE"))
COMPLETE_WITH("FAST", "SPREAD");
}
ERROR: unrecognized MODE option "wrong"
LINE 1: CHECKPOINT (MODE WRONG);
^
-CHECKPOINT (MODE FAST);
-CHECKPOINT;
+CHECKPOINT (MODE FAST, FLUSH_UNLOGGED FALSE);
+CHECKPOINT (FLUSH_UNLOGGED);
SELECT num_requested > :rqst_ckpts_before FROM pg_stat_checkpointer;
?column?
----------
-- because it would prolong the test.
CHECKPOINT (WRONG);
CHECKPOINT (MODE WRONG);
-CHECKPOINT (MODE FAST);
-CHECKPOINT;
+CHECKPOINT (MODE FAST, FLUSH_UNLOGGED FALSE);
+CHECKPOINT (FLUSH_UNLOGGED);
SELECT num_requested > :rqst_ckpts_before FROM pg_stat_checkpointer;
SELECT wal_bytes > :wal_bytes_before FROM pg_stat_wal;