Commit 5d34af42 authored by Michael Meskes's avatar Michael Meskes

Added STRING datatype for Informix compatibility mode. This work is

based on a patch send in by Böszörményi Zoltán <zb@cybertec.at>.
parent 06f1f53e
......@@ -2412,6 +2412,12 @@ Mon, 02 Feb 2009 16:34:53 +0100
- Fixed auto allocation for binary data types.
- Set pgtypes library version to 3.1.
- Set compat library version to 3.1.
- Set ecpg library version to 6.2.
- Set ecpg library version to 6.1.
- Set ecpg version to 4.5.
Fri, 07 Aug 2009 10:41:28 +0200
- Added STRING datatype for Informix compatibility mode. This work is
based on a patch send in by Böszörményi Zoltán <zb@cybertec.at>.
- Set ecpg library version to 6.2.
- Set ecpg version to 4.6.
......@@ -5,7 +5,7 @@
# Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.43 2009/07/13 01:37:05 momjian Exp $
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.44 2009/08/07 10:51:20 meskes Exp $
#
#-------------------------------------------------------------------------
......@@ -15,7 +15,7 @@ include $(top_builddir)/src/Makefile.global
NAME= ecpg_compat
SO_MAJOR_VERSION= 3
SO_MINOR_VERSION= 2
SO_MINOR_VERSION= 1
override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
-I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils $(CPPFLAGS)
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.42 2009/01/15 11:52:55 petere Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.43 2009/08/07 10:51:20 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
......@@ -138,6 +138,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_varchar:
case ECPGt_string:
break;
default:
......@@ -389,13 +390,29 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_string:
if (pval)
{
char *str = (char *) ((long) var + offset * act_tuple);
if (varcharsize == 0 || varcharsize > size)
strncpy((char *) ((long) var + offset * act_tuple), pval, size + 1);
{
char *last;
strncpy(str, pval, size + 1);
/* do the rtrim() */
if (type == ECPGt_string)
{
char *last = str + size;
while (last > str && (*last == ' ' || *last == '\0'))
{
*last = '\0';
last--;
}
}
}
else
{
strncpy((char *) ((long) var + offset * act_tuple), pval, varcharsize);
strncpy(str, pval, varcharsize);
if (varcharsize < size)
{
......
/* dynamic SQL support routines
*
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.32 2009/06/11 14:49:13 momjian Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.33 2009/08/07 10:51:20 meskes Exp $
*/
#define POSTGRES_ECPG_INTERNAL
......@@ -200,6 +200,7 @@ get_char_item(int lineno, void *var, enum ECPGttype vartype, char *value, int va
{
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_string:
strncpy((char *) var, value, varcharsize);
break;
case ECPGt_varchar:
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.85 2009/06/11 14:49:13 momjian Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.86 2009/08/07 10:51:20 meskes Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
......@@ -359,6 +359,7 @@ ecpg_store_result(const PGresult *results, int act_field,
{
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_string:
if (!var->varcharsize && !var->arrsize)
{
/* special mode for handling char**foo=0 */
......@@ -418,7 +419,7 @@ ecpg_store_result(const PGresult *results, int act_field,
/* fill the variable with the tuple(s) */
if (!var->varcharsize && !var->arrsize &&
(var->type == ECPGt_char || var->type == ECPGt_unsigned_char))
(var->type == ECPGt_char || var->type == ECPGt_unsigned_char || var->type == ECPGt_string))
{
/* special mode for handling char**foo=0 */
......@@ -757,6 +758,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_string:
{
/* set slen to string length if type is char * */
int slen = (var->varcharsize == 0) ? strlen((char *) var->value) : (unsigned int) var->varcharsize;
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.49 2009/06/11 14:49:13 momjian Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.50 2009/08/07 10:51:20 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
......@@ -295,6 +295,7 @@ ECPGset_noind_null(enum ECPGttype type, void *ptr)
{
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_string:
*((char *) ptr) = '\0';
break;
case ECPGt_short:
......@@ -361,6 +362,7 @@ ECPGis_noind_null(enum ECPGttype type, void *ptr)
{
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_string:
if (*((char *) ptr) == '\0')
return true;
break;
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.14 2007/11/15 21:14:45 momjian Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.15 2009/08/07 10:51:20 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
......@@ -19,6 +19,7 @@ ecpg_type_name(enum ECPGttype typ)
switch (typ)
{
case ECPGt_char:
case ECPGt_string:
return "char";
case ECPGt_unsigned_char:
return "unsigned char";
......
......@@ -5,7 +5,7 @@
* All types that can be handled for host variable declarations has to
* be handled eventually.
*
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpgtype.h,v 1.37 2007/08/14 10:01:52 meskes Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpgtype.h,v 1.38 2009/08/07 10:51:20 meskes Exp $
*/
/*
......@@ -61,7 +61,8 @@ enum ECPGttype
ECPGt_const, /* a constant is needed sometimes */
ECPGt_EOIT, /* End of insert types. */
ECPGt_EORT, /* End of result types. */
ECPGt_NO_INDICATOR /* no indicator */
ECPGt_NO_INDICATOR, /* no indicator */
ECPGt_string /* trimmed (char *) type */
};
/* descriptor items */
......@@ -86,7 +87,7 @@ enum ECPGdtype
ECPGd_cardinality
};
#define IS_SIMPLE_TYPE(type) ((type) >= ECPGt_char && (type) <= ECPGt_interval)
#define IS_SIMPLE_TYPE(type) (((type) >= ECPGt_char && (type) <= ECPGt_interval) || ((type) == ECPGt_string))
/* we also have to handle different statement types */
enum ECPG_statement_type
......
......@@ -5,7 +5,7 @@
# Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.44 2009/07/13 01:37:05 momjian Exp $
# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.45 2009/08/07 10:51:20 meskes Exp $
#
#-------------------------------------------------------------------------
......@@ -15,7 +15,7 @@ include $(top_builddir)/src/Makefile.global
NAME= pgtypes
SO_MAJOR_VERSION= 3
SO_MINOR_VERSION= 2
SO_MINOR_VERSION= 1
override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
-I$(top_srcdir)/src/include/utils -I$(libpq_srcdir) $(CPPFLAGS)
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.header,v 1.7 2009/06/10 23:11:52 petere Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.header,v 1.8 2009/08/07 10:51:20 meskes Exp $ */
/* Copyright comment */
%{
......@@ -256,12 +256,12 @@ adjust_informix(struct arguments *list)
original_var = ptr->variable->name;
sprintf(temp, "%d))", ecpg_informix_var);
if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char) && atoi(ptr->variable->type->size) > 1)
if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
{
ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"), ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
sprintf(temp, "%d, (", ecpg_informix_var++);
}
else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char) && atoi(ptr->variable->type->size) > 1)
else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
{
ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
sprintf(temp, "%d, (", ecpg_informix_var++);
......@@ -343,6 +343,8 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu
type_enum == ECPGt_union) &&
initializer == 1)
mmerror(PARSE_ERROR, ET_ERROR, "initializer not allowed in type definition");
else if (INFORMIX_MODE && strcmp(name, "string") == 0)
mmerror(PARSE_ERROR, ET_ERROR, "type name \"string\" is reserved in Informix mode");
else
{
for (ptr = types; ptr != NULL; ptr = ptr->next)
......@@ -371,6 +373,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu
if (type_enum != ECPGt_varchar &&
type_enum != ECPGt_char &&
type_enum != ECPGt_unsigned_char &&
type_enum != ECPGt_string &&
atoi(this->type->type_index) >= 0)
mmerror(PARSE_ERROR, ET_ERROR, "multidimensional arrays for simple data types are not supported");
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.9 2009/06/10 23:11:52 petere Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.10 2009/08/07 10:51:20 meskes Exp $ */
statements: /*EMPTY*/
| statements statement
......@@ -213,6 +213,7 @@ char_variable: cvariable
{
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_string:
$$ = $1;
break;
case ECPGt_varchar:
......@@ -587,6 +588,14 @@ var_type: simple_type
$$.type_index = make_str("-1");
$$.type_sizeof = NULL;
}
else if ((strcmp($1, "string") == 0) && INFORMIX_MODE)
{
$$.type_enum = ECPGt_string;
$$.type_str = make_str("char");
$$.type_dimension = make_str("-1");
$$.type_index = make_str("-1");
$$.type_sizeof = NULL;
}
else
{
/* this is for typedef'ed types */
......@@ -849,6 +858,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_string:
if (atoi(dimension) == -1)
{
int i = strlen($5);
......@@ -1269,6 +1279,7 @@ ECPGVar: SQL_VAR
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_string:
if (atoi(dimension) == -1)
type = ECPGmake_simple_type($5.type_enum, length, 0);
else
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.83 2009/06/11 14:49:13 momjian Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.84 2009/08/07 10:51:20 meskes Exp $ */
#include "postgres_fe.h"
......@@ -200,6 +200,9 @@ get_type(enum ECPGttype type)
case ECPGt_timestamp:
return ("ECPGt_timestamp");
break;
case ECPGt_string:
return ("ECPGt_string");
break;
default:
mmerror(PARSE_ERROR, ET_ERROR, "unrecognized variable type code %d", type);
}
......@@ -366,6 +369,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_char_variable:
case ECPGt_string:
/*
* we have to use the pointer except for arrays with given
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.49 2009/06/11 14:49:13 momjian Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.50 2009/08/07 10:51:20 meskes Exp $ */
#include "postgres_fe.h"
......@@ -500,7 +500,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
"multilevel pointers (more than 2 levels) are not supported; found %d levels", pointer_len),
pointer_len);
if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char)
if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char && type_enum != ECPGt_string)
mmerror(PARSE_ERROR, ET_FATAL, "pointer to pointer is not supported for this data type");
if (pointer_len > 1 && (atoi(*length) >= 0 || atoi(*dimension) >= 0))
......@@ -539,6 +539,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
break;
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_string:
/* char ** */
if (pointer_len == 2)
{
......
......@@ -13,6 +13,7 @@ int main(void)
{
$int i = 14;
$decimal j, m, n;
$string c[10];
ECPGdebug(1, stderr);
$whenever sqlerror do dosqlprint();
......@@ -20,19 +21,19 @@ int main(void)
$connect to REGRESSDB1;
if (sqlca.sqlcode != 0) exit(1);
$create table test(i int primary key, j int);
$create table test(i int primary key, j int, c text);
/* this INSERT works */
rsetnull(CDECIMALTYPE, (char *)&j);
$insert into test (i, j) values (7, :j);
$insert into test (i, j, c) values (7, :j, 'test ');
$commit;
/* this INSERT should fail because i is a unique column */
$insert into test (i, j) values (7, NUMBER);
$insert into test (i, j, c) values (7, NUMBER, 'a');
printf("INSERT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
if (sqlca.sqlcode != 0) $rollback;
$insert into test (i, j) values (:i, 1);
$insert into test (i, j, c) values (:i, 1, 'a ');
$commit;
/* this will fail (more than one row in subquery) */
......@@ -51,7 +52,7 @@ int main(void)
while (1)
{
$fetch forward c into :i, :j;
$fetch forward c into :i, :j, :c;
if (sqlca.sqlcode == 100) break;
else if (sqlca.sqlcode != 0) printf ("Error: %ld\n", sqlca.sqlcode);
......@@ -62,7 +63,7 @@ int main(void)
int a;
dectoint(&j, &a);
printf("%d %d\n", i, a);
printf("%d %d \"%s\"\n", i, a, c);
}
}
......
......@@ -43,106 +43,112 @@ int main(void)
#line 15 "test_informix.pgc"
#line 16 "test_informix.pgc"
char c [ 10 ] ;
#line 16 "test_informix.pgc"
ECPGdebug(1, stderr);
/* exec sql whenever sqlerror do dosqlprint ( ) ; */
#line 18 "test_informix.pgc"
#line 19 "test_informix.pgc"
{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0);
#line 20 "test_informix.pgc"
#line 21 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 20 "test_informix.pgc"
#line 21 "test_informix.pgc"
if (sqlca.sqlcode != 0) exit(1);
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table test ( i int primary key , j int )", ECPGt_EOIT, ECPGt_EORT);
#line 23 "test_informix.pgc"
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table test ( i int primary key , j int , c text )", ECPGt_EOIT, ECPGt_EORT);
#line 24 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 23 "test_informix.pgc"
#line 24 "test_informix.pgc"
/* this INSERT works */
rsetnull(CDECIMALTYPE, (char *)&j);
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into test ( i , j ) values ( 7 , $1 )",
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into test ( i , j , c ) values ( 7 , $1 , 'test ' )",
ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 27 "test_informix.pgc"
#line 28 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 27 "test_informix.pgc"
#line 28 "test_informix.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");
#line 28 "test_informix.pgc"
#line 29 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 28 "test_informix.pgc"
#line 29 "test_informix.pgc"
/* this INSERT should fail because i is a unique column */
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into test ( i , j ) values ( 7 , 12 )", ECPGt_EOIT, ECPGt_EORT);
#line 31 "test_informix.pgc"
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into test ( i , j , c ) values ( 7 , 12 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
#line 32 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 31 "test_informix.pgc"
#line 32 "test_informix.pgc"
printf("INSERT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
if (sqlca.sqlcode != 0) { ECPGtrans(__LINE__, NULL, "rollback");
#line 33 "test_informix.pgc"
#line 34 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 33 "test_informix.pgc"
#line 34 "test_informix.pgc"
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into test ( i , j ) values ( $1 , 1 )",
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into test ( i , j , c ) values ( $1 , 1 , 'a ' )",
ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 35 "test_informix.pgc"
#line 36 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 35 "test_informix.pgc"
#line 36 "test_informix.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");
#line 36 "test_informix.pgc"
#line 37 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 36 "test_informix.pgc"
#line 37 "test_informix.pgc"
/* this will fail (more than one row in subquery) */
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select i from test where j = ( select j from test )", ECPGt_EOIT, ECPGt_EORT);
#line 39 "test_informix.pgc"
#line 40 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 39 "test_informix.pgc"
#line 40 "test_informix.pgc"
{ ECPGtrans(__LINE__, NULL, "rollback");
#line 40 "test_informix.pgc"
#line 41 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 40 "test_informix.pgc"
#line 41 "test_informix.pgc"
/* this however should be ok */
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select i from test where j = ( select j from test order by i limit 1 )", ECPGt_EOIT, ECPGt_EORT);
#line 43 "test_informix.pgc"
#line 44 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 43 "test_informix.pgc"
#line 44 "test_informix.pgc"
printf("SELECT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
if (sqlca.sqlcode != 0) { ECPGtrans(__LINE__, NULL, "rollback");
#line 45 "test_informix.pgc"
#line 46 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 45 "test_informix.pgc"
#line 46 "test_informix.pgc"
ECPG_informix_set_var( 0, &( i ), __LINE__);\
/* declare c cursor for select * from test where i <= $1 */
#line 47 "test_informix.pgc"
#line 48 "test_informix.pgc"
openit();
......@@ -154,11 +160,13 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_string,(c),(long)10,(long)1,(10)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 54 "test_informix.pgc"
#line 55 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 54 "test_informix.pgc"
#line 55 "test_informix.pgc"
if (sqlca.sqlcode == 100) break;
else if (sqlca.sqlcode != 0) printf ("Error: %ld\n", sqlca.sqlcode);
......@@ -170,7 +178,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
int a;
dectoint(&j, &a);
printf("%d %d\n", i, a);
printf("%d %d \"%s\"\n", i, a, c);
}
}
......@@ -180,53 +188,53 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "delete from test where i = $1 :: decimal",
ECPGt_decimal,&(n),(long)1,(long)1,sizeof(decimal),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 72 "test_informix.pgc"
#line 73 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 72 "test_informix.pgc"
#line 73 "test_informix.pgc"
printf("DELETE: %ld\n", sqlca.sqlcode);
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select 1 from test where i = 14", ECPGt_EOIT, ECPGt_EORT);
#line 75 "test_informix.pgc"
#line 76 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 75 "test_informix.pgc"
#line 76 "test_informix.pgc"
printf("Exists: %ld\n", sqlca.sqlcode);
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select 1 from test where i = 147", ECPGt_EOIT, ECPGt_EORT);
#line 78 "test_informix.pgc"
#line 79 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 78 "test_informix.pgc"
#line 79 "test_informix.pgc"
printf("Does not exist: %ld\n", sqlca.sqlcode);
{ ECPGtrans(__LINE__, NULL, "commit");
#line 81 "test_informix.pgc"
#line 82 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 81 "test_informix.pgc"
#line 82 "test_informix.pgc"
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);
#line 82 "test_informix.pgc"
#line 83 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 82 "test_informix.pgc"
#line 83 "test_informix.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");
#line 83 "test_informix.pgc"
#line 84 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 83 "test_informix.pgc"
#line 84 "test_informix.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
#line 85 "test_informix.pgc"
#line 86 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 85 "test_informix.pgc"
#line 86 "test_informix.pgc"
return 0;
......@@ -237,10 +245,10 @@ static void openit(void)
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare c cursor for select * from test where i <= $1 ",
ECPGt_int,&(*( int *)(ECPG_informix_get_var( 0))),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 92 "test_informix.pgc"
#line 93 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
#line 92 "test_informix.pgc"
#line 93 "test_informix.pgc"
}
doSQLprint: Error: duplicate key value violates unique constraint "test_pkey" on line 31
INSERT: -239=duplicate key value violates unique constraint "test_pkey" on line 31
doSQLprint: Error: more than one row returned by a subquery used as an expression on line 39
doSQLprint: Error: duplicate key value violates unique constraint "test_pkey" on line 32
INSERT: -239=duplicate key value violates unique constraint "test_pkey" on line 32
doSQLprint: Error: more than one row returned by a subquery used as an expression on line 40
SELECT: 0=
7 0
14 1
7 0 "test"
14 1 "a"
DELETE: 100
Exists: 0
Does not exist: 100
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