PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16484
PG Version13beta1
OSlinux, windows
Opened2020-06-08 05:45:30+00
Reported byRoman Zharkov
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16484
Logged by:          Roman Zharkov
Email address:      (redacted)
PostgreSQL version: 13beta1
Operating system:   linux, windows
Description:        

Hello,
pg_regress fails when i try to change the output directory with
"--outputdir" parameter.
This happens bacause pg_regress creates the output directory, but doesn't
create sql and expected subdirectories.

Here is an example:

$ ./pg_regress int8 --dlpath=.
(using postmaster on Unix socket, default port)
============== dropping database "regression"         ==============
DROP DATABASE
============== creating database "regression"         ==============
CREATE DATABASE
ALTER DATABASE
============== running regression test queries        ==============
test int8                         ... ok          122 ms

=====================
 All 1 tests passed. 
=====================

$ ./pg_regress int8 --dlpath=. --outputdir=~regress_output
(using postmaster on Unix socket, default port)
pg_regress: could not open file "~regress_output/sql/largeobject.sql" for
writing: Нет такого файла или каталога
$ mkdir ~regress_output/sql
$ ./pg_regress int8 --dlpath=. --outputdir=~regress_output
(using postmaster on Unix socket, default port)
pg_regress: could not open file
"~regress_output/expected/create_function_2.out" for writing: Нет такого
файла или каталога
$ mkdir ~regress_output/expected
$ ./pg_regress int8 --dlpath=. --outputdir=~regress_output
(using postmaster on Unix socket, default port)
============== dropping database "regression"         ==============
DROP DATABASE
============== creating database "regression"         ==============
CREATE DATABASE
ALTER DATABASE
============== running regression test queries        ==============
test int8                         ... ok          174 ms

=====================
 All 1 tests passed. 
=====================

This patch can fix the issue:

diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 38b2b1e8e1b..1eb1122d237 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -465,6 +465,7 @@ convert_sourcefiles_in(const char *source_subdir, const
char *dest_dir, const ch
 {
 	char		testtablespace[MAXPGPATH];
 	char		indir[MAXPGPATH];
+	char		output_subdir[MAXPGPATH];
 	struct stat st;
 	int			ret;
 	char	  **name;
@@ -473,6 +474,11 @@ convert_sourcefiles_in(const char *source_subdir, const
char *dest_dir, const ch
 
 	snprintf(indir, MAXPGPATH, "%s/%s", inputdir, source_subdir);
 
+	/* Create dest_subdir directory if it not exists */
+	snprintf(output_subdir, MAXPGPATH, "%s/%s", dest_dir, dest_subdir);
+	if (!directory_exists(output_subdir))
+		make_directory(output_subdir);
+
 	/* Check that indir actually exists and is a directory */
 	ret = stat(indir, &st);
 	if (ret != 0 || !S_ISDIR(st.st_mode))

Messages

DateAuthorSubject
2020-06-08 05:45:30+00PG Bug reporting formBUG #16484: pg_regress fails with --outputdir parameter
2020-06-08 09:09:42+00Daniel GustafssonRe: BUG #16484: pg_regress fails with --outputdir parameter
2020-06-09 05:33:56+00Michael PaquierRe: BUG #16484: pg_regress fails with --outputdir parameter
2020-06-09 05:55:06+00Tom LaneRe: BUG #16484: pg_regress fails with --outputdir parameter
2020-06-09 08:28:32+00Daniel GustafssonRe: BUG #16484: pg_regress fails with --outputdir parameter
2020-06-11 08:27:36+00Michael PaquierRe: BUG #16484: pg_regress fails with --outputdir parameter
2020-06-11 09:59:20+00Daniel GustafssonRe: BUG #16484: pg_regress fails with --outputdir parameter
2020-06-13 05:12:01+00Michael PaquierRe: BUG #16484: pg_regress fails with --outputdir parameter