aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-exec.c
diff options
context:
space:
mode:
authorBryan Henderson <bryanh@giraffe.netgate.net>1996-12-24 09:03:16 +0000
committerBryan Henderson <bryanh@giraffe.netgate.net>1996-12-24 09:03:16 +0000
commit9b5590464749d7e42c1c1f281aad2f591385c2e1 (patch)
tree4b82e8bb28715f55c6aba164e065064fa1280ab4 /src/interfaces/libpq/fe-exec.c
parentab90c18d126f684b959da2eb1d66a8b10695c1e5 (diff)
downloadpostgresql-9b5590464749d7e42c1c1f281aad2f591385c2e1.tar.gz
postgresql-9b5590464749d7e42c1c1f281aad2f591385c2e1.zip
Clarify error message about trying to PQgetvalue() nonexistent row.
Diffstat (limited to 'src/interfaces/libpq/fe-exec.c')
-rw-r--r--src/interfaces/libpq/fe-exec.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 14cbe84c5cd..1b3f9438ba2 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.22 1996/12/20 20:34:38 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.23 1996/12/24 09:03:16 bryanh Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1486,8 +1486,7 @@ const char* PQoidStatus(PGresult *res) {
/*
PQgetvalue:
- return the attribute value of field 'field_num' of
- row 'tup_num'
+ return the value of field 'field_num' of row 'tup_num'
If res is binary, then the value returned is NOT a null-terminated
ASCII string, but the binary representation in the server's native
@@ -1499,21 +1498,27 @@ char*
PQgetvalue(PGresult *res, int tup_num, int field_num)
{
if (!res) {
- fprintf(stderr, "PQgetvalue() -- pointer to PQresult is null");
+ fprintf(stderr, "PQgetvalue: pointer to PQresult is null\n");
+ return NULL;
+ } else if (tup_num > (res->ntups - 1)) {
+ fprintf(stderr,
+ "PQgetvalue: There is no row %d in the query results. "
+ "The highest numbered row is %d.\n",
+ tup_num, res->ntups - 1);
+ return NULL;
+ } else if (field_num > (res->numAttributes - 1)) {
+ fprintf(stderr,
+ "PQgetvalue: There is no field %d in the query results. "
+ "The highest numbered field is %d.\n",
+ field_num, res->numAttributes - 1);
return NULL;
- }
-
- if (tup_num > (res->ntups - 1) ||
- field_num > (res->numAttributes - 1)) {
- fprintf(stderr,
- "PQgetvalue: ERROR! field %d(of %d) of row %d(of %d) "
- "is not available",
- field_num, res->numAttributes - 1, tup_num, res->ntups);
}
return res->tuples[tup_num][field_num].value;
}
+
+
/* PQgetlength:
returns the length of a field value in bytes. If res is binary,
i.e. a result of a binary portal, then the length returned does