Skip to content

Commit 208bf36

Browse files
committed
Remove incidental md5() function uses from main regression tests
Most of these calls were to generate some random data. These can be replaced by appropriately adapted sha256() calls. To keep the diff smaller, we wrap this into a helper function that produces the same output format and length as the md5() call. This will eventually allow these tests to pass in OpenSSL FIPS mode (which does not allow MD5 use). Similar work for other test suites will follow later. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/dbbd927f-ef1f-c9a1-4ec6-c759778ac852@enterprisedb.com
1 parent d72900b commit 208bf36

26 files changed

+374
-353
lines changed

src/test/regress/expected/arrays.out

+3-3
Original file line numberDiff line numberDiff line change
@@ -2303,22 +2303,22 @@ insert into src
23032303
create type textandtext as (c1 text, c2 text);
23042304
create temp table dest (f1 textandtext[]);
23052305
insert into dest select array[row(f1,f1)::textandtext] from src;
2306-
select length(md5((f1[1]).c2)) from dest;
2306+
select length(fipshash((f1[1]).c2)) from dest;
23072307
length
23082308
--------
23092309
32
23102310
(1 row)
23112311

23122312
delete from src;
2313-
select length(md5((f1[1]).c2)) from dest;
2313+
select length(fipshash((f1[1]).c2)) from dest;
23142314
length
23152315
--------
23162316
32
23172317
(1 row)
23182318

23192319
truncate table src;
23202320
drop table src;
2321-
select length(md5((f1[1]).c2)) from dest;
2321+
select length(fipshash((f1[1]).c2)) from dest;
23222322
length
23232323
--------
23242324
32

src/test/regress/expected/brin.out

+2-2
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM brin_test WHERE b = 1;
530530
CREATE TABLE brintest_3 (a text, b text, c text, d text);
531531
-- long random strings (~2000 chars each, so ~6kB for min/max on two
532532
-- columns) to trigger toasting
533-
WITH rand_value AS (SELECT string_agg(md5(i::text),'') AS val FROM generate_series(1,60) s(i))
533+
WITH rand_value AS (SELECT string_agg(fipshash(i::text),'') AS val FROM generate_series(1,60) s(i))
534534
INSERT INTO brintest_3
535535
SELECT val, val, val, val FROM rand_value;
536536
CREATE INDEX brin_test_toast_idx ON brintest_3 USING brin (b, c);
@@ -545,7 +545,7 @@ VACUUM brintest_3;
545545
-- retry insert with a different random-looking (but deterministic) value
546546
-- the value is different, and so should replace either min or max in the
547547
-- brin summary
548-
WITH rand_value AS (SELECT string_agg(md5((-i)::text),'') AS val FROM generate_series(1,60) s(i))
548+
WITH rand_value AS (SELECT string_agg(fipshash((-i)::text),'') AS val FROM generate_series(1,60) s(i))
549549
INSERT INTO brintest_3
550550
SELECT val, val, val, val FROM rand_value;
551551
-- now try some queries, accessing the brin index

src/test/regress/expected/brin_multi.out

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ INSERT INTO brintest_multi SELECT
2929
(four + 1.0)/(hundred+1),
3030
odd::float8 / (tenthous + 1),
3131
format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr,
32-
substr(md5(unique1::text), 1, 16)::macaddr8,
32+
substr(fipshash(unique1::text), 1, 16)::macaddr8,
3333
inet '10.2.3.4/24' + tenthous,
3434
cidr '10.2.3/24' + tenthous,
3535
date '1995-08-15' + tenthous,
@@ -179,7 +179,7 @@ INSERT INTO brinopers_multi VALUES
179179
('macaddr8col', 'macaddr8',
180180
'{>, >=, =, <=, <}',
181181
'{b1:d1:0e:7b:af:a4:42:12, d9:35:91:bd:f7:86:0e:1e, 72:8f:20:6c:2a:01:bf:57, 23:e8:46:63:86:07:ad:cb, 13:16:8e:6a:2e:6c:84:b4}',
182-
'{33, 15, 1, 13, 6}'),
182+
'{31, 17, 1, 11, 4}'),
183183
('inetcol', 'inet',
184184
'{=, <, <=, >, >=}',
185185
'{10.2.14.231/24, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0}',
@@ -327,7 +327,7 @@ INSERT INTO brintest_multi SELECT
327327
(four + 1.0)/(hundred+1),
328328
odd::float8 / (tenthous + 1),
329329
format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr,
330-
substr(md5(unique1::text), 1, 16)::macaddr8,
330+
substr(fipshash(unique1::text), 1, 16)::macaddr8,
331331
inet '10.2.3.4' + tenthous,
332332
cidr '10.2.3/24' + tenthous,
333333
date '1995-08-15' + tenthous,

src/test/regress/expected/compression.out

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ SELECT pg_column_compression(f1) FROM cmmove2;
102102

103103
-- test externally stored compressed data
104104
CREATE OR REPLACE FUNCTION large_val() RETURNS TEXT LANGUAGE SQL AS
105-
'select array_agg(md5(g::text))::text from generate_series(1, 256) g';
105+
'select array_agg(fipshash(g::text))::text from generate_series(1, 256) g';
106106
CREATE TABLE cmdata2 (f1 text COMPRESSION pglz);
107107
INSERT INTO cmdata2 SELECT large_val() || repeat('a', 4000);
108108
SELECT pg_column_compression(f1) FROM cmdata2;
@@ -123,13 +123,13 @@ SELECT SUBSTR(f1, 200, 5) FROM cmdata1;
123123
substr
124124
--------
125125
01234
126-
8f14e
126+
79026
127127
(2 rows)
128128

129129
SELECT SUBSTR(f1, 200, 5) FROM cmdata2;
130130
substr
131131
--------
132-
8f14e
132+
79026
133133
(1 row)
134134

135135
DROP TABLE cmdata2;
@@ -317,7 +317,7 @@ SELECT pg_column_compression(f1) FROM cmdata;
317317
DROP TABLE cmdata2;
318318
CREATE TABLE cmdata2 (f1 TEXT COMPRESSION pglz, f2 TEXT COMPRESSION lz4);
319319
CREATE UNIQUE INDEX idx1 ON cmdata2 ((f1 || f2));
320-
INSERT INTO cmdata2 VALUES((SELECT array_agg(md5(g::TEXT))::TEXT FROM
320+
INSERT INTO cmdata2 VALUES((SELECT array_agg(fipshash(g::TEXT))::TEXT FROM
321321
generate_series(1, 50) g), VERSION());
322322
-- check data is ok
323323
SELECT length(f1) FROM cmdata;

src/test/regress/expected/compression_1.out

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ SELECT pg_column_compression(f1) FROM cmmove2;
102102

103103
-- test externally stored compressed data
104104
CREATE OR REPLACE FUNCTION large_val() RETURNS TEXT LANGUAGE SQL AS
105-
'select array_agg(md5(g::text))::text from generate_series(1, 256) g';
105+
'select array_agg(fipshash(g::text))::text from generate_series(1, 256) g';
106106
CREATE TABLE cmdata2 (f1 text COMPRESSION pglz);
107107
INSERT INTO cmdata2 SELECT large_val() || repeat('a', 4000);
108108
SELECT pg_column_compression(f1) FROM cmdata2;
@@ -126,7 +126,7 @@ LINE 1: SELECT SUBSTR(f1, 200, 5) FROM cmdata1;
126126
SELECT SUBSTR(f1, 200, 5) FROM cmdata2;
127127
substr
128128
--------
129-
8f14e
129+
79026
130130
(1 row)
131131

132132
DROP TABLE cmdata2;
@@ -312,10 +312,10 @@ ERROR: compression method lz4 not supported
312312
DETAIL: This functionality requires the server to be built with lz4 support.
313313
CREATE UNIQUE INDEX idx1 ON cmdata2 ((f1 || f2));
314314
ERROR: relation "cmdata2" does not exist
315-
INSERT INTO cmdata2 VALUES((SELECT array_agg(md5(g::TEXT))::TEXT FROM
315+
INSERT INTO cmdata2 VALUES((SELECT array_agg(fipshash(g::TEXT))::TEXT FROM
316316
generate_series(1, 50) g), VERSION());
317317
ERROR: relation "cmdata2" does not exist
318-
LINE 1: INSERT INTO cmdata2 VALUES((SELECT array_agg(md5(g::TEXT))::...
318+
LINE 1: INSERT INTO cmdata2 VALUES((SELECT array_agg(fipshash(g::TEXT)...
319319
^
320320
-- check data is ok
321321
SELECT length(f1) FROM cmdata;

src/test/regress/expected/inherit.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -2560,7 +2560,7 @@ alter table permtest_child attach partition permtest_grandchild for values in ('
25602560
alter table permtest_parent attach partition permtest_child for values in (1);
25612561
create index on permtest_parent (left(c, 3));
25622562
insert into permtest_parent
2563-
select 1, 'a', left(md5(i::text), 5) from generate_series(0, 100) i;
2563+
select 1, 'a', left(fipshash(i::text), 5) from generate_series(0, 100) i;
25642564
analyze permtest_parent;
25652565
create role regress_no_child_access;
25662566
revoke all on permtest_grandchild from regress_no_child_access;

src/test/regress/expected/largeobject.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ TRUNCATE lotest_stash_values;
441441
\set newloid_1 :LASTOID
442442
SELECT lo_from_bytea(0, lo_get(:newloid_1)) AS newloid_2
443443
\gset
444-
SELECT md5(lo_get(:newloid_1)) = md5(lo_get(:newloid_2));
444+
SELECT fipshash(lo_get(:newloid_1)) = fipshash(lo_get(:newloid_2));
445445
?column?
446446
----------
447447
t

src/test/regress/expected/largeobject_1.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ TRUNCATE lotest_stash_values;
441441
\set newloid_1 :LASTOID
442442
SELECT lo_from_bytea(0, lo_get(:newloid_1)) AS newloid_2
443443
\gset
444-
SELECT md5(lo_get(:newloid_1)) = md5(lo_get(:newloid_2));
444+
SELECT fipshash(lo_get(:newloid_1)) = fipshash(lo_get(:newloid_2));
445445
?column?
446446
----------
447447
t

src/test/regress/expected/matview.out

+4-4
Original file line numberDiff line numberDiff line change
@@ -556,10 +556,10 @@ SET ROLE regress_user_mvtest;
556556
-- duplicate all the aliases used in those queries
557557
CREATE TABLE mvtest_foo_data AS SELECT i,
558558
i+1 AS tid,
559-
md5(random()::text) AS mv,
560-
md5(random()::text) AS newdata,
561-
md5(random()::text) AS newdata2,
562-
md5(random()::text) AS diff
559+
fipshash(random()::text) AS mv,
560+
fipshash(random()::text) AS newdata,
561+
fipshash(random()::text) AS newdata2,
562+
fipshash(random()::text) AS diff
563563
FROM generate_series(1, 10) i;
564564
CREATE MATERIALIZED VIEW mvtest_mv_foo AS SELECT * FROM mvtest_foo_data;
565565
CREATE MATERIALIZED VIEW mvtest_mv_foo AS SELECT * FROM mvtest_foo_data;

src/test/regress/expected/memoize.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ DROP TABLE flt;
164164
CREATE TABLE strtest (n name, t text);
165165
CREATE INDEX strtest_n_idx ON strtest (n);
166166
CREATE INDEX strtest_t_idx ON strtest (t);
167-
INSERT INTO strtest VALUES('one','one'),('two','two'),('three',repeat(md5('three'),100));
167+
INSERT INTO strtest VALUES('one','one'),('two','two'),('three',repeat(fipshash('three'),100));
168168
-- duplicate rows so we get some cache hits
169169
INSERT INTO strtest SELECT * FROM strtest;
170170
ANALYZE strtest;

src/test/regress/expected/plpgsql.out

+10-10
Original file line numberDiff line numberDiff line change
@@ -3404,22 +3404,22 @@ select * from ret_query1();
34043404
create type record_type as (x text, y int, z boolean);
34053405
create or replace function ret_query2(lim int) returns setof record_type as $$
34063406
begin
3407-
return query select md5(s.x::text), s.x, s.x > 0
3407+
return query select fipshash(s.x::text), s.x, s.x > 0
34083408
from generate_series(-8, lim) s (x) where s.x % 2 = 0;
34093409
end;
34103410
$$ language plpgsql;
34113411
select * from ret_query2(8);
34123412
x | y | z
34133413
----------------------------------+----+---
3414-
a8d2ec85eaf98407310b72eb73dda247 | -8 | f
3415-
596a3d04481816330f07e4f97510c28f | -6 | f
3416-
0267aaf632e87a63288a08331f22c7c3 | -4 | f
3417-
5d7b9adcbe1c629ec722529dd12e5129 | -2 | f
3418-
cfcd208495d565ef66e7dff9f98764da | 0 | f
3419-
c81e728d9d4c2f636f067f89cc14862c | 2 | t
3420-
a87ff679a2f3e71d9181a67b7542122c | 4 | t
3421-
1679091c5a880faf6fb5e6087eb1b2dc | 6 | t
3422-
c9f0f895fb98ab9159f51fd0297e236d | 8 | t
3414+
e91592205d3881e3ea35d66973bb4898 | -8 | f
3415+
03b26944890929ff751653acb2f2af79 | -6 | f
3416+
e5e0093f285a4fb94c3fcc2ad7fd04ed | -4 | f
3417+
cf3bae39dd692048a8bf961182e6a34d | -2 | f
3418+
5feceb66ffc86f38d952786c6d696c79 | 0 | f
3419+
d4735e3a265e16eee03f59718b9b5d03 | 2 | t
3420+
4b227777d4dd1fc61c6f884f48641d02 | 4 | t
3421+
e7f6c011776e8db7cd330b54174fd76f | 6 | t
3422+
2c624232cdd221771294dfbb310aca00 | 8 | t
34233423
(9 rows)
34243424

34253425
-- test EXECUTE USING

0 commit comments

Comments
 (0)