7
7
*
8
8
*
9
9
* 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 $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -1486,8 +1486,7 @@ const char* PQoidStatus(PGresult *res) {
1486
1486
1487
1487
/*
1488
1488
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'
1491
1490
1492
1491
If res is binary, then the value returned is NOT a null-terminated
1493
1492
ASCII string, but the binary representation in the server's native
@@ -1499,21 +1498,27 @@ char*
1499
1498
PQgetvalue (PGresult * res , int tup_num , int field_num )
1500
1499
{
1501
1500
if (!res ) {
1502
- fprintf (stderr , "PQgetvalue() -- pointer to PQresult is null" );
1501
+ fprintf (stderr , "PQgetvalue: pointer to PQresult is null\n" );
1502
+ return NULL ;
1503
+ } else if (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
+ return NULL ;
1509
+ } else if (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 );
1503
1514
return NULL ;
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 );
1512
1515
}
1513
1516
1514
1517
return res -> tuples [tup_num ][field_num ].value ;
1515
1518
}
1516
1519
1520
+
1521
+
1517
1522
/* PQgetlength:
1518
1523
returns the length of a field value in bytes. If res is binary,
1519
1524
i.e. a result of a binary portal, then the length returned does
0 commit comments