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
84 * NOTE: The Microsoft unicode define is only for apps that want to use TCHARs and
85 * be able to compile for both unicode and non-unicode with the same source.
86 * This is not recommended for linux applications and is not supported
87 * by the standard linux string header files.
89 #ifdef SQL_WCHART_CONVERT
90 typedef wchar_t TCHAR
;
92 typedef signed short TCHAR
;
103 typedef unsigned short WORD
;
104 #if (SIZEOF_LONG_INT == 4)
105 typedef unsigned long DWORD
;
107 typedef unsigned int DWORD
;
109 typedef unsigned char BYTE
;
111 #ifdef SQL_WCHART_CONVERT
112 typedef wchar_t WCHAR
;
114 typedef unsigned short WCHAR
;
117 typedef WCHAR
* LPWSTR
;
118 typedef const char* LPCSTR
;
119 typedef const WCHAR
* LPCWSTR
;
120 typedef TCHAR
* LPTSTR
;
122 typedef DWORD
* LPDWORD
;
124 typedef void* HINSTANCE
;
129 /****************************
130 * standard SQL* data types. use these as much as possible when using ODBC calls/vars
131 ***************************/
132 typedef unsigned char SQLCHAR
;
134 #if (ODBCVER >= 0x0300)
135 typedef unsigned char SQLDATE
;
136 typedef unsigned char SQLDECIMAL
;
137 typedef double SQLDOUBLE
;
138 typedef double SQLFLOAT
;
142 * can't use a long it fails on 64 platforms
146 * Hopefully by now it should be safe to assume most drivers know about SQLLEN now
147 * and the default is now sizeof( SQLLEN ) = 8 on 64 bit platforms
151 #if (SIZEOF_LONG_INT == 8)
152 #ifdef BUILD_LEGACY_64_BIT_MODE
153 typedef int SQLINTEGER
;
154 typedef unsigned int SQLUINTEGER
;
155 #define SQLLEN SQLINTEGER
156 #define SQLULEN SQLUINTEGER
157 #define SQLSETPOSIROW SQLUSMALLINT
159 * These are not supported on 64bit ODBC according to MS, removed, so use at your peril
161 typedef SQLULEN SQLROWCOUNT;
162 typedef SQLULEN SQLROWSETSIZE;
163 typedef SQLULEN SQLTRANSID;
164 typedef SQLLEN SQLROWOFFSET;
167 typedef int SQLINTEGER
;
168 typedef unsigned int SQLUINTEGER
;
170 typedef unsigned long SQLULEN
;
171 typedef unsigned long SQLSETPOSIROW
;
173 * These are not supported on 64bit ODBC according to MS, removed, so use at your peril
175 typedef SQLULEN SQLTRANSID;
176 typedef SQLULEN SQLROWCOUNT;
177 typedef SQLUINTEGER SQLROWSETSIZE;
178 typedef SQLLEN SQLROWOFFSET;
180 typedef SQLULEN SQLROWCOUNT
;
181 typedef SQLULEN SQLROWSETSIZE
;
182 typedef SQLULEN SQLTRANSID
;
183 typedef SQLLEN SQLROWOFFSET
;
186 typedef long SQLINTEGER
;
187 typedef unsigned long SQLUINTEGER
;
188 #define SQLLEN SQLINTEGER
189 #define SQLULEN SQLUINTEGER
190 #define SQLSETPOSIROW SQLUSMALLINT
191 typedef SQLULEN SQLROWCOUNT
;
192 typedef SQLULEN SQLROWSETSIZE
;
193 typedef SQLULEN SQLTRANSID
;
194 typedef SQLLEN SQLROWOFFSET
;
197 #if (ODBCVER >= 0x0300)
198 typedef unsigned char SQLNUMERIC
;
201 typedef void * SQLPOINTER
;
203 #if (ODBCVER >= 0x0300)
204 typedef float SQLREAL
;
207 typedef signed short int SQLSMALLINT
;
208 typedef unsigned short SQLUSMALLINT
;
210 #if (ODBCVER >= 0x0300)
211 typedef unsigned char SQLTIME
;
212 typedef unsigned char SQLTIMESTAMP
;
213 typedef unsigned char SQLVARCHAR
;
216 typedef SQLSMALLINT SQLRETURN
;
218 #if (ODBCVER >= 0x0300)
219 typedef void * SQLHANDLE
;
220 typedef SQLHANDLE SQLHENV
;
221 typedef SQLHANDLE SQLHDBC
;
222 typedef SQLHANDLE SQLHSTMT
;
223 typedef SQLHANDLE SQLHDESC
;
225 typedef void * SQLHENV
;
226 typedef void * SQLHDBC
;
227 typedef void * SQLHSTMT
;
229 * some things like PHP won't build without this
231 typedef void * SQLHANDLE
;
234 /****************************
235 * These are cast into the actual struct that is being passed around. The
236 * DriverManager knows what its structs look like and the Driver knows about its
237 * structs... the app knows nothing about them... just void*
238 * These are deprecated in favour of SQLHENV, SQLHDBC, SQLHSTMT
239 ***************************/
241 #if (ODBCVER >= 0x0300)
242 typedef SQLHANDLE HENV
;
243 typedef SQLHANDLE HDBC
;
244 typedef SQLHANDLE HSTMT
;
248 typedef void * HSTMT
;
252 /****************************
253 * more basic data types to augment what windows.h provides
254 ***************************/
255 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
257 typedef unsigned char UCHAR
;
258 typedef signed char SCHAR
;
259 typedef SCHAR SQLSCHAR
;
260 #if (SIZEOF_LONG_INT == 4)
261 typedef long int SDWORD
;
262 typedef unsigned long int UDWORD
;
265 typedef unsigned int UDWORD
;
267 typedef signed short int SWORD
;
268 typedef unsigned short int UWORD
;
269 typedef unsigned int UINT
;
270 typedef signed long SLONG
;
271 typedef signed short SSHORT
;
272 typedef unsigned long ULONG
;
273 typedef unsigned short USHORT
;
274 typedef double SDOUBLE
;
275 typedef double LDOUBLE
;
276 typedef float SFLOAT
;
278 typedef signed short RETCODE
;
279 typedef void* SQLHWND
;
283 /****************************
284 * standard structs for working with date/times
285 ***************************/
288 typedef struct tagDATE_STRUCT
295 #if (ODBCVER >= 0x0300)
296 typedef DATE_STRUCT SQL_DATE_STRUCT
;
299 typedef struct tagTIME_STRUCT
306 #if (ODBCVER >= 0x0300)
307 typedef TIME_STRUCT SQL_TIME_STRUCT
;
310 typedef struct tagTIMESTAMP_STRUCT
318 SQLUINTEGER fraction
;
321 #if (ODBCVER >= 0x0300)
322 typedef TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT
;
326 #if (ODBCVER >= 0x0300)
335 SQL_IS_YEAR_TO_MONTH
= 7,
336 SQL_IS_DAY_TO_HOUR
= 8,
337 SQL_IS_DAY_TO_MINUTE
= 9,
338 SQL_IS_DAY_TO_SECOND
= 10,
339 SQL_IS_HOUR_TO_MINUTE
= 11,
340 SQL_IS_HOUR_TO_SECOND
= 12,
341 SQL_IS_MINUTE_TO_SECOND
= 13
346 #if (ODBCVER >= 0x0300)
347 typedef struct tagSQL_YEAR_MONTH
351 } SQL_YEAR_MONTH_STRUCT
;
353 typedef struct tagSQL_DAY_SECOND
359 SQLUINTEGER fraction
;
360 } SQL_DAY_SECOND_STRUCT
;
362 typedef struct tagSQL_INTERVAL_STRUCT
364 SQLINTERVAL interval_type
;
365 SQLSMALLINT interval_sign
;
367 SQL_YEAR_MONTH_STRUCT year_month
;
368 SQL_DAY_SECOND_STRUCT day_second
;
371 } SQL_INTERVAL_STRUCT
;
378 # if (ODBCVER >= 0x0300)
379 # if (SIZEOF_LONG_INT == 8)
380 # define ODBCINT64 long
381 # define UODBCINT64 unsigned long
383 # ifdef HAVE_LONG_LONG
384 # define ODBCINT64 long long
385 # define UODBCINT64 unsigned long long
388 * may fail in some cases, but what else can we do ?
390 struct __bigint_struct
395 struct __bigint_struct_u
400 # define ODBCINT64 struct __bigint_struct
401 # define UODBCINT64 struct __bigint_struct_u
408 typedef ODBCINT64 SQLBIGINT
;
411 typedef UODBCINT64 SQLUBIGINT
;
415 /****************************
416 * cursor and bookmark
417 ***************************/
418 #if (ODBCVER >= 0x0300)
419 #define SQL_MAX_NUMERIC_LEN 16
420 typedef struct tagSQL_NUMERIC_STRUCT
424 SQLCHAR sign
; /* 1=pos 0=neg */
425 SQLCHAR val
[SQL_MAX_NUMERIC_LEN
];
426 } SQL_NUMERIC_STRUCT
;
429 #if (ODBCVER >= 0x0350)
431 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
432 typedef GUID SQLGUID
;
434 typedef struct tagSQLGUID
443 typedef struct tagSQLGUID
453 typedef SQLULEN BOOKMARK
;
455 typedef WCHAR SQLWCHAR
;
458 typedef SQLWCHAR SQLTCHAR
;
460 typedef SQLCHAR SQLTCHAR
;