2-pg85-sqlda-19-ctxdiff.patch
text/x-patch
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
| File | + | − |
|---|---|---|
| src/interfaces/ecpg/ecpglib/execute.c | 222 | 0 |
| src/interfaces/ecpg/ecpglib/extern.h | 8 | 0 |
| src/interfaces/ecpg/ecpglib/Makefile | 1 | 1 |
| src/interfaces/ecpg/ecpglib/sqlda.c | 617 | 0 |
| src/interfaces/ecpg/ecpglib/sqlda.c~ | 616 | 0 |
| src/interfaces/ecpg/ecpglib/typename.c | 40 | 0 |
| src/interfaces/ecpg/include/ecpgtype.h | 2 | 1 |
| src/interfaces/ecpg/include/Makefile | 3 | 2 |
| src/interfaces/ecpg/include/sqlda-compat.h | 47 | 0 |
| src/interfaces/ecpg/include/sqlda.h | 19 | 0 |
| src/interfaces/ecpg/include/sqlda-native.h | 35 | 0 |
| src/interfaces/ecpg/include/sqltypes.h | 27 | 0 |
| src/interfaces/ecpg/preproc/descriptor.c | 19 | 0 |
| src/interfaces/ecpg/preproc/ecpg.addons | 5 | 5 |
| src/interfaces/ecpg/preproc/ecpg.c | 3 | 0 |
| src/interfaces/ecpg/preproc/ecpg.trailer | 26 | 6 |
| src/interfaces/ecpg/preproc/ecpg.type | 2 | 1 |
| src/interfaces/ecpg/preproc/extern.h | 1 | 0 |
| src/interfaces/ecpg/preproc/type.c | 5 | 0 |
| src/interfaces/ecpg/test/compat_informix/Makefile | 4 | 0 |
| src/interfaces/ecpg/test/compat_informix/sqlda.pgc | 254 | 0 |
| src/interfaces/ecpg/test/ecpg_schedule | 2 | 0 |
| src/interfaces/ecpg/test/ecpg_schedule_tcp | 2 | 0 |
| src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c | 1 | 0 |
| src/interfaces/ecpg/test/expected/compat_informix-dec_test.c | 1 | 0 |
| src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c | 1 | 0 |
| src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c | 1 | 0 |
| src/interfaces/ecpg/test/expected/compat_informix-rnull.c | 1 | 0 |
| src/interfaces/ecpg/test/expected/compat_informix-sqlda.c | 541 | 0 |
| src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr | 604 | 0 |
| src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout | 60 | 0 |
| src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c | 1 | 0 |
| src/interfaces/ecpg/test/expected/compat_informix-test_informix.c | 1 | 0 |
| src/interfaces/ecpg/test/expected/sql-sqlda.c | 548 | 0 |
| src/interfaces/ecpg/test/expected/sql-sqlda.stderr | 594 | 0 |
| src/interfaces/ecpg/test/expected/sql-sqlda.stdout | 60 | 0 |
| src/interfaces/ecpg/test/sql/desc.pgc | 6 | 6 |
| src/interfaces/ecpg/test/sql/dynalloc2.pgc | 1 | 1 |
| src/interfaces/ecpg/test/sql/dynalloc.pgc | 1 | 1 |
| src/interfaces/ecpg/test/sql/Makefile | 1 | 0 |
| src/interfaces/ecpg/test/sql/sqlda.pgc | 263 | 0 |
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c pgsql.2.1/src/interfaces/ecpg/ecpglib/execute.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c 2009-09-03 14:37:34.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/ecpglib/execute.c 2010-01-04 14:51:44.000000000 +0100
***************
*** 25,30 ****
--- 25,32 ----
#include "ecpgerrno.h"
#include "extern.h"
#include "sqlca.h"
+ #include "sqlda-native.h"
+ #include "sqlda-compat.h"
#include "sql3types.h"
#include "pgtypes_numeric.h"
#include "pgtypes_date.h"
*************** ecpg_store_input(const int lineno, const
*** 1033,1038 ****
--- 1035,1041 ----
break;
case ECPGt_descriptor:
+ case ECPGt_sqlda:
break;
default:
*************** ecpg_execute(struct statement * stmt)
*** 1172,1177 ****
--- 1175,1294 ----
if (desc->count == desc_counter)
desc_counter = 0;
}
+ else if (var->type == ECPGt_sqlda)
+ {
+ if (INFORMIX_MODE(stmt->compat))
+ {
+ struct sqlda_compat *sqlda = *(struct sqlda_compat **)var->pointer;
+ struct variable desc_inlist;
+ int i;
+
+ if (sqlda == NULL)
+ return false;
+
+ desc_counter++;
+ for (i = 0; i < sqlda->sqld; i++)
+ {
+ if (i + 1 == desc_counter)
+ {
+ desc_inlist.type = sqlda->sqlvar[i].sqltype;
+ desc_inlist.value = sqlda->sqlvar[i].sqldata;
+ desc_inlist.pointer = &(sqlda->sqlvar[i].sqldata);
+ switch (desc_inlist.type)
+ {
+ case ECPGt_char:
+ case ECPGt_varchar:
+ desc_inlist.varcharsize = strlen(sqlda->sqlvar[i].sqldata);
+ break;
+ default:
+ desc_inlist.varcharsize = 0;
+ break;
+ }
+ desc_inlist.arrsize = 1;
+ desc_inlist.offset = 0;
+ if (sqlda->sqlvar[i].sqlind)
+ {
+ desc_inlist.ind_type = ECPGt_short;
+ /* ECPG expects indicator value < 0 */
+ if (*(sqlda->sqlvar[i].sqlind))
+ *(sqlda->sqlvar[i].sqlind) = -1;
+ desc_inlist.ind_value = sqlda->sqlvar[i].sqlind;
+ desc_inlist.ind_pointer = &(sqlda->sqlvar[i].sqlind);
+ desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
+ desc_inlist.ind_offset = 0;
+ }
+ else
+ {
+ desc_inlist.ind_type = ECPGt_NO_INDICATOR;
+ desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
+ desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
+ }
+ if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, false))
+ return false;
+
+ break;
+ }
+ }
+ if (sqlda->sqld == desc_counter)
+ desc_counter = 0;
+ }
+ else
+ {
+ struct sqlda_struct *sqlda = *(struct sqlda_struct **)var->pointer;
+ struct variable desc_inlist;
+ int i;
+
+ if (sqlda == NULL)
+ return false;
+
+ desc_counter++;
+ for (i = 0; i < sqlda->sqln; i++)
+ {
+ if (i + 1 == desc_counter)
+ {
+ desc_inlist.type = sqlda->sqlvar[i].sqltype;
+ desc_inlist.value = sqlda->sqlvar[i].sqldata;
+ desc_inlist.pointer = &(sqlda->sqlvar[i].sqldata);
+ switch (desc_inlist.type)
+ {
+ case ECPGt_char:
+ case ECPGt_varchar:
+ desc_inlist.varcharsize = strlen(sqlda->sqlvar[i].sqldata);
+ break;
+ default:
+ desc_inlist.varcharsize = 0;
+ break;
+ }
+ desc_inlist.arrsize = 1;
+ desc_inlist.offset = 0;
+ if (sqlda->sqlvar[i].sqlind)
+ {
+ desc_inlist.ind_type = ECPGt_short;
+ /* ECPG expects indicator value < 0 */
+ if (*(sqlda->sqlvar[i].sqlind))
+ *(sqlda->sqlvar[i].sqlind) = -1;
+ desc_inlist.ind_value = sqlda->sqlvar[i].sqlind;
+ desc_inlist.ind_pointer = &(sqlda->sqlvar[i].sqlind);
+ desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
+ desc_inlist.ind_offset = 0;
+ }
+ else
+ {
+ desc_inlist.ind_type = ECPGt_NO_INDICATOR;
+ desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
+ desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
+ }
+ if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, false))
+ return false;
+
+ break;
+ }
+ }
+ if (sqlda->sqln == desc_counter)
+ desc_counter = 0;
+ }
+
+ }
else
{
if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, var, &tobeinserted, false))
*************** ecpg_execute(struct statement * stmt)
*** 1353,1358 ****
--- 1470,1580 ----
}
var = var->next;
}
+ else if (var != NULL && var->type == ECPGt_sqlda)
+ {
+ if (INFORMIX_MODE(stmt->compat))
+ {
+ struct sqlda_compat **_sqlda = (struct sqlda_compat **)var->pointer;
+ struct sqlda_compat *sqlda = *_sqlda;
+ struct sqlda_compat *sqlda_new;
+ int i;
+
+ /* If we are passed in a previously existing sqlda (chain) then free it. */
+ while (sqlda)
+ {
+ sqlda_new = sqlda->desc_next;
+ free(sqlda);
+ sqlda = sqlda_new;
+ }
+ *_sqlda = sqlda = sqlda_new = NULL;
+ for (i = ntuples - 1; i >= 0; i--)
+ {
+ /* Build a new sqlda structure. Note that only fetching 1 record is supported */
+ sqlda_new = ecpg_build_compat_sqlda(stmt->lineno, results, i, stmt->compat);
+
+ if (!sqlda_new)
+ {
+ /* cleanup all SQLDAs we created up */
+ while (sqlda)
+ {
+ sqlda_new = sqlda->desc_next;
+ free(sqlda);
+ sqlda = sqlda_new;
+ }
+ *_sqlda = NULL;
+
+ ecpg_log("ecpg_execute on line %d: out of memory allocating a new sqlda\n", stmt->lineno);
+ status = false;
+ break;
+ }
+ else
+ {
+ ecpg_log("ecpg_execute on line %d: new sqlda was built\n", stmt->lineno);
+
+ *_sqlda = sqlda_new;
+
+ ecpg_set_compat_sqlda(stmt->lineno, _sqlda, results, i, stmt->compat);
+ ecpg_log("ecpg_execute on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
+ stmt->lineno, PQnfields(results));
+
+ sqlda_new->desc_next = sqlda;
+ sqlda = sqlda_new;
+ }
+ }
+ }
+ else
+ {
+ struct sqlda_struct **_sqlda = (struct sqlda_struct **)var->pointer;
+ struct sqlda_struct *sqlda = *_sqlda;
+ struct sqlda_struct *sqlda_new;
+ int i;
+
+ /* If we are passed in a previously existing sqlda (chain) then free it. */
+ while (sqlda)
+ {
+ sqlda_new = sqlda->desc_next;
+ free(sqlda);
+ sqlda = sqlda_new;
+ }
+ *_sqlda = sqlda = sqlda_new = NULL;
+ for (i = ntuples - 1; i >= 0; i--)
+ {
+ /* Build a new sqlda structure. Note that only fetching 1 record is supported */
+ sqlda_new = ecpg_build_native_sqlda(stmt->lineno, results, i, stmt->compat);
+
+ if (!sqlda_new)
+ {
+ /* cleanup all SQLDAs we created up */
+ while (sqlda)
+ {
+ sqlda_new = sqlda->desc_next;
+ free(sqlda);
+ sqlda = sqlda_new;
+ }
+ *_sqlda = NULL;
+
+ ecpg_log("ecpg_execute on line %d: out of memory allocating a new sqlda\n", stmt->lineno);
+ status = false;
+ break;
+ }
+ else
+ {
+ ecpg_log("ecpg_execute on line %d: new sqlda was built\n", stmt->lineno);
+
+ *_sqlda = sqlda_new;
+
+ ecpg_set_native_sqlda(stmt->lineno, _sqlda, results, i, stmt->compat);
+ ecpg_log("ecpg_execute on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
+ stmt->lineno, PQnfields(results));
+
+ sqlda_new->desc_next = sqlda;
+ sqlda = sqlda_new;
+ }
+ }
+ }
+
+ var = var->next;
+ }
else
for (act_field = 0; act_field < nfields && status; act_field++)
{
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/extern.h pgsql.2.1/src/interfaces/ecpg/ecpglib/extern.h
*** pgsql.orig/src/interfaces/ecpg/ecpglib/extern.h 2009-05-25 12:08:48.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/ecpglib/extern.h 2010-01-01 16:25:58.000000000 +0100
***************
*** 6,11 ****
--- 6,13 ----
#include "postgres_fe.h"
#include "libpq-fe.h"
#include "sqlca.h"
+ #include "sqlda-native.h"
+ #include "sqlda-compat.h"
#include "ecpg_config.h"
#ifndef CHAR_BIT
#include <limits.h>
*************** bool ecpg_init(const struct connection
*** 129,134 ****
--- 131,137 ----
char *ecpg_strdup(const char *, int);
const char *ecpg_type_name(enum ECPGttype);
int ecpg_dynamic_type(Oid);
+ int sqlda_dynamic_type(Oid, enum COMPAT_MODE);
void ecpg_free_auto_mem(void);
void ecpg_clear_auto_mem(void);
*************** void ecpg_log(const char *format,...);
*** 149,154 ****
--- 152,162 ----
bool ecpg_auto_prepare(int, const char *, const int, char **, const char *);
void ecpg_init_sqlca(struct sqlca_t * sqlca);
+ struct sqlda_compat *ecpg_build_compat_sqlda(int, PGresult *, int, enum COMPAT_MODE);
+ void ecpg_set_compat_sqlda(int, struct sqlda_compat **, const PGresult *, int, enum COMPAT_MODE);
+ struct sqlda_struct *ecpg_build_native_sqlda(int, PGresult *, int, enum COMPAT_MODE);
+ void ecpg_set_native_sqlda(int, struct sqlda_struct **, const PGresult *, int, enum COMPAT_MODE);
+
/* SQLSTATE values generated or processed by ecpglib (intentionally
* not exported -- users should refer to the codes directly) */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/Makefile pgsql.2.1/src/interfaces/ecpg/ecpglib/Makefile
*** pgsql.orig/src/interfaces/ecpg/ecpglib/Makefile 2009-07-13 11:16:41.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/ecpglib/Makefile 2010-01-01 14:35:36.000000000 +0100
*************** override CFLAGS += $(PTHREAD_CFLAGS)
*** 24,30 ****
# Need to recompile any libpgport object files
LIBS := $(filter-out -lpgport, $(LIBS))
! OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
connect.o misc.o path.o pgstrcasecmp.o \
$(filter snprintf.o strlcpy.o, $(LIBOBJS))
--- 24,30 ----
# Need to recompile any libpgport object files
LIBS := $(filter-out -lpgport, $(LIBS))
! OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \
connect.o misc.o path.o pgstrcasecmp.o \
$(filter snprintf.o strlcpy.o, $(LIBOBJS))
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c pgsql.2.1/src/interfaces/ecpg/ecpglib/sqlda.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c 1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/ecpglib/sqlda.c 2010-01-04 17:48:14.000000000 +0100
***************
*** 0 ****
--- 1,617 ----
+ /*
+ * SQLDA support routines
+ *
+ * The allocated memory area pointed by an sqlda pointer
+ * contains both the metadata and the data, so freeing up
+ * is a simple free(sqlda) as expected by the ESQL/C examples.
+ */
+
+ #define POSTGRES_ECPG_INTERNAL
+ #include "postgres_fe.h"
+ #include "pg_type.h"
+
+ #include <inttypes.h>
+ #include <dlfcn.h>
+
+ #include "ecpg-pthread-win32.h"
+ #include "decimal.h"
+ #include "ecpgtype.h"
+ #include "ecpglib.h"
+ #include "ecpgerrno.h"
+ #include "extern.h"
+ #include "sqlca.h"
+ #include "sqlda-native.h"
+ #include "sqlda-compat.h"
+
+ /*
+ * Compute the next variable's offset with
+ * the current variable's size and alignment.
+ *
+ *
+ * Returns:
+ * - the current variable's offset in *current
+ * - the next variable's offset in *next
+ */
+ static void
+ ecpg_sqlda_align_add_size(long offset, int alignment, int size, long *current, long *next)
+ {
+ if (offset % alignment)
+ offset += alignment - (offset % alignment);
+ if (current)
+ *current = offset;
+ offset += size;
+ if (next)
+ *next = offset;
+ }
+
+ static long
+ sqlda_compat_empty_size(const PGresult *res)
+ {
+ long offset;
+ int i;
+ int sqld = PQnfields(res);
+
+ /* Initial size to store main structure and field structures */
+ offset = sizeof(struct sqlda_compat) + sqld * sizeof(struct sqlvar_compat);
+
+ /* Add space for field names */
+ for (i = 0; i < sqld; i++)
+ offset += strlen(PQfname(res, i)) + 1;
+
+ /* Add padding to the first field value */
+ ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
+
+ return offset;
+ }
+
+ static long
+ sqlda_common_total_size(const PGresult *res, int row, enum COMPAT_MODE compat, long offset)
+ {
+ int sqld = PQnfields(res);
+ int i;
+ long next_offset;
+
+ /* Add space for the field values */
+ for (i = 0; i < sqld; i++)
+ {
+ enum ECPGttype type = sqlda_dynamic_type(PQftype(res, i), compat);
+ switch (type)
+ {
+ case ECPGt_short:
+ case ECPGt_unsigned_short:
+ ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_int:
+ case ECPGt_unsigned_int:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_long:
+ case ECPGt_unsigned_long:
+ ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_long_long:
+ case ECPGt_unsigned_long_long:
+ ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_bool:
+ ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_float:
+ ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_double:
+ ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_decimal:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_numeric:
+ /*
+ * Let's align both the numeric struct and the digits array to int
+ * Unfortunately we need to do double work here to compute the size
+ * of the space needed for the numeric structure.
+ */
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ if (!PQgetisnull(res, row, i))
+ {
+ char *val = PQgetvalue(res, row, i);
+ numeric *num;
+
+ num = PGTYPESnumeric_from_asc(val, NULL);
+ if (!num)
+ break;
+ ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ PGTYPESnumeric_free(num);
+ }
+ break;
+ case ECPGt_date:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(date), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_timestamp:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(timestamp), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_interval:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(interval), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_char:
+ case ECPGt_unsigned_char:
+ case ECPGt_string:
+ default:
+ {
+ long datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ }
+ }
+ offset = next_offset;
+ }
+ return offset;
+ }
+
+
+ static long
+ sqlda_compat_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ long offset;
+
+ offset = sqlda_compat_empty_size(res);
+
+ if (row < 0)
+ return offset;
+
+ offset = sqlda_common_total_size(res, row, compat, offset);
+ return offset;
+ }
+
+ static long
+ sqlda_native_empty_size(const PGresult *res)
+ {
+ long offset;
+ int sqld = PQnfields(res);
+
+ /* Initial size to store main structure and field structures */
+ offset = sizeof(struct sqlda_struct) + (sqld - 1) * sizeof(struct sqlvar_struct);
+
+ /* Add padding to the first field value */
+ ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
+
+ return offset;
+ }
+
+ static long
+ sqlda_native_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ long offset;
+
+ offset = sqlda_native_empty_size(res);
+
+ if (row < 0)
+ return offset;
+
+ offset = sqlda_common_total_size(res, row, compat, offset);
+ return offset;
+ }
+
+ /*
+ * Build "struct sqlda_compat" (metadata only) from PGresult
+ * leaving enough space for the field values in
+ * the given row number
+ */
+ struct sqlda_compat *
+ ecpg_build_compat_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ struct sqlda_compat *sqlda;
+ struct sqlvar_compat *sqlvar;
+ char *fname;
+ long size;
+ int sqld;
+ int i;
+
+ size = sqlda_compat_total_size(res, row, compat);
+ sqlda = (struct sqlda_compat *)ecpg_alloc(size, line);
+ if (!sqlda)
+ return NULL;
+
+ memset(sqlda, 0, size);
+ sqlvar = (struct sqlvar_compat *)(sqlda + 1);
+ sqld = PQnfields(res);
+ fname = (char *)(sqlvar + sqld);
+
+ sqlda->sqld = sqld;
+ ecpg_log("%s sqld = %d\n", __FUNCTION__, sqld);
+ sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
+ sqlda->sqlvar = sqlvar;
+
+ for (i = 0; i < sqlda->sqld; i++)
+ {
+ sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
+ strcpy(fname, PQfname(res, i));
+ sqlda->sqlvar[i].sqlname = fname;
+ fname += strlen(sqlda->sqlvar[i].sqlname) + 1;
+ sqlda->sqlvar[i].sqlformat = (char *)(long)PQfformat(res, i);
+ sqlda->sqlvar[i].sqlxid = PQftype(res, i);
+ sqlda->sqlvar[i].sqltypelen = PQfsize(res, i);
+ }
+
+ return sqlda;
+ }
+
+ /*
+ * Sets values from PGresult.
+ */
+ static int2 value_is_null = -1;
+ static int2 value_is_not_null = 0;
+
+ void
+ ecpg_set_compat_sqlda(int lineno, struct sqlda_compat **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ struct sqlda_compat *sqlda = (*_sqlda);
+ int i;
+ long offset, next_offset;
+
+ if (row < 0)
+ return;
+
+ /* Offset for the first field value */
+ offset = sqlda_compat_empty_size(res);
+
+ /*
+ * Set sqlvar[i]->sqldata pointers and convert values to correct format
+ */
+ for (i = 0; i < sqlda->sqld; i++)
+ {
+ int isnull;
+ int datalen;
+ bool set_data = true;
+
+ switch (sqlda->sqlvar[i].sqltype)
+ {
+ case ECPGt_short:
+ case ECPGt_unsigned_short:
+ ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(short);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_int:
+ case ECPGt_unsigned_int:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(int);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_long:
+ case ECPGt_unsigned_long:
+ ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(long);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_long_long:
+ case ECPGt_unsigned_long_long:
+ ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(long long);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_bool:
+ ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(bool);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_float:
+ ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(float);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_double:
+ ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(double);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_decimal:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(decimal);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_numeric:
+ {
+ numeric *num;
+ char *val;
+
+ set_data = false;
+
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(numeric);
+ ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+
+ if (PQgetisnull(res, row, i))
+ {
+ ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ break;
+ }
+
+ val = PQgetvalue(res, row, i);
+ num = PGTYPESnumeric_from_asc(val, NULL);
+ if (!num)
+ {
+ ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ break;
+ }
+
+ memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
+
+ ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
+ ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+
+ ((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
+ ((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
+
+ PGTYPESnumeric_free(num);
+
+ break;
+ }
+ case ECPGt_date:
+ ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(date);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_timestamp:
+ ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(timestamp);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_interval:
+ ecpg_sqlda_align_add_size(offset, sizeof(int64_t), sizeof(interval), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(interval);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_char:
+ case ECPGt_unsigned_char:
+ case ECPGt_string:
+ default:
+ datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = datalen;
+ if (datalen > 32768)
+ sqlda->sqlvar[i].sqlilongdata = sqlda->sqlvar[i].sqldata;
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ }
+
+ isnull = PQgetisnull(res, row, i);
+ ecpg_log("%s row %d col %d %s\n", __FUNCTION__, row, i, isnull ? "IS NULL" : "IS NOT NULL");
+ sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+ sqlda->sqlvar[i].sqlitype = ECPGt_short;
+ sqlda->sqlvar[i].sqlilen = sizeof(short);
+ if (!isnull)
+ {
+ if (set_data)
+ ecpg_get_data(res, row, i, lineno,
+ sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
+ sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+ ECPG_ARRAY_NONE, compat, false);
+ }
+ else
+ ECPGset_noind_null(sqlda->sqlvar[i].sqltype, sqlda->sqlvar[i].sqldata);
+
+ offset = next_offset;
+ }
+ }
+
+ struct sqlda_struct *
+ ecpg_build_native_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ struct sqlda_struct *sqlda;
+ long size;
+ int i;
+
+ size = sqlda_native_total_size(res, row, compat);
+ sqlda = (struct sqlda_struct *)ecpg_alloc(size, line);
+ if (!sqlda)
+ return NULL;
+
+ memset(sqlda, 0, size);
+
+ sprintf(sqlda->sqldaid, "SQLDA ");
+ sqlda->sqld = sqlda->sqln = PQnfields(res);
+ ecpg_log("%s sqld = %d\n", __FUNCTION__, sqlda->sqld);
+ sqlda->sqldabc = sizeof(struct sqlda_struct) + (sqlda->sqld - 1) * sizeof(struct sqlvar_struct);
+
+ for (i = 0; i < sqlda->sqld; i++)
+ {
+ char *fname;
+
+ sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
+ fname = PQfname(res, i);
+ sqlda->sqlvar[i].sqlname.length = strlen(fname);
+ strcpy(sqlda->sqlvar[i].sqlname.data, fname);
+ }
+
+ return sqlda;
+ }
+
+ void
+ ecpg_set_native_sqlda(int lineno, struct sqlda_struct **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ struct sqlda_struct *sqlda = (*_sqlda);
+ int i;
+ long offset, next_offset;
+
+ if (row < 0)
+ return;
+
+ /* Offset for the first field value */
+ offset = sqlda_native_empty_size(res);
+
+ /*
+ * Set sqlvar[i]->sqldata pointers and convert values to correct format
+ */
+ for (i = 0; i < sqlda->sqld; i++)
+ {
+ int isnull;
+ int datalen;
+ bool set_data = true;
+
+ switch (sqlda->sqlvar[i].sqltype)
+ {
+ case ECPGt_short:
+ case ECPGt_unsigned_short:
+ ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(short);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_int:
+ case ECPGt_unsigned_int:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(int);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_long:
+ case ECPGt_unsigned_long:
+ ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(long);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_long_long:
+ case ECPGt_unsigned_long_long:
+ ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(long long);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_bool:
+ ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(bool);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_float:
+ ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(float);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_double:
+ ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(double);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_decimal:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(decimal);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_numeric:
+ {
+ numeric *num;
+ char *val;
+
+ set_data = false;
+
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(numeric);
+ ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+
+ if (PQgetisnull(res, row, i))
+ {
+ ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ break;
+ }
+
+ val = PQgetvalue(res, row, i);
+ num = PGTYPESnumeric_from_asc(val, NULL);
+ if (!num)
+ {
+ ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ break;
+ }
+
+ memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
+
+ ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
+ ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+
+ ((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
+ ((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
+
+ PGTYPESnumeric_free(num);
+
+ break;
+ }
+ case ECPGt_date:
+ ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(date);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_timestamp:
+ ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(timestamp);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_interval:
+ ecpg_sqlda_align_add_size(offset, sizeof(int64_t), sizeof(interval), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(interval);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_char:
+ case ECPGt_unsigned_char:
+ case ECPGt_string:
+ default:
+ datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = datalen;
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ }
+
+ isnull = PQgetisnull(res, row, i);
+ ecpg_log("%s row %d col %d %s\n", __FUNCTION__, row, i, isnull ? "IS NULL" : "IS NOT NULL");
+ sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+ if (!isnull)
+ {
+ if (set_data)
+ ecpg_get_data(res, row, i, lineno,
+ sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
+ sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+ ECPG_ARRAY_NONE, compat, false);
+ }
+
+ offset = next_offset;
+ }
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c~ pgsql.2.1/src/interfaces/ecpg/ecpglib/sqlda.c~
*** pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c~ 1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/ecpglib/sqlda.c~ 2010-01-04 17:48:14.000000000 +0100
***************
*** 0 ****
--- 1,616 ----
+ /*
+ * SQLDA support routines
+ *
+ * The allocated memory area pointed by an sqlda pointer
+ * contains both the metadata and the data, so freeing up
+ * is a simple free(sqlda) as expected by the ESQL/C examples.
+ */
+
+ #define POSTGRES_ECPG_INTERNAL
+ #include "postgres_fe.h"
+ #include "pg_type.h"
+
+ #include <inttypes.h>
+ #include <dlfcn.h>
+
+ #include "ecpg-pthread-win32.h"
+ #include "decimal.h"
+ #include "ecpgtype.h"
+ #include "ecpglib.h"
+ #include "ecpgerrno.h"
+ #include "extern.h"
+ #include "sqlca.h"
+ #include "sqlda-native.h"
+ #include "sqlda-compat.h"
+
+ /*
+ * Compute the next variable's offset with
+ * the current variable's size and alignment.
+ *
+ *
+ * Returns:
+ * - the current variable's offset in *current
+ * - the next variable's offset in *next
+ */
+ static void
+ ecpg_sqlda_align_add_size(long offset, int alignment, int size, long *current, long *next)
+ {
+ if (offset % alignment)
+ offset += alignment - (offset % alignment);
+ if (current)
+ *current = offset;
+ offset += size;
+ if (next)
+ *next = offset;
+ }
+
+ static long
+ sqlda_compat_empty_size(const PGresult *res)
+ {
+ long offset;
+ int i;
+ int sqld = PQnfields(res);
+
+ /* Initial size to store main structure and field structures */
+ offset = sizeof(struct sqlda_compat) + sqld * sizeof(struct sqlvar_compat);
+
+ /* Add space for field names */
+ for (i = 0; i < sqld; i++)
+ offset += strlen(PQfname(res, i)) + 1;
+
+ /* Add padding to the first field value */
+ ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
+
+ return offset;
+ }
+
+ static long
+ sqlda_common_total_size(const PGresult *res, int row, enum COMPAT_MODE compat, long offset)
+ {
+ int sqld = PQnfields(res);
+ int i;
+ long next_offset;
+
+ /* Add space for the field values */
+ for (i = 0; i < sqld; i++)
+ {
+ enum ECPGttype type = sqlda_dynamic_type(PQftype(res, i), compat);
+ switch (type)
+ {
+ case ECPGt_short:
+ case ECPGt_unsigned_short:
+ ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_int:
+ case ECPGt_unsigned_int:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_long:
+ case ECPGt_unsigned_long:
+ ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_long_long:
+ case ECPGt_unsigned_long_long:
+ ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_bool:
+ ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_float:
+ ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_double:
+ ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_decimal:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_numeric:
+ /*
+ * Let's align both the numeric struct and the digits array to int
+ * Unfortunately we need to do double work here to compute the size
+ * of the space needed for the numeric structure.
+ */
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ if (!PQgetisnull(res, row, i))
+ {
+ char *val = PQgetvalue(res, row, i);
+ numeric *num;
+
+ num = PGTYPESnumeric_from_asc(val, NULL);
+ if (!num)
+ break;
+ ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ PGTYPESnumeric_free(num);
+ }
+ break;
+ case ECPGt_date:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(date), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_timestamp:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(timestamp), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_interval:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(interval), &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ case ECPGt_char:
+ case ECPGt_unsigned_char:
+ case ECPGt_string:
+ default:
+ {
+ long datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ break;
+ }
+ }
+ offset = next_offset;
+ }
+ return offset;
+ }
+
+
+ static long
+ sqlda_compat_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ long offset;
+
+ offset = sqlda_compat_empty_size(res);
+
+ if (row < 0)
+ return offset;
+
+ offset = sqlda_common_total_size(res, row, compat, offset);
+ return offset;
+ }
+
+ static long
+ sqlda_native_empty_size(const PGresult *res)
+ {
+ long offset;
+ int sqld = PQnfields(res);
+
+ /* Initial size to store main structure and field structures */
+ offset = sizeof(struct sqlda_struct) + (sqld - 1) * sizeof(struct sqlvar_struct);
+
+ /* Add padding to the first field value */
+ ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
+
+ return offset;
+ }
+
+ static long
+ sqlda_native_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ long offset;
+
+ offset = sqlda_native_empty_size(res);
+
+ if (row < 0)
+ return offset;
+
+ offset = sqlda_common_total_size(res, row, compat, offset);
+ return offset;
+ }
+
+ /*
+ * Build "struct sqlda_compat" (metadata only) from PGresult
+ * leaving enough space for the field values in
+ * the given row number
+ */
+ struct sqlda_compat *
+ ecpg_build_compat_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ struct sqlda_compat *sqlda;
+ struct sqlvar_compat *sqlvar;
+ char *fname;
+ long size;
+ int sqld;
+ int i;
+
+ size = sqlda_compat_total_size(res, row, compat);
+ sqlda = (struct sqlda_compat *)ecpg_alloc(size, line);
+ if (!sqlda)
+ return NULL;
+
+ memset(sqlda, 0, size);
+ sqlvar = (struct sqlvar_compat *)(sqlda + 1);
+ sqld = PQnfields(res);
+ fname = (char *)(sqlvar + sqld);
+
+ sqlda->sqld = sqld;
+ sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
+ sqlda->sqlvar = sqlvar;
+
+ for (i = 0; i < sqlda->sqld; i++)
+ {
+ sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
+ strcpy(fname, PQfname(res, i));
+ sqlda->sqlvar[i].sqlname = fname;
+ fname += strlen(sqlda->sqlvar[i].sqlname) + 1;
+ sqlda->sqlvar[i].sqlformat = (char *)(long)PQfformat(res, i);
+ sqlda->sqlvar[i].sqlxid = PQftype(res, i);
+ sqlda->sqlvar[i].sqltypelen = PQfsize(res, i);
+ }
+
+ return sqlda;
+ }
+
+ /*
+ * Sets values from PGresult.
+ */
+ static int2 value_is_null = -1;
+ static int2 value_is_not_null = 0;
+
+ void
+ ecpg_set_compat_sqlda(int lineno, struct sqlda_compat **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ struct sqlda_compat *sqlda = (*_sqlda);
+ int i;
+ long offset, next_offset;
+
+ if (row < 0)
+ return;
+
+ /* Offset for the first field value */
+ offset = sqlda_compat_empty_size(res);
+
+ /*
+ * Set sqlvar[i]->sqldata pointers and convert values to correct format
+ */
+ for (i = 0; i < sqlda->sqld; i++)
+ {
+ int isnull;
+ int datalen;
+ bool set_data = true;
+
+ switch (sqlda->sqlvar[i].sqltype)
+ {
+ case ECPGt_short:
+ case ECPGt_unsigned_short:
+ ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(short);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_int:
+ case ECPGt_unsigned_int:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(int);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_long:
+ case ECPGt_unsigned_long:
+ ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(long);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_long_long:
+ case ECPGt_unsigned_long_long:
+ ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(long long);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_bool:
+ ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(bool);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_float:
+ ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(float);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_double:
+ ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(double);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_decimal:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(decimal);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_numeric:
+ {
+ numeric *num;
+ char *val;
+
+ set_data = false;
+
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(numeric);
+ ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+
+ if (PQgetisnull(res, row, i))
+ {
+ ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ break;
+ }
+
+ val = PQgetvalue(res, row, i);
+ num = PGTYPESnumeric_from_asc(val, NULL);
+ if (!num)
+ {
+ ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ break;
+ }
+
+ memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
+
+ ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
+ ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+
+ ((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
+ ((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
+
+ PGTYPESnumeric_free(num);
+
+ break;
+ }
+ case ECPGt_date:
+ ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(date);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_timestamp:
+ ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(timestamp);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_interval:
+ ecpg_sqlda_align_add_size(offset, sizeof(int64_t), sizeof(interval), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(interval);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_char:
+ case ECPGt_unsigned_char:
+ case ECPGt_string:
+ default:
+ datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = datalen;
+ if (datalen > 32768)
+ sqlda->sqlvar[i].sqlilongdata = sqlda->sqlvar[i].sqldata;
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ }
+
+ isnull = PQgetisnull(res, row, i);
+ ecpg_log("%s row %d col %d %s\n", __FUNCTION__, row, i, isnull ? "IS NULL" : "IS NOT NULL");
+ sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+ sqlda->sqlvar[i].sqlitype = ECPGt_short;
+ sqlda->sqlvar[i].sqlilen = sizeof(short);
+ if (!isnull)
+ {
+ if (set_data)
+ ecpg_get_data(res, row, i, lineno,
+ sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
+ sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+ ECPG_ARRAY_NONE, compat, false);
+ }
+ else
+ ECPGset_noind_null(sqlda->sqlvar[i].sqltype, sqlda->sqlvar[i].sqldata);
+
+ offset = next_offset;
+ }
+ }
+
+ struct sqlda_struct *
+ ecpg_build_native_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ struct sqlda_struct *sqlda;
+ long size;
+ int sqld;
+ int i;
+
+ size = sqlda_native_total_size(res, row, compat);
+ sqlda = (struct sqlda_struct *)ecpg_alloc(size, line);
+ if (!sqlda)
+ return NULL;
+
+ memset(sqlda, 0, size);
+ sqld = PQnfields(res);
+
+ sprintf(sqlda->sqldaid, "SQLDA ");
+ sqlda->sqld = sqlda->sqln = sqld;
+
+ for (i = 0; i < sqlda->sqld; i++)
+ {
+ char *fname;
+
+ sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
+ fname = PQfname(res, i);
+ sqlda->sqlvar[i].sqlname.length = strlen(fname);
+ strcpy(sqlda->sqlvar[i].sqlname.data, fname);
+ }
+
+ return sqlda;
+ }
+
+ void
+ ecpg_set_native_sqlda(int lineno, struct sqlda_struct **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ struct sqlda_struct *sqlda = (*_sqlda);
+ int i;
+ long offset, next_offset;
+
+ if (row < 0)
+ return;
+
+ /* Offset for the first field value */
+ offset = sqlda_native_empty_size(res);
+
+ /*
+ * Set sqlvar[i]->sqldata pointers and convert values to correct format
+ */
+ for (i = 0; i < sqlda->sqld; i++)
+ {
+ int isnull;
+ int datalen;
+ bool set_data = true;
+
+ switch (sqlda->sqlvar[i].sqltype)
+ {
+ case ECPGt_short:
+ case ECPGt_unsigned_short:
+ ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(short);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_int:
+ case ECPGt_unsigned_int:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(int);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_long:
+ case ECPGt_unsigned_long:
+ ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(long);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_long_long:
+ case ECPGt_unsigned_long_long:
+ ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(long long);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_bool:
+ ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(bool);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_float:
+ ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(float);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_double:
+ ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(double);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_decimal:
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(decimal);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_numeric:
+ {
+ numeric *num;
+ char *val;
+
+ set_data = false;
+
+ ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(numeric);
+ ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+
+ if (PQgetisnull(res, row, i))
+ {
+ ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ break;
+ }
+
+ val = PQgetvalue(res, row, i);
+ num = PGTYPESnumeric_from_asc(val, NULL);
+ if (!num)
+ {
+ ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ break;
+ }
+
+ memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
+
+ ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
+ ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+
+ ((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
+ ((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
+
+ PGTYPESnumeric_free(num);
+
+ break;
+ }
+ case ECPGt_date:
+ ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(date);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_timestamp:
+ ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(timestamp);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_interval:
+ ecpg_sqlda_align_add_size(offset, sizeof(int64_t), sizeof(interval), &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = sizeof(interval);
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ case ECPGt_char:
+ case ECPGt_unsigned_char:
+ case ECPGt_string:
+ default:
+ datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ sqlda->sqlvar[i].sqllen = datalen;
+ ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ break;
+ }
+
+ isnull = PQgetisnull(res, row, i);
+ ecpg_log("%s row %d col %d %s\n", __FUNCTION__, row, i, isnull ? "IS NULL" : "IS NOT NULL");
+ sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+ if (!isnull)
+ {
+ if (set_data)
+ ecpg_get_data(res, row, i, lineno,
+ sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
+ sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+ ECPG_ARRAY_NONE, compat, false);
+ }
+
+ offset = next_offset;
+ }
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/typename.c pgsql.2.1/src/interfaces/ecpg/ecpglib/typename.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/typename.c 2009-08-07 13:06:28.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/ecpglib/typename.c 2010-01-01 14:35:36.000000000 +0100
***************
*** 7,12 ****
--- 7,13 ----
#include "ecpgtype.h"
#include "ecpglib.h"
#include "extern.h"
+ #include "sqltypes.h"
#include "sql3types.h"
#include "pg_type.h"
*************** ecpg_dynamic_type(Oid type)
*** 100,102 ****
--- 101,142 ----
return -(int) type;
}
}
+
+ int
+ sqlda_dynamic_type(Oid type, enum COMPAT_MODE compat)
+ {
+ switch (type)
+ {
+ case CHAROID:
+ case VARCHAROID:
+ case BPCHAROID:
+ case TEXTOID:
+ return ECPGt_char;
+ case INT2OID:
+ return ECPGt_short;
+ case INT4OID:
+ return ECPGt_int;
+ case FLOAT8OID:
+ return ECPGt_double;
+ case FLOAT4OID:
+ return ECPGt_float;
+ case NUMERICOID:
+ return INFORMIX_MODE(compat) ? ECPGt_decimal : ECPGt_numeric;
+ case DATEOID:
+ return ECPGt_date;
+ case TIMESTAMPOID:
+ case TIMESTAMPTZOID:
+ return ECPGt_timestamp;
+ case INTERVALOID:
+ return ECPGt_interval;
+ case INT8OID:
+ #ifdef HAVE_LONG_LONG_INT_64
+ return ECPGt_long_long;
+ #endif
+ #ifdef HAVE_LONG_INT_64
+ return ECPGt_long;
+ #endif
+ default:
+ return (-type);
+ }
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/ecpgtype.h pgsql.2.1/src/interfaces/ecpg/include/ecpgtype.h
*** pgsql.orig/src/interfaces/ecpg/include/ecpgtype.h 2009-08-07 13:06:28.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/include/ecpgtype.h 2010-01-01 14:35:36.000000000 +0100
*************** enum ECPGttype
*** 62,68 ****
ECPGt_EOIT, /* End of insert types. */
ECPGt_EORT, /* End of result types. */
ECPGt_NO_INDICATOR, /* no indicator */
! ECPGt_string /* trimmed (char *) type */
};
/* descriptor items */
--- 62,69 ----
ECPGt_EOIT, /* End of insert types. */
ECPGt_EORT, /* End of result types. */
ECPGt_NO_INDICATOR, /* no indicator */
! ECPGt_string, /* trimmed (char *) type */
! ECPGt_sqlda /* C struct descriptor */
};
/* descriptor items */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/Makefile pgsql.2.1/src/interfaces/ecpg/include/Makefile
*** pgsql.orig/src/interfaces/ecpg/include/Makefile 2009-10-27 20:36:17.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/include/Makefile 2010-01-01 15:03:34.000000000 +0100
*************** install: all installdirs install-headers
*** 14,21 ****
.PHONY: install-headers
ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h \
! pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h pgtypes_interval.h
! informix_headers = datetime.h decimal.h sqltypes.h sqlda.h
install-headers: $(ecpg_headers) $(informix_headers)
$(INSTALL_DATA) $(addprefix $(srcdir)/,$(ecpg_headers)) '$(DESTDIR)$(includedir)/'
--- 14,22 ----
.PHONY: install-headers
ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h \
! pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h pgtypes_interval.h \
! sqlda.h sqlda-compat.h sqlda-native.h
! informix_headers = datetime.h decimal.h sqltypes.h
install-headers: $(ecpg_headers) $(informix_headers)
$(INSTALL_DATA) $(addprefix $(srcdir)/,$(ecpg_headers)) '$(DESTDIR)$(includedir)/'
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqlda-compat.h pgsql.2.1/src/interfaces/ecpg/include/sqlda-compat.h
*** pgsql.orig/src/interfaces/ecpg/include/sqlda-compat.h 1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/include/sqlda-compat.h 2010-01-01 15:01:20.000000000 +0100
***************
*** 0 ****
--- 1,47 ----
+ /*
+ * pgsql/src/interfaces/ecpg/include/sqlda-infx-compat.h
+ */
+
+ #ifndef ECPG_SQLDA_COMPAT_H
+ #define ECPG_SQLDA_COMPAT_H
+
+ struct sqlvar_compat
+ {
+ short sqltype; /* variable type */
+ int sqllen; /* length in bytes */
+ char *sqldata; /* pointer to data */
+ short *sqlind; /* pointer to indicator */
+ char *sqlname; /* variable name */
+ char *sqlformat; /* reserved for future use */
+ short sqlitype; /* ind variable type */
+ short sqlilen; /* ind length in bytes */
+ char *sqlidata; /* ind data pointer */
+ int sqlxid; /* extended id type */
+ char *sqltypename; /* extended type name */
+ short sqltypelen; /* length of extended type name */
+ short sqlownerlen; /* length of owner name */
+ short sqlsourcetype; /* source type for distinct of built-ins */
+ char *sqlownername; /* owner name */
+ int sqlsourceid; /* extended id of source type */
+
+ /*
+ * sqlilongdata is new. It supports data that exceeds the 32k
+ * limit. sqlilen and sqlidata are for backward compatibility
+ * and they have maximum value of <32K.
+ */
+ char *sqlilongdata; /* for data field beyond 32K */
+ int sqlflags; /* for internal use only */
+ void *sqlreserved; /* reserved for future use */
+ };
+
+ struct sqlda_compat
+ {
+ short sqld;
+ struct sqlvar_compat *sqlvar;
+ char desc_name[19]; /* descriptor name */
+ short desc_occ; /* size of sqlda structure */
+ struct sqlda_compat *desc_next; /* pointer to next sqlda struct */
+ void *reserved; /* reserved for future use */
+ };
+
+ #endif /* ECPG_SQLDA_COMPAT_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqlda.h pgsql.2.1/src/interfaces/ecpg/include/sqlda.h
*** pgsql.orig/src/interfaces/ecpg/include/sqlda.h 2009-06-13 18:25:05.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/include/sqlda.h 2010-01-04 12:56:38.000000000 +0100
***************
*** 1,3 ****
--- 1,22 ----
/*
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
*/
+
+ #ifndef ECPG_SQLDA_H
+ #define ECPG_SQLDA_H
+
+ #ifdef ECPG_INFORMIX_COMPAT
+
+ #include "sqlda-compat.h"
+ typedef struct sqlvar_compat sqlvar_t;
+ typedef struct sqlda_compat sqlda_t;
+
+ #else
+
+ #include "sqlda-native.h"
+ typedef struct sqlvar_struct sqlvar_t;
+ typedef struct sqlda_struct sqlda_t;
+
+ #endif
+
+ #endif /* ECPG_SQLDA_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqlda-native.h pgsql.2.1/src/interfaces/ecpg/include/sqlda-native.h
*** pgsql.orig/src/interfaces/ecpg/include/sqlda-native.h 1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/include/sqlda-native.h 2010-01-04 13:18:23.000000000 +0100
***************
*** 0 ****
--- 1,35 ----
+ /*
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+ */
+
+ #ifndef ECPG_SQLDA_NATIVE_H
+ #define ECPG_SQLDA_NATIVE_H
+
+ #include "postgres_fe.h"
+
+ struct sqlname
+ {
+ short length;
+ char data[NAMEDATALEN];
+ };
+
+ struct sqlvar_struct
+ {
+ short sqltype;
+ short sqllen;
+ char *sqldata;
+ short *sqlind;
+ struct sqlname sqlname;
+ };
+
+ struct sqlda_struct
+ {
+ char sqldaid[8];
+ long sqldabc;
+ short sqln;
+ short sqld;
+ struct sqlda_struct *desc_next;
+ struct sqlvar_struct sqlvar[1];
+ };
+
+ #endif /* ECPG_SQLDA_NATIVE_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqltypes.h pgsql.2.1/src/interfaces/ecpg/include/sqltypes.h
*** pgsql.orig/src/interfaces/ecpg/include/sqltypes.h 2009-06-13 18:25:05.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/include/sqltypes.h 2010-01-01 14:35:36.000000000 +0100
***************
*** 4,9 ****
--- 4,11 ----
#ifndef ECPG_SQLTYPES_H
#define ECPG_SQLTYPES_H
+ #include <limits.h>
+
#define CCHARTYPE ECPGt_char
#define CSHORTTYPE ECPGt_short
#define CINTTYPE ECPGt_int
***************
*** 30,33 ****
--- 32,60 ----
#define CLVCHARPTRTYPE 124
#define CTYPEMAX 25
+ /*
+ * Values used in sqlda->sqlvar[i]->sqltype
+ */
+ #define SQLCHAR ECPGt_char
+ #define SQLSMINT ECPGt_short
+ #define SQLINT ECPGt_int
+ #define SQLFLOAT ECPGt_double
+ #define SQLSMFLOAT ECPGt_float
+ #define SQLDECIMAL ECPGt_decimal
+ #define SQLSERIAL ECPGt_int
+ #define SQLDATE ECPGt_date
+ #define SQLDTIME ECPGt_timestamp
+ #define SQLTEXT ECPGt_char
+ #define SQLVCHAR ECPGt_char
+ #define SQLINTERVAL ECPGt_interval
+ #define SQLNCHAR ECPGt_char
+ #define SQLNVCHAR ECPGt_char
+ #if (LONG_BIT == 64)
+ #define SQLINT8 ECPGt_long
+ #define SQLSERIAL8 ECPGt_long
+ #else
+ #define SQLINT8 ECPGt_long_long
+ #define SQLSERIAL8 ECPGt_long_long
+ #endif
+
#endif /* ndef ECPG_SQLTYPES_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/descriptor.c pgsql.2.1/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.orig/src/interfaces/ecpg/preproc/descriptor.c 2009-01-30 17:28:46.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/preproc/descriptor.c 2010-01-01 14:35:36.000000000 +0100
*************** descriptor_variable(const char *name, in
*** 326,328 ****
--- 326,347 ----
strlcpy(descriptor_names[input], name, sizeof(descriptor_names[input]));
return (struct variable *) & varspace[input];
}
+
+ struct variable *
+ sqlda_variable(const char *name)
+ {
+ struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable));
+
+ p->name = mm_strdup(name);
+ p->type = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
+ p->type->type = ECPGt_sqlda;
+ p->type->size = NULL;
+ p->type->struct_sizeof = NULL;
+ p->type->u.element = NULL;
+ p->type->lineno = 0;
+ p->brace_level = 0;
+ p->next = NULL;
+
+ return p;
+ }
+
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons 2009-12-16 11:30:27.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.addons 2010-01-01 14:35:36.000000000 +0100
*************** ECPG: VariableShowStmtSHOWALL block
*** 409,437 ****
$$ = EMPTY;
}
ECPG: FetchStmtMOVEfetch_args rule
! | FETCH fetch_args ecpg_into
{
$$ = cat2_str(make_str("fetch"), $2);
}
! | FETCH FORWARD cursor_name opt_ecpg_into
{
char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
add_additional_variables($3, false);
$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
}
! | FETCH FORWARD from_in cursor_name opt_ecpg_into
{
char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
add_additional_variables($4, false);
$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
}
! | FETCH BACKWARD cursor_name opt_ecpg_into
{
char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
add_additional_variables($3, false);
$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
}
! | FETCH BACKWARD from_in cursor_name opt_ecpg_into
{
char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
add_additional_variables($4, false);
--- 409,437 ----
$$ = EMPTY;
}
ECPG: FetchStmtMOVEfetch_args rule
! | FETCH fetch_args ecpg_fetch_into
{
$$ = cat2_str(make_str("fetch"), $2);
}
! | FETCH FORWARD cursor_name opt_ecpg_fetch_into
{
char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
add_additional_variables($3, false);
$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
}
! | FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
{
char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
add_additional_variables($4, false);
$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
}
! | FETCH BACKWARD cursor_name opt_ecpg_fetch_into
{
char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
add_additional_variables($3, false);
$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
}
! | FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
{
char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
add_additional_variables($4, false);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.c pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.c
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.c 2009-08-07 13:06:28.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.c 2010-01-01 14:43:43.000000000 +0100
*************** main(int argc, char *const argv[])
*** 446,451 ****
--- 446,454 ----
fprintf(yyout, "/* End of automatic include section */\n");
}
+ if (INFORMIX_MODE)
+ fprintf(yyout, "#define ECPG_INFORMIX_COMPAT 1\n");
+
if (regression_mode)
fprintf(yyout, "#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))\n");
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer 2009-11-26 18:57:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.trailer 2010-01-01 16:28:15.000000000 +0100
*************** ecpg_using: USING using_list { $$ = EMP
*** 970,991 ****
| using_descriptor { $$ = $1; }
;
! using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
{
add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
$$ = EMPTY;
}
;
! into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
{
add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
$$ = EMPTY;
}
;
- opt_sql: /*EMPTY*/ | SQL_SQL;
-
using_list: UsingValue | UsingValue ',' using_list;
UsingValue: UsingConst
--- 970,999 ----
| using_descriptor { $$ = $1; }
;
! using_descriptor: USING SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar
{
add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
$$ = EMPTY;
}
+ | USING SQL_DESCRIPTOR name
+ {
+ add_variable_to_head(&argsinsert, sqlda_variable($3), &no_indicator);
+ $$ = EMPTY;
+ }
;
! into_descriptor: INTO SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar
{
add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
$$ = EMPTY;
}
+ | INTO SQL_DESCRIPTOR name
+ {
+ add_variable_to_head(&argsresult, sqlda_variable($3), &no_indicator);
+ $$ = EMPTY;
+ }
;
using_list: UsingValue | UsingValue ',' using_list;
UsingValue: UsingConst
*************** ecpg_into: INTO into_list { $$ = EMPTY;
*** 1806,1813 ****
| into_descriptor { $$ = $1; }
;
! opt_ecpg_into: /* EMPTY */ { $$ = EMPTY; }
! | ecpg_into { $$ = $1; }
;
%%
--- 1814,1833 ----
| into_descriptor { $$ = $1; }
;
! ecpg_fetch_into: ecpg_into { $$ = $1; }
! | using_descriptor
! {
! struct variable *var;
!
! var = argsinsert->variable;
! remove_variable_from_list(&argsinsert, var);
! add_variable_to_head(&argsresult, var, &no_indicator);
! $$ = $1;
! }
! ;
!
! opt_ecpg_fetch_into: /* EMPTY */ { $$ = EMPTY; }
! | ecpg_fetch_into { $$ = $1; }
;
%%
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type 2009-11-26 18:57:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.type 2010-01-01 14:35:36.000000000 +0100
***************
*** 61,66 ****
--- 61,67 ----
%type <str> ecpg_ident
%type <str> ecpg_interval
%type <str> ecpg_into
+ %type <str> ecpg_fetch_into
%type <str> ecpg_param
%type <str> ecpg_sconst
%type <str> ecpg_using
***************
*** 76,82 ****
%type <str> opt_bit_field
%type <str> opt_connection_name
%type <str> opt_database_name
! %type <str> opt_ecpg_into
%type <str> opt_ecpg_using
%type <str> opt_initializer
%type <str> opt_options
--- 77,83 ----
%type <str> opt_bit_field
%type <str> opt_connection_name
%type <str> opt_database_name
! %type <str> opt_ecpg_fetch_into
%type <str> opt_ecpg_using
%type <str> opt_initializer
%type <str> opt_options
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/extern.h pgsql.2.1/src/interfaces/ecpg/preproc/extern.h
*** pgsql.orig/src/interfaces/ecpg/preproc/extern.h 2009-11-26 18:57:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/preproc/extern.h 2010-01-01 14:35:36.000000000 +0100
*************** extern void add_descriptor(char *, char
*** 88,93 ****
--- 88,94 ----
extern void drop_descriptor(char *, char *);
extern struct descriptor *lookup_descriptor(char *, char *);
extern struct variable *descriptor_variable(const char *name, int input);
+ extern struct variable *sqlda_variable(const char *name);
extern void add_variable_to_head(struct arguments **, struct variable *, struct variable *);
extern void add_variable_to_tail(struct arguments **, struct variable *, struct variable *);
extern void remove_variable_from_list(struct arguments ** list, struct variable * var);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/type.c pgsql.2.1/src/interfaces/ecpg/preproc/type.c
*** pgsql.orig/src/interfaces/ecpg/preproc/type.c 2009-09-03 12:25:47.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/preproc/type.c 2010-01-01 14:35:36.000000000 +0100
*************** get_type(enum ECPGttype type)
*** 194,199 ****
--- 194,202 ----
case ECPGt_descriptor:
return ("ECPGt_descriptor");
break;
+ case ECPGt_sqlda:
+ return ("ECPGt_sqlda");
+ break;
case ECPGt_date:
return ("ECPGt_date");
break;
*************** ECPGdump_a_simple(FILE *o, const char *n
*** 328,333 ****
--- 331,338 ----
else if (type == ECPGt_descriptor)
/* remember that name here already contains quotes (if needed) */
fprintf(o, "\n\tECPGt_descriptor, %s, 0L, 0L, 0L, ", name);
+ else if (type == ECPGt_sqlda)
+ fprintf(o, "\n\tECPGt_sqlda, &%s, 0L, 0L, 0L, ", name);
else
{
char *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.2.1/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile 2006-09-19 17:36:08.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/test/compat_informix/Makefile 2010-01-01 14:35:36.000000000 +0100
*************** TESTS = test_informix test_informix.c \
*** 16,21 ****
--- 16,22 ----
rfmtdate rfmtdate.c \
rfmtlong rfmtlong.c \
rnull rnull.c \
+ sqlda sqlda.c \
charfuncs charfuncs.c
all: $(TESTS)
*************** test_informix.c: test_informix.pgc ../re
*** 26,31 ****
--- 27,35 ----
test_informix2.c: test_informix2.pgc ../regression.h
$(ECPG) -o $@ -I$(srcdir) $<
+ sqlda.c: sqlda.pgc ../regression.h
+ $(ECPG) -o $@ -I$(srcdir) $<
+
dec_test.c: dec_test.pgc ../regression.h
$(ECPG) -o $@ -I$(srcdir) $<
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/sqlda.pgc pgsql.2.1/src/interfaces/ecpg/test/compat_informix/sqlda.pgc
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/sqlda.pgc 1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/compat_informix/sqlda.pgc 2010-01-04 14:25:46.000000000 +0100
***************
*** 0 ****
--- 1,254 ----
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+
+ exec sql include ../regression;
+
+ exec sql include sqlda.h;
+ exec sql include sqltypes.h;
+
+ exec sql whenever sqlerror stop;
+
+ /* These shouldn't be under DECLARE SECTION */
+ sqlda_t *inp_sqlda, *outp_sqlda;
+
+ static void
+ dump_sqlda(sqlda_t *sqlda)
+ {
+ int i;
+
+ if (sqlda == NULL)
+ {
+ printf("dump_sqlda called with NULL sqlda\n");
+ return;
+ }
+
+ for (i = 0; i < sqlda->sqld; i++)
+ {
+ if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ else
+ switch (sqlda->sqlvar[i].sqltype)
+ {
+ case SQLCHAR:
+ printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ break;
+ case SQLINT:
+ printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ break;
+ case SQLINT8:
+ printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ break;
+ case SQLFLOAT:
+ printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ break;
+ case SQLDECIMAL:
+ {
+ char val[64];
+ dectoasc((dec_t *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ break;
+ }
+ }
+ }
+ }
+
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ char *stmt1 = "SELECT * FROM t1";
+ char *stmt2 = "SELECT * FROM t1 WHERE id = ?";
+ int rec;
+ int id;
+ exec sql end declare section;
+
+ char msg[128];
+
+ ECPGdebug(1, stderr);
+
+ strcpy(msg, "connect");
+ exec sql connect to REGRESSDB1 as regress1;
+
+ strcpy(msg, "set");
+ exec sql set datestyle to iso;
+
+ strcpy(msg, "create");
+ exec sql create table t1(
+ id integer,
+ t text,
+ d1 numeric,
+ d2 float8,
+ c char(10));
+
+ strcpy(msg, "insert");
+ exec sql insert into t1 values
+ (1, 'a', 1.0, 1, 'a'),
+ (2, null, null, null, null),
+ (3, '"c"', -3, 'nan'::float8, 'c'),
+ (4, 'd', 4.0, 4, 'd');
+
+ strcpy(msg, "commit");
+ exec sql commit;
+
+ /* SQLDA test for getting all records from a table */
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ exec sql prepare st_id1 from :stmt1;
+
+ strcpy(msg, "declare");
+ exec sql declare mycur1 cursor for st_id1;
+
+ strcpy(msg, "open");
+ exec sql open mycur1;
+
+ exec sql whenever not found do break;
+
+ rec = 0;
+ while (1)
+ {
+ strcpy(msg, "fetch");
+ exec sql fetch 1 from mycur1 into descriptor outp_sqlda;
+
+ printf("FETCH RECORD %d\n", ++rec);
+ dump_sqlda(outp_sqlda);
+ }
+
+ exec sql whenever not found continue;
+
+ strcpy(msg, "close");
+ exec sql close mycur1;
+
+ strcpy(msg, "deallocate");
+ exec sql deallocate prepare st_id1;
+
+ free(outp_sqlda);
+
+ /* SQLDA test for getting all records from a table
+ using the Informix-specific FETCH ... USING DESCRIPTOR
+ */
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ exec sql prepare st_id2 from :stmt1;
+
+ strcpy(msg, "declare");
+ exec sql declare mycur2 cursor for st_id2;
+
+ strcpy(msg, "open");
+ exec sql open mycur2;
+
+ exec sql whenever not found do break;
+
+ rec = 0;
+ while (1)
+ {
+ strcpy(msg, "fetch");
+ exec sql fetch from mycur2 using descriptor outp_sqlda;
+
+ printf("FETCH RECORD %d\n", ++rec);
+ dump_sqlda(outp_sqlda);
+ }
+
+ exec sql whenever not found continue;
+
+ strcpy(msg, "close");
+ exec sql close mycur2;
+
+ strcpy(msg, "deallocate");
+ exec sql deallocate prepare st_id2;
+
+ free(outp_sqlda);
+
+ /* SQLDA test for getting one record using an input descriptor */
+
+ /* Input sqlda has to be built manually */
+ inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ memset(inp_sqlda, 0, sizeof(sqlda_t));
+ inp_sqlda->sqld = 1;
+ inp_sqlda->sqlvar = malloc(sizeof(sqlvar_t));
+ memset(inp_sqlda->sqlvar, 0, sizeof(sqlvar_t));
+
+ inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+ printf("EXECUTE RECORD 4\n");
+
+ id = 4;
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ exec sql prepare st_id3 FROM :stmt2;
+
+ strcpy(msg, "execute");
+ exec sql execute st_id3 using descriptor inp_sqlda into descriptor outp_sqlda;
+
+ dump_sqlda(outp_sqlda);
+
+ strcpy(msg, "deallocate");
+ exec sql deallocate prepare st_id3;
+
+ free(inp_sqlda->sqlvar);
+ free(inp_sqlda);
+ free(outp_sqlda);
+
+ /* SQLDA test for getting one record using an input descriptor
+ * on a named connection
+ */
+
+ exec sql connect to REGRESSDB1 as con2;
+
+ /* Input sqlda has to be built manually */
+ inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ memset(inp_sqlda, 0, sizeof(sqlda_t));
+ inp_sqlda->sqld = 1;
+ inp_sqlda->sqlvar = malloc(sizeof(sqlvar_t));
+ memset(inp_sqlda->sqlvar, 0, sizeof(sqlvar_t));
+
+ inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+ printf("EXECUTE RECORD 4\n");
+
+ id = 4;
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ exec sql at con2 prepare st_id4 FROM :stmt2;
+
+ strcpy(msg, "execute");
+ exec sql at con2 execute st_id4 using descriptor inp_sqlda into descriptor outp_sqlda;
+
+ dump_sqlda(outp_sqlda);
+
+ strcpy(msg, "commit");
+ exec sql at con2 commit;
+
+ strcpy(msg, "deallocate");
+ exec sql deallocate prepare st_id4;
+
+ free(inp_sqlda->sqlvar);
+ free(inp_sqlda);
+ free(outp_sqlda);
+
+ strcpy(msg, "disconnect");
+ exec sql disconnect con2;
+
+ /* End test */
+
+ strcpy(msg, "drop");
+ exec sql drop table t1;
+
+ strcpy(msg, "commit");
+ exec sql commit;
+
+ strcpy(msg, "disconnect");
+ exec sql disconnect;
+
+ return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule pgsql.2.1/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule 2009-11-26 18:57:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/ecpg_schedule 2010-01-01 14:35:36.000000000 +0100
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
test: compat_informix/rfmtdate
test: compat_informix/rfmtlong
test: compat_informix/rnull
+ test: compat_informix/sqlda
test: compat_informix/test_informix
test: compat_informix/test_informix2
test: connect/test2
*************** test: sql/code100
*** 29,34 ****
--- 30,36 ----
test: sql/copystdout
test: sql/define
test: sql/desc
+ test: sql/sqlda
test: sql/dynalloc
test: sql/dynalloc2
test: sql/dyntest
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.2.1/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp 2009-11-26 18:57:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/ecpg_schedule_tcp 2010-01-01 14:35:36.000000000 +0100
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
test: compat_informix/rfmtdate
test: compat_informix/rfmtlong
test: compat_informix/rnull
+ test: compat_informix/sqlda
test: compat_informix/test_informix
test: compat_informix/test_informix2
test: connect/test2
*************** test: sql/code100
*** 29,34 ****
--- 30,36 ----
test: sql/copystdout
test: sql/define
test: sql/desc
+ test: sql/sqlda
test: sql/dynalloc
test: sql/dynalloc2
test: sql/dyntest
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c 2008-02-18 13:50:14.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c 2010-01-04 13:49:39.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
/* Needed for informix compatibility */
#include <ecpg_informix.h>
/* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "charfuncs.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c 2008-02-18 13:50:14.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c 2010-01-04 13:49:28.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
/* Needed for informix compatibility */
#include <ecpg_informix.h>
/* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "dec_test.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c 2008-02-18 13:50:14.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c 2010-01-04 13:49:54.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
/* Needed for informix compatibility */
#include <ecpg_informix.h>
/* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "rfmtdate.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c 2008-02-18 13:50:14.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c 2010-01-04 13:50:00.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
/* Needed for informix compatibility */
#include <ecpg_informix.h>
/* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "rfmtlong.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-rnull.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-rnull.c 2008-12-30 15:28:02.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-rnull.c 2010-01-04 13:50:12.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
/* Needed for informix compatibility */
#include <ecpg_informix.h>
/* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "rnull.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c 1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c 2010-01-04 14:30:22.000000000 +0100
***************
*** 0 ****
--- 1,541 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "sqlda.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 5 "sqlda.pgc"
+
+
+
+ #line 1 "sqlda.h"
+ /*
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+ */
+
+ #ifndef ECPG_SQLDA_H
+ #define ECPG_SQLDA_H
+
+ #ifdef ECPG_INFORMIX_COMPAT
+
+ #include "sqlda-compat.h"
+ typedef struct sqlvar_compat sqlvar_t;
+ typedef struct sqlda_compat sqlda_t;
+
+ #else
+
+ #include "sqlda-native.h"
+ typedef struct sqlvar_struct sqlvar_t;
+ typedef struct sqlda_struct sqlda_t;
+
+ #endif
+
+ #endif /* ECPG_SQLDA_H */
+
+ #line 7 "sqlda.pgc"
+
+
+ #line 1 "sqltypes.h"
+ /*
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.9 2009/06/11 14:49:13 momjian Exp $
+ */
+ #ifndef ECPG_SQLTYPES_H
+ #define ECPG_SQLTYPES_H
+
+ #include <limits.h>
+
+ #define CCHARTYPE ECPGt_char
+ #define CSHORTTYPE ECPGt_short
+ #define CINTTYPE ECPGt_int
+ #define CLONGTYPE ECPGt_long
+ #define CFLOATTYPE ECPGt_float
+ #define CDOUBLETYPE ECPGt_double
+ #define CDECIMALTYPE ECPGt_decimal
+ #define CFIXCHARTYPE 108
+ #define CSTRINGTYPE ECPGt_char
+ #define CDATETYPE ECPGt_date
+ #define CMONEYTYPE 111
+ #define CDTIMETYPE ECPGt_timestamp
+ #define CLOCATORTYPE 113
+ #define CVCHARTYPE ECPGt_varchar
+ #define CINVTYPE 115
+ #define CFILETYPE 116
+ #define CINT8TYPE ECPGt_long_long
+ #define CCOLLTYPE 118
+ #define CLVCHARTYPE 119
+ #define CFIXBINTYPE 120
+ #define CVARBINTYPE 121
+ #define CBOOLTYPE ECPGt_bool
+ #define CROWTYPE 123
+ #define CLVCHARPTRTYPE 124
+ #define CTYPEMAX 25
+
+ /*
+ * Values used in sqlda->sqlvar[i]->sqltype
+ */
+ #define SQLCHAR ECPGt_char
+ #define SQLSMINT ECPGt_short
+ #define SQLINT ECPGt_int
+ #define SQLFLOAT ECPGt_double
+ #define SQLSMFLOAT ECPGt_float
+ #define SQLDECIMAL ECPGt_decimal
+ #define SQLSERIAL ECPGt_int
+ #define SQLDATE ECPGt_date
+ #define SQLDTIME ECPGt_timestamp
+ #define SQLTEXT ECPGt_char
+ #define SQLVCHAR ECPGt_char
+ #define SQLINTERVAL ECPGt_interval
+ #define SQLNCHAR ECPGt_char
+ #define SQLNVCHAR ECPGt_char
+ #if (LONG_BIT == 64)
+ #define SQLINT8 ECPGt_long
+ #define SQLSERIAL8 ECPGt_long
+ #else
+ #define SQLINT8 ECPGt_long_long
+ #define SQLSERIAL8 ECPGt_long_long
+ #endif
+
+ #endif /* ndef ECPG_SQLTYPES_H */
+
+ #line 8 "sqlda.pgc"
+
+
+ /* exec sql whenever sqlerror stop ; */
+ #line 10 "sqlda.pgc"
+
+
+ /* These shouldn't be under DECLARE SECTION */
+ sqlda_t *inp_sqlda, *outp_sqlda;
+
+ static void
+ dump_sqlda(sqlda_t *sqlda)
+ {
+ int i;
+
+ if (sqlda == NULL)
+ {
+ printf("dump_sqlda called with NULL sqlda\n");
+ return;
+ }
+
+ for (i = 0; i < sqlda->sqld; i++)
+ {
+ if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ else
+ switch (sqlda->sqlvar[i].sqltype)
+ {
+ case SQLCHAR:
+ printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ break;
+ case SQLINT:
+ printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ break;
+ case SQLINT8:
+ printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ break;
+ case SQLFLOAT:
+ printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ break;
+ case SQLDECIMAL:
+ {
+ char val[64];
+ dectoasc((decimal *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ break;
+ }
+ }
+ }
+ }
+
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+
+
+
+
+
+ #line 60 "sqlda.pgc"
+ char * stmt1 = "SELECT * FROM t1" ;
+
+ #line 61 "sqlda.pgc"
+ char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
+
+ #line 62 "sqlda.pgc"
+ int rec ;
+
+ #line 63 "sqlda.pgc"
+ int id ;
+ /* exec sql end declare section */
+ #line 64 "sqlda.pgc"
+
+
+ char msg[128];
+
+ ECPGdebug(1, stderr);
+
+ strcpy(msg, "connect");
+ { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "regress1", 0);
+ #line 71 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 71 "sqlda.pgc"
+
+
+ strcpy(msg, "set");
+ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 74 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 74 "sqlda.pgc"
+
+
+ strcpy(msg, "create");
+ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 82 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "sqlda.pgc"
+
+
+ strcpy(msg, "insert");
+ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '\"c\"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 89 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 89 "sqlda.pgc"
+
+
+ strcpy(msg, "commit");
+ { ECPGtrans(__LINE__, NULL, "commit");
+ #line 92 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 92 "sqlda.pgc"
+
+
+ /* SQLDA test for getting all records from a table */
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 99 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "sqlda.pgc"
+
+
+ strcpy(msg, "declare");
+ ECPG_informix_reset_sqlca(); /* declare mycur1 cursor for $1 */
+ #line 102 "sqlda.pgc"
+
+
+ strcpy(msg, "open");
+ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1",
+ ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 105 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 105 "sqlda.pgc"
+
+
+ /* exec sql whenever not found break ; */
+ #line 107 "sqlda.pgc"
+
+
+ rec = 0;
+ while (1)
+ {
+ strcpy(msg, "fetch");
+ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT,
+ ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 113 "sqlda.pgc"
+
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 113 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 113 "sqlda.pgc"
+
+
+ printf("FETCH RECORD %d\n", ++rec);
+ dump_sqlda(outp_sqlda);
+ }
+
+ /* exec sql whenever not found continue ; */
+ #line 119 "sqlda.pgc"
+
+
+ strcpy(msg, "close");
+ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 122 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 122 "sqlda.pgc"
+
+
+ strcpy(msg, "deallocate");
+ { ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 125 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 125 "sqlda.pgc"
+
+
+ free(outp_sqlda);
+
+ /* SQLDA test for getting all records from a table
+ using the Informix-specific FETCH ... USING DESCRIPTOR
+ */
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 136 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 136 "sqlda.pgc"
+
+
+ strcpy(msg, "declare");
+ ECPG_informix_reset_sqlca(); /* declare mycur2 cursor for $1 */
+ #line 139 "sqlda.pgc"
+
+
+ strcpy(msg, "open");
+ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1",
+ ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 142 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 142 "sqlda.pgc"
+
+
+ /* exec sql whenever not found break ; */
+ #line 144 "sqlda.pgc"
+
+
+ rec = 0;
+ while (1)
+ {
+ strcpy(msg, "fetch");
+ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from mycur2", ECPGt_EOIT,
+ ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 150 "sqlda.pgc"
+
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 150 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 150 "sqlda.pgc"
+
+
+ printf("FETCH RECORD %d\n", ++rec);
+ dump_sqlda(outp_sqlda);
+ }
+
+ /* exec sql whenever not found continue ; */
+ #line 156 "sqlda.pgc"
+
+
+ strcpy(msg, "close");
+ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+ #line 159 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 159 "sqlda.pgc"
+
+
+ strcpy(msg, "deallocate");
+ { ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 162 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 162 "sqlda.pgc"
+
+
+ free(outp_sqlda);
+
+ /* SQLDA test for getting one record using an input descriptor */
+
+ /* Input sqlda has to be built manually */
+ inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ memset(inp_sqlda, 0, sizeof(sqlda_t));
+ inp_sqlda->sqld = 1;
+ inp_sqlda->sqlvar = malloc(sizeof(sqlvar_t));
+ memset(inp_sqlda->sqlvar, 0, sizeof(sqlvar_t));
+
+ inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+ printf("EXECUTE RECORD 4\n");
+
+ id = 4;
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ { ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
+ #line 185 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 185 "sqlda.pgc"
+
+
+ strcpy(msg, "execute");
+ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_execute, "st_id3",
+ ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L,
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+ ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 188 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 188 "sqlda.pgc"
+
+
+ dump_sqlda(outp_sqlda);
+
+ strcpy(msg, "deallocate");
+ { ECPGdeallocate(__LINE__, 1, NULL, "st_id3");
+ #line 193 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 193 "sqlda.pgc"
+
+
+ free(inp_sqlda->sqlvar);
+ free(inp_sqlda);
+ free(outp_sqlda);
+
+ /* SQLDA test for getting one record using an input descriptor
+ * on a named connection
+ */
+
+ { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "con2", 0);
+ #line 203 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 203 "sqlda.pgc"
+
+
+ /* Input sqlda has to be built manually */
+ inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ memset(inp_sqlda, 0, sizeof(sqlda_t));
+ inp_sqlda->sqld = 1;
+ inp_sqlda->sqlvar = malloc(sizeof(sqlvar_t));
+ memset(inp_sqlda->sqlvar, 0, sizeof(sqlvar_t));
+
+ inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+ printf("EXECUTE RECORD 4\n");
+
+ id = 4;
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ { ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
+ #line 222 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 222 "sqlda.pgc"
+
+
+ strcpy(msg, "execute");
+ { ECPGdo(__LINE__, 1, 1, "con2", 0, ECPGst_execute, "st_id4",
+ ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L,
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+ ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 225 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 225 "sqlda.pgc"
+
+
+ dump_sqlda(outp_sqlda);
+
+ strcpy(msg, "commit");
+ { ECPGtrans(__LINE__, "con2", "commit");
+ #line 230 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 230 "sqlda.pgc"
+
+
+ strcpy(msg, "deallocate");
+ { ECPGdeallocate(__LINE__, 1, NULL, "st_id4");
+ #line 233 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 233 "sqlda.pgc"
+
+
+ free(inp_sqlda->sqlvar);
+ free(inp_sqlda);
+ free(outp_sqlda);
+
+ strcpy(msg, "disconnect");
+ { ECPGdisconnect(__LINE__, "con2");
+ #line 240 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 240 "sqlda.pgc"
+
+
+ /* End test */
+
+ strcpy(msg, "drop");
+ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 245 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 245 "sqlda.pgc"
+
+
+ strcpy(msg, "commit");
+ { ECPGtrans(__LINE__, NULL, "commit");
+ #line 248 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 248 "sqlda.pgc"
+
+
+ strcpy(msg, "disconnect");
+ { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 251 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 251 "sqlda.pgc"
+
+
+ return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr 1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr 2010-01-04 18:18:27.000000000 +0100
***************
*** 0 ****
--- 1,604 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 74: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 74: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 74: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 77: query: create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 77: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 77: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '"c"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: OK: INSERT 0 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 92: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 99: name st_id1; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 105: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 105: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 105: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 113: no data found on line 113
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 122: query: close mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 122: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 122: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 125: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 136: name st_id2; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 142: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 142: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 142: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 150: no data found on line 150
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 159: query: close mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 159: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 159: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 162: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 185: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 188: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 188: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 188: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 188: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 188: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 188: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 188: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 188: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 188: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 188: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 188: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 193: name st_id3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 222: name st_id4; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 225: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection con2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 225: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 225: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 225: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 225: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 225: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 225: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 225: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 225: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 225: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 225: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 230: action "commit"; connection "con2"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 233: name st_id4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection con2 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 245: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 245: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 245: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 248: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout 1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout 2010-01-01 14:35:36.000000000 +0100
***************
*** 0 ****
--- 1,60 ----
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd '
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd '
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c 2008-12-30 15:28:02.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c 2010-01-04 13:51:27.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
/* Needed for informix compatibility */
#include <ecpg_informix.h>
/* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "test_informix2.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c 2009-11-11 20:47:12.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c 2010-01-04 13:51:27.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
/* Needed for informix compatibility */
#include <ecpg_informix.h>
/* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "test_informix.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.c pgsql.2.1/src/interfaces/ecpg/test/expected/sql-sqlda.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.c 1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/sql-sqlda.c 2010-01-04 14:52:41.000000000 +0100
***************
*** 0 ****
--- 1,548 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "sqlda.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 6 "sqlda.pgc"
+
+
+
+ #line 1 "sqlda.h"
+ /*
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+ */
+
+ #ifndef ECPG_SQLDA_H
+ #define ECPG_SQLDA_H
+
+ #ifdef ECPG_INFORMIX_COMPAT
+
+ #include "sqlda-compat.h"
+ typedef struct sqlvar_compat sqlvar_t;
+ typedef struct sqlda_compat sqlda_t;
+
+ #else
+
+ #include "sqlda-native.h"
+ typedef struct sqlvar_struct sqlvar_t;
+ typedef struct sqlda_struct sqlda_t;
+
+ #endif
+
+ #endif /* ECPG_SQLDA_H */
+
+ #line 8 "sqlda.pgc"
+
+
+ #line 1 "pgtypes_numeric.h"
+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_numeric.h,v 1.16 2006/08/09 07:30:56 meskes Exp $ */
+
+ #ifndef PGTYPES_NUMERIC
+ #define PGTYPES_NUMERIC
+
+ #define NUMERIC_POS 0x0000
+ #define NUMERIC_NEG 0x4000
+ #define NUMERIC_NAN 0xC000
+ #define NUMERIC_MAX_PRECISION 1000
+ #define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION
+ #define NUMERIC_MIN_DISPLAY_SCALE 0
+ #define NUMERIC_MIN_SIG_DIGITS 16
+
+ #define DECSIZE 30
+
+ typedef unsigned char NumericDigit;
+ typedef struct
+ {
+ int ndigits; /* number of digits in digits[] - can be 0! */
+ int weight; /* weight of first digit */
+ int rscale; /* result scale */
+ int dscale; /* display scale */
+ int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ NumericDigit *buf; /* start of alloc'd space for digits[] */
+ NumericDigit *digits; /* decimal digits */
+ } numeric;
+
+ typedef struct
+ {
+ int ndigits; /* number of digits in digits[] - can be 0! */
+ int weight; /* weight of first digit */
+ int rscale; /* result scale */
+ int dscale; /* display scale */
+ int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ NumericDigit digits[DECSIZE]; /* decimal digits */
+ } decimal;
+
+ #ifdef __cplusplus
+ extern "C"
+ {
+ #endif
+
+ numeric *PGTYPESnumeric_new(void);
+ decimal *PGTYPESdecimal_new(void);
+ void PGTYPESnumeric_free(numeric *);
+ void PGTYPESdecimal_free(decimal *);
+ numeric *PGTYPESnumeric_from_asc(char *, char **);
+ char *PGTYPESnumeric_to_asc(numeric *, int);
+ int PGTYPESnumeric_add(numeric *, numeric *, numeric *);
+ int PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
+ int PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
+ int PGTYPESnumeric_div(numeric *, numeric *, numeric *);
+ int PGTYPESnumeric_cmp(numeric *, numeric *);
+ int PGTYPESnumeric_from_int(signed int, numeric *);
+ int PGTYPESnumeric_from_long(signed long int, numeric *);
+ int PGTYPESnumeric_copy(numeric *, numeric *);
+ int PGTYPESnumeric_from_double(double, numeric *);
+ int PGTYPESnumeric_to_double(numeric *, double *);
+ int PGTYPESnumeric_to_int(numeric *, int *);
+ int PGTYPESnumeric_to_long(numeric *, long *);
+ int PGTYPESnumeric_to_decimal(numeric *, decimal *);
+ int PGTYPESnumeric_from_decimal(decimal *, numeric *);
+
+ #ifdef __cplusplus
+ }
+ #endif
+
+ #endif /* PGTYPES_NUMERIC */
+
+ #line 9 "sqlda.pgc"
+
+
+ /* exec sql whenever sqlerror stop ; */
+ #line 11 "sqlda.pgc"
+
+
+ /* These shouldn't be under DECLARE SECTION */
+ sqlda_t *inp_sqlda, *outp_sqlda, *outp_sqlda1;
+
+ static void
+ dump_sqlda(sqlda_t *sqlda)
+ {
+ int i;
+
+ if (sqlda == NULL)
+ {
+ printf("dump_sqlda called with NULL sqlda\n");
+ return;
+ }
+
+ for (i = 0; i < sqlda->sqld; i++)
+ {
+ if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname.data);
+ else
+ switch (sqlda->sqlvar[i].sqltype)
+ {
+ case ECPGt_char:
+ printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname.data, sqlda->sqlvar[i].sqldata);
+ break;
+ case ECPGt_int:
+ printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname.data, *(int *)sqlda->sqlvar[i].sqldata);
+ break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ case ECPGt_long_long:
+ # else
+ # error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname.data, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ break;
+ case ECPGt_double:
+ printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname.data, *(double *)sqlda->sqlvar[i].sqldata);
+ break;
+ case ECPGt_numeric:
+ {
+ char *val;
+
+ val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname.data, val);
+ free(val);
+ break;
+ }
+ }
+ }
+ }
+
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+
+
+
+
+
+ #line 71 "sqlda.pgc"
+ char * stmt1 = "SELECT * FROM t1" ;
+
+ #line 72 "sqlda.pgc"
+ char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
+
+ #line 73 "sqlda.pgc"
+ int rec ;
+
+ #line 74 "sqlda.pgc"
+ int id ;
+ /* exec sql end declare section */
+ #line 75 "sqlda.pgc"
+
+
+ char msg[128];
+
+ ECPGdebug(1, stderr);
+
+ strcpy(msg, "connect");
+ { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "regress1", 0);
+ #line 82 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "sqlda.pgc"
+
+
+ strcpy(msg, "set");
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 85 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 85 "sqlda.pgc"
+
+
+ strcpy(msg, "create");
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 93 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 93 "sqlda.pgc"
+
+
+ strcpy(msg, "insert");
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '\"c\"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 100 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 100 "sqlda.pgc"
+
+
+ strcpy(msg, "commit");
+ { ECPGtrans(__LINE__, NULL, "commit");
+ #line 103 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 103 "sqlda.pgc"
+
+
+ /* SQLDA test for getting all records from a table */
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 110 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "sqlda.pgc"
+
+
+ strcpy(msg, "declare");
+ /* declare mycur1 cursor for $1 */
+ #line 113 "sqlda.pgc"
+
+
+ strcpy(msg, "open");
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1",
+ ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 116 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 116 "sqlda.pgc"
+
+
+ /* exec sql whenever not found break ; */
+ #line 118 "sqlda.pgc"
+
+
+ rec = 0;
+ while (1)
+ {
+ strcpy(msg, "fetch");
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT,
+ ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 124 "sqlda.pgc"
+
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 124 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 124 "sqlda.pgc"
+
+
+ printf("FETCH RECORD %d\n", ++rec);
+ dump_sqlda(outp_sqlda);
+ }
+
+ /* exec sql whenever not found continue ; */
+ #line 130 "sqlda.pgc"
+
+
+ strcpy(msg, "close");
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 133 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 133 "sqlda.pgc"
+
+
+ strcpy(msg, "deallocate");
+ { ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 136 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 136 "sqlda.pgc"
+
+
+ free(outp_sqlda);
+
+ /* SQLDA test for getting ALL records into the sqlda list */
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 145 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 145 "sqlda.pgc"
+
+
+ strcpy(msg, "declare");
+ /* declare mycur2 cursor for $1 */
+ #line 148 "sqlda.pgc"
+
+
+ strcpy(msg, "open");
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1",
+ ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 151 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 151 "sqlda.pgc"
+
+
+ strcpy(msg, "fetch");
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT,
+ ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 154 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 154 "sqlda.pgc"
+
+
+ outp_sqlda1 = outp_sqlda;
+ rec = 0;
+ while (outp_sqlda1)
+ {
+ sqlda_t *ptr;
+ printf("FETCH RECORD %d\n", ++rec);
+ dump_sqlda(outp_sqlda1);
+
+ ptr = outp_sqlda1;
+ outp_sqlda1 = outp_sqlda1->desc_next;
+ free(ptr);
+ }
+
+ strcpy(msg, "close");
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+ #line 170 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 170 "sqlda.pgc"
+
+
+ strcpy(msg, "deallocate");
+ { ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 173 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 173 "sqlda.pgc"
+
+
+ /* SQLDA test for getting one record using an input descriptor */
+
+ /*
+ * Input sqlda has to be built manually
+ * sqlda_t contains 1 sqlvar_t structure already.
+ */
+ inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ memset(inp_sqlda, 0, sizeof(sqlda_t));
+ inp_sqlda->sqln = 1;
+
+ inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+ printf("EXECUTE RECORD 4\n");
+
+ id = 4;
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ { ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
+ #line 195 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 195 "sqlda.pgc"
+
+
+ strcpy(msg, "execute");
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "st_id3",
+ ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L,
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+ ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 198 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 198 "sqlda.pgc"
+
+
+ dump_sqlda(outp_sqlda);
+
+ strcpy(msg, "deallocate");
+ { ECPGdeallocate(__LINE__, 0, NULL, "st_id3");
+ #line 203 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 203 "sqlda.pgc"
+
+
+ free(inp_sqlda);
+ free(outp_sqlda);
+
+ /* SQLDA test for getting one record using an input descriptor
+ * on a named connection
+ */
+
+ { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "con2", 0);
+ #line 212 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 212 "sqlda.pgc"
+
+
+ /*
+ * Input sqlda has to be built manually
+ * sqlda_t contains 1 sqlvar_t structure already.
+ */
+ inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ memset(inp_sqlda, 0, sizeof(sqlda_t));
+ inp_sqlda->sqln = 1;
+
+ inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+ printf("EXECUTE RECORD 4\n");
+
+ id = 4;
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ { ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
+ #line 232 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 232 "sqlda.pgc"
+
+
+ strcpy(msg, "execute");
+ { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, "st_id4",
+ ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L,
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+ ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 235 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 235 "sqlda.pgc"
+
+
+ dump_sqlda(outp_sqlda);
+
+ strcpy(msg, "commit");
+ { ECPGtrans(__LINE__, "con2", "commit");
+ #line 240 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 240 "sqlda.pgc"
+
+
+ strcpy(msg, "deallocate");
+ { ECPGdeallocate(__LINE__, 0, NULL, "st_id4");
+ #line 243 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 243 "sqlda.pgc"
+
+
+ free(inp_sqlda);
+ free(outp_sqlda);
+
+ strcpy(msg, "disconnect");
+ { ECPGdisconnect(__LINE__, "con2");
+ #line 249 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 249 "sqlda.pgc"
+
+
+ /* End test */
+
+ strcpy(msg, "drop");
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 254 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 254 "sqlda.pgc"
+
+
+ strcpy(msg, "commit");
+ { ECPGtrans(__LINE__, NULL, "commit");
+ #line 257 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 257 "sqlda.pgc"
+
+
+ strcpy(msg, "disconnect");
+ { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 260 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 260 "sqlda.pgc"
+
+
+ return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stderr pgsql.2.1/src/interfaces/ecpg/test/expected/sql-sqlda.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stderr 1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/sql-sqlda.stderr 2010-01-04 18:18:46.000000000 +0100
***************
*** 0 ****
--- 1,594 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 88: query: create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 88: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 88: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 96: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '"c"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 96: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 96: OK: INSERT 0 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 103: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 110: name st_id1; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 124: no data found on line 124
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 133: query: close mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 133: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 133: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 136: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 145: name st_id2; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 151: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 151: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 151: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: query: fetch all from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: correctly got 4 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 3 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 3 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 3 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 3 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 3 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 2 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 2 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 2 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 2 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 2 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 1 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 1 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 1 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 1 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 1 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 170: query: close mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 170: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 170: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 173: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 195: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 198: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 198: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 198: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 198: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 198: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 203: name st_id3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 232: name st_id4; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 235: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection con2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 235: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 235: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 235: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 235: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 235: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 235: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 235: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 235: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 235: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 240: action "commit"; connection "con2"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 243: name st_id4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection con2 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 254: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 254: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 254: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 257: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stdout pgsql.2.1/src/interfaces/ecpg/test/expected/sql-sqlda.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stdout 1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/sql-sqlda.stdout 2010-01-01 14:35:36.000000000 +0100
***************
*** 0 ****
--- 1,60 ----
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value NUMERIC '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value NUMERIC '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd '
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value NUMERIC '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value NUMERIC '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd '
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/desc.pgc pgsql.2.1/src/interfaces/ecpg/test/sql/desc.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/desc.pgc 2007-08-14 12:01:54.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/test/sql/desc.pgc 2010-01-01 14:35:36.000000000 +0100
*************** main(void)
*** 32,61 ****
EXEC SQL PREPARE foo2 FROM :stmt2;
EXEC SQL PREPARE foo3 FROM :stmt3;
! EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2null, DATA = :val2;
! EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 3;
EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val1, DATA = 'this is a long test';
! EXEC SQL EXECUTE "Foo-1" USING DESCRIPTOR indesc;
EXEC SQL DEALLOCATE "Foo-1";
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1;
EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2i, DATA = :val2;
! EXEC SQL EXECUTE foo2 USING DESCRIPTOR indesc INTO DESCRIPTOR outdesc;
EXEC SQL GET DESCRIPTOR outdesc VALUE 1 :val2output = DATA;
printf("output = %s\n", val2output);
EXEC SQL DECLARE c1 CURSOR FOR foo2;
! EXEC SQL OPEN c1 USING DESCRIPTOR indesc;
EXEC SQL FETCH next FROM c1 INTO :val1output:ind1, :val2output:ind2;
printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
--- 32,61 ----
EXEC SQL PREPARE foo2 FROM :stmt2;
EXEC SQL PREPARE foo3 FROM :stmt3;
! EXEC SQL EXECUTE foo1 USING SQL DESCRIPTOR indesc;
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2null, DATA = :val2;
! EXEC SQL EXECUTE foo1 USING SQL DESCRIPTOR indesc;
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 3;
EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val1, DATA = 'this is a long test';
! EXEC SQL EXECUTE "Foo-1" USING SQL DESCRIPTOR indesc;
EXEC SQL DEALLOCATE "Foo-1";
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1;
EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2i, DATA = :val2;
! EXEC SQL EXECUTE foo2 USING SQL DESCRIPTOR indesc INTO SQL DESCRIPTOR outdesc;
EXEC SQL GET DESCRIPTOR outdesc VALUE 1 :val2output = DATA;
printf("output = %s\n", val2output);
EXEC SQL DECLARE c1 CURSOR FOR foo2;
! EXEC SQL OPEN c1 USING SQL DESCRIPTOR indesc;
EXEC SQL FETCH next FROM c1 INTO :val1output:ind1, :val2output:ind2;
printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
*************** main(void)
*** 67,73 ****
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
EXEC SQL DECLARE c2 CURSOR FOR foo3;
! EXEC SQL OPEN c2 USING DESCRIPTOR indesc;
EXEC SQL FETCH next FROM c2 INTO :val1output, :val2output :val2i;
printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
--- 67,73 ----
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
EXEC SQL DECLARE c2 CURSOR FOR foo3;
! EXEC SQL OPEN c2 USING SQL DESCRIPTOR indesc;
EXEC SQL FETCH next FROM c2 INTO :val1output, :val2output :val2i;
printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc2.pgc pgsql.2.1/src/interfaces/ecpg/test/sql/dynalloc2.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc2.pgc 2006-08-19 15:42:40.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/test/sql/dynalloc2.pgc 2010-01-01 14:35:36.000000000 +0100
*************** int main(void)
*** 30,36 ****
exec sql insert into test values (NULL, NULL);
exec sql allocate descriptor mydesc;
! exec sql select * into descriptor mydesc from test;
exec sql get descriptor mydesc :colnum=COUNT;
exec sql get descriptor mydesc value 1 :ip1=DATA, :ipointer1=INDICATOR;
exec sql get descriptor mydesc value 2 :cp2=DATA, :ipointer2=INDICATOR;
--- 30,36 ----
exec sql insert into test values (NULL, NULL);
exec sql allocate descriptor mydesc;
! exec sql select * into sql descriptor mydesc from test;
exec sql get descriptor mydesc :colnum=COUNT;
exec sql get descriptor mydesc value 1 :ip1=DATA, :ipointer1=INDICATOR;
exec sql get descriptor mydesc value 2 :cp2=DATA, :ipointer2=INDICATOR;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc.pgc pgsql.2.1/src/interfaces/ecpg/test/sql/dynalloc.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc.pgc 2006-08-19 15:42:40.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/test/sql/dynalloc.pgc 2010-01-01 14:35:36.000000000 +0100
*************** int main(void)
*** 39,45 ****
exec sql insert into test (b, c, d, e, f, g, h, i) values (2.446456, NULL, 'v', 'c', '2003-03-03 12:33:07 PDT', false, NULL, NULL);
exec sql allocate descriptor mydesc;
! exec sql select a,b,c,d,e,f,g,h,i into descriptor mydesc from test order by a;
exec sql get descriptor mydesc value 1 :d1=DATA, :i1=INDICATOR;
exec sql get descriptor mydesc value 2 :d2=DATA, :i2=INDICATOR;
exec sql get descriptor mydesc value 3 :d3=DATA, :i3=INDICATOR;
--- 39,45 ----
exec sql insert into test (b, c, d, e, f, g, h, i) values (2.446456, NULL, 'v', 'c', '2003-03-03 12:33:07 PDT', false, NULL, NULL);
exec sql allocate descriptor mydesc;
! exec sql select a,b,c,d,e,f,g,h,i into sql descriptor mydesc from test order by a;
exec sql get descriptor mydesc value 1 :d1=DATA, :i1=INDICATOR;
exec sql get descriptor mydesc value 2 :d2=DATA, :i2=INDICATOR;
exec sql get descriptor mydesc value 3 :d3=DATA, :i3=INDICATOR;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/Makefile pgsql.2.1/src/interfaces/ecpg/test/sql/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/sql/Makefile 2007-08-14 12:01:54.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/test/sql/Makefile 2010-01-01 14:35:36.000000000 +0100
*************** TESTS = array array.c \
*** 20,25 ****
--- 20,26 ----
parser parser.c \
quote quote.c \
show show.c \
+ sqlda sqlda.c \
insupd insupd.c
all: $(TESTS)
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/sqlda.pgc pgsql.2.1/src/interfaces/ecpg/test/sql/sqlda.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/sqlda.pgc 1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/sql/sqlda.pgc 2010-01-04 14:36:24.000000000 +0100
***************
*** 0 ****
--- 1,263 ----
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+
+ exec sql include ../regression;
+
+ exec sql include sqlda.h;
+ exec sql include pgtypes_numeric.h;
+
+ exec sql whenever sqlerror stop;
+
+ /* These shouldn't be under DECLARE SECTION */
+ sqlda_t *inp_sqlda, *outp_sqlda, *outp_sqlda1;
+
+ static void
+ dump_sqlda(sqlda_t *sqlda)
+ {
+ int i;
+
+ if (sqlda == NULL)
+ {
+ printf("dump_sqlda called with NULL sqlda\n");
+ return;
+ }
+
+ for (i = 0; i < sqlda->sqld; i++)
+ {
+ if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname.data);
+ else
+ switch (sqlda->sqlvar[i].sqltype)
+ {
+ case ECPGt_char:
+ printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname.data, sqlda->sqlvar[i].sqldata);
+ break;
+ case ECPGt_int:
+ printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname.data, *(int *)sqlda->sqlvar[i].sqldata);
+ break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ case ECPGt_long_long:
+ # else
+ # error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname.data, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ break;
+ case ECPGt_double:
+ printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname.data, *(double *)sqlda->sqlvar[i].sqldata);
+ break;
+ case ECPGt_numeric:
+ {
+ char *val;
+
+ val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname.data, val);
+ free(val);
+ break;
+ }
+ }
+ }
+ }
+
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ char *stmt1 = "SELECT * FROM t1";
+ char *stmt2 = "SELECT * FROM t1 WHERE id = ?";
+ int rec;
+ int id;
+ exec sql end declare section;
+
+ char msg[128];
+
+ ECPGdebug(1, stderr);
+
+ strcpy(msg, "connect");
+ exec sql connect to REGRESSDB1 as regress1;
+
+ strcpy(msg, "set");
+ exec sql set datestyle to iso;
+
+ strcpy(msg, "create");
+ exec sql create table t1(
+ id integer,
+ t text,
+ d1 numeric,
+ d2 float8,
+ c char(10));
+
+ strcpy(msg, "insert");
+ exec sql insert into t1 values
+ (1, 'a', 1.0, 1, 'a'),
+ (2, null, null, null, null),
+ (3, '"c"', -3, 'nan'::float8, 'c'),
+ (4, 'd', 4.0, 4, 'd');
+
+ strcpy(msg, "commit");
+ exec sql commit;
+
+ /* SQLDA test for getting all records from a table */
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ exec sql prepare st_id1 from :stmt1;
+
+ strcpy(msg, "declare");
+ exec sql declare mycur1 cursor for st_id1;
+
+ strcpy(msg, "open");
+ exec sql open mycur1;
+
+ exec sql whenever not found do break;
+
+ rec = 0;
+ while (1)
+ {
+ strcpy(msg, "fetch");
+ exec sql fetch 1 from mycur1 into descriptor outp_sqlda;
+
+ printf("FETCH RECORD %d\n", ++rec);
+ dump_sqlda(outp_sqlda);
+ }
+
+ exec sql whenever not found continue;
+
+ strcpy(msg, "close");
+ exec sql close mycur1;
+
+ strcpy(msg, "deallocate");
+ exec sql deallocate prepare st_id1;
+
+ free(outp_sqlda);
+
+ /* SQLDA test for getting ALL records into the sqlda list */
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ exec sql prepare st_id2 from :stmt1;
+
+ strcpy(msg, "declare");
+ exec sql declare mycur2 cursor for st_id2;
+
+ strcpy(msg, "open");
+ exec sql open mycur2;
+
+ strcpy(msg, "fetch");
+ exec sql fetch all from mycur2 into descriptor outp_sqlda;
+
+ outp_sqlda1 = outp_sqlda;
+ rec = 0;
+ while (outp_sqlda1)
+ {
+ sqlda_t *ptr;
+ printf("FETCH RECORD %d\n", ++rec);
+ dump_sqlda(outp_sqlda1);
+
+ ptr = outp_sqlda1;
+ outp_sqlda1 = outp_sqlda1->desc_next;
+ free(ptr);
+ }
+
+ strcpy(msg, "close");
+ exec sql close mycur2;
+
+ strcpy(msg, "deallocate");
+ exec sql deallocate prepare st_id2;
+
+ /* SQLDA test for getting one record using an input descriptor */
+
+ /*
+ * Input sqlda has to be built manually
+ * sqlda_t contains 1 sqlvar_t structure already.
+ */
+ inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ memset(inp_sqlda, 0, sizeof(sqlda_t));
+ inp_sqlda->sqln = 1;
+
+ inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+ printf("EXECUTE RECORD 4\n");
+
+ id = 4;
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ exec sql prepare st_id3 FROM :stmt2;
+
+ strcpy(msg, "execute");
+ exec sql execute st_id3 using descriptor inp_sqlda into descriptor outp_sqlda;
+
+ dump_sqlda(outp_sqlda);
+
+ strcpy(msg, "deallocate");
+ exec sql deallocate prepare st_id3;
+
+ free(inp_sqlda);
+ free(outp_sqlda);
+
+ /* SQLDA test for getting one record using an input descriptor
+ * on a named connection
+ */
+
+ exec sql connect to REGRESSDB1 as con2;
+
+ /*
+ * Input sqlda has to be built manually
+ * sqlda_t contains 1 sqlvar_t structure already.
+ */
+ inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ memset(inp_sqlda, 0, sizeof(sqlda_t));
+ inp_sqlda->sqln = 1;
+
+ inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+ printf("EXECUTE RECORD 4\n");
+
+ id = 4;
+
+ outp_sqlda = NULL;
+
+ strcpy(msg, "prepare");
+ exec sql at con2 prepare st_id4 FROM :stmt2;
+
+ strcpy(msg, "execute");
+ exec sql at con2 execute st_id4 using descriptor inp_sqlda into descriptor outp_sqlda;
+
+ dump_sqlda(outp_sqlda);
+
+ strcpy(msg, "commit");
+ exec sql at con2 commit;
+
+ strcpy(msg, "deallocate");
+ exec sql deallocate prepare st_id4;
+
+ free(inp_sqlda);
+ free(outp_sqlda);
+
+ strcpy(msg, "disconnect");
+ exec sql disconnect con2;
+
+ /* End test */
+
+ strcpy(msg, "drop");
+ exec sql drop table t1;
+
+ strcpy(msg, "commit");
+ exec sql commit;
+
+ strcpy(msg, "disconnect");
+ exec sql disconnect;
+
+ return (0);
+ }