From 46651ce6fe013220ed397add242004d764fc0153 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 14:15:05 +0200 Subject: Adding upstream version 14.5. Signed-off-by: Daniel Baumann --- src/interfaces/ecpg/include/.gitignore | 2 + src/interfaces/ecpg/include/Makefile | 35 ++++++++ src/interfaces/ecpg/include/datetime.h | 14 +++ src/interfaces/ecpg/include/decimal.h | 13 +++ src/interfaces/ecpg/include/ecpg-pthread-win32.h | 58 ++++++++++++ src/interfaces/ecpg/include/ecpg_config.h.in | 18 ++++ src/interfaces/ecpg/include/ecpg_informix.h | 90 +++++++++++++++++++ src/interfaces/ecpg/include/ecpgerrno.h | 79 ++++++++++++++++ src/interfaces/ecpg/include/ecpglib.h | 103 +++++++++++++++++++++ src/interfaces/ecpg/include/ecpgtype.h | 109 +++++++++++++++++++++++ src/interfaces/ecpg/include/pgtypes.h | 17 ++++ src/interfaces/ecpg/include/pgtypes_date.h | 32 +++++++ src/interfaces/ecpg/include/pgtypes_error.h | 18 ++++ src/interfaces/ecpg/include/pgtypes_interval.h | 48 ++++++++++ src/interfaces/ecpg/include/pgtypes_numeric.h | 69 ++++++++++++++ src/interfaces/ecpg/include/pgtypes_timestamp.h | 31 +++++++ src/interfaces/ecpg/include/sql3types.h | 43 +++++++++ src/interfaces/ecpg/include/sqlca.h | 66 ++++++++++++++ src/interfaces/ecpg/include/sqlda-compat.h | 47 ++++++++++ src/interfaces/ecpg/include/sqlda-native.h | 43 +++++++++ src/interfaces/ecpg/include/sqlda.h | 18 ++++ src/interfaces/ecpg/include/sqltypes.h | 57 ++++++++++++ 22 files changed, 1010 insertions(+) create mode 100644 src/interfaces/ecpg/include/.gitignore create mode 100644 src/interfaces/ecpg/include/Makefile create mode 100644 src/interfaces/ecpg/include/datetime.h create mode 100644 src/interfaces/ecpg/include/decimal.h create mode 100644 src/interfaces/ecpg/include/ecpg-pthread-win32.h create mode 100644 src/interfaces/ecpg/include/ecpg_config.h.in create mode 100644 src/interfaces/ecpg/include/ecpg_informix.h create mode 100644 src/interfaces/ecpg/include/ecpgerrno.h create mode 100644 src/interfaces/ecpg/include/ecpglib.h create mode 100644 src/interfaces/ecpg/include/ecpgtype.h create mode 100644 src/interfaces/ecpg/include/pgtypes.h create mode 100644 src/interfaces/ecpg/include/pgtypes_date.h create mode 100644 src/interfaces/ecpg/include/pgtypes_error.h create mode 100644 src/interfaces/ecpg/include/pgtypes_interval.h create mode 100644 src/interfaces/ecpg/include/pgtypes_numeric.h create mode 100644 src/interfaces/ecpg/include/pgtypes_timestamp.h create mode 100644 src/interfaces/ecpg/include/sql3types.h create mode 100644 src/interfaces/ecpg/include/sqlca.h create mode 100644 src/interfaces/ecpg/include/sqlda-compat.h create mode 100644 src/interfaces/ecpg/include/sqlda-native.h create mode 100644 src/interfaces/ecpg/include/sqlda.h create mode 100644 src/interfaces/ecpg/include/sqltypes.h (limited to 'src/interfaces/ecpg/include') diff --git a/src/interfaces/ecpg/include/.gitignore b/src/interfaces/ecpg/include/.gitignore new file mode 100644 index 0000000..608493d --- /dev/null +++ b/src/interfaces/ecpg/include/.gitignore @@ -0,0 +1,2 @@ +/ecpg_config.h +/stamp-h diff --git a/src/interfaces/ecpg/include/Makefile b/src/interfaces/ecpg/include/Makefile new file mode 100644 index 0000000..9c68bf3 --- /dev/null +++ b/src/interfaces/ecpg/include/Makefile @@ -0,0 +1,35 @@ +subdir = src/interfaces/ecpg/include +top_builddir = ../../../.. +include $(top_builddir)/src/Makefile.global + +override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \ + -I$(libpq_srcdir) -I$(top_builddir)/src/port $(CPPFLAGS) + +informix_esql_dir = $(pkgincludedir)/informix/esql +ecpg_config_h = $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h + +all: $(ecpg_config_h) + +install: all installdirs 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 pgtypes_interval.h pgtypes.h \ + sqlda.h sqlda-compat.h sqlda-native.h +informix_headers = datetime.h decimal.h sqltypes.h + +install-headers: $(ecpg_headers) $(informix_headers) installdirs + $(INSTALL_DATA) $(addprefix $(srcdir)/,$(ecpg_headers)) '$(DESTDIR)$(includedir)/' + $(INSTALL_DATA) $(addprefix $(srcdir)/,$(informix_headers)) '$(DESTDIR)$(informix_esql_dir)/' + $(INSTALL_DATA) $(ecpg_config_h) '$(DESTDIR)$(includedir)' + +installdirs: + $(MKDIR_P) '$(DESTDIR)$(includedir)' '$(DESTDIR)$(informix_esql_dir)' + +uninstall: + rm -f $(addprefix '$(DESTDIR)$(includedir)'/, $(ecpg_headers)) + rm -f $(addprefix '$(DESTDIR)$(informix_esql_dir)'/, $(informix_headers)) + rm -f '$(DESTDIR)$(includedir)'/$(notdir $(ecpg_config_h)) + +distclean maintainer-clean: + rm -f ecpg_config.h stamp-h diff --git a/src/interfaces/ecpg/include/datetime.h b/src/interfaces/ecpg/include/datetime.h new file mode 100644 index 0000000..44b2422 --- /dev/null +++ b/src/interfaces/ecpg/include/datetime.h @@ -0,0 +1,14 @@ +/* src/interfaces/ecpg/include/datetime.h */ + +#ifndef _ECPG_DATETIME_H +#define _ECPG_DATETIME_H + +#include + +/* source created by ecpg which defines these symbols */ +#ifndef _ECPGLIB_H +typedef timestamp dtime_t; +typedef interval intrvl_t; +#endif /* ndef _ECPGLIB_H */ + +#endif /* ndef _ECPG_DATETIME_H */ diff --git a/src/interfaces/ecpg/include/decimal.h b/src/interfaces/ecpg/include/decimal.h new file mode 100644 index 0000000..6ac2962 --- /dev/null +++ b/src/interfaces/ecpg/include/decimal.h @@ -0,0 +1,13 @@ +/* src/interfaces/ecpg/include/decimal.h */ + +#ifndef _ECPG_DECIMAL_H +#define _ECPG_DECIMAL_H + +#include + +/* source created by ecpg which defines this */ +#ifndef _ECPGLIB_H +typedef decimal dec_t; +#endif /* ndef _ECPGLIB_H */ + +#endif /* ndef _ECPG_DECIMAL_H */ diff --git a/src/interfaces/ecpg/include/ecpg-pthread-win32.h b/src/interfaces/ecpg/include/ecpg-pthread-win32.h new file mode 100644 index 0000000..33c897b --- /dev/null +++ b/src/interfaces/ecpg/include/ecpg-pthread-win32.h @@ -0,0 +1,58 @@ +/* src/interfaces/ecpg/include/ecpg-pthread-win32.h */ +/* + * pthread mapping macros for win32 native thread implementation + */ +#ifndef _ECPG_PTHREAD_WIN32_H +#define _ECPG_PTHREAD_WIN32_H + +#ifdef ENABLE_THREAD_SAFETY + +#ifndef WIN32 + +#include +#else + +typedef struct pthread_mutex_t +{ + HANDLE handle; + LONG initlock; +} pthread_mutex_t; + +typedef DWORD pthread_key_t; +typedef bool pthread_once_t; + +#define PTHREAD_MUTEX_INITIALIZER { NULL, 0 } +#define PTHREAD_ONCE_INIT false + +void win32_pthread_mutex(volatile pthread_mutex_t *mutex); +void win32_pthread_once(volatile pthread_once_t *once, void (*fn) (void)); + +#define pthread_mutex_lock(mutex) \ + do { \ + if ((mutex)->handle == NULL) \ + win32_pthread_mutex((mutex)); \ + WaitForSingleObject((mutex)->handle, INFINITE); \ + } while(0) + +#define pthread_mutex_unlock(mutex) \ + ReleaseMutex((mutex)->handle) + +#define pthread_getspecific(key) \ + TlsGetValue((key)) + +#define pthread_setspecific(key, value) \ + TlsSetValue((key), (value)) + +/* FIXME: destructor is never called in Win32. */ +#define pthread_key_create(key, destructor) \ + do { *(key) = TlsAlloc(); ((void)(destructor)); } while(0) + +#define pthread_once(once, fn) \ + do { \ + if (!*(once)) \ + win32_pthread_once((once), (fn)); \ + } while(0) +#endif /* WIN32 */ +#endif /* ENABLE_THREAD_SAFETY */ + +#endif /* _ECPG_PTHREAD_WIN32_H */ diff --git a/src/interfaces/ecpg/include/ecpg_config.h.in b/src/interfaces/ecpg/include/ecpg_config.h.in new file mode 100644 index 0000000..17e93c4 --- /dev/null +++ b/src/interfaces/ecpg/include/ecpg_config.h.in @@ -0,0 +1,18 @@ +/* Define to 1 if the system has the type `int64'. */ +#undef HAVE_INT64 + +/* Define to 1 if `long int' works and is 64 bits. */ +#undef HAVE_LONG_INT_64 + +/* Define to 1 if the system has the type `long long int'. */ +#define HAVE_LONG_LONG_INT 1 + +/* Define to 1 if `long long int' works and is 64 bits. */ +#undef HAVE_LONG_LONG_INT_64 + +/* Define to 1 to use to define type bool. */ +#undef PG_USE_STDBOOL + +/* Define to 1 to build client libraries as thread-safe code. + * (--enable-thread-safety) */ +#undef ENABLE_THREAD_SAFETY diff --git a/src/interfaces/ecpg/include/ecpg_informix.h b/src/interfaces/ecpg/include/ecpg_informix.h new file mode 100644 index 0000000..a5260a5 --- /dev/null +++ b/src/interfaces/ecpg/include/ecpg_informix.h @@ -0,0 +1,90 @@ +/* + * This file contains stuff needed to be as compatible to Informix as possible. + * src/interfaces/ecpg/include/ecpg_informix.h + */ +#ifndef _ECPG_INFORMIX_H +#define _ECPG_INFORMIX_H + +#include +#include +#include +#include +#include + +#define SQLNOTFOUND 100 + +#define ECPG_INFORMIX_NUM_OVERFLOW -1200 +#define ECPG_INFORMIX_NUM_UNDERFLOW -1201 +#define ECPG_INFORMIX_DIVIDE_ZERO -1202 +#define ECPG_INFORMIX_BAD_YEAR -1204 +#define ECPG_INFORMIX_BAD_MONTH -1205 +#define ECPG_INFORMIX_BAD_DAY -1206 +#define ECPG_INFORMIX_ENOSHORTDATE -1209 +#define ECPG_INFORMIX_DATE_CONVERT -1210 +#define ECPG_INFORMIX_OUT_OF_MEMORY -1211 +#define ECPG_INFORMIX_ENOTDMY -1212 +#define ECPG_INFORMIX_BAD_NUMERIC -1213 +#define ECPG_INFORMIX_BAD_EXPONENT -1216 +#define ECPG_INFORMIX_BAD_DATE -1218 +#define ECPG_INFORMIX_EXTRA_CHARS -1264 + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern int rdatestr(date, char *); +extern void rtoday(date *); +extern int rjulmdy(date, short *); +extern int rdefmtdate(date *, const char *, const char *); +extern int rfmtdate(date, const char *, char *); +extern int rmdyjul(short *, date *); +extern int rstrdate(const char *, date *); +extern int rdayofweek(date); + +extern int rfmtlong(long, const char *, char *); +extern int rgetmsg(int, char *, int); +extern int risnull(int, const char *); +extern int rsetnull(int, char *); +extern int rtypalign(int, int); +extern int rtypmsize(int, int); +extern int rtypwidth(int, int); +extern void rupshift(char *); + +extern int byleng(char *, int); +extern void ldchar(char *, int, char *); + +extern void ECPG_informix_set_var(int, void *, int); +extern void *ECPG_informix_get_var(int); +extern void ECPG_informix_reset_sqlca(void); + +/* Informix defines these in decimal.h */ +int decadd(decimal *, decimal *, decimal *); +int deccmp(decimal *, decimal *); +void deccopy(decimal *, decimal *); +int deccvasc(const char *, int, decimal *); +int deccvdbl(double, decimal *); +int deccvint(int, decimal *); +int deccvlong(long, decimal *); +int decdiv(decimal *, decimal *, decimal *); +int decmul(decimal *, decimal *, decimal *); +int decsub(decimal *, decimal *, decimal *); +int dectoasc(decimal *, char *, int, int); +int dectodbl(decimal *, double *); +int dectoint(decimal *, int *); +int dectolong(decimal *, long *); + +/* Informix defines these in datetime.h */ +extern void dtcurrent(timestamp *); +extern int dtcvasc(char *, timestamp *); +extern int dtsub(timestamp *, timestamp *, interval *); +extern int dttoasc(timestamp *, char *); +extern int dttofmtasc(timestamp *, char *, int, char *); +extern int intoasc(interval *, char *); +extern int dtcvfmtasc(char *, char *, timestamp *); + +#ifdef __cplusplus +} +#endif + +#endif /* ndef _ECPG_INFORMIX_H */ diff --git a/src/interfaces/ecpg/include/ecpgerrno.h b/src/interfaces/ecpg/include/ecpgerrno.h new file mode 100644 index 0000000..c4bc526 --- /dev/null +++ b/src/interfaces/ecpg/include/ecpgerrno.h @@ -0,0 +1,79 @@ +/* src/interfaces/ecpg/include/ecpgerrno.h */ + +#ifndef _ECPG_ERRNO_H +#define _ECPG_ERRNO_H + +#include + +/* This is a list of all error codes the embedded SQL program can return */ +#define ECPG_NO_ERROR 0 +#define ECPG_NOT_FOUND 100 + +/* system error codes returned by ecpglib get the correct number, + * but are made negative + */ +#define ECPG_OUT_OF_MEMORY -ENOMEM + +/* first we have a set of ecpg messages, they start at 200 */ +#define ECPG_UNSUPPORTED -200 +#define ECPG_TOO_MANY_ARGUMENTS -201 +#define ECPG_TOO_FEW_ARGUMENTS -202 +#define ECPG_TOO_MANY_MATCHES -203 +#define ECPG_INT_FORMAT -204 +#define ECPG_UINT_FORMAT -205 +#define ECPG_FLOAT_FORMAT -206 +#define ECPG_NUMERIC_FORMAT -207 +#define ECPG_INTERVAL_FORMAT -208 +#define ECPG_DATE_FORMAT -209 +#define ECPG_TIMESTAMP_FORMAT -210 +#define ECPG_CONVERT_BOOL -211 +#define ECPG_EMPTY -212 +#define ECPG_MISSING_INDICATOR -213 +#define ECPG_NO_ARRAY -214 +#define ECPG_DATA_NOT_ARRAY -215 +#define ECPG_ARRAY_INSERT -216 + +#define ECPG_NO_CONN -220 +#define ECPG_NOT_CONN -221 + +#define ECPG_INVALID_STMT -230 + +/* dynamic SQL related */ +#define ECPG_UNKNOWN_DESCRIPTOR -240 +#define ECPG_INVALID_DESCRIPTOR_INDEX -241 +#define ECPG_UNKNOWN_DESCRIPTOR_ITEM -242 +#define ECPG_VAR_NOT_NUMERIC -243 +#define ECPG_VAR_NOT_CHAR -244 + +/* finally the backend error messages, they start at 400 */ +#define ECPG_PGSQL -400 +#define ECPG_TRANS -401 +#define ECPG_CONNECT -402 +#define ECPG_DUPLICATE_KEY -403 +#define ECPG_SUBSELECT_NOT_ONE -404 + +/* for compatibility we define some different error codes for the same error + * if adding a new one make sure to not double define it */ +#define ECPG_INFORMIX_DUPLICATE_KEY -239 +#define ECPG_INFORMIX_SUBSELECT_NOT_ONE -284 + +/* backend WARNINGs, starting at 600 */ +#define ECPG_WARNING_UNRECOGNIZED -600 + /* WARNING: (transaction aborted): queries ignored until END */ + + /* + * WARNING: current transaction is aborted, queries ignored until end of + * transaction block + */ +#define ECPG_WARNING_QUERY_IGNORED -601 + /* WARNING: PerformPortalClose: portal "*" not found */ +#define ECPG_WARNING_UNKNOWN_PORTAL -602 + /* WARNING: BEGIN: already a transaction in progress */ +#define ECPG_WARNING_IN_TRANSACTION -603 + /* WARNING: AbortTransaction and not in in-progress state */ + /* WARNING: COMMIT: no transaction in progress */ +#define ECPG_WARNING_NO_TRANSACTION -604 + /* WARNING: BlankPortalAssignName: portal * already exists */ +#define ECPG_WARNING_PORTAL_EXISTS -605 + +#endif /* !_ECPG_ERRNO_H */ diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h new file mode 100644 index 0000000..0024010 --- /dev/null +++ b/src/interfaces/ecpg/include/ecpglib.h @@ -0,0 +1,103 @@ +/* + * Client-visible declarations for ecpglib + * + * src/interfaces/ecpg/include/ecpglib.h + */ + +#ifndef _ECPGLIB_H +#define _ECPGLIB_H + +#include + +#include "ecpg_config.h" +#include "ecpgtype.h" +#include "libpq-fe.h" +#include "sqlca.h" + +/* + * This is a small extract from c.h since we don't want to leak all postgres + * definitions into ecpg programs; but we need to know what bool is. + */ +#ifndef __cplusplus + +#ifdef PG_USE_STDBOOL +#include +#else + +/* + * We assume bool has been defined if true and false are. This avoids + * duplicate-typedef errors if this file is included after c.h. + */ +#if !(defined(true) && defined(false)) +typedef unsigned char bool; +#endif + +#ifndef true +#define true ((bool) 1) +#endif + +#ifndef false +#define false ((bool) 0) +#endif + +#endif /* not PG_USE_STDBOOL */ +#endif /* not C++ */ + + +#ifdef __cplusplus +extern "C" +{ +#endif + +void ECPGdebug(int, FILE *); +bool ECPGstatus(int, const char *); +bool ECPGsetcommit(int, const char *, const char *); +bool ECPGsetconn(int, const char *); +bool ECPGconnect(int, int, const char *, const char *, const char *, const char *, int); +bool ECPGdo(const int, const int, const int, const char *, const bool, const int, const char *,...); +bool ECPGtrans(int, const char *, const char *); +bool ECPGdisconnect(int, const char *); +bool ECPGprepare(int, const char *, const bool, const char *, const char *); +bool ECPGdeallocate(int, int, const char *, const char *); +bool ECPGdeallocate_all(int, int, const char *); +char *ECPGprepared_statement(const char *, const char *, int); +PGconn *ECPGget_PGconn(const char *); +PGTransactionStatusType ECPGtransactionStatus(const char *); + + /* print an error message */ +void sqlprint(void); + +/* define this for simplicity as well as compatibility */ + +#define SQLCODE sqlca.sqlcode +#define SQLSTATE sqlca.sqlstate + +/* dynamic SQL */ + +bool ECPGdo_descriptor(int, const char *, const char *, const char *); +bool ECPGdeallocate_desc(int, const char *); +bool ECPGallocate_desc(int, const char *); +bool ECPGget_desc_header(int, const char *, int *); +bool ECPGget_desc(int, const char *, int,...); +bool ECPGset_desc_header(int, const char *, int); +bool ECPGset_desc(int, const char *, int,...); + +void ECPGset_noind_null(enum ECPGttype, void *); +bool ECPGis_noind_null(enum ECPGttype, const void *); +bool ECPGdescribe(int, int, bool, const char *, const char *,...); + +void ECPGset_var(int, void *, int); +void *ECPGget_var(int number); + +/* dynamic result allocation */ +void ECPGfree_auto_mem(void); + +#ifdef ENABLE_THREAD_SAFETY +void ecpg_pthreads_init(void); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _ECPGLIB_H */ diff --git a/src/interfaces/ecpg/include/ecpgtype.h b/src/interfaces/ecpg/include/ecpgtype.h new file mode 100644 index 0000000..3a57508 --- /dev/null +++ b/src/interfaces/ecpg/include/ecpgtype.h @@ -0,0 +1,109 @@ +/* + * This file implements a data structure that is built and maintained by the + * preprocessor. + * + * All types that can be handled for host variable declarations has to + * be handled eventually. + * + * src/interfaces/ecpg/include/ecpgtype.h + */ + +/* + * Here are all the types that we are to handle. Note that it is the type + * that is registered and that has nothing whatsoever to do with the storage + * class. + * + * Simple types + * integers: char, short, int, long (signed and unsigned) + * floats: float, double + * + * Complex types: + * VARCHAR, VARCHAR2 - Strings with length (maxlen is given in the declaration) + * Arrays of simple types and of VARCHAR, VARCHAR2 (size given in declaration) + * Records build of simple types, arrays and other structs. + * + * Complicating things: + * typedefs and struct names! + * + * Conclusion: + * This is a typically recursive definition. A structure of typed list elements + * would probably work fine: + */ + +#ifndef _ECPGTYPE_H +#define _ECPGTYPE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +enum ECPGttype +{ + ECPGt_char = 1, ECPGt_unsigned_char, ECPGt_short, ECPGt_unsigned_short, + ECPGt_int, ECPGt_unsigned_int, ECPGt_long, ECPGt_unsigned_long, + ECPGt_long_long, ECPGt_unsigned_long_long, + ECPGt_bool, + ECPGt_float, ECPGt_double, + ECPGt_varchar, ECPGt_varchar2, + ECPGt_numeric, /* this is a decimal that stores its digits in + * a malloced array */ + ECPGt_decimal, /* this is a decimal that stores its digits in + * a fixed array */ + ECPGt_date, + ECPGt_timestamp, + ECPGt_interval, + ECPGt_array, + ECPGt_struct, + ECPGt_union, + ECPGt_descriptor, /* sql descriptor, no C variable */ + ECPGt_char_variable, + ECPGt_const, /* a constant is needed sometimes */ + ECPGt_EOIT, /* End of insert types. */ + ECPGt_EORT, /* End of result types. */ + ECPGt_NO_INDICATOR, /* no indicator */ + ECPGt_string, /* trimmed (char *) type */ + ECPGt_sqlda, /* C struct descriptor */ + ECPGt_bytea +}; + + /* descriptor items */ +enum ECPGdtype +{ + ECPGd_count = 1, + ECPGd_data, + ECPGd_di_code, + ECPGd_di_precision, + ECPGd_indicator, + ECPGd_key_member, + ECPGd_length, + ECPGd_name, + ECPGd_nullable, + ECPGd_octet, + ECPGd_precision, + ECPGd_ret_length, + ECPGd_ret_octet, + ECPGd_scale, + ECPGd_type, + ECPGd_EODT, /* End of descriptor types. */ + ECPGd_cardinality +}; + +#define IS_SIMPLE_TYPE(type) (((type) >= ECPGt_char && (type) <= ECPGt_interval) || ((type) == ECPGt_string) || ((type) == ECPGt_bytea)) + +/* we also have to handle different statement types */ +enum ECPG_statement_type +{ + ECPGst_normal, + ECPGst_execute, + ECPGst_exec_immediate, + ECPGst_prepnormal, + ECPGst_prepare, + ECPGst_exec_with_exprlist +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _ECPGTYPE_H */ diff --git a/src/interfaces/ecpg/include/pgtypes.h b/src/interfaces/ecpg/include/pgtypes.h new file mode 100644 index 0000000..dbf759b --- /dev/null +++ b/src/interfaces/ecpg/include/pgtypes.h @@ -0,0 +1,17 @@ +/* src/interfaces/ecpg/include/pgtypes.h */ + +#ifndef PGTYPES_H +#define PGTYPES_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern void PGTYPESchar_free(char *ptr); + +#ifdef __cplusplus +} +#endif + +#endif /* PGTYPES_H */ diff --git a/src/interfaces/ecpg/include/pgtypes_date.h b/src/interfaces/ecpg/include/pgtypes_date.h new file mode 100644 index 0000000..c668097 --- /dev/null +++ b/src/interfaces/ecpg/include/pgtypes_date.h @@ -0,0 +1,32 @@ +/* src/interfaces/ecpg/include/pgtypes_date.h */ + +#ifndef PGTYPES_DATETIME +#define PGTYPES_DATETIME + +#include +#include + +typedef long date; + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern date * PGTYPESdate_new(void); +extern void PGTYPESdate_free(date *); +extern date PGTYPESdate_from_asc(char *, char **); +extern char *PGTYPESdate_to_asc(date); +extern date PGTYPESdate_from_timestamp(timestamp); +extern void PGTYPESdate_julmdy(date, int *); +extern void PGTYPESdate_mdyjul(int *, date *); +extern int PGTYPESdate_dayofweek(date); +extern void PGTYPESdate_today(date *); +extern int PGTYPESdate_defmt_asc(date *, const char *, const char *); +extern int PGTYPESdate_fmt_asc(date, const char *, char *); + +#ifdef __cplusplus +} +#endif + +#endif /* PGTYPES_DATETIME */ diff --git a/src/interfaces/ecpg/include/pgtypes_error.h b/src/interfaces/ecpg/include/pgtypes_error.h new file mode 100644 index 0000000..9fc22a2 --- /dev/null +++ b/src/interfaces/ecpg/include/pgtypes_error.h @@ -0,0 +1,18 @@ +/* src/interfaces/ecpg/include/pgtypes_error.h */ + +#define PGTYPES_NUM_OVERFLOW 301 +#define PGTYPES_NUM_BAD_NUMERIC 302 +#define PGTYPES_NUM_DIVIDE_ZERO 303 +#define PGTYPES_NUM_UNDERFLOW 304 + +#define PGTYPES_DATE_BAD_DATE 310 +#define PGTYPES_DATE_ERR_EARGS 311 +#define PGTYPES_DATE_ERR_ENOSHORTDATE 312 +#define PGTYPES_DATE_ERR_ENOTDMY 313 +#define PGTYPES_DATE_BAD_DAY 314 +#define PGTYPES_DATE_BAD_MONTH 315 + +#define PGTYPES_TS_BAD_TIMESTAMP 320 +#define PGTYPES_TS_ERR_EINFTIME 321 + +#define PGTYPES_INTVL_BAD_INTERVAL 330 diff --git a/src/interfaces/ecpg/include/pgtypes_interval.h b/src/interfaces/ecpg/include/pgtypes_interval.h new file mode 100644 index 0000000..3b17cd1 --- /dev/null +++ b/src/interfaces/ecpg/include/pgtypes_interval.h @@ -0,0 +1,48 @@ +/* src/interfaces/ecpg/include/pgtypes_interval.h */ + +#ifndef PGTYPES_INTERVAL +#define PGTYPES_INTERVAL + +#include +#include + +#ifndef C_H + +#ifdef HAVE_LONG_INT_64 +#ifndef HAVE_INT64 +typedef long int int64; +#endif +#elif defined(HAVE_LONG_LONG_INT_64) +#ifndef HAVE_INT64 +typedef long long int int64; +#endif +#else +/* neither HAVE_LONG_INT_64 nor HAVE_LONG_LONG_INT_64 */ +#error must have a working 64-bit integer datatype +#endif + +#define HAVE_INT64_TIMESTAMP +#endif /* C_H */ + +typedef struct +{ + int64 time; /* all time units other than months and years */ + long month; /* months and years, after time for alignment */ +} interval; + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern interval * PGTYPESinterval_new(void); +extern void PGTYPESinterval_free(interval *); +extern interval * PGTYPESinterval_from_asc(char *, char **); +extern char *PGTYPESinterval_to_asc(interval *); +extern int PGTYPESinterval_copy(interval *, interval *); + +#ifdef __cplusplus +} +#endif + +#endif /* PGTYPES_INTERVAL */ diff --git a/src/interfaces/ecpg/include/pgtypes_numeric.h b/src/interfaces/ecpg/include/pgtypes_numeric.h new file mode 100644 index 0000000..5c763a9 --- /dev/null +++ b/src/interfaces/ecpg/include/pgtypes_numeric.h @@ -0,0 +1,69 @@ +#ifndef PGTYPES_NUMERIC +#define PGTYPES_NUMERIC + +#include + +#define NUMERIC_POS 0x0000 +#define NUMERIC_NEG 0x4000 +#define NUMERIC_NAN 0xC000 +#define NUMERIC_NULL 0xF000 +#define NUMERIC_MAX_PRECISION 1000 +#define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION +#define NUMERIC_MIN_DISPLAY_SCALE 0 +#define NUMERIC_MIN_SIG_DIGITS 16 + +#define DECSIZE 30 + +typedef unsigned char NumericDigit; +typedef struct +{ + int ndigits; /* number of digits in digits[] - can be 0! */ + int weight; /* weight of first digit */ + int rscale; /* result scale */ + int dscale; /* display scale */ + int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */ + NumericDigit *buf; /* start of alloc'd space for digits[] */ + NumericDigit *digits; /* decimal digits */ +} numeric; + +typedef struct +{ + int ndigits; /* number of digits in digits[] - can be 0! */ + int weight; /* weight of first digit */ + int rscale; /* result scale */ + int dscale; /* display scale */ + int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */ + NumericDigit digits[DECSIZE]; /* decimal digits */ +} decimal; + +#ifdef __cplusplus +extern "C" +{ +#endif + +numeric *PGTYPESnumeric_new(void); +decimal *PGTYPESdecimal_new(void); +void PGTYPESnumeric_free(numeric *); +void PGTYPESdecimal_free(decimal *); +numeric *PGTYPESnumeric_from_asc(char *, char **); +char *PGTYPESnumeric_to_asc(numeric *, int); +int PGTYPESnumeric_add(numeric *, numeric *, numeric *); +int PGTYPESnumeric_sub(numeric *, numeric *, numeric *); +int PGTYPESnumeric_mul(numeric *, numeric *, numeric *); +int PGTYPESnumeric_div(numeric *, numeric *, numeric *); +int PGTYPESnumeric_cmp(numeric *, numeric *); +int PGTYPESnumeric_from_int(signed int, numeric *); +int PGTYPESnumeric_from_long(signed long int, numeric *); +int PGTYPESnumeric_copy(numeric *, numeric *); +int PGTYPESnumeric_from_double(double, numeric *); +int PGTYPESnumeric_to_double(numeric *, double *); +int PGTYPESnumeric_to_int(numeric *, int *); +int PGTYPESnumeric_to_long(numeric *, long *); +int PGTYPESnumeric_to_decimal(numeric *, decimal *); +int PGTYPESnumeric_from_decimal(decimal *, numeric *); + +#ifdef __cplusplus +} +#endif + +#endif /* PGTYPES_NUMERIC */ diff --git a/src/interfaces/ecpg/include/pgtypes_timestamp.h b/src/interfaces/ecpg/include/pgtypes_timestamp.h new file mode 100644 index 0000000..3e29837 --- /dev/null +++ b/src/interfaces/ecpg/include/pgtypes_timestamp.h @@ -0,0 +1,31 @@ +/* src/interfaces/ecpg/include/pgtypes_timestamp.h */ + +#ifndef PGTYPES_TIMESTAMP +#define PGTYPES_TIMESTAMP + +#include +/* pgtypes_interval.h includes ecpg_config.h */ +#include + +typedef int64 timestamp; +typedef int64 TimestampTz; + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern timestamp PGTYPEStimestamp_from_asc(char *, char **); +extern char *PGTYPEStimestamp_to_asc(timestamp); +extern int PGTYPEStimestamp_sub(timestamp *, timestamp *, interval *); +extern int PGTYPEStimestamp_fmt_asc(timestamp *, char *, int, const char *); +extern void PGTYPEStimestamp_current(timestamp *); +extern int PGTYPEStimestamp_defmt_asc(const char *, const char *, timestamp *); +extern int PGTYPEStimestamp_add_interval(timestamp * tin, interval * span, timestamp * tout); +extern int PGTYPEStimestamp_sub_interval(timestamp * tin, interval * span, timestamp * tout); + +#ifdef __cplusplus +} +#endif + +#endif /* PGTYPES_TIMESTAMP */ diff --git a/src/interfaces/ecpg/include/sql3types.h b/src/interfaces/ecpg/include/sql3types.h new file mode 100644 index 0000000..644b616 --- /dev/null +++ b/src/interfaces/ecpg/include/sql3types.h @@ -0,0 +1,43 @@ +#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 */ diff --git a/src/interfaces/ecpg/include/sqlca.h b/src/interfaces/ecpg/include/sqlca.h new file mode 100644 index 0000000..c5f107d --- /dev/null +++ b/src/interfaces/ecpg/include/sqlca.h @@ -0,0 +1,66 @@ +#ifndef POSTGRES_SQLCA_H +#define POSTGRES_SQLCA_H + +#ifndef PGDLLIMPORT +#if defined(WIN32) || defined(__CYGWIN__) +#define PGDLLIMPORT __declspec (dllimport) +#else +#define PGDLLIMPORT +#endif /* __CYGWIN__ */ +#endif /* PGDLLIMPORT */ + +#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 diff --git a/src/interfaces/ecpg/include/sqlda-compat.h b/src/interfaces/ecpg/include/sqlda-compat.h new file mode 100644 index 0000000..7b0ac45 --- /dev/null +++ b/src/interfaces/ecpg/include/sqlda-compat.h @@ -0,0 +1,47 @@ +/* + * src/interfaces/ecpg/include/sqlda-compat.h + */ + +#ifndef ECPG_SQLDA_COMPAT_H +#define ECPG_SQLDA_COMPAT_H + +struct sqlvar_compat +{ + short sqltype; /* variable type */ + int sqllen; /* length in bytes */ + char *sqldata; /* pointer to data */ + short *sqlind; /* pointer to indicator */ + char *sqlname; /* variable name */ + char *sqlformat; /* reserved for future use */ + short sqlitype; /* ind variable type */ + short sqlilen; /* ind length in bytes */ + char *sqlidata; /* ind data pointer */ + int sqlxid; /* extended id type */ + char *sqltypename; /* extended type name */ + short sqltypelen; /* length of extended type name */ + short sqlownerlen; /* length of owner name */ + short sqlsourcetype; /* source type for distinct of built-ins */ + char *sqlownername; /* owner name */ + int sqlsourceid; /* extended id of source type */ + + /* + * sqlilongdata is new. It supports data that exceeds the 32k limit. + * sqlilen and sqlidata are for backward compatibility and they have + * maximum value of <32K. + */ + char *sqlilongdata; /* for data field beyond 32K */ + int sqlflags; /* for internal use only */ + void *sqlreserved; /* reserved for future use */ +}; + +struct sqlda_compat +{ + short sqld; + struct sqlvar_compat *sqlvar; + char desc_name[19]; /* descriptor name */ + short desc_occ; /* size of sqlda structure */ + struct sqlda_compat *desc_next; /* pointer to next sqlda struct */ + void *reserved; /* reserved for future use */ +}; + +#endif /* ECPG_SQLDA_COMPAT_H */ diff --git a/src/interfaces/ecpg/include/sqlda-native.h b/src/interfaces/ecpg/include/sqlda-native.h new file mode 100644 index 0000000..9e73f1f --- /dev/null +++ b/src/interfaces/ecpg/include/sqlda-native.h @@ -0,0 +1,43 @@ +/* + * src/interfaces/ecpg/include/sqlda-native.h + */ + +#ifndef ECPG_SQLDA_NATIVE_H +#define ECPG_SQLDA_NATIVE_H + +/* + * Maximum length for identifiers (e.g. table names, column names, + * function names). Names actually are limited to one fewer byte than this, + * because the length must include a trailing zero byte. + * + * This should be at least as much as NAMEDATALEN of the database the + * applications run against. + */ +#define NAMEDATALEN 64 + +struct sqlname +{ + short length; + char data[NAMEDATALEN]; +}; + +struct sqlvar_struct +{ + short sqltype; + short sqllen; + char *sqldata; + short *sqlind; + struct sqlname sqlname; +}; + +struct sqlda_struct +{ + char sqldaid[8]; + long sqldabc; + short sqln; + short sqld; + struct sqlda_struct *desc_next; + struct sqlvar_struct sqlvar[1]; +}; + +#endif /* ECPG_SQLDA_NATIVE_H */ diff --git a/src/interfaces/ecpg/include/sqlda.h b/src/interfaces/ecpg/include/sqlda.h new file mode 100644 index 0000000..d810e73 --- /dev/null +++ b/src/interfaces/ecpg/include/sqlda.h @@ -0,0 +1,18 @@ +#ifndef ECPG_SQLDA_H +#define ECPG_SQLDA_H + +#ifdef _ECPG_INFORMIX_H + +#include "sqlda-compat.h" +typedef struct sqlvar_compat sqlvar_t; +typedef struct sqlda_compat sqlda_t; + +#else + +#include "sqlda-native.h" +typedef struct sqlvar_struct sqlvar_t; +typedef struct sqlda_struct sqlda_t; + +#endif + +#endif /* ECPG_SQLDA_H */ diff --git a/src/interfaces/ecpg/include/sqltypes.h b/src/interfaces/ecpg/include/sqltypes.h new file mode 100644 index 0000000..e7cbfa4 --- /dev/null +++ b/src/interfaces/ecpg/include/sqltypes.h @@ -0,0 +1,57 @@ +#ifndef ECPG_SQLTYPES_H +#define ECPG_SQLTYPES_H + +#include + +#define CCHARTYPE ECPGt_char +#define CSHORTTYPE ECPGt_short +#define CINTTYPE ECPGt_int +#define CLONGTYPE ECPGt_long +#define CFLOATTYPE ECPGt_float +#define CDOUBLETYPE ECPGt_double +#define CDECIMALTYPE ECPGt_decimal +#define CFIXCHARTYPE 108 +#define CSTRINGTYPE ECPGt_char +#define CDATETYPE ECPGt_date +#define CMONEYTYPE 111 +#define CDTIMETYPE ECPGt_timestamp +#define CLOCATORTYPE 113 +#define CVCHARTYPE ECPGt_varchar +#define CINVTYPE 115 +#define CFILETYPE 116 +#define CINT8TYPE ECPGt_long_long +#define CCOLLTYPE 118 +#define CLVCHARTYPE 119 +#define CFIXBINTYPE 120 +#define CVARBINTYPE 121 +#define CBOOLTYPE ECPGt_bool +#define CROWTYPE 123 +#define CLVCHARPTRTYPE 124 +#define CTYPEMAX 25 + +/* + * Values used in sqlda->sqlvar[i]->sqltype + */ +#define SQLCHAR ECPGt_char +#define SQLSMINT ECPGt_short +#define SQLINT ECPGt_int +#define SQLFLOAT ECPGt_double +#define SQLSMFLOAT ECPGt_float +#define SQLDECIMAL ECPGt_decimal +#define SQLSERIAL ECPGt_int +#define SQLDATE ECPGt_date +#define SQLDTIME ECPGt_timestamp +#define SQLTEXT ECPGt_char +#define SQLVCHAR ECPGt_char +#define SQLINTERVAL ECPGt_interval +#define SQLNCHAR ECPGt_char +#define SQLNVCHAR ECPGt_char +#ifdef HAVE_LONG_LONG_INT_64 +#define SQLINT8 ECPGt_long_long +#define SQLSERIAL8 ECPGt_long_long +#else +#define SQLINT8 ECPGt_long +#define SQLSERIAL8 ECPGt_long +#endif + +#endif /* ndef ECPG_SQLTYPES_H */ -- cgit v1.2.3