postgresql/src/test/regress/pg_regress_main.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

118 lines
3.0 KiB
C
Raw Normal View History

/*-------------------------------------------------------------------------
*
* pg_regress_main --- regression test for the main backend
*
* This is a C implementation of the previous shell script for running
* the regression tests, and should be mostly compatible with it.
* Initial author of C translation: Magnus Hagander
*
* This code is released under the terms of the PostgreSQL License.
*
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
2010-09-20 22:08:53 +02:00
* src/test/regress/pg_regress_main.c
*
*-------------------------------------------------------------------------
*/
#include "postgres_fe.h"
#include "lib/stringinfo.h"
#include "pg_regress.h"
/*
* start a psql test process for specified file (including redirection),
* and return process ID
*/
static PID_TYPE
psql_start_test(const char *testname,
_stringlist **resultfiles,
_stringlist **expectfiles,
_stringlist **tags)
{
PID_TYPE pid;
char infile[MAXPGPATH];
char outfile[MAXPGPATH];
char expectfile[MAXPGPATH];
StringInfoData psql_cmd;
char *appnameenv;
/*
* Look for files in the output dir first, consistent with a vpath search.
* This is mainly to create more reasonable error messages if the file is
* not found. It also allows local test overrides when running pg_regress
* outside of the source tree.
*/
snprintf(infile, sizeof(infile), "%s/sql/%s.sql",
outputdir, testname);
if (!file_exists(infile))
snprintf(infile, sizeof(infile), "%s/sql/%s.sql",
inputdir, testname);
snprintf(outfile, sizeof(outfile), "%s/results/%s.out",
outputdir, testname);
snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
expecteddir, testname);
if (!file_exists(expectfile))
snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
inputdir, testname);
add_stringlist_item(resultfiles, outfile);
add_stringlist_item(expectfiles, expectfile);
initStringInfo(&psql_cmd);
if (launcher)
appendStringInfo(&psql_cmd, "%s ", launcher);
2018-08-15 22:29:31 +02:00
tableam: introduce table AM infrastructure. This introduces the concept of table access methods, i.e. CREATE ACCESS METHOD ... TYPE TABLE and CREATE TABLE ... USING (storage-engine). No table access functionality is delegated to table AMs as of this commit, that'll be done in following commits. Subsequent commits will incrementally abstract table access functionality to be routed through table access methods. That change is too large to be reviewed & committed at once, so it'll be done incrementally. Docs will be updated at the end, as adding them incrementally would likely make them less coherent, and definitely is a lot more work, without a lot of benefit. Table access methods are specified similar to index access methods, i.e. pg_am.amhandler returns, as INTERNAL, a pointer to a struct with callbacks. In contrast to index AMs that struct needs to live as long as a backend, typically that's achieved by just returning a pointer to a constant struct. Psql's \d+ now displays a table's access method. That can be disabled with HIDE_TABLEAM=true, which is mainly useful so regression tests can be run against different AMs. It's quite possible that this behaviour still needs to be fine tuned. For now it's not allowed to set a table AM for a partitioned table, as we've not resolved how partitions would inherit that. Disallowing allows us to introduce, if we decide that's the way forward, such a behaviour without a compatibility break. Catversion bumped, to add the heap table AM and references to it. Author: Haribabu Kommi, Andres Freund, Alvaro Herrera, Dimitri Golgov and others Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de https://postgr.es/m/20160812231527.GA690404@alvherre.pgsql https://postgr.es/m/20190107235616.6lur25ph22u5u5av@alap3.anarazel.de https://postgr.es/m/20190304234700.w5tmhducs5wxgzls@alap3.anarazel.de
2019-03-06 18:54:38 +01:00
/*
* Use HIDE_TABLEAM to hide different AMs to allow to use regression tests
* against different AMs without unnecessary differences.
*/
appendStringInfo(&psql_cmd,
"\"%s%spsql\" -X -a -q -d \"%s\" %s < \"%s\" > \"%s\" 2>&1",
bindir ? bindir : "",
bindir ? "/" : "",
dblist->str,
"-v HIDE_TABLEAM=on -v HIDE_TOAST_COMPRESSION=on",
infile,
outfile);
appnameenv = psprintf("pg_regress/%s", testname);
setenv("PGAPPNAME", appnameenv, 1);
free(appnameenv);
pid = spawn_process(psql_cmd.data);
if (pid == INVALID_PID)
{
fprintf(stderr, _("could not start process for test %s\n"),
testname);
exit(2);
}
unsetenv("PGAPPNAME");
pfree(psql_cmd.data);
return pid;
}
static void
psql_init(int argc, char **argv)
{
/* set default regression database name */
add_stringlist_item(&dblist, "regression");
}
int
main(int argc, char *argv[])
{
return regression_main(argc, argv,
psql_init,
psql_start_test,
NULL /* no postfunc needed */ );
}