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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
--- generic/mysqltcl.c.orig Wed Jan 11 21:08:48 2006
+++ generic/mysqltcl.c Wed Jan 11 21:17:10 2006
@@ -95,6 +95,8 @@
/* C variable corresponding to mysqlstatus(nullvalue) */
#define MYSQL_NULLV_INIT ""
+#define FUNCTION_NOT_AVAILABLE "function not available"
+
/* Check Level for mysql_prologue */
enum CONNLEVEL {CL_PLAIN,CL_CONN,CL_DB,CL_RES};
@@ -183,7 +185,6 @@
static int MysqlNullSet(Tcl_Interp *interp, Tcl_Obj *objPtr)
{
Tcl_ObjType *oldTypePtr = objPtr->typePtr;
- Tcl_HashEntry *entryPtr;
if ((oldTypePtr != NULL) && (oldTypePtr->freeIntRepProc != NULL)) {
oldTypePtr->freeIntRepProc(objPtr);
@@ -803,6 +804,7 @@
if (booleanflag)
flags |= CLIENT_ODBC;
break;
+#if (MYSQL_VERSION_ID >= 40107)
case MYSQL_MULTISTATEMENT_OPT:
if (Tcl_GetBooleanFromObj(interp,objv[++i],&booleanflag) != TCL_OK )
return TCL_ERROR;
@@ -817,6 +819,7 @@
if (booleanflag)
flags |= CLIENT_MULTI_RESULTS;
break;
+#endif
case MYSQL_LOCALFILES_OPT:
if (Tcl_GetBooleanFromObj(interp,objv[++i],&booleanflag) != TCL_OK )
@@ -876,9 +879,11 @@
#if (MYSQL_VERSION_ID>=32350)
mysql_options(handle->connection,MYSQL_READ_DEFAULT_GROUP,groupname);
#endif
+#if (MYSQL_VERSION_ID >= 40107)
if (isSSL) {
mysql_ssl_set(handle->connection,sslkey,sslcert, sslca, sslcapath, sslcipher);
}
+#endif
if (!mysql_real_connect(handle->connection, hostname, user,
password, db, port, socket, flags)) {
@@ -1388,8 +1393,8 @@
static int Mysqltcl_Receive(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
MysqltclState *statePtr = (MysqltclState *)clientData;
- int code ;
- int count ;
+ int code = TCL_ERROR;
+ int count = 0;
MysqlTclHandle *handle;
int idx ;
@@ -1397,7 +1402,6 @@
Tcl_Obj** listObjv ;
MYSQL_ROW row ;
int *val = NULL;
- int breakLoop = 0;
unsigned long *lengths;
@@ -1455,15 +1459,9 @@
switch(code=Tcl_EvalObjEx(interp, objv[4],0)) {
case TCL_CONTINUE:
case TCL_OK:
- break ;
- case TCL_BREAK:
- breakLoop=1;
- break;
- default:
- breakLoop=1;
- break;
+ continue;
}
- if (breakLoop==1) break;
+ break;
}
}
if (val!=NULL) {
@@ -1592,6 +1590,7 @@
Tcl_SetObjResult(interp, Tcl_NewStringObj(val,-1));
}
break;
+#if (MYSQL_VERSION_ID >= 40107)
case MYSQL_INF_SERVERVERSION:
Tcl_SetObjResult(interp, Tcl_NewStringObj(mysql_get_server_info(handle->connection),-1));
break;
@@ -1604,6 +1603,7 @@
case MYSQL_INFO_STATE:
Tcl_SetObjResult(interp, Tcl_NewStringObj(mysql_stat(handle->connection),-1));
break;
+#endif
default: /* should never happen */
return mysql_prim_confl(interp,objc,objv,"weirdness in Mysqltcl_Info") ;
}
@@ -1625,6 +1625,7 @@
int idx ;
Tcl_Obj *resList;
char **option;
+#if (MYSQL_VERSION_ID >= 40107)
static CONST char* MysqlInfoOpt[] =
{
"connectparameters", "clientversion","clientversionid", NULL
@@ -1632,6 +1633,15 @@
enum baseoption {
MYSQL_BINFO_CONNECT, MYSQL_BINFO_CLIENTVERSION,MYSQL_BINFO_CLIENTVERSIONID
};
+#else
+ static CONST char* MysqlInfoOpt[] =
+ {
+ "connectparameters", "clientversion", NULL
+ };
+ enum baseoption {
+ MYSQL_BINFO_CONNECT, MYSQL_BINFO_CLIENTVERSION
+ };
+#endif
if (objc <2) {
Tcl_WrongNumArgs(interp, 1, objv, "connectparameters | clientversion");
@@ -1657,9 +1667,11 @@
case MYSQL_BINFO_CLIENTVERSION:
Tcl_SetObjResult(interp, Tcl_NewStringObj(mysql_get_client_info(),-1));
break;
+#if (MYSQL_VERSION_ID >= 40107)
case MYSQL_BINFO_CLIENTVERSIONID:
Tcl_SetObjResult(interp, Tcl_NewIntObj(mysql_get_client_version()));
break;
+#endif
}
return TCL_OK ;
}
@@ -1974,6 +1986,10 @@
static int Mysqltcl_AutoCommit(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
int isAutocommit = 0;
@@ -1986,6 +2002,7 @@
mysql_server_confl(interp,objc,objv,handle->connection);
}
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------
@@ -1997,6 +2014,10 @@
static int Mysqltcl_Commit(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
if ((handle = mysql_prologue(interp, objc, objv, 2, 2, CL_CONN,
@@ -2006,6 +2027,7 @@
mysql_server_confl(interp,objc,objv,handle->connection);
}
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------
@@ -2017,6 +2039,10 @@
static int Mysqltcl_Rollback(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
if ((handle = mysql_prologue(interp, objc, objv, 2, 2, CL_CONN,
@@ -2026,6 +2052,7 @@
mysql_server_confl(interp,objc,objv,handle->connection);
}
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------
@@ -2037,6 +2064,10 @@
static int Mysqltcl_MoreResult(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
int boolResult = 0;
@@ -2046,6 +2077,7 @@
boolResult = mysql_more_results(handle->connection);
Tcl_SetObjResult(interp,Tcl_NewBooleanObj(boolResult));
return TCL_OK;
+#endif
}
/*
@@ -2059,6 +2091,10 @@
static int Mysqltcl_NextResult(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
int result = 0;
@@ -2085,6 +2121,7 @@
Tcl_SetObjResult(interp, Tcl_NewIntObj(handle->res_count));
}
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------
@@ -2096,6 +2133,10 @@
static int Mysqltcl_WarningCount(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
int count = 0;
@@ -2105,6 +2146,7 @@
count = mysql_warning_count(handle->connection);
Tcl_SetObjResult(interp,Tcl_NewIntObj(count));
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------
@@ -2149,7 +2191,6 @@
static int Mysqltcl_NewNull(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Tcl_Obj *objPtr;
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, "");
return TCL_ERROR;
@@ -2164,13 +2205,19 @@
* usage: mysql::setserveroption (-
*
*/
+#if (MYSQL_VERSION_ID >= 40107)
static CONST char* MysqlServerOpt[] =
{
"-multi_statment_on", "-multi_statment_off",NULL
};
+#endif
static int Mysqltcl_SetServerOption(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
int idx;
enum enum_mysql_set_option mysqlServerOption;
@@ -2201,6 +2248,7 @@
mysql_server_confl(interp,objc,objv,handle->connection);
}
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------
@@ -2211,6 +2259,10 @@
*/
static int Mysqltcl_ShutDown(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
if ((handle = mysql_prologue(interp, objc, objv, 2, 2, CL_CONN,
@@ -2220,6 +2272,7 @@
mysql_server_confl(interp,objc,objv,handle->connection);
}
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------
|