e576bb2002-10-11Martin Nilsson /* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. */
1b10db2002-10-08Martin Nilsson 
f1e17d1997-03-10Henrik Grubbström (Grubba) /* * Pike interface to ODBC compliant databases. * */ #ifndef PIKE_PRECOMPILED_ODBC_H #define PIKE_PRECOMPILED_ODBC_H /* * Includes */ #ifdef HAVE_CONFIG_H #include "config.h" #endif /* HAVE_CONFIG_H */
1289671999-04-09Marcus Comstedt #ifdef HAVE_ODBC
4a14b21999-03-17Marcus Comstedt #ifdef HAVE_ISQL_H #include <isql.h> #else /* !HAVE_ISQL_H */
f085d11998-10-19Henrik Grubbström (Grubba) #ifdef HAVE_QEODBC_H
f1e17d1997-03-10Henrik Grubbström (Grubba) #include <qeodbc.h>
f085d11998-10-19Henrik Grubbström (Grubba) #else
4203812006-11-06Henrik Grubbström (Grubba) #ifdef HAVE_WINDOWS_H #include <windows.h> #else /* !HAVE_WINDOWS_H */ #ifndef HAVE_SQL_H
f085d11998-10-19Henrik Grubbström (Grubba) #undef HAVE_ODBC
4203812006-11-06Henrik Grubbström (Grubba) #endif /* !HAVE_SQL_H */
f085d11998-10-19Henrik Grubbström (Grubba) #endif /* HAVE_WINDOWS_H */
4203812006-11-06Henrik Grubbström (Grubba) #endif /* HAVE_QEODBC_H */
4a14b21999-03-17Marcus Comstedt #endif /* HAVE_ISQL_H */
1289671999-04-09Marcus Comstedt #endif /* HAVE_ODBC */
f085d11998-10-19Henrik Grubbström (Grubba)  #ifdef HAVE_ODBC
4a14b21999-03-17Marcus Comstedt #ifndef HAVE_ISQL_H
f1e17d1997-03-10Henrik Grubbström (Grubba) #ifdef HAVE_SQL_H #include <sql.h> #endif /* HAVE_SQL_H */
4a14b21999-03-17Marcus Comstedt #endif /* !HAVE_ISQL_H */
4203812006-11-06Henrik Grubbström (Grubba) 
4a14b21999-03-17Marcus Comstedt #ifdef HAVE_ISQLEXT_H #include <isqlext.h> #else /* !HAVE_ISQLEXT_H */
f1e17d1997-03-10Henrik Grubbström (Grubba) #ifdef HAVE_SQLEXT_H #include <sqlext.h> #endif /* HAVE_SQLEXT_H */
4a14b21999-03-17Marcus Comstedt #endif /* HAVE_ISQLEXT_H */
f1e17d1997-03-10Henrik Grubbström (Grubba)  /* * Globals */
ff0bcb2015-12-29Henrik Grubbström (Grubba) extern struct program *Odbc_odbc_program;
ea72502016-04-03Henrik Grubbström (Grubba) extern struct program *Odbc_Result_program; extern struct program *Odbc_TypedResult_program;
f1e17d1997-03-10Henrik Grubbström (Grubba) 
ea72502016-04-03Henrik Grubbström (Grubba) extern int Odbc_Result_program_fun_num; extern int Odbc_TypedResult_program_fun_num;
eeaa802015-02-12Henrik Grubbström (Grubba) 
f1e17d1997-03-10Henrik Grubbström (Grubba) /*
798bda2000-08-30Henrik Grubbström (Grubba)  * Typedefs */
bd4b042000-09-14Henrik Grubbström (Grubba) #ifndef HAVE_SQLSMALLINT typedef SWORD SQLSMALLINT; #endif /* HAVE_SQLSMALLINT */ #ifndef HAVE_SQLUSMALLINT typedef UWORD SQLUSMALLINT; #endif /* HAVE_SQLUSMALLINT */
1a1abf2000-09-14Henrik Grubbström (Grubba) #ifndef HAVE_SQLINTEGER typedef SDWORD SQLINTEGER; #endif /* !HAVE_SQLINTEGER */ #ifndef HAVE_SQLUINTEGER typedef UDWORD SQLUINTEGER; #endif /* !HAVE_SQLUINTEGER */
798bda2000-08-30Henrik Grubbström (Grubba) #ifndef HAVE_SQLLEN typedef SQLINTEGER SQLLEN; #endif /* !HAVE_SQLLEN */
012c912000-08-30Henrik Grubbström (Grubba) #ifndef HAVE_SQLULEN typedef SQLUINTEGER SQLULEN; #endif /* !HAVE_SQLLEN */
8ddb012003-05-02Henrik Grubbström (Grubba) #ifndef HAVE_SQLHENV typedef HENV SQLHENV; #endif /* !HAVE_SQLENV */ #ifndef HAVE_SQLHDBC typedef HDBC SQLHDBC; #endif /* !HAVE_SQLHDBC */ #ifndef HAVE_SQLHSTMT typedef HSTMT SQLHSTMT; #endif /* !HAVE_SQLSTMT */
798bda2000-08-30Henrik Grubbström (Grubba) /*
f1e17d1997-03-10Henrik Grubbström (Grubba)  * Structures */
4dd24b2015-02-16Henrik Grubbström (Grubba) typedef void (*field_factory_func)(int);
f1e17d1997-03-10Henrik Grubbström (Grubba) struct field_info {
1d463a1999-03-28Marcus Comstedt  SWORD type;
4dd24b2015-02-16Henrik Grubbström (Grubba)  SWORD bin_type;
b620322015-02-17Henrik Grubbström (Grubba)  SWORD scale;
5b71352009-05-11Henrik Grubbström (Grubba)  SQLULEN size;
4dd24b2015-02-16Henrik Grubbström (Grubba)  SQLULEN bin_size; field_factory_func factory;
f1e17d1997-03-10Henrik Grubbström (Grubba) };
f661702015-06-27Henrik Grubbström (Grubba) struct Odbc_odbc_struct;
f1e17d1997-03-10Henrik Grubbström (Grubba)  /* * Defines */
f661702015-06-27Henrik Grubbström (Grubba) #define PIKE_ODBC THIS_ODBC_ODBC #define PIKE_ODBC_RES THIS_ODBC_RESULT
f1e17d1997-03-10Henrik Grubbström (Grubba) 
bef4eb1998-05-31Henrik Grubbström (Grubba) /* Flags */
d390952015-12-29Henrik Grubbström (Grubba) #define PIKE_ODBC_CONNECTED 1 #define PIKE_ODBC_OLD_TDS_KLUDGE 2 /* String shift used for wide data. */ #define PIKE_ODBC_WDATA_SHIFT_SHIFT 2 #define PIKE_ODBC_WDATA_SHIFT_MASK 12 /* String shift used for wide labels. */ #define PIKE_ODBC_WLABEL_SHIFT_SHIFT 4 #define PIKE_ODBC_WLABEL_SHIFT_MASK 48 /* String shift used for wide queries. */ #define PIKE_ODBC_WQUERY_SHIFT_SHIFT 6 #define PIKE_ODBC_WQUERY_SHIFT_MASK 192
bef4eb1998-05-31Henrik Grubbström (Grubba) 
5553ac2007-12-07Martin Stjernholm /* http://msdn2.microsoft.com/en-us/library/ms715361.aspx says: * * On multithread operating systems, drivers must be thread-safe. * That is, it must be possible for applications to use the same * handle on more than one thread. * * This means we don't need a lock at all on the connection when we * release the interpreter lock. If this really is true remains to be * seen.. */ #define ODBC_ALLOW() THREADS_ALLOW() #define ODBC_DISALLOW() THREADS_DISALLOW()
f1e17d1997-03-10Henrik Grubbström (Grubba) /* * Prototypes */
f661702015-06-27Henrik Grubbström (Grubba) SQLHDBC pike_odbc_get_hdbc(struct Odbc_odbc_struct *odbc); void pike_odbc_set_affected_rows(struct Odbc_odbc_struct *odbc, SQLLEN rows); unsigned int pike_odbc_get_flags(struct Odbc_odbc_struct *odbc);
6cdcda2016-01-05Henrik Grubbström (Grubba) void push_sqlwchar(SQLWCHAR *str, size_t len);
c2b2631997-11-02Henrik Grubbström (Grubba) void odbc_error(const char *fun, const char *msg,
f661702015-06-27Henrik Grubbström (Grubba)  struct Odbc_odbc_struct *odbc, SQLHSTMT hstmt,
101ee52006-02-03Henrik Grubbström (Grubba)  RETCODE code, void (*clean)(void *), void *clean_arg);
f1e17d1997-03-10Henrik Grubbström (Grubba) 
23dc931997-06-10Henrik Grubbström (Grubba) void init_odbc_res_programs(void); void exit_odbc_res(void);
f085d11998-10-19Henrik Grubbström (Grubba) #endif /* HAVE_ODBC */
f1e17d1997-03-10Henrik Grubbström (Grubba) #endif /* PIKE_PRECOMPILED_ODBC_H */