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;
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;
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
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
-------
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;
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
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;
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;
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);
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;
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';
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;
$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);");
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");
}
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
-- 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
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
# 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; }
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);
# 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.
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;
# 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');
"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');
$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;
});
$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;
});
$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);
# 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)"
);
$node_subscriber->safe_psql('postgres', "CREATE TABLE test_tab_2 (a int)");
$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;
});
# 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
# 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
$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;
});
$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;
});
$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;
});
$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;
});
$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;
});
$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;
});
$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;
});
$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;
});
# 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)");
# 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';
$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;
});
# 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
$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';});
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';
$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';});
$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';});
$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';});
$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';});
$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';});
# 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)");
$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);
]);
'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',