2
0
mirror of https://git.postgresql.org/git/postgresql.git synced 2024-12-15 08:20:16 +08:00

Fixed array handling in ecpg.

When ecpg was rewritten to the new protocol version not all variable types
were corrected. This patch rewrites the code for these types to fix that. It
also fixes the documentation to correctly tell the status of array handling.
This commit is contained in:
Michael Meskes 2015-02-10 12:00:13 +01:00
parent 025c02420d
commit 1f393fc923
10 changed files with 564 additions and 484 deletions

View File

@ -1377,10 +1377,13 @@ EXEC SQL END DECLARE SECTION;
<title>Arrays</title>
<para>
SQL-level arrays are not directly supported in ECPG. It is not
possible to simply map an SQL array into a C array host variable.
This will result in undefined behavior. Some workarounds exist,
however.
Multi-dimensional SQL-level arrays are not directly supported in ECPG.
One-dimensional SQL-level arrays can be mapped into C array host
variables and vice-versa. However, when creating a statement ecpg does
not know the types of the columns, so that it cannot check if a C array
is input into a corresponding SQL-level array. When processing the
output of a SQL statement, ecpg has the necessary information and thus
checks if both are arrays.
</para>
<para>

View File

@ -291,6 +291,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
date ddres;
timestamp tres;
interval *ires;
char *endptr, endchar;
case ECPGt_short:
case ECPGt_int:
@ -564,10 +565,11 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_decimal:
case ECPGt_numeric:
if (isarray && *pval == '"')
nres = PGTYPESnumeric_from_asc(pval + 1, &scan_length);
else
nres = PGTYPESnumeric_from_asc(pval, &scan_length);
for (endptr = pval; *endptr && *endptr != ',' && *endptr != '}'; endptr++);
endchar = *endptr;
*endptr = '\0';
nres = PGTYPESnumeric_from_asc(pval, &scan_length);
*endptr = endchar;
/* did we get an error? */
if (nres == NULL)
@ -600,10 +602,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
else
{
if (isarray && *scan_length == '"')
scan_length++;
if (garbage_left(isarray, scan_length, compat))
if (!isarray && garbage_left(isarray, scan_length, compat))
{
free(nres);
ecpg_raise(lineno, ECPG_NUMERIC_FORMAT,
@ -622,10 +621,14 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break;
case ECPGt_interval:
if (isarray && *pval == '"')
ires = PGTYPESinterval_from_asc(pval + 1, &scan_length);
else
ires = PGTYPESinterval_from_asc(pval, &scan_length);
if (*pval == '"')
pval++;
for (endptr = pval; *endptr && *endptr != ',' && *endptr != '"' && *endptr != '}'; endptr++);
endchar = *endptr;
*endptr = '\0';
ires = PGTYPESinterval_from_asc(pval, &scan_length);
*endptr = endchar;
/* did we get an error? */
if (ires == NULL)
@ -654,10 +657,10 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
else
{
if (isarray && *scan_length == '"')
if (*scan_length == '"')
scan_length++;
if (garbage_left(isarray, scan_length, compat))
if (!isarray && garbage_left(isarray, scan_length, compat))
{
free(ires);
ecpg_raise(lineno, ECPG_INTERVAL_FORMAT,
@ -672,10 +675,14 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break;
case ECPGt_date:
if (isarray && *pval == '"')
ddres = PGTYPESdate_from_asc(pval + 1, &scan_length);
else
ddres = PGTYPESdate_from_asc(pval, &scan_length);
if (*pval == '"')
pval++;
for (endptr = pval; *endptr && *endptr != ',' && *endptr != '"' && *endptr != '}'; endptr++);
endchar = *endptr;
*endptr = '\0';
ddres = PGTYPESdate_from_asc(pval, &scan_length);
*endptr = endchar;
/* did we get an error? */
if (errno != 0)
@ -700,10 +707,10 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
else
{
if (isarray && *scan_length == '"')
if (*scan_length == '"')
scan_length++;
if (garbage_left(isarray, scan_length, compat))
if (!isarray && garbage_left(isarray, scan_length, compat))
{
ecpg_raise(lineno, ECPG_DATE_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
@ -716,10 +723,14 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break;
case ECPGt_timestamp:
if (isarray && *pval == '"')
tres = PGTYPEStimestamp_from_asc(pval + 1, &scan_length);
else
tres = PGTYPEStimestamp_from_asc(pval, &scan_length);
if (*pval == '"')
pval++;
for (endptr = pval; *endptr && *endptr != ',' && *endptr != '"' && *endptr != '}'; endptr++);
endchar = *endptr;
*endptr = '\0';
tres = PGTYPEStimestamp_from_asc(pval, &scan_length);
*endptr = endchar;
/* did we get an error? */
if (errno != 0)
@ -744,10 +755,10 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
else
{
if (isarray && *scan_length == '"')
if (*scan_length == '"')
scan_length++;
if (garbage_left(isarray, scan_length, compat))
if (!isarray && garbage_left(isarray, scan_length, compat))
{
ecpg_raise(lineno, ECPG_TIMESTAMP_FORMAT,
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);

View File

@ -499,16 +499,10 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
char *newcopy = NULL;
/*
* arrays are not possible unless the attribute is an array too FIXME: we
* do not know if the attribute is an array here
* arrays are not possible unless the column is an array, too
* FIXME: we do not know if the column is an array here
* array input to singleton column will result in a runtime error
*/
#if 0
if (var->arrsize > 1 &&...)
{
ecpg_raise(lineno, ECPG_ARRAY_INSERT, ECPG_SQLSTATE_DATATYPE_MISMATCH, NULL);
return false;
}
#endif
/*
* Some special treatment is needed for records since we want their
@ -566,12 +560,12 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
if (asize > 1)
{
strcpy(mallocedval, "array [");
strcpy(mallocedval, "{");
for (element = 0; element < asize; element++)
sprintf(mallocedval + strlen(mallocedval), "%hd,", ((short *) var->value)[element]);
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
}
else
sprintf(mallocedval, "%hd", *((short *) var->value));
@ -604,12 +598,12 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
if (asize > 1)
{
strcpy(mallocedval, "array [");
strcpy(mallocedval, "{");
for (element = 0; element < asize; element++)
sprintf(mallocedval + strlen(mallocedval), "%hu,", ((unsigned short *) var->value)[element]);
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
}
else
sprintf(mallocedval, "%hu", *((unsigned short *) var->value));
@ -623,12 +617,12 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
if (asize > 1)
{
strcpy(mallocedval, "array [");
strcpy(mallocedval, "{");
for (element = 0; element < asize; element++)
sprintf(mallocedval + strlen(mallocedval), "%u,", ((unsigned int *) var->value)[element]);
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
}
else
sprintf(mallocedval, "%u", *((unsigned int *) var->value));
@ -642,12 +636,12 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
if (asize > 1)
{
strcpy(mallocedval, "array [");
strcpy(mallocedval, "{");
for (element = 0; element < asize; element++)
sprintf(mallocedval + strlen(mallocedval), "%ld,", ((long *) var->value)[element]);
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
}
else
sprintf(mallocedval, "%ld", *((long *) var->value));
@ -661,12 +655,12 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
if (asize > 1)
{
strcpy(mallocedval, "array [");
strcpy(mallocedval, "{");
for (element = 0; element < asize; element++)
sprintf(mallocedval + strlen(mallocedval), "%lu,", ((unsigned long *) var->value)[element]);
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
}
else
sprintf(mallocedval, "%lu", *((unsigned long *) var->value));
@ -680,12 +674,12 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
if (asize > 1)
{
strcpy(mallocedval, "array [");
strcpy(mallocedval, "{");
for (element = 0; element < asize; element++)
sprintf(mallocedval + strlen(mallocedval), "%lld,", ((long long int *) var->value)[element]);
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
}
else
sprintf(mallocedval, "%lld", *((long long int *) var->value));
@ -699,12 +693,12 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
if (asize > 1)
{
strcpy(mallocedval, "array [");
strcpy(mallocedval, "{");
for (element = 0; element < asize; element++)
sprintf(mallocedval + strlen(mallocedval), "%llu,", ((unsigned long long int *) var->value)[element]);
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
}
else
sprintf(mallocedval, "%llu", *((unsigned long long int *) var->value));
@ -718,12 +712,12 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
if (asize > 1)
{
strcpy(mallocedval, "array [");
strcpy(mallocedval, "{");
for (element = 0; element < asize; element++)
sprintf_float_value(mallocedval + strlen(mallocedval), ((float *) var->value)[element], ",");
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
}
else
sprintf_float_value(mallocedval, *((float *) var->value), "");
@ -737,12 +731,12 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
if (asize > 1)
{
strcpy(mallocedval, "array [");
strcpy(mallocedval, "{");
for (element = 0; element < asize; element++)
sprintf_double_value(mallocedval + strlen(mallocedval), ((double *) var->value)[element], ",");
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
}
else
sprintf_double_value(mallocedval, *((double *) var->value), "");
@ -751,27 +745,27 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
break;
case ECPGt_bool:
if (!(mallocedval = ecpg_alloc(var->arrsize + sizeof("array []"), lineno)))
if (!(mallocedval = ecpg_alloc(var->arrsize + sizeof("{}"), lineno)))
return false;
if (var->arrsize > 1)
{
strcpy(mallocedval, "array [");
strcpy(mallocedval, "{");
if (var->offset == sizeof(char))
for (element = 0; element < var->arrsize; element++)
for (element = 0; element < asize; element++)
sprintf(mallocedval + strlen(mallocedval), "%c,", (((char *) var->value)[element]) ? 't' : 'f');
/*
* this is necessary since sizeof(C++'s bool)==sizeof(int)
*/
else if (var->offset == sizeof(int))
for (element = 0; element < var->arrsize; element++)
for (element = 0; element < asize; element++)
sprintf(mallocedval + strlen(mallocedval), "%c,", (((int *) var->value)[element]) ? 't' : 'f');
else
ecpg_raise(lineno, ECPG_CONVERT_BOOL, ECPG_SQLSTATE_DATATYPE_MISMATCH, NULL);
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
}
else
{
@ -853,67 +847,33 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
numeric *nval;
if (var->arrsize > 1)
{
if (!(mallocedval = ecpg_strdup("array [", lineno)))
mallocedval = ecpg_strdup("{", lineno);
else
mallocedval = ecpg_strdup("", lineno);
if (!mallocedval)
return false;
for (element = 0; element < var->arrsize; element++)
{
int result;
nval = PGTYPESnumeric_new();
if (!nval)
{
ecpg_free(mallocedval);
return false;
}
if (var->type == ECPGt_numeric)
result = PGTYPESnumeric_copy((numeric *) ((var + var->offset * element)->value), nval);
else
result = PGTYPESnumeric_from_decimal((decimal *) ((var + var->offset * element)->value), nval);
if (result != 0)
{
PGTYPESnumeric_free(nval);
ecpg_free(mallocedval);
return false;
}
str = PGTYPESnumeric_to_asc(nval, nval->dscale);
slen = strlen(str);
PGTYPESnumeric_free(nval);
if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
{
ecpg_free(mallocedval);
ecpg_free(str);
return false;
}
mallocedval = newcopy;
memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
}
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
}
else
for (element = 0; element < asize; element++)
{
int result;
nval = PGTYPESnumeric_new();
if (!nval)
{
ecpg_free(mallocedval);
return false;
}
if (var->type == ECPGt_numeric)
result = PGTYPESnumeric_copy((numeric *) (var->value), nval);
result = PGTYPESnumeric_copy(&(((numeric *) (var->value))[element]), nval);
else
result = PGTYPESnumeric_from_decimal((decimal *) (var->value), nval);
result = PGTYPESnumeric_from_decimal(&(((decimal *) (var->value))[element]), nval);
if (result != 0)
{
PGTYPESnumeric_free(nval);
ecpg_free(mallocedval);
return false;
}
@ -921,17 +881,25 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
slen = strlen(str);
PGTYPESnumeric_free(nval);
if (!(mallocedval = ecpg_alloc(slen + 1, lineno)))
if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
{
free(str);
ecpg_free(mallocedval);
ecpg_free(str);
return false;
}
mallocedval = newcopy;
/* also copy trailing '\0' */
memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
if (var->arrsize > 1)
strcpy(mallocedval + strlen(mallocedval), ",");
strncpy(mallocedval, str, slen);
mallocedval[slen] = '\0';
ecpg_free(str);
}
if (var->arrsize > 1)
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
*tobeinserted_p = mallocedval;
}
break;
@ -942,52 +910,43 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
int slen;
if (var->arrsize > 1)
{
if (!(mallocedval = ecpg_strdup("array [", lineno)))
return false;
for (element = 0; element < var->arrsize; element++)
{
str = quote_postgres(PGTYPESinterval_to_asc((interval *) ((var + var->offset * element)->value)), quote, lineno);
if (!str)
{
ecpg_free(mallocedval);
return false;
}
slen = strlen(str);
if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
{
ecpg_free(mallocedval);
ecpg_free(str);
return false;
}
mallocedval = newcopy;
memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
}
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
}
mallocedval = ecpg_strdup("{", lineno);
else
{
str = quote_postgres(PGTYPESinterval_to_asc((interval *) (var->value)), quote, lineno);
if (!str)
mallocedval = ecpg_strdup("", lineno);
if (!mallocedval)
return false;
for (element = 0; element < asize; element++)
{
str = quote_postgres(PGTYPESinterval_to_asc(&(((interval *) (var->value))[element])), quote, lineno);
if (!str)
{
ecpg_free(mallocedval);
return false;
}
slen = strlen(str);
if (!(mallocedval = ecpg_alloc(slen + sizeof("interval ") + 1, lineno)))
if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
{
ecpg_free(mallocedval);
ecpg_free(str);
return false;
}
mallocedval = newcopy;
/* also copy trailing '\0' */
memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
if (var->arrsize > 1)
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
}
if (var->arrsize > 1)
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
*tobeinserted_p = mallocedval;
}
break;
@ -998,52 +957,43 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
int slen;
if (var->arrsize > 1)
{
if (!(mallocedval = ecpg_strdup("array [", lineno)))
return false;
for (element = 0; element < var->arrsize; element++)
{
str = quote_postgres(PGTYPESdate_to_asc(*(date *) ((var + var->offset * element)->value)), quote, lineno);
if (!str)
{
ecpg_free(mallocedval);
return false;
}
slen = strlen(str);
if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
{
ecpg_free(mallocedval);
ecpg_free(str);
return false;
}
mallocedval = newcopy;
memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
}
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
}
mallocedval = ecpg_strdup("{", lineno);
else
{
str = quote_postgres(PGTYPESdate_to_asc(*(date *) (var->value)), quote, lineno);
if (!str)
mallocedval = ecpg_strdup("", lineno);
if (!mallocedval)
return false;
for (element = 0; element < asize; element++)
{
str = quote_postgres(PGTYPESdate_to_asc(((date *) (var->value))[element]), quote, lineno);
if (!str)
{
ecpg_free(mallocedval);
return false;
}
slen = strlen(str);
if (!(mallocedval = ecpg_alloc(slen + sizeof("date ") + 1, lineno)))
if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
{
ecpg_free(mallocedval);
ecpg_free(str);
return false;
}
mallocedval = newcopy;
/* also copy trailing '\0' */
memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
if (var->arrsize > 1)
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
}
if (var->arrsize > 1)
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
*tobeinserted_p = mallocedval;
}
break;
@ -1054,53 +1004,43 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
int slen;
if (var->arrsize > 1)
{
if (!(mallocedval = ecpg_strdup("array [", lineno)))
return false;
for (element = 0; element < var->arrsize; element++)
{
str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) ((var + var->offset * element)->value)), quote, lineno);
if (!str)
{
ecpg_free(mallocedval);
return false;
}
slen = strlen(str);
if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
{
ecpg_free(mallocedval);
ecpg_free(str);
return false;
}
mallocedval = newcopy;
memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
}
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
}
mallocedval = ecpg_strdup("{", lineno);
else
{
str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) (var->value)), quote, lineno);
if (!str)
mallocedval = ecpg_strdup("", lineno);
if (!mallocedval)
return false;
for (element = 0; element < asize; element++)
{
str = quote_postgres(PGTYPEStimestamp_to_asc(((timestamp *) (var->value))[element]), quote, lineno);
if (!str)
{
ecpg_free(mallocedval);
return false;
}
slen = strlen(str);
if (!(mallocedval = ecpg_alloc(slen + sizeof("timestamp") + 1, lineno)))
if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
{
ecpg_free(mallocedval);
ecpg_free(str);
return false;
}
mallocedval = newcopy;
/* also copy trailing '\0' */
memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
if (var->arrsize > 1)
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
}
if (var->arrsize > 1)
strcpy(mallocedval + strlen(mallocedval) - 1, "}");
*tobeinserted_p = mallocedval;
}
break;

View File

@ -11,8 +11,13 @@
#include <string.h>
#include <stdlib.h>
#include <pgtypes_date.h>
#include <pgtypes_interval.h>
#include <pgtypes_numeric.h>
#include <pgtypes_timestamp.h>
/* exec sql whenever sqlerror sqlprint ; */
#line 5 "array.pgc"
#line 10 "array.pgc"
@ -84,7 +89,7 @@ struct sqlca_t *ECPGget_sqlca(void);
#endif
#line 7 "array.pgc"
#line 12 "array.pgc"
#line 1 "regression.h"
@ -94,39 +99,55 @@ struct sqlca_t *ECPGget_sqlca(void);
#line 8 "array.pgc"
#line 13 "array.pgc"
int
main (void)
{
/* exec sql begin declare section */
#line 14 "array.pgc"
int i = 1 ;
#line 19 "array.pgc"
int i = 1 , j ;
#line 15 "array.pgc"
#line 20 "array.pgc"
int * did = & i ;
#line 16 "array.pgc"
int a [ 10 ] = { 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 } ;
#line 21 "array.pgc"
short a [ 10 ] = { 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 } ;
#line 17 "array.pgc"
#line 22 "array.pgc"
timestamp ts [ 10 ] ;
#line 23 "array.pgc"
date d [ 10 ] ;
#line 24 "array.pgc"
interval in [ 10 ] ;
#line 25 "array.pgc"
numeric n [ 10 ] ;
#line 26 "array.pgc"
char text [ 25 ] = "klmnopqrst" ;
#line 18 "array.pgc"
#line 27 "array.pgc"
char * t = ( char * ) malloc ( 11 ) ;
#line 19 "array.pgc"
#line 28 "array.pgc"
double f ;
/* exec sql end declare section */
#line 20 "array.pgc"
#line 29 "array.pgc"
strcpy(t, "0123456789");
@ -134,77 +155,124 @@ main (void)
ECPGdebug(1, stderr);
for (j = 0; j < 10; j++) {
char str[20];
numeric *value;
interval *inter;
sprintf(str, "2000-1-1 0%d:00:00", j);
ts[j] = PGTYPEStimestamp_from_asc(str, NULL);
sprintf(str, "2000-1-1%d\n", j);
d[j] = PGTYPESdate_from_asc(str, NULL);
sprintf(str, "%d hours", j+10);
inter = PGTYPESinterval_from_asc(str, NULL);
in[j] = *inter;
value = PGTYPESnumeric_new();
PGTYPESnumeric_from_int(j, value);
n[j] = *value;
}
{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0);
#line 27 "array.pgc"
#line 53 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 27 "array.pgc"
#line 53 "array.pgc"
{ ECPGsetcommit(__LINE__, "on", NULL);
#line 29 "array.pgc"
#line 55 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 29 "array.pgc"
#line 55 "array.pgc"
{ ECPGtrans(__LINE__, NULL, "begin work");
#line 31 "array.pgc"
#line 57 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 31 "array.pgc"
#line 57 "array.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( f float , i int , a int [ 10 ] , text char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
#line 33 "array.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( f float , i int , a int [ 10 ] , text char ( 10 ) , ts timestamp [ 10 ] , n numeric [ 10 ] , d date [ 10 ] , inter interval [ 10 ] )", ECPGt_EOIT, ECPGt_EORT);
#line 59 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 33 "array.pgc"
#line 59 "array.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' )", ECPGt_EOIT, ECPGt_EORT);
#line 35 "array.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' , $1 , $2 , $3 , $4 )",
ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 61 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 35 "array.pgc"
#line 61 "array.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text ) values ( 140787.0 , 2 , $1 , $2 )",
ECPGt_int,(a),(long)1,(long)10,sizeof(int),
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 140787.0 , 2 , $1 , $2 , $3 , $4 , $5 , $6 )",
ECPGt_short,(a),(long)1,(long)10,sizeof(short),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 37 "array.pgc"
#line 63 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 37 "array.pgc"
#line 63 "array.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text ) values ( 14.07 , $1 , $2 , $3 )",
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 14.07 , $1 , $2 , $3 , $4 , $5 , $6 , $7 )",
ECPGt_int,&(did),(long)1,(long)0,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_int,(a),(long)1,(long)10,sizeof(int),
ECPGt_short,(a),(long)1,(long)10,sizeof(short),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 39 "array.pgc"
#line 65 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 39 "array.pgc"
#line 65 "array.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");
#line 41 "array.pgc"
#line 67 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 41 "array.pgc"
#line 67 "array.pgc"
for (j = 0; j < 10; j++) {
ts[j] = PGTYPEStimestamp_from_asc("1900-01-01 00:00:00", NULL);
d[j] = PGTYPESdate_from_asc("1900-01-01", NULL);
in[j] = *PGTYPESinterval_new();
n[j] = *PGTYPESnumeric_new();
}
{ ECPGtrans(__LINE__, NULL, "begin work");
#line 43 "array.pgc"
#line 75 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 43 "array.pgc"
#line 75 "array.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select f , text from test where i = 1", ECPGt_EOIT,
@ -212,30 +280,38 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 48 "array.pgc"
#line 80 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 48 "array.pgc"
#line 80 "array.pgc"
printf("Found f=%f text=%10.10s\n", f, text);
f=140787;
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a , text from test where f = $1 ",
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a , text , ts , n , d , inter from test where f = $1 ",
ECPGt_double,&(f),(long)1,(long)1,sizeof(double),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
ECPGt_int,(a),(long)1,(long)10,sizeof(int),
ECPGt_short,(a),(long)1,(long)10,sizeof(short),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 56 "array.pgc"
#line 88 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 56 "array.pgc"
#line 88 "array.pgc"
for (i = 0; i < 10; i++)
printf("Found a[%d] = %d\n", i, a[i]);
printf("Found a[%d] = %d ts[%d] = %s n[%d] = %s d[%d] = %s in[%d] = %s\n", i, a[i], i, PGTYPEStimestamp_to_asc(ts[i]), i, PGTYPESnumeric_to_asc(&(n[i]), -1), i, PGTYPESdate_to_asc(d[i]), i, PGTYPESinterval_to_asc(&(in[i])));
printf("Found text=%10.10s\n", t);
@ -244,33 +320,33 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 66 "array.pgc"
#line 98 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 66 "array.pgc"
#line 98 "array.pgc"
printf("Found text=%s\n", text);
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);
#line 70 "array.pgc"
#line 102 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 70 "array.pgc"
#line 102 "array.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");
#line 72 "array.pgc"
#line 104 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 72 "array.pgc"
#line 104 "array.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
#line 74 "array.pgc"
#line 106 "array.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 74 "array.pgc"
#line 106 "array.pgc"
free(t);

View File

@ -2,89 +2,129 @@
[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]: ECPGsetcommit on line 29: action "on"; connection "regress1"
[NO_PID]: ECPGsetcommit on line 55: action "on"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 31: action "begin work"; connection "regress1"
[NO_PID]: ECPGtrans on line 57: action "begin work"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 33: query: create table test ( f float , i int , a int [ 10 ] , text char ( 10 ) ); with 0 parameter(s) on connection regress1
[NO_PID]: ecpg_execute on line 59: query: create table test ( f float , i int , a int [ 10 ] , text char ( 10 ) , ts timestamp [ 10 ] , n numeric [ 10 ] , d date [ 10 ] , inter interval [ 10 ] ); with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 33: using PQexec
[NO_PID]: ecpg_execute on line 59: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 33: OK: CREATE TABLE
[NO_PID]: ecpg_process_output on line 59: OK: CREATE TABLE
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 35: query: insert into test ( f , i , a , text ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' ); with 0 parameter(s) on connection regress1
[NO_PID]: ecpg_execute on line 61: query: insert into test ( f , i , a , text , ts , n , d , inter ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' , $1 , $2 , $3 , $4 ); with 4 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 35: using PQexec
[NO_PID]: ecpg_execute on line 61: using PQexecParams
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 35: OK: INSERT 0 1
[NO_PID]: ecpg_free_params on line 61: parameter 1 = {2000-01-01 00:00:00,2000-01-01 01:00:00,2000-01-01 02:00:00,2000-01-01 03:00:00,2000-01-01 04:00:00,2000-01-01 05:00:00,2000-01-01 06:00:00,2000-01-01 07:00:00,2000-01-01 08:00:00,2000-01-01 09:00:00}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 37: query: insert into test ( f , i , a , text ) values ( 140787.0 , 2 , $1 , $2 ); with 2 parameter(s) on connection regress1
[NO_PID]: ecpg_free_params on line 61: parameter 2 = {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 37: using PQexecParams
[NO_PID]: ecpg_free_params on line 61: parameter 3 = {2000-01-10,2000-01-11,2000-01-12,2000-01-13,2000-01-14,2000-01-15,2000-01-16,2000-01-17,2000-01-18,2000-01-19}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 37: parameter 1 = {9,8,7,6,5,4,3,2,1,0}
[NO_PID]: ecpg_free_params on line 61: parameter 4 = {@ 10 hours,@ 11 hours,@ 12 hours,@ 13 hours,@ 14 hours,@ 15 hours,@ 16 hours,@ 17 hours,@ 18 hours,@ 19 hours}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 37: parameter 2 = klmnopqrst
[NO_PID]: ecpg_process_output on line 61: OK: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 37: OK: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 39: query: insert into test ( f , i , a , text ) values ( 14.07 , $1 , $2 , $3 ); with 3 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 39: using PQexecParams
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 39: parameter 1 = 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 39: parameter 2 = {9,8,7,6,5,4,3,2,1,0}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 39: parameter 3 = 0123456789
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 39: OK: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 43: action "begin work"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 45: query: select f , text from test where i = 1; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 45: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 45: correctly got 1 tuples with 2 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 45: RESULT: 14.07 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 45: RESULT: 0123456789 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 53: query: select a , text from test where f = $1 ; with 1 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 53: using PQexecParams
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 53: parameter 1 = 140787
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 53: correctly got 1 tuples with 2 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_is_type_an_array on line 53: type (1007); C (5); array (yes)
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: {9,8,7,6,5,4,3,2,1,0} offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: klmnopqrst offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 63: query: select a from test where f = $1 ; with 1 parameter(s) on connection regress1
[NO_PID]: ecpg_execute on line 63: query: insert into test ( f , i , a , text , ts , n , d , inter ) values ( 140787.0 , 2 , $1 , $2 , $3 , $4 , $5 , $6 ); with 6 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 63: using PQexecParams
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 63: parameter 1 = 140787
[NO_PID]: ecpg_free_params on line 63: parameter 1 = {9,8,7,6,5,4,3,2,1,0}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 63: correctly got 1 tuples with 1 fields
[NO_PID]: ecpg_free_params on line 63: parameter 2 = klmnopqrst
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 63: RESULT: {9,8,7,6,5,4,3,2,1,0} offset: -1; array: yes
[NO_PID]: ecpg_free_params on line 63: parameter 3 = {2000-01-01 00:00:00,2000-01-01 01:00:00,2000-01-01 02:00:00,2000-01-01 03:00:00,2000-01-01 04:00:00,2000-01-01 05:00:00,2000-01-01 06:00:00,2000-01-01 07:00:00,2000-01-01 08:00:00,2000-01-01 09:00:00}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 70: query: drop table test; with 0 parameter(s) on connection regress1
[NO_PID]: ecpg_free_params on line 63: parameter 4 = {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 70: using PQexec
[NO_PID]: ecpg_free_params on line 63: parameter 5 = {2000-01-10,2000-01-11,2000-01-12,2000-01-13,2000-01-14,2000-01-15,2000-01-16,2000-01-17,2000-01-18,2000-01-19}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 70: OK: DROP TABLE
[NO_PID]: ecpg_free_params on line 63: parameter 6 = {@ 10 hours,@ 11 hours,@ 12 hours,@ 13 hours,@ 14 hours,@ 15 hours,@ 16 hours,@ 17 hours,@ 18 hours,@ 19 hours}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 72: action "commit"; connection "regress1"
[NO_PID]: ecpg_process_output on line 63: OK: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 65: query: insert into test ( f , i , a , text , ts , n , d , inter ) values ( 14.07 , $1 , $2 , $3 , $4 , $5 , $6 , $7 ); with 7 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 65: using PQexecParams
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 65: parameter 1 = 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 65: parameter 2 = {9,8,7,6,5,4,3,2,1,0}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 65: parameter 3 = 0123456789
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 65: parameter 4 = {2000-01-01 00:00:00,2000-01-01 01:00:00,2000-01-01 02:00:00,2000-01-01 03:00:00,2000-01-01 04:00:00,2000-01-01 05:00:00,2000-01-01 06:00:00,2000-01-01 07:00:00,2000-01-01 08:00:00,2000-01-01 09:00:00}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 65: parameter 5 = {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 65: parameter 6 = {2000-01-10,2000-01-11,2000-01-12,2000-01-13,2000-01-14,2000-01-15,2000-01-16,2000-01-17,2000-01-18,2000-01-19}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 65: parameter 7 = {@ 10 hours,@ 11 hours,@ 12 hours,@ 13 hours,@ 14 hours,@ 15 hours,@ 16 hours,@ 17 hours,@ 18 hours,@ 19 hours}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 65: OK: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 67: action "commit"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 75: action "begin work"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 77: query: select f , text from test where i = 1; 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_process_output on line 77: correctly got 1 tuples with 2 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 77: RESULT: 14.07 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 77: RESULT: 0123456789 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 85: query: select a , text , ts , n , d , inter from test where f = $1 ; with 1 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 85: using PQexecParams
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 85: parameter 1 = 140787
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 85: correctly got 1 tuples with 6 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_is_type_an_array on line 85: type (1007); C (3); array (yes)
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 85: RESULT: {9,8,7,6,5,4,3,2,1,0} offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 85: RESULT: klmnopqrst offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_is_type_an_array on line 85: type (1115); C (19); array (yes)
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 85: RESULT: {"Sat Jan 01 00:00:00 2000","Sat Jan 01 01:00:00 2000","Sat Jan 01 02:00:00 2000","Sat Jan 01 03:00:00 2000","Sat Jan 01 04:00:00 2000","Sat Jan 01 05:00:00 2000","Sat Jan 01 06:00:00 2000","Sat Jan 01 07:00:00 2000","Sat Jan 01 08:00:00 2000","Sat Jan 01 09:00:00 2000"} offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_is_type_an_array on line 85: type (1231); C (16); array (yes)
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 85: RESULT: {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0} offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_is_type_an_array on line 85: type (1182); C (18); array (yes)
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 85: RESULT: {01-10-2000,01-11-2000,01-12-2000,01-13-2000,01-14-2000,01-15-2000,01-16-2000,01-17-2000,01-18-2000,01-19-2000} offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_is_type_an_array on line 85: type (1187); C (20); array (yes)
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 85: RESULT: {"@ 10 hours","@ 11 hours","@ 12 hours","@ 13 hours","@ 14 hours","@ 15 hours","@ 16 hours","@ 17 hours","@ 18 hours","@ 19 hours"} offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 95: query: select a from test where f = $1 ; with 1 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 95: using PQexecParams
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 95: parameter 1 = 140787
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 95: correctly got 1 tuples with 1 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 95: RESULT: {9,8,7,6,5,4,3,2,1,0} offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 102: query: drop table test; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 102: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 102: OK: DROP TABLE
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 104: 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

@ -1,13 +1,13 @@
Found f=14.070000 text=0123456789
Found a[0] = 9
Found a[1] = 8
Found a[2] = 7
Found a[3] = 6
Found a[4] = 5
Found a[5] = 4
Found a[6] = 3
Found a[7] = 2
Found a[8] = 1
Found a[9] = 0
Found a[0] = 9 ts[0] = 2000-01-01 00:00:00 n[0] = 0.0 d[0] = 2000-01-10 in[0] = @ 10 hours
Found a[1] = 8 ts[1] = 2000-01-01 01:00:00 n[1] = 1.0 d[1] = 2000-01-11 in[1] = @ 11 hours
Found a[2] = 7 ts[2] = 2000-01-01 02:00:00 n[2] = 2.0 d[2] = 2000-01-12 in[2] = @ 12 hours
Found a[3] = 6 ts[3] = 2000-01-01 03:00:00 n[3] = 3.0 d[3] = 2000-01-13 in[3] = @ 13 hours
Found a[4] = 5 ts[4] = 2000-01-01 04:00:00 n[4] = 4.0 d[4] = 2000-01-14 in[4] = @ 14 hours
Found a[5] = 4 ts[5] = 2000-01-01 05:00:00 n[5] = 5.0 d[5] = 2000-01-15 in[5] = @ 15 hours
Found a[6] = 3 ts[6] = 2000-01-01 06:00:00 n[6] = 6.0 d[6] = 2000-01-16 in[6] = @ 16 hours
Found a[7] = 2 ts[7] = 2000-01-01 07:00:00 n[7] = 7.0 d[7] = 2000-01-17 in[7] = @ 17 hours
Found a[8] = 1 ts[8] = 2000-01-01 08:00:00 n[8] = 8.0 d[8] = 2000-01-18 in[8] = @ 18 hours
Found a[9] = 0 ts[9] = 2000-01-01 09:00:00 n[9] = 9.0 d[9] = 2000-01-19 in[9] = @ 19 hours
Found text=klmnopqrst
Found text={9,8,7,6,5,4,3,2,1,0}

View File

@ -64,89 +64,90 @@ main(void)
if (sqlca.sqlcode < 0) sqlprint();}
#line 24 "oldexec.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) )", ECPGt_EOIT, ECPGt_EORT);
#line 25 "oldexec.pgc"
#line 26 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 25 "oldexec.pgc"
#line 26 "oldexec.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");
#line 26 "oldexec.pgc"
#line 27 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 26 "oldexec.pgc"
#line 27 "oldexec.pgc"
sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f')");
{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_exec_immediate, command, ECPGt_EOIT, ECPGt_EORT);
#line 29 "oldexec.pgc"
#line 30 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 29 "oldexec.pgc"
#line 30 "oldexec.pgc"
sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')");
{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_exec_immediate, command, ECPGt_EOIT, ECPGt_EORT);
#line 32 "oldexec.pgc"
#line 33 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 32 "oldexec.pgc"
#line 33 "oldexec.pgc"
sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test");
{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_exec_immediate, command, ECPGt_EOIT, ECPGt_EORT);
#line 35 "oldexec.pgc"
#line 36 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 35 "oldexec.pgc"
#line 36 "oldexec.pgc"
printf("Inserted %ld tuples via execute immediate\n", sqlca.sqlerrd[2]);
sprintf(command, "insert into test (name, amount, letter) select name, amount+$1, letter from test");
{ ECPGprepare(__LINE__, NULL, 1, "i", command);
#line 40 "oldexec.pgc"
#line 41 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 40 "oldexec.pgc"
#line 41 "oldexec.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_execute, "i",
ECPGt_int,&(increment),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 41 "oldexec.pgc"
#line 42 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 41 "oldexec.pgc"
#line 42 "oldexec.pgc"
printf("Inserted %ld tuples via prepared execute\n", sqlca.sqlerrd[2]);
{ ECPGtrans(__LINE__, NULL, "commit");
#line 45 "oldexec.pgc"
#line 46 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 45 "oldexec.pgc"
#line 46 "oldexec.pgc"
sprintf (command, "select * from test");
{ ECPGprepare(__LINE__, NULL, 1, "f", command);
#line 49 "oldexec.pgc"
#line 50 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 49 "oldexec.pgc"
#line 50 "oldexec.pgc"
/* declare CUR cursor for $1 */
#line 50 "oldexec.pgc"
#line 51 "oldexec.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR cursor for $1",
ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 52 "oldexec.pgc"
#line 53 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 52 "oldexec.pgc"
#line 53 "oldexec.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT,
ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
@ -155,48 +156,38 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 53 "oldexec.pgc"
#line 54 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 53 "oldexec.pgc"
#line 54 "oldexec.pgc"
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
{
/* exec sql begin declare section */
#line 58 "oldexec.pgc"
char n [ 8 ] , l = letter [ i ] [ 0 ] ;
#line 59 "oldexec.pgc"
int a = amount [ i ] ;
/* exec sql end declare section */
#line 60 "oldexec.pgc"
char n[8], l = letter[i][0];
int a = amount[i];
strncpy(n, name[i], 8);
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
}
{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
#line 66 "oldexec.pgc"
#line 65 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 66 "oldexec.pgc"
#line 65 "oldexec.pgc"
sprintf (command, "select * from test where ? = amount");
{ ECPGprepare(__LINE__, NULL, 1, "f", command);
#line 70 "oldexec.pgc"
#line 69 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 70 "oldexec.pgc"
#line 69 "oldexec.pgc"
/* declare CUR3 cursor for $1 */
#line 71 "oldexec.pgc"
#line 70 "oldexec.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR3 cursor for $1",
@ -204,10 +195,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_const,"1",(long)1,(long)1,strlen("1"),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 73 "oldexec.pgc"
#line 72 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 73 "oldexec.pgc"
#line 72 "oldexec.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch in CUR3", ECPGt_EOIT,
ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
@ -216,54 +207,44 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 74 "oldexec.pgc"
#line 73 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 74 "oldexec.pgc"
#line 73 "oldexec.pgc"
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
{
/* exec sql begin declare section */
#line 79 "oldexec.pgc"
char n [ 8 ] , l = letter [ i ] [ 0 ] ;
#line 80 "oldexec.pgc"
int a = amount [ i ] ;
/* exec sql end declare section */
#line 81 "oldexec.pgc"
char n[8], l = letter[i][0];
int a = amount[i];
strncpy(n, name[i], 8);
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
}
{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR3", ECPGt_EOIT, ECPGt_EORT);
#line 87 "oldexec.pgc"
#line 84 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 87 "oldexec.pgc"
#line 84 "oldexec.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);
#line 88 "oldexec.pgc"
#line 85 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 88 "oldexec.pgc"
#line 85 "oldexec.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");
#line 89 "oldexec.pgc"
#line 86 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 89 "oldexec.pgc"
#line 86 "oldexec.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
#line 90 "oldexec.pgc"
#line 87 "oldexec.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 90 "oldexec.pgc"
#line 87 "oldexec.pgc"
return (0);

View File

@ -2,149 +2,149 @@
[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 25: query: create table test ( name char ( 8 ) , amount int , letter char ( 1 ) ); with 0 parameter(s) on connection main
[NO_PID]: ecpg_execute on line 26: query: create table test ( name char ( 8 ) , amount int , letter char ( 1 ) ); with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 25: using PQexec
[NO_PID]: ecpg_execute on line 26: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 25: OK: CREATE TABLE
[NO_PID]: ecpg_process_output on line 26: OK: CREATE TABLE
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 26: action "commit"; connection "main"
[NO_PID]: ECPGtrans on line 27: action "commit"; connection "main"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 29: query: insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f'); with 0 parameter(s) on connection main
[NO_PID]: ecpg_execute on line 30: query: insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f'); with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 29: using PQexec
[NO_PID]: ecpg_execute on line 30: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 29: OK: INSERT 0 1
[NO_PID]: ecpg_process_output on line 30: OK: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 32: query: insert into test (name, amount, letter) values ('db: ''r1''', 2, 't'); with 0 parameter(s) on connection main
[NO_PID]: ecpg_execute on line 33: query: insert into test (name, amount, letter) values ('db: ''r1''', 2, 't'); with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 32: using PQexec
[NO_PID]: ecpg_execute on line 33: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 32: OK: INSERT 0 1
[NO_PID]: ecpg_process_output on line 33: OK: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 35: query: insert into test (name, amount, letter) select name, amount+10, letter from test; with 0 parameter(s) on connection main
[NO_PID]: ecpg_execute on line 36: query: insert into test (name, amount, letter) select name, amount+10, letter from test; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 35: using PQexec
[NO_PID]: ecpg_execute on line 36: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 35: OK: INSERT 0 2
[NO_PID]: ecpg_process_output on line 36: OK: INSERT 0 2
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: prepare_common on line 40: name i; query: "insert into test (name, amount, letter) select name, amount+$1, letter from test"
[NO_PID]: prepare_common on line 41: name i; query: "insert into test (name, amount, letter) select name, amount+$1, letter from test"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 41: query: insert into test (name, amount, letter) select name, amount+$1, letter from test; with 1 parameter(s) on connection main
[NO_PID]: ecpg_execute on line 42: query: insert into test (name, amount, letter) select name, amount+$1, letter from test; with 1 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 41: using PQexecPrepared for "insert into test (name, amount, letter) select name, amount+$1, letter from test"
[NO_PID]: ecpg_execute on line 42: using PQexecPrepared for "insert into test (name, amount, letter) select name, amount+$1, letter from test"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 41: parameter 1 = 100
[NO_PID]: ecpg_free_params on line 42: parameter 1 = 100
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 41: OK: INSERT 0 4
[NO_PID]: ecpg_process_output on line 42: OK: INSERT 0 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 45: action "commit"; connection "main"
[NO_PID]: ECPGtrans on line 46: action "commit"; connection "main"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: prepare_common on line 49: name f; query: "select * from test"
[NO_PID]: prepare_common on line 50: name f; query: "select * from test"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 52: query: declare CUR cursor for select * from test; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 52: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 52: OK: DECLARE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 53: query: fetch 8 in CUR; with 0 parameter(s) on connection main
[NO_PID]: ecpg_execute on line 53: query: declare CUR cursor for select * from test; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 53: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 53: correctly got 8 tuples with 3 fields
[NO_PID]: ecpg_process_output on line 53: OK: DECLARE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: ecpg_execute on line 54: query: fetch 8 in CUR; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: ecpg_execute on line 54: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: ecpg_process_output on line 54: correctly got 8 tuples with 3 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: 1 offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: 11 offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: 12 offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: 1 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: 101 offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: 2 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: 102 offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: 11 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: 111 offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: 12 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: 112 offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: 101 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: f offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: 102 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: t offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: 111 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: f offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: 112 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: t offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: f offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: f offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: t offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: t offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: f offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: f offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: t offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 53: RESULT: t offset: -1; array: no
[NO_PID]: ecpg_get_data on line 54: RESULT: f offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 66: query: close CUR; with 0 parameter(s) on connection main
[NO_PID]: ecpg_get_data on line 54: RESULT: t offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 66: using PQexec
[NO_PID]: ecpg_get_data on line 54: RESULT: f offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 66: OK: CLOSE CURSOR
[NO_PID]: ecpg_get_data on line 54: RESULT: t offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: deallocate_one on line 70: name f
[NO_PID]: ecpg_execute on line 65: query: close CUR; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: prepare_common on line 70: name f; query: "select * from test where $1 = amount"
[NO_PID]: ecpg_execute on line 65: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 73: query: declare CUR3 cursor for select * from test where $1 = amount; with 1 parameter(s) on connection main
[NO_PID]: ecpg_process_output on line 65: OK: CLOSE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 73: using PQexecParams
[NO_PID]: deallocate_one on line 69: name f
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_free_params on line 73: parameter 1 = 1
[NO_PID]: prepare_common on line 69: name f; query: "select * from test where $1 = amount"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 73: OK: DECLARE CURSOR
[NO_PID]: ecpg_execute on line 72: query: declare CUR3 cursor for select * from test where $1 = amount; with 1 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 74: query: fetch in CUR3; with 0 parameter(s) on connection main
[NO_PID]: ecpg_execute on line 72: using PQexecParams
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 74: using PQexec
[NO_PID]: ecpg_free_params on line 72: parameter 1 = 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 74: correctly got 1 tuples with 3 fields
[NO_PID]: ecpg_process_output on line 72: OK: DECLARE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 74: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: ecpg_execute on line 73: query: fetch in CUR3; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 74: RESULT: 1 offset: -1; array: no
[NO_PID]: ecpg_execute on line 73: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 74: RESULT: f offset: -1; array: no
[NO_PID]: ecpg_process_output on line 73: correctly got 1 tuples with 3 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 87: query: close CUR3; with 0 parameter(s) on connection main
[NO_PID]: ecpg_get_data on line 73: RESULT: db: 'r1' offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 87: using PQexec
[NO_PID]: ecpg_get_data on line 73: RESULT: 1 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 87: OK: CLOSE CURSOR
[NO_PID]: ecpg_get_data on line 73: RESULT: f offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 88: query: drop table test; with 0 parameter(s) on connection main
[NO_PID]: ecpg_execute on line 84: query: close CUR3; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 88: using PQexec
[NO_PID]: ecpg_execute on line 84: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_process_output on line 88: OK: DROP TABLE
[NO_PID]: ecpg_process_output on line 84: OK: CLOSE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 89: action "commit"; connection "main"
[NO_PID]: ecpg_execute on line 85: query: drop table test; with 0 parameter(s) on connection main
[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_process_output on line 85: OK: DROP TABLE
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 86: action "commit"; connection "main"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: deallocate_one on line 0: name f
[NO_PID]: sqlca: code: 0, state: 00000

View File

@ -2,6 +2,11 @@
#include <string.h>
#include <stdlib.h>
#include <pgtypes_date.h>
#include <pgtypes_interval.h>
#include <pgtypes_numeric.h>
#include <pgtypes_timestamp.h>
exec sql whenever sqlerror sqlprint;
exec sql include sqlca;
@ -11,9 +16,13 @@ int
main (void)
{
EXEC SQL BEGIN DECLARE SECTION;
int i = 1;
int i = 1, j;
int *did = &i;
int a[10] = {9,8,7,6,5,4,3,2,1,0};
short a[10] = {9,8,7,6,5,4,3,2,1,0};
timestamp ts[10];
date d[10];
interval in[10];
numeric n[10];
char text[25] = "klmnopqrst";
char *t = (char *)malloc(11);
double f;
@ -24,22 +33,45 @@ EXEC SQL END DECLARE SECTION;
ECPGdebug(1, stderr);
for (j = 0; j < 10; j++) {
char str[20];
numeric *value;
interval *inter;
sprintf(str, "2000-1-1 0%d:00:00", j);
ts[j] = PGTYPEStimestamp_from_asc(str, NULL);
sprintf(str, "2000-1-1%d\n", j);
d[j] = PGTYPESdate_from_asc(str, NULL);
sprintf(str, "%d hours", j+10);
inter = PGTYPESinterval_from_asc(str, NULL);
in[j] = *inter;
value = PGTYPESnumeric_new();
PGTYPESnumeric_from_int(j, value);
n[j] = *value;
}
EXEC SQL CONNECT TO REGRESSDB1;
EXEC SQL SET AUTOCOMMIT = ON;
EXEC SQL BEGIN WORK;
EXEC SQL CREATE TABLE test (f float, i int, a int[10], text char(10));
EXEC SQL CREATE TABLE test (f float, i int, a int[10], text char(10), ts timestamp[10], n numeric[10], d date[10], inter interval[10]);
EXEC SQL INSERT INTO test(f,i,a,text) VALUES(404.90,3,'{0,1,2,3,4,5,6,7,8,9}','abcdefghij');
EXEC SQL INSERT INTO test(f,i,a,text,ts,n,d,inter) VALUES(404.90,3,'{0,1,2,3,4,5,6,7,8,9}','abcdefghij',:ts,:n,:d,:in);
EXEC SQL INSERT INTO test(f,i,a,text) VALUES(140787.0,2,:a,:text);
EXEC SQL INSERT INTO test(f,i,a,text,ts,n,d,inter) VALUES(140787.0,2,:a,:text,:ts,:n,:d,:in);
EXEC SQL INSERT INTO test(f,i,a,text) VALUES(14.07,:did,:a,:t);
EXEC SQL INSERT INTO test(f,i,a,text,ts,n,d,inter) VALUES(14.07,:did,:a,:t,:ts,:n,:d,:in);
EXEC SQL COMMIT;
for (j = 0; j < 10; j++) {
ts[j] = PGTYPEStimestamp_from_asc("1900-01-01 00:00:00", NULL);
d[j] = PGTYPESdate_from_asc("1900-01-01", NULL);
in[j] = *PGTYPESinterval_new();
n[j] = *PGTYPESnumeric_new();
}
EXEC SQL BEGIN WORK;
EXEC SQL SELECT f,text
@ -50,13 +82,13 @@ EXEC SQL END DECLARE SECTION;
printf("Found f=%f text=%10.10s\n", f, text);
f=140787;
EXEC SQL SELECT a,text
INTO :a,:t
EXEC SQL SELECT a,text,ts,n,d,inter
INTO :a,:t,:ts,:n,:d,:in
FROM test
WHERE f = :f;
for (i = 0; i < 10; i++)
printf("Found a[%d] = %d\n", i, a[i]);
printf("Found a[%d] = %d ts[%d] = %s n[%d] = %s d[%d] = %s in[%d] = %s\n", i, a[i], i, PGTYPEStimestamp_to_asc(ts[i]), i, PGTYPESnumeric_to_asc(&(n[i]), -1), i, PGTYPESdate_to_asc(d[i]), i, PGTYPESinterval_to_asc(&(in[i])));
printf("Found text=%10.10s\n", t);

View File

@ -22,6 +22,7 @@ exec sql end declare section;
ECPGdebug(1, stderr);
exec sql connect to REGRESSDB1 as main;
exec sql create table test (name char(8), amount int, letter char(1));
exec sql commit;
@ -54,10 +55,8 @@ exec sql end declare section;
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
{
exec sql begin declare section;
char n[8], l = letter[i][0];
int a = amount[i];
exec sql end declare section;
strncpy(n, name[i], 8);
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
@ -75,10 +74,8 @@ exec sql end declare section;
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
{
exec sql begin declare section;
char n[8], l = letter[i][0];
int a = amount[i];
exec sql end declare section;
strncpy(n, name[i], 8);
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);