Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9b55904

Browse files
author
Bryan Henderson
committed
Clarify error message about trying to PQgetvalue() nonexistent row.
1 parentab90c18 commit9b55904

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

‎src/interfaces/libpq/fe-exec.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.22 1996/12/20 20:34:38 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.23 1996/12/24 09:03:16 bryanh Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1486,8 +1486,7 @@ const char* PQoidStatus(PGresult *res) {
14861486

14871487
/*
14881488
PQgetvalue:
1489-
return the attribute value of field 'field_num' of
1490-
row 'tup_num'
1489+
return the value of field 'field_num' of row 'tup_num'
14911490
14921491
If res is binary, then the value returned is NOT a null-terminated
14931492
ASCII string, but the binary representation in the server's native
@@ -1499,21 +1498,27 @@ char*
14991498
PQgetvalue(PGresult*res,inttup_num,intfield_num)
15001499
{
15011500
if (!res) {
1502-
fprintf(stderr,"PQgetvalue() -- pointer to PQresult is null");
1501+
fprintf(stderr,"PQgetvalue: pointer to PQresult is null\n");
1502+
returnNULL;
1503+
}elseif (tup_num> (res->ntups-1)) {
1504+
fprintf(stderr,
1505+
"PQgetvalue: There is no row %d in the query results. "
1506+
"The highest numbered row is %d.\n",
1507+
tup_num,res->ntups-1);
1508+
returnNULL;
1509+
}elseif (field_num> (res->numAttributes-1)) {
1510+
fprintf(stderr,
1511+
"PQgetvalue: There is no field %d in the query results. "
1512+
"The highest numbered field is %d.\n",
1513+
field_num,res->numAttributes-1);
15031514
returnNULL;
1504-
}
1505-
1506-
if (tup_num> (res->ntups-1)||
1507-
field_num> (res->numAttributes-1)) {
1508-
fprintf(stderr,
1509-
"PQgetvalue: ERROR! field %d(of %d) of row %d(of %d) "
1510-
"is not available",
1511-
field_num,res->numAttributes-1,tup_num,res->ntups);
15121515
}
15131516

15141517
returnres->tuples[tup_num][field_num].value;
15151518
}
15161519

1520+
1521+
15171522
/* PQgetlength:
15181523
returns the length of a field value in bytes. If res is binary,
15191524
i.e. a result of a binary portal, then the length returned does

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp