8000 Reject missing database name in pg_regress and cohorts. · postgres/postgres@04f3acc · GitHub
[go: up one dir, main page]

Skip to content

Commit 04f3acc

Browse files
committed
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
1 parent 80e5916 commit 04f3acc

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/test/regress/pg_regress.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,6 +2220,17 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
22202220
optind++;
22212221
}
22222222

2223+
/*
2224+
* We must have a database to run the tests in; either a default name, or
2225+
* one supplied by the --dbname switch.
2226+
*/
2227+
if (!(dblist && dblist->str && dblist->str[0]))
2228+
{
2229+
fprintf(stderr, _("%s: no database name was specified\n"),
2230+
progname);
2231+
exit(2);
2232+
}
2233+
22232234
if (config_auth_datadir)
22242235
{
22252236
#ifdef ENABLE_SSPI

0 commit comments

Comments
 (0)
0