summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2016-06-24 05:08:08 +0000
committerPeter Eisentraut2016-06-24 05:08:08 +0000
commitbd406af16841384b100c783a5cb36923eec6df6d (patch)
tree430dc94d1f93e6fa33fc2bcc659d13d30f31bb3f
parent562e44972490196884452e632a0a6d0db81b2335 (diff)
psql: Improve \crosstabview error messages
-rw-r--r--src/bin/psql/crosstabview.c5
-rw-r--r--src/test/regress/expected/psql_crosstab.out2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/bin/psql/crosstabview.c b/src/bin/psql/crosstabview.c
index cbe8ddff55a..b283c24e3c2 100644
--- a/src/bin/psql/crosstabview.c
+++ b/src/bin/psql/crosstabview.c
@@ -122,7 +122,7 @@ PrintResultsInCrosstab(const PGresult *res)
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
- psql_error("\\crosstabview: query must return results to be shown in crosstab\n");
+ psql_error("\\crosstabview: statement did not return a result set\n");
goto error_return;
}
@@ -643,7 +643,8 @@ indexOfColumn(char *arg, const PGresult *res)
idx = atoi(arg) - 1;
if (idx < 0 || idx >= PQnfields(res))
{
- psql_error("\\crosstabview: invalid column number: \"%s\"\n", arg);
+ psql_error("\\crosstabview: column number %d is out of range 1..%d\n",
+ idx + 1, PQnfields(res));
return -1;
}
}
diff --git a/src/test/regress/expected/psql_crosstab.out b/src/test/regress/expected/psql_crosstab.out
index f45e7261326..9be36c44801 100644
--- a/src/test/regress/expected/psql_crosstab.out
+++ b/src/test/regress/expected/psql_crosstab.out
@@ -188,7 +188,7 @@ SELECT 1 as "22", 2 as b, 3 as "Foo"
-- error: bad column number
SELECT v,h,i,c FROM ctv_data
\crosstabview 2 1 5
-\crosstabview: invalid column number: "5"
+\crosstabview: column number 5 is out of range 1..4
-- error: same H and V columns
SELECT v,h,i,c FROM ctv_data
\crosstabview 2 h 4