1 /* File: psqlodbc.h 2 * 3 * Description: This file contains defines and declarations that are related to 4 * the entire driver. 5 * 6 * Comments: See "readme.txt" for copyright and license information. 7 */ 8 9 #ifndef __PSQLODBC_H__ 10 #define __PSQLODBC_H__ 11 12 /* #define __MS_REPORTS_ANSI_CHAR__ */ 13 14 #ifndef WIN32 15 #include "config.h" 16 #else 17 #define WIN32_LEAN_AND_MEAN 18 #include <windows.h> 19 #endif 20 21 #include <stdio.h> /* for FILE* pointers: see GLOBAL_VALUES */ 22 #ifdef POSIX_MULTITHREAD_SUPPORT 23 #include <pthread.h> 24 #endif 25 #include "version.h" 26 27 #ifdef WIN32 28 #ifdef _DEBUG 29 #ifndef _MEMORY_DEBUG_ 30 #include <stdlib.h> 31 #if (_MSC_VER < 1400) /* in case of VC7 or under */ 32 #include <malloc.h> 33 #endif /* _MSC_VER */ 34 #define _CRTDBG_MAP_ALLOC 35 #include <crtdbg.h> 36 #endif /* _MEMORY_DEBUG_ */ 37 #else /* _DEBUG */ 38 #include <stdlib.h> 39 #endif /* _DEBUG */ 40 #else /* WIN32 */ 41 #include <stdlib.h> 42 #endif /* WIN32 */ 43 44 #ifdef __INCLUDE_POSTGRES_FE_H__ /* currently not defined */ 45 /* 46 * Unfortunately #including postgres_fe.h causes various trobles. 47 */ 48 #include "postgres_fe.h" 49 #else /* currently */ 50 #if defined(__GNUC__) || defined(__IBMC__) 51 #if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 404 52 #define PG_PRINTF_ATTRIBUTE gnu_printf 53 #else 54 #define PG_PRINTF_ATTRIBUTE printf 55 #endif 56 #define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a))) 57 #else 58 #define __attribute__(x) 59 #define pg_attribute_printf(f,a) 60 #endif /* __GNUC__ || __IBMC__ */ 61 #endif /* __INCLUDE_POSTGRES_FE_H__ */ 62 63 #ifdef _MEMORY_DEBUG_ 64 void *pgdebug_alloc(size_t); 65 void *pgdebug_calloc(size_t, size_t); 66 void *pgdebug_realloc(void *, size_t); 67 char *pgdebug_strdup(const char *); 68 void *pgdebug_memcpy(void *, const void *, size_t); 69 void *pgdebug_memset(void *, int c, size_t); 70 char *pgdebug_strcpy(char *, const char *); 71 char *pgdebug_strncpy(char *, const char *, size_t); 72 char *pgdebug_strncpy_null(char *, const char *, size_t); 73 void pgdebug_free(void *); 74 void debug_memory_check(void); 75 76 #ifdef WIN32 77 #undef strdup 78 #endif /* WIN32 */ 79 #define malloc pgdebug_alloc 80 #define realloc pgdebug_realloc 81 #define calloc pgdebug_calloc 82 #define strdup pgdebug_strdup 83 #define free pgdebug_free 84 #define strcpy pgdebug_strcpy 85 #define strncpy pgdebug_strncpy 86 /* #define strncpy_null pgdebug_strncpy_null */ 87 #define memcpy pgdebug_memcpy 88 #define memset pgdebug_memset 89 #endif /* _MEMORY_DEBUG_ */ 90 91 #ifdef WIN32 92 #include <delayimp.h> 93 #endif /* WIN32 */ 94 /* Must come before sql.h */ 95 #define ODBCVER 0x0351 96 97 /* 98 * Default NAMEDATALEN value in the server. The server can be compiled with 99 * a different value, but this will do. 100 */ 101 #define NAMEDATALEN_V73 64 102 103 #ifndef NAMESTORAGELEN 104 #define NAMESTORAGELEN 64 105 #endif /* NAMESTORAGELEN */ 106 107 #ifndef WIN32 108 #undef WIN_MULTITHREAD_SUPPORT 109 #endif 110 111 #if defined(WIN32) || defined(WITH_UNIXODBC) || defined(WITH_IODBC) 112 #include <sql.h> 113 #include <sqlext.h> 114 #if defined(WIN32) && (_MSC_VER < 1300) /* in case of VC6 or under */ 115 #define SQLLEN SQLINTEGER 116 #define SQLULEN SQLUINTEGER 117 #define SQLSETPOSIROW SQLUSMALLINT 118 /* VC6 bypasses 64bit mode. */ 119 #define DWLP_USER DWL_USER 120 #define ULONG_PTR ULONG 121 #define LONG_PTR LONG 122 #define SetWindowLongPtr(hdlg, DWLP_USER, lParam) SetWindowLong(hdlg, DWLP_USER, lParam) 123 #define GetWindowLongPtr(hdlg, DWLP_USER) GetWindowLong(hdlg, DWLP_USER); 124 #endif 125 #else 126 #include "iodbc.h" 127 #include "isql.h" 128 #include "isqlext.h" 129 #endif /* WIN32 */ 130 131 #if defined(WIN32) 132 #include <odbcinst.h> 133 #elif defined(WITH_UNIXODBC) 134 #include <odbcinst.h> 135 #elif defined(WITH_IODBC) 136 #include <iodbcinst.h> 137 #endif 138 139 #ifdef __cplusplus 140 extern "C" { 141 #endif 142 143 #define Int4 int 144 #define UInt4 unsigned int 145 #define Int2 short 146 #define UInt2 unsigned short 147 typedef SQLBIGINT Int8; 148 typedef UInt4 OID; 149 150 #ifndef SQL_TRUE 151 #define SQL_TRUE TRUE 152 #endif /* SQL_TRUE */ 153 #ifndef SQL_FALSE 154 #define SQL_FALSE FALSE 155 #endif /* SQL_FALSE */ 156 157 #define FORMAT_SMALLI "%d" /* SQLSMALLINT */ 158 #define FORMAT_USMALLI "%u" /* SQLUSMALLINT */ 159 #ifdef WIN32 160 #ifndef SSIZE_T_DEFINED 161 #define ssize_t SSIZE_T 162 #define SSIZE_T_DEFINED 163 #endif /* SSIZE_T */ 164 #define FORMAT_SIZE_T "%Iu" /* size_t */ 165 #define FORMAT_SSIZE_T "%Id" /* ssize_t */ 166 #define FORMAT_INTEGER "%ld" /* SQLINTEGER */ 167 #define FORMAT_UINTEGER "%lu" /* SQLUINTEGER */ 168 #define FORMATI64 "%I64d" /* SQLBIGINT */ 169 #define FORMATI64U "%I64u" /* SQLUBIGINT */ 170 #ifdef _WIN64 171 #define FORMAT_LEN "%I64d" /* SQLLEN */ 172 #define FORMAT_ULEN "%I64u" /* SQLULEN */ 173 #define FORMAT_POSIROW "%I64u" 174 #else /* _WIN64 */ 175 #define FORMAT_LEN "%ld" /* SQLLEN */ 176 #define FORMAT_ULEN "%lu" /* SQLULEN */ 177 #define FORMAT_POSIROW "%hu" 178 #endif /* _WIN64 */ 179 #else /* WIN32 */ 180 #define FORMAT_SIZE_T "%zu" /* size_t */ 181 #define FORMAT_SSIZE_T "%zd" /* ssize_t */ 182 #ifndef HAVE_SSIZE_T 183 typedef long ssize_t 184 #endif /* HAVE_SSIZE_T */ 185 186 #if (SIZEOF_VOID_P == SIZEOF_LONG) /* ILP32 or LP64 */ 187 typedef long LONG_PTR; 188 typedef unsigned long ULONG_PTR; 189 #elif defined (HAVE_LONG_LONG) /* LLP64 */ 190 typedef long long LONG_PTR; 191 typedef unsigned long long ULONG_PTR; 192 #else /* SIZEOF_VOID_P */ 193 #error appropriate long pointer type not found 194 #endif /* SIZEOF_VOID_P */ 195 #if (SIZEOF_LONG == 8) /* LP64 */ 196 #define FORMAT_INTEGER "%d" /* SQLINTEGER */ 197 #define FORMAT_UINTEGER "%u" /* SQLUINTEGER */ 198 #define FORMATI64 "%ld" /* SQLBIGINT */ 199 #define FORMATI64U "%lu" /* SQLUBIGINT */ 200 #define FORMAT_LEN "%ld" /* SQLLEN */ 201 #define FORMAT_ULEN "%lu" /* SQLULEN */ 202 #else /* SIZEOF_LONG */ 203 #define FORMAT_INTEGER "%ld" /* SQLINTEGER */ 204 #define FORMAT_UINTEGER "%lu" /* SQLUINTEGER */ 205 #if defined(HAVE_LONG_LONG) 206 #define FORMATI64 "%lld" /* SQLBIGINT */ 207 #define FORMATI64U "%llu" /* SQLUBIGINT */ 208 #if (SIZEOF_VOID_P == 8) /* LLP64 */ 209 #define FORMAT_LEN "%lld" /* SQLLEN */ 210 #define FORMAT_ULEN "%llu" /* SQLULEN */ 211 #else /* SIZEOF_VOID_P ILP32 */ 212 #define FORMAT_LEN "%ld" /* SQLLEN */ 213 #define FORMAT_ULEN "%lu" /* SQLULEN */ 214 #endif /* SIZEOF_VOID_P */ 215 #else /* HAVE_LONG_LONG */ 216 #define FORMAT_LEN "%ld" /* SQLLEN */ 217 #define FORMAT_ULEN "%lu" /* SQLULEN */ 218 #endif /* HAVE_LONG_LONG */ 219 #endif /* SIZEOF_LONG */ 220 221 #if (SIZEOF_VOID_P == 8) && !defined(WITH_IODBC) 222 #define FORMAT_POSIROW FORMAT_ULEN 223 #else 224 #define FORMAT_POSIROW "%u" 225 #endif 226 227 #endif /* WIN32 */ 228 229 #define CAST_PTR(type, ptr) (type)((LONG_PTR)(ptr)) 230 #define CAST_UPTR(type, ptr) (type)((ULONG_PTR)(ptr)) 231 #ifndef SQL_IS_LEN 232 #define SQL_IS_LEN (-1000) 233 #endif /* SQL_IS_LEN */ 234 #ifdef HAVE_SIGNED_CHAR 235 typedef signed char po_ind_t; 236 #else 237 typedef char po_ind_t; 238 #endif /* HAVE_SIGNED_CHAR */ 239 240 #ifndef WIN32 241 #if !defined(WITH_UNIXODBC) && !defined(WITH_IODBC) 242 typedef float SFLOAT; 243 typedef double SDOUBLE; 244 #endif /* WITH_UNIXODBC */ 245 246 #ifndef CALLBACK 247 #define CALLBACK 248 #endif /* CALLBACK */ 249 #endif /* WIN32 */ 250 251 #ifndef WIN32 252 #define stricmp strcasecmp 253 #define strnicmp strncasecmp 254 #ifndef TRUE 255 #define TRUE (BOOL)1 256 #endif /* TRUE */ 257 #ifndef FALSE 258 #define FALSE (BOOL)0 259 #endif /* FALSE */ 260 #else 261 262 #if (_MSC_VER < 1900) /* vc12 or under */ 263 #define POSIX_SNPRINTF_REQUIRED 264 #define snprintf posix_snprintf 265 extern int posix_snprintf(char *buf, size_t size, const char *format, ...); 266 #endif /* _MSC_VER */ 267 #ifndef strdup 268 #define strdup _strdup 269 #endif /* strdup */ 270 #define strnicmp _strnicmp 271 #define stricmp _stricmp 272 #endif /* WIN32 */ 273 274 #define IS_NOT_SPACE(c) ((c) && !isspace((UCHAR) c)) 275 276 #ifndef SQL_ATTR_APP_ROW_DESC 277 #define SQL_ATTR_APP_ROW_DESC 10010 278 #endif 279 #ifndef SQL_ATTR_APP_PARAM_DESC 280 #define SQL_ATTR_APP_PARAM_DESC 10011 281 #endif 282 #ifndef SQL_ATTR_IMP_ROW_DESC 283 #define SQL_ATTR_IMP_ROW_DESC 10012 284 #endif 285 #ifndef SQL_ATTR_IMP_PARAM_DESC 286 #define SQL_ATTR_IMP_PARAM_DESC 10013 287 #endif 288 289 /* Driver stuff */ 290 291 #define DRIVERNAME "PostgreSQL ODBC" 292 293 #define DBMS_NAME_UNICODE "PostgreSQL Unicode" 294 #define DBMS_NAME_ANSI "PostgreSQL ANSI" 295 296 #define DRIVER_ODBC_VER "03.51" 297 298 #ifdef UNICODE_SUPPORT 299 #define WCLEN sizeof(SQLWCHAR) 300 SQLULEN ucs2strlen(const SQLWCHAR *); 301 #else 302 #undef SQL_WCHAR 303 #undef SQL_WVARCHAR 304 #undef SQL_WLONGVARCHAR 305 #undef SQL_C_WCHAR 306 #define SQL_WCHAR SQL_WCHAR_IS_INHIBITED 307 #define SQL_WVARCHAR SQL_WVARCHAR_IS_INHIBITED 308 #define SQL_WLONGVARCHAR SQL_WLONGVARCHAR_IS_INHIBITED 309 #define SQL_C_WCHAR SQL_C_WCHAR_IS_INHIBITED 310 #endif 311 312 #ifndef DBMS_NAME 313 #ifdef _WIN64 314 #ifdef UNICODE_SUPPORT 315 #define DBMS_NAME DBMS_NAME_UNICODE"(x64)" 316 #else 317 #define DBMS_NAME DBMS_NAME_ANSI"(x64)" 318 #endif /* UNICODE_SUPPORT */ 319 #else /* _WIN64 */ 320 #ifdef UNICODE_SUPPORT 321 #define DBMS_NAME DBMS_NAME_UNICODE 322 #else 323 #define DBMS_NAME DBMS_NAME_ANSI 324 #endif /* UNICODE_SUPPORT */ 325 #endif /* _WIN64 */ 326 #endif /* DBMS_NAME */ 327 328 #ifndef DBMS_NAME 329 #define DBMS_NAME "PostgreSQL Legacy" 330 #endif /* DBMS_NAME */ 331 #ifdef WIN32 332 #ifdef UNICODE_SUPPORT 333 #define DRIVER_FILE_NAME "PSQLODBC35W.DLL" 334 #else 335 #define DRIVER_FILE_NAME "PSQLODBC30A.DLL" 336 #endif /* UNICODE_SUPPORT */ 337 #else 338 #ifdef UNICODE_SUPPORT 339 #define DRIVER_FILE_NAME "psqlodbcw.so" 340 #else 341 #define DRIVER_FILE_NAME "psqlodbca.so" 342 #endif 343 #endif /* WIN32 */ 344 BOOL isMsAccess(void); 345 BOOL isMsQuery(void); 346 BOOL isSqlServr(void); 347 348 /* ESCAPEs */ 349 #define ESCAPE_IN_LITERAL '\\' 350 #define BYTEA_ESCAPE_CHAR '\\' 351 #define SEARCH_PATTERN_ESCAPE '\\' 352 #define LITERAL_QUOTE '\'' 353 #define IDENTIFIER_QUOTE '\"' 354 #define ODBC_ESCAPE_START '{' 355 #define ODBC_ESCAPE_END '}' 356 #define DOLLAR_QUOTE '$' 357 #define LITERAL_EXT 'E' 358 #define PG_CARRIAGE_RETURN '\r' 359 #define PG_LINEFEED '\n' 360 361 /* Limits */ 362 #define MAXPGPATH 1024 363 364 /* see an easy way round this - DJP 24-1-2001 */ 365 #define MAX_CONNECT_STRING 4096 366 #define FETCH_MAX 100 /* default number of rows to cache 367 * for declare/fetch */ 368 #define TUPLE_MALLOC_INC 100 369 #define MAX_CONNECTIONS 128 /* conns per environment 370 * (arbitrary) */ 371 372 #ifdef NAMEDATALEN 373 #define MAX_SCHEMA_LEN NAMEDATALEN 374 #define MAX_TABLE_LEN NAMEDATALEN 375 #define MAX_COLUMN_LEN NAMEDATALEN 376 #define NAME_FIELD_SIZE NAMEDATALEN /* size of name fields */ 377 #if (NAMEDATALEN > NAMESTORAGELEN) 378 #undef NAMESTORAGELEN 379 #define NAMESTORAGELEN NAMEDATALEN 380 #endif 381 #endif /* NAMEDATALEN */ 382 #define MAX_CURSOR_LEN 32 383 384 #define SCHEMA_NAME_STORAGE_LEN NAMESTORAGELEN 385 #define TABLE_NAME_STORAGE_LEN NAMESTORAGELEN 386 #define COLUMN_NAME_STORAGE_LEN NAMESTORAGELEN 387 #define INDEX_KEYS_STORAGE_COUNT 32 388 389 /* Registry length limits */ 390 #define LARGE_REGISTRY_LEN 4096 /* used for special cases */ 391 #define MEDIUM_REGISTRY_LEN 256 /* normal size for 392 * user,database,etc. */ 393 #define SMALL_REGISTRY_LEN 10 /* for 1/0 settings */ 394 395 396 /* These prefixes denote system tables */ 397 #define POSTGRES_SYS_PREFIX "pg_" 398 399 /* Info limits */ 400 #define MAX_INFO_STRING 128 401 402 /* POSIX defines a PATH_MAX.( wondows is _MAX_PATH ..) */ 403 #ifndef PATH_MAX 404 #ifdef _MAX_PATH 405 #define PATH_MAX _MAX_PATH 406 #else 407 #define PATH_MAX 1024 408 #endif /* _MAX_PATH */ 409 #endif /* PATH_MAX */ 410 411 typedef struct ConnectionClass_ ConnectionClass; 412 typedef struct StatementClass_ StatementClass; 413 typedef struct QResultClass_ QResultClass; 414 typedef struct BindInfoClass_ BindInfoClass; 415 typedef struct ParameterInfoClass_ ParameterInfoClass; 416 typedef struct ParameterImplClass_ ParameterImplClass; 417 typedef struct ColumnInfoClass_ ColumnInfoClass; 418 typedef struct EnvironmentClass_ EnvironmentClass; 419 typedef struct TupleField_ TupleField; 420 typedef struct KeySet_ KeySet; 421 typedef struct Rollback_ Rollback; 422 typedef struct ARDFields_ ARDFields; 423 typedef struct APDFields_ APDFields; 424 typedef struct IRDFields_ IRDFields; 425 typedef struct IPDFields_ IPDFields; 426 427 typedef struct col_info COL_INFO; 428 typedef struct lo_arg LO_ARG; 429 430 typedef struct QResultHold_struct { 431 QResultClass *first; 432 QResultClass *last; 433 } QResultHold; 434 435 /* pgNAME type define */ 436 typedef struct 437 { 438 char *name; 439 } pgNAME; 440 #define GET_NAME(the_name) ((the_name).name) 441 #define SAFE_NAME(the_name) ((the_name).name ? (the_name).name : NULL_STRING) 442 #define PRINT_NAME(the_name) ((the_name).name ? (the_name).name : PRINT_NULL) 443 #define NAME_IS_NULL(the_name) (NULL == (the_name).name) 444 #define NAME_IS_VALID(the_name) (NULL != (the_name).name) 445 #define INIT_NAME(the_name) ((the_name).name = NULL) 446 #define NULL_THE_NAME(the_name) \ 447 do { \ 448 if ((the_name).name) free((the_name).name); \ 449 (the_name).name = NULL; \ 450 } while (0) 451 #define STR_TO_NAME(the_name, str) \ 452 do { \ 453 if ((the_name).name) \ 454 free((the_name).name); \ 455 (the_name).name = (str ? strdup((str)) : NULL); \ 456 } while (0) 457 #define STRX_TO_NAME(the_name, str) \ 458 do { \ 459 if ((the_name).name) \ 460 free((the_name).name); \ 461 (the_name).name = strdup((str)); \ 462 } while (0) 463 #define STRN_TO_NAME(the_name, str, n) \ 464 do { \ 465 if ((the_name).name) \ 466 free((the_name).name); \ 467 if (str) \ 468 { \ 469 (the_name).name = malloc((n) + 1); \ 470 if ((the_name).name) \ 471 { \ 472 memcpy((the_name).name, str, (n)); \ 473 (the_name).name[(n)] = '\0'; \ 474 } \ 475 } \ 476 else \ 477 (the_name).name = NULL; \ 478 } while (0) 479 #define NAME_TO_NAME(to, from) \ 480 do { \ 481 if ((to).name) \ 482 free((to).name); \ 483 if ((from).name) \ 484 (to).name = strdup(from.name); \ 485 else \ 486 (to).name = NULL; \ 487 } while (0) 488 #define MOVE_NAME(to, from) \ 489 do { \ 490 if ((to).name) \ 491 free((to).name); \ 492 (to).name = (from).name; \ 493 (from).name = NULL; \ 494 } while (0) 495 #define SET_NAME_DIRECTLY(the_name, str) ((the_name).name = (str)) 496 497 #define NAMECMP(name1, name2) (strcmp(SAFE_NAME(name1), SAFE_NAME(name2))) 498 #define NAMEICMP(name1, name2) (stricmp(SAFE_NAME(name1), SAFE_NAME(name2))) 499 /* pgNAME define end */ 500 501 502 typedef struct GlobalValues_ 503 { 504 pgNAME drivername; 505 int fetch_max; 506 int unknown_sizes; 507 int max_varchar_size; 508 int max_longvarchar_size; 509 char debug; 510 char commlog; 511 char unique_index; 512 char use_declarefetch; 513 char text_as_longvarchar; 514 char unknowns_as_longvarchar; 515 char bools_as_char; 516 char lie; 517 char parse; 518 char extra_systable_prefixes[MEDIUM_REGISTRY_LEN]; 519 char protocol[SMALL_REGISTRY_LEN]; 520 } GLOBAL_VALUES; 521 522 void copy_globals(GLOBAL_VALUES *to, const GLOBAL_VALUES *from); 523 void init_globals(GLOBAL_VALUES *glbv); 524 void finalize_globals(GLOBAL_VALUES *glbv); 525 526 typedef struct StatementOptions_ 527 { 528 SQLLEN maxRows; 529 SQLLEN maxLength; 530 SQLLEN keyset_size; 531 SQLUINTEGER cursor_type; 532 SQLUINTEGER scroll_concurrency; 533 SQLUINTEGER retrieve_data; 534 SQLUINTEGER use_bookmarks; 535 void *bookmark_ptr; 536 SQLUINTEGER metadata_id; 537 SQLULEN stmt_timeout; 538 } StatementOptions; 539 540 /* Used to pass extra query info to send_query */ 541 typedef struct QueryInfo_ 542 { 543 SQLLEN row_size; 544 SQLLEN fetch_size; 545 QResultClass *result_in; 546 const char *cursor; 547 } QueryInfo; 548 549 /* Used to save the error information */ 550 typedef struct 551 { 552 UInt4 status; 553 Int2 errorsize; 554 Int2 recsize; 555 Int2 errorpos; 556 char sqlstate[6]; 557 SQLLEN diag_row_count; 558 char __error_message[40]; 559 } PG_ErrorInfo; 560 PG_ErrorInfo *ER_Constructor(SDWORD errornumber, const char *errormsg); 561 PG_ErrorInfo *ER_Dup(const PG_ErrorInfo *from); 562 void ER_Destructor(PG_ErrorInfo *); 563 RETCODE SQL_API ER_ReturnError(PG_ErrorInfo *, SQLSMALLINT, UCHAR *, 564 SQLINTEGER *, UCHAR *, SQLSMALLINT, SQLSMALLINT *, UWORD); 565 566 void logs_on_off(int cnopen, int, int); 567 568 #define PG_TYPE_LO_UNDEFINED (-999) /* hack until permanent 569 * type available */ 570 #define PG_TYPE_LO_NAME "lo" 571 #define CTID_ATTNUM (-1) /* the attnum of ctid */ 572 #define OID_ATTNUM (-2) /* the attnum of oid */ 573 #define XMIN_ATTNUM (-3) /* the attnum of xmin */ 574 575 /* sizes */ 576 #define TEXT_FIELD_SIZE 8190 /* size of default text fields 577 * (not including null term) */ 578 #define MAX_VARCHAR_SIZE 255 /* default maximum size of 579 * varchar fields (not including null term) */ 580 #define INFO_VARCHAR_SIZE 254 /* varchar field size 581 * used in info.c */ 582 583 #define PG_NUMERIC_MAX_PRECISION 1000 584 #define PG_NUMERIC_MAX_SCALE 1000 585 586 /* Sufficient digits to recover original float values */ 587 #define PG_REAL_DIGITS 9 588 #define PG_DOUBLE_DIGITS 17 589 590 #define INFO_INQUIRY_LEN 8192 /* this seems sufficiently big for 591 * queries used in info.c inoue 592 * 2001/05/17 */ 593 594 #define LENADDR_SHIFT(x, sft) ((x) ? (SQLLEN *)((char *)(x) + (sft)) : NULL) 595 596 /* Structure to hold all the connection attributes for a specific 597 connection (used for both registry and file, DSN and DRIVER) 598 */ 599 typedef struct 600 { 601 char dsn[MEDIUM_REGISTRY_LEN]; 602 char desc[MEDIUM_REGISTRY_LEN]; 603 char drivername[MEDIUM_REGISTRY_LEN]; 604 char server[MEDIUM_REGISTRY_LEN]; 605 char database[MEDIUM_REGISTRY_LEN]; 606 char username[MEDIUM_REGISTRY_LEN]; 607 pgNAME password; 608 char port[SMALL_REGISTRY_LEN]; 609 char sslmode[16]; 610 char onlyread[SMALL_REGISTRY_LEN]; 611 char fake_oid_index[SMALL_REGISTRY_LEN]; 612 char show_oid_column[SMALL_REGISTRY_LEN]; 613 char row_versioning[SMALL_REGISTRY_LEN]; 614 char show_system_tables[SMALL_REGISTRY_LEN]; 615 char translation_dll[MEDIUM_REGISTRY_LEN]; 616 char translation_option[SMALL_REGISTRY_LEN]; 617 char password_required; 618 char conn_settings_in_str; 619 char pqopt_in_str; 620 pgNAME conn_settings; 621 pgNAME pqopt; 622 signed char allow_keyset; 623 signed char updatable_cursors; 624 signed char lf_conversion; 625 signed char true_is_minus1; 626 signed char int8_as; 627 signed char bytea_as_longvarbinary; 628 signed char use_server_side_prepare; 629 signed char lower_case_identifier; 630 signed char rollback_on_error; 631 signed char force_abbrev_connstr; 632 signed char bde_environment; 633 signed char fake_mss; 634 signed char cvt_null_date_string; 635 signed char accessible_only; 636 signed char ignore_round_trip_time; 637 signed char disable_keepalive; 638 signed char disable_convert_func; 639 signed char wcs_debug; 640 signed char numeric_as; 641 signed char optional_errors; 642 signed char ignore_timeout; 643 signed char fetch_refcursors; 644 UInt4 extra_opts; 645 Int4 keepalive_idle; 646 Int4 keepalive_interval; 647 Int4 batch_size; 648 #ifdef _HANDLE_ENLIST_IN_DTC_ 649 signed char xa_opt; 650 #endif /* _HANDLE_ENLIST_IN_DTC_ */ 651 GLOBAL_VALUES drivers; /* moved from driver's option */ 652 } ConnInfo; 653 654 #define SUPPORT_DESCRIBE_PARAM(conninfo_) (conninfo_->use_server_side_prepare) 655 656 int initialize_global_cs(void); 657 enum { /* CC_conninfo_init option */ 658 CLEANUP_FOR_REUSE = 1L /* reuse the info */ 659 ,INIT_GLOBALS = (1L << 1) /* init globals memebers */ 660 }; 661 void CC_conninfo_init(ConnInfo *conninfo, UInt4 option); 662 void CC_conninfo_release(ConnInfo *conninfo); 663 void CC_copy_conninfo(ConnInfo *ci, const ConnInfo *sci); 664 const char *GetExeProgramName(); 665 #ifdef POSIX_MULTITHREAD_SUPPORT 666 #if !defined(HAVE_ECO_THREAD_LOCKS) 667 #define POSIX_THREADMUTEX_SUPPORT 668 #endif /* HAVE_ECO_THREAD_LOCKS */ 669 #endif /* POSIX_MULTITHREAD_SUPPORT */ 670 671 #ifdef POSIX_THREADMUTEX_SUPPORT 672 const pthread_mutexattr_t *getMutexAttr(void); 673 #endif /* POSIX_THREADMUTEX_SUPPORT */ 674 675 /* Define a type for defining a constant string expression */ 676 #ifndef CSTR 677 #define CSTR static const char * const 678 #endif /* CSTR */ 679 680 CSTR NULL_STRING = ""; 681 CSTR PRINT_NULL = "(null)"; 682 #define OID_NAME "oid" 683 #define XMIN_NAME "xmin" 684 #define TABLEOID_NAME "tableoid" 685 686 enum 687 { 688 DISALLOW_UPDATABLE_CURSORS = 0, /* No cursors are updatable */ 689 ALLOW_STATIC_CURSORS = 1L, /* Static cursors are updatable */ 690 ALLOW_KEYSET_DRIVEN_CURSORS = (1L << 1), /* Keyset-driven cursors are updatable */ 691 ALLOW_DYNAMIC_CURSORS = (1L << 2), /* Dynamic cursors are updatable */ 692 ALLOW_BULK_OPERATIONS = (1L << 3), /* Bulk operations available */ 693 SENSE_SELF_OPERATIONS = (1L << 4), /* Sense self update/delete/add */ 694 }; 695 696 #ifdef __cplusplus 697 } 698 #endif 699 700 #include "mylog.h" 701 702 #endif /* __PSQLODBC_H__ */ 703