Remove incidental md5() function uses from several tests
authorPeter Eisentraut <[email protected]>
Tue, 4 Jul 2023 12:31:57 +0000 (14:31 +0200)
committerPeter Eisentraut <[email protected]>
Tue, 4 Jul 2023 12:31:57 +0000 (14:31 +0200)
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 <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/f9b480b5-e473-d2d1-223a-4b9db30a229a@eisentraut.org

17 files changed:
contrib/bloom/expected/bloom.out
contrib/bloom/sql/bloom.sql
contrib/bloom/t/001_wal.pl
contrib/test_decoding/expected/concurrent_stream.out
contrib/test_decoding/specs/concurrent_stream.spec
src/test/isolation/specs/insert-conflict-specconflict.spec
src/test/recovery/t/015_promotion_pages.pl
src/test/recovery/t/026_overwrite_contrecord.pl
src/test/subscription/t/008_diff_schema.pl
src/test/subscription/t/015_stream.pl
src/test/subscription/t/016_stream_subxact.pl
src/test/subscription/t/017_stream_ddl.pl
src/test/subscription/t/018_stream_subxact_abort.pl
src/test/subscription/t/019_stream_subxact_ddl_abort.pl
src/test/subscription/t/022_twophase_cascade.pl
src/test/subscription/t/023_twophase_stream.pl
src/test/subscription/t/029_on_error.pl

index dae12a7d3e7e04763192adcb61ab0932133c8a57..edc855121e12e79ce5381cf927778d92cb90535f 100644 (file)
@@ -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;
index 4733e1e7050e5b864f53554ae2d536659bdecf69..fa63b301c6e4c04f8096e9eaa7becc980b63d994 100644 (file)
@@ -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;
index c1614e9be861cf253d98941749ca6335785e1971..2a69ff1a746bba3ce6db82a63940485dad2f4e56 100644 (file)
@@ -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");
 }
index bf1e1326c6196b4aebf3225f05ec9d0a5706befa..1e5e2d1b111d37935a347909a67327a3bd4ed0da 100644 (file)
@@ -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                                    
index 54218a4b3f6551b2048a333935597317d09a754d..7b5c3ec79d883e0a8a0ae53c413dddc819f14994 100644 (file)
@@ -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; }
index 0d55a015b6e5bd00ea33e4eaa119b6ace3c8629a..6674820867289b226cf7ea34e8e1b30215114324 100644 (file)
@@ -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);
 
index 271c93aa8b40bb33c093fd68cdf208918d4de9f5..beeb9dfddf753437509da83371cf6571e592dd54 100644 (file)
@@ -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.
index fad1811ca8d784e59f2bfaf59ef195ffa1022017..6807a97f26d51385766f65347d457ae29c859c75 100644 (file)
@@ -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;
index 67db1ebd3cdbf795a0989e1d5ccba88a92753e0b..c6e41b65b9fc6d456a6b5b55b743be97f4b307bb 100644 (file)
@@ -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');
 
index 5c00711ef2d6ec70547bb373fb64bf9ce811b470..b450a78adf78d614ab80ae10c111da6532c6ddcb 100644 (file)
@@ -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)");
index d830f26e06f4b72ef112e3881b5e44c1620fd3cc..838049af65c36ff435f005652475dcd4ca754a77 100644 (file)
@@ -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
index 626676a383b3a47ccbc3faace9a3aa726e860d73..d00ede44ed133a8a84d3c5ab69abf60e4eafb15e 100644 (file)
@@ -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;
 });
 
index 91d19ae672ad7e2f44b3191124b24f799b2dff9e..77c96011a9236f3edb81edcca57384e5a9b42fe2 100644 (file)
@@ -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)");
index d0e556c8b8307f03ad8ea87ad407f9de5868bc7c..6c2a9c5bf123fc75731829900011b11636a9d0b2 100644 (file)
@@ -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;
 });
 
index e624ebe55c600e8a6886dceefca60401020b174b..b37ed95c9e24b5f9d77db8b38e2b0cb575c1f7a3 100644 (file)
@@ -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';
index fdcc4b359d2aee08bb964f13fb776afb98f29bc3..fdc9e2a0f047c9df63d0ded0d4848602932ad1a5 100644 (file)
@@ -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)");
 
index 7d6fb66985ae24543851a5d315d5bcd585ee6a41..fcab7386feec253107f04ac1f3d94674190e86f1 100644 (file)
@@ -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',