(1 row)
-SELECT test_slot_timelines_advance_logical_slot('test_slot', txid_current(), txid_current(), pg_current_xlog_location(), pg_current_xlog_location());
+SELECT test_slot_timelines_advance_logical_slot('test_slot', txid_current()::text::xid, txid_current()::text::xid, pg_current_xlog_location(), pg_current_xlog_location());
test_slot_timelines_advance_logical_slot
------------------------------------------
SELECT test_slot_timelines_create_logical_slot('test_slot', 'test_decoding');
-SELECT test_slot_timelines_advance_logical_slot('test_slot', txid_current(), txid_current(), pg_current_xlog_location(), pg_current_xlog_location());
+SELECT test_slot_timelines_advance_logical_slot('test_slot', txid_current()::text::xid, txid_current()::text::xid, pg_current_xlog_location(), pg_current_xlog_location());
SELECT pg_drop_replication_slot('test_slot');
CREATE OR REPLACE FUNCTION test_slot_timelines_create_logical_slot(slot_name text, plugin text)
RETURNS void
-LANGUAGE c AS 'MODULE_PATHNAME';
+STRICT LANGUAGE c AS 'MODULE_PATHNAME';
COMMENT ON FUNCTION test_slot_timelines_create_logical_slot(text, text)
IS 'Create a logical slot at a particular lsn and xid. Do not use in production servers, it is not safe. The slot is created with an invalid xmin and lsn.';
-CREATE OR REPLACE FUNCTION test_slot_timelines_advance_logical_slot(slot_name text, new_xmin bigint, new_catalog_xmin bigint, new_restart_lsn pg_lsn, new_confirmed_lsn pg_lsn)
+CREATE OR REPLACE FUNCTION test_slot_timelines_advance_logical_slot(slot_name text, new_xmin xid, new_catalog_xmin xid, new_restart_lsn pg_lsn, new_confirmed_lsn pg_lsn)
RETURNS void
-LANGUAGE c AS 'MODULE_PATHNAME';
+STRICT LANGUAGE c AS 'MODULE_PATHNAME';
-COMMENT ON FUNCTION test_slot_timelines_advance_logical_slot(text, bigint, bigint, pg_lsn, pg_lsn)
+COMMENT ON FUNCTION test_slot_timelines_advance_logical_slot(text, xid, xid, pg_lsn, pg_lsn)
IS 'Advance a logical slot directly. Do not use this in production servers, it is not safe.';
test_slot_timelines_advance_logical_slot(PG_FUNCTION_ARGS)
{
char *slotname = text_to_cstring(PG_GETARG_TEXT_P(0));
- TransactionId new_xmin = (TransactionId) PG_GETARG_INT64(1);
- TransactionId new_catalog_xmin = (TransactionId) PG_GETARG_INT64(2);
+ TransactionId new_xmin = DatumGetTransactionId(PG_GETARG_DATUM(1));
+ TransactionId new_catalog_xmin = DatumGetTransactionId(PG_GETARG_DATUM(2));
XLogRecPtr restart_lsn = PG_GETARG_LSN(3);
XLogRecPtr confirmed_lsn = PG_GETARG_LSN(4);
ReplicationSlotAcquire(slotname);
if (MyReplicationSlot->data.database != MyDatabaseId)
- elog(ERROR, "Trying to update a slot on a different database");
+ elog(ERROR, "trying to update a slot on a different database");
MyReplicationSlot->data.xmin = new_xmin;
MyReplicationSlot->data.catalog_xmin = new_catalog_xmin;
# we're just doing it by hand for this test. This is exposing
# postgres innards to SQL so it's unsafe except for testing.
$node_master->safe_psql('postgres', 'CREATE EXTENSION test_slot_timelines;');
-my $slotinfo = $node_master->safe_psql('postgres',
-'SELECT slot_name, plugin, xmin, catalog_xmin, restart_lsn, confirmed_flush_lsn FROM pg_replication_slots ORDER BY slot_name'
+
+my $slotinfo = $node_master->safe_psql(
+ 'postgres',
+ qq{SELECT slot_name, plugin,
+ COALESCE(xmin, '0'), catalog_xmin,
+ restart_lsn, confirmed_flush_lsn
+ FROM pg_replication_slots ORDER BY slot_name}
);
diag "Copying slots to replica";
open my $fh, '<', \$slotinfo or die $!;
chomp $_;
my ($slot_name, $plugin, $xmin, $catalog_xmin, $restart_lsn,
$confirmed_flush_lsn)
- = map {
- if ($_ ne '') { "'$_'" }
- else { 'NULL' }
- } split qr/\|/, $_;
+ = map { "'$_'" } split qr/\|/, $_;
print
"# Copying slot $slot_name,$plugin,$xmin,$catalog_xmin,$restart_lsn,$confirmed_flush_lsn\n";
$stdout = $node_replica->safe_psql(
'postgres',
- qq{SELECT slot_name, plugin, xmin, catalog_xmin,
+ qq{SELECT slot_name, plugin, COALESCE(xmin, '0'), catalog_xmin,
restart_lsn, confirmed_flush_lsn
FROM pg_replication_slots
ORDER BY slot_name});
opendir(my $pg_xlog, $node_master->data_dir . "/pg_xlog") or die $!;
while (my $seg = readdir $pg_xlog)
{
+ next if $seg eq '.' or $seg eq '..';
next unless $seg >= $oldest_needed_segment && $seg =~ /^[0-9]{24}/;
diag "copying xlog seg $seg";
copy(