diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index 991bb17..fbf821d 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -85,6 +85,7 @@ char *inputdir = "."; char *outputdir = "."; char *psqldir = PGBINDIR; static _stringlist *loadlanguage = NULL; +static _stringlist *requirelanguage = NULL; static int max_connections = 0; static char *encoding = NULL; static _stringlist *schedulelist = NULL; @@ -1798,6 +1799,24 @@ create_database(const char *dbname) header(_("installing %s"), sl->str); psql_command(dbname, "CREATE LANGUAGE \"%s\"", sl->str); } + + /* + * Make sure any required procedural languages are installed. + */ + for (sl = requirelanguage; sl != NULL; sl = sl->next) + { + header(_("making sure %s is installed"), sl->str); + psql_command(dbname, + "DO LANGUAGE plpgsql $$" + "BEGIN" + " IF NOT EXISTS" + " (SELECT 1 FROM pg_catalog.pg_language WHERE lanname='%s')" + " THEN" + " CREATE LANGUAGE %s;" + " END IF;" + "END" + "$$", sl->str, sl->str); + } } static void @@ -1860,6 +1879,8 @@ help(void) printf(_(" --inputdir=DIR take input files from DIR (default \".\")\n")); printf(_(" --load-language=lang load the named language before running the\n")); printf(_(" tests; can appear multiple times\n")); + printf(_(" --require-language=lang make sure the named language is loaded before\n")); + printf(_(" running the tests; can appear multiple times\n")); printf(_(" --create-role=ROLE create the specified role before testing\n")); printf(_(" --max-connections=N maximum number of concurrent connections\n")); printf(_(" (default is 0 meaning unlimited)\n")); @@ -1920,6 +1941,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc {"create-role", required_argument, NULL, 18}, {"temp-config", required_argument, NULL, 19}, {"use-existing", no_argument, NULL, 20}, + {"require-language", required_argument, NULL, 21}, {NULL, 0, NULL, 0} }; @@ -2013,6 +2035,9 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc case 20: use_existing = true; break; + case 21: + add_stringlist_item(&requirelanguage, optarg); + break; default: /* getopt_long already emitted a complaint */ fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),