Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d10fad9

Browse files
committed
Adjust new pg_read_file() test cases for more portability.
It's allowed for an installation to remove postgresql.auto.conf, so don't rely on that being present. Instead probe whether we can read postmaster.pid. (If you've removed that, you broke the data directory's multiple-postmaster interlock, not to mention pg_ctl.) Per gripe from Michael Paquier. Discussion: https://postgr.es/m/YuSZTsoBMObyY+vT@paquier.xyz
1 parent 212bdc0 commit d10fad9

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/test/regress/expected/misc_functions.out

+7-7
Original file line numberDiff line numberDiff line change
@@ -373,16 +373,16 @@ select count(*) >= 0 as ok from pg_ls_archive_statusdir();
373373
(1 row)
374374

375375
-- pg_read_file()
376-
select length(pg_read_file('postgresql.auto.conf')) > 30;
376+
select length(pg_read_file('postmaster.pid')) > 20;
377377
?column?
378378
----------
379379
t
380380
(1 row)
381381

382-
select length(pg_read_file('postgresql.auto.conf', 1, 30));
382+
select length(pg_read_file('postmaster.pid', 1, 20));
383383
length
384384
--------
385-
30
385+
20
386386
(1 row)
387387

388388
-- Test missing_ok
@@ -400,16 +400,16 @@ ERROR: requested length cannot be negative
400400
select pg_read_file('does not exist', 0, -1, true); -- error
401401
ERROR: requested length cannot be negative
402402
-- pg_read_binary_file()
403-
select length(pg_read_binary_file('postgresql.auto.conf')) > 30;
403+
select length(pg_read_binary_file('postmaster.pid')) > 20;
404404
?column?
405405
----------
406406
t
407407
(1 row)
408408

409-
select length(pg_read_binary_file('postgresql.auto.conf', 1, 30));
409+
select length(pg_read_binary_file('postmaster.pid', 1, 20));
410410
length
411411
--------
412-
30
412+
20
413413
(1 row)
414414

415415
-- Test missing_ok
@@ -427,7 +427,7 @@ ERROR: requested length cannot be negative
427427
select pg_read_binary_file('does not exist', 0, -1, true); -- error
428428
ERROR: requested length cannot be negative
429429
-- pg_stat_file()
430-
select size > 30, isdir from pg_stat_file('postgresql.auto.conf');
430+
select size > 20, isdir from pg_stat_file('postmaster.pid');
431431
?column? | isdir
432432
----------+-------
433433
t | f

src/test/regress/sql/misc_functions.sql

+5-5
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ from (select pg_ls_waldir() w) ss where length((w).name) = 24 limit 1;
124124
select count(*) >= 0 as ok from pg_ls_archive_statusdir();
125125

126126
-- pg_read_file()
127-
select length(pg_read_file('postgresql.auto.conf')) > 30;
128-
select length(pg_read_file('postgresql.auto.conf', 1, 30));
127+
select length(pg_read_file('postmaster.pid')) > 20;
128+
select length(pg_read_file('postmaster.pid', 1, 20));
129129
-- Test missing_ok
130130
select pg_read_file('does not exist'); -- error
131131
select pg_read_file('does not exist', true) IS NULL; -- ok
@@ -134,8 +134,8 @@ select pg_read_file('does not exist', 0, -1); -- error
134134
select pg_read_file('does not exist', 0, -1, true); -- error
135135

136136
-- pg_read_binary_file()
137-
select length(pg_read_binary_file('postgresql.auto.conf')) > 30;
138-
select length(pg_read_binary_file('postgresql.auto.conf', 1, 30));
137+
select length(pg_read_binary_file('postmaster.pid')) > 20;
138+
select length(pg_read_binary_file('postmaster.pid', 1, 20));
139139
-- Test missing_ok
140140
select pg_read_binary_file('does not exist'); -- error
141141
select pg_read_binary_file('does not exist', true) IS NULL; -- ok
@@ -144,7 +144,7 @@ select pg_read_binary_file('does not exist', 0, -1); -- error
144144
select pg_read_binary_file('does not exist', 0, -1, true); -- error
145145

146146
-- pg_stat_file()
147-
select size > 30, isdir from pg_stat_file('postgresql.auto.conf');
147+
select size > 20, isdir from pg_stat_file('postmaster.pid');
148148

149149
-- pg_ls_dir()
150150
select * from (select pg_ls_dir('.') a) a where a = 'base' limit 1;

0 commit comments

Comments
 (0)