Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/spock_apply_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,22 @@ FindReplTupleInLocalRel(ApplyExecutionData *edata, Relation localrel,
#endif
#endif

#if PG_VERSION_NUM >= 190000

/*
* Since PG 19 the caller tells whether the first index match can be
* taken without comparing it to the search slot (upstream
* 2f7bf51b7b). localidxoid is the replica identity index recorded in
* the relation map, so it can. Back branches kept the old signature.
*/
found = RelationFindReplTupleByIndex(localrel, localidxoid, true,
LockTupleExclusive,
remoteslot, *localslot);
#else
found = RelationFindReplTupleByIndex(localrel, localidxoid,
LockTupleExclusive,
remoteslot, *localslot);
#endif
}
else
{
Expand Down
36 changes: 28 additions & 8 deletions tests/tap/t/033_zodan_lolor_add_node.pl
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,27 @@ sub dsn {
}

# Three large objects exist (deadbeefcafe, feedface, c0ffee); after the drop
# they live in pg_catalog on every node.
for my $node (1, 2, 3) {
is(scalar_query($node, "SELECT count(*) FROM pg_catalog.pg_largeobject_metadata"),
'3', "n$node holds the 3 large objects natively after the drop");
is(scalar_query($node, "SELECT lolor.migrate_from_native()"),
'3', "n$node migrated its 3 native large objects back into lolor");
# they live in pg_catalog on every node, and migrate_from_native() puts them
# back. Both halves of that round-trip are lolor's large object migration,
# which arrived after the newest release ensure_lolor() builds, so check it
# only where lolor actually carries it; the drop and recreate above are
# exercised either way.
my $have_lo_migration = scalar_query(1,
"SELECT count(*) FROM pg_proc p "
. "JOIN pg_namespace n ON n.oid = p.pronamespace "
. "WHERE n.nspname = 'lolor' AND p.proname = 'migrate_from_native'") eq '1';

SKIP: {
skip "lolor has no migrate_from_native(): large object migration "
. "postdates the released lolor this test builds", 6
unless $have_lo_migration;

for my $node (1, 2, 3) {
is(scalar_query($node, "SELECT count(*) FROM pg_catalog.pg_largeobject_metadata"),
'3', "n$node holds the 3 large objects natively after the drop");
is(scalar_query($node, "SELECT lolor.migrate_from_native()"),
'3', "n$node migrated its 3 native large objects back into lolor");
}
}

# Only after every node has migrated: once a table is back in a set, rows
Expand Down Expand Up @@ -324,10 +339,15 @@ sub diag_sync_status {
or diag_sync_status($node);
}

# The three migrated large objects and the new one live side by side.
# The migrated large objects and the new one live side by side. Without the
# migration above only the new one is there.
my $expected_los = $have_lo_migration ? '4' : '1';
for my $node (1, 2, 3) {
is(scalar_query($node, "SELECT count(*) FROM lolor.pg_largeobject_metadata"),
'4', "n$node holds the 3 migrated large objects plus the new one");
$expected_los,
"n$node holds "
. ($have_lo_migration ? "the 3 migrated large objects plus the new one"
: "the new large object"));
}

destroy_cluster('Destroy zodan lolor test cluster');
Expand Down
34 changes: 30 additions & 4 deletions tests/tap/t/SpockTest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -173,22 +173,47 @@ sub system_maybe {
return $rc == 0;
}

# lolor refuses CREATE EXTENSION unless its library is preloaded, so once
# ensure_lolor() succeeds every cluster created afterwards loads it.
my $preload_lolor = 0;

# Build and install the lolor extension if it is not already present.
# Returns true when lolor is available. Callers should skip_all (rather
# than fail) when this returns false, e.g. no network to clone the repo.
# Must be called before create_cluster(), which adds lolor to
# shared_preload_libraries.
sub ensure_lolor {
my $sharedir = `$PG_BIN/pg_config --sharedir`;
chomp $sharedir;
return 1 if $sharedir && -f "$sharedir/extension/lolor.control";
return $preload_lolor = 1
if $sharedir && -f "$sharedir/extension/lolor.control";

my $build = "/tmp/spock_lolor_build";
my $log = "$LOG_DIR/lolor_build.log";
my $repo = 'https://github.com/pgEdge/lolor.git';

# Build the newest released lolor, not whatever main happens to be:
# main is a development branch and a bad commit there would break these
# tests for reasons that have nothing to do with spock.
#
# lolor publishes no GitHub releases, only tags, so the release is the
# highest vN.N.N tag. Pre-release tags (v1.2.3-rc.1) carry a suffix and
# are excluded by the pattern; sort -V then orders the rest by version
# rather than lexically, so v1.2.10 would outrank v1.2.9.
my $tag = `git ls-remote --tags --refs $repo 2>> '$log' | awk -F/ '{print \$NF}' | grep -E '^v[0-9]+(\\.[0-9]+)*\$' | sort -V | tail -1`;
chomp $tag;

# No tag means no network, or the tagging scheme changed. Report failure
# so the caller skips, rather than silently falling back to main.
return 0 unless $tag =~ /^v[0-9][0-9.]*$/;

system('rm', '-rf', $build);
my $rc = system("git clone --depth 1 https://github.com/pgEdge/lolor.git $build >> '$log' 2>&1");
my $rc = system("git clone --depth 1 --branch $tag $repo $build >> '$log' 2>&1");
return 0 if $rc != 0;
$rc = system("make -C $build USE_PGXS=1 PG_CONFIG='$PG_BIN/pg_config' install >> '$log' 2>&1");
return 0 if $rc != 0;
return ($sharedir && -f "$sharedir/extension/lolor.control") ? 1 : 0;
return $preload_lolor =
($sharedir && -f "$sharedir/extension/lolor.control") ? 1 : 0;
}

# Return the output_plugin_libraries line a node needs, or '' if the server
Expand Down Expand Up @@ -232,7 +257,8 @@ sub create_postgresql_conf {

open(my $conf, '>>', "$datadir/postgresql.conf") or die "Cannot open config file: $!";
print $conf "shared_buffers=1GB\n";
print $conf "shared_preload_libraries='spock'\n";
print $conf "shared_preload_libraries='"
. ($preload_lolor ? 'spock, lolor' : 'spock') . "'\n";
print $conf output_plugin_libraries_conf($PG_BIN);
print $conf "wal_level=logical\n";
print $conf "spock.enable_ddl_replication=on\n";
Expand Down
Loading