MCPcopy Create free account
hub / github.com/apache/cloudberry / pg_decode_truncate

Function pg_decode_truncate

contrib/test_decoding/test_decoding.c:680–733  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

678}
679
680static void
681pg_decode_truncate(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
682 int nrelations, Relation relations[], ReorderBufferChange *change)
683{
684 TestDecodingData *data;
685 TestDecodingTxnData *txndata;
686 MemoryContext old;
687 int i;
688
689 data = ctx->output_plugin_private;
690 txndata = txn->output_plugin_private;
691
692 /* output BEGIN if we haven't yet */
693 if (data->skip_empty_xacts && !txndata->xact_wrote_changes)
694 {
695 pg_output_begin(ctx, data, txn, false);
696 }
697 txndata->xact_wrote_changes = true;
698
699 /* Avoid leaking memory by using and resetting our own context */
700 old = MemoryContextSwitchTo(data->context);
701
702 OutputPluginPrepareWrite(ctx, true);
703
704 appendStringInfoString(ctx->out, "table ");
705
706 for (i = 0; i < nrelations; i++)
707 {
708 if (i > 0)
709 appendStringInfoString(ctx->out, ", ");
710
711 appendStringInfoString(ctx->out,
712 quote_qualified_identifier(get_namespace_name(relations[i]->rd_rel->relnamespace),
713 NameStr(relations[i]->rd_rel->relname)));
714 }
715
716 appendStringInfoString(ctx->out, ": TRUNCATE:");
717
718 if (change->data.truncate.restart_seqs
719 || change->data.truncate.cascade)
720 {
721 if (change->data.truncate.restart_seqs)
722 appendStringInfoString(ctx->out, " restart_seqs");
723 if (change->data.truncate.cascade)
724 appendStringInfoString(ctx->out, " cascade");
725 }
726 else
727 appendStringInfoString(ctx->out, " (no-flags)");
728
729 MemoryContextSwitchTo(old);
730 MemoryContextReset(data->context);
731
732 OutputPluginWrite(ctx, true);
733}
734
735static void
736pg_decode_message(LogicalDecodingContext *ctx,

Callers

nothing calls this directly

Calls 8

pg_output_beginFunction · 0.85
MemoryContextSwitchToFunction · 0.85
OutputPluginPrepareWriteFunction · 0.85
appendStringInfoStringFunction · 0.85
get_namespace_nameFunction · 0.85
MemoryContextResetFunction · 0.85
OutputPluginWriteFunction · 0.85

Tested by

no test coverage detected