FreeTDS API: include/tdsodbc.h Source File

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

# include/tdsodbc.h

    00001 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    00002  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005  Brian Bruns
    00003  * Copyright (C) 2004-2010  Frediano Ziglio
    00004  *
    00005  * This library is free software; you can redistribute it and/or
    00006  * modify it under the terms of the GNU Library General Public
    00007  * License as published by the Free Software Foundation; either
    00008  * version 2 of the License, or (at your option) any later version.
    00009  *
    00010  * This library is distributed in the hope that it will be useful,
    00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013  * Library General Public License for more details.
    00014  *
    00015  * You should have received a copy of the GNU Library General Public
    00016  * License along with this library; if not, write to the
    00017  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00018  * Boston, MA 02111-1307, USA.
    00019  */
    00020
    00021 #ifndef _sql_h_
    00022 #define _sql_h_
    00023
    00024 #include "tds.h"
    00025
    00026 #if defined(UNIXODBC) || defined(TDS_NO_DM)
    00027 #include <sql.h>
    00028 #include <sqlext.h>
    00029 #ifdef UNIXODBC
    00030 #include <odbcinst.h>
    00031 #endif
    00032 #else /* IODBC */
    00033 #include <isql.h>
    00034 #include <isqlext.h>
    00035 #ifdef HAVE_IODBCINST_H
    00036 #include <iodbcinst.h>
    00037 #endif /* HAVE_IODBCINST_H */
    00038 #endif
    00039
    00040 #ifndef HAVE_SQLLEN
    00041 #ifndef SQLULEN
    00042 #define SQLULEN SQLUINTEGER
    00043 #endif
    00044 #ifndef SQLLEN
    00045 #define SQLLEN SQLINTEGER
    00046 #endif
    00047 #endif
    00048
    00049 #ifndef HAVE_SQLSETPOSIROW
    00050 #define SQLSETPOSIROW SQLUSMALLINT
    00051 #endif
    00052
    00053 #ifndef HAVE_SQLROWOFFSET
    00054 #define SQLROWOFFSET SQLLEN
    00055 #endif
    00056
    00057 #ifndef HAVE_SQLROWSETSIZE
    00058 #define SQLROWSETSIZE SQLULEN
    00059 #endif
    00060
    00061 #ifdef __cplusplus
    00062 extern "C"
    00063 {
    00064 #if 0
    00065 }
    00066 #endif
    00067 #endif
    00068
    00069 /* $Id: tdsodbc.h,v 1.127 2010-11-09 15:46:42 freddy77 Exp $ */
    00070
    00071 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
    00072 #pragma GCC visibility push(hidden)
    00073 #define ODBC_API SQL_API __attribute__((externally_visible))
    00074 #else
    00075 #define ODBC_API SQL_API
    00076 #endif
    00077
    00078 #if (defined(_WIN32) || defined(__CYGWIN__)) && defined(__GNUC__)
    00079 #  define ODBC_PUBLIC __attribute__((dllexport))
    00080 #else
    00081 #  define ODBC_PUBLIC
    00082 #endif
    00083
    00084 #define ODBC_MAX(a,b) ( (a) > (b) ? (a) : (b) )
    00085 #define ODBC_MIN(a,b) ( (a) < (b) ? (a) : (b) )
    00086
    00087 struct _sql_error
    00088 {
    00089         const char *msg;
    00090         char state2[6];
    00091         char state3[6];
    00092         TDS_UINT native;
    00093         char *server;
    00094         int linenum;
    00095         int msgstate;
    00096         int row;
    00097 };
    00098
    00099 struct _sql_errors
    00100 {
    00101         struct _sql_error *errs;
    00102         int num_errors;
    00103         SQLRETURN lastrc;
    00104         char ranked;
    00105 };
    00106
    00107 typedef struct _sql_errors TDS_ERRS;
    00108
    00109 #if ENABLE_EXTRA_CHECKS
    00110 void odbc_check_struct_extra(void *p);
    00111
    00112 #define ODBC_RETURN(handle, rc) \
    00113         do { odbc_check_struct_extra(handle); return (handle->errs.lastrc = (rc)); } while(0)
    00114 #define ODBC_RETURN_(handle) \
    00115         do { odbc_check_struct_extra(handle); return handle->errs.lastrc; } while(0)
    00116 #else
    00117 #define ODBC_RETURN(handle, rc) \
    00118         do { return (handle->errs.lastrc = (rc)); } while(0)
    00119 #define ODBC_RETURN_(handle) \
    00120         do { return handle->errs.lastrc; } while(0)
    00121 #endif
    00122
    00124 void odbc_errs_reset(struct _sql_errors *errs);
    00125
    00127 void odbc_errs_add(struct _sql_errors *errs, const char *sqlstate, const char *msg);
    00128
    00130 void odbc_errs_add_rdbms(struct _sql_errors *errs, TDS_UINT native, const char *sqlstate, const char *msg, int linenum,
    00131                          int msgstate, const char *server, int row);
    00132
    00133 struct _dheader
    00134 {
    00135         SQLSMALLINT sql_desc_alloc_type;
    00136         SQLINTEGER sql_desc_bind_type;
    00137         SQLULEN sql_desc_array_size;
    00138         /* TODO SQLLEN ?? see http://support.microsoft.com/default.aspx?scid=kb;en-us;298678 */
    00139         SQLSMALLINT sql_desc_count;
    00140         SQLUSMALLINT *sql_desc_array_status_ptr;
    00141         SQLULEN *sql_desc_rows_processed_ptr;
    00142         SQLLEN *sql_desc_bind_offset_ptr;
    00143 };
    00144
    00145 struct _drecord
    00146 {
    00147         SQLUINTEGER sql_desc_auto_unique_value;
    00148         DSTR sql_desc_base_column_name;
    00149         DSTR sql_desc_base_table_name;
    00150         SQLINTEGER sql_desc_case_sensitive;
    00151         DSTR sql_desc_catalog_name;
    00152         SQLSMALLINT sql_desc_concise_type;
    00153         SQLPOINTER sql_desc_data_ptr;
    00154         SQLSMALLINT sql_desc_datetime_interval_code;
    00155         SQLINTEGER sql_desc_datetime_interval_precision;
    00156         SQLLEN sql_desc_display_size;
    00157         SQLSMALLINT sql_desc_fixed_prec_scale;
    00158         SQLLEN *sql_desc_indicator_ptr;
    00159         DSTR sql_desc_label;
    00160         SQLULEN sql_desc_length;
    00161         /* this point to a constant buffer, do not free or modify */
    00162         const char *sql_desc_literal_prefix;
    00163         /* this point to a constant buffer, do not free or modify */
    00164         const char *sql_desc_literal_suffix;
    00165         DSTR sql_desc_local_type_name;
    00166         DSTR sql_desc_name;
    00167         SQLSMALLINT sql_desc_nullable;
    00168         SQLINTEGER sql_desc_num_prec_radix;
    00169         SQLLEN sql_desc_octet_length;
    00170         SQLLEN *sql_desc_octet_length_ptr;
    00171         SQLSMALLINT sql_desc_parameter_type;
    00172         SQLSMALLINT sql_desc_precision;
    00173         SQLSMALLINT sql_desc_rowver;
    00174         SQLSMALLINT sql_desc_scale;
    00175         DSTR sql_desc_schema_name;
    00176         SQLSMALLINT sql_desc_searchable;
    00177         DSTR sql_desc_table_name;
    00178         SQLSMALLINT sql_desc_type;
    00179         /* this point to a constant buffer, do not free or modify */
    00180         const char *sql_desc_type_name;
    00181         SQLSMALLINT sql_desc_unnamed;
    00182         SQLSMALLINT sql_desc_unsigned;
    00183         SQLSMALLINT sql_desc_updatable;
    00184 };
    00185
    00186 struct _hdesc
    00187 {
    00188         SQLSMALLINT htype;      /* do not reorder this field */
    00189         struct _sql_errors errs;        /* do not reorder this field */
    00190         int type;
    00191         SQLHANDLE parent;
    00192         struct _dheader header;
    00193         struct _drecord *records;
    00194 };
    00195
    00196 typedef struct _hdesc TDS_DESC;
    00197
    00198 #define DESC_IRD        1
    00199 #define DESC_IPD        2
    00200 #define DESC_ARD        3
    00201 #define DESC_APD        4
    00202
    00203 struct _heattr
    00204 {
    00205         SQLUINTEGER connection_pooling;
    00206         SQLUINTEGER cp_match;
    00207         SQLINTEGER odbc_version;
    00208         SQLINTEGER output_nts;
    00209 };
    00210
    00211 struct _hchk
    00212 {
    00213         SQLSMALLINT htype;      /* do not reorder this field */
    00214         struct _sql_errors errs;        /* do not reorder this field */
    00215 };
    00216
    00217 struct _henv
    00218 {
    00219         SQLSMALLINT htype;      /* do not reorder this field */
    00220         struct _sql_errors errs;        /* do not reorder this field */
    00221         TDSCONTEXT *tds_ctx;
    00222         struct _heattr attr;
    00223 };
    00224
    00225 struct _hcattr
    00226 {
    00227         SQLUINTEGER access_mode;
    00228         SQLUINTEGER async_enable;
    00229         SQLUINTEGER auto_ipd;
    00230         SQLUINTEGER autocommit;
    00231         SQLUINTEGER connection_dead;
    00232         SQLUINTEGER connection_timeout;
    00233         DSTR current_catalog;
    00234         SQLUINTEGER login_timeout;
    00235         SQLUINTEGER metadata_id;
    00236         SQLUINTEGER odbc_cursors;
    00237         SQLUINTEGER packet_size;
    00238         SQLHWND quite_mode;
    00239         DSTR translate_lib;
    00240         SQLUINTEGER translate_option;
    00241         SQLUINTEGER txn_isolation;
    00242         SQLUINTEGER cursor_type;
    00243 #ifdef TDS_NO_DM
    00244         SQLUINTEGER trace;
    00245         DSTR tracefile;
    00246 #endif
    00247 };
    00248
    00249 #define TDS_MAX_APP_DESC        100
    00250
    00251 struct _hstmt;
    00252 struct _hdbc
    00253 {
    00254         SQLSMALLINT htype;      /* do not reorder this field */
    00255         struct _sql_errors errs;        /* do not reorder this field */
    00256         struct _henv *env;
    00257         TDSSOCKET *tds_socket;
    00258         DSTR dsn;
    00259         DSTR server;            /* aka Instance */
    00260 #ifdef ENABLE_ODBC_WIDE
    00261         DSTR original_charset;
    00262         TDSICONV *mb_conv;
    00263 #endif
    00264
    00270         struct _hstmt *current_statement;
    00272         struct _hstmt *stmt_list;
    00273         struct _hcattr attr;
    00275         TDS_DESC *uad[TDS_MAX_APP_DESC];
    00277         unsigned int cursor_support;
    00278         TDS_INT default_query_timeout;
    00279 };
    00280
    00281 struct _hsattr
    00282 {
    00283         /* TODO remove IRD, ARD, IPD, APD from statement, do not duplicate */
    00284 /*      TDS_DESC *app_row_desc; */
    00285 /*      TDS_DESC *app_param_desc; */
    00286         SQLUINTEGER async_enable;
    00287         SQLUINTEGER concurrency;
    00288         SQLUINTEGER cursor_scrollable;
    00289         SQLUINTEGER cursor_sensitivity;
    00290         SQLUINTEGER cursor_type;
    00291         SQLUINTEGER enable_auto_ipd;
    00292         SQLPOINTER fetch_bookmark_ptr;
    00293         SQLULEN keyset_size;
    00294         SQLULEN max_length;
    00295         SQLULEN max_rows;
    00296         SQLUINTEGER metadata_id;
    00297         SQLUINTEGER noscan;
    00298         /* apd->sql_desc_bind_offset_ptr */
    00299         /* SQLUINTEGER *param_bind_offset_ptr; */
    00300         /* apd->sql_desc_bind_type */
    00301         /* SQLUINTEGER param_bind_type; */
    00302         /* apd->sql_desc_array_status_ptr */
    00303         /* SQLUSMALLINT *param_operation_ptr; */
    00304         /* ipd->sql_desc_array_status_ptr */
    00305         /* SQLUSMALLINT *param_status_ptr; */
    00306         /* ipd->sql_desc_rows_processed_ptr */
    00307         /* SQLUSMALLINT *params_processed_ptr; */
    00308         /* apd->sql_desc_array_size */
    00309         /* SQLUINTEGER paramset_size; */
    00310         SQLUINTEGER query_timeout;
    00311         SQLUINTEGER retrieve_data;
    00312         /* ard->sql_desc_bind_offset_ptr */
    00313         /* SQLUINTEGER *row_bind_offset_ptr; */
    00314         /* ard->sql_desc_array_size */
    00315         /* SQLUINTEGER row_array_size; */
    00316         /* ard->sql_desc_bind_type */
    00317         /* SQLUINTEGER row_bind_type; */
    00318         SQLULEN row_number;
    00319         /* ard->sql_desc_array_status_ptr */
    00320         /* SQLUINTEGER *row_operation_ptr; */
    00321         /* ird->sql_desc_array_status_ptr */
    00322         /* SQLUINTEGER *row_status_ptr; */
    00323         /* ird->sql_desc_rows_processed_ptr */
    00324         /* SQLUINTEGER *rows_fetched_ptr; */
    00325         SQLUINTEGER simulate_cursor;
    00326         SQLUINTEGER use_bookmarks;
    00327         /* SQLGetStmtAttr only */
    00328 /*      TDS_DESC *imp_row_desc; */
    00329 /*      TDS_DESC *imp_param_desc; */
    00330 };
    00331
    00332 typedef enum
    00333 {
    00334         NOT_IN_ROW,
    00335         IN_NORMAL_ROW,
    00336         IN_COMPUTE_ROW,
    00337         AFTER_COMPUTE_ROW,
    00338         PRE_NORMAL_ROW
    00339 } TDS_ODBC_ROW_STATUS;
    00340
    00341 typedef enum
    00342 {
    00343         ODBC_SPECIAL_NONE = 0,
    00344         ODBC_SPECIAL_GETTYPEINFO = 1,
    00345         ODBC_SPECIAL_COLUMNS = 2,
    00346         ODBC_SPECIAL_PROCEDURECOLUMNS = 3,
    00347         ODBC_SPECIAL_SPECIALCOLUMNS = 4
    00348 } TDS_ODBC_SPECIAL_ROWS;
    00349
    00350 struct _hstmt
    00351 {
    00352         SQLSMALLINT htype;      /* do not reorder this field */
    00353         struct _sql_errors errs;        /* do not reorder this field */
    00354         struct _hdbc *dbc;
    00356         char *query;
    00357
    00359         struct _hstmt *next;
    00361         struct _hstmt *prev;
    00362
    00363         /* begin prepared query stuff */
    00364         char *prepared_query;
    00365         unsigned prepared_query_is_func:1;
    00366         unsigned prepared_query_is_rpc:1;
    00367         unsigned need_reprepare:1;
    00368         unsigned param_data_called:1;
    00369         /* end prepared query stuff */
    00370
    00372         TDSPARAMINFO *params;
    00374         int param_num;
    00376         char *prepared_pos;
    00377
    00378         unsigned int curr_param_row, num_param_rows;
    00379
    00381         unsigned int param_count;
    00382         int row;
    00384         TDS_INT8 row_count;
    00386         TDS_ODBC_ROW_STATUS row_status;
    00387         /* do NOT free dynamic, free from socket or attach to connection */
    00388         TDSDYNAMIC *dyn;
    00389         TDS_DESC *ard, *ird, *apd, *ipd;
    00390         TDS_DESC *orig_ard, *orig_apd;
    00391         SQLULEN sql_rowset_size;
    00392         struct _hsattr attr;
    00393         DSTR cursor_name;       /* auto generated cursor name */
    00394         TDS_ODBC_SPECIAL_ROWS special_row;
    00395         /* do NOT free cursor, free from socket or attach to connection */
    00396         TDSCURSOR *cursor;
    00397         unsigned char cancel_sent;
    00398 };
    00399
    00400 typedef struct _henv TDS_ENV;
    00401 typedef struct _hdbc TDS_DBC;
    00402 typedef struct _hstmt TDS_STMT;
    00403 typedef struct _hchk TDS_CHK;
    00404
    00405 #define IS_HENV(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_ENV)
    00406 #define IS_HDBC(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_DBC)
    00407 #define IS_HSTMT(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_STMT)
    00408 #define IS_HDESC(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_DESC)
    00409
    00410 /* fix a bug in MingW headers */
    00411 #ifdef __MINGW32__
    00412 #if SQL_INTERVAL_YEAR == (100 + SQL_CODE_SECOND)
    00413
    00414 #undef SQL_INTERVAL_YEAR
    00415 #undef SQL_INTERVAL_MONTH
    00416 #undef SQL_INTERVAL_DAY
    00417 #undef SQL_INTERVAL_HOUR
    00418 #undef SQL_INTERVAL_MINUTE
    00419 #undef SQL_INTERVAL_SECOND
    00420 #undef SQL_INTERVAL_YEAR_TO_MONTH
    00421 #undef SQL_INTERVAL_DAY_TO_HOUR
    00422 #undef SQL_INTERVAL_DAY_TO_MINUTE
    00423 #undef SQL_INTERVAL_DAY_TO_SECOND
    00424 #undef SQL_INTERVAL_HOUR_TO_MINUTE
    00425 #undef SQL_INTERVAL_HOUR_TO_SECOND
    00426 #undef SQL_INTERVAL_MINUTE_TO_SECOND
    00427
    00428 #define SQL_INTERVAL_YEAR                                       (100 + SQL_CODE_YEAR)
    00429 #define SQL_INTERVAL_MONTH                                      (100 + SQL_CODE_MONTH)
    00430 #define SQL_INTERVAL_DAY                                        (100 + SQL_CODE_DAY)
    00431 #define SQL_INTERVAL_HOUR                                       (100 + SQL_CODE_HOUR)
    00432 #define SQL_INTERVAL_MINUTE                                     (100 + SQL_CODE_MINUTE)
    00433 #define SQL_INTERVAL_SECOND                     (100 + SQL_CODE_SECOND)
    00434 #define SQL_INTERVAL_YEAR_TO_MONTH                      (100 + SQL_CODE_YEAR_TO_MONTH)
    00435 #define SQL_INTERVAL_DAY_TO_HOUR                        (100 + SQL_CODE_DAY_TO_HOUR)
    00436 #define SQL_INTERVAL_DAY_TO_MINUTE                      (100 + SQL_CODE_DAY_TO_MINUTE)
    00437 #define SQL_INTERVAL_DAY_TO_SECOND                      (100 + SQL_CODE_DAY_TO_SECOND)
    00438 #define SQL_INTERVAL_HOUR_TO_MINUTE                     (100 + SQL_CODE_HOUR_TO_MINUTE)
    00439 #define SQL_INTERVAL_HOUR_TO_SECOND                     (100 + SQL_CODE_HOUR_TO_SECOND)
    00440 #define SQL_INTERVAL_MINUTE_TO_SECOND           (100 + SQL_CODE_MINUTE_TO_SECOND)
    00441
    00442 #endif
    00443 #endif
    00444
    00445 #ifdef _WIN32
    00446 BOOL get_login_info(HWND hwndParent, TDSCONNECTION * connection);
    00447 #endif
    00448
    00449 #define ODBC_PARAM_LIST \
    00450         ODBC_PARAM(Servername) \
    00451         ODBC_PARAM(Server) \
    00452         ODBC_PARAM(DSN) \
    00453         ODBC_PARAM(UID) \
    00454         ODBC_PARAM(PWD) \
    00455         ODBC_PARAM(Address) \
    00456         ODBC_PARAM(Port) \
    00457         ODBC_PARAM(TDS_Version) \
    00458         ODBC_PARAM(Language) \
    00459         ODBC_PARAM(Database) \
    00460         ODBC_PARAM(TextSize) \
    00461         ODBC_PARAM(PacketSize) \
    00462         ODBC_PARAM(ClientCharset) \
    00463         ODBC_PARAM(DumpFile) \
    00464         ODBC_PARAM(DumpFileAppend) \
    00465         ODBC_PARAM(DebugFlags) \
    00466         ODBC_PARAM(Encryption) \
    00467         ODBC_PARAM(Trusted_Connection) \
    00468         ODBC_PARAM(APP) \
    00469         ODBC_PARAM(WSID) \
    00470         ODBC_PARAM(UseNTLMv2)
    00471
    00472 #define ODBC_PARAM(p) ODBC_PARAM_##p,
    00473 enum {
    00474         ODBC_PARAM_LIST
    00475         ODBC_PARAM_SIZE
    00476 };
    00477 #undef ODBC_PARAM
    00478
    00479
    00480 /*
    00481  * connectparams.h
    00482  */
    00483
    00484 typedef struct {
    00485         const char *p;
    00486         size_t len;
    00487 } TDS_PARSED_PARAM;
    00488
    00496 int odbc_parse_connect_string(TDS_ERRS *errs, const char *connect_string, const char *connect_string_end, TDSCONNECTION * connection, TDS_PARSED_PARAM *parsed_params);
    00497 int odbc_get_dsn_info(TDS_ERRS *errs, const char *DSN, TDSCONNECTION * connection);
    00498 #ifdef _WIN32
    00499 int odbc_build_connect_string(TDS_ERRS *errs, TDS_PARSED_PARAM *params, char **out);
    00500 #endif
    00501
    00502 /*
    00503  * convert_tds2sql.c
    00504  */
    00505 SQLLEN odbc_tds2sql(TDS_STMT * stmt, TDSCOLUMN *curcol, int srctype, TDS_CHAR * src, TDS_UINT srclen, int desttype, TDS_CHAR * dest, SQLULEN destlen, const struct _drecord *drec_ixd);
    00506
    00507 /*
    00508  * descriptor.c
    00509  */
    00510 TDS_DESC *desc_alloc(SQLHANDLE parent, int desc_type, int alloc_type);
    00511 SQLRETURN desc_free(TDS_DESC * desc);
    00512 SQLRETURN desc_alloc_records(TDS_DESC * desc, unsigned count);
    00513 SQLRETURN desc_copy(TDS_DESC * dest, TDS_DESC * src);
    00514 SQLRETURN desc_free_records(TDS_DESC * desc);
    00515 TDS_DBC *desc_get_dbc(TDS_DESC *desc);
    00516
    00517 /*
    00518  * odbc.c
    00519  */
    00520 SQLRETURN _SQLRowCount(SQLHSTMT hstmt, SQLLEN FAR * pcrow);
    00521
    00522 /*
    00523  * odbc_checks.h
    00524  */
    00525 #if ENABLE_EXTRA_CHECKS
    00526 /* macro */
    00527 #define CHECK_ENV_EXTRA(env) odbc_check_env_extra(env)
    00528 #define CHECK_DBC_EXTRA(dbc) odbc_check_dbc_extra(dbc)
    00529 #define CHECK_STMT_EXTRA(stmt) odbc_check_stmt_extra(stmt)
    00530 #define CHECK_DESC_EXTRA(desc) odbc_check_desc_extra(desc)
    00531 /* declarations*/
    00532 void odbc_check_env_extra(TDS_ENV * env);
    00533 void odbc_check_dbc_extra(TDS_DBC * dbc);
    00534 void odbc_check_stmt_extra(TDS_STMT * stmt);
    00535 void odbc_check_desc_extra(TDS_DESC * desc);
    00536 #else
    00537 /* macro */
    00538 #define CHECK_ENV_EXTRA(env)
    00539 #define CHECK_DBC_EXTRA(dbc)
    00540 #define CHECK_STMT_EXTRA(stmt)
    00541 #define CHECK_DESC_EXTRA(desc)
    00542 #endif
    00543
    00544 /*
    00545  * odbc_util.h
    00546  */
    00547
    00548 /* helpers for ODBC wide string support */
    00549 #undef _wide
    00550 #undef _WIDE
    00551 #ifdef ENABLE_ODBC_WIDE
    00552 typedef union {
    00553         char mb[1];
    00554         SQLWCHAR wide[1];
    00555 } ODBC_CHAR;
    00556 # define _wide ,wide
    00557 # define _wide0 ,0
    00558 # define _WIDE ,int wide
    00559 #else
    00560 # define _wide
    00561 # define _wide0
    00562 # define _WIDE
    00563 # define ODBC_CHAR SQLCHAR
    00564 #endif
    00565 int odbc_set_stmt_query(struct _hstmt *stmt, const ODBC_CHAR *sql, int sql_len _WIDE);
    00566 int odbc_set_stmt_prepared_query(struct _hstmt *stmt, const ODBC_CHAR *sql, int sql_len _WIDE);
    00567 void odbc_set_return_status(struct _hstmt *stmt, unsigned int n_row);
    00568 void odbc_set_return_params(struct _hstmt *stmt, unsigned int n_row);
    00569
    00570 SQLSMALLINT odbc_server_to_sql_type(int col_type, int col_size);
    00571 int odbc_sql_to_c_type_default(int sql_type);
    00572 int odbc_sql_to_server_type(TDSSOCKET * tds, int sql_type);
    00573 int odbc_c_to_server_type(int c_type);
    00574
    00575 void odbc_set_sql_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver);
    00576 SQLINTEGER odbc_sql_to_displaysize(int sqltype, TDSCOLUMN *col);
    00577 int odbc_get_string_size(int size, ODBC_CHAR * str _WIDE);
    00578 void odbc_rdbms_version(TDSSOCKET * tds_socket, char *pversion_string);
    00579 SQLINTEGER odbc_get_param_len(const struct _drecord *drec_axd, const struct _drecord *drec_ixd, const TDS_DESC* axd, unsigned int n_row);
    00580
    00581 #ifdef ENABLE_ODBC_WIDE
    00582 DSTR* odbc_dstr_copy_flag(TDS_DBC *dbc, DSTR *s, int size, ODBC_CHAR * str, int flag);
    00583 #define odbc_dstr_copy(dbc, s, len, out) \
    00584         odbc_dstr_copy_flag(dbc, s, len, sizeof((out)->mb) ? (out) : (out), wide)
    00585 #define odbc_dstr_copy_oct(dbc, s, len, out) \
    00586         odbc_dstr_copy_flag(dbc, s, len, out, wide|0x20)
    00587 #else
    00588 DSTR* odbc_dstr_copy(TDS_DBC *dbc, DSTR *s, int size, ODBC_CHAR * str);
    00589 #define odbc_dstr_copy_oct odbc_dstr_copy
    00590 #endif
    00591
    00592
    00593 SQLRETURN odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer, SQLINTEGER cbBuffer, void FAR * pcbBuffer, const char *s, int len, int flag);
    00594 #ifdef ENABLE_ODBC_WIDE
    00595 #define odbc_set_string(dbc, buf, buf_len, out_len, s, s_len) \
    00596         odbc_set_string_flag(dbc, sizeof((buf)->mb) ? (buf) : (buf), buf_len, out_len, s, s_len, (wide) | (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0:0x10))
    00597 #define odbc_set_string_oct(dbc, buf, buf_len, out_len, s, s_len) \
    00598         odbc_set_string_flag(dbc, buf, buf_len, out_len, s, s_len, (wide) | (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0x20:0x30))
    00599 #else
    00600 #define odbc_set_string(dbc, buf, buf_len, out_len, s, s_len) \
    00601         odbc_set_string_flag(dbc, buf, buf_len, out_len, s, s_len, (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0:0x10))
    00602 #define odbc_set_string_oct(dbc, buf, buf_len, out_len, s, s_len) \
    00603         odbc_set_string_flag(dbc, buf, buf_len, out_len, s, s_len, (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0x20:0x30))
    00604 #endif
    00605
    00606 SQLSMALLINT odbc_get_concise_sql_type(SQLSMALLINT type, SQLSMALLINT interval);
    00607 SQLRETURN odbc_set_concise_sql_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only);
    00608 SQLSMALLINT odbc_get_concise_c_type(SQLSMALLINT type, SQLSMALLINT interval);
    00609 SQLRETURN odbc_set_concise_c_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only);
    00610
    00611 SQLLEN odbc_get_octet_len(int c_type, const struct _drecord *drec);
    00612 void odbc_convert_err_set(struct _sql_errors *errs, TDS_INT err);
    00613
    00614 /*
    00615  * prepare_query.c
    00616  */
    00617 SQLRETURN prepare_call(struct _hstmt *stmt);
    00618 SQLRETURN native_sql(struct _hdbc *dbc, char *s);
    00619 int parse_prepared_query(struct _hstmt *stmt, int compute_row);
    00620 int start_parse_prepared_query(struct _hstmt *stmt, int compute_row);
    00621 int continue_parse_prepared_query(struct _hstmt *stmt, SQLPOINTER DataPtr, SQLLEN StrLen_or_Ind);
    00622 const char *parse_const_param(const char * s, TDS_SERVER_TYPE *type);
    00623
    00624 /*
    00625  * sql2tds.c
    00626  */
    00627 SQLRETURN odbc_sql2tds(TDS_STMT * stmt, const struct _drecord *drec_ixd, const struct _drecord *drec_axd, TDSCOLUMN *curcol, int compute_row, const TDS_DESC* axd, unsigned int n_row);
    00628
    00629 /*
    00630  * sqlwchar.c
    00631  */
    00632 #if SIZEOF_SQLWCHAR != SIZEOF_WCHAR_T
    00633 size_t sqlwcslen(const SQLWCHAR * s);
    00634 #else
    00635 #define sqlwcslen wcslen
    00636 #endif
    00637
    00638 #if SIZEOF_SQLWCHAR == 2
    00639 # if WORDS_BIGENDIAN
    00640 #  define ODBC_WIDE_NAME "UCS-2BE"
    00641 # else
    00642 #  define ODBC_WIDE_NAME "UCS-2LE"
    00643 # endif
    00644 #elif SIZEOF_SQLWCHAR == 4
    00645 # if WORDS_BIGENDIAN
    00646 #  define ODBC_WIDE_NAME "UCS-4BE"
    00647 # else
    00648 #  define ODBC_WIDE_NAME "UCS-4LE"
    00649 # endif
    00650 #else
    00651 #error SIZEOF_SQLWCHAR not supported !!
    00652 #endif
    00653
    00654 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
    00655 #pragma GCC visibility pop
    00656 #endif
    00657
    00658 #ifdef __cplusplus
    00659 #if 0
    00660 {
    00661 #endif
    00662 }
    00663 #endif
    00664
    00665 #endif

All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines