Skip to content

Commit bd406af

Browse files
committed
psql: Improve \crosstabview error messages
1 parent 562e449 commit bd406af

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/bin/psql/crosstabview.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ PrintResultsInCrosstab(const PGresult *res)
122122

123123
if (PQresultStatus(res) != PGRES_TUPLES_OK)
124124
{
125-
psql_error("\\crosstabview: query must return results to be shown in crosstab\n");
125+
psql_error("\\crosstabview: statement did not return a result set\n");
126126
goto error_return;
127127
}
128128

@@ -643,7 +643,8 @@ indexOfColumn(char *arg, const PGresult *res)
643643
idx = atoi(arg) - 1;
644644
if (idx < 0 || idx >= PQnfields(res))
645645
{
646-
psql_error("\\crosstabview: invalid column number: \"%s\"\n", arg);
646+
psql_error("\\crosstabview: column number %d is out of range 1..%d\n",
647+
idx + 1, PQnfields(res));
647648
return -1;
648649
}
649650
}

src/test/regress/expected/psql_crosstab.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ SELECT 1 as "22", 2 as b, 3 as "Foo"
188188
-- error: bad column number
189189
SELECT v,h,i,c FROM ctv_data
190190
\crosstabview 2 1 5
191-
\crosstabview: invalid column number: "5"
191+
\crosstabview: column number 5 is out of range 1..4
192192
-- error: same H and V columns
193193
SELECT v,h,i,c FROM ctv_data
194194
\crosstabview 2 h 4

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy