mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Revert "Logical decoding of sequences"
This reverts a sequence of commits, implementing features related to logical decoding and replication of sequences: -0da92dc530
-80901b3291
-b779d7d8fd
-d5ed9da41d
-a180c2b34d
-75b1521dae
-2d2232933b
-002c9dd97a
-05843b1aa4
The implementation has issues, mostly due to combining transactional and non-transactional behavior of sequences. It's not clear how this could be fixed, but it'll require reworking significant part of the patch. Discussion: https://postgr.es/m/95345a19-d508-63d1-860a-f5c2f41e8d40@enterprisedb.com
This commit is contained in:
@ -35,7 +35,6 @@ typedef struct
|
||||
bool include_timestamp;
|
||||
bool skip_empty_xacts;
|
||||
bool only_local;
|
||||
bool include_sequences;
|
||||
} TestDecodingData;
|
||||
|
||||
/*
|
||||
@ -77,10 +76,6 @@ static void pg_decode_message(LogicalDecodingContext *ctx,
|
||||
ReorderBufferTXN *txn, XLogRecPtr message_lsn,
|
||||
bool transactional, const char *prefix,
|
||||
Size sz, const char *message);
|
||||
static void pg_decode_sequence(LogicalDecodingContext *ctx,
|
||||
ReorderBufferTXN *txn, XLogRecPtr sequence_lsn,
|
||||
Relation rel, bool transactional,
|
||||
int64 last_value, int64 log_cnt, bool is_called);
|
||||
static bool pg_decode_filter_prepare(LogicalDecodingContext *ctx,
|
||||
TransactionId xid,
|
||||
const char *gid);
|
||||
@ -121,10 +116,6 @@ static void pg_decode_stream_message(LogicalDecodingContext *ctx,
|
||||
ReorderBufferTXN *txn, XLogRecPtr message_lsn,
|
||||
bool transactional, const char *prefix,
|
||||
Size sz, const char *message);
|
||||
static void pg_decode_stream_sequence(LogicalDecodingContext *ctx,
|
||||
ReorderBufferTXN *txn, XLogRecPtr sequence_lsn,
|
||||
Relation rel, bool transactional,
|
||||
int64 last_value, int64 log_cnt, bool is_called);
|
||||
static void pg_decode_stream_truncate(LogicalDecodingContext *ctx,
|
||||
ReorderBufferTXN *txn,
|
||||
int nrelations, Relation relations[],
|
||||
@ -150,7 +141,6 @@ _PG_output_plugin_init(OutputPluginCallbacks *cb)
|
||||
cb->filter_by_origin_cb = pg_decode_filter;
|
||||
cb->shutdown_cb = pg_decode_shutdown;
|
||||
cb->message_cb = pg_decode_message;
|
||||
cb->sequence_cb = pg_decode_sequence;
|
||||
cb->filter_prepare_cb = pg_decode_filter_prepare;
|
||||
cb->begin_prepare_cb = pg_decode_begin_prepare_txn;
|
||||
cb->prepare_cb = pg_decode_prepare_txn;
|
||||
@ -163,7 +153,6 @@ _PG_output_plugin_init(OutputPluginCallbacks *cb)
|
||||
cb->stream_commit_cb = pg_decode_stream_commit;
|
||||
cb->stream_change_cb = pg_decode_stream_change;
|
||||
cb->stream_message_cb = pg_decode_stream_message;
|
||||
cb->stream_sequence_cb = pg_decode_stream_sequence;
|
||||
cb->stream_truncate_cb = pg_decode_stream_truncate;
|
||||
}
|
||||
|
||||
@ -184,7 +173,6 @@ pg_decode_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
|
||||
data->include_xids = true;
|
||||
data->include_timestamp = false;
|
||||
data->skip_empty_xacts = false;
|
||||
data->include_sequences = true;
|
||||
data->only_local = false;
|
||||
|
||||
ctx->output_plugin_private = data;
|
||||
@ -277,17 +265,6 @@ pg_decode_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
|
||||
errmsg("could not parse value \"%s\" for parameter \"%s\"",
|
||||
strVal(elem->arg), elem->defname)));
|
||||
}
|
||||
else if (strcmp(elem->defname, "include-sequences") == 0)
|
||||
{
|
||||
|
||||
if (elem->arg == NULL)
|
||||
data->include_sequences = false;
|
||||
else if (!parse_bool(strVal(elem->arg), &data->include_sequences))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("could not parse value \"%s\" for parameter \"%s\"",
|
||||
strVal(elem->arg), elem->defname)));
|
||||
}
|
||||
else
|
||||
{
|
||||
ereport(ERROR,
|
||||
@ -779,38 +756,6 @@ pg_decode_message(LogicalDecodingContext *ctx,
|
||||
OutputPluginWrite(ctx, true);
|
||||
}
|
||||
|
||||
static void
|
||||
pg_decode_sequence(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
|
||||
XLogRecPtr sequence_lsn, Relation rel,
|
||||
bool transactional,
|
||||
int64 last_value, int64 log_cnt, bool is_called)
|
||||
{
|
||||
TestDecodingData *data = ctx->output_plugin_private;
|
||||
TestDecodingTxnData *txndata = txn->output_plugin_private;
|
||||
|
||||
if (!data->include_sequences)
|
||||
return;
|
||||
|
||||
/* output BEGIN if we haven't yet, but only for the transactional case */
|
||||
if (transactional)
|
||||
{
|
||||
if (data->skip_empty_xacts && !txndata->xact_wrote_changes)
|
||||
{
|
||||
pg_output_begin(ctx, data, txn, false);
|
||||
}
|
||||
txndata->xact_wrote_changes = true;
|
||||
}
|
||||
|
||||
OutputPluginPrepareWrite(ctx, true);
|
||||
appendStringInfoString(ctx->out, "sequence ");
|
||||
appendStringInfoString(ctx->out,
|
||||
quote_qualified_identifier(get_namespace_name(get_rel_namespace(RelationGetRelid(rel))),
|
||||
RelationGetRelationName(rel)));
|
||||
appendStringInfo(ctx->out, ": transactional:%d last_value: " INT64_FORMAT " log_cnt: " INT64_FORMAT " is_called:%d",
|
||||
transactional, last_value, log_cnt, is_called);
|
||||
OutputPluginWrite(ctx, true);
|
||||
}
|
||||
|
||||
static void
|
||||
pg_decode_stream_start(LogicalDecodingContext *ctx,
|
||||
ReorderBufferTXN *txn)
|
||||
@ -1010,38 +955,6 @@ pg_decode_stream_message(LogicalDecodingContext *ctx,
|
||||
OutputPluginWrite(ctx, true);
|
||||
}
|
||||
|
||||
static void
|
||||
pg_decode_stream_sequence(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
|
||||
XLogRecPtr sequence_lsn, Relation rel,
|
||||
bool transactional,
|
||||
int64 last_value, int64 log_cnt, bool is_called)
|
||||
{
|
||||
TestDecodingData *data = ctx->output_plugin_private;
|
||||
TestDecodingTxnData *txndata = txn->output_plugin_private;
|
||||
|
||||
if (!data->include_sequences)
|
||||
return;
|
||||
|
||||
/* output BEGIN if we haven't yet, but only for the transactional case */
|
||||
if (transactional)
|
||||
{
|
||||
if (data->skip_empty_xacts && !txndata->xact_wrote_changes)
|
||||
{
|
||||
pg_output_begin(ctx, data, txn, false);
|
||||
}
|
||||
txndata->xact_wrote_changes = true;
|
||||
}
|
||||
|
||||
OutputPluginPrepareWrite(ctx, true);
|
||||
appendStringInfoString(ctx->out, "streaming sequence ");
|
||||
appendStringInfoString(ctx->out,
|
||||
quote_qualified_identifier(get_namespace_name(get_rel_namespace(RelationGetRelid(rel))),
|
||||
RelationGetRelationName(rel)));
|
||||
appendStringInfo(ctx->out, ": transactional:%d last_value: " INT64_FORMAT " log_cnt: " INT64_FORMAT " is_called:%d",
|
||||
transactional, last_value, log_cnt, is_called);
|
||||
OutputPluginWrite(ctx, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* In streaming mode, we don't display the detailed information of Truncate.
|
||||
* See pg_decode_stream_change.
|
||||
|
Reference in New Issue
Block a user