|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.14 1996/08/10 00:22:48 scrappy Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.15 1996/08/13 01:34:27 scrappy Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -156,11 +156,9 @@ getTuple(PGconn *conn, PGresult* result, int binary)
|
156 | 156 | for (i=0;i<nfields;i++) {
|
157 | 157 | if (!(bmap & 0200)) {
|
158 | 158 | /* if the field value is absent, make it '\0' */
|
159 |
| - /* XXX this makes it impossible to distinguish NULL |
160 |
| - attributes from "". Is that OK? */ |
161 | 159 | tup[i].value = (char*)malloc(1);
|
162 | 160 | tup[i].value[0] = '\0';
|
163 |
| - tup[i].len = 0; |
| 161 | + tup[i].len = NULL_LEN; |
164 | 162 | }
|
165 | 163 | else {
|
166 | 164 | /* get the value length (the first four bytes are for length) */
|
@@ -1469,6 +1467,35 @@ PQgetlength(PGresult *res, int tup_num, int field_num)
|
1469 | 1467 | "PQgetlength: ERROR! field %d(of %d) of tuple %d(of %d) is not available",
|
1470 | 1468 | field_num, res->numAttributes - 1, tup_num, res->ntups);
|
1471 | 1469 | }
|
1472 |
| - |
1473 |
| - return res->tuples[tup_num][field_num].len; |
| 1470 | + |
| 1471 | + if (res->tuples[tup_num][field_num].len != NULL_LEN) |
| 1472 | + return res->tuples[tup_num][field_num].len; |
| 1473 | + else |
| 1474 | + return 0; |
1474 | 1475 | }
|
| 1476 | + |
| 1477 | +/* PQgetisnull: |
| 1478 | + returns the null status of a field value. |
| 1479 | +*/ |
| 1480 | +int |
| 1481 | +PQgetisnull(PGresult *res, int tup_num, int field_num) |
| 1482 | +{ |
| 1483 | + if (!res) { |
| 1484 | + fprintf(stderr, "PQgetisnull() -- pointer to PQresult is null"); |
| 1485 | + return (int)NULL; |
| 1486 | + } |
| 1487 | + |
| 1488 | + if (tup_num > (res->ntups - 1 )|| |
| 1489 | + field_num > (res->numAttributes - 1)) { |
| 1490 | + fprintf(stderr, |
| 1491 | + "PQgetisnull: ERROR! field %d(of %d) of tuple %d(of %d) is not available", |
| 1492 | + field_num, res->numAttributes - 1, tup_num, res->ntups); |
| 1493 | + } |
| 1494 | + |
| 1495 | + if (res->tuples[tup_num][field_num].len == NULL_LEN) |
| 1496 | + return 1; |
| 1497 | + else |
| 1498 | + return 0; |
| 1499 | + } |
| 1500 | + |
| 1501 | + |
0 commit comments