Applied patch by Boszormenyi Zoltan <zb@cybertec.at> to add sqlda support to

ecpg in both native and compatiblity mode.
This commit is contained in:
Michael Meskes 2010-01-05 16:38:23 +00:00
parent af322a8a3e
commit 6d4a351fcb
32 changed files with 4026 additions and 39 deletions

View File

@ -5,7 +5,7 @@
# Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.65 2010/01/02 16:58:11 momjian Exp $
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.66 2010/01/05 16:38:23 meskes Exp $
#
#-------------------------------------------------------------------------
@ -24,7 +24,7 @@ override CFLAGS += $(PTHREAD_CFLAGS)
# 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 \
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))

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.87 2009/09/03 10:24:48 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.88 2010/01/05 16:38:23 meskes Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
@ -25,6 +25,8 @@
#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"
@ -1033,6 +1035,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
break;
case ECPGt_descriptor:
case ECPGt_sqlda:
break;
default:
@ -1172,6 +1175,120 @@ ecpg_execute(struct statement * stmt)
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))
@ -1353,6 +1470,111 @@ ecpg_execute(struct statement * stmt)
}
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++)
{

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.35 2009/05/20 16:13:18 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.36 2010/01/05 16:38:23 meskes Exp $ */
#ifndef _ECPG_LIB_EXTERN_H
#define _ECPG_LIB_EXTERN_H
@ -6,6 +6,8 @@
#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>
@ -129,6 +131,7 @@ bool ecpg_init(const struct connection *, const char *, const int);
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);
@ -149,6 +152,11 @@ void ecpg_log(const char *format,...);
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) */

View File

@ -0,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;
}
}

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.15 2009/08/07 10:51:20 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.16 2010/01/05 16:38:23 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@ -7,6 +7,7 @@
#include "ecpgtype.h"
#include "ecpglib.h"
#include "extern.h"
#include "sqltypes.h"
#include "sql3types.h"
#include "pg_type.h"
@ -100,3 +101,42 @@ ecpg_dynamic_type(Oid type)
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);
}
}

View File

@ -14,8 +14,9 @@ install: all installdirs install-headers
.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
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)/'

View File

@ -5,7 +5,7 @@
* All types that can be handled for host variable declarations has to
* be handled eventually.
*
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpgtype.h,v 1.38 2009/08/07 10:51:20 meskes Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpgtype.h,v 1.39 2010/01/05 16:38:23 meskes Exp $
*/
/*
@ -62,7 +62,8 @@ enum ECPGttype
ECPGt_EOIT, /* End of insert types. */
ECPGt_EORT, /* End of result types. */
ECPGt_NO_INDICATOR, /* no indicator */
ECPGt_string /* trimmed (char *) type */
ECPGt_string, /* trimmed (char *) type */
ECPGt_sqlda /* C struct descriptor */
};
/* descriptor items */

View File

@ -0,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 */

View File

@ -0,0 +1,35 @@
/*
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda-native.h,v 1.1 2010/01/05 16:38:23 meskes 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 */

View File

@ -1,3 +1,22 @@
/*
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.5 2010/01/05 16:38:23 meskes Exp $
*/
#ifndef ECPG_SQLDA_H
#define ECPG_SQLDA_H
#ifdef _ECPG_INFORMIX_H
#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 */

View File

@ -1,9 +1,11 @@
/*
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.9 2009/06/11 14:49:13 momjian Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.10 2010/01/05 16:38:23 meskes Exp $
*/
#ifndef ECPG_SQLTYPES_H
#define ECPG_SQLTYPES_H
#include <limits.h>
#define CCHARTYPE ECPGt_char
#define CSHORTTYPE ECPGt_short
#define CINTTYPE ECPGt_int
@ -30,4 +32,29 @@
#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
#ifdef HAVE_LONG_LONG_INT_64
#define SQLINT8 ECPGt_long_long
#define SQLSERIAL8 ECPGt_long_long
#else
#define SQLINT8 ECPGt_long
#define SQLSERIAL8 ECPGt_long
#endif
#endif /* ndef ECPG_SQLTYPES_H */

View File

@ -1,7 +1,7 @@
/*
* functions needed for descriptor handling
*
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.28 2009/01/23 12:43:32 petere Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.29 2010/01/05 16:38:23 meskes Exp $
*
* since descriptor might be either a string constant or a string var
* we need to check for a constant if we expect a constant
@ -326,3 +326,22 @@ descriptor_variable(const char *name, int input)
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;
}

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.12 2009/12/16 10:15:06 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.13 2010/01/05 16:38:23 meskes Exp $ */
ECPG: stmtClosePortalStmt block
{
if (INFORMIX_MODE)
@ -409,29 +409,29 @@ ECPG: VariableShowStmtSHOWALL block
$$ = EMPTY;
}
ECPG: FetchStmtMOVEfetch_args rule
| FETCH fetch_args ecpg_into
| FETCH fetch_args ecpg_fetch_into
{
$$ = cat2_str(make_str("fetch"), $2);
}
| FETCH FORWARD cursor_name opt_ecpg_into
| 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_into
| 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_into
| 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_into
| FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
{
char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
add_additional_variables($4, false);

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.16 2009/11/26 15:06:47 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.17 2010/01/05 16:38:23 meskes Exp $ */
statements: /*EMPTY*/
| statements statement
@ -970,21 +970,29 @@ ecpg_using: USING using_list { $$ = EMPTY; }
| using_descriptor { $$ = $1; }
;
using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
using_descriptor: USING SQL_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
| USING SQL_DESCRIPTOR name
{
add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
add_variable_to_head(&argsinsert, sqlda_variable($3), &no_indicator);
$$ = EMPTY;
}
;
opt_sql: /*EMPTY*/ | SQL_SQL;
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;
@ -1806,8 +1814,20 @@ ecpg_into: INTO into_list { $$ = EMPTY; }
| into_descriptor { $$ = $1; }
;
opt_ecpg_into: /* EMPTY */ { $$ = EMPTY; }
| ecpg_into { $$ = $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; }
;
%%

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.type,v 1.4 2009/11/26 15:06:47 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.type,v 1.5 2010/01/05 16:38:23 meskes Exp $ */
%type <str> ECPGAllocateDescr
%type <str> ECPGCKeywords
%type <str> ECPGColId
@ -61,6 +61,7 @@
%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,7 +77,7 @@
%type <str> opt_bit_field
%type <str> opt_connection_name
%type <str> opt_database_name
%type <str> opt_ecpg_into
%type <str> opt_ecpg_fetch_into
%type <str> opt_ecpg_using
%type <str> opt_initializer
%type <str> opt_options

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/extern.h,v 1.76 2009/11/26 15:06:47 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/extern.h,v 1.77 2010/01/05 16:38:23 meskes Exp $ */
#ifndef _ECPG_PREPROC_EXTERN_H
#define _ECPG_PREPROC_EXTERN_H
@ -88,6 +88,7 @@ extern void add_descriptor(char *, char *);
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);

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.85 2009/09/03 09:59:20 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.86 2010/01/05 16:38:23 meskes Exp $ */
#include "postgres_fe.h"
@ -194,6 +194,9 @@ get_type(enum ECPGttype type)
case ECPGt_descriptor:
return ("ECPGt_descriptor");
break;
case ECPGt_sqlda:
return ("ECPGt_sqlda");
break;
case ECPGt_date:
return ("ECPGt_date");
break;
@ -328,6 +331,8 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
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);

View File

@ -16,6 +16,7 @@ TESTS = test_informix test_informix.c \
rfmtdate rfmtdate.c \
rfmtlong rfmtlong.c \
rnull rnull.c \
sqlda sqlda.c \
charfuncs charfuncs.c
all: $(TESTS)
@ -26,6 +27,9 @@ test_informix.c: test_informix.pgc ../regression.h
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) $<

View File

@ -0,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);
}

View File

@ -3,6 +3,7 @@ test: compat_informix/charfuncs
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
@ -29,6 +30,7 @@ test: sql/code100
test: sql/copystdout
test: sql/define
test: sql/desc
test: sql/sqlda
test: sql/dynalloc
test: sql/dynalloc2
test: sql/dyntest

View File

@ -3,6 +3,7 @@ test: compat_informix/charfuncs
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
@ -29,6 +30,7 @@ test: sql/code100
test: sql/copystdout
test: sql/define
test: sql/desc
test: sql/sqlda
test: sql/dynalloc
test: sql/dynalloc2
test: sql/dyntest

View File

@ -0,0 +1,540 @@
/* 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 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/test/expected/compat_informix-sqlda.c,v 1.1 2010/01/05 16:38:23 meskes Exp $
*/
#ifndef ECPG_SQLDA_H
#define ECPG_SQLDA_H
#ifdef _ECPG_INFORMIX_H
#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/test/expected/compat_informix-sqlda.c,v 1.1 2010/01/05 16:38:23 meskes 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
#ifdef HAVE_LONG_LONG_INT_64
#define SQLINT8 ECPGt_long_long
#define SQLSERIAL8 ECPGt_long_long
#else
#define SQLINT8 ECPGt_long
#define SQLSERIAL8 ECPGt_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);
}

View File

@ -0,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

View File

@ -0,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 '

View File

@ -0,0 +1,544 @@
/* 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/test/expected/sql-sqlda.c,v 1.1 2010/01/05 16:38:23 meskes Exp $
*/
#ifndef ECPG_SQLDA_H
#define ECPG_SQLDA_H
#ifdef _ECPG_INFORMIX_H
#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/test/expected/sql-sqlda.c,v 1.1 2010/01/05 16:38:23 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;
#ifdef HAVE_LONG_LONG_INT_64
case ECPGt_long_long:
#else
case ECPGt_long:
#endif
printf("name sqlda descriptor: '%s' value " INT64_FORMAT "\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 67 "sqlda.pgc"
char * stmt1 = "SELECT * FROM t1" ;
#line 68 "sqlda.pgc"
char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
#line 69 "sqlda.pgc"
int rec ;
#line 70 "sqlda.pgc"
int id ;
/* exec sql end declare section */
#line 71 "sqlda.pgc"
char msg[128];
ECPGdebug(1, stderr);
strcpy(msg, "connect");
{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "regress1", 0);
#line 78 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 78 "sqlda.pgc"
strcpy(msg, "set");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
#line 81 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 81 "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 89 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 89 "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 96 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 96 "sqlda.pgc"
strcpy(msg, "commit");
{ ECPGtrans(__LINE__, NULL, "commit");
#line 99 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 99 "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 106 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 106 "sqlda.pgc"
strcpy(msg, "declare");
/* declare mycur1 cursor for $1 */
#line 109 "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 112 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 112 "sqlda.pgc"
/* exec sql whenever not found break ; */
#line 114 "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 120 "sqlda.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
#line 120 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 120 "sqlda.pgc"
printf("FETCH RECORD %d\n", ++rec);
dump_sqlda(outp_sqlda);
}
/* exec sql whenever not found continue ; */
#line 126 "sqlda.pgc"
strcpy(msg, "close");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
#line 129 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 129 "sqlda.pgc"
strcpy(msg, "deallocate");
{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
#line 132 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 132 "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 141 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 141 "sqlda.pgc"
strcpy(msg, "declare");
/* declare mycur2 cursor for $1 */
#line 144 "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 147 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 147 "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 150 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 150 "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 166 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 166 "sqlda.pgc"
strcpy(msg, "deallocate");
{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
#line 169 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 169 "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 191 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 191 "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 194 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 194 "sqlda.pgc"
dump_sqlda(outp_sqlda);
strcpy(msg, "deallocate");
{ ECPGdeallocate(__LINE__, 0, NULL, "st_id3");
#line 199 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 199 "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 208 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 208 "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 228 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 228 "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 231 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 231 "sqlda.pgc"
dump_sqlda(outp_sqlda);
strcpy(msg, "commit");
{ ECPGtrans(__LINE__, "con2", "commit");
#line 236 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 236 "sqlda.pgc"
strcpy(msg, "deallocate");
{ ECPGdeallocate(__LINE__, 0, NULL, "st_id4");
#line 239 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 239 "sqlda.pgc"
free(inp_sqlda);
free(outp_sqlda);
strcpy(msg, "disconnect");
{ ECPGdisconnect(__LINE__, "con2");
#line 245 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 245 "sqlda.pgc"
/* End test */
strcpy(msg, "drop");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
#line 250 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 250 "sqlda.pgc"
strcpy(msg, "commit");
{ ECPGtrans(__LINE__, NULL, "commit");
#line 253 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 253 "sqlda.pgc"
strcpy(msg, "disconnect");
{ ECPGdisconnect(__LINE__, "CURRENT");
#line 256 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 256 "sqlda.pgc"
return (0);
}

View File

@ -0,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 81: 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 81: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 81: OK: SET
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 84: 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 84: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 84: OK: CREATE TABLE
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 92: 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 92: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 92: OK: INSERT 0 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 99: action "commit"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGprepare on line 106: name st_id1; query: "SELECT * FROM t1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 112: 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 112: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 112: OK: DECLARE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 120: 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 120: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 120: 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 120: 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 120: 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 120: 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 120: 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 120: RESULT: a offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 120: putting result (1 tuple 5 fields) into sqlda descriptor
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 120: 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 120: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 120: 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 120: 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 120: 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 120: putting result (1 tuple 5 fields) into sqlda descriptor
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 120: 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 120: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 120: 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 120: 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 120: 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 120: 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 120: 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 120: RESULT: c offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 120: putting result (1 tuple 5 fields) into sqlda descriptor
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 120: 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 120: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 120: 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 120: 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 120: 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 120: 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 120: 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 120: RESULT: d offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 120: putting result (1 tuple 5 fields) into sqlda descriptor
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 120: 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 120: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 120: correctly got 0 tuples with 5 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: raising sqlcode 100 on line 120: no data found on line 120
[NO_PID]: sqlca: code: 100, state: 02000
[NO_PID]: ecpg_execute on line 129: query: close mycur1; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 129: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 129: OK: CLOSE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGdeallocate on line 132: name st_id1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGprepare on line 141: name st_id2; query: "SELECT * FROM t1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 147: 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 147: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 147: OK: DECLARE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 150: 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 150: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 150: 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 150: 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 150: 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 150: 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 150: 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 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]: 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 150: 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 150: 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 150: 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 150: 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 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]: 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 150: 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 150: 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 150: 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 150: 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 150: 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 150: 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 150: 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 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 166: query: close mycur2; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 166: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 166: OK: CLOSE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGdeallocate on line 169: name st_id2
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGprepare on line 191: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 194: 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 194: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: free_params on line 194: parameter 1 = 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 194: 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 194: 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 194: 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 194: 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 194: 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 194: RESULT: d offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 194: putting result (1 tuple 5 fields) into sqlda descriptor
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGdeallocate on line 199: 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 228: name st_id4; query: "SELECT * FROM t1 WHERE id = $1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 231: 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 231: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: free_params on line 231: parameter 1 = 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 231: 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 231: 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 231: 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 231: 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 231: 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 231: RESULT: d offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 231: putting result (1 tuple 5 fields) into sqlda descriptor
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 236: action "commit"; connection "con2"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGdeallocate on line 239: 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 250: query: drop table t1; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 250: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 250: OK: DROP TABLE
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 253: 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

View File

@ -0,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 '

View File

@ -20,6 +20,7 @@ TESTS = array array.c \
parser parser.c \
quote quote.c \
show show.c \
sqlda sqlda.c \
insupd insupd.c
all: $(TESTS)

View File

@ -32,30 +32,30 @@ main(void)
EXEC SQL PREPARE foo2 FROM :stmt2;
EXEC SQL PREPARE foo3 FROM :stmt3;
EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
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 DESCRIPTOR indesc;
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 DESCRIPTOR indesc;
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 DESCRIPTOR indesc INTO DESCRIPTOR outdesc;
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 DESCRIPTOR indesc;
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",
@ -67,7 +67,7 @@ main(void)
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 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);

View File

@ -39,7 +39,7 @@ int main(void)
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 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;

View File

@ -30,7 +30,7 @@ int main(void)
exec sql insert into test values (NULL, NULL);
exec sql allocate descriptor mydesc;
exec sql select * into descriptor mydesc from test;
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;

View File

@ -0,0 +1,259 @@
#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;
#ifdef HAVE_LONG_LONG_INT_64
case ECPGt_long_long:
#else
case ECPGt_long:
#endif
printf("name sqlda descriptor: '%s' value " INT64_FORMAT "\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);
}