| 678 | } |
| 679 | |
| 680 | static void |
| 681 | pg_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 | |
| 735 | static void |
| 736 | pg_decode_message(LogicalDecodingContext *ctx, |
nothing calls this directly
no test coverage detected