Continuing the work started with 208bf364a9, this patch 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. 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.From 4b967dd39e73f33faa1be3a5b577f77da169e74d Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Wed, 7 Jun 2023 08:24:03 +0200
Subject: [PATCH 1/3] 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.
---
contrib/bloom/expected/bloom.out | 32 ++++++++---------
contrib/bloom/sql/bloom.sql | 8 ++---
contrib/bloom/t/001_wal.pl | 4 +--
.../expected/concurrent_stream.out | 6 ++--
.../specs/concurrent_stream.spec | 8 ++---
.../specs/insert-conflict-specconflict.spec | 2 +-
src/test/recovery/t/015_promotion_pages.pl | 4 +--
.../recovery/t/026_overwrite_contrecord.pl | 2 +-
src/test/subscription/t/008_diff_schema.pl | 4 +--
src/test/subscription/t/015_stream.pl | 16 ++++-----
src/test/subscription/t/016_stream_subxact.pl | 24 ++++++-------
src/test/subscription/t/017_stream_ddl.pl | 18 +++++-----
.../t/018_stream_subxact_abort.pl | 34 +++++++++----------
.../t/019_stream_subxact_ddl_abort.pl | 14 ++++----
.../subscription/t/022_twophase_cascade.pl | 14 ++++----
.../subscription/t/023_twophase_stream.pl | 24 ++++++-------
src/test/subscription/t/029_on_error.pl | 8 ++---
17 files changed, 111 insertions(+), 111 deletions(-)
diff --git a/contrib/bloom/expected/bloom.out b/contrib/bloom/expected/bloom.out
index dae12a7d3e..edc855121e 100644
--- a/contrib/bloom/expected/bloom.out
+++ b/contrib/bloom/expected/bloom.out
@@ -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;
diff --git a/contrib/bloom/sql/bloom.sql b/contrib/bloom/sql/bloom.sql
index 4733e1e705..fa63b301c6 100644
--- a/contrib/bloom/sql/bloom.sql
+++ b/contrib/bloom/sql/bloom.sql
@@ -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 @@ CREATE INDEX bloomidx ON tst USING bloom (i, t) WITH (col1 =
3);
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 @@ CREATE INDEX bloomidx ON tst USING bloom (i, t) WITH (col1 =
3);
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;
diff --git a/contrib/bloom/t/001_wal.pl b/contrib/bloom/t/001_wal.pl
index c1614e9be8..2a69ff1a74 100644
--- a/contrib/bloom/t/001_wal.pl
+++ b/contrib/bloom/t/001_wal.pl
@@ -59,7 +59,7 @@ sub test_index_replay
$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 @@ sub test_index_replay
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");
}
diff --git a/contrib/test_decoding/expected/concurrent_stream.out
b/contrib/test_decoding/expected/concurrent_stream.out
index bf1e1326c6..1e5e2d1b11 100644
--- a/contrib/test_decoding/expected/concurrent_stream.out
+++ b/contrib/test_decoding/expected/concurrent_stream.out
@@ -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
diff --git a/contrib/test_decoding/specs/concurrent_stream.spec
b/contrib/test_decoding/specs/concurrent_stream.spec
index 54218a4b3f..7b5c3ec79d 100644
--- a/contrib/test_decoding/specs/concurrent_stream.spec
+++ b/contrib/test_decoding/specs/concurrent_stream.spec
@@ -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; }
diff --git a/src/test/isolation/specs/insert-conflict-specconflict.spec
b/src/test/isolation/specs/insert-conflict-specconflict.spec
index 0d55a015b6..6674820867 100644
--- a/src/test/isolation/specs/insert-conflict-specconflict.spec
+++ b/src/test/isolation/specs/insert-conflict-specconflict.spec
@@ -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);
diff --git a/src/test/recovery/t/015_promotion_pages.pl
b/src/test/recovery/t/015_promotion_pages.pl
index 271c93aa8b..beeb9dfddf 100644
--- a/src/test/recovery/t/015_promotion_pages.pl
+++ b/src/test/recovery/t/015_promotion_pages.pl
@@ -54,9 +54,9 @@
# 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.
diff --git a/src/test/recovery/t/026_overwrite_contrecord.pl
b/src/test/recovery/t/026_overwrite_contrecord.pl
index fad1811ca8..6807a97f26 100644
--- a/src/test/recovery/t/026_overwrite_contrecord.pl
+++ b/src/test/recovery/t/026_overwrite_contrecord.pl
@@ -39,7 +39,7 @@
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;
diff --git a/src/test/subscription/t/008_diff_schema.pl
b/src/test/subscription/t/008_diff_schema.pl
index 67db1ebd3c..c6e41b65b9 100644
--- a/src/test/subscription/t/008_diff_schema.pl
+++ b/src/test/subscription/t/008_diff_schema.pl
@@ -48,7 +48,7 @@
# 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 @@
"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');
diff --git a/src/test/subscription/t/015_stream.pl
b/src/test/subscription/t/015_stream.pl
index 5c00711ef2..441c818b09 100644
--- a/src/test/subscription/t/015_stream.pl
+++ b/src/test/subscription/t/015_stream.pl
@@ -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::bytea) 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::bytea) 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 @@ sub test_streaming
# 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 @@ sub test_streaming
# 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)");
diff --git a/src/test/subscription/t/016_stream_subxact.pl
b/src/test/subscription/t/016_stream_subxact.pl
index d830f26e06..5787ec4b82 100644
--- a/src/test/subscription/t/016_stream_subxact.pl
+++ b/src/test/subscription/t/016_stream_subxact.pl
@@ -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::bytea) 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::bytea) 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::bytea) 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::bytea) 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::bytea) WHERE mod(a,2) = 0;
DELETE FROM test_tab WHERE mod(a,3) = 0;
COMMIT;
});
@@ -89,13 +89,13 @@ sub test_streaming
# 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
diff --git a/src/test/subscription/t/017_stream_ddl.pl
b/src/test/subscription/t/017_stream_ddl.pl
index 626676a383..d00ede44ed 100644
--- a/src/test/subscription/t/017_stream_ddl.pl
+++ b/src/test/subscription/t/017_stream_ddl.pl
@@ -31,7 +31,7 @@
# 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 @@
$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 @@
$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 @@
$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 @@
$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 @@
$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;
});
diff --git a/src/test/subscription/t/018_stream_subxact_abort.pl
b/src/test/subscription/t/018_stream_subxact_abort.pl
index 91d19ae672..77c96011a9 100644
--- a/src/test/subscription/t/018_stream_subxact_abort.pl
+++ b/src/test/subscription/t/018_stream_subxact_abort.pl
@@ -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 @@ sub test_streaming
# 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)");
diff --git a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
index d0e556c8b8..6c2a9c5bf1 100644
--- a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
+++ b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
@@ -26,13 +26,13 @@
# 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 @@
$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;
});
diff --git a/src/test/subscription/t/022_twophase_cascade.pl
b/src/test/subscription/t/022_twophase_cascade.pl
index e624ebe55c..5a89a364cd 100644
--- a/src/test/subscription/t/022_twophase_cascade.pl
+++ b/src/test/subscription/t/022_twophase_cascade.pl
@@ -59,17 +59,17 @@
# 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_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::bytea) WHERE mod(a,2) = 0;
DELETE FROM test_tab WHERE mod(a,3) = 0;
PREPARE TRANSACTION 'test_prepared_tab';});
@@ -371,8 +371,8 @@
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::bytea) WHERE mod(a,2) = 0;
DELETE FROM test_tab WHERE mod(a,3) = 0;
ROLLBACK TO SAVEPOINT sp_inner;
PREPARE TRANSACTION 'outer';
diff --git a/src/test/subscription/t/023_twophase_stream.pl
b/src/test/subscription/t/023_twophase_stream.pl
index fdcc4b359d..9fc3952d7b 100644
--- a/src/test/subscription/t/023_twophase_stream.pl
+++ b/src/test/subscription/t/023_twophase_stream.pl
@@ -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::bytea) 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::bytea) 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::bytea) 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::bytea) 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::bytea) WHERE mod(a,2) = 0;
DELETE FROM test_tab WHERE mod(a,3) = 0;
PREPARE TRANSACTION 'test_prepared_tab';});
@@ -316,14 +316,14 @@ sub test_streaming
# 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)");
diff --git a/src/test/subscription/t/029_on_error.pl
b/src/test/subscription/t/029_on_error.pl
index 7d6fb66985..fcab7386fe 100644
--- a/src/test/subscription/t/029_on_error.pl
+++ b/src/test/subscription/t/029_on_error.pl
@@ -91,13 +91,13 @@ sub test_skip_lsn
$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 @@ sub test_skip_lsn
'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',
--
2.40.1