|
1 | 1 | /*-------------------------------------------------------
|
2 | 2 | *
|
3 |
| - * $Id: Pg.xs,v 1.10 1998/12/13 02:50:20 momjian Exp $ |
| 3 | + * $Id: Pg.xs,v 1.11 1999/02/11 23:25:16 tgl Exp $ |
4 | 4 | *
|
5 | 5 | * Copyright (c) 1997, 1998 Edmund Mergl
|
6 | 6 | *
|
|
14 | 14 | #include <fcntl.h>
|
15 | 15 |
|
16 | 16 | #include "libpq-fe.h"
|
17 |
| -#include "libpq-int.h" /* need this for sizeof(PGresult) */ |
18 | 17 |
|
19 | 18 | typedef struct pg_conn *PG_conn;
|
20 | 19 | typedef struct pg_result *PG_result;
|
@@ -352,7 +351,7 @@ PQexec(conn, query)
|
352 | 351 | CODE:
|
353 | 352 | RETVAL = PQexec(conn, query);
|
354 | 353 | if (! RETVAL) {
|
355 |
| - RETVAL = (PGresult *)calloc(1, sizeof(PGresult)); |
| 354 | + RETVAL = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR); |
356 | 355 | }
|
357 | 356 | OUTPUT:
|
358 | 357 | RETVAL
|
@@ -384,7 +383,7 @@ PQgetResult(conn)
|
384 | 383 | CODE:
|
385 | 384 | RETVAL = PQgetResult(conn);
|
386 | 385 | if (! RETVAL) {
|
387 |
| - RETVAL = (PGresult *)calloc(1, sizeof(PGresult)); |
| 386 | + RETVAL = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR); |
388 | 387 | }
|
389 | 388 | OUTPUT:
|
390 | 389 | RETVAL
|
@@ -893,7 +892,7 @@ PQexec(conn, query)
|
893 | 892 | if (RETVAL) {
|
894 | 893 | RETVAL->result = PQexec((PGconn *)conn, query);
|
895 | 894 | if (!RETVAL->result) {
|
896 |
| - RETVAL->result = (PG_result)calloc(1, sizeof(PGresult)); |
| 895 | + RETVAL->result = PQmakeEmptyPGresult((PGconn *)conn, PGRES_FATAL_ERROR); |
897 | 896 | }
|
898 | 897 | }
|
899 | 898 | OUTPUT:
|
@@ -928,7 +927,7 @@ PQgetResult(conn)
|
928 | 927 | if (RETVAL) {
|
929 | 928 | RETVAL->result = PQgetResult((PGconn *)conn);
|
930 | 929 | if (!RETVAL->result) {
|
931 |
| - RETVAL->result = (PG_result)calloc(1, sizeof(PGresult)); |
| 930 | + RETVAL->result = PQmakeEmptyPGresult((PGconn *)conn, PGRES_FATAL_ERROR); |
932 | 931 | }
|
933 | 932 | }
|
934 | 933 | OUTPUT:
|
@@ -994,9 +993,6 @@ PQmakeEmptyPGresult(conn, status)
|
994 | 993 | RETVAL = (PG_results)calloc(1, sizeof(PGresults));
|
995 | 994 | if (RETVAL) {
|
996 | 995 | RETVAL->result = PQmakeEmptyPGresult((PGconn *)conn, status);
|
997 |
| - if (!RETVAL->result) { |
998 |
| - RETVAL->result = (PG_result)calloc(1, sizeof(PGresult)); |
999 |
| - } |
1000 | 996 | }
|
1001 | 997 | OUTPUT:
|
1002 | 998 | RETVAL
|
|
0 commit comments