Commit fd3ca524 authored by Michael Meskes's avatar Michael Meskes

Implemented Informix special way to treat NULLs, removed warnings, synced.

parent ff4c69e0
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <math.h> #include <math.h>
#include <ctype.h> #include <ctype.h>
#include <ecpgtype.h>
#include <ecpg_informix.h> #include <ecpg_informix.h>
#include <pgtypes_error.h> #include <pgtypes_error.h>
#include <pgtypes_date.h> #include <pgtypes_date.h>
...@@ -645,18 +646,6 @@ rgetmsg(int msgnum, char *s, int maxsize) ...@@ -645,18 +646,6 @@ rgetmsg(int msgnum, char *s, int maxsize)
return 0; return 0;
} }
int
risnull(int vtype, char *pcvar)
{
return 0;
}
int
rsetnull(int vtype, char *pcvar)
{
return 0;
}
int int
rtypalign(int offset, int type) rtypalign(int offset, int type)
{ {
...@@ -681,30 +670,6 @@ dtcvfmtasc (char *inbuf, char *fmtstr, dtime_t *dtvalue) ...@@ -681,30 +670,6 @@ dtcvfmtasc (char *inbuf, char *fmtstr, dtime_t *dtvalue)
return 0; return 0;
} }
bool
ECPGconnect_informix(int lineno, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
{
char *informix_name = (char *)name, *envname;
/* Informix uses an environment variable DBPATH that overrides
* the connection parameters given here.
* We do the same with PG_DBPATH as the syntax is different. */
envname = getenv("PG_DBPATH");
if (envname)
informix_name = envname;
return (ECPGconnect(lineno, informix_name, user, passwd, connection_name , autocommit));
}
bool
ECPGdeallocate_informix(int lineno, char *name)
{
ECPGdeallocate_one(lineno, name);
/* Just ignore all errors since we do not know the list of cursors we
* are allowed to free. We have to trust that the software. */
return true;
}
static struct var_list static struct var_list
{ {
int number; int number;
...@@ -744,3 +709,14 @@ ECPG_informix_get_var(int number) ...@@ -744,3 +709,14 @@ ECPG_informix_get_var(int number)
return (ptr) ? ptr->pointer : NULL; return (ptr) ? ptr->pointer : NULL;
} }
int rsetnull(int t, char *ptr)
{
ECPGset_informix_null(t, ptr);
return 0;
}
int risnull(int t, char *ptr)
{
return(ECPGis_informix_null(t, ptr));
}
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.7 2003/06/15 04:07:58 momjian Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.8 2003/06/25 10:44:21 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL #define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -173,7 +173,7 @@ ECPGnoticeProcessor(void *arg, const char *message) ...@@ -173,7 +173,7 @@ ECPGnoticeProcessor(void *arg, const char *message)
struct sqlca_t *sqlca = ECPGget_sqlca(); struct sqlca_t *sqlca = ECPGget_sqlca();
/* these notices raise an error */ /* these notices raise an error */
if (strncmp(message, "WARNING: ", 9)) if (strncmp(message, "WARNING: ", 9) && strncmp(message, "NOTICE: ", 8))
{ {
ECPGlog("ECPGnoticeProcessor: strange warning '%s'\n", message); ECPGlog("ECPGnoticeProcessor: strange warning '%s'\n", message);
ECPGnoticeProcessor_raise(ECPG_WARNING_UNRECOGNIZED, message); ECPGnoticeProcessor_raise(ECPG_WARNING_UNRECOGNIZED, message);
...@@ -290,9 +290,10 @@ ECPGnoticeProcessor(void *arg, const char *message) ...@@ -290,9 +290,10 @@ ECPGnoticeProcessor(void *arg, const char *message)
/* this contains some quick hacks, needs to be cleaned up, but it works */ /* this contains some quick hacks, needs to be cleaned up, but it works */
bool bool
ECPGconnect(int lineno, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit) ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
{ {
struct sqlca_t *sqlca = ECPGget_sqlca(); struct sqlca_t *sqlca = ECPGget_sqlca();
enum COMPAT_MODE compat = c;
struct connection *this; struct connection *this;
char *dbname = strdup(name), char *dbname = strdup(name),
*host = NULL, *host = NULL,
...@@ -303,6 +304,22 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd, ...@@ -303,6 +304,22 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
ECPGinit_sqlca(sqlca); ECPGinit_sqlca(sqlca);
if (compat == ECPG_COMPAT_INFORMIX)
{
char *envname;
/* Informix uses an environment variable DBPATH that overrides
* the connection parameters given here.
* We do the same with PG_DBPATH as the syntax is different. */
envname = getenv("PG_DBPATH");
if (envname)
{
free(dbname);
dbname = envname;
}
}
if ((this = (struct connection *) ECPGalloc(sizeof(struct connection), lineno)) == NULL) if ((this = (struct connection *) ECPGalloc(sizeof(struct connection), lineno)) == NULL)
return false; return false;
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.7 2003/06/22 11:00:48 meskes Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.8 2003/06/25 10:44:21 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL #define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -20,7 +20,7 @@ bool ...@@ -20,7 +20,7 @@ bool
ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
enum ECPGttype type, enum ECPGttype ind_type, enum ECPGttype type, enum ECPGttype ind_type,
char *var, char *ind, long varcharsize, long offset, char *var, char *ind, long varcharsize, long offset,
long ind_offset, bool isarray) long ind_offset, bool isarray, enum COMPAT_MODE compat, bool force_indicator)
{ {
struct sqlca_t *sqlca = ECPGget_sqlca(); struct sqlca_t *sqlca = ECPGget_sqlca();
char *pval = (char *) PQgetvalue(results, act_tuple, act_field); char *pval = (char *) PQgetvalue(results, act_tuple, act_field);
...@@ -55,35 +55,36 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, ...@@ -55,35 +55,36 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
/* /*
* check for null value and set indicator accordingly * check for null value and set indicator accordingly
*/ */
if (PQgetisnull(results, act_tuple, act_field))
{
switch (ind_type) switch (ind_type)
{ {
case ECPGt_short: case ECPGt_short:
case ECPGt_unsigned_short: case ECPGt_unsigned_short:
/* ((short *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/ *((short *) (ind + ind_offset * act_tuple)) = -1;
*((short *) (ind + ind_offset * act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
break; break;
case ECPGt_int: case ECPGt_int:
case ECPGt_unsigned_int: case ECPGt_unsigned_int:
/* ((int *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/ *((int *) (ind + ind_offset * act_tuple)) = -1;
*((int *) (ind + ind_offset * act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
break; break;
case ECPGt_long: case ECPGt_long:
case ECPGt_unsigned_long: case ECPGt_unsigned_long:
/* ((long *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/ *((long *) (ind + ind_offset * act_tuple)) = -1;
*((long *) (ind + ind_offset * act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
break; break;
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG_INT_64
case ECPGt_long_long: case ECPGt_long_long:
case ECPGt_unsigned_long_long: case ECPGt_unsigned_long_long:
/* ((long long int *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/ *((long long int *) (ind + ind_offset * act_tuple)) = -1;
*((long long int *) (ind + ind_offset * act_tuple)) = -PQgetisnull(results, act_tuple, act_field);
break; break;
/* case ECPGt_unsigned_long_long:
((unsigned long long int *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);
break;*/
#endif /* HAVE_LONG_LONG_INT_64 */ #endif /* HAVE_LONG_LONG_INT_64 */
case ECPGt_NO_INDICATOR: case ECPGt_NO_INDICATOR:
if (PQgetisnull(results, act_tuple, act_field)) if (force_indicator == false && compat == ECPG_COMPAT_INFORMIX)
{
/* Informix has an additional way to specify NULLs
* note that this uses special values to denote NULL */
ECPGset_informix_null(type, var + offset * act_tuple);
}
else
{ {
ECPGraise(lineno, ECPG_MISSING_INDICATOR, NULL); ECPGraise(lineno, ECPG_MISSING_INDICATOR, NULL);
return (false); return (false);
...@@ -95,6 +96,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, ...@@ -95,6 +96,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break; break;
} }
return (true);
}
do do
{ {
switch (type) switch (type)
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.11 2003/06/20 12:00:59 meskes Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.12 2003/06/25 10:44:21 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.
...@@ -88,7 +88,7 @@ quote_postgres(char *arg, int lineno) ...@@ -88,7 +88,7 @@ quote_postgres(char *arg, int lineno)
* ind_offset - indicator offset * ind_offset - indicator offset
*/ */
static bool static bool
create_statement(int lineno, struct connection * connection, struct statement ** stmt, char *query, va_list ap) create_statement(int lineno, int compat, int force_indicator, struct connection * connection, struct statement ** stmt, char *query, va_list ap)
{ {
struct variable **list = &((*stmt)->inlist); struct variable **list = &((*stmt)->inlist);
enum ECPGttype type; enum ECPGttype type;
...@@ -99,6 +99,8 @@ create_statement(int lineno, struct connection * connection, struct statement ** ...@@ -99,6 +99,8 @@ create_statement(int lineno, struct connection * connection, struct statement **
(*stmt)->command = query; (*stmt)->command = query;
(*stmt)->connection = connection; (*stmt)->connection = connection;
(*stmt)->lineno = lineno; (*stmt)->lineno = lineno;
(*stmt)->compat = compat;
(*stmt)->force_indicator = force_indicator;
list = &((*stmt)->inlist); list = &((*stmt)->inlist);
...@@ -428,7 +430,7 @@ ECPGstore_result(const PGresult *results, int act_field, ...@@ -428,7 +430,7 @@ ECPGstore_result(const PGresult *results, int act_field,
if (!ECPGget_data(results, act_tuple, act_field, stmt->lineno, if (!ECPGget_data(results, act_tuple, act_field, stmt->lineno,
var->type, var->ind_type, current_data_location, var->type, var->ind_type, current_data_location,
var->ind_value, len, 0, 0, isarray)) var->ind_value, len, 0, 0, isarray, stmt->compat, stmt->force_indicator))
status = false; status = false;
else else
{ {
...@@ -447,7 +449,7 @@ ECPGstore_result(const PGresult *results, int act_field, ...@@ -447,7 +449,7 @@ ECPGstore_result(const PGresult *results, int act_field,
{ {
if (!ECPGget_data(results, act_tuple, act_field, stmt->lineno, if (!ECPGget_data(results, act_tuple, act_field, stmt->lineno,
var->type, var->ind_type, var->value, var->type, var->ind_type, var->value,
var->ind_value, var->varcharsize, var->offset, var->ind_offset, isarray)) var->ind_value, var->varcharsize, var->offset, var->ind_offset, isarray, stmt->compat, stmt->force_indicator))
status = false; status = false;
} }
} }
...@@ -505,10 +507,16 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var, ...@@ -505,10 +507,16 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
*tobeinserted_p = "null"; *tobeinserted_p = "null";
break; break;
#endif /* HAVE_LONG_LONG_INT_64 */ #endif /* HAVE_LONG_LONG_INT_64 */
case ECPGt_NO_INDICATOR:
if (stmt->force_indicator == false && stmt->compat == ECPG_COMPAT_INFORMIX)
{
if (ECPGis_informix_null(var->type, var->value))
*tobeinserted_p = "null";
}
break;
default: default:
break; break;
} }
if (**tobeinserted_p == '\0') if (**tobeinserted_p == '\0')
{ {
switch (var->type) switch (var->type)
...@@ -1222,7 +1230,7 @@ ECPGexecute(struct statement * stmt) ...@@ -1222,7 +1230,7 @@ ECPGexecute(struct statement * stmt)
} }
bool bool
ECPGdo(int lineno, const char *connection_name, char *query,...) ECPGdo(int lineno, int compat, int force_indicator, const char *connection_name, char *query,...)
{ {
va_list args; va_list args;
struct statement *stmt; struct statement *stmt;
...@@ -1244,7 +1252,7 @@ ECPGdo(int lineno, const char *connection_name, char *query,...) ...@@ -1244,7 +1252,7 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
/* construct statement in our own structure */ /* construct statement in our own structure */
va_start(args, query); va_start(args, query);
if (create_statement(lineno, con, &stmt, query, args) == false) if (create_statement(lineno, compat, force_indicator, con, &stmt, query, args) == false)
{ {
setlocale(LC_NUMERIC, oldlocale); setlocale(LC_NUMERIC, oldlocale);
ECPGfree(oldlocale); ECPGfree(oldlocale);
...@@ -1280,7 +1288,8 @@ bool ...@@ -1280,7 +1288,8 @@ bool
ECPGdo_descriptor(int line, const char *connection, ECPGdo_descriptor(int line, const char *connection,
const char *descriptor, const char *query) const char *descriptor, const char *query)
{ {
return ECPGdo(line, connection, (char *) query, ECPGt_EOIT, return ECPGdo(line, ECPG_COMPAT_PGSQL, true, connection, (char *) query, ECPGt_EOIT,
ECPGt_descriptor, descriptor, 0L, 0L, 0L, ECPGt_descriptor, descriptor, 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
} }
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "libpq-fe.h" #include "libpq-fe.h"
#include "sqlca.h" #include "sqlca.h"
enum COMPAT_MODE { ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX};
/* Here are some methods used by the lib. */ /* Here are some methods used by the lib. */
/* Stores the backend error message for client access */ /* Stores the backend error message for client access */
...@@ -18,7 +20,7 @@ char *ECPGerrmsg(void); ...@@ -18,7 +20,7 @@ char *ECPGerrmsg(void);
void ECPGadd_mem(void *ptr, int lineno); void ECPGadd_mem(void *ptr, int lineno);
bool ECPGget_data(const PGresult *, int, int, int, enum ECPGttype type, bool ECPGget_data(const PGresult *, int, int, int, enum ECPGttype type,
enum ECPGttype, char *, char *, long, long, long, bool); enum ECPGttype, char *, char *, long, long, long, bool, enum COMPAT_MODE, bool);
struct connection *ECPGget_connection(const char *); struct connection *ECPGget_connection(const char *);
char *ECPGalloc(long, int); char *ECPGalloc(long, int);
char *ECPGrealloc(void *, long, int); char *ECPGrealloc(void *, long, int);
...@@ -54,6 +56,8 @@ struct statement ...@@ -54,6 +56,8 @@ struct statement
int lineno; int lineno;
char *command; char *command;
struct connection *connection; struct connection *connection;
enum COMPAT_MODE compat;
bool force_indicator;
struct variable *inlist; struct variable *inlist;
struct variable *outlist; struct variable *outlist;
}; };
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.4 2003/06/15 04:56:45 momjian Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.5 2003/06/25 10:44:21 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL #define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
#include "ecpgerrno.h" #include "ecpgerrno.h"
#include "extern.h" #include "extern.h"
#include "sqlca.h" #include "sqlca.h"
#include "pgtypes_numeric.h"
#include "pgtypes_date.h"
#include "pgtypes_timestamp.h"
#include "pgtypes_interval.h"
static struct sqlca_t sqlca_init = static struct sqlca_t sqlca_init =
{ {
...@@ -238,3 +242,114 @@ ECPGlog(const char *format,...) ...@@ -238,3 +242,114 @@ ECPGlog(const char *format,...)
pthread_mutex_unlock(&debug_mutex); pthread_mutex_unlock(&debug_mutex);
#endif #endif
} }
void
ECPGset_informix_null(enum ECPGttype type, void *ptr)
{
switch (type)
{
case ECPGt_char:
case ECPGt_unsigned_char:
*((char *) ptr) = 0x00;
break;
case ECPGt_short:
case ECPGt_unsigned_short:
*((short int *) ptr) = SHRT_MIN;
break;
case ECPGt_int:
case ECPGt_unsigned_int:
*((int *) ptr) = INT_MIN;
break;
case ECPGt_long:
case ECPGt_unsigned_long:
case ECPGt_date:
*((long *) ptr) = LONG_MIN;
break;
#ifdef HAVE_LONG_LONG_INT_64
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
*((long long *) ptr) = LONG_LONG_MIN;
break;
#endif /* HAVE_LONG_LONG_INT_64 */
case ECPGt_float:
memset((char *) ptr, 0xff, sizeof(float));
break;
case ECPGt_double:
memset((char *) ptr, 0xff, sizeof(double));
break;
case ECPGt_varchar:
*(((struct ECPGgeneric_varchar *) ptr)->arr) = 0x00;
break;
case ECPGt_numeric:
((Numeric *) ptr)->sign = NUMERIC_NAN;
break;
case ECPGt_interval:
memset((char *) ptr, 0xff, sizeof(Interval));
break;
case ECPGt_timestamp:
memset((char *) ptr, 0xff, sizeof(Timestamp));
break;
default:
break;
}
}
static bool _check(unsigned char *ptr, int length)
{
for (;ptr[length] == 0xff && length >= 0; length --);
if (length < 0) return true;
return false;
}
bool
ECPGis_informix_null(enum ECPGttype type, void *ptr)
{
switch (type)
{
case ECPGt_char:
case ECPGt_unsigned_char:
if (*((char *)ptr) == 0x00) return true;
break;
case ECPGt_short:
case ECPGt_unsigned_short:
if (*((short int *) ptr) == SHRT_MIN) return true;
break;
case ECPGt_int:
case ECPGt_unsigned_int:
if (*((int *) ptr) == INT_MIN) return true;
break;
case ECPGt_long:
case ECPGt_unsigned_long:
case ECPGt_date:
if (*((long *) ptr) == LONG_MIN) return true;
break;
#ifdef HAVE_LONG_LONG_INT_64
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
if (*((long long *) ptr) == LONG_LONG_MIN) return true;
break;
#endif /* HAVE_LONG_LONG_INT_64 */
case ECPGt_float:
return(_check(ptr, sizeof(float)));
break;
case ECPGt_double:
return(_check(ptr, sizeof(double)));
break;
case ECPGt_varchar:
if (*(((struct ECPGgeneric_varchar *) ptr)->arr) == 0x00) return true;
break;
case ECPGt_numeric:
if (((Numeric *) ptr)->sign == NUMERIC_NAN) return true;
break;
case ECPGt_interval:
return(_check(ptr, sizeof(Interval)));
break;
case ECPGt_timestamp:
return(_check(ptr, sizeof(Timestamp)));
break;
default:
break;
}
return false;
}
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.3 2003/06/20 13:36:34 meskes Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.4 2003/06/25 10:44:21 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL #define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -64,7 +64,7 @@ ECPGprepare(int lineno, char *name, char *variable) ...@@ -64,7 +64,7 @@ ECPGprepare(int lineno, char *name, char *variable)
for (this = prep_stmts; this != NULL && strcmp(this->name, name) != 0; this = this->next); for (this = prep_stmts; this != NULL && strcmp(this->name, name) != 0; this = this->next);
if (this) if (this)
{ {
bool b = ECPGdeallocate(lineno, name); bool b = ECPGdeallocate(lineno, ECPG_COMPAT_PGSQL, name);
if (!b) if (!b)
return false; return false;
...@@ -105,15 +105,22 @@ ECPGprepare(int lineno, char *name, char *variable) ...@@ -105,15 +105,22 @@ ECPGprepare(int lineno, char *name, char *variable)
/* handle the EXEC SQL DEALLOCATE PREPARE statement */ /* handle the EXEC SQL DEALLOCATE PREPARE statement */
bool bool
ECPGdeallocate(int lineno, char *name) ECPGdeallocate(int lineno, int c, char *name)
{ {
bool ret = ECPGdeallocate_one(lineno, name); bool ret = ECPGdeallocate_one(lineno, name);
enum COMPAT_MODE compat = c;
if (compat == ECPG_COMPAT_INFORMIX)
{
/* Just ignore all errors since we do not know the list of cursors we
* are allowed to free. We have to trust that the software. */
return true;
}
if (!ret) if (!ret)
ECPGraise(lineno, ECPG_INVALID_STMT, name); ECPGraise(lineno, ECPG_INVALID_STMT, name);
return ret; return ret;
} }
bool bool
...@@ -147,7 +154,7 @@ ECPGdeallocate_all(int lineno) ...@@ -147,7 +154,7 @@ ECPGdeallocate_all(int lineno)
/* deallocate all prepared statements */ /* deallocate all prepared statements */
while (prep_stmts != NULL) while (prep_stmts != NULL)
{ {
bool b = ECPGdeallocate(lineno, prep_stmts->name); bool b = ECPGdeallocate(lineno, ECPG_COMPAT_PGSQL, prep_stmts->name);
if (!b) if (!b)
return false; return false;
......
...@@ -5,7 +5,8 @@ include $(top_builddir)/src/Makefile.global ...@@ -5,7 +5,8 @@ include $(top_builddir)/src/Makefile.global
install: all installdirs install-headers install: all installdirs install-headers
.PHONY: install-headers .PHONY: install-headers
ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h datetime.h decimal.h ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h datetime.h decimal.h pgtypes_interval.h
install-headers: $(ecpg_headers) install-headers: $(ecpg_headers)
for i in $^; do $(INSTALL_DATA) $$i $(DESTDIR)$(includedir); done for i in $^; do $(INSTALL_DATA) $$i $(DESTDIR)$(includedir); done
......
...@@ -33,7 +33,5 @@ extern void rupshift(char *); ...@@ -33,7 +33,5 @@ extern void rupshift(char *);
extern int byleng(char *, int); extern int byleng(char *, int);
extern void ldchar(char *, int, char *); extern void ldchar(char *, int, char *);
extern bool ECPGconnect_informix(int, const char *, const char *, const char *, const char *, int);
extern bool ECPGdeallocate_informix(int, char *);
extern void ECPG_informix_set_var(int, void *, int); extern void ECPG_informix_set_var(int, void *, int);
extern void *ECPG_informix_get_var(int); extern void *ECPG_informix_get_var(int);
...@@ -45,12 +45,12 @@ void ECPGdebug(int, FILE *); ...@@ -45,12 +45,12 @@ void ECPGdebug(int, FILE *);
bool ECPGstatus(int, const char *); bool ECPGstatus(int, const char *);
bool ECPGsetcommit(int, const char *, const char *); bool ECPGsetcommit(int, const char *, const char *);
bool ECPGsetconn(int, const char *); bool ECPGsetconn(int, const char *);
bool ECPGconnect(int, const char *, const char *, const char *, const char *, int); bool ECPGconnect(int, int, const char *, const char *, const char *, const char *, int);
bool ECPGdo(int, const char *, char *,...); bool ECPGdo(int, int, int, const char *, char *,...);
bool ECPGtrans(int, const char *, const char *); bool ECPGtrans(int, const char *, const char *);
bool ECPGdisconnect(int, const char *); bool ECPGdisconnect(int, const char *);
bool ECPGprepare(int, char *, char *); bool ECPGprepare(int, char *, char *);
bool ECPGdeallocate(int, char *); bool ECPGdeallocate(int, int, char *);
bool ECPGdeallocate_one(int, char *); bool ECPGdeallocate_one(int, char *);
bool ECPGdeallocate_all(int); bool ECPGdeallocate_all(int);
char *ECPGprepared_statement(char *); char *ECPGprepared_statement(char *);
...@@ -75,13 +75,13 @@ void ECPGraise(int line, int code, const char *str); ...@@ -75,13 +75,13 @@ void ECPGraise(int line, int code, const char *str);
bool ECPGget_desc_header(int, char *, int *); bool ECPGget_desc_header(int, char *, int *);
bool ECPGget_desc(int, char *, int,...); bool ECPGget_desc(int, char *, int,...);
void ECPGset_informix_null(enum ECPGttype, void *);
bool ECPGis_informix_null(enum ECPGttype, void *);
bool ECPGdescribe(int, bool, const char *, ...); bool ECPGdescribe(int, bool, const char *, ...);
/* dynamic result allocation */ /* dynamic result allocation */
void ECPGfree_auto_mem(void); void ECPGfree_auto_mem(void);
enum COMPAT_MODE { ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX};
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#define NUMERIC_POS 0x0000 #define NUMERIC_POS 0x0000
#define NUMERIC_NEG 0x4000 #define NUMERIC_NEG 0x4000
#define NUMERIC_NAN 0xC000
#define NUMERIC_MAX_PRECISION 1000 #define NUMERIC_MAX_PRECISION 1000
#define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION #define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION
#define NUMERIC_MIN_DISPLAY_SCALE 0 #define NUMERIC_MIN_DISPLAY_SCALE 0
......
#define CCHARTYPE 100 #define CCHARTYPE ECPGt_char
#define CSHORTTYPE 101 #define CSHORTTYPE ECPGt_short
#define CINTTYPE 102 #define CINTTYPE ECPGt_int
#define CLONGTYPE 103 #define CLONGTYPE ECPGt_long
#define CFLOATTYPE 104 #define CFLOATTYPE ECPGt_float
#define CDOUBLETYPE 105 #define CDOUBLETYPE ECPGt_double
#define CDECIMALTYPE 107 #define CDECIMALTYPE ECPGt_numeric
#define CFIXCHARTYPE 108 #define CFIXCHARTYPE 108
#define CSTRINGTYPE 109 #define CSTRINGTYPE ECPGt_char
#define CDATETYPE 110 #define CDATETYPE ECPGt_date
#define CMONEYTYPE 111 #define CMONEYTYPE 111
#define CDTIMETYPE 112 #define CDTIMETYPE 112
#define CLOCATORTYPE 113 #define CLOCATORTYPE 113
#define CVCHARTYPE 114 #define CVCHARTYPE ECPGt_varchar
#define CINVTYPE 115 #define CINVTYPE 115
#define CFILETYPE 116 #define CFILETYPE 116
#define CINT8TYPE 117 #define CINT8TYPE ECPGt_long_long
#define CCOLLTYPE 118 #define CCOLLTYPE 118
#define CLVCHARTYPE 119 #define CLVCHARTYPE 119
#define CFIXBINTYPE 120 #define CFIXBINTYPE 120
#define CVARBINTYPE 121 #define CVARBINTYPE 121
#define CBOOLTYPE 122 #define CBOOLTYPE ECPGt_bool
#define CROWTYPE 123 #define CROWTYPE 123
#define CLVCHARPTRTYPE 124 #define CLVCHARPTRTYPE 124
#define CTYPEMAX 25 #define CTYPEMAX 25
...@@ -464,8 +464,11 @@ dttofmtasc_replace (Timestamp *ts, Date dDate, int dow, struct tm* tm, ...@@ -464,8 +464,11 @@ dttofmtasc_replace (Timestamp *ts, Date dDate, int dow, struct tm* tm,
break; break;
case 'g': case 'g':
/* XXX: fall back to strftime */ /* XXX: fall back to strftime */
{
char *fmt = "%g"; /* Keep compiler quiet about 2-digit year */
tm->tm_mon -= 1; tm->tm_mon -= 1;
i = strftime(q, *pstr_len, "%g", tm); i = strftime(q, *pstr_len, fmt, tm);
if (i == 0) { return -1; } if (i == 0) { return -1; }
while (*q) { while (*q) {
q++; q++;
...@@ -473,6 +476,7 @@ dttofmtasc_replace (Timestamp *ts, Date dDate, int dow, struct tm* tm, ...@@ -473,6 +476,7 @@ dttofmtasc_replace (Timestamp *ts, Date dDate, int dow, struct tm* tm,
} }
tm->tm_mon += 1; tm->tm_mon += 1;
replace_type = PGTYPES_REPLACE_NOTHING; replace_type = PGTYPES_REPLACE_NOTHING;
}
break; break;
case 'H': case 'H':
replace_val.replace_uint = tm->tm_hour; replace_val.replace_uint = tm->tm_hour;
...@@ -602,8 +606,11 @@ dttofmtasc_replace (Timestamp *ts, Date dDate, int dow, struct tm* tm, ...@@ -602,8 +606,11 @@ dttofmtasc_replace (Timestamp *ts, Date dDate, int dow, struct tm* tm,
break; break;
case 'x': case 'x':
/* XXX: fall back to strftime */ /* XXX: fall back to strftime */
{
char *fmt = "%x"; /* Keep compiler quiet about 2-digit year */
tm->tm_mon -= 1; tm->tm_mon -= 1;
i = strftime(q, *pstr_len, "%x", tm); i = strftime(q, *pstr_len, fmt, tm);
if (i == 0) { return -1; } if (i == 0) { return -1; }
while (*q) { while (*q) {
q++; q++;
...@@ -611,6 +618,7 @@ dttofmtasc_replace (Timestamp *ts, Date dDate, int dow, struct tm* tm, ...@@ -611,6 +618,7 @@ dttofmtasc_replace (Timestamp *ts, Date dDate, int dow, struct tm* tm,
} }
tm->tm_mon += 1; tm->tm_mon += 1;
replace_type = PGTYPES_REPLACE_NOTHING; replace_type = PGTYPES_REPLACE_NOTHING;
}
break; break;
case 'X': case 'X':
/* XXX: fall back to strftime */ /* XXX: fall back to strftime */
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.73 2003/06/13 10:50:57 meskes Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.74 2003/06/25 10:44:21 meskes Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */ /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */ /* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
...@@ -20,7 +20,8 @@ extern char *optarg; ...@@ -20,7 +20,8 @@ extern char *optarg;
int ret_value = 0, int ret_value = 0,
autocommit = false, autocommit = false,
auto_create_c = false, auto_create_c = false,
system_includes = false; system_includes = false,
force_indicator = true;
enum COMPAT_MODE compat = ECPG_COMPAT_PGSQL; enum COMPAT_MODE compat = ECPG_COMPAT_PGSQL;
...@@ -44,8 +45,9 @@ help(const char *progname) ...@@ -44,8 +45,9 @@ help(const char *progname)
printf(" -d generate parser debug output\n"); printf(" -d generate parser debug output\n");
#endif #endif
printf(" -C <mode> set compatibility mode\n" printf(" -C <mode> set compatibility mode\n"
" mode may be INFORMIX only at the moment\n" " mode may be \"INFORMIX\" only at the moment\n");
" INFORMIX mode implies '-i'\n"); printf(" -r <option> specify runtime behaviour\n"
" option may be only \"no_indicator\" at the moment\n");
printf(" -D SYMBOL define SYMBOL\n"); printf(" -D SYMBOL define SYMBOL\n");
printf(" -I DIRECTORY search DIRECTORY for include files\n"); printf(" -I DIRECTORY search DIRECTORY for include files\n");
printf(" -o OUTFILE write result to OUTFILE\n"); printf(" -o OUTFILE write result to OUTFILE\n");
...@@ -132,7 +134,7 @@ main(int argc, char *const argv[]) ...@@ -132,7 +134,7 @@ main(int argc, char *const argv[])
} }
} }
while ((c = getopt(argc, argv, "vcio:I:tD:dC:")) != -1) while ((c = getopt(argc, argv, "vcio:I:tD:dC:r:")) != -1)
{ {
switch (c) switch (c)
{ {
...@@ -177,6 +179,15 @@ main(int argc, char *const argv[]) ...@@ -177,6 +179,15 @@ main(int argc, char *const argv[])
return ILLEGAL_OPTION; return ILLEGAL_OPTION;
} }
break; break;
case 'r':
if (strcmp(optarg, "no_indicator") == 0)
force_indicator = false;
else
{
fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]);
return ILLEGAL_OPTION;
}
break;
case 'D': case 'D':
add_preprocessor_define(optarg); add_preprocessor_define(optarg);
break; break;
......
...@@ -16,6 +16,7 @@ extern int braces_open, ...@@ -16,6 +16,7 @@ extern int braces_open,
autocommit, autocommit,
auto_create_c, auto_create_c,
system_includes, system_includes,
force_indicator,
ret_value, ret_value,
struct_level, struct_level,
ecpg_informix_var; ecpg_informix_var;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.58 2003/05/23 15:19:34 meskes Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.59 2003/06/25 10:44:21 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -100,6 +100,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -100,6 +100,7 @@ static ScanKeyword ScanKeywords[] = {
{"decimal", DECIMAL_P}, {"decimal", DECIMAL_P},
{"declare", DECLARE}, {"declare", DECLARE},
{"default", DEFAULT}, {"default", DEFAULT},
{"defaults", DEFAULTS},
{"deferrable", DEFERRABLE}, {"deferrable", DEFERRABLE},
{"deferred", DEFERRED}, {"deferred", DEFERRED},
{"definer", DEFINER}, {"definer", DEFINER},
...@@ -119,6 +120,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -119,6 +120,7 @@ static ScanKeyword ScanKeywords[] = {
{"end", END_P}, {"end", END_P},
{"escape", ESCAPE}, {"escape", ESCAPE},
{"except", EXCEPT}, {"except", EXCEPT},
{"excluding", EXCLUDING},
{"exclusive", EXCLUSIVE}, {"exclusive", EXCLUSIVE},
{"execute", EXECUTE}, {"execute", EXECUTE},
{"exists", EXISTS}, {"exists", EXISTS},
...@@ -150,6 +152,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -150,6 +152,7 @@ static ScanKeyword ScanKeywords[] = {
{"immutable", IMMUTABLE}, {"immutable", IMMUTABLE},
{"implicit", IMPLICIT_P}, {"implicit", IMPLICIT_P},
{"in", IN_P}, {"in", IN_P},
{"including", INCLUDING},
{"increment", INCREMENT}, {"increment", INCREMENT},
{"index", INDEX}, {"index", INDEX},
{"inherits", INHERITS}, {"inherits", INHERITS},
......
...@@ -109,7 +109,7 @@ output_statement(char *stmt, int mode, char *con) ...@@ -109,7 +109,7 @@ output_statement(char *stmt, int mode, char *con)
int i, int i,
j = strlen(stmt); j = strlen(stmt);
fprintf(yyout, "{ ECPGdo(__LINE__, %s, \"", con ? con : "NULL"); fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, \"", compat, force_indicator, con ? con : "NULL");
/* output this char by char as we have to filter '\"' */ /* output this char by char as we have to filter '\"' */
for (i = 0; i < j; i++) for (i = 0; i < j; i++)
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.237 2003/06/24 23:14:49 momjian Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.238 2003/06/25 10:44:21 meskes Exp $ */
/* Copyright comment */ /* Copyright comment */
%{ %{
...@@ -275,10 +275,10 @@ adjust_informix(struct arguments *list) ...@@ -275,10 +275,10 @@ adjust_informix(struct arguments *list)
CREATE CREATEDB CREATEUSER CROSS CURRENT_DATE CURRENT_TIME CREATE CREATEDB CREATEUSER CROSS CURRENT_DATE CURRENT_TIME
CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFAULTS
DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS
DESC DISTINCT DO DOMAIN_P DOUBLE_P DROP DESC DISTINCT DO DOMAIN_P DOUBLE_P DROP
EACH ELSE ENCODING ENCRYPTED END_P ESCAPE EXCEPT EXCLUSIVE EACH ELSE ENCODING ENCRYPTED END_P ESCAPE EXCEPT EXCLUSIVE EXCLUDING
EXECUTE EXISTS EXPLAIN EXTERNAL EXTRACT EXECUTE EXISTS EXPLAIN EXTERNAL EXTRACT
FALSE_P FETCH FIRST_P FLOAT_P FOR FORCE FOREIGN FORWARD FREEZE FROM FALSE_P FETCH FIRST_P FLOAT_P FOR FORCE FOREIGN FORWARD FREEZE FROM
...@@ -287,9 +287,10 @@ adjust_informix(struct arguments *list) ...@@ -287,9 +287,10 @@ adjust_informix(struct arguments *list)
GET GLOBAL GRANT GROUP_P GET GLOBAL GRANT GROUP_P
HANDLER HAVING HOLD HOUR_P HANDLER HAVING HOLD HOUR_P
ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IN_P INCREMENT INDEX INHERITS ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IN_P INCLUDING INCREMENT
INITIALLY INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INDEX INHERITS INITIALLY INNER_P INOUT INPUT_P
INTEGER INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION INSENSITIVE INSERT INSTEAD INT_P INTEGER INTERSECT
INTERVAL INTO INVOKER IS ISNULL ISOLATION
JOIN JOIN
...@@ -397,7 +398,7 @@ adjust_informix(struct arguments *list) ...@@ -397,7 +398,7 @@ adjust_informix(struct arguments *list)
%type <str> columnList DeleteStmt LockStmt UpdateStmt DeclareCursorStmt %type <str> columnList DeleteStmt LockStmt UpdateStmt DeclareCursorStmt
%type <str> NotifyStmt columnElem UnlistenStmt TableElement rowdefinition %type <str> NotifyStmt columnElem UnlistenStmt TableElement rowdefinition
%type <str> copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary %type <str> copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary
%type <str> FetchStmt from_in CreateOpClassStmt %type <str> FetchStmt from_in CreateOpClassStmt like_including_defaults
%type <str> ClosePortalStmt DropStmt VacuumStmt AnalyzeStmt opt_verbose %type <str> ClosePortalStmt DropStmt VacuumStmt AnalyzeStmt opt_verbose
%type <str> opt_full func_arg OptWithOids opt_freeze %type <str> opt_full func_arg OptWithOids opt_freeze
%type <str> analyze_keyword opt_name_list ExplainStmt index_params %type <str> analyze_keyword opt_name_list ExplainStmt index_params
...@@ -615,10 +616,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); } ...@@ -615,10 +616,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
if (connection) if (connection)
mmerror(PARSE_ERROR, ET_ERROR, "no at option for connect statement.\n"); mmerror(PARSE_ERROR, ET_ERROR, "no at option for connect statement.\n");
if (compat == ECPG_COMPAT_INFORMIX) fprintf(yyout, "{ ECPGconnect(__LINE__, %d, %s, %d); ", compat, $1, autocommit);
fprintf(yyout, "{ ECPGconnect_informix(__LINE__, %s, %d); ", $1, autocommit);
else
fprintf(yyout, "{ ECPGconnect(__LINE__, %s, %d); ", $1, autocommit);
reset_variables(); reset_variables();
whenever_action(2); whenever_action(2);
free($1); free($1);
...@@ -674,10 +672,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); } ...@@ -674,10 +672,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
} }
| ECPGFree | ECPGFree
{ {
if (compat == ECPG_COMPAT_INFORMIX) fprintf(yyout, "{ ECPGdeallocate(__LINE__, %d, \"%s\");", compat, $1);
fprintf(yyout, "{ ECPGdeallocate_informix(__LINE__, \"%s\");", $1);
else
fprintf(yyout, "{ ECPGdeallocate(__LINE__, \"%s\");", $1);
whenever_action(2); whenever_action(2);
free($1); free($1);
...@@ -1311,13 +1306,18 @@ ConstraintAttr: DEFERRABLE { $$ = make_str("deferrable"); } ...@@ -1311,13 +1306,18 @@ ConstraintAttr: DEFERRABLE { $$ = make_str("deferrable"); }
| INITIALLY IMMEDIATE { $$ = make_str("initially immediate"); } | INITIALLY IMMEDIATE { $$ = make_str("initially immediate"); }
; ;
TableLikeClause: LIKE any_name TableLikeClause: LIKE qualified_name like_including_defaults
{ {
mmerror(PARSE_ERROR, ET_ERROR, "LIKE in table definitions not yet supported"); $$ = cat_str(3, make_str("like"), $2, $3);
$$ = cat2_str(make_str("like"), $2);
} }
; ;
like_including_defaults:
INCLUDING DEFAULTS { $$ = make_str("including defaults"); }
| EXCLUDING DEFAULTS { $$ = make_str("excluding defaults"); }
| /* EMPTY */ { $$ = EMPTY; }
;
/* ConstraintElem specifies constraint syntax which is not embedded into /* ConstraintElem specifies constraint syntax which is not embedded into
* a column definition. ColConstraintElem specifies the embedded form. * a column definition. ColConstraintElem specifies the embedded form.
* - thomas 1997-12-03 * - thomas 1997-12-03
...@@ -3476,6 +3476,8 @@ a_expr: c_expr ...@@ -3476,6 +3476,8 @@ a_expr: c_expr
{ $$ = cat_str(3, $1, make_str("not in"), $4); } { $$ = cat_str(3, $1, make_str("not in"), $4); }
| a_expr qual_all_Op sub_type select_with_parens %prec Op | a_expr qual_all_Op sub_type select_with_parens %prec Op
{ $$ = cat_str(4, $1, $2, $3, $4); } { $$ = cat_str(4, $1, $2, $3, $4); }
| a_expr qual_all_Op sub_type '(' a_expr ')' %prec Op
{ $$ = cat_str(6, $1, $2, $3, make_str("("), $5, make_str(")")); }
| UNIQUE select_with_parens %prec Op | UNIQUE select_with_parens %prec Op
{ $$ = cat2_str(make_str("unique"), $2); } { $$ = cat2_str(make_str("unique"), $2); }
| r_expr | r_expr
...@@ -3881,6 +3883,8 @@ inf_val_list: a_expr ...@@ -3881,6 +3883,8 @@ inf_val_list: a_expr
update_target_el: ColId opt_indirection '=' a_expr update_target_el: ColId opt_indirection '=' a_expr
{ $$ = cat_str(4, $1, $2, make_str("="), $4); } { $$ = cat_str(4, $1, $2, make_str("="), $4); }
| ColId opt_indirection '=' DEFAULT
{ $$ = cat_str(3, $1, $2, make_str("= default")); }
; ;
insert_target_list: insert_target_list ',' insert_target_el insert_target_list: insert_target_list ',' insert_target_el
...@@ -5744,6 +5748,7 @@ unreserved_keyword: ...@@ -5744,6 +5748,7 @@ unreserved_keyword:
| DAY_P { $$ = make_str("day"); } | DAY_P { $$ = make_str("day"); }
| DEALLOCATE { $$ = make_str("deallocate"); } | DEALLOCATE { $$ = make_str("deallocate"); }
| DECLARE { $$ = make_str("declare"); } | DECLARE { $$ = make_str("declare"); }
| DEFAULTS { $$ = make_str("defaults"); }
| DEFERRED { $$ = make_str("deferred"); } | DEFERRED { $$ = make_str("deferred"); }
| DELETE_P { $$ = make_str("delete"); } | DELETE_P { $$ = make_str("delete"); }
| DELIMITER { $$ = make_str("delimiter"); } | DELIMITER { $$ = make_str("delimiter"); }
...@@ -5755,6 +5760,7 @@ unreserved_keyword: ...@@ -5755,6 +5760,7 @@ unreserved_keyword:
| ENCODING { $$ = make_str("encoding"); } | ENCODING { $$ = make_str("encoding"); }
| ENCRYPTED { $$ = make_str("encrypted"); } | ENCRYPTED { $$ = make_str("encrypted"); }
| ESCAPE { $$ = make_str("escape"); } | ESCAPE { $$ = make_str("escape"); }
| EXCLUDING { $$ = make_str("excluding"); }
| EXCLUSIVE { $$ = make_str("exclusive"); } | EXCLUSIVE { $$ = make_str("exclusive"); }
| EXECUTE { $$ = make_str("execute"); } | EXECUTE { $$ = make_str("execute"); }
| EXPLAIN { $$ = make_str("explain"); } | EXPLAIN { $$ = make_str("explain"); }
...@@ -5770,6 +5776,7 @@ unreserved_keyword: ...@@ -5770,6 +5776,7 @@ unreserved_keyword:
| IMMEDIATE { $$ = make_str("immediate"); } | IMMEDIATE { $$ = make_str("immediate"); }
| IMMUTABLE { $$ = make_str("immutable"); } | IMMUTABLE { $$ = make_str("immutable"); }
| IMPLICIT_P { $$ = make_str("implicit"); } | IMPLICIT_P { $$ = make_str("implicit"); }
| INCLUDING { $$ = make_str("including"); }
| INCREMENT { $$ = make_str("increment"); } | INCREMENT { $$ = make_str("increment"); }
| INDEX { $$ = make_str("index"); } | INDEX { $$ = make_str("index"); }
| INHERITS { $$ = make_str("inherits"); } | INHERITS { $$ = make_str("inherits"); }
......
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.36 2003/04/08 17:09:51 tgl Exp $ # $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.37 2003/06/25 10:44:21 meskes Exp $
subdir = src/interfaces/ecpg/test subdir = src/interfaces/ecpg/test
top_builddir = ../../../.. top_builddir = ../../../..
...@@ -8,15 +8,21 @@ override CPPFLAGS := -I$(srcdir)/../include $(CPPFLAGS) ...@@ -8,15 +8,21 @@ override CPPFLAGS := -I$(srcdir)/../include $(CPPFLAGS)
ECPG = ../preproc/ecpg -I$(srcdir)/../include ECPG = ../preproc/ecpg -I$(srcdir)/../include
TESTS = test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init testdynalloc num_test dt_test TESTS = test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init testdynalloc num_test dt_test test_informix
all: $(TESTS) all: $(TESTS)
%: %.o %: %.o
$(CC) $(CFLAGS) $(LDFLAGS) -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lpq -o $@ $(CC) $(CFLAGS) $(LDFLAGS) -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lpq -o $@
test_informix: test_informix.o
$(CC) $(CFLAGS) $(LDFLAGS) -L../compatlib -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lecpg_compat -lpq -o $@
%.c: %.pgc %.c: %.pgc
$(ECPG) $< $(ECPG) $<
test_informix.c: test_informix.pgc
$(ECPG) -C INFORMIX $<
clean: clean:
rm -f $(TESTS) $(TESTS:%=%.o) $(TESTS:%=%.c) log rm -f $(TESTS) $(TESTS:%=%.o) $(TESTS:%=%.c) log
#include "sqltypes.h"
void openit(void);
int main()
{
$int i = 14;
$int j;
FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL)
ECPGdebug(1, dbgs);
$connect to mm;
$create table test(i int primary key, j int);
rsetnull(CINTTYPE, (char *)&j);
$insert into test (i, j) values (7, :j);
$insert into test (i, j) values (:i, 1);
$declare c cursor for select * from test where i <= :i;
openit();
j=0;
while (1)
{
$fetch in c into :i, :j;
if (sqlca.sqlcode == 100) break;
else if (sqlca.sqlcode != 0) printf ("Error: %ld\n", sqlca.sqlcode);
if (risnull(CINTTYPE, (char *)&j))
printf("%d\n", i);
else
printf("%d %d\n", i, j);
}
$drop table test;
$disconnect;
return 0;
}
void openit(void)
{
$open c;
}
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