Skip to content

Commit

Permalink
Reject missing database name in pg_regress and cohorts.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tglsfdc committed Nov 30, 2022
1 parent 7b96f52 commit a587901
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/regress/pg_regress.c
Expand Up @@ -2257,6 +2257,17 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
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
Expand Down

0 comments on commit a587901

Please sign in to comment.