postgres.git / summary / log / commit / refs

commit    a949b7320fdfad445453375a1630f81f6bd3b49d
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Wed Nov 30 18:01:41 2022 +0000

    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


src/test/regress/pg_regress.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index 27486cf5385..362b638f505 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -2308,6 +2308,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 [parent: 5d208b90b75b]