Applied patch for VPATH builds by Alvaro Herrera <alvherre@commandprompt.com>

Merged dyntest.pgc and dyntest2.pgc.
Hopefully fixed the last Coverity reports (finally)
This commit is contained in:
Michael Meskes 2006-08-13 10:18:31 +00:00
parent b5633943cb
commit ab6aa40b64
18 changed files with 595 additions and 8009 deletions

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.32 2006/08/02 13:43:22 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.33 2006/08/13 10:18:29 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@ -387,8 +387,9 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
ECPGraise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : "<DEFAULT>");
if (host)
ECPGfree(host);
if (port)
ECPGfree(port);
/* port not set yet
* if (port)
* ECPGfree(port); */
if (options)
ECPGfree(options);
if (realname)

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.30 2006/08/09 09:08:31 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.31 2006/08/13 10:18:30 meskes Exp $ */
#include "postgres_fe.h"
#include <ctype.h>
@ -1505,8 +1505,7 @@ numericvar_to_double(numeric *var, double *dp)
return -1;
/*
* strtod seems to not reset errno to 0 in case of success.
* at least on aome architectures
* strtod does not reset errno to 0 in case of success.
*/
errno = 0;
val = strtod(tmp, &endptr);

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.70 2006/08/09 09:08:32 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.71 2006/08/13 10:18:30 meskes Exp $ */
#include "postgres_fe.h"
@ -249,7 +249,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
ind_name,
type->size,
type->u.element,
(ind_type->type == ECPGt_NO_INDICATOR) ? ind_type : ind_type->u.element,
(ind_type == NULL) ? NULL : ((ind_type->type == ECPGt_NO_INDICATOR) ? ind_type : ind_type->u.element),
NULL, prefix, ind_prefix);
break;
default:

View File

@ -1,7 +1,7 @@
subdir = src/interfaces/ecpg/test/compat_informix
top_builddir = ../../../../..
include $(top_builddir)/src/Makefile.global
include ../Makefile.regress
include $(top_srcdir)/$(subdir)/../Makefile.regress
# special informix compatiblity switches
ECPG += -C INFORMIX

View File

@ -1,7 +1,7 @@
subdir = src/interfaces/ecpg/test/complex
top_builddir = ../../../../..
include $(top_builddir)/src/Makefile.global
include ../Makefile.regress
include $(top_srcdir)/$(subdir)/../Makefile.regress
TESTS = test1 test1.c \

View File

@ -1,7 +1,7 @@
subdir = src/interfaces/ecpg/test/connect
top_builddir = ../../../../..
include $(top_builddir)/src/Makefile.global
include ../Makefile.regress
include $(top_srcdir)/$(subdir)/../Makefile.regress
# port number for temp-installation test postmaster
# this is also defined in ../Makefile

View File

@ -1,7 +1,7 @@
subdir = src/interfaces/ecpg/test/errors
top_builddir = ../../../../..
include $(top_builddir)/src/Makefile.global
include ../Makefile.regress
include $(top_srcdir)/$(subdir)/../Makefile.regress
TESTS = init init.c

View File

@ -12,7 +12,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#line 1 "./../../include/sql3types.h"
@ -60,7 +59,7 @@ enum
#endif /* !_ECPG_SQL3TYPES_H */
#line 8 "dyntest.pgc"
#line 7 "dyntest.pgc"
#line 1 "./../../include/sqlca.h"
@ -131,7 +130,7 @@ struct sqlca_t *ECPGget_sqlca(void);
#endif
#line 9 "dyntest.pgc"
#line 8 "dyntest.pgc"
#line 1 "./../regression.h"
@ -141,341 +140,343 @@ struct sqlca_t *ECPGget_sqlca(void);
#line 10 "dyntest.pgc"
#line 9 "dyntest.pgc"
static void error(void)
{ printf("#%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
exit(1);
static void
error (void)
{
printf ("\n#%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
exit (1);
}
int main(int argc,char **argv)
{ /* exec sql begin declare section */
int
main (int argc, char **argv)
{
/* exec sql begin declare section */
#line 19 "dyntest.pgc"
#line 22 "dyntest.pgc"
int COUNT ;
#line 20 "dyntest.pgc"
#line 23 "dyntest.pgc"
int INTVAR ;
#line 21 "dyntest.pgc"
#line 24 "dyntest.pgc"
int INDEX ;
#line 22 "dyntest.pgc"
#line 25 "dyntest.pgc"
int INDICATOR ;
#line 23 "dyntest.pgc"
bool BOOLVAR ;
#line 24 "dyntest.pgc"
#line 26 "dyntest.pgc"
int TYPE , LENGTH , OCTET_LENGTH , PRECISION , SCALE , RETURNED_OCTET_LENGTH ;
#line 25 "dyntest.pgc"
#line 27 "dyntest.pgc"
int DATETIME_INTERVAL_CODE ;
#line 26 "dyntest.pgc"
char NAME [ 120 ] ;
#line 27 "dyntest.pgc"
char STRINGVAR [ 1024 ] ;
#line 28 "dyntest.pgc"
float FLOATVAR ;
char NAME [ 120 ] , BOOLVAR ;
#line 29 "dyntest.pgc"
double DOUBLEVAR ;
char STRINGVAR [ 1024 ] ;
#line 30 "dyntest.pgc"
double DOUBLEVAR ;
#line 31 "dyntest.pgc"
char * QUERY ;
/* exec sql end declare section */
#line 31 "dyntest.pgc"
#line 32 "dyntest.pgc"
int done=0;
int done = 0;
ECPGdebug(1, stderr);
/* exec sql var BOOLVAR is bool */
#line 35 "dyntest.pgc"
QUERY="select rulename, ev_class, ev_attr, ev_type, is_instead, ev_qual from pg_rewrite";
ECPGdebug (1, stderr);
QUERY = "select * from dyntest";
/* exec sql whenever sqlerror do error ( ) ; */
#line 38 "dyntest.pgc"
#line 43 "dyntest.pgc"
ECPGallocate_desc(__LINE__, "MYDESC");
#line 40 "dyntest.pgc"
#line 45 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );
#line 40 "dyntest.pgc"
#line 45 "dyntest.pgc"
{ ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0);
#line 42 "dyntest.pgc"
#line 47 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 42 "dyntest.pgc"
#line 47 "dyntest.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "create table dyntest ( name char ( 14 ) , d float8 , i int , bignumber int8 , b boolean , comment text , day date ) ", ECPGt_EOIT, ECPGt_EORT);
#line 51 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 51 "dyntest.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into dyntest values( 'first entry' , 14.7 , 14 , 123045607890 , true , 'The world''s most advanced open source database.' , '1987-07-14' )", ECPGt_EOIT, ECPGt_EORT);
#line 52 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 52 "dyntest.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into dyntest values( 'second entry' , 1407.87 , 1407 , 987065403210 , false , 'The elephant never forgets.' , '1999-11-5' )", ECPGt_EOIT, ECPGt_EORT);
#line 53 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 53 "dyntest.pgc"
{ ECPGprepare(__LINE__, "MYQUERY" , QUERY);
#line 44 "dyntest.pgc"
#line 55 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 44 "dyntest.pgc"
#line 55 "dyntest.pgc"
/* declare MYCURS cursor for ? */
#line 45 "dyntest.pgc"
#line 56 "dyntest.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "declare MYCURS cursor for ?",
ECPGt_char_variable,(ECPGprepared_statement("MYQUERY")),(long)1,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 47 "dyntest.pgc"
#line 58 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 47 "dyntest.pgc"
#line 58 "dyntest.pgc"
while (1)
{
{ ECPGdo(__LINE__, 0, 1, NULL, "fetch in MYCURS", ECPGt_EOIT,
{
{ ECPGdo(__LINE__, 0, 1, NULL, "fetch in MYCURS", ECPGt_EOIT,
ECPGt_descriptor, "MYDESC", 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 51 "dyntest.pgc"
#line 62 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 51 "dyntest.pgc"
#line 62 "dyntest.pgc"
if (sqlca.sqlcode) break;
if (sqlca.sqlcode)
break;
{ ECPGget_desc_header(__LINE__, "MYDESC", &(COUNT));
{ ECPGget_desc_header(__LINE__, "MYDESC", &(COUNT));
#line 55 "dyntest.pgc"
#line 67 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 55 "dyntest.pgc"
#line 67 "dyntest.pgc"
if (!done)
{
printf("%d Columns\n",COUNT);
for (INDEX=1;INDEX<=COUNT;++INDEX)
{
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_ret_octet,
ECPGt_int,&(RETURNED_OCTET_LENGTH),(long)1,(long)1,sizeof(int), ECPGd_name,
if (!done)
{
printf ("Found %d columns\n", COUNT);
done = 1;
}
for (INDEX = 1; INDEX <= COUNT; ++INDEX)
{
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_indicator,
ECPGt_int,&(INDICATOR),(long)1,(long)1,sizeof(int), ECPGd_name,
ECPGt_char,(NAME),(long)120,(long)1,(120)*sizeof(char), ECPGd_scale,
ECPGt_int,&(SCALE),(long)1,(long)1,sizeof(int), ECPGd_precision,
ECPGt_int,&(PRECISION),(long)1,(long)1,sizeof(int), ECPGd_octet,
ECPGt_int,&(PRECISION),(long)1,(long)1,sizeof(int), ECPGd_ret_octet,
ECPGt_int,&(RETURNED_OCTET_LENGTH),(long)1,(long)1,sizeof(int), ECPGd_octet,
ECPGt_int,&(OCTET_LENGTH),(long)1,(long)1,sizeof(int), ECPGd_length,
ECPGt_int,&(LENGTH),(long)1,(long)1,sizeof(int), ECPGd_type,
ECPGt_int,&(TYPE),(long)1,(long)1,sizeof(int), ECPGd_EODT);
#line 66 "dyntest.pgc"
#line 84 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 66 "dyntest.pgc"
#line 84 "dyntest.pgc"
printf("%s ",NAME);
switch (TYPE)
{ case SQL3_BOOLEAN:
printf("bool ");
break;
case SQL3_NUMERIC:
printf("numeric(%d,%d) ",PRECISION,SCALE);
break;
case SQL3_DECIMAL:
printf("decimal(%d,%d) ",PRECISION,SCALE);
break;
case SQL3_INTEGER:
printf("integer ");
break;
case SQL3_SMALLINT:
printf("smallint ");
break;
case SQL3_FLOAT:
printf("float(%d,%d) ",PRECISION,SCALE);
break;
case SQL3_REAL:
printf("real ");
break;
case SQL3_DOUBLE_PRECISION:
printf("double precision ");
break;
case SQL3_DATE_TIME_TIMESTAMP:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_di_code,
printf ("%2d\t%s (type: %d length: %d precision: %d scale: %d = " , INDEX, NAME, TYPE, LENGTH, PRECISION, SCALE);
switch (TYPE)
{
case SQL3_BOOLEAN:
printf ("bool");
break;
case SQL3_NUMERIC:
printf ("numeric(%d,%d)", PRECISION, SCALE);
break;
case SQL3_DECIMAL:
printf ("decimal(%d,%d)", PRECISION, SCALE);
break;
case SQL3_INTEGER:
printf ("integer");
break;
case SQL3_SMALLINT:
printf ("smallint");
break;
case SQL3_FLOAT:
printf ("float(%d,%d)", PRECISION, SCALE);
break;
case SQL3_REAL:
printf ("real");
break;
case SQL3_DOUBLE_PRECISION:
printf ("double precision");
break;
case SQL3_DATE_TIME_TIMESTAMP:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_di_code,
ECPGt_int,&(DATETIME_INTERVAL_CODE),(long)1,(long)1,sizeof(int), ECPGd_EODT);
#line 95 "dyntest.pgc"
#line 114 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 95 "dyntest.pgc"
#line 114 "dyntest.pgc"
switch(DATETIME_INTERVAL_CODE)
{ case SQL3_DDT_DATE:
printf("date "); break;
case SQL3_DDT_TIME:
printf("time "); break;
case SQL3_DDT_TIMESTAMP:
printf("timestamp "); break;
case SQL3_DDT_TIME_WITH_TIME_ZONE:
printf("time with time zone "); break;
case SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE:
printf("timestamp with time zone "); break;
}
break;
case SQL3_INTERVAL:
printf("interval ");
break;
case SQL3_CHARACTER:
if (LENGTH>0) printf("char(%d) ",LENGTH);
else printf("char(?) ");
break;
case SQL3_CHARACTER_VARYING:
if (LENGTH>0) printf("varchar(%d) ",LENGTH);
else printf("varchar() ");
break;
default:
if (TYPE<0) printf("<OID %d> ",-TYPE);
else printf("<SQL3 %d> ",TYPE);
break;
}
if (OCTET_LENGTH>0) printf("[%d bytes]",OCTET_LENGTH);
putchar('\n');
}
putchar('\n');
done=1;
}
for (INDEX=1;INDEX<=COUNT;++INDEX)
{
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_indicator,
ECPGt_int,&(INDICATOR),(long)1,(long)1,sizeof(int), ECPGd_precision,
ECPGt_int,&(PRECISION),(long)1,(long)1,sizeof(int), ECPGd_scale,
ECPGt_int,&(SCALE),(long)1,(long)1,sizeof(int), ECPGd_type,
ECPGt_int,&(TYPE),(long)1,(long)1,sizeof(int), ECPGd_EODT);
#line 136 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 136 "dyntest.pgc"
if (INDICATOR==-1) printf("NULL");
else switch (TYPE)
{ case SQL3_BOOLEAN:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
switch (DATETIME_INTERVAL_CODE)
{
case SQL3_DDT_DATE:
printf ("date");
break;
case SQL3_DDT_TIME:
printf ("time");
break;
case SQL3_DDT_TIMESTAMP:
printf ("timestamp");
break;
case SQL3_DDT_TIME_WITH_TIME_ZONE:
printf ("time with time zone");
break;
case SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE:
printf ("timestamp with time zone");
break;
}
break;
case SQL3_INTERVAL:
printf ("interval");
break;
case SQL3_CHARACTER:
if (LENGTH > 0)
printf ("char(%d)", LENGTH);
else
printf ("text");
break;
case SQL3_CHARACTER_VARYING:
if (LENGTH > 0)
printf ("varchar(%d)", LENGTH);
else
printf ("varchar()");
break;
default:
if (TYPE < 0)
printf ("<OID %d>", -TYPE);
else
printf ("<SQL3 %d>", TYPE);
break;
}
printf (")\n\toctet_length: %d returned_octet_length: %d)\n\t= ",
OCTET_LENGTH, RETURNED_OCTET_LENGTH);
if (INDICATOR == -1)
printf ("NULL\n");
else
switch (TYPE)
{
case SQL3_BOOLEAN:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_bool,&(BOOLVAR),(long)1,(long)1,sizeof(bool), ECPGd_EODT);
#line 140 "dyntest.pgc"
#line 164 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 140 "dyntest.pgc"
#line 164 "dyntest.pgc"
printf(BOOLVAR?"true":"false");
break;
case SQL3_NUMERIC:
case SQL3_DECIMAL:
if (SCALE==0) /* we might even print leading zeros "%0*d" */
{ { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
printf ("%s\n", BOOLVAR ? "true" : "false");
break;
case SQL3_INTEGER:
case SQL3_SMALLINT:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_int,&(INTVAR),(long)1,(long)1,sizeof(int), ECPGd_EODT);
#line 146 "dyntest.pgc"
#line 169 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 146 "dyntest.pgc"
#line 169 "dyntest.pgc"
printf("%*d",PRECISION,INTVAR);
}
else
{ { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_float,&(FLOATVAR),(long)1,(long)1,sizeof(float), ECPGd_EODT);
#line 150 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 150 "dyntest.pgc"
printf("%*.*f",PRECISION+1,SCALE,FLOATVAR);
}
break;
case SQL3_INTEGER:
case SQL3_SMALLINT:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_int,&(INTVAR),(long)1,(long)1,sizeof(int), ECPGd_EODT);
#line 156 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 156 "dyntest.pgc"
printf("%d",INTVAR);
break;
case SQL3_FLOAT:
case SQL3_REAL:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_float,&(FLOATVAR),(long)1,(long)1,sizeof(float), ECPGd_EODT);
#line 161 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 161 "dyntest.pgc"
printf("%f",FLOATVAR);
break;
case SQL3_DOUBLE_PRECISION:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
printf ("%d\n", INTVAR);
break;
case SQL3_DOUBLE_PRECISION:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_double,&(DOUBLEVAR),(long)1,(long)1,sizeof(double), ECPGd_EODT);
#line 165 "dyntest.pgc"
#line 173 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 165 "dyntest.pgc"
#line 173 "dyntest.pgc"
printf("%f",DOUBLEVAR);
break;
case SQL3_DATE_TIME_TIMESTAMP:
case SQL3_INTERVAL:
case SQL3_CHARACTER:
case SQL3_CHARACTER_VARYING:
default:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
printf ("%.*f\n", PRECISION, DOUBLEVAR);
break;
case SQL3_DATE_TIME_TIMESTAMP:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_di_code,
ECPGt_int,&(DATETIME_INTERVAL_CODE),(long)1,(long)1,sizeof(int), ECPGd_EODT);
#line 179 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 179 "dyntest.pgc"
printf ("%d \"%s\"\n", DATETIME_INTERVAL_CODE, STRINGVAR);
break;
case SQL3_CHARACTER:
case SQL3_CHARACTER_VARYING:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_EODT);
#line 173 "dyntest.pgc"
#line 184 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 173 "dyntest.pgc"
#line 184 "dyntest.pgc"
printf("'%s'",STRINGVAR);
break;
}
putchar('|');
}
putchar('\n');
}
printf ("\"%s\"\n", STRINGVAR);
break;
default:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_EODT);
#line 188 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 188 "dyntest.pgc"
printf ("<\"%s\">\n", STRINGVAR);
break;
}
}
}
{ ECPGdo(__LINE__, 0, 1, NULL, "close MYCURS", ECPGt_EOIT, ECPGt_EORT);
#line 182 "dyntest.pgc"
#line 195 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 182 "dyntest.pgc"
#line 195 "dyntest.pgc"
ECPGdeallocate_desc(__LINE__, "MYDESC");
#line 183 "dyntest.pgc"
#line 197 "dyntest.pgc"
if (sqlca.sqlcode < 0) error ( );
#line 183 "dyntest.pgc"
#line 197 "dyntest.pgc"
/* no exec sql disconnect; */
return 0;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,81 +1,43 @@
6 Columns
rulename <OID 19> [64 bytes]
ev_class <OID 26> [4 bytes]
ev_attr smallint [2 bytes]
ev_type <OID 18> [1 bytes]
is_instead bool [1 bytes]
ev_qual char(?)
'_RETURN'|'10297'|-1|'1'|true|'<>'|
'_RETURN'|'10300'|-1|'1'|true|'<>'|
'_RETURN'|'10303'|-1|'1'|true|'<>'|
'_RETURN'|'10306'|-1|'1'|true|'<>'|
'_RETURN'|'10309'|-1|'1'|true|'<>'|
'_RETURN'|'10313'|-1|'1'|true|'<>'|
'_RETURN'|'10316'|-1|'1'|true|'<>'|
'_RETURN'|'10320'|-1|'1'|true|'<>'|
'_RETURN'|'10324'|-1|'1'|true|'<>'|
'_RETURN'|'10328'|-1|'1'|true|'<>'|
'_RETURN'|'10331'|-1|'1'|true|'<>'|
'_RETURN'|'10334'|-1|'1'|true|'<>'|
'_RETURN'|'10337'|-1|'1'|true|'<>'|
'_RETURN'|'10340'|-1|'1'|true|'<>'|
'pg_settings_u'|'10340'|-1|'2'|false|'{OPEXPR :opno 98 :opfuncid 0 :opresulttype 16 :opretset false :args ({VAR :varno 2 :varattno 1 :vartype 25 :vartypmod -1 :varlevelsup 0 :varnoold 2 :varoattno 1} {VAR :varno 1 :varattno 1 :vartype 25 :vartypmod -1 :varlevelsup 0 :varnoold 1 :varoattno 1})}'|
'pg_settings_n'|'10340'|-1|'2'|true|'<>'|
'_RETURN'|'10345'|-1|'1'|true|'<>'|
'_RETURN'|'10348'|-1|'1'|true|'<>'|
'_RETURN'|'10352'|-1|'1'|true|'<>'|
'_RETURN'|'10355'|-1|'1'|true|'<>'|
'_RETURN'|'10358'|-1|'1'|true|'<>'|
'_RETURN'|'10362'|-1|'1'|true|'<>'|
'_RETURN'|'10365'|-1|'1'|true|'<>'|
'_RETURN'|'10368'|-1|'1'|true|'<>'|
'_RETURN'|'10372'|-1|'1'|true|'<>'|
'_RETURN'|'10375'|-1|'1'|true|'<>'|
'_RETURN'|'10378'|-1|'1'|true|'<>'|
'_RETURN'|'10382'|-1|'1'|true|'<>'|
'_RETURN'|'10385'|-1|'1'|true|'<>'|
'_RETURN'|'10388'|-1|'1'|true|'<>'|
'_RETURN'|'10391'|-1|'1'|true|'<>'|
'_RETURN'|'10394'|-1|'1'|true|'<>'|
'_RETURN'|'10397'|-1|'1'|true|'<>'|
'_RETURN'|'10400'|-1|'1'|true|'<>'|
'_RETURN'|'10634'|-1|'1'|true|'<>'|
'_RETURN'|'10638'|-1|'1'|true|'<>'|
'_RETURN'|'10641'|-1|'1'|true|'<>'|
'_RETURN'|'10644'|-1|'1'|true|'<>'|
'_RETURN'|'10648'|-1|'1'|true|'<>'|
'_RETURN'|'10651'|-1|'1'|true|'<>'|
'_RETURN'|'10655'|-1|'1'|true|'<>'|
'_RETURN'|'10659'|-1|'1'|true|'<>'|
'_RETURN'|'10663'|-1|'1'|true|'<>'|
'_RETURN'|'10667'|-1|'1'|true|'<>'|
'_RETURN'|'10671'|-1|'1'|true|'<>'|
'_RETURN'|'10675'|-1|'1'|true|'<>'|
'_RETURN'|'10678'|-1|'1'|true|'<>'|
'_RETURN'|'10681'|-1|'1'|true|'<>'|
'_RETURN'|'10684'|-1|'1'|true|'<>'|
'_RETURN'|'10688'|-1|'1'|true|'<>'|
'_RETURN'|'10691'|-1|'1'|true|'<>'|
'_RETURN'|'10695'|-1|'1'|true|'<>'|
'_RETURN'|'10699'|-1|'1'|true|'<>'|
'_RETURN'|'10703'|-1|'1'|true|'<>'|
'_RETURN'|'10707'|-1|'1'|true|'<>'|
'_RETURN'|'10711'|-1|'1'|true|'<>'|
'_RETURN'|'10715'|-1|'1'|true|'<>'|
'_RETURN'|'10718'|-1|'1'|true|'<>'|
'_RETURN'|'10722'|-1|'1'|true|'<>'|
'_RETURN'|'10726'|-1|'1'|true|'<>'|
'_RETURN'|'10729'|-1|'1'|true|'<>'|
'_RETURN'|'10767'|-1|'1'|true|'<>'|
'_RETURN'|'10771'|-1|'1'|true|'<>'|
'_RETURN'|'10775'|-1|'1'|true|'<>'|
'_RETURN'|'10779'|-1|'1'|true|'<>'|
'_RETURN'|'10782'|-1|'1'|true|'<>'|
'_RETURN'|'10786'|-1|'1'|true|'<>'|
'_RETURN'|'10789'|-1|'1'|true|'<>'|
'_RETURN'|'10793'|-1|'1'|true|'<>'|
'_RETURN'|'10797'|-1|'1'|true|'<>'|
'_RETURN'|'10801'|-1|'1'|true|'<>'|
'_RETURN'|'10805'|-1|'1'|true|'<>'|
'_RETURN'|'10809'|-1|'1'|true|'<>'|
Found 7 columns
1 name (type: 1 length: 14 precision: 0 scale: 14 = char(14))
octet_length: -1 returned_octet_length: 14)
= "first entry "
2 d (type: 8 length: -5 precision: -1 scale: 65531 = double precision)
octet_length: 8 returned_octet_length: 4)
= 14.700000
3 i (type: 4 length: -5 precision: -1 scale: 65531 = integer)
octet_length: 4 returned_octet_length: 2)
= 14
4 bignumber (type: -20 length: -5 precision: -1 scale: 65531 = <OID 20>)
octet_length: 8 returned_octet_length: 12)
= <"123045607890">
5 b (type: 16 length: -5 precision: -1 scale: 65531 = bool)
octet_length: 1 returned_octet_length: 1)
= true
6 comment (type: 1 length: -5 precision: -1 scale: 65531 = text)
octet_length: -1 returned_octet_length: 47)
= "The world's most advanced open source database."
7 day (type: 9 length: -5 precision: -1 scale: 65531 = date)
octet_length: 4 returned_octet_length: 10)
= 1 "07-14-1987"
1 name (type: 1 length: 14 precision: 0 scale: 14 = char(14))
octet_length: -1 returned_octet_length: 14)
= "second entry "
2 d (type: 8 length: -5 precision: -1 scale: 65531 = double precision)
octet_length: 8 returned_octet_length: 7)
= 1407.870000
3 i (type: 4 length: -5 precision: -1 scale: 65531 = integer)
octet_length: 4 returned_octet_length: 4)
= 1407
4 bignumber (type: -20 length: -5 precision: -1 scale: 65531 = <OID 20>)
octet_length: 8 returned_octet_length: 12)
= <"987065403210">
5 b (type: 16 length: -5 precision: -1 scale: 65531 = bool)
octet_length: 1 returned_octet_length: 1)
= false
6 comment (type: 1 length: -5 precision: -1 scale: 65531 = text)
octet_length: -1 returned_octet_length: 27)
= "The elephant never forgets."
7 day (type: 9 length: -5 precision: -1 scale: 65531 = date)
octet_length: 4 returned_octet_length: 10)
= 1 "11-05-1999"

View File

@ -1,402 +0,0 @@
/* Processed by ecpg (4.2.1) */
/* These include files are added by the preprocessor */
#include <ecpgtype.h>
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
/* End of automatic include section */
#line 1 "dyntest2.pgc"
/* dynamic SQL test program
*/
#include <stdio.h>
#include <stdlib.h>
#line 1 "./../../include/sql3types.h"
#ifndef _ECPG_SQL3TYPES_H
#define _ECPG_SQL3TYPES_H
/* SQL3 dynamic type codes */
/* chapter 13.1 table 2: Codes used for SQL data types in Dynamic SQL */
enum
{
SQL3_CHARACTER = 1,
SQL3_NUMERIC,
SQL3_DECIMAL,
SQL3_INTEGER,
SQL3_SMALLINT,
SQL3_FLOAT,
SQL3_REAL,
SQL3_DOUBLE_PRECISION,
SQL3_DATE_TIME_TIMESTAMP,
SQL3_INTERVAL, /* 10 */
SQL3_CHARACTER_VARYING = 12,
SQL3_ENUMERATED,
SQL3_BIT,
SQL3_BIT_VARYING,
SQL3_BOOLEAN,
SQL3_abstract
/* the rest is xLOB stuff */
};
/* chapter 13.1 table 3: Codes associated with datetime data types in Dynamic SQL */
enum
{
SQL3_DDT_DATE = 1,
SQL3_DDT_TIME,
SQL3_DDT_TIMESTAMP,
SQL3_DDT_TIME_WITH_TIME_ZONE,
SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE,
SQL3_DDT_ILLEGAL /* not a datetime data type (not part of
* standard) */
};
#endif /* !_ECPG_SQL3TYPES_H */
#line 7 "dyntest2.pgc"
#line 1 "./../../include/sqlca.h"
#ifndef POSTGRES_SQLCA_H
#define POSTGRES_SQLCA_H
#ifndef DLLIMPORT
#if defined(WIN32) || defined(__CYGWIN__)
#define DLLIMPORT __declspec (dllimport)
#else
#define DLLIMPORT
#endif /* __CYGWIN__ */
#endif /* DLLIMPORT */
#define SQLERRMC_LEN 150
#ifdef __cplusplus
extern "C"
{
#endif
struct sqlca_t
{
char sqlcaid[8];
long sqlabc;
long sqlcode;
struct
{
int sqlerrml;
char sqlerrmc[SQLERRMC_LEN];
} sqlerrm;
char sqlerrp[8];
long sqlerrd[6];
/* Element 0: empty */
/* 1: OID of processed tuple if applicable */
/* 2: number of rows processed */
/* after an INSERT, UPDATE or */
/* DELETE statement */
/* 3: empty */
/* 4: empty */
/* 5: empty */
char sqlwarn[8];
/* Element 0: set to 'W' if at least one other is 'W' */
/* 1: if 'W' at least one character string */
/* value was truncated when it was */
/* stored into a host variable. */
/*
* 2: if 'W' a (hopefully) non-fatal notice occurred
*/ /* 3: empty */
/* 4: empty */
/* 5: empty */
/* 6: empty */
/* 7: empty */
char sqlstate[5];
};
struct sqlca_t *ECPGget_sqlca(void);
#ifndef POSTGRES_ECPG_INTERNAL
#define sqlca (*ECPGget_sqlca())
#endif
#ifdef __cplusplus
}
#endif
#endif
#line 8 "dyntest2.pgc"
#line 1 "./../regression.h"
#line 9 "dyntest2.pgc"
static void error(void)
{
printf("\n#%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
exit(1);
}
int main(int argc,char **argv)
{
/* exec sql begin declare section */
#line 20 "dyntest2.pgc"
int COUNT ;
#line 21 "dyntest2.pgc"
int INTVAR ;
#line 22 "dyntest2.pgc"
int INDEX ;
#line 23 "dyntest2.pgc"
int INDICATOR ;
#line 24 "dyntest2.pgc"
int TYPE , LENGTH , OCTET_LENGTH , PRECISION , SCALE , RETURNED_OCTET_LENGTH ;
#line 25 "dyntest2.pgc"
int DATETIME_INTERVAL_CODE ;
#line 26 "dyntest2.pgc"
char NAME [ 120 ] , BOOLVAR ;
#line 27 "dyntest2.pgc"
char STRINGVAR [ 1024 ] ;
#line 28 "dyntest2.pgc"
double DOUBLEVAR ;
#line 29 "dyntest2.pgc"
char * QUERY ;
/* exec sql end declare section */
#line 30 "dyntest2.pgc"
int done=0;
/* exec sql var BOOLVAR is bool */
#line 33 "dyntest2.pgc"
ECPGdebug(1, stderr);
QUERY="select * from dyntest";
/* exec sql whenever sqlerror do error ( ) ; */
#line 39 "dyntest2.pgc"
ECPGallocate_desc(__LINE__, "MYDESC");
#line 41 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );
#line 41 "dyntest2.pgc"
{ ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0);
#line 43 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 43 "dyntest2.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "create table dyntest ( name char ( 14 ) , d float8 , i int , bignumber int8 , b boolean , comment text , day date ) ", ECPGt_EOIT, ECPGt_EORT);
#line 45 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 45 "dyntest2.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into dyntest values( 'first entry' , 14.7 , 14 , 123045607890 , true , 'The world''s most advanced open source database.' , '1987-07-14' )", ECPGt_EOIT, ECPGt_EORT);
#line 46 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 46 "dyntest2.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into dyntest values( 'second entry' , 1407.87 , 1407 , 987065403210 , false , 'The elephant never forgets.' , '1999-11-5' )", ECPGt_EOIT, ECPGt_EORT);
#line 47 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 47 "dyntest2.pgc"
{ ECPGprepare(__LINE__, "MYQUERY" , QUERY);
#line 49 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 49 "dyntest2.pgc"
/* declare MYCURS cursor for ? */
#line 50 "dyntest2.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "declare MYCURS cursor for ?",
ECPGt_char_variable,(ECPGprepared_statement("MYQUERY")),(long)1,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 52 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 52 "dyntest2.pgc"
while (1)
{
{ ECPGdo(__LINE__, 0, 1, NULL, "fetch in MYCURS", ECPGt_EOIT,
ECPGt_descriptor, "MYDESC", 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 56 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 56 "dyntest2.pgc"
if (sqlca.sqlcode) break;
{ ECPGget_desc_header(__LINE__, "MYDESC", &(COUNT));
#line 60 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 60 "dyntest2.pgc"
if (!done)
{
printf("Count %d\n",COUNT);
done=1;
}
for (INDEX=1;INDEX<=COUNT;++INDEX)
{
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_indicator,
ECPGt_int,&(INDICATOR),(long)1,(long)1,sizeof(int), ECPGd_name,
ECPGt_char,(NAME),(long)120,(long)1,(120)*sizeof(char), ECPGd_scale,
ECPGt_int,&(SCALE),(long)1,(long)1,sizeof(int), ECPGd_precision,
ECPGt_int,&(PRECISION),(long)1,(long)1,sizeof(int), ECPGd_ret_octet,
ECPGt_int,&(RETURNED_OCTET_LENGTH),(long)1,(long)1,sizeof(int), ECPGd_octet,
ECPGt_int,&(OCTET_LENGTH),(long)1,(long)1,sizeof(int), ECPGd_length,
ECPGt_int,&(LENGTH),(long)1,(long)1,sizeof(int), ECPGd_type,
ECPGt_int,&(TYPE),(long)1,(long)1,sizeof(int), ECPGd_EODT);
#line 74 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 74 "dyntest2.pgc"
printf("%2d\t%s (type: %d length: %d precision: %d scale: %d\n"
"\toctet_length: %d returned_octet_length: %d)\n\t= "
,INDEX,NAME,TYPE,LENGTH,PRECISION,SCALE
,OCTET_LENGTH,RETURNED_OCTET_LENGTH);
if (INDICATOR==-1) printf("NULL\n");
else switch (TYPE)
{
case SQL3_BOOLEAN:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_bool,&(BOOLVAR),(long)1,(long)1,sizeof(bool), ECPGd_EODT);
#line 83 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 83 "dyntest2.pgc"
printf("%s\n",BOOLVAR ? "true":"false");
break;
case SQL3_INTEGER:
case SQL3_SMALLINT:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_int,&(INTVAR),(long)1,(long)1,sizeof(int), ECPGd_EODT);
#line 88 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 88 "dyntest2.pgc"
printf("%d\n",INTVAR);
break;
case SQL3_DOUBLE_PRECISION:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_double,&(DOUBLEVAR),(long)1,(long)1,sizeof(double), ECPGd_EODT);
#line 92 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 92 "dyntest2.pgc"
printf("%.*f\n",PRECISION,DOUBLEVAR);
break;
case SQL3_DATE_TIME_TIMESTAMP:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_di_code,
ECPGt_int,&(DATETIME_INTERVAL_CODE),(long)1,(long)1,sizeof(int), ECPGd_EODT);
#line 98 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 98 "dyntest2.pgc"
printf("%d \"%s\"\n",DATETIME_INTERVAL_CODE,STRINGVAR);
break;
case SQL3_CHARACTER:
case SQL3_CHARACTER_VARYING:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_EODT);
#line 103 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 103 "dyntest2.pgc"
printf("\"%s\"\n",STRINGVAR);
break;
default:
{ ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_EODT);
#line 107 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 107 "dyntest2.pgc"
printf("<\"%s\">\n",STRINGVAR);
break;
}
}
}
{ ECPGdo(__LINE__, 0, 1, NULL, "close MYCURS", ECPGt_EOIT, ECPGt_EORT);
#line 114 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );}
#line 114 "dyntest2.pgc"
ECPGdeallocate_desc(__LINE__, "MYDESC");
#line 116 "dyntest2.pgc"
if (sqlca.sqlcode < 0) error ( );
#line 116 "dyntest2.pgc"
return 0;
}

View File

@ -1,360 +0,0 @@
[NO_PID]: ECPGdebug: set to 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 45: QUERY: create table dyntest ( name char ( 14 ) , d float8 , i int , bignumber int8 , b boolean , comment text , day date ) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 45 Ok: CREATE TABLE
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 46: QUERY: insert into dyntest values( 'first entry' , 14.7 , 14 , 123045607890 , true , 'The world''s most advanced open source database.' , '1987-07-14' ) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 46 Ok: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 47: QUERY: insert into dyntest values( 'second entry' , 1407.87 , 1407 , 987065403210 , false , 'The elephant never forgets.' , '1999-11-5' ) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 47 Ok: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGprepare line 49: QUERY: select * from dyntest
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 52: QUERY: declare MYCURS cursor for select * from dyntest on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 52 Ok: DECLARE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 56: QUERY: fetch in MYCURS on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 56: Correctly got 1 tuples with 7 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute putting result (1 tuples) into descriptor 'MYDESC'
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc_header: found 7 attributes.
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = name
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 14
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 14
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = 14
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 103: RESULT: first entry offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 2
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = d
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 65531
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = 8
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = -5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 8
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 2
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 92: RESULT: 14.7 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 3
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = i
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 65531
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 2
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = -5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 3
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 88: RESULT: 14 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = bignumber
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 65531
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 12
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = 8
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = -5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = -20
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 107: RESULT: 123045607890 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = b
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 65531
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = -5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 16
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 83: RESULT: t offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 6
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = comment
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 65531
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 47
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = -5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 6
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 103: RESULT: The world's most advanced open source database. offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 7
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = day
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 65531
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 10
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = -5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 9
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 7
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 96: RESULT: 07-14-1987 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 56: QUERY: fetch in MYCURS on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 56: Correctly got 1 tuples with 7 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute putting result (1 tuples) into descriptor 'MYDESC'
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc_header: found 7 attributes.
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = name
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 14
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 14
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = 14
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 103: RESULT: second entry offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 2
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = d
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 65531
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 7
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = 8
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = -5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 8
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 2
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 92: RESULT: 1407.87 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 3
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = i
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 65531
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = -5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 3
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 88: RESULT: 1407 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = bignumber
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 65531
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 12
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = 8
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = -5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = -20
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 107: RESULT: 987065403210 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = b
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 65531
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = -5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 16
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 83: RESULT: f offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 6
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = comment
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 65531
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 27
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = -5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 6
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 103: RESULT: The elephant never forgets. offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 7
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: NAME = day
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: SCALE = 65531
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: PRECISION = -1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: RETURNED[0] = 10
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: OCTET_LENGTH = 4
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: LENGTH = -5
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 9
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: INDICATOR[0] = 0
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: reading items for tuple 7
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_desc: TYPE = 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 96: RESULT: 11-05-1999 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 56: QUERY: fetch in MYCURS on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 56: Correctly got 0 tuples with 7 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: raising sqlcode 100 in line 56, 'No data found in line 56.'.
[NO_PID]: sqlca: code: 100, state: 02000
[NO_PID]: ECPGexecute line 114: QUERY: close MYCURS on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 114 Ok: CLOSE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000

View File

@ -1,43 +0,0 @@
Count 7
1 name (type: 1 length: 14 precision: 0 scale: 14
octet_length: -1 returned_octet_length: 14)
= "first entry "
2 d (type: 8 length: -5 precision: -1 scale: 65531
octet_length: 8 returned_octet_length: 4)
= 14.700000
3 i (type: 4 length: -5 precision: -1 scale: 65531
octet_length: 4 returned_octet_length: 2)
= 14
4 bignumber (type: -20 length: -5 precision: -1 scale: 65531
octet_length: 8 returned_octet_length: 12)
= <"123045607890">
5 b (type: 16 length: -5 precision: -1 scale: 65531
octet_length: 1 returned_octet_length: 1)
= true
6 comment (type: 1 length: -5 precision: -1 scale: 65531
octet_length: -1 returned_octet_length: 47)
= "The world's most advanced open source database."
7 day (type: 9 length: -5 precision: -1 scale: 65531
octet_length: 4 returned_octet_length: 10)
= 1 "07-14-1987"
1 name (type: 1 length: 14 precision: 0 scale: 14
octet_length: -1 returned_octet_length: 14)
= "second entry "
2 d (type: 8 length: -5 precision: -1 scale: 65531
octet_length: 8 returned_octet_length: 7)
= 1407.870000
3 i (type: 4 length: -5 precision: -1 scale: 65531
octet_length: 4 returned_octet_length: 4)
= 1407
4 bignumber (type: -20 length: -5 precision: -1 scale: 65531
octet_length: 8 returned_octet_length: 12)
= <"987065403210">
5 b (type: 16 length: -5 precision: -1 scale: 65531
octet_length: 1 returned_octet_length: 1)
= false
6 comment (type: 1 length: -5 precision: -1 scale: 65531
octet_length: -1 returned_octet_length: 27)
= "The elephant never forgets."
7 day (type: 9 length: -5 precision: -1 scale: 65531
octet_length: 4 returned_octet_length: 10)
= 1 "11-05-1999"

View File

@ -1,7 +1,7 @@
subdir = src/interfaces/ecpg/test/pgtypeslib
top_builddir = ../../../../..
include $(top_builddir)/src/Makefile.global
include ../Makefile.regress
include $(top_srcdir)/$(subdir)/../Makefile.regress
TESTS = dt_test dt_test.c \
dt_test2 dt_test2.c \

View File

@ -1,11 +1,10 @@
subdir = src/interfaces/ecpg/test/sql
top_builddir = ../../../../..
include $(top_builddir)/src/Makefile.global
include ../Makefile.regress
include $(top_srcdir)/$(subdir)/../Makefile.regress
TESTS = define define.c \
dyntest dyntest.c \
dyntest2 dyntest2.c \
code100 code100.c \
desc desc.c \
dynalloc dynalloc.c \

View File

@ -3,186 +3,198 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
exec sql include sql3types;
exec sql include sqlca;
exec sql include ../regression;
static void error(void)
{ printf("#%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
exit(1);
static void
error (void)
{
printf ("\n#%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
exit (1);
}
int main(int argc,char **argv)
{ exec sql begin declare section;
int
main (int argc, char **argv)
{
exec sql begin declare section;
int COUNT;
int INTVAR;
int INDEX;
int INDICATOR;
bool BOOLVAR;
int TYPE,LENGTH,OCTET_LENGTH,PRECISION,SCALE,RETURNED_OCTET_LENGTH;
int TYPE, LENGTH, OCTET_LENGTH, PRECISION, SCALE, RETURNED_OCTET_LENGTH;
int DATETIME_INTERVAL_CODE;
char NAME[120];
char NAME[120], BOOLVAR;
char STRINGVAR[1024];
float FLOATVAR;
double DOUBLEVAR;
char *QUERY;
exec sql end declare section;
int done=0;
int done = 0;
ECPGdebug(1, stderr);
exec sql var BOOLVAR is bool;
QUERY="select rulename, ev_class, ev_attr, ev_type, is_instead, ev_qual from pg_rewrite";
ECPGdebug (1, stderr);
exec sql whenever sqlerror do error();
QUERY = "select * from dyntest";
exec sql whenever sqlerror
do
error ();
exec sql allocate descriptor MYDESC;
exec sql connect to REGRESSDB1;
exec sql prepare MYQUERY from :QUERY;
exec sql create table dyntest (name char (14), d float8, i int,
bignumber int8, b boolean, comment text,
day date);
exec sql insert into dyntest values ('first entry', 14.7, 14, 123045607890, true, 'The world''''s most advanced open source database.', '1987-07-14');
exec sql insert into dyntest values ('second entry', 1407.87, 1407, 987065403210, false, 'The elephant never forgets.', '1999-11-5');
exec sql prepare MYQUERY from:QUERY;
exec sql declare MYCURS cursor for MYQUERY;
exec sql open MYCURS;
while (1)
{
exec sql fetch in MYCURS into sql descriptor MYDESC;
{
exec sql fetch in MYCURS into sql descriptor MYDESC;
if (sqlca.sqlcode) break;
if (sqlca.sqlcode)
break;
exec sql get descriptor MYDESC :COUNT = count;
if (!done)
{
printf("%d Columns\n",COUNT);
for (INDEX=1;INDEX<=COUNT;++INDEX)
{
exec sql get descriptor MYDESC value :INDEX
:TYPE = type,
:LENGTH = length, :OCTET_LENGTH=octet_length,
:PRECISION = precision, :SCALE=scale,
:NAME=name,
:RETURNED_OCTET_LENGTH=returned_octet_length;
printf("%s ",NAME);
switch (TYPE)
{ case SQL3_BOOLEAN:
printf("bool ");
break;
case SQL3_NUMERIC:
printf("numeric(%d,%d) ",PRECISION,SCALE);
break;
case SQL3_DECIMAL:
printf("decimal(%d,%d) ",PRECISION,SCALE);
break;
case SQL3_INTEGER:
printf("integer ");
break;
case SQL3_SMALLINT:
printf("smallint ");
break;
case SQL3_FLOAT:
printf("float(%d,%d) ",PRECISION,SCALE);
break;
case SQL3_REAL:
printf("real ");
break;
case SQL3_DOUBLE_PRECISION:
printf("double precision ");
break;
case SQL3_DATE_TIME_TIMESTAMP:
exec sql get descriptor MYDESC value :INDEX
:DATETIME_INTERVAL_CODE=datetime_interval_code;
switch(DATETIME_INTERVAL_CODE)
{ case SQL3_DDT_DATE:
printf("date "); break;
case SQL3_DDT_TIME:
printf("time "); break;
case SQL3_DDT_TIMESTAMP:
printf("timestamp "); break;
case SQL3_DDT_TIME_WITH_TIME_ZONE:
printf("time with time zone "); break;
case SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE:
printf("timestamp with time zone "); break;
}
break;
case SQL3_INTERVAL:
printf("interval ");
break;
case SQL3_CHARACTER:
if (LENGTH>0) printf("char(%d) ",LENGTH);
else printf("char(?) ");
break;
case SQL3_CHARACTER_VARYING:
if (LENGTH>0) printf("varchar(%d) ",LENGTH);
else printf("varchar() ");
break;
default:
if (TYPE<0) printf("<OID %d> ",-TYPE);
else printf("<SQL3 %d> ",TYPE);
break;
}
if (OCTET_LENGTH>0) printf("[%d bytes]",OCTET_LENGTH);
putchar('\n');
}
putchar('\n');
done=1;
}
exec sql get descriptor MYDESC:COUNT = count;
if (!done)
{
printf ("Found %d columns\n", COUNT);
done = 1;
}
for (INDEX=1;INDEX<=COUNT;++INDEX)
{
exec sql get descriptor MYDESC value :INDEX
:TYPE = type, :SCALE=scale, :PRECISION = precision,
:INDICATOR=indicator;
if (INDICATOR==-1) printf("NULL");
else switch (TYPE)
{ case SQL3_BOOLEAN:
exec sql get descriptor MYDESC value :INDEX :BOOLVAR=data;
printf(BOOLVAR?"true":"false");
break;
case SQL3_NUMERIC:
case SQL3_DECIMAL:
if (SCALE==0) /* we might even print leading zeros "%0*d" */
{ exec sql get descriptor MYDESC value :INDEX :INTVAR=data;
printf("%*d",PRECISION,INTVAR);
}
else
{ exec sql get descriptor MYDESC value :INDEX :FLOATVAR=data;
printf("%*.*f",PRECISION+1,SCALE,FLOATVAR);
}
break;
case SQL3_INTEGER:
case SQL3_SMALLINT:
exec sql get descriptor MYDESC value :INDEX :INTVAR=data;
printf("%d",INTVAR);
break;
case SQL3_FLOAT:
case SQL3_REAL:
exec sql get descriptor MYDESC value :INDEX :FLOATVAR=data;
printf("%f",FLOATVAR);
break;
case SQL3_DOUBLE_PRECISION:
exec sql get descriptor MYDESC value :INDEX :DOUBLEVAR=data;
printf("%f",DOUBLEVAR);
break;
case SQL3_DATE_TIME_TIMESTAMP:
case SQL3_INTERVAL:
case SQL3_CHARACTER:
case SQL3_CHARACTER_VARYING:
default:
exec sql get descriptor MYDESC value :INDEX :STRINGVAR=data;
printf("'%s'",STRINGVAR);
break;
}
putchar('|');
}
putchar('\n');
}
for (INDEX = 1; INDEX <= COUNT; ++INDEX)
{
exec sql get descriptor MYDESC value :INDEX
:TYPE = type,
:LENGTH = length,
:OCTET_LENGTH = octet_length,
:RETURNED_OCTET_LENGTH = returned_octet_length,
:PRECISION = precision,
:SCALE = scale,
:NAME = name,
:INDICATOR = indicator;
printf ("%2d\t%s (type: %d length: %d precision: %d scale: %d = " , INDEX, NAME, TYPE, LENGTH, PRECISION, SCALE);
switch (TYPE)
{
case SQL3_BOOLEAN:
printf ("bool");
break;
case SQL3_NUMERIC:
printf ("numeric(%d,%d)", PRECISION, SCALE);
break;
case SQL3_DECIMAL:
printf ("decimal(%d,%d)", PRECISION, SCALE);
break;
case SQL3_INTEGER:
printf ("integer");
break;
case SQL3_SMALLINT:
printf ("smallint");
break;
case SQL3_FLOAT:
printf ("float(%d,%d)", PRECISION, SCALE);
break;
case SQL3_REAL:
printf ("real");
break;
case SQL3_DOUBLE_PRECISION:
printf ("double precision");
break;
case SQL3_DATE_TIME_TIMESTAMP:
exec sql get descriptor MYDESC value :INDEX
:DATETIME_INTERVAL_CODE = datetime_interval_code;
switch (DATETIME_INTERVAL_CODE)
{
case SQL3_DDT_DATE:
printf ("date");
break;
case SQL3_DDT_TIME:
printf ("time");
break;
case SQL3_DDT_TIMESTAMP:
printf ("timestamp");
break;
case SQL3_DDT_TIME_WITH_TIME_ZONE:
printf ("time with time zone");
break;
case SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE:
printf ("timestamp with time zone");
break;
}
break;
case SQL3_INTERVAL:
printf ("interval");
break;
case SQL3_CHARACTER:
if (LENGTH > 0)
printf ("char(%d)", LENGTH);
else
printf ("text");
break;
case SQL3_CHARACTER_VARYING:
if (LENGTH > 0)
printf ("varchar(%d)", LENGTH);
else
printf ("varchar()");
break;
default:
if (TYPE < 0)
printf ("<OID %d>", -TYPE);
else
printf ("<SQL3 %d>", TYPE);
break;
}
printf (")\n\toctet_length: %d returned_octet_length: %d)\n\t= ",
OCTET_LENGTH, RETURNED_OCTET_LENGTH);
if (INDICATOR == -1)
printf ("NULL\n");
else
switch (TYPE)
{
case SQL3_BOOLEAN:
exec sql get descriptor MYDESC value :INDEX :BOOLVAR = data;
printf ("%s\n", BOOLVAR ? "true" : "false");
break;
case SQL3_INTEGER:
case SQL3_SMALLINT:
exec sql get descriptor MYDESC value :INDEX :INTVAR = data;
printf ("%d\n", INTVAR);
break;
case SQL3_DOUBLE_PRECISION:
exec sql get descriptor MYDESC value :INDEX :DOUBLEVAR = data;
printf ("%.*f\n", PRECISION, DOUBLEVAR);
break;
case SQL3_DATE_TIME_TIMESTAMP:
exec sql get descriptor MYDESC value :INDEX
:DATETIME_INTERVAL_CODE = datetime_interval_code,
:STRINGVAR = data;
printf ("%d \"%s\"\n", DATETIME_INTERVAL_CODE, STRINGVAR);
break;
case SQL3_CHARACTER:
case SQL3_CHARACTER_VARYING:
exec sql get descriptor MYDESC value :INDEX :STRINGVAR = data;
printf ("\"%s\"\n", STRINGVAR);
break;
default:
exec sql get descriptor MYDESC value :INDEX :STRINGVAR = data;
printf ("<\"%s\">\n", STRINGVAR);
break;
}
}
}
exec sql close MYCURS;
exec sql deallocate descriptor MYDESC;
/* no exec sql disconnect; */
return 0;
}
}

View File

@ -1,119 +0,0 @@
/* dynamic SQL test program
*/
#include <stdio.h>
#include <stdlib.h>
exec sql include sql3types;
exec sql include sqlca;
exec sql include ../regression;
static void error(void)
{
printf("\n#%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
exit(1);
}
int main(int argc,char **argv)
{
exec sql begin declare section;
int COUNT;
int INTVAR;
int INDEX;
int INDICATOR;
int TYPE,LENGTH,OCTET_LENGTH,PRECISION,SCALE,RETURNED_OCTET_LENGTH;
int DATETIME_INTERVAL_CODE;
char NAME[120], BOOLVAR;
char STRINGVAR[1024];
double DOUBLEVAR;
char *QUERY;
exec sql end declare section;
int done=0;
exec sql var BOOLVAR is bool;
ECPGdebug(1, stderr);
QUERY="select * from dyntest";
exec sql whenever sqlerror do error();
exec sql allocate descriptor MYDESC;
exec sql connect to REGRESSDB1;
exec sql create table dyntest (name char(14), d float8, i int, bignumber int8, b boolean, comment text, day date);
exec sql insert into dyntest values('first entry', 14.7, 14, 123045607890, true, 'The world''''s most advanced open source database.', '1987-07-14');
exec sql insert into dyntest values('second entry', 1407.87, 1407, 987065403210, false, 'The elephant never forgets.', '1999-11-5');
exec sql prepare MYQUERY from :QUERY;
exec sql declare MYCURS cursor for MYQUERY;
exec sql open MYCURS;
while (1)
{
exec sql fetch in MYCURS into sql descriptor MYDESC;
if (sqlca.sqlcode) break;
exec sql get descriptor MYDESC :COUNT = count;
if (!done)
{
printf("Count %d\n",COUNT);
done=1;
}
for (INDEX=1;INDEX<=COUNT;++INDEX)
{
exec sql get descriptor MYDESC value :INDEX
:TYPE = type,
:LENGTH = length, :OCTET_LENGTH=octet_length,
:RETURNED_OCTET_LENGTH=returned_octet_length,
:PRECISION = precision, :SCALE=scale,
:NAME=name, :INDICATOR=indicator;
printf("%2d\t%s (type: %d length: %d precision: %d scale: %d\n"
"\toctet_length: %d returned_octet_length: %d)\n\t= "
,INDEX,NAME,TYPE,LENGTH,PRECISION,SCALE
,OCTET_LENGTH,RETURNED_OCTET_LENGTH);
if (INDICATOR==-1) printf("NULL\n");
else switch (TYPE)
{
case SQL3_BOOLEAN:
exec sql get descriptor MYDESC value :INDEX :BOOLVAR=data;
printf("%s\n",BOOLVAR ? "true":"false");
break;
case SQL3_INTEGER:
case SQL3_SMALLINT:
exec sql get descriptor MYDESC value :INDEX :INTVAR=data;
printf("%d\n",INTVAR);
break;
case SQL3_DOUBLE_PRECISION:
exec sql get descriptor MYDESC value :INDEX :DOUBLEVAR=data;
printf("%.*f\n",PRECISION,DOUBLEVAR);
break;
case SQL3_DATE_TIME_TIMESTAMP:
exec sql get descriptor MYDESC value :INDEX
:DATETIME_INTERVAL_CODE=datetime_interval_code,
:STRINGVAR=data;
printf("%d \"%s\"\n",DATETIME_INTERVAL_CODE,STRINGVAR);
break;
case SQL3_CHARACTER:
case SQL3_CHARACTER_VARYING:
exec sql get descriptor MYDESC value :INDEX :STRINGVAR=data;
printf("\"%s\"\n",STRINGVAR);
break;
default:
exec sql get descriptor MYDESC value :INDEX :STRINGVAR=data;
printf("<\"%s\">\n",STRINGVAR);
break;
}
}
}
exec sql close MYCURS;
exec sql deallocate descriptor MYDESC;
return 0;
}

View File

@ -1,7 +1,7 @@
subdir = src/interfaces/ecpg/test/thread
top_builddir = ../../../../..
include $(top_builddir)/src/Makefile.global
include ../Makefile.regress
include $(top_srcdir)/$(subdir)/../Makefile.regress
TESTS = thread_implicit thread_implicit.c \