aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-08-22 14:19:10 +0100
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-08-22 14:19:10 +0100
commite7b90c52b3ee440f63445ba8f83419fd713069cf (patch)
tree94817cf8b0787c1e157d42a3f937ffbf52b8047b
parent6e5d9f278c1209936d973930996857f55e119cd8 (diff)
downloadpostgresql-e7b90c52b3ee440f63445ba8f83419fd713069cf.tar.gz
postgresql-e7b90c52b3ee440f63445ba8f83419fd713069cf.zip
Add hint to run "pgbench -i", if test tables don't exist.
Fabien Coelho, reviewed by Julien Rouhaud
-rw-r--r--src/bin/pgbench/pgbench.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 2e55c906b62..30e8d2a3f2e 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -55,6 +55,8 @@
#include "pgbench.h"
+#define ERRCODE_UNDEFINED_TABLE "42P01"
+
/*
* Multi-platform pthread implementations
*/
@@ -3252,7 +3254,14 @@ main(int argc, char **argv)
res = PQexec(con, "select count(*) from pgbench_branches");
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
+ char *sqlState = PQresultErrorField(res, PG_DIAG_SQLSTATE);
+
fprintf(stderr, "%s", PQerrorMessage(con));
+ if (sqlState && strcmp(sqlState, ERRCODE_UNDEFINED_TABLE) == 0)
+ {
+ fprintf(stderr, "Perhaps you need to do initialization (\"pgbench -i\") in database \"%s\"\n", PQdb(con));
+ }
+
exit(1);
}
scale = atoi(PQgetvalue(res, 0, 0));