Commit 92e1583b authored by Peter Eisentraut's avatar Peter Eisentraut

Don't do logical replication of TRUNCATE of zero tables

When due to publication configuration, a TRUNCATE change ends up with
zero tables to be published, don't send the message out, just skip it.
It's not wrong, but obviously useless overhead.
parent e348e7ae
...@@ -407,6 +407,8 @@ pgoutput_truncate(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, ...@@ -407,6 +407,8 @@ pgoutput_truncate(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
maybe_send_schema(ctx, relation, relentry); maybe_send_schema(ctx, relation, relentry);
} }
if (nrelids > 0)
{
OutputPluginPrepareWrite(ctx, true); OutputPluginPrepareWrite(ctx, true);
logicalrep_write_truncate(ctx->out, logicalrep_write_truncate(ctx->out,
nrelids, nrelids,
...@@ -414,6 +416,7 @@ pgoutput_truncate(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, ...@@ -414,6 +416,7 @@ pgoutput_truncate(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
change->data.truncate.cascade, change->data.truncate.cascade,
change->data.truncate.restart_seqs); change->data.truncate.restart_seqs);
OutputPluginWrite(ctx, true); OutputPluginWrite(ctx, true);
}
MemoryContextSwitchTo(old); MemoryContextSwitchTo(old);
MemoryContextReset(data->context); MemoryContextReset(data->context);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment