Skip to content

Commit d07fb68

Browse files
committed
Tighten some regexes with proper character escaping in pg_dump TAP tests
Some tests have been using regular expressions which have been lax in escaping dots, which may cause tests to pass when they should not. This make the whole set of tests more robust where needed. Author: David Rowley Reviewed-by: Daniel Gustafsson, Michael Paquier Discussion: https://postgr.es/m/CAKJS1f9jD8aVo1BTH+Vgwd=f-ynbuRVrS90XbWMT6UigaOQJTA@mail.gmail.com
1 parent f83419b commit d07fb68

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/bin/pg_dump/t/002_pg_dump.pl

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@
448448
},
449449

450450
'ALTER COLLATION test0 OWNER TO' => {
451-
regexp => qr/^ALTER COLLATION public.test0 OWNER TO .*;/m,
451+
regexp => qr/^\QALTER COLLATION public.test0 OWNER TO \E.*;/m,
452452
collation => 1,
453453
like => { %full_runs, section_pre_data => 1, },
454454
unlike => { %dump_test_schema_runs, no_owner => 1, },
@@ -757,7 +757,7 @@
757757
},
758758

759759
'ALTER TABLE test_table OWNER TO' => {
760-
regexp => qr/^ALTER TABLE dump_test.test_table OWNER TO .*;/m,
760+
regexp => qr/^\QALTER TABLE dump_test.test_table OWNER TO \E.*;/m,
761761
like => {
762762
%full_runs,
763763
%dump_test_schema_runs,
@@ -776,7 +776,7 @@
776776
create_sql => 'ALTER TABLE dump_test.test_table
777777
ENABLE ROW LEVEL SECURITY;',
778778
regexp =>
779-
qr/^ALTER TABLE dump_test.test_table ENABLE ROW LEVEL SECURITY;/m,
779+
qr/^\QALTER TABLE dump_test.test_table ENABLE ROW LEVEL SECURITY;\E/m,
780780
like => {
781781
%full_runs,
782782
%dump_test_schema_runs,
@@ -790,7 +790,7 @@
790790
},
791791

792792
'ALTER TABLE test_second_table OWNER TO' => {
793-
regexp => qr/^ALTER TABLE dump_test.test_second_table OWNER TO .*;/m,
793+
regexp => qr/^\QALTER TABLE dump_test.test_second_table OWNER TO \E.*;/m,
794794
like =>
795795
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
796796
unlike => {
@@ -800,7 +800,7 @@
800800
},
801801

802802
'ALTER TABLE measurement OWNER TO' => {
803-
regexp => qr/^ALTER TABLE dump_test.measurement OWNER TO .*;/m,
803+
regexp => qr/^\QALTER TABLE dump_test.measurement OWNER TO \E.*;/m,
804804
like =>
805805
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
806806
unlike => {
@@ -811,7 +811,7 @@
811811

812812
'ALTER TABLE measurement_y2006m2 OWNER TO' => {
813813
regexp =>
814-
qr/^ALTER TABLE dump_test_second_schema.measurement_y2006m2 OWNER TO .*;/m,
814+
qr/^\QALTER TABLE dump_test_second_schema.measurement_y2006m2 OWNER TO \E.*;/m,
815815
like => {
816816
%full_runs,
817817
role => 1,
@@ -822,7 +822,7 @@
822822

823823
'ALTER FOREIGN TABLE foreign_table OWNER TO' => {
824824
regexp =>
825-
qr/^ALTER FOREIGN TABLE dump_test.foreign_table OWNER TO .*;/m,
825+
qr/^\QALTER FOREIGN TABLE dump_test.foreign_table OWNER TO \E.*;/m,
826826
like =>
827827
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
828828
unlike => {
@@ -833,7 +833,7 @@
833833

834834
'ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 OWNER TO' => {
835835
regexp =>
836-
qr/^ALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 OWNER TO .*;/m,
836+
qr/^\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 OWNER TO \E.*;/m,
837837
like =>
838838
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
839839
unlike => {
@@ -844,7 +844,7 @@
844844

845845
'ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 OWNER TO' => {
846846
regexp =>
847-
qr/^ALTER TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 OWNER TO .*;/m,
847+
qr/^\QALTER TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 OWNER TO \E.*;/m,
848848
like =>
849849
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
850850
unlike => {
@@ -913,7 +913,7 @@
913913
create_sql => 'COMMENT ON TABLE dump_test.test_table
914914
IS \'comment on table\';',
915915
regexp =>
916-
qr/^COMMENT ON TABLE dump_test.test_table IS 'comment on table';/m,
916+
qr/^\QCOMMENT ON TABLE dump_test.test_table IS 'comment on table';\E/m,
917917
like => {
918918
%full_runs,
919919
%dump_test_schema_runs,
@@ -986,7 +986,7 @@
986986
create_sql => 'COMMENT ON CONVERSION dump_test.test_conversion
987987
IS \'comment on test conversion\';',
988988
regexp =>
989-
qr/^COMMENT ON CONVERSION dump_test.test_conversion IS 'comment on test conversion';/m,
989+
qr/^\QCOMMENT ON CONVERSION dump_test.test_conversion IS 'comment on test conversion';\E/m,
990990
like =>
991991
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
992992
unlike => { exclude_dump_test_schema => 1, },
@@ -997,7 +997,7 @@
997997
create_sql => 'COMMENT ON COLLATION test0
998998
IS \'comment on test0 collation\';',
999999
regexp =>
1000-
qr/^COMMENT ON COLLATION public.test0 IS 'comment on test0 collation';/m,
1000+
qr/^\QCOMMENT ON COLLATION public.test0 IS 'comment on test0 collation';\E/m,
10011001
collation => 1,
10021002
like => { %full_runs, section_pre_data => 1, },
10031003
},
@@ -1051,7 +1051,7 @@
10511051
'COMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1
10521052
IS \'comment on text search configuration\';',
10531053
regexp =>
1054-
qr/^COMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 IS 'comment on text search configuration';/m,
1054+
qr/^\QCOMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 IS 'comment on text search configuration';\E/m,
10551055
like =>
10561056
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
10571057
unlike => { exclude_dump_test_schema => 1, },
@@ -1063,7 +1063,7 @@
10631063
'COMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1
10641064
IS \'comment on text search dictionary\';',
10651065
regexp =>
1066-
qr/^COMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 IS 'comment on text search dictionary';/m,
1066+
qr/^\QCOMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 IS 'comment on text search dictionary';\E/m,
10671067
like =>
10681068
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
10691069
unlike => { exclude_dump_test_schema => 1, },
@@ -1074,7 +1074,7 @@
10741074
create_sql => 'COMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1
10751075
IS \'comment on text search parser\';',
10761076
regexp =>
1077-
qr/^COMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1 IS 'comment on text search parser';/m,
1077+
qr/^\QCOMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1 IS 'comment on text search parser';\E/m,
10781078
like =>
10791079
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
10801080
unlike => { exclude_dump_test_schema => 1, },
@@ -1085,7 +1085,7 @@
10851085
create_sql => 'COMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1
10861086
IS \'comment on text search template\';',
10871087
regexp =>
1088-
qr/^COMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1 IS 'comment on text search template';/m,
1088+
qr/^\QCOMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1 IS 'comment on text search template';\E/m,
10891089
like =>
10901090
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
10911091
unlike => { exclude_dump_test_schema => 1, },
@@ -1096,7 +1096,7 @@
10961096
create_sql => 'COMMENT ON TYPE dump_test.planets
10971097
IS \'comment on enum type\';',
10981098
regexp =>
1099-
qr/^COMMENT ON TYPE dump_test.planets IS 'comment on enum type';/m,
1099+
qr/^\QCOMMENT ON TYPE dump_test.planets IS 'comment on enum type';\E/m,
11001100
like =>
11011101
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
11021102
unlike => { exclude_dump_test_schema => 1, },
@@ -1107,7 +1107,7 @@
11071107
create_sql => 'COMMENT ON TYPE dump_test.textrange
11081108
IS \'comment on range type\';',
11091109
regexp =>
1110-
qr/^COMMENT ON TYPE dump_test.textrange IS 'comment on range type';/m,
1110+
qr/^\QCOMMENT ON TYPE dump_test.textrange IS 'comment on range type';\E/m,
11111111
like =>
11121112
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
11131113
unlike => { exclude_dump_test_schema => 1, },
@@ -1118,7 +1118,7 @@
11181118
create_sql => 'COMMENT ON TYPE dump_test.int42
11191119
IS \'comment on regular type\';',
11201120
regexp =>
1121-
qr/^COMMENT ON TYPE dump_test.int42 IS 'comment on regular type';/m,
1121+
qr/^\QCOMMENT ON TYPE dump_test.int42 IS 'comment on regular type';\E/m,
11221122
like =>
11231123
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
11241124
unlike => { exclude_dump_test_schema => 1, },
@@ -1129,7 +1129,7 @@
11291129
create_sql => 'COMMENT ON TYPE dump_test.undefined
11301130
IS \'comment on undefined type\';',
11311131
regexp =>
1132-
qr/^COMMENT ON TYPE dump_test.undefined IS 'comment on undefined type';/m,
1132+
qr/^\QCOMMENT ON TYPE dump_test.undefined IS 'comment on undefined type';\E/m,
11331133
like =>
11341134
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
11351135
unlike => { exclude_dump_test_schema => 1, },
@@ -1282,14 +1282,14 @@
12821282

12831283
'INSERT INTO test_table' => {
12841284
regexp => qr/^
1285-
(?:INSERT\ INTO\ dump_test.test_table\ \(col1,\ col2,\ col3,\ col4\)\ VALUES\ \(\d,\ NULL,\ NULL,\ NULL\);\n){9}
1285+
(?:INSERT\ INTO\ dump_test\.test_table\ \(col1,\ col2,\ col3,\ col4\)\ VALUES\ \(\d,\ NULL,\ NULL,\ NULL\);\n){9}
12861286
/xm,
12871287
like => { column_inserts => 1, },
12881288
},
12891289

12901290
'INSERT INTO test_second_table' => {
12911291
regexp => qr/^
1292-
(?:INSERT\ INTO\ dump_test.test_second_table\ \(col1,\ col2\)
1292+
(?:INSERT\ INTO\ dump_test\.test_second_table\ \(col1,\ col2\)
12931293
\ VALUES\ \(\d,\ '\d'\);\n){9}/xm,
12941294
like => { column_inserts => 1, },
12951295
},
@@ -1620,7 +1620,7 @@
16201620
'CREATE TYPE dump_test.int42' => {
16211621
create_order => 39,
16221622
create_sql => 'CREATE TYPE dump_test.int42;',
1623-
regexp => qr/^CREATE TYPE dump_test.int42;/m,
1623+
regexp => qr/^\QCREATE TYPE dump_test.int42;\E/m,
16241624
like =>
16251625
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
16261626
unlike => { exclude_dump_test_schema => 1, },
@@ -1832,7 +1832,7 @@
18321832
'CREATE TYPE dump_test.undefined' => {
18331833
create_order => 39,
18341834
create_sql => 'CREATE TYPE dump_test.undefined;',
1835-
regexp => qr/^CREATE TYPE dump_test.undefined;/m,
1835+
regexp => qr/^\QCREATE TYPE dump_test.undefined;\E/m,
18361836
like =>
18371837
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
18381838
unlike => { exclude_dump_test_schema => 1, },
@@ -2770,7 +2770,7 @@
27702770
create_sql => 'GRANT SELECT ON TABLE dump_test.test_table
27712771
TO regress_dump_test_role;',
27722772
regexp =>
2773-
qr/^GRANT SELECT ON TABLE dump_test.test_table TO regress_dump_test_role;/m,
2773+
qr/^\QGRANT SELECT ON TABLE dump_test.test_table TO regress_dump_test_role;\E/m,
27742774
like => {
27752775
%full_runs,
27762776
%dump_test_schema_runs,
@@ -2790,7 +2790,7 @@
27902790
TABLE dump_test.measurement
27912791
TO regress_dump_test_role;',
27922792
regexp =>
2793-
qr/^GRANT SELECT ON TABLE dump_test.measurement TO regress_dump_test_role;/m,
2793+
qr/^\QGRANT SELECT ON TABLE dump_test.measurement TO regress_dump_test_role;\E/m,
27942794
like =>
27952795
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
27962796
unlike => {
@@ -2805,7 +2805,7 @@
28052805
TABLE dump_test_second_schema.measurement_y2006m2
28062806
TO regress_dump_test_role;',
28072807
regexp =>
2808-
qr/^GRANT SELECT ON TABLE dump_test_second_schema.measurement_y2006m2 TO regress_dump_test_role;/m,
2808+
qr/^\QGRANT SELECT ON TABLE dump_test_second_schema.measurement_y2006m2 TO regress_dump_test_role;\E/m,
28092809
like => {
28102810
%full_runs,
28112811
role => 1,
@@ -2948,7 +2948,7 @@
29482948
},
29492949
29502950
'REFRESH MATERIALIZED VIEW matview' => {
2951-
regexp => qr/^REFRESH MATERIALIZED VIEW dump_test.matview;/m,
2951+
regexp => qr/^\QREFRESH MATERIALIZED VIEW dump_test.matview;\E/m,
29522952
like =>
29532953
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
29542954
unlike => {
@@ -3015,7 +3015,7 @@
30153015
create_order => 45,
30163016
create_sql => 'REVOKE SELECT ON TABLE pg_proc FROM public;',
30173017
regexp =>
3018-
qr/^REVOKE SELECT ON TABLE pg_catalog.pg_proc FROM PUBLIC;/m,
3018+
qr/^\QREVOKE SELECT ON TABLE pg_catalog.pg_proc FROM PUBLIC;\E/m,
30193019
like => { %full_runs, section_pre_data => 1, },
30203020
unlike => { no_privs => 1, },
30213021
},

0 commit comments

Comments
 (0)