mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-11-21 03:13:05 +08:00
Remove incidental md5() function uses from several tests
This removes md5() function calls from these test suites:
- bloom
- test_decoding
- isolation
- recovery
- subscription
This covers all remaining test suites where md5() calls were just used
to generate some random data and can be replaced by appropriately
adapted sha256() calls. This will eventually allow these tests to
pass in OpenSSL FIPS mode (which does not allow MD5 use). See also
208bf364a9
. Unlike for the main regression tests, I didn't write a
fipshash() wrapper here, because that would have been too repetitive
and wouldn't really save much here. In some cases it was easier to
remove one layer of indirection by changing column types from text to
bytea.
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/flat/f9b480b5-e473-d2d1-223a-4b9db30a229a@eisentraut.org
This commit is contained in:
parent
625d5b3ca0
commit
657f5f223e
@ -3,7 +3,7 @@ CREATE TABLE tst (
|
||||
i int4,
|
||||
t text
|
||||
);
|
||||
INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
|
||||
INSERT INTO tst SELECT i%10, substr(encode(sha256(i::text::bytea), 'hex'), 1, 1) FROM generate_series(1,2000) i;
|
||||
CREATE INDEX bloomidx ON tst USING bloom (i, t) WITH (col1 = 3);
|
||||
ALTER INDEX bloomidx SET (length=80);
|
||||
SET enable_seqscan=on;
|
||||
@ -18,13 +18,13 @@ SELECT count(*) FROM tst WHERE i = 7;
|
||||
SELECT count(*) FROM tst WHERE t = '5';
|
||||
count
|
||||
-------
|
||||
112
|
||||
126
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
||||
count
|
||||
-------
|
||||
13
|
||||
14
|
||||
(1 row)
|
||||
|
||||
SET enable_seqscan=off;
|
||||
@ -69,17 +69,17 @@ SELECT count(*) FROM tst WHERE i = 7;
|
||||
SELECT count(*) FROM tst WHERE t = '5';
|
||||
count
|
||||
-------
|
||||
112
|
||||
126
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
||||
count
|
||||
-------
|
||||
13
|
||||
14
|
||||
(1 row)
|
||||
|
||||
DELETE FROM tst;
|
||||
INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
|
||||
INSERT INTO tst SELECT i%10, substr(encode(sha256(i::text::bytea), 'hex'), 1, 1) FROM generate_series(1,2000) i;
|
||||
VACUUM ANALYZE tst;
|
||||
SELECT count(*) FROM tst WHERE i = 7;
|
||||
count
|
||||
@ -90,18 +90,18 @@ SELECT count(*) FROM tst WHERE i = 7;
|
||||
SELECT count(*) FROM tst WHERE t = '5';
|
||||
count
|
||||
-------
|
||||
112
|
||||
126
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
||||
count
|
||||
-------
|
||||
13
|
||||
14
|
||||
(1 row)
|
||||
|
||||
DELETE FROM tst WHERE i > 1 OR t = '5';
|
||||
VACUUM tst;
|
||||
INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
|
||||
INSERT INTO tst SELECT i%10, substr(encode(sha256(i::text::bytea), 'hex'), 1, 1) FROM generate_series(1,2000) i;
|
||||
SELECT count(*) FROM tst WHERE i = 7;
|
||||
count
|
||||
-------
|
||||
@ -111,13 +111,13 @@ SELECT count(*) FROM tst WHERE i = 7;
|
||||
SELECT count(*) FROM tst WHERE t = '5';
|
||||
count
|
||||
-------
|
||||
112
|
||||
126
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
||||
count
|
||||
-------
|
||||
13
|
||||
14
|
||||
(1 row)
|
||||
|
||||
VACUUM FULL tst;
|
||||
@ -130,13 +130,13 @@ SELECT count(*) FROM tst WHERE i = 7;
|
||||
SELECT count(*) FROM tst WHERE t = '5';
|
||||
count
|
||||
-------
|
||||
112
|
||||
126
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
||||
count
|
||||
-------
|
||||
13
|
||||
14
|
||||
(1 row)
|
||||
|
||||
-- Try an unlogged table too
|
||||
@ -144,7 +144,7 @@ CREATE UNLOGGED TABLE tstu (
|
||||
i int4,
|
||||
t text
|
||||
);
|
||||
INSERT INTO tstu SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
|
||||
INSERT INTO tstu SELECT i%10, substr(encode(sha256(i::text::bytea), 'hex'), 1, 1) FROM generate_series(1,2000) i;
|
||||
CREATE INDEX bloomidxu ON tstu USING bloom (i, t) WITH (col2 = 4);
|
||||
SET enable_seqscan=off;
|
||||
SET enable_bitmapscan=on;
|
||||
@ -188,13 +188,13 @@ SELECT count(*) FROM tstu WHERE i = 7;
|
||||
SELECT count(*) FROM tstu WHERE t = '5';
|
||||
count
|
||||
-------
|
||||
112
|
||||
126
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tstu WHERE i = 7 AND t = '5';
|
||||
count
|
||||
-------
|
||||
13
|
||||
14
|
||||
(1 row)
|
||||
|
||||
RESET enable_seqscan;
|
||||
|
@ -5,7 +5,7 @@ CREATE TABLE tst (
|
||||
t text
|
||||
);
|
||||
|
||||
INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
|
||||
INSERT INTO tst SELECT i%10, substr(encode(sha256(i::text::bytea), 'hex'), 1, 1) FROM generate_series(1,2000) i;
|
||||
CREATE INDEX bloomidx ON tst USING bloom (i, t) WITH (col1 = 3);
|
||||
ALTER INDEX bloomidx SET (length=80);
|
||||
|
||||
@ -30,7 +30,7 @@ SELECT count(*) FROM tst WHERE t = '5';
|
||||
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
||||
|
||||
DELETE FROM tst;
|
||||
INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
|
||||
INSERT INTO tst SELECT i%10, substr(encode(sha256(i::text::bytea), 'hex'), 1, 1) FROM generate_series(1,2000) i;
|
||||
VACUUM ANALYZE tst;
|
||||
|
||||
SELECT count(*) FROM tst WHERE i = 7;
|
||||
@ -39,7 +39,7 @@ SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
||||
|
||||
DELETE FROM tst WHERE i > 1 OR t = '5';
|
||||
VACUUM tst;
|
||||
INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
|
||||
INSERT INTO tst SELECT i%10, substr(encode(sha256(i::text::bytea), 'hex'), 1, 1) FROM generate_series(1,2000) i;
|
||||
|
||||
SELECT count(*) FROM tst WHERE i = 7;
|
||||
SELECT count(*) FROM tst WHERE t = '5';
|
||||
@ -58,7 +58,7 @@ CREATE UNLOGGED TABLE tstu (
|
||||
t text
|
||||
);
|
||||
|
||||
INSERT INTO tstu SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
|
||||
INSERT INTO tstu SELECT i%10, substr(encode(sha256(i::text::bytea), 'hex'), 1, 1) FROM generate_series(1,2000) i;
|
||||
CREATE INDEX bloomidxu ON tstu USING bloom (i, t) WITH (col2 = 4);
|
||||
|
||||
SET enable_seqscan=off;
|
||||
|
@ -59,7 +59,7 @@ $node_standby->start;
|
||||
$node_primary->safe_psql("postgres", "CREATE EXTENSION bloom;");
|
||||
$node_primary->safe_psql("postgres", "CREATE TABLE tst (i int4, t text);");
|
||||
$node_primary->safe_psql("postgres",
|
||||
"INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,100000) i;"
|
||||
"INSERT INTO tst SELECT i%10, substr(encode(sha256(i::text::bytea), 'hex'), 1, 1) FROM generate_series(1,10000) i;"
|
||||
);
|
||||
$node_primary->safe_psql("postgres",
|
||||
"CREATE INDEX bloomidx ON tst USING bloom (i, t) WITH (col1 = 3);");
|
||||
@ -76,7 +76,7 @@ for my $i (1 .. 10)
|
||||
test_index_replay("vacuum $i");
|
||||
my ($start, $end) = (100001 + ($i - 1) * 10000, 100000 + $i * 10000);
|
||||
$node_primary->safe_psql("postgres",
|
||||
"INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series($start,$end) i;"
|
||||
"INSERT INTO tst SELECT i%10, substr(encode(sha256(i::text::bytea), 'hex'), 1, 1) FROM generate_series($start,$end) i;"
|
||||
);
|
||||
test_index_replay("insert $i");
|
||||
}
|
||||
|
@ -2,11 +2,11 @@ Parsed test spec with 3 sessions
|
||||
|
||||
starting permutation: s0_begin s0_ddl s1_ddl s1_begin s1_toast_insert s2_ddl s1_commit s1_get_stream_changes
|
||||
step s0_begin: BEGIN;
|
||||
step s0_ddl: CREATE TABLE stream_test1(data text);
|
||||
step s1_ddl: CREATE TABLE stream_test(data text);
|
||||
step s0_ddl: CREATE TABLE stream_test1(data bytea);
|
||||
step s1_ddl: CREATE TABLE stream_test(data bytea);
|
||||
step s1_begin: BEGIN;
|
||||
step s1_toast_insert: INSERT INTO stream_test SELECT large_val();
|
||||
step s2_ddl: CREATE TABLE stream_test2(data text);
|
||||
step s2_ddl: CREATE TABLE stream_test2(data bytea);
|
||||
step s1_commit: COMMIT;
|
||||
step s1_get_stream_changes: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL,NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
|
||||
data
|
||||
|
@ -8,7 +8,7 @@ setup
|
||||
|
||||
-- consume DDL
|
||||
SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
CREATE OR REPLACE FUNCTION large_val() RETURNS TEXT LANGUAGE SQL AS 'select array_agg(md5(g::text))::text from generate_series(1, 80000) g';
|
||||
CREATE OR REPLACE FUNCTION large_val() RETURNS bytea LANGUAGE SQL AS $$ select string_agg(sha256(g::text::bytea), '') from generate_series(1, 83000) g $$;
|
||||
}
|
||||
|
||||
teardown
|
||||
@ -21,11 +21,11 @@ teardown
|
||||
session "s0"
|
||||
setup { SET synchronous_commit=on; }
|
||||
step "s0_begin" { BEGIN; }
|
||||
step "s0_ddl" {CREATE TABLE stream_test1(data text);}
|
||||
step "s0_ddl" {CREATE TABLE stream_test1(data bytea);}
|
||||
|
||||
session "s2"
|
||||
setup { SET synchronous_commit=on; }
|
||||
step "s2_ddl" {CREATE TABLE stream_test2(data text);}
|
||||
step "s2_ddl" {CREATE TABLE stream_test2(data bytea);}
|
||||
|
||||
# The transaction commit for s1_ddl will add the INTERNAL_SNAPSHOT change to
|
||||
# the currently running s0_ddl and we want to test that s0_ddl should not get
|
||||
@ -34,7 +34,7 @@ step "s2_ddl" {CREATE TABLE stream_test2(data text);}
|
||||
# what gets streamed.
|
||||
session "s1"
|
||||
setup { SET synchronous_commit=on; }
|
||||
step "s1_ddl" { CREATE TABLE stream_test(data text); }
|
||||
step "s1_ddl" { CREATE TABLE stream_test(data bytea); }
|
||||
step "s1_begin" { BEGIN; }
|
||||
step "s1_toast_insert" {INSERT INTO stream_test SELECT large_val();}
|
||||
step "s1_commit" { COMMIT; }
|
||||
|
@ -31,7 +31,7 @@ setup
|
||||
RETURN $1;
|
||||
END;$$;
|
||||
|
||||
CREATE OR REPLACE FUNCTION ctoast_large_val() RETURNS TEXT LANGUAGE SQL AS 'select array_agg(md5(g::text))::text from generate_series(1, 256) g';
|
||||
CREATE OR REPLACE FUNCTION ctoast_large_val() RETURNS text LANGUAGE SQL AS $$ select string_agg(encode(sha256(g::text::bytea),'hex'), '')::text from generate_series(1, 133) g $$;
|
||||
|
||||
CREATE TABLE upserttest(key text, data text);
|
||||
|
||||
|
@ -54,9 +54,9 @@ $bravo->safe_psql('postgres', 'checkpoint');
|
||||
|
||||
# Now just use a dummy table and run some operations to move minRecoveryPoint
|
||||
# beyond the previous vacuum.
|
||||
$alpha->safe_psql('postgres', 'create table test2 (a int, b text)');
|
||||
$alpha->safe_psql('postgres', 'create table test2 (a int, b bytea)');
|
||||
$alpha->safe_psql('postgres',
|
||||
'insert into test2 select generate_series(1,10000), md5(random()::text)');
|
||||
q{insert into test2 select generate_series(1,10000), sha256(random()::text::bytea)});
|
||||
$alpha->safe_psql('postgres', 'truncate test2');
|
||||
|
||||
# Wait again for all records to be replayed.
|
||||
|
@ -39,7 +39,7 @@ DECLARE
|
||||
BEGIN
|
||||
LOOP
|
||||
INSERT into filler
|
||||
select g, repeat(md5(g::text), (random() * 60 + 1)::int)
|
||||
select g, repeat(encode(sha256(g::text::bytea), 'hex'), (random() * 15 + 1)::int)
|
||||
from generate_series(1, 10) g;
|
||||
|
||||
remain := wal_segsize - (pg_current_wal_insert_lsn() - '0/0') % wal_segsize;
|
||||
|
@ -48,7 +48,7 @@ is($result, qq(2|2|2), 'check initial data was copied to subscriber');
|
||||
|
||||
# Update the rows on the publisher and check the additional columns on
|
||||
# subscriber didn't change
|
||||
$node_publisher->safe_psql('postgres', "UPDATE test_tab SET b = md5(b)");
|
||||
$node_publisher->safe_psql('postgres', "UPDATE test_tab SET b = encode(sha256(b::bytea), 'hex')");
|
||||
|
||||
$node_publisher->wait_for_catchup('tap_sub');
|
||||
|
||||
@ -65,7 +65,7 @@ $node_subscriber->safe_psql('postgres',
|
||||
"UPDATE test_tab SET c = 'epoch'::timestamptz + 987654321 * interval '1s'"
|
||||
);
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"UPDATE test_tab SET b = md5(a::text)");
|
||||
"UPDATE test_tab SET b = encode(sha256(a::text::bytea), 'hex')");
|
||||
|
||||
$node_publisher->wait_for_catchup('tap_sub');
|
||||
|
||||
|
@ -38,15 +38,15 @@ sub test_streaming
|
||||
$h->query_safe(
|
||||
q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(3, 5000) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(3, 5000) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
});
|
||||
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(5001, 9999) s(i);
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(5001, 9999) s(i);
|
||||
DELETE FROM test_tab WHERE a > 5000;
|
||||
COMMIT;
|
||||
});
|
||||
@ -76,8 +76,8 @@ sub test_streaming
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(5001, 10000) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(5001, 10000) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
COMMIT;
|
||||
});
|
||||
@ -104,7 +104,7 @@ sub test_streaming
|
||||
$offset = -s $node_subscriber->logfile;
|
||||
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"UPDATE test_tab SET b = md5(a::text)");
|
||||
"UPDATE test_tab SET b = sha256(a::text::bytea)");
|
||||
|
||||
$node_publisher->wait_for_catchup($appname);
|
||||
|
||||
@ -136,7 +136,7 @@ $node_subscriber->start;
|
||||
|
||||
# Create some preexisting content on publisher
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE TABLE test_tab (a int primary key, b varchar)");
|
||||
"CREATE TABLE test_tab (a int primary key, b bytea)");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')");
|
||||
|
||||
@ -144,7 +144,7 @@ $node_publisher->safe_psql('postgres', "CREATE TABLE test_tab_2 (a int)");
|
||||
|
||||
# Setup structure on subscriber
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"
|
||||
"CREATE TABLE test_tab (a int primary key, b bytea, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"
|
||||
);
|
||||
|
||||
$node_subscriber->safe_psql('postgres', "CREATE TABLE test_tab_2 (a int)");
|
||||
|
@ -36,24 +36,24 @@ sub test_streaming
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(3, 5) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(3, 5) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(6, 8) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(6, 8) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
SAVEPOINT s2;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(9, 11) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(9, 11) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
SAVEPOINT s3;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(12, 14) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(12, 14) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
SAVEPOINT s4;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(15, 17) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(15, 17) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
COMMIT;
|
||||
});
|
||||
@ -89,13 +89,13 @@ $node_subscriber->start;
|
||||
|
||||
# Create some preexisting content on publisher
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE TABLE test_tab (a int primary key, b varchar)");
|
||||
"CREATE TABLE test_tab (a int primary key, b bytea)");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')");
|
||||
|
||||
# Setup structure on subscriber
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"
|
||||
"CREATE TABLE test_tab (a int primary key, b bytea, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"
|
||||
);
|
||||
|
||||
# Setup logical replication
|
||||
|
@ -31,7 +31,7 @@ $node_publisher->safe_psql('postgres',
|
||||
|
||||
# Setup structure on subscriber
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE TABLE test_tab (a int primary key, b text, c INT, d INT, e INT, f INT)"
|
||||
"CREATE TABLE test_tab (a int primary key, b bytea, c INT, d INT, e INT, f INT)"
|
||||
);
|
||||
|
||||
# Setup logical replication
|
||||
@ -56,10 +56,10 @@ is($result, qq(2|0|0), 'check initial data was copied to subscriber');
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab VALUES (3, md5(3::text));
|
||||
INSERT INTO test_tab VALUES (3, sha256(3::text::bytea));
|
||||
ALTER TABLE test_tab ADD COLUMN c INT;
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO test_tab VALUES (4, md5(4::text), -4);
|
||||
INSERT INTO test_tab VALUES (4, sha256(4::text::bytea), -4);
|
||||
COMMIT;
|
||||
});
|
||||
|
||||
@ -67,10 +67,10 @@ COMMIT;
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text), -i FROM generate_series(5, 1000) s(i);
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea), -i FROM generate_series(5, 1000) s(i);
|
||||
ALTER TABLE test_tab ADD COLUMN d INT;
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text), -i, 2*i FROM generate_series(1001, 2000) s(i);
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea), -i, 2*i FROM generate_series(1001, 2000) s(i);
|
||||
COMMIT;
|
||||
});
|
||||
|
||||
@ -78,10 +78,10 @@ COMMIT;
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab VALUES (2001, md5(2001::text), -2001, 2*2001);
|
||||
INSERT INTO test_tab VALUES (2001, sha256(2001::text::bytea), -2001, 2*2001);
|
||||
ALTER TABLE test_tab ADD COLUMN e INT;
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO test_tab VALUES (2002, md5(2002::text), -2002, 2*2002, -3*2002);
|
||||
INSERT INTO test_tab VALUES (2002, sha256(2002::text::bytea), -2002, 2*2002, -3*2002);
|
||||
COMMIT;
|
||||
});
|
||||
|
||||
@ -100,7 +100,7 @@ is($result, qq(2002|1999|1002|1),
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text), -i, 2*i, -3*i FROM generate_series(2003,5000) s(i);
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea), -i, 2*i, -3*i FROM generate_series(2003,5000) s(i);
|
||||
ALTER TABLE test_tab ADD COLUMN f INT;
|
||||
COMMIT;
|
||||
});
|
||||
@ -110,7 +110,7 @@ COMMIT;
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text), -i, 2*i, -3*i, 4*i FROM generate_series(5001,5005) s(i);
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea), -i, 2*i, -3*i, 4*i FROM generate_series(5001,5005) s(i);
|
||||
COMMIT;
|
||||
});
|
||||
|
||||
|
@ -36,21 +36,21 @@ sub test_streaming
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab VALUES (3, md5(3::text));
|
||||
INSERT INTO test_tab VALUES (3, sha256(3::text::bytea));
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO test_tab VALUES (4, md5(4::text));
|
||||
INSERT INTO test_tab VALUES (4, sha256(4::text::bytea));
|
||||
SAVEPOINT s2;
|
||||
INSERT INTO test_tab VALUES (5, md5(5::text));
|
||||
INSERT INTO test_tab VALUES (5, sha256(5::text::bytea));
|
||||
SAVEPOINT s3;
|
||||
INSERT INTO test_tab VALUES (6, md5(6::text));
|
||||
INSERT INTO test_tab VALUES (6, sha256(6::text::bytea));
|
||||
ROLLBACK TO s2;
|
||||
INSERT INTO test_tab VALUES (7, md5(7::text));
|
||||
INSERT INTO test_tab VALUES (7, sha256(7::text::bytea));
|
||||
ROLLBACK TO s1;
|
||||
INSERT INTO test_tab VALUES (8, md5(8::text));
|
||||
INSERT INTO test_tab VALUES (8, sha256(8::text::bytea));
|
||||
SAVEPOINT s4;
|
||||
INSERT INTO test_tab VALUES (9, md5(9::text));
|
||||
INSERT INTO test_tab VALUES (9, sha256(9::text::bytea));
|
||||
SAVEPOINT s5;
|
||||
INSERT INTO test_tab VALUES (10, md5(10::text));
|
||||
INSERT INTO test_tab VALUES (10, sha256(10::text::bytea));
|
||||
COMMIT;
|
||||
});
|
||||
|
||||
@ -73,15 +73,15 @@ sub test_streaming
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab VALUES (11, md5(11::text));
|
||||
INSERT INTO test_tab VALUES (11, sha256(11::text::bytea));
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO test_tab VALUES (12, md5(12::text));
|
||||
INSERT INTO test_tab VALUES (12, sha256(12::text::bytea));
|
||||
SAVEPOINT s2;
|
||||
INSERT INTO test_tab VALUES (13, md5(13::text));
|
||||
INSERT INTO test_tab VALUES (13, sha256(13::text::bytea));
|
||||
SAVEPOINT s3;
|
||||
INSERT INTO test_tab VALUES (14, md5(14::text));
|
||||
INSERT INTO test_tab VALUES (14, sha256(14::text::bytea));
|
||||
RELEASE s2;
|
||||
INSERT INTO test_tab VALUES (15, md5(15::text));
|
||||
INSERT INTO test_tab VALUES (15, sha256(15::text::bytea));
|
||||
ROLLBACK TO s1;
|
||||
COMMIT;
|
||||
});
|
||||
@ -103,11 +103,11 @@ sub test_streaming
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab VALUES (16, md5(16::text));
|
||||
INSERT INTO test_tab VALUES (16, sha256(16::text::bytea));
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO test_tab VALUES (17, md5(17::text));
|
||||
INSERT INTO test_tab VALUES (17, sha256(17::text::bytea));
|
||||
SAVEPOINT s2;
|
||||
INSERT INTO test_tab VALUES (18, md5(18::text));
|
||||
INSERT INTO test_tab VALUES (18, sha256(18::text::bytea));
|
||||
ROLLBACK;
|
||||
});
|
||||
|
||||
@ -140,7 +140,7 @@ $node_subscriber->start;
|
||||
|
||||
# Create some preexisting content on publisher
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE TABLE test_tab (a int primary key, b varchar)");
|
||||
"CREATE TABLE test_tab (a int primary key, b bytea)");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')");
|
||||
$node_publisher->safe_psql('postgres', "CREATE TABLE test_tab_2 (a int)");
|
||||
|
@ -26,13 +26,13 @@ $node_subscriber->start;
|
||||
|
||||
# Create some preexisting content on publisher
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE TABLE test_tab (a int primary key, b varchar)");
|
||||
"CREATE TABLE test_tab (a int primary key, b bytea)");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')");
|
||||
|
||||
# Setup structure on subscriber
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE TABLE test_tab (a int primary key, b text, c INT, d INT, e INT)");
|
||||
"CREATE TABLE test_tab (a int primary key, b bytea, c INT, d INT, e INT)");
|
||||
|
||||
# Setup logical replication
|
||||
my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
|
||||
@ -56,19 +56,19 @@ is($result, qq(2|0), 'check initial data was copied to subscriber');
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab VALUES (3, md5(3::text));
|
||||
INSERT INTO test_tab VALUES (3, sha256(3::text::bytea));
|
||||
ALTER TABLE test_tab ADD COLUMN c INT;
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO test_tab VALUES (4, md5(4::text), -4);
|
||||
INSERT INTO test_tab VALUES (4, sha256(4::text::bytea), -4);
|
||||
ALTER TABLE test_tab ADD COLUMN d INT;
|
||||
SAVEPOINT s2;
|
||||
INSERT INTO test_tab VALUES (5, md5(5::text), -5, 5*2);
|
||||
INSERT INTO test_tab VALUES (5, sha256(5::text::bytea), -5, 5*2);
|
||||
ALTER TABLE test_tab ADD COLUMN e INT;
|
||||
SAVEPOINT s3;
|
||||
INSERT INTO test_tab VALUES (6, md5(6::text), -6, 6*2, -6*3);
|
||||
INSERT INTO test_tab VALUES (6, sha256(6::text::bytea), -6, 6*2, -6*3);
|
||||
ALTER TABLE test_tab DROP COLUMN c;
|
||||
ROLLBACK TO s1;
|
||||
INSERT INTO test_tab VALUES (4, md5(4::text), 4);
|
||||
INSERT INTO test_tab VALUES (4, sha256(4::text::bytea), 4);
|
||||
COMMIT;
|
||||
});
|
||||
|
||||
|
@ -59,17 +59,17 @@ $node_C->safe_psql('postgres', "CREATE TABLE tab_full (a int PRIMARY KEY)");
|
||||
|
||||
# Create some pre-existing content on node_A (for streaming tests)
|
||||
$node_A->safe_psql('postgres',
|
||||
"CREATE TABLE test_tab (a int primary key, b varchar)");
|
||||
"CREATE TABLE test_tab (a int primary key, b bytea)");
|
||||
$node_A->safe_psql('postgres',
|
||||
"INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')");
|
||||
|
||||
# Create the same tables on node_B and node_C
|
||||
# columns a and b are compatible with same table name on node_A
|
||||
$node_B->safe_psql('postgres',
|
||||
"CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"
|
||||
"CREATE TABLE test_tab (a int primary key, b bytea, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"
|
||||
);
|
||||
$node_C->safe_psql('postgres',
|
||||
"CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"
|
||||
"CREATE TABLE test_tab (a int primary key, b bytea, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"
|
||||
);
|
||||
|
||||
# Setup logical replication
|
||||
@ -308,8 +308,8 @@ $node_B->poll_query_until(
|
||||
$node_A->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(3, 5000) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(3, 5000) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
PREPARE TRANSACTION 'test_prepared_tab';});
|
||||
|
||||
@ -371,8 +371,8 @@ $node_A->safe_psql(
|
||||
BEGIN;
|
||||
INSERT INTO test_tab VALUES (9999, 'foobar');
|
||||
SAVEPOINT sp_inner;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(3, 5000) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(3, 5000) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
ROLLBACK TO SAVEPOINT sp_inner;
|
||||
PREPARE TRANSACTION 'outer';
|
||||
|
@ -45,8 +45,8 @@ sub test_streaming
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(3, 5) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(3, 5) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
PREPARE TRANSACTION 'test_prepared_tab';});
|
||||
|
||||
@ -95,8 +95,8 @@ sub test_streaming
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(3, 5) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(3, 5) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
PREPARE TRANSACTION 'test_prepared_tab';});
|
||||
|
||||
@ -142,8 +142,8 @@ sub test_streaming
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(3, 5) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(3, 5) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
PREPARE TRANSACTION 'test_prepared_tab';});
|
||||
|
||||
@ -191,8 +191,8 @@ sub test_streaming
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(3, 5) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(3, 5) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
PREPARE TRANSACTION 'test_prepared_tab';});
|
||||
|
||||
@ -249,8 +249,8 @@ sub test_streaming
|
||||
$node_publisher->safe_psql(
|
||||
'postgres', q{
|
||||
BEGIN;
|
||||
INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(3, 5) s(i);
|
||||
UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
|
||||
INSERT INTO test_tab SELECT i, sha256(i::text::bytea) FROM generate_series(3, 5) s(i);
|
||||
UPDATE test_tab SET b = sha256(b) WHERE mod(a,2) = 0;
|
||||
DELETE FROM test_tab WHERE mod(a,3) = 0;
|
||||
PREPARE TRANSACTION 'test_prepared_tab';});
|
||||
|
||||
@ -316,14 +316,14 @@ $node_subscriber->start;
|
||||
|
||||
# Create some pre-existing content on publisher
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE TABLE test_tab (a int primary key, b varchar)");
|
||||
"CREATE TABLE test_tab (a int primary key, b bytea)");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')");
|
||||
$node_publisher->safe_psql('postgres', "CREATE TABLE test_tab_2 (a int)");
|
||||
|
||||
# Setup structure on subscriber (columns a and b are compatible with same table name on publisher)
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"
|
||||
"CREATE TABLE test_tab (a int primary key, b bytea, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"
|
||||
);
|
||||
$node_subscriber->safe_psql('postgres', "CREATE TABLE test_tab_2 (a int)");
|
||||
|
||||
|
@ -91,13 +91,13 @@ $node_subscriber->start;
|
||||
$node_publisher->safe_psql(
|
||||
'postgres',
|
||||
qq[
|
||||
CREATE TABLE tbl (i INT, t TEXT);
|
||||
CREATE TABLE tbl (i INT, t BYTEA);
|
||||
INSERT INTO tbl VALUES (1, NULL);
|
||||
]);
|
||||
$node_subscriber->safe_psql(
|
||||
'postgres',
|
||||
qq[
|
||||
CREATE TABLE tbl (i INT PRIMARY KEY, t TEXT);
|
||||
CREATE TABLE tbl (i INT PRIMARY KEY, t BYTEA);
|
||||
INSERT INTO tbl VALUES (1, NULL);
|
||||
]);
|
||||
|
||||
@ -163,10 +163,10 @@ $node_publisher->safe_psql(
|
||||
'postgres',
|
||||
qq[
|
||||
BEGIN;
|
||||
INSERT INTO tbl SELECT i, md5(i::text) FROM generate_series(1, 10000) s(i);
|
||||
INSERT INTO tbl SELECT i, sha256(i::text::bytea) FROM generate_series(1, 10000) s(i);
|
||||
COMMIT;
|
||||
]);
|
||||
test_skip_lsn($node_publisher, $node_subscriber, "(4, md5(4::text))",
|
||||
test_skip_lsn($node_publisher, $node_subscriber, "(4, sha256(4::text::bytea))",
|
||||
"4", "test skipping stream-commit");
|
||||
|
||||
$result = $node_subscriber->safe_psql('postgres',
|
||||
|
Loading…
Reference in New Issue
Block a user