Commit 9bade3ff authored by Michael Meskes's avatar Michael Meskes

Replaced double-quote-fix with a hopefully better version.

Use initializer string length as size for character strings.
Added ecpg_config.h file that is created via configure.
parent efdec1ac
This source diff could not be displayed because it is too large. You can view the blob instead.
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl $PostgreSQL: pgsql/configure.in,v 1.472 2006/08/17 17:25:43 petere Exp $ dnl $PostgreSQL: pgsql/configure.in,v 1.473 2006/08/23 12:01:52 meskes Exp $
dnl dnl
dnl Developers, please strive to achieve this order: dnl Developers, please strive to achieve this order:
dnl dnl
...@@ -1448,6 +1448,9 @@ AC_CONFIG_HEADERS([src/include/pg_config.h], ...@@ -1448,6 +1448,9 @@ AC_CONFIG_HEADERS([src/include/pg_config.h],
echo >src/include/stamp-h echo >src/include/stamp-h
]) ])
AC_CONFIG_HEADERS([src/interfaces/ecpg/include/ecpg_config.h])
# #
# Warn about unknown options # Warn about unknown options
# #
......
# -*-makefile-*- # -*-makefile-*-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.225 2006/07/24 16:32:44 petere Exp $ # $PostgreSQL: pgsql/src/Makefile.global.in,v 1.226 2006/08/23 12:01:52 meskes Exp $
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets, # All PostgreSQL makefiles include this file and use the variables it sets,
...@@ -488,6 +488,11 @@ $(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h ...@@ -488,6 +488,11 @@ $(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h
$(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status $(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status
cd $(top_builddir) && ./config.status src/include/pg_config.h cd $(top_builddir) && ./config.status src/include/pg_config.h
# Also remake ecpg_config.h from ecpg_config.h.in if the latter changed. Values in it can
# only change if pg_config.h has changed, so include this file to its dependencies.
$(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/include/pg_config.h $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h.in $(top_builddir)/config.status
cd $(top_builddir) && ./config.status src/interfaces/ecpg/include/ecpg_config.h
# When configure changes, rerun configure with the same options as # When configure changes, rerun configure with the same options as
# last time. To change configure, you need to run autoconf manually. # last time. To change configure, you need to run autoconf manually.
$(top_builddir)/config.status: $(top_srcdir)/configure $(top_builddir)/config.status: $(top_srcdir)/configure
......
...@@ -2110,5 +2110,11 @@ Sa 19. Aug 14:11:32 CEST 2006 ...@@ -2110,5 +2110,11 @@ Sa 19. Aug 14:11:32 CEST 2006
Tu 22. Aug 13:54:08 CEST 2006 Tu 22. Aug 13:54:08 CEST 2006
- Descriptor values were quoted twice. - Descriptor values were quoted twice.
We 23. Aug 09:32:14 CEST 2006
- Replaced double-quote-fix with a hopefully better version.
- Use initializer string length as size for character strings.
- Added ecpg_config.h file that is created via configure.
- Set ecpg library version to 5.2. - Set ecpg library version to 5.2.
- Set ecpg version to 4.2.1. - Set ecpg version to 4.2.1.
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.60 2006/08/22 12:46:17 meskes Exp $ */ /* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.61 2006/08/23 12:01:52 meskes Exp $ */
/* /*
* The aim is to get a simpler inteface to the database routines. * The aim is to get a simpler inteface to the database routines.
...@@ -36,47 +36,43 @@ ...@@ -36,47 +36,43 @@
* escaped. * escaped.
*/ */
static char * static char *
quote_postgres(char *arg, int lineno) quote_postgres(char *arg, bool quote, int lineno)
{ {
char *res = (char *) ECPGalloc(2 * strlen(arg) + 3, lineno); char *res;
int i, quoted = false, int i, ri = 0;
ri = 0;
if (!res)
return (res);
/* /* if quote is false we just need to store things in a descriptor
* We don't know if the target database is using * they will be quoted once they are inserted in a statement */
* standard_conforming_strings, so we always use E'' strings. if (!quote)
*/ return res = ECPGstrdup(arg, lineno);
if (strchr(arg, '\\') != NULL) else
res[ri++] = ESCAPE_STRING_SYNTAX;
i = 0;
res[ri++] = '\'';
/* do not quote the string if it is already quoted */
if (*arg == '\'' && arg[strlen(arg)-1] == '\'')
{ {
quoted = true; res = (char *) ECPGalloc(2 * strlen(arg) + 3, lineno);
i = 1; if (!res)
} return (res);
for (; arg[i]; i++, ri++) /*
{ * We don't know if the target database is using
if (SQL_STR_DOUBLE(arg[i], true)) * standard_conforming_strings, so we always use E'' strings.
res[ri++] = arg[i]; */
res[ri] = arg[i]; if (strchr(arg, '\\') != NULL)
} res[ri++] = ESCAPE_STRING_SYNTAX;
/* do not quote the string if it is already quoted */
if (quoted)
ri--;
else
res[ri++] = '\''; res[ri++] = '\'';
res[ri] = '\0'; for (i = 0; arg[i]; i++, ri++)
{
if (SQL_STR_DOUBLE(arg[i], true))
res[ri++] = arg[i];
res[ri] = arg[i];
}
res[ri++] = '\'';
res[ri] = '\0';
ECPGfree(arg); ECPGfree(arg);
return res; return res;
}
} }
#if defined(__GNUC__) && (defined (__powerpc__) || defined(__amd64__) || defined(__x86_64__)) #if defined(__GNUC__) && (defined (__powerpc__) || defined(__amd64__) || defined(__x86_64__))
...@@ -522,7 +518,7 @@ ECPGstore_result(const PGresult *results, int act_field, ...@@ -522,7 +518,7 @@ ECPGstore_result(const PGresult *results, int act_field,
bool bool
ECPGstore_input(const int lineno, const bool force_indicator, const struct variable * var, ECPGstore_input(const int lineno, const bool force_indicator, const struct variable * var,
const char **tobeinserted_p, bool *malloced_p) const char **tobeinserted_p, bool *malloced_p, bool quote)
{ {
char *mallocedval = NULL; char *mallocedval = NULL;
char *newcopy = NULL; char *newcopy = NULL;
...@@ -839,7 +835,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia ...@@ -839,7 +835,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
strncpy(newcopy, (char *) var->value, slen); strncpy(newcopy, (char *) var->value, slen);
newcopy[slen] = '\0'; newcopy[slen] = '\0';
mallocedval = quote_postgres(newcopy, lineno); mallocedval = quote_postgres(newcopy, quote, lineno);
if (!mallocedval) if (!mallocedval)
return false; return false;
...@@ -873,7 +869,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia ...@@ -873,7 +869,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
strncpy(newcopy, variable->arr, variable->len); strncpy(newcopy, variable->arr, variable->len);
newcopy[variable->len] = '\0'; newcopy[variable->len] = '\0';
mallocedval = quote_postgres(newcopy, lineno); mallocedval = quote_postgres(newcopy, quote, lineno);
if (!mallocedval) if (!mallocedval)
return false; return false;
...@@ -961,7 +957,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia ...@@ -961,7 +957,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
{ {
for (element = 0; element < var->arrsize; element++) for (element = 0; element < var->arrsize; element++)
{ {
str = quote_postgres(PGTYPESinterval_to_asc((interval *) ((var + var->offset * element)->value)), lineno); str = quote_postgres(PGTYPESinterval_to_asc((interval *) ((var + var->offset * element)->value)), quote, lineno);
if (!str) if (!str)
return false; return false;
slen = strlen(str); slen = strlen(str);
...@@ -984,7 +980,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia ...@@ -984,7 +980,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
} }
else else
{ {
str = quote_postgres(PGTYPESinterval_to_asc((interval *) (var->value)), lineno); str = quote_postgres(PGTYPESinterval_to_asc((interval *) (var->value)), quote, lineno);
if (!str) if (!str)
return false; return false;
slen = strlen(str); slen = strlen(str);
...@@ -1015,7 +1011,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia ...@@ -1015,7 +1011,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
{ {
for (element = 0; element < var->arrsize; element++) for (element = 0; element < var->arrsize; element++)
{ {
str = quote_postgres(PGTYPESdate_to_asc(*(date *) ((var + var->offset * element)->value)), lineno); str = quote_postgres(PGTYPESdate_to_asc(*(date *) ((var + var->offset * element)->value)), quote, lineno);
if (!str) if (!str)
return false; return false;
slen = strlen(str); slen = strlen(str);
...@@ -1038,7 +1034,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia ...@@ -1038,7 +1034,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
} }
else else
{ {
str = quote_postgres(PGTYPESdate_to_asc(*(date *) (var->value)), lineno); str = quote_postgres(PGTYPESdate_to_asc(*(date *) (var->value)), quote, lineno);
if (!str) if (!str)
return false; return false;
slen = strlen(str); slen = strlen(str);
...@@ -1069,7 +1065,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia ...@@ -1069,7 +1065,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
{ {
for (element = 0; element < var->arrsize; element++) for (element = 0; element < var->arrsize; element++)
{ {
str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) ((var + var->offset * element)->value)), lineno); str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) ((var + var->offset * element)->value)), quote, lineno);
if (!str) if (!str)
return false; return false;
...@@ -1093,7 +1089,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia ...@@ -1093,7 +1089,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
} }
else else
{ {
str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) (var->value)), lineno); str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) (var->value)), quote, lineno);
if (!str) if (!str)
return false; return false;
slen = strlen(str); slen = strlen(str);
...@@ -1212,7 +1208,7 @@ ECPGexecute(struct statement * stmt) ...@@ -1212,7 +1208,7 @@ ECPGexecute(struct statement * stmt)
desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1; desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
desc_inlist.ind_offset = 0; desc_inlist.ind_offset = 0;
} }
if (!ECPGstore_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, &malloced)) if (!ECPGstore_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, &malloced, true))
{ {
ECPGfree(copiedquery); ECPGfree(copiedquery);
return false; return false;
...@@ -1230,7 +1226,7 @@ ECPGexecute(struct statement * stmt) ...@@ -1230,7 +1226,7 @@ ECPGexecute(struct statement * stmt)
} }
else else
{ {
if (!ECPGstore_input(stmt->lineno, stmt->force_indicator, var, &tobeinserted, &malloced)) if (!ECPGstore_input(stmt->lineno, stmt->force_indicator, var, &tobeinserted, &malloced, true))
return false; return false;
} }
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.18 2006/08/04 03:23:37 momjian Exp $ */ /* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.19 2006/08/23 12:01:52 meskes Exp $ */
#ifndef _ECPG_LIB_EXTERN_H #ifndef _ECPG_LIB_EXTERN_H
#define _ECPG_LIB_EXTERN_H #define _ECPG_LIB_EXTERN_H
...@@ -129,7 +129,7 @@ PGresult **ECPGdescriptor_lvalue(int line, const char *descriptor); ...@@ -129,7 +129,7 @@ PGresult **ECPGdescriptor_lvalue(int line, const char *descriptor);
bool ECPGstore_result(const PGresult *results, int act_field, bool ECPGstore_result(const PGresult *results, int act_field,
const struct statement * stmt, struct variable * var); const struct statement * stmt, struct variable * var);
bool ECPGstore_input(const int, const bool, const struct variable *, const char **, bool *); bool ECPGstore_input(const int, const bool, const struct variable *, const char **, bool *, bool);
#if defined(__GNUC__) && (defined (__powerpc__) || defined(__amd64__) || defined(__x86_64__)) #if defined(__GNUC__) && (defined (__powerpc__) || defined(__amd64__) || defined(__x86_64__))
/* work around a gcc/ABI bug with va_lists on ppc+amd64 */ /* work around a gcc/ABI bug with va_lists on ppc+amd64 */
......
...@@ -24,3 +24,7 @@ installdirs: ...@@ -24,3 +24,7 @@ installdirs:
uninstall: uninstall:
rm -f $(addprefix '$(DESTDIR)$(includedir)'/, $(ecpg_headers)) rm -f $(addprefix '$(DESTDIR)$(includedir)'/, $(ecpg_headers))
rm -f $(addprefix '$(DESTDIR)$(informix_esql_dir)'/, $(informix_headers)) rm -f $(addprefix '$(DESTDIR)$(informix_esql_dir)'/, $(informix_headers))
distclean maintainer-clean:
rm -f ecpg_config.h
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_interval.h,v 1.9 2006/03/11 04:38:39 momjian Exp $ */ /* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_interval.h,v 1.10 2006/08/23 12:01:52 meskes Exp $ */
#ifndef PGTYPES_INTERVAL #ifndef PGTYPES_INTERVAL
#define PGTYPES_INTERVAL #define PGTYPES_INTERVAL
#include <ecpg_config.h>
#if defined(USE_INTEGER_DATETIMES) && (defined(HAVE_LONG_INT_64) || defined(HAVE_LONG_LONG_INT_64))
#define HAVE_INT64_TIMESTAMP
#endif
typedef struct typedef struct
{ {
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_timestamp.h,v 1.10 2006/03/11 04:38:39 momjian Exp $ */ /* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_timestamp.h,v 1.11 2006/08/23 12:01:52 meskes Exp $ */
#ifndef PGTYPES_TIMESTAMP #ifndef PGTYPES_TIMESTAMP
#define PGTYPES_TIMESTAMP #define PGTYPES_TIMESTAMP
/* pgtypes_interval.h includes ecpg_config.h */
#include <pgtypes_interval.h> #include <pgtypes_interval.h>
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.329 2006/08/18 15:59:35 meskes Exp $ */ /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.330 2006/08/23 12:01:52 meskes Exp $ */
/* Copyright comment */ /* Copyright comment */
%{ %{
...@@ -5414,7 +5414,18 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize ...@@ -5414,7 +5414,18 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize
case ECPGt_char: case ECPGt_char:
case ECPGt_unsigned_char: case ECPGt_unsigned_char:
if (atoi(dimension) == -1) if (atoi(dimension) == -1)
{
int i = strlen($5);
if (atoi(length) == -1 && i > 0) /* char <var>[] = "string" */
{
/* if we have an initializer but no string size set, let's use the initializer's length */
free(length);
length = mm_alloc(i+sizeof("sizeof()"));
sprintf(length, "sizeof(%s)+1", $5+2);
}
type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length); type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length);
}
else else
type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length), dimension); type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length), dimension);
......
...@@ -101,21 +101,6 @@ main(void) ...@@ -101,21 +101,6 @@ main(void)
r = dectodbl(dec, &dbl); r = dectodbl(dec, &dbl);
if (r) check_errno(); if (r) check_errno();
printf("dec[%d,10]: %2.7f (r: %d)\n", i, r?0.0:dbl, r); printf("dec[%d,10]: %2.7f (r: %d)\n", i, r?0.0:dbl, r);
if (r == 0)
{
r = deccvdbl(dbl, din);
if (r)
{
check_errno();
printf("dec[%d,11(f)]: - (r: %d)\n", i, r);
}
else
{
dectoasc(din, buf, BUFSIZE-1, 2);
q = deccmp(dec, din);
printf("dec[%d,11]: %s (r: %d - cmp: %d)\n", i, buf, r, q);
}
}
PGTYPESdecimal_free(din); PGTYPESdecimal_free(din);
printf("\n"); printf("\n");
......
...@@ -121,21 +121,6 @@ main(void) ...@@ -121,21 +121,6 @@ main(void)
r = dectodbl(dec, &dbl); r = dectodbl(dec, &dbl);
if (r) check_errno(); if (r) check_errno();
printf("dec[%d,10]: %2.7f (r: %d)\n", i, r?0.0:dbl, r); printf("dec[%d,10]: %2.7f (r: %d)\n", i, r?0.0:dbl, r);
if (r == 0)
{
r = deccvdbl(dbl, din);
if (r)
{
check_errno();
printf("dec[%d,11(f)]: - (r: %d)\n", i, r);
}
else
{
dectoasc(din, buf, BUFSIZE-1, 2);
q = deccmp(dec, din);
printf("dec[%d,11]: %s (r: %d - cmp: %d)\n", i, buf, r, q);
}
}
PGTYPESdecimal_free(din); PGTYPESdecimal_free(din);
printf("\n"); printf("\n");
......
...@@ -17,7 +17,6 @@ dec[1,7]: -2.00 (r: 0 - cmp: 0) ...@@ -17,7 +17,6 @@ dec[1,7]: -2.00 (r: 0 - cmp: 0)
dec[1,8]: -2 (r: 0) dec[1,8]: -2 (r: 0)
dec[1,9]: -2.00 (r: 0 - cmp: 0) dec[1,9]: -2.00 (r: 0 - cmp: 0)
dec[1,10]: -2.0000000 (r: 0) dec[1,10]: -2.0000000 (r: 0)
dec[1,11]: -2.00 (r: 0 - cmp: 0)
dec[2,1]: r: 0, 0.794 dec[2,1]: r: 0, 0.794
dec[2,2]: r: 0, 1 dec[2,2]: r: 0, 1
...@@ -29,7 +28,6 @@ dec[2,7]: 1.00 (r: 0 - cmp: -1) ...@@ -29,7 +28,6 @@ dec[2,7]: 1.00 (r: 0 - cmp: -1)
dec[2,8]: 1 (r: 0) dec[2,8]: 1 (r: 0)
dec[2,9]: 1.00 (r: 0 - cmp: -1) dec[2,9]: 1.00 (r: 0 - cmp: -1)
dec[2,10]: 0.7940000 (r: 0) dec[2,10]: 0.7940000 (r: 0)
dec[2,11]: 0.79 (r: 0 - cmp: 0)
dec[3,1]: r: 0, 3.44 dec[3,1]: r: 0, 3.44
dec[3,2]: r: 0, 3 dec[3,2]: r: 0, 3
...@@ -41,7 +39,6 @@ dec[3,7]: 3.00 (r: 0 - cmp: 1) ...@@ -41,7 +39,6 @@ dec[3,7]: 3.00 (r: 0 - cmp: 1)
dec[3,8]: 3 (r: 0) dec[3,8]: 3 (r: 0)
dec[3,9]: 3.00 (r: 0 - cmp: 1) dec[3,9]: 3.00 (r: 0 - cmp: 1)
dec[3,10]: 3.4400000 (r: 0) dec[3,10]: 3.4400000 (r: 0)
dec[3,11]: 3.44 (r: 0 - cmp: 0)
dec[4,1]: r: 0, 592490000000000000000000 dec[4,1]: r: 0, 592490000000000000000000
dec[4,2]: r: 0, 592490000000000000000000 dec[4,2]: r: 0, 592490000000000000000000
...@@ -51,7 +48,6 @@ dec[4,5]: r: 0, 0.00 ...@@ -51,7 +48,6 @@ dec[4,5]: r: 0, 0.00
(errno == PGTYPES_NUM_OVERFLOW) - dec[4,6]: 0 (r: -1) (errno == PGTYPES_NUM_OVERFLOW) - dec[4,6]: 0 (r: -1)
(errno == PGTYPES_NUM_OVERFLOW) - dec[4,8]: 0 (r: -1) (errno == PGTYPES_NUM_OVERFLOW) - dec[4,8]: 0 (r: -1)
dec[4,10]: 592490000000000009961472.0000000 (r: 0) dec[4,10]: 592490000000000009961472.0000000 (r: 0)
dec[4,11]: 592490000000000009961472.00 (r: 0 - cmp: -1)
dec[5,1]: r: 0, -328400 dec[5,1]: r: 0, -328400
dec[5,2]: r: 0, -328400 dec[5,2]: r: 0, -328400
...@@ -63,7 +59,6 @@ dec[5,7]: -328400.00 (r: 0 - cmp: 0) ...@@ -63,7 +59,6 @@ dec[5,7]: -328400.00 (r: 0 - cmp: 0)
dec[5,8]: -328400 (r: 0) dec[5,8]: -328400 (r: 0)
dec[5,9]: -328400.00 (r: 0 - cmp: 0) dec[5,9]: -328400.00 (r: 0 - cmp: 0)
dec[5,10]: -328400.0000000 (r: 0) dec[5,10]: -328400.0000000 (r: 0)
dec[5,11]: -328400.00 (r: 0 - cmp: 0)
(no errno set) - dec[6,1]: r: -1, * (no errno set) - dec[6,1]: r: -1, *
dec[6,2]: r: 0, 0 dec[6,2]: r: 0, 0
...@@ -86,7 +81,6 @@ dec[7,7]: 0.00 (r: 0 - cmp: 1) ...@@ -86,7 +81,6 @@ dec[7,7]: 0.00 (r: 0 - cmp: 1)
dec[7,8]: 0 (r: 0) dec[7,8]: 0 (r: 0)
dec[7,9]: 0.00 (r: 0 - cmp: 1) dec[7,9]: 0.00 (r: 0 - cmp: 1)
dec[7,10]: 0.0010000 (r: 0) dec[7,10]: 0.0010000 (r: 0)
dec[7,11]: 0.00 (r: 0 - cmp: 0)
dec[8,1]: r: 0, 0.0 dec[8,1]: r: 0, 0.0
dec[8,2]: r: 0, 0 dec[8,2]: r: 0, 0
...@@ -98,7 +92,6 @@ dec[8,7]: 0.00 (r: 0 - cmp: 0) ...@@ -98,7 +92,6 @@ dec[8,7]: 0.00 (r: 0 - cmp: 0)
dec[8,8]: 0 (r: 0) dec[8,8]: 0 (r: 0)
dec[8,9]: 0.00 (r: 0 - cmp: 0) dec[8,9]: 0.00 (r: 0 - cmp: 0)
dec[8,10]: 0.0000000 (r: 0) dec[8,10]: 0.0000000 (r: 0)
dec[8,11]: 0.00 (r: 0 - cmp: 0)
dec[9,1]: r: 0, -0.000059249 dec[9,1]: r: 0, -0.000059249
dec[9,2]: r: 0, -0 dec[9,2]: r: 0, -0
...@@ -110,7 +103,6 @@ dec[9,7]: 0.00 (r: 0 - cmp: -1) ...@@ -110,7 +103,6 @@ dec[9,7]: 0.00 (r: 0 - cmp: -1)
dec[9,8]: 0 (r: 0) dec[9,8]: 0 (r: 0)
dec[9,9]: 0.00 (r: 0 - cmp: -1) dec[9,9]: 0.00 (r: 0 - cmp: -1)
dec[9,10]: -0.0000592 (r: 0) dec[9,10]: -0.0000592 (r: 0)
dec[9,11]: -0.00 (r: 0 - cmp: -1)
dec[10,1]: r: 0, 0.003284 dec[10,1]: r: 0, 0.003284
dec[10,2]: r: 0, 0 dec[10,2]: r: 0, 0
...@@ -122,7 +114,6 @@ dec[10,7]: 0.00 (r: 0 - cmp: 1) ...@@ -122,7 +114,6 @@ dec[10,7]: 0.00 (r: 0 - cmp: 1)
dec[10,8]: 0 (r: 0) dec[10,8]: 0 (r: 0)
dec[10,9]: 0.00 (r: 0 - cmp: 1) dec[10,9]: 0.00 (r: 0 - cmp: 1)
dec[10,10]: 0.0032840 (r: 0) dec[10,10]: 0.0032840 (r: 0)
dec[10,11]: 0.00 (r: 0 - cmp: 0)
dec[11,1]: r: 0, 0.500001 dec[11,1]: r: 0, 0.500001
dec[11,2]: r: 0, 1 dec[11,2]: r: 0, 1
...@@ -134,7 +125,6 @@ dec[11,7]: 1.00 (r: 0 - cmp: -1) ...@@ -134,7 +125,6 @@ dec[11,7]: 1.00 (r: 0 - cmp: -1)
dec[11,8]: 1 (r: 0) dec[11,8]: 1 (r: 0)
dec[11,9]: 1.00 (r: 0 - cmp: -1) dec[11,9]: 1.00 (r: 0 - cmp: -1)
dec[11,10]: 0.5000010 (r: 0) dec[11,10]: 0.5000010 (r: 0)
dec[11,11]: 0.50 (r: 0 - cmp: 0)
dec[12,1]: r: 0, -0.5000001 dec[12,1]: r: 0, -0.5000001
dec[12,2]: r: 0, -1 dec[12,2]: r: 0, -1
...@@ -146,7 +136,6 @@ dec[12,7]: -1.00 (r: 0 - cmp: 1) ...@@ -146,7 +136,6 @@ dec[12,7]: -1.00 (r: 0 - cmp: 1)
dec[12,8]: -1 (r: 0) dec[12,8]: -1 (r: 0)
dec[12,9]: -1.00 (r: 0 - cmp: 1) dec[12,9]: -1.00 (r: 0 - cmp: 1)
dec[12,10]: -0.5000001 (r: 0) dec[12,10]: -0.5000001 (r: 0)
dec[12,11]: -0.50 (r: 0 - cmp: -1)
dec[13,1]: r: 0, 1234567890123456789012345678.91 dec[13,1]: r: 0, 1234567890123456789012345678.91
dec[13,2]: r: 0, 1234567890123456789012345679 dec[13,2]: r: 0, 1234567890123456789012345679
...@@ -156,7 +145,6 @@ dec[13,5]: r: 0, 0.00 ...@@ -156,7 +145,6 @@ dec[13,5]: r: 0, 0.00
(errno == PGTYPES_NUM_OVERFLOW) - dec[13,6]: 0 (r: -1) (errno == PGTYPES_NUM_OVERFLOW) - dec[13,6]: 0 (r: -1)
(errno == PGTYPES_NUM_OVERFLOW) - dec[13,8]: 0 (r: -1) (errno == PGTYPES_NUM_OVERFLOW) - dec[13,8]: 0 (r: -1)
dec[13,10]: 1234567890123456850245451776.0000000 (r: 0) dec[13,10]: 1234567890123456850245451776.0000000 (r: 0)
(errno == PGTYPES_NUM_OVERFLOW) - dec[13,11(f)]: - (r: -1)
(errno == PGTYPES_NUM_OVERFLOW) - dec[14,0]: r: -1200 (errno == PGTYPES_NUM_OVERFLOW) - dec[14,0]: r: -1200
(errno == PGTYPES_NUM_BAD_NUMERIC) - dec[15,0]: r: -1213 (errno == PGTYPES_NUM_BAD_NUMERIC) - dec[15,0]: r: -1213
......
...@@ -119,7 +119,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} ...@@ -119,7 +119,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
{ ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl ) values( 1 , ? , ? , ? , ? , ? , ? , ? ) ", { ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl ) values( 1 , ? , ? , ? , ? , ? , ? , ? ) ",
ECPGt_char,&(c),(long)-1,(long)1,(-1)*sizeof(char), ECPGt_char,(c),(long)sizeof("abc ")+1,(long)1,(sizeof("abc ")+1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_short,&(s),(long)1,(long)1,sizeof(short), ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
...@@ -157,7 +157,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} ...@@ -157,7 +157,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
rsetnull(CDTIMETYPE, (char *) &tmp); rsetnull(CDTIMETYPE, (char *) &tmp);
{ ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl , dec , dat , tmp ) values( 2 , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ", { ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl , dec , dat , tmp ) values( 2 , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ",
ECPGt_char,&(c),(long)-1,(long)1,(-1)*sizeof(char), ECPGt_char,(c),(long)sizeof("abc ")+1,(long)1,(sizeof("abc ")+1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_short,&(s),(long)1,(long)1,sizeof(short), ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
...@@ -192,7 +192,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} ...@@ -192,7 +192,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
printf("first select\n"); printf("first select\n");
{ ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 1 ", ECPGt_EOIT, { ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 1 ", ECPGt_EOIT,
ECPGt_char,&(c),(long)-1,(long)1,(-1)*sizeof(char), ECPGt_char,(c),(long)sizeof("abc ")+1,(long)1,(sizeof("abc ")+1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_short,&(s),(long)1,(long)1,sizeof(short), ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
...@@ -232,7 +232,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} ...@@ -232,7 +232,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
printf("second select\n"); printf("second select\n");
{ ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 2 ", ECPGt_EOIT, { ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 2 ", ECPGt_EOIT,
ECPGt_char,&(c),(long)-1,(long)1,(-1)*sizeof(char), ECPGt_char,(c),(long)sizeof("abc ")+1,(long)1,(sizeof("abc ")+1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_short,&(s),(long)1,(long)1,sizeof(short), ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
......
...@@ -113,30 +113,25 @@ main(void) ...@@ -113,30 +113,25 @@ main(void)
r = PGTYPESnumeric_to_double(num, &d); r = PGTYPESnumeric_to_double(num, &d);
if (r) check_errno(); if (r) check_errno();
printf("num[%d,10]: %2.7f (r: %d)\n", i, r?0.0:d, r); printf("num[%d,10]: %g (r: %d)\n", i, r?0.0:d, r);
if (r == 0) /* do not test double to numeric because
{ * - extra digits are different on different architectures
r = PGTYPESnumeric_from_double(d, nin); * - PGTYPESnumeric_from_double internally calls PGTYPESnumeric_from_asc anyway
if (r) check_errno(); */
text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,11]: %s (r: %d - cmp: %d)\n", i, text, r, q);
free(text);
}
dec = PGTYPESdecimal_new(); dec = PGTYPESdecimal_new();
r = PGTYPESnumeric_to_decimal(num, dec); r = PGTYPESnumeric_to_decimal(num, dec);
if (r) check_errno(); if (r) check_errno();
/* we have no special routine for outputting decimal, it would /* we have no special routine for outputting decimal, it would
* convert to a numeric anyway */ * convert to a numeric anyway */
printf("num[%d,12]: - (r: %d)\n", i, r); printf("num[%d,11]: - (r: %d)\n", i, r);
if (r == 0) if (r == 0)
{ {
r = PGTYPESnumeric_from_decimal(dec, nin); r = PGTYPESnumeric_from_decimal(dec, nin);
if (r) check_errno(); if (r) check_errno();
text = PGTYPESnumeric_to_asc(nin, 2); text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin); q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,13]: %s (r: %d - cmp: %d)\n", i, text, r, q); printf("num[%d,12]: %s (r: %d - cmp: %d)\n", i, text, r, q);
free(text); free(text);
} }
......
...@@ -6,9 +6,9 @@ num[0,4]: 2000000000000000000000000000000000000000000000000000000000000000000000 ...@@ -6,9 +6,9 @@ num[0,4]: 2000000000000000000000000000000000000000000000000000000000000000000000
num[0,5]: 0.00 num[0,5]: 0.00
(errno == PGTYPES_NUM_OVERFLOW) - num[0,6]: 0 (r: -1) (errno == PGTYPES_NUM_OVERFLOW) - num[0,6]: 0 (r: -1)
(errno == PGTYPES_NUM_OVERFLOW) - num[0,8]: 0 (r: -1) (errno == PGTYPES_NUM_OVERFLOW) - num[0,8]: 0 (r: -1)
(errno == PGTYPES_NUM_OVERFLOW) - num[0,10]: 0.0000000 (r: -1) (errno == PGTYPES_NUM_OVERFLOW) - num[0,10]: 0 (r: -1)
num[0,12]: - (r: 0) num[0,11]: - (r: 0)
num[0,13]: 20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00 (r: 0 - cmp: 0) num[0,12]: 20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00 (r: 0 - cmp: 0)
endptr of 1 is not NULL endptr of 1 is not NULL
num[1,1]: -2 num[1,1]: -2
...@@ -20,10 +20,9 @@ num[1,6]: -2 (r: 0) ...@@ -20,10 +20,9 @@ num[1,6]: -2 (r: 0)
num[1,7]: -2.00 (r: 0 - cmp: 0) num[1,7]: -2.00 (r: 0 - cmp: 0)
num[1,8]: -2 (r: 0) num[1,8]: -2 (r: 0)
num[1,9]: -2.00 (r: 0 - cmp: 0) num[1,9]: -2.00 (r: 0 - cmp: 0)
num[1,10]: -2.0000000 (r: 0) num[1,10]: -2 (r: 0)
num[1,11]: -2.00 (r: 0 - cmp: 0) num[1,11]: - (r: 0)
num[1,12]: - (r: 0) num[1,12]: -2.00 (r: 0 - cmp: 0)
num[1,13]: -2.00 (r: 0 - cmp: 0)
endptr of 2 is not NULL endptr of 2 is not NULL
num[2,1]: 0.794 num[2,1]: 0.794
...@@ -35,10 +34,9 @@ num[2,6]: 1 (r: 0) ...@@ -35,10 +34,9 @@ num[2,6]: 1 (r: 0)
num[2,7]: 1.00 (r: 0 - cmp: -1) num[2,7]: 1.00 (r: 0 - cmp: -1)
num[2,8]: 1 (r: 0) num[2,8]: 1 (r: 0)
num[2,9]: 1.00 (r: 0 - cmp: -1) num[2,9]: 1.00 (r: 0 - cmp: -1)
num[2,10]: 0.7940000 (r: 0) num[2,10]: 0.794 (r: 0)
num[2,11]: 0.79 (r: 0 - cmp: 0) num[2,11]: - (r: 0)
num[2,12]: - (r: 0) num[2,12]: 0.79 (r: 0 - cmp: 0)
num[2,13]: 0.79 (r: 0 - cmp: 0)
endptr of 3 is not NULL endptr of 3 is not NULL
num[3,1]: 3.44 num[3,1]: 3.44
...@@ -50,10 +48,9 @@ num[3,6]: 3 (r: 0) ...@@ -50,10 +48,9 @@ num[3,6]: 3 (r: 0)
num[3,7]: 3.00 (r: 0 - cmp: 1) num[3,7]: 3.00 (r: 0 - cmp: 1)
num[3,8]: 3 (r: 0) num[3,8]: 3 (r: 0)
num[3,9]: 3.00 (r: 0 - cmp: 1) num[3,9]: 3.00 (r: 0 - cmp: 1)
num[3,10]: 3.4400000 (r: 0) num[3,10]: 3.44 (r: 0)
num[3,11]: 3.44 (r: 0 - cmp: 0) num[3,11]: - (r: 0)
num[3,12]: - (r: 0) num[3,12]: 3.44 (r: 0 - cmp: 0)
num[3,13]: 3.44 (r: 0 - cmp: 0)
endptr of 4 is not NULL endptr of 4 is not NULL
num[4,1]: 592490000000000000000000 num[4,1]: 592490000000000000000000
...@@ -63,10 +60,9 @@ num[4,4]: 592490000000000000000000.00 ...@@ -63,10 +60,9 @@ num[4,4]: 592490000000000000000000.00
num[4,5]: 0.00 num[4,5]: 0.00
(errno == PGTYPES_NUM_OVERFLOW) - num[4,6]: 0 (r: -1) (errno == PGTYPES_NUM_OVERFLOW) - num[4,6]: 0 (r: -1)
(errno == PGTYPES_NUM_OVERFLOW) - num[4,8]: 0 (r: -1) (errno == PGTYPES_NUM_OVERFLOW) - num[4,8]: 0 (r: -1)
num[4,10]: 592490000000000009961472.0000000 (r: 0) num[4,10]: 5.9249e+23 (r: 0)
num[4,11]: 592490000000000009961472.00 (r: 0 - cmp: -1) num[4,11]: - (r: 0)
num[4,12]: - (r: 0) num[4,12]: 592490000000000000000000.00 (r: 0 - cmp: 0)
num[4,13]: 592490000000000000000000.00 (r: 0 - cmp: 0)
endptr of 5 is not NULL endptr of 5 is not NULL
num[5,1]: -328400 num[5,1]: -328400
...@@ -78,10 +74,9 @@ num[5,6]: -328400 (r: 0) ...@@ -78,10 +74,9 @@ num[5,6]: -328400 (r: 0)
num[5,7]: -328400.00 (r: 0 - cmp: 0) num[5,7]: -328400.00 (r: 0 - cmp: 0)
num[5,8]: -328400 (r: 0) num[5,8]: -328400 (r: 0)
num[5,9]: -328400.00 (r: 0 - cmp: 0) num[5,9]: -328400.00 (r: 0 - cmp: 0)
num[5,10]: -328400.0000000 (r: 0) num[5,10]: -328400 (r: 0)
num[5,11]: -328400.00 (r: 0 - cmp: 0) num[5,11]: - (r: 0)
num[5,12]: - (r: 0) num[5,12]: -328400.00 (r: 0 - cmp: 0)
num[5,13]: -328400.00 (r: 0 - cmp: 0)
endptr of 6 is not NULL endptr of 6 is not NULL
num[6,1]: 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002 num[6,1]: 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002
...@@ -93,9 +88,9 @@ num[6,6]: 0 (r: 0) ...@@ -93,9 +88,9 @@ num[6,6]: 0 (r: 0)
num[6,7]: 0.00 (r: 0 - cmp: 1) num[6,7]: 0.00 (r: 0 - cmp: 1)
num[6,8]: 0 (r: 0) num[6,8]: 0 (r: 0)
num[6,9]: 0.00 (r: 0 - cmp: 1) num[6,9]: 0.00 (r: 0 - cmp: 1)
(errno == PGTYPES_NUM_UNDERFLOW) - num[6,10]: 0.0000000 (r: -1) (errno == PGTYPES_NUM_UNDERFLOW) - num[6,10]: 0 (r: -1)
num[6,12]: - (r: 0) num[6,11]: - (r: 0)
num[6,13]: 0.00 (r: 0 - cmp: 0) num[6,12]: 0.00 (r: 0 - cmp: 0)
endptr of 7 is not NULL endptr of 7 is not NULL
num[7,1]: 0.001 num[7,1]: 0.001
...@@ -107,10 +102,9 @@ num[7,6]: 0 (r: 0) ...@@ -107,10 +102,9 @@ num[7,6]: 0 (r: 0)
num[7,7]: 0.00 (r: 0 - cmp: 1) num[7,7]: 0.00 (r: 0 - cmp: 1)
num[7,8]: 0 (r: 0) num[7,8]: 0 (r: 0)
num[7,9]: 0.00 (r: 0 - cmp: 1) num[7,9]: 0.00 (r: 0 - cmp: 1)
num[7,10]: 0.0010000 (r: 0) num[7,10]: 0.001 (r: 0)
num[7,11]: 0.00 (r: 0 - cmp: 0) num[7,11]: - (r: 0)
num[7,12]: - (r: 0) num[7,12]: 0.00 (r: 0 - cmp: 0)
num[7,13]: 0.00 (r: 0 - cmp: 0)
endptr of 8 is not NULL endptr of 8 is not NULL
num[8,1]: 0.0 num[8,1]: 0.0
...@@ -122,10 +116,9 @@ num[8,6]: 0 (r: 0) ...@@ -122,10 +116,9 @@ num[8,6]: 0 (r: 0)
num[8,7]: 0.00 (r: 0 - cmp: 0) num[8,7]: 0.00 (r: 0 - cmp: 0)
num[8,8]: 0 (r: 0) num[8,8]: 0 (r: 0)
num[8,9]: 0.00 (r: 0 - cmp: 0) num[8,9]: 0.00 (r: 0 - cmp: 0)
num[8,10]: 0.0000000 (r: 0) num[8,10]: 0 (r: 0)
num[8,11]: 0.00 (r: 0 - cmp: 0) num[8,11]: - (r: 0)
num[8,12]: - (r: 0) num[8,12]: 0.00 (r: 0 - cmp: 0)
num[8,13]: 0.00 (r: 0 - cmp: 0)
endptr of 9 is not NULL endptr of 9 is not NULL
num[9,1]: -0.000059249 num[9,1]: -0.000059249
...@@ -137,10 +130,9 @@ num[9,6]: 0 (r: 0) ...@@ -137,10 +130,9 @@ num[9,6]: 0 (r: 0)
num[9,7]: 0.00 (r: 0 - cmp: -1) num[9,7]: 0.00 (r: 0 - cmp: -1)
num[9,8]: 0 (r: 0) num[9,8]: 0 (r: 0)
num[9,9]: 0.00 (r: 0 - cmp: -1) num[9,9]: 0.00 (r: 0 - cmp: -1)
num[9,10]: -0.0000592 (r: 0) num[9,10]: -5.9249e-05 (r: 0)
num[9,11]: -0.00 (r: 0 - cmp: -1) num[9,11]: - (r: 0)
num[9,12]: - (r: 0) num[9,12]: -0.00 (r: 0 - cmp: 0)
num[9,13]: -0.00 (r: 0 - cmp: 0)
endptr of 10 is not NULL endptr of 10 is not NULL
num[10,1]: 0.003284 num[10,1]: 0.003284
...@@ -152,10 +144,9 @@ num[10,6]: 0 (r: 0) ...@@ -152,10 +144,9 @@ num[10,6]: 0 (r: 0)
num[10,7]: 0.00 (r: 0 - cmp: 1) num[10,7]: 0.00 (r: 0 - cmp: 1)
num[10,8]: 0 (r: 0) num[10,8]: 0 (r: 0)
num[10,9]: 0.00 (r: 0 - cmp: 1) num[10,9]: 0.00 (r: 0 - cmp: 1)
num[10,10]: 0.0032840 (r: 0) num[10,10]: 0.003284 (r: 0)
num[10,11]: 0.00 (r: 0 - cmp: 0) num[10,11]: - (r: 0)
num[10,12]: - (r: 0) num[10,12]: 0.00 (r: 0 - cmp: 0)
num[10,13]: 0.00 (r: 0 - cmp: 0)
endptr of 11 is not NULL endptr of 11 is not NULL
num[11,1]: 0.500001 num[11,1]: 0.500001
...@@ -167,10 +158,9 @@ num[11,6]: 1 (r: 0) ...@@ -167,10 +158,9 @@ num[11,6]: 1 (r: 0)
num[11,7]: 1.00 (r: 0 - cmp: -1) num[11,7]: 1.00 (r: 0 - cmp: -1)
num[11,8]: 1 (r: 0) num[11,8]: 1 (r: 0)
num[11,9]: 1.00 (r: 0 - cmp: -1) num[11,9]: 1.00 (r: 0 - cmp: -1)
num[11,10]: 0.5000010 (r: 0) num[11,10]: 0.500001 (r: 0)
num[11,11]: 0.50 (r: 0 - cmp: 0) num[11,11]: - (r: 0)
num[11,12]: - (r: 0) num[11,12]: 0.50 (r: 0 - cmp: 0)
num[11,13]: 0.50 (r: 0 - cmp: 0)
endptr of 12 is not NULL endptr of 12 is not NULL
num[12,1]: -0.5000001 num[12,1]: -0.5000001
...@@ -182,10 +172,9 @@ num[12,6]: -1 (r: 0) ...@@ -182,10 +172,9 @@ num[12,6]: -1 (r: 0)
num[12,7]: -1.00 (r: 0 - cmp: 1) num[12,7]: -1.00 (r: 0 - cmp: 1)
num[12,8]: -1 (r: 0) num[12,8]: -1 (r: 0)
num[12,9]: -1.00 (r: 0 - cmp: 1) num[12,9]: -1.00 (r: 0 - cmp: 1)
num[12,10]: -0.5000001 (r: 0) num[12,10]: -0.5 (r: 0)
num[12,11]: -0.50 (r: 0 - cmp: -1) num[12,11]: - (r: 0)
num[12,12]: - (r: 0) num[12,12]: -0.50 (r: 0 - cmp: 0)
num[12,13]: -0.50 (r: 0 - cmp: 0)
endptr of 13 is not NULL endptr of 13 is not NULL
num[13,1]: 1234567890123456789012345678.91 num[13,1]: 1234567890123456789012345678.91
...@@ -195,10 +184,9 @@ num[13,4]: 1234567890123456789012345678.91 ...@@ -195,10 +184,9 @@ num[13,4]: 1234567890123456789012345678.91
num[13,5]: 0.00 num[13,5]: 0.00
(errno == PGTYPES_NUM_OVERFLOW) - num[13,6]: 0 (r: -1) (errno == PGTYPES_NUM_OVERFLOW) - num[13,6]: 0 (r: -1)
(errno == PGTYPES_NUM_OVERFLOW) - num[13,8]: 0 (r: -1) (errno == PGTYPES_NUM_OVERFLOW) - num[13,8]: 0 (r: -1)
num[13,10]: 1234567890123456850245451776.0000000 (r: 0) num[13,10]: 1.23457e+27 (r: 0)
num[13,11]: 1234567890123456850245451776.00 (r: 0 - cmp: -1) num[13,11]: - (r: 0)
num[13,12]: - (r: 0) num[13,12]: 1234567890123456789012345678.91 (r: 0 - cmp: 0)
num[13,13]: 1234567890123456789012345678.91 (r: 0 - cmp: 0)
endptr of 14 is not NULL endptr of 14 is not NULL
num[14,1]: 1234567890123456789012345678.921 num[14,1]: 1234567890123456789012345678.921
...@@ -208,9 +196,8 @@ num[14,4]: 1234567890123456789012345678.92 ...@@ -208,9 +196,8 @@ num[14,4]: 1234567890123456789012345678.92
num[14,5]: 0.00 num[14,5]: 0.00
(errno == PGTYPES_NUM_OVERFLOW) - num[14,6]: 0 (r: -1) (errno == PGTYPES_NUM_OVERFLOW) - num[14,6]: 0 (r: -1)
(errno == PGTYPES_NUM_OVERFLOW) - num[14,8]: 0 (r: -1) (errno == PGTYPES_NUM_OVERFLOW) - num[14,8]: 0 (r: -1)
num[14,10]: 1234567890123456850245451776.0000000 (r: 0) num[14,10]: 1.23457e+27 (r: 0)
num[14,11]: 1234567890123456850245451776.00 (r: 0 - cmp: -1) (errno == PGTYPES_NUM_OVERFLOW) - num[14,11]: - (r: -1)
(errno == PGTYPES_NUM_OVERFLOW) - num[14,12]: - (r: -1)
(errno == PGTYPES_NUM_BAD_NUMERIC) - endptr of 15 is not NULL (errno == PGTYPES_NUM_BAD_NUMERIC) - endptr of 15 is not NULL
*endptr of 15 is not \0 *endptr of 15 is not \0
......
...@@ -48,7 +48,7 @@ main(void) ...@@ -48,7 +48,7 @@ main(void)
int val1 = 1 ; int val1 = 1 ;
#line 13 "desc.pgc" #line 13 "desc.pgc"
char val2 [ 4 ] = "one" , val2output [ 4 ] = "AAA" ; char val2 [ 4 ] = "one" , val2output [] = "AAA" ;
#line 14 "desc.pgc" #line 14 "desc.pgc"
int val1output = 2 , val2i = 0 ; int val1output = 2 , val2i = 0 ;
...@@ -168,7 +168,7 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -168,7 +168,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data, { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT); ECPGt_const,"3",(long)1,(long)1,strlen("3"), ECPGd_EODT);
#line 41 "desc.pgc" #line 41 "desc.pgc"
...@@ -176,8 +176,8 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -176,8 +176,8 @@ if (sqlca.sqlcode < 0) sqlprint();}
#line 41 "desc.pgc" #line 41 "desc.pgc"
{ ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data, { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data,
ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator, ECPGt_const,"this is a long test",(long)19,(long)1,strlen("this is a long test"), ECPGd_indicator,
ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGd_EODT); ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT);
#line 42 "desc.pgc" #line 42 "desc.pgc"
...@@ -185,6 +185,35 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -185,6 +185,35 @@ if (sqlca.sqlcode < 0) sqlprint();}
#line 42 "desc.pgc" #line 42 "desc.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "?",
ECPGt_char_variable,(ECPGprepared_statement("foo1")),(long)1,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_descriptor, "indesc", 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 44 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 44 "desc.pgc"
{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT);
#line 46 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 46 "desc.pgc"
{ ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data,
ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator,
ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGd_EODT);
#line 47 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 47 "desc.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "?", { ECPGdo(__LINE__, 0, 1, NULL, "?",
ECPGt_char_variable,(ECPGprepared_statement("foo2")),(long)1,(long)1,(1)*sizeof(char), ECPGt_char_variable,(ECPGprepared_statement("foo2")),(long)1,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
...@@ -192,141 +221,141 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -192,141 +221,141 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
ECPGt_descriptor, "outdesc", 0L, 0L, 0L, ECPGt_descriptor, "outdesc", 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 44 "desc.pgc" #line 49 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 44 "desc.pgc" #line 49 "desc.pgc"
{ ECPGget_desc(__LINE__, "outdesc", 1,ECPGd_data, { ECPGget_desc(__LINE__, "outdesc", 1,ECPGd_data,
ECPGt_char,(val2output),(long)4,(long)1,(4)*sizeof(char), ECPGd_EODT); ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char), ECPGd_EODT);
#line 46 "desc.pgc" #line 51 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 46 "desc.pgc" #line 51 "desc.pgc"
printf("output = %s\n", val2output); printf("output = %s\n", val2output);
/* declare c1 cursor for ? */ /* declare c1 cursor for ? */
#line 49 "desc.pgc" #line 54 "desc.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "declare c1 cursor for ?", { ECPGdo(__LINE__, 0, 1, NULL, "declare c1 cursor for ?",
ECPGt_char_variable,(ECPGprepared_statement("foo2")),(long)1,(long)1,(1)*sizeof(char), ECPGt_char_variable,(ECPGprepared_statement("foo2")),(long)1,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_descriptor, "indesc", 0L, 0L, 0L, ECPGt_descriptor, "indesc", 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 50 "desc.pgc" #line 55 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 50 "desc.pgc" #line 55 "desc.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c1", ECPGt_EOIT, { ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c1", ECPGt_EOIT,
ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int),
ECPGt_char,(val2output),(long)4,(long)1,(4)*sizeof(char), ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char),
ECPGt_int,&(ind2),(long)1,(long)1,sizeof(int), ECPGt_EORT); ECPGt_int,&(ind2),(long)1,(long)1,sizeof(int), ECPGt_EORT);
#line 52 "desc.pgc" #line 57 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 52 "desc.pgc" #line 57 "desc.pgc"
printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n", printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
val1output, ind1, val2output, ind2); val1output, ind1, val2output, ind2);
{ ECPGdo(__LINE__, 0, 1, NULL, "close c1", ECPGt_EOIT, ECPGt_EORT); { ECPGdo(__LINE__, 0, 1, NULL, "close c1", ECPGt_EOIT, ECPGt_EORT);
#line 56 "desc.pgc" #line 61 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 56 "desc.pgc" #line 61 "desc.pgc"
{ ECPGset_desc_header(__LINE__, "indesc", (int)(1)); { ECPGset_desc_header(__LINE__, "indesc", (int)(1));
#line 58 "desc.pgc" #line 63 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 58 "desc.pgc" #line 63 "desc.pgc"
{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data, { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGd_EODT); ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGd_EODT);
#line 59 "desc.pgc" #line 64 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 59 "desc.pgc" #line 64 "desc.pgc"
/* declare c2 cursor for ? */ /* declare c2 cursor for ? */
#line 61 "desc.pgc" #line 66 "desc.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "declare c2 cursor for ?", { ECPGdo(__LINE__, 0, 1, NULL, "declare c2 cursor for ?",
ECPGt_char_variable,(ECPGprepared_statement("foo3")),(long)1,(long)1,(1)*sizeof(char), ECPGt_char_variable,(ECPGprepared_statement("foo3")),(long)1,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_descriptor, "indesc", 0L, 0L, 0L, ECPGt_descriptor, "indesc", 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 62 "desc.pgc" #line 67 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 62 "desc.pgc" #line 67 "desc.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c2", ECPGt_EOIT, { ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c2", ECPGt_EOIT,
ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(val2output),(long)4,(long)1,(4)*sizeof(char), ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char),
ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT); ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
#line 64 "desc.pgc" #line 69 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 64 "desc.pgc" #line 69 "desc.pgc"
printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output); printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
{ ECPGdo(__LINE__, 0, 1, NULL, "close c2", ECPGt_EOIT, ECPGt_EORT); { ECPGdo(__LINE__, 0, 1, NULL, "close c2", ECPGt_EOIT, ECPGt_EORT);
#line 67 "desc.pgc" #line 72 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 67 "desc.pgc" #line 72 "desc.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "select * from test1 where a = 2 ", ECPGt_EOIT, { ECPGdo(__LINE__, 0, 1, NULL, "select * from test1 where a = 3 ", ECPGt_EOIT,
ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(val2output),(long)4,(long)1,(4)*sizeof(char), ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char),
ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT); ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
#line 69 "desc.pgc" #line 74 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 69 "desc.pgc" #line 74 "desc.pgc"
printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output); printf("val1=%d val2=%c%c%c%c warn=%c truncate=%d\n", val1output, val2output[0], val2output[1], val2output[2], val2output[3], sqlca.sqlwarn[0], val2i);
{ ECPGdo(__LINE__, 0, 1, NULL, "drop table test1 ", ECPGt_EOIT, ECPGt_EORT); { ECPGdo(__LINE__, 0, 1, NULL, "drop table test1 ", ECPGt_EOIT, ECPGt_EORT);
#line 72 "desc.pgc" #line 77 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 72 "desc.pgc" #line 77 "desc.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT"); { ECPGdisconnect(__LINE__, "CURRENT");
#line 73 "desc.pgc" #line 78 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 73 "desc.pgc" #line 78 "desc.pgc"
ECPGdeallocate_desc(__LINE__, "indesc"); ECPGdeallocate_desc(__LINE__, "indesc");
#line 75 "desc.pgc" #line 80 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint(); if (sqlca.sqlcode < 0) sqlprint();
#line 75 "desc.pgc" #line 80 "desc.pgc"
ECPGdeallocate_desc(__LINE__, "outdesc"); ECPGdeallocate_desc(__LINE__, "outdesc");
#line 76 "desc.pgc" #line 81 "desc.pgc"
if (sqlca.sqlcode < 0) sqlprint(); if (sqlca.sqlcode < 0) sqlprint();
#line 76 "desc.pgc" #line 81 "desc.pgc"
return 0; return 0;
......
...@@ -20,59 +20,63 @@ ...@@ -20,59 +20,63 @@
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 39 Ok: INSERT 0 1 [NO_PID]: ECPGexecute line 39 Ok: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 44: QUERY: SELECT * from test1 where a = '1' and b = 'one' on connection regress1 [NO_PID]: ECPGexecute line 44: QUERY: INSERT INTO test1 VALUES ('3', 'this is a long test') on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 44: Correctly got 1 tuples with 2 fields [NO_PID]: ECPGexecute line 44 Ok: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 49: QUERY: SELECT * from test1 where a = '1' and b = 'one' on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 49: Correctly got 1 tuples with 2 fields
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute putting result (1 tuples) into descriptor 'outdesc' [NO_PID]: ECPGexecute putting result (1 tuples) into descriptor 'outdesc'
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 1 [NO_PID]: ECPGget_desc: reading items for tuple 1
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 46: RESULT: 1 offset: -1 array: Yes [NO_PID]: ECPGget_data line 51: RESULT: 1 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 50: QUERY: declare c1 cursor for SELECT * from test1 where a = '1' and b = 'one' on connection regress1 [NO_PID]: ECPGexecute line 55: QUERY: declare c1 cursor for SELECT * from test1 where a = '1' and b = 'one' on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 50 Ok: DECLARE CURSOR [NO_PID]: ECPGexecute line 55 Ok: DECLARE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 52: QUERY: fetch next from c1 on connection regress1 [NO_PID]: ECPGexecute line 57: QUERY: fetch next from c1 on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 52: Correctly got 1 tuples with 2 fields [NO_PID]: ECPGexecute line 57: Correctly got 1 tuples with 2 fields
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 52: RESULT: 1 offset: -1 array: Yes [NO_PID]: ECPGget_data line 57: RESULT: 1 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 52: RESULT: one offset: -1 array: Yes [NO_PID]: ECPGget_data line 57: RESULT: one offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 56: QUERY: close c1 on connection regress1 [NO_PID]: ECPGexecute line 61: QUERY: close c1 on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 56 Ok: CLOSE CURSOR [NO_PID]: ECPGexecute line 61 Ok: CLOSE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 62: QUERY: declare c2 cursor for SELECT * from test1 where a = '2' on connection regress1 [NO_PID]: ECPGexecute line 67: QUERY: declare c2 cursor for SELECT * from test1 where a = '2' on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 62 Ok: DECLARE CURSOR [NO_PID]: ECPGexecute line 67 Ok: DECLARE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 64: QUERY: fetch next from c2 on connection regress1 [NO_PID]: ECPGexecute line 69: QUERY: fetch next from c2 on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 64: Correctly got 1 tuples with 2 fields [NO_PID]: ECPGexecute line 69: Correctly got 1 tuples with 2 fields
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 64: RESULT: 2 offset: -1 array: Yes [NO_PID]: ECPGget_data line 69: RESULT: 2 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 64: RESULT: offset: -1 array: Yes [NO_PID]: ECPGget_data line 69: RESULT: offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 67: QUERY: close c2 on connection regress1 [NO_PID]: ECPGexecute line 72: QUERY: close c2 on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 67 Ok: CLOSE CURSOR [NO_PID]: ECPGexecute line 72 Ok: CLOSE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 69: QUERY: select * from test1 where a = 2 on connection regress1 [NO_PID]: ECPGexecute line 74: QUERY: select * from test1 where a = 3 on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 69: Correctly got 1 tuples with 2 fields [NO_PID]: ECPGexecute line 74: Correctly got 1 tuples with 2 fields
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 69: RESULT: 2 offset: -1 array: Yes [NO_PID]: ECPGget_data line 74: RESULT: 3 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 69: RESULT: offset: -1 array: Yes [NO_PID]: ECPGget_data line 74: RESULT: this is a long test offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 72: QUERY: drop table test1 on connection regress1 [NO_PID]: ECPGexecute line 77: QUERY: drop table test1 on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 72 Ok: DROP TABLE [NO_PID]: ECPGexecute line 77 Ok: DROP TABLE
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection regress1 closed. [NO_PID]: ecpg_finish: Connection regress1 closed.
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
output = 1 output = 1
val1=1 (ind1: 0) val2=one (ind2: 0) val1=1 (ind1: 0) val2=one (ind2: 0)
val1=2 val2=null val1=2 val2=null
val1=2 val2=null val1=3 val2=this warn=W truncate=19
...@@ -95,30 +95,25 @@ main(void) ...@@ -95,30 +95,25 @@ main(void)
r = PGTYPESnumeric_to_double(num, &d); r = PGTYPESnumeric_to_double(num, &d);
if (r) check_errno(); if (r) check_errno();
printf("num[%d,10]: %2.7f (r: %d)\n", i, r?0.0:d, r); printf("num[%d,10]: %g (r: %d)\n", i, r?0.0:d, r);
if (r == 0) /* do not test double to numeric because
{ * - extra digits are different on different architectures
r = PGTYPESnumeric_from_double(d, nin); * - PGTYPESnumeric_from_double internally calls PGTYPESnumeric_from_asc anyway
if (r) check_errno(); */
text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,11]: %s (r: %d - cmp: %d)\n", i, text, r, q);
free(text);
}
dec = PGTYPESdecimal_new(); dec = PGTYPESdecimal_new();
r = PGTYPESnumeric_to_decimal(num, dec); r = PGTYPESnumeric_to_decimal(num, dec);
if (r) check_errno(); if (r) check_errno();
/* we have no special routine for outputting decimal, it would /* we have no special routine for outputting decimal, it would
* convert to a numeric anyway */ * convert to a numeric anyway */
printf("num[%d,12]: - (r: %d)\n", i, r); printf("num[%d,11]: - (r: %d)\n", i, r);
if (r == 0) if (r == 0)
{ {
r = PGTYPESnumeric_from_decimal(dec, nin); r = PGTYPESnumeric_from_decimal(dec, nin);
if (r) check_errno(); if (r) check_errno();
text = PGTYPESnumeric_to_asc(nin, 2); text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin); q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,13]: %s (r: %d - cmp: %d)\n", i, text, r, q); printf("num[%d,12]: %s (r: %d - cmp: %d)\n", i, text, r, q);
free(text); free(text);
} }
......
...@@ -10,7 +10,7 @@ main(void) ...@@ -10,7 +10,7 @@ main(void)
char *stmt3 = "SELECT * from test1 where a = ?"; char *stmt3 = "SELECT * from test1 where a = ?";
int val1 = 1; int val1 = 1;
char val2[4] = "one", val2output[4] = "AAA"; char val2[4] = "one", val2output[] = "AAA";
int val1output = 2, val2i = 0; int val1output = 2, val2i = 0;
int val2null = -1; int val2null = -1;
int ind1, ind2; int ind1, ind2;
...@@ -38,6 +38,11 @@ main(void) ...@@ -38,6 +38,11 @@ main(void)
EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc; EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 3;
EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val1, DATA = 'this is a long test';
EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1; EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1;
EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2i, DATA = :val2; EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2i, DATA = :val2;
...@@ -66,8 +71,8 @@ main(void) ...@@ -66,8 +71,8 @@ main(void)
EXEC SQL CLOSE c2; EXEC SQL CLOSE c2;
EXEC SQL SELECT * INTO :val1output, :val2output :val2i FROM test1 where a = 2; EXEC SQL SELECT * INTO :val1output, :val2output:val2i FROM test1 where a = 3;
printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output); printf("val1=%d val2=%c%c%c%c warn=%c truncate=%d\n", val1output, val2output[0], val2output[1], val2output[2], val2output[3], sqlca.sqlwarn[0], val2i);
EXEC SQL DROP TABLE test1; EXEC SQL DROP TABLE test1;
EXEC SQL DISCONNECT; EXEC SQL DISCONNECT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment