1 /*************************************************************
4 * This is the lowest level include in unixODBC. It defines
5 * the basic types required by unixODBC and is heavily based
6 * upon the MS include of the same name (it has to be for
7 * binary compatibility between drivers developed under different
10 * You can include this file directly but it is almost always
11 * included indirectly, by including.. for example sqlext.h
13 * This include makes no effort to be useful on any platforms other
14 * than Linux (with some exceptions for UNIX in general).
16 * !!!DO NOT CONTAMINATE THIS FILE WITH NON-Linux CODE!!!
18 *************************************************************/
22 /****************************
23 * default to the 3.51 definitions. should define ODBCVER before here if you want an older set of defines
24 ***************************/
26 #define ODBCVER 0x0351
30 * if this is set, then use a 4 byte unicode definition, instead of the 2 bytes that MS uses
33 #ifdef SQL_WCHART_CONVERT
35 * Use this if you want to use the C/C++ portable definition of a wide char, wchar_t
36 * Microsoft hardcoded a definition of unsigned short which may not be compatible with
37 * your platform specific wide char definition.
42 #include <sal/types.h>
48 #ifndef SIZEOF_LONG_INT
49 # define SIZEOF_LONG_INT SAL_TYPES_SIZEOFLONG
52 # define ODBCINT64 sal_Int64
55 # define UODBCINT64 sal_uInt64
59 * this is defined by configure, but will not be on a normal application build
60 * the install creates a unixodbc_conf.h file that contains the current build settings
63 #ifndef SIZEOF_LONG_INT
64 #include <unixodbc_conf.h>
67 #ifndef SIZEOF_LONG_INT
68 #error "Needs to know how big a long int is to continue!!!"
71 /****************************
72 * These make up for having no windows.h
73 ***************************/
74 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
85 * NOTE: The Microsoft unicode define is only for apps that want to use TCHARs and
86 * be able to compile for both unicode and non-unicode with the same source.
87 * This is not recommended for linux applications and is not supported
88 * by the standard linux string header files.
90 #ifdef SQL_WCHART_CONVERT
91 typedef wchar_t TCHAR
;
93 typedef signed short TCHAR
;
104 typedef unsigned short WORD
;
105 #if (SIZEOF_LONG_INT == 4)
106 typedef unsigned long DWORD
;
108 typedef unsigned int DWORD
;
110 typedef unsigned char BYTE
;
112 #ifdef SQL_WCHART_CONVERT
113 typedef wchar_t WCHAR
;
115 typedef unsigned short WCHAR
;
118 typedef WCHAR
* LPWSTR
;
119 typedef const char* LPCSTR
;
120 typedef const WCHAR
* LPCWSTR
;
121 typedef TCHAR
* LPTSTR
;
123 typedef DWORD
* LPDWORD
;
125 typedef void* HINSTANCE
;
130 /****************************
131 * standard SQL* data types. use these as much as possible when using ODBC calls/vars
132 ***************************/
133 typedef unsigned char SQLCHAR
;
135 #if (ODBCVER >= 0x0300)
136 typedef unsigned char SQLDATE
;
137 typedef unsigned char SQLDECIMAL
;
138 typedef double SQLDOUBLE
;
139 typedef double SQLFLOAT
;
143 * can't use a long it fails on 64 platforms
147 * Hopefully by now it should be safe to assume most drivers know about SQLLEN now
148 * and the default is now sizeof( SQLLEN ) = 8 on 64 bit platforms
152 #if (SIZEOF_LONG_INT == 8)
153 #ifdef BUILD_LEGACY_64_BIT_MODE
154 typedef int SQLINTEGER
;
155 typedef unsigned int SQLUINTEGER
;
156 #define SQLLEN SQLINTEGER
157 #define SQLULEN SQLUINTEGER
158 #define SQLSETPOSIROW SQLUSMALLINT
160 * These are not supported on 64bit ODBC according to MS, removed, so use at your peril
162 typedef SQLULEN SQLROWCOUNT;
163 typedef SQLULEN SQLROWSETSIZE;
164 typedef SQLULEN SQLTRANSID;
165 typedef SQLLEN SQLROWOFFSET;
168 typedef int SQLINTEGER
;
169 typedef unsigned int SQLUINTEGER
;
171 typedef unsigned long SQLULEN
;
172 typedef unsigned long SQLSETPOSIROW
;
174 * These are not supported on 64bit ODBC according to MS, removed, so use at your peril
176 typedef SQLULEN SQLTRANSID;
177 typedef SQLULEN SQLROWCOUNT;
178 typedef SQLUINTEGER SQLROWSETSIZE;
179 typedef SQLLEN SQLROWOFFSET;
181 typedef SQLULEN SQLROWCOUNT
;
182 typedef SQLULEN SQLROWSETSIZE
;
183 typedef SQLULEN SQLTRANSID
;
184 typedef SQLLEN SQLROWOFFSET
;
187 typedef long SQLINTEGER
;
188 typedef unsigned long SQLUINTEGER
;
189 #define SQLLEN SQLINTEGER
190 #define SQLULEN SQLUINTEGER
191 #define SQLSETPOSIROW SQLUSMALLINT
192 typedef SQLULEN SQLROWCOUNT
;
193 typedef SQLULEN SQLROWSETSIZE
;
194 typedef SQLULEN SQLTRANSID
;
195 typedef SQLLEN SQLROWOFFSET
;
198 #if (ODBCVER >= 0x0300)
199 typedef unsigned char SQLNUMERIC
;
202 typedef void * SQLPOINTER
;
204 #if (ODBCVER >= 0x0300)
205 typedef float SQLREAL
;
208 typedef signed short int SQLSMALLINT
;
209 typedef unsigned short SQLUSMALLINT
;
211 #if (ODBCVER >= 0x0300)
212 typedef unsigned char SQLTIME
;
213 typedef unsigned char SQLTIMESTAMP
;
214 typedef unsigned char SQLVARCHAR
;
217 typedef SQLSMALLINT SQLRETURN
;
219 #if (ODBCVER >= 0x0300)
220 typedef void * SQLHANDLE
;
221 typedef SQLHANDLE SQLHENV
;
222 typedef SQLHANDLE SQLHDBC
;
223 typedef SQLHANDLE SQLHSTMT
;
224 typedef SQLHANDLE SQLHDESC
;
226 typedef void * SQLHENV
;
227 typedef void * SQLHDBC
;
228 typedef void * SQLHSTMT
;
230 * some things like PHP won't build without this
232 typedef void * SQLHANDLE
;
235 /****************************
236 * These are cast into the actual struct that is being passed around. The
237 * DriverManager knows what its structs look like and the Driver knows about its
238 * structs... the app knows nothing about them... just void*
239 * These are deprecated in favour of SQLHENV, SQLHDBC, SQLHSTMT
240 ***************************/
242 #if (ODBCVER >= 0x0300)
243 typedef SQLHANDLE HENV
;
244 typedef SQLHANDLE HDBC
;
245 typedef SQLHANDLE HSTMT
;
249 typedef void * HSTMT
;
253 /****************************
254 * more basic data types to augment what windows.h provides
255 ***************************/
256 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
258 typedef unsigned char UCHAR
;
259 typedef signed char SCHAR
;
260 typedef SCHAR SQLSCHAR
;
261 #if (SIZEOF_LONG_INT == 4)
262 typedef long int SDWORD
;
263 typedef unsigned long int UDWORD
;
266 typedef unsigned int UDWORD
;
268 typedef signed short int SWORD
;
269 typedef unsigned short int UWORD
;
270 typedef unsigned int UINT
;
271 typedef signed long SLONG
;
272 typedef signed short SSHORT
;
273 typedef unsigned long ULONG
;
274 typedef unsigned short USHORT
;
275 typedef double SDOUBLE
;
276 typedef double LDOUBLE
;
277 typedef float SFLOAT
;
279 typedef signed short RETCODE
;
280 typedef void* SQLHWND
;
284 /****************************
285 * standard structs for working with date/times
286 ***************************/
289 typedef struct tagDATE_STRUCT
296 #if (ODBCVER >= 0x0300)
297 typedef DATE_STRUCT SQL_DATE_STRUCT
;
300 typedef struct tagTIME_STRUCT
307 #if (ODBCVER >= 0x0300)
308 typedef TIME_STRUCT SQL_TIME_STRUCT
;
311 typedef struct tagTIMESTAMP_STRUCT
319 SQLUINTEGER fraction
;
322 #if (ODBCVER >= 0x0300)
323 typedef TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT
;
327 #if (ODBCVER >= 0x0300)
336 SQL_IS_YEAR_TO_MONTH
= 7,
337 SQL_IS_DAY_TO_HOUR
= 8,
338 SQL_IS_DAY_TO_MINUTE
= 9,
339 SQL_IS_DAY_TO_SECOND
= 10,
340 SQL_IS_HOUR_TO_MINUTE
= 11,
341 SQL_IS_HOUR_TO_SECOND
= 12,
342 SQL_IS_MINUTE_TO_SECOND
= 13
347 #if (ODBCVER >= 0x0300)
348 typedef struct tagSQL_YEAR_MONTH
352 } SQL_YEAR_MONTH_STRUCT
;
354 typedef struct tagSQL_DAY_SECOND
360 SQLUINTEGER fraction
;
361 } SQL_DAY_SECOND_STRUCT
;
363 typedef struct tagSQL_INTERVAL_STRUCT
365 SQLINTERVAL interval_type
;
366 SQLSMALLINT interval_sign
;
368 SQL_YEAR_MONTH_STRUCT year_month
;
369 SQL_DAY_SECOND_STRUCT day_second
;
372 } SQL_INTERVAL_STRUCT
;
379 # if (ODBCVER >= 0x0300)
380 # if (SIZEOF_LONG_INT == 8)
381 # define ODBCINT64 long
382 # define UODBCINT64 unsigned long
384 # ifdef HAVE_LONG_LONG
385 # define ODBCINT64 long long
386 # define UODBCINT64 unsigned long long
389 * may fail in some cases, but what else can we do ?
391 struct __bigint_struct
396 struct __bigint_struct_u
401 # define ODBCINT64 struct __bigint_struct
402 # define UODBCINT64 struct __bigint_struct_u
409 typedef ODBCINT64 SQLBIGINT
;
412 typedef UODBCINT64 SQLUBIGINT
;
416 /****************************
417 * cursor and bookmark
418 ***************************/
419 #if (ODBCVER >= 0x0300)
420 #define SQL_MAX_NUMERIC_LEN 16
421 typedef struct tagSQL_NUMERIC_STRUCT
425 SQLCHAR sign
; /* 1=pos 0=neg */
426 SQLCHAR val
[SQL_MAX_NUMERIC_LEN
];
427 } SQL_NUMERIC_STRUCT
;
430 #if (ODBCVER >= 0x0350)
432 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
433 typedef GUID SQLGUID
;
435 typedef struct tagSQLGUID
444 typedef struct tagSQLGUID
454 typedef SQLULEN BOOKMARK
;
456 typedef WCHAR SQLWCHAR
;
459 typedef SQLWCHAR SQLTCHAR
;
461 typedef SQLCHAR SQLTCHAR
;