forked from CUBRID/cubrid-odbc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
odbc_connection.h
198 lines (180 loc) · 7.14 KB
/
odbc_connection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
* Copyright (C) 2008 Search Solution Corporation. All rights reserved by Search Solution.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of the <ORGANIZATION> nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
*/
#ifndef __ODBC_CONN_HEADER /* to avoid multiple inclusion */
#define __ODBC_CONN_HEADER
#include "odbc_portable.h"
#include "odbc_diag_record.h"
#include "odbc_env.h"
#include "odbc_statement.h"
#define KEYWORD_DSN "DSN"
#define KEYWORD_FILEDSN "FILEDSN"
#define KEYWORD_DBNAME "DB_NAME"
#define KEYWORD_USER "UID"
#define KEYWORD_PASSWORD "PWD"
#define KEYWORD_SERVER "SERVER"
#define KEYWORD_PORT "PORT"
#define KEYWORD_FETCH_SIZE "FETCH_SIZE"
#define KEYWORD_DESCRIPTION "DESCRIPTION"
#define KEYWORD_SAVEFILE "SAVEFILE"
#define KEYWORD_DRIVER "DRIVER"
#define KEYWORD_CHARSET "CHARSET"
#define KEYWORD_ALTHOSTS "ALTHOSTS"
#define KEYWORD_RCTIME "RCTIME"
#define KEYWORD_LOADBALANCE "LOADBALANCE"
#define KEYWORD_QUERYTIMEOUT "QUERYTIMEOUT"
#define KEYWORD_QUERY_TIMEOUT "QUERY_TIMEOUT"
#define KEYWORD_LOGINTIMEOUT "LOGINTIMEOUT"
#define KEYWORD_LOGIN_TIMEOUT "LOGIN_TIMEOUT"
#define KEYWORD_DISCONNECT_ON_QUERY_TIMEOUT "DISCONNECT_ON_QUERY_TIMEOUT"
#define KEYWORD_DISCONNECTONQUERYTIMEOUT "DISCONNECTONQUERYTIMEOUT"
#define KEYWORD_LOGFILE "LOGFILE"
#define KEYWORD_LOGBASEDIR "LOGBASEDIR"
#define KEYWORD_LOGSLOWQUERIES "LOGSLOWQUERIES"
#define KEYWORD_SLOWQUERYTHRESHOLDMILLIS "SLOWQUERYTHRESHOLDMILLIS"
#define KEYWORD_LOGTRACEAPI "LOGTRACEAPI"
#define KEYWORD_LOGTRACENETWORK "LOGTRACENETWORK"
typedef struct stCUBRIDDSNItem
{
char driver[ITEMBUFLEN];
char dsn[ITEMBUFLEN];
char db_name[ITEMBUFLEN];
char user[ITEMBUFLEN];
char password[ITEMBUFLEN];
char server[ITEMBUFLEN];
char port[ITEMBUFLEN];
char fetch_size[ITEMBUFLEN];
char save_file[_MAX_PATH];
char description[2 * ITEMBUFLEN];
char charset[ITEMBUFLEN];
} CUBRIDDSNItem;
typedef struct st_odbc_connection_attr
{
char *altHosts;
char *rcTime;
char *loadBalance;
char *login_timeout;
char *query_timeout;
char *disconnect_on_query_timeout;
char *logFile;
char *logBaseDir;
char *logSlowQueries;
char *slowQueryThresholdMillis;
char *logTraceApi;
char *logTraceNetwork;
} ODBC_CONNECTION_ATTR;
typedef struct st_odbc_connection
{
unsigned short handle_type;
struct st_diag *diag;
int connhd;
struct st_odbc_env *env;
struct st_odbc_connection *next;
//void *statements;
//void *descriptors;
struct st_odbc_statement *statements;
struct st_odbc_desc *descriptors; /* external descriptor */
char *data_source; /* data source name */
unsigned char *server; /* odbc server address */
long port; /* odbc server port number */
char *db_name; /* CUBRID db name */
char *user; /* CUBRID db user */
char *password; /* CUBRID db password */
int fetch_size; /* fetch size */
struct st_odbc_connection_attr attr_connect;
char *charset;
char db_ver[16];
unsigned long old_txn_isolation; /* for read-only mode */
// Maximum length of the string data type from UniCAS
long max_string_length;
/* ODBC connection attributes */
unsigned long attr_access_mode; /* CORE */
unsigned long attr_autocommit; /* LEVEL 1 */
//unsigned long attr_connection_dead; /* LEVEL 1 */
// attr_connection_dead´Â connhd·Î ºÎÅÍ ¾Ë¾Æ ³¾ ¼ö ÀÖ´Ù.
// if connhd > 0, alive.
void *attr_quiet_mode; /* CORE */
unsigned long attr_metadata_id; /* CORE */
unsigned long attr_odbc_cursors; /* CORE, DM */
unsigned long attr_trace; /* CORE, DM */
char *attr_tracefile; /* CORE, DM */
unsigned long attr_txn_isolation; /* LEVEL 1 */
unsigned long attr_async_enable; /* LEVEL 1 */
/* Not supported */
unsigned long attr_auto_ipd; /* LEVEL2, RDONLY */
unsigned long attr_connection_timeout; /* LEVEL 2 */
char *attr_current_catalog; /* LEVEL 2 */
unsigned long attr_login_timeout; /* LEVEL 2 */
unsigned long attr_packet_size; /* LEVEL 2 */
char *attr_translate_lib; /* CORE */
unsigned long attr_translate_option; /* CORE */
/* stmt attributes */
unsigned long attr_max_rows; // 1
unsigned long attr_query_timeout; // 2
} ODBC_CONNECTION;
PUBLIC RETCODE odbc_alloc_connection (ODBC_ENV * env,
ODBC_CONNECTION ** connptr);
PUBLIC RETCODE odbc_free_connection (ODBC_CONNECTION * conn);
PUBLIC RETCODE odbc_connect_new (ODBC_CONNECTION * conn,
const char *data_source,
const char *db_name,
const char *user,
const char *password,
const char *server,
int port, int fetch_size,
const char *charset,
const char *conn_str_in);
PUBLIC RETCODE odbc_disconnect (ODBC_CONNECTION * conn);
PUBLIC RETCODE odbc_set_connect_attr (ODBC_CONNECTION * conn,
long attribute,
void *valueptr, long stringlength);
PUBLIC RETCODE odbc_get_connect_attr (ODBC_CONNECTION * conn,
SQLINTEGER attribute,
SQLPOINTER value_ptr,
SQLINTEGER buffer_length,
SQLINTEGER * string_length_ptr);
PUBLIC RETCODE odbc_auto_commit (ODBC_CONNECTION * conn);
PUBLIC RETCODE odbc_native_sql (ODBC_CONNECTION * conn,
SQLCHAR * in_stmt_text,
SQLCHAR * out_stmt_text,
SQLINTEGER buffer_length,
SQLINTEGER * out_stmt_length);
PUBLIC RETCODE odbc_get_functions (ODBC_CONNECTION * conn,
unsigned short function_id,
unsigned short *supported_ptr);
PUBLIC RETCODE odbc_get_info (ODBC_CONNECTION * conn, SQLUSMALLINT info_type,
SQLPOINTER info_value_ptr,
SQLSMALLINT buffer_length,
SQLLEN * string_length_ptr);
PUBLIC int get_dsn_info (const char *dsn, char *db_name, int db_name_len,
char *user, int user_len, char *pwd, int pwd_len,
char *server, int server_len, int *port,
int *fetch_size,
char *charset, int charset_len);
#endif /* ! __ODBC_CONN_HEADER */