]> granicus.if.org Git - postgresql/blobdiff - src/test/regress/pg_regress_main.c
Fix initialization of fake LSN for unlogged relations
[postgresql] / src / test / regress / pg_regress_main.c
index a4f66b8a33f0bc7ec9c1b4773e5ba8aa0a81c8ef..f1df7557fa1e9335aae9a32df036f128414337a9 100644 (file)
@@ -8,7 +8,7 @@
  *
  * This code is released under the terms of the PostgreSQL License.
  *
- * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * src/test/regress/pg_regress_main.c
@@ -16,6 +16,8 @@
  *-------------------------------------------------------------------------
  */
 
+#include "postgres_fe.h"
+
 #include "pg_regress.h"
 
 /*
@@ -24,9 +26,9 @@
  */
 static PID_TYPE
 psql_start_test(const char *testname,
-                               _stringlist ** resultfiles,
-                               _stringlist ** expectfiles,
-                               _stringlist ** tags)
+                               _stringlist **resultfiles,
+                               _stringlist **expectfiles,
+                               _stringlist **tags)
 {
        PID_TYPE        pid;
        char            infile[MAXPGPATH];
@@ -34,6 +36,7 @@ psql_start_test(const char *testname,
        char            expectfile[MAXPGPATH];
        char            psql_cmd[MAXPGPATH * 3];
        size_t          offset = 0;
+       char       *appnameenv;
 
        /*
         * Look for files in the output dir first, consistent with a vpath search.
@@ -60,16 +63,36 @@ psql_start_test(const char *testname,
        add_stringlist_item(expectfiles, expectfile);
 
        if (launcher)
+       {
                offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
                                                   "%s ", launcher);
+               if (offset >= sizeof(psql_cmd))
+               {
+                       fprintf(stderr, _("command too long\n"));
+                       exit(2);
+               }
+       }
+
+       /*
+        * Use HIDE_TABLEAM to hide different AMs to allow to use regression tests
+        * against different AMs without unnecessary differences.
+        */
+       offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
+                                          "\"%s%spsql\" -X -a -q -d \"%s\" -v %s < \"%s\" > \"%s\" 2>&1",
+                                          bindir ? bindir : "",
+                                          bindir ? "/" : "",
+                                          dblist->str,
+                                          "HIDE_TABLEAM=\"on\"",
+                                          infile,
+                                          outfile);
+       if (offset >= sizeof(psql_cmd))
+       {
+               fprintf(stderr, _("command too long\n"));
+               exit(2);
+       }
 
-       snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
-                        SYSTEMQUOTE "\"%s%spsql\" -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
-                        psqldir ? psqldir : "",
-                        psqldir ? "/" : "",
-                        dblist->str,
-                        infile,
-                        outfile);
+       appnameenv = psprintf("PGAPPNAME=pg_regress/%s", testname);
+       putenv(appnameenv);
 
        pid = spawn_process(psql_cmd);
 
@@ -80,6 +103,9 @@ psql_start_test(const char *testname,
                exit(2);
        }
 
+       unsetenv("PGAPPNAME");
+       free(appnameenv);
+
        return pid;
 }