diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-11-30 13:01:41 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-11-30 13:01:41 -0500 |
commit | d5515ca7cf1b095fab65c93710c71fece5baf67e (patch) | |
tree | c8d853faa4d359b918dd2fad610c2f7a5e1273b1 | |
parent | 8f2e74bf87e8c60c4984924caa67b723c51e0a6e (diff) | |
download | postgresql-d5515ca7cf1b095fab65c93710c71fece5baf67e.tar.gz postgresql-d5515ca7cf1b095fab65c93710c71fece5baf67e.zip |
Reject missing database name in pg_regress and cohorts.
Writing "pg_regress --dbname= ..." led to a crash, because
we weren't expecting there to be no database name supplied.
It doesn't seem like a great idea to run regression tests
in whatever is the user's default database; so rather than
supporting this case let's explicitly reject it.
Per report from Xing Guo. Back-patch to all supported
branches.
Discussion: https://postgr.es/m/CACpMh+A8cRvtvtOWVAZsCM1DU81GK4DL26R83y6ugZ1osV=ifA@mail.gmail.com
-rw-r--r-- | src/test/regress/pg_regress.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index dda076847a3..f308da6c503 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -2182,6 +2182,17 @@ regression_main(int argc, char *argv[], optind++; } + /* + * We must have a database to run the tests in; either a default name, or + * one supplied by the --dbname switch. + */ + if (!(dblist && dblist->str && dblist->str[0])) + { + fprintf(stderr, _("%s: no database name was specified\n"), + progname); + exit(2); + } + if (config_auth_datadir) { #ifdef ENABLE_SSPI |