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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
diff -NurdB libgda-1.2.3/configure.in libgda-1.2.3-patched/configure.in
--- libgda-1.2.3/configure.in 2005-10-27 04:18:24.000000000 -0500
+++ libgda-1.2.3-patched/configure.in 2006-08-06 02:13:21.000000000 -0500
@@ -440,45 +440,23 @@
AC_MSG_WARN(tds backend not used)
else
AC_MSG_CHECKING(for freetds version)
- freetdsvercheck="`grep \"^#define \(VERSION_NO \|TDS_VERSION_NO \)\" $freetds_incdir/tdsver.h|sed 's|^.*"\(.*\)"|\1|'`"
+ freetdsvercheck="`grep \"^#define \(VERSION_NO \|TDS_VERSION_NO \)\" $freetds_incdir/tdsver.h|sed 's|^.*".*v\(.*\)"|\1|'`"
if test "x$freetdsvercheck" = "x"
then
AC_MSG_WARN(freetds version check failed - backend not used)
freetdsdir=""
freetds_incdir=""
else
- case "$freetdsvercheck" in
- *v0.5*) AC_MSG_RESULT($freetdsvercheck - using v0.5x api)
- AC_DEFINE(HAVE_FREETDS_VER0_5X, 1, [Have freetds v0.5x API])
- FREETDS_CFLAGS="-I${freetds_incdir}"
- FREETDS_LIBS="-L${freetdsdir}/lib -ltds"
- AC_DEFINE(HAVE_FREETDS, 1, [Have freetds])
- ;;
- *v0.60) AC_MSG_RESULT($freetdsvercheck - using v0.60 api)
- AC_DEFINE(HAVE_FREETDS_VER0_60, 1, [Have freetds v0.60 API])
- FREETDS_CFLAGS="-I${freetds_incdir}"
- FREETDS_LIBS="-L${freetdsdir}/lib -ltds"
- AC_DEFINE(HAVE_FREETDS, 1, [Have freetds])
- ;;
- *v0.6[[3-9]]*) AC_MSG_RESULT($freetdsvercheck - using v0.63 api)
- AC_DEFINE(HAVE_FREETDS_VER0_63, 1, [Have freetds v0.63 API])
- AC_DEFINE(HAVE_FREETDS_VER0_6X, 1, [Have freetds v0.6x API])
- FREETDS_CFLAGS="-I${freetds_incdir}"
- FREETDS_LIBS="-L${freetdsdir}/lib -ltds"
- AC_DEFINE(HAVE_FREETDS, 1, [Have freetds])
- ;;
- *v0.6*) AC_MSG_RESULT($freetdsvercheck - using v0.6x api)
- AC_DEFINE(HAVE_FREETDS_VER0_6X, 1, [Have freetds v0.6x API])
- FREETDS_CFLAGS="-I${freetds_incdir}"
- FREETDS_LIBS="-L${freetdsdir}/lib -ltds"
- AC_DEFINE(HAVE_FREETDS, 1, [Have freetds])
- ;;
- *) AC_MSG_WARN($freetdsvercheck not supported - backend not used)
- freetdsdir=""
- freetds_incdir=""
- ;;
- esac
-
+ AC_MSG_RESULT($freetdsvercheck)
+ FREETDS_CFLAGS="-I${freetds_incdir}"
+ FREETDS_LIBS="-L${freetdsdir}/lib -ltds"
+ AC_DEFINE(HAVE_FREETDS, 1, [Have freetds])
+
+ freetds_version_major="`echo $freetdsvercheck|sed 's:^\([[^.]]*\).*:\1:'`"
+ freetds_version_minor="`echo $freetdsvercheck|sed 's:^[[^.]]*\.\([[^.]]*\).*:\1:'`"
+
+ AC_DEFINE_UNQUOTED(FREETDS_VERSION_MAJOR, [$freetds_version_major])
+ AC_DEFINE_UNQUOTED(FREETDS_VERSION_MINOR, [$freetds_version_minor])
fi
fi
fi
diff -NurdB libgda-1.2.3/providers/freetds/gda-freetds-provider.c libgda-1.2.3-patched/providers/freetds/gda-freetds-provider.c
--- libgda-1.2.3/providers/freetds/gda-freetds-provider.c 2004-12-28 08:26:11.000000000 -0500
+++ libgda-1.2.3-patched/providers/freetds/gda-freetds-provider.c 2006-08-06 04:13:59.000000000 -0500
@@ -103,7 +103,7 @@
const gint col,
const gint row);
-#ifdef HAVE_FREETDS_VER0_5X
+#if FREETDS_VERSION < 6000
static gboolean tds_cbs_initialized = FALSE;
extern int (*g_tds_msg_handler)();
extern int (*g_tds_err_handler)();
@@ -116,7 +116,7 @@
static int gda_freetds_provider_tds_handle_message (void *aStruct,
void *bStruct,
const gboolean is_err_msg);
-#if defined(HAVE_FREETDS_VER0_6X) || defined(HAVE_FREETDS_VER0_60)
+#if FREETDS_VERSION >= 6000
static int gda_freetds_provider_tds_handle_info_msg (TDSCONTEXT *,
TDSSOCKET *,
TDSMSGINFO *);
@@ -252,8 +252,12 @@
tds_set_packet(tds_cnc->login, 512);
/* Version 0.60 api uses context additionaly */
-#if defined(HAVE_FREETDS_VER0_6X) || defined(HAVE_FREETDS_VER0_60)
+#if FREETDS_VERSION >= 6000
+#if FREETDS_VERSION >= 6400
+ tds_cnc->ctx = tds_alloc_context(NULL);
+#else
tds_cnc->ctx = tds_alloc_context();
+#endif
if (! tds_cnc->ctx) {
gda_log_error (_("Allocating tds context failed."));
gda_freetds_free_connection_data (tds_cnc);
@@ -267,9 +271,9 @@
#endif
/* establish connection; change in 0.6x api */
-#if defined(HAVE_FREETDS_VER0_60)
+#if FREETDS_VERSION == 6000
tds_cnc->tds = tds_connect(tds_cnc->login, tds_cnc->ctx, NULL);
-#elif defined(HAVE_FREETDS_VER0_6X)
+#elif FREETDS_VERSION > 6000
tds_cnc->tds = tds_alloc_socket(tds_cnc->ctx, 512);
if (! tds_cnc->tds) {
gda_log_error (_("Allocating tds socket failed."));
@@ -297,9 +301,9 @@
}
/* try to receive connection info for sanity check */
-#if defined(HAVE_FREETDS_VER0_6X)
+#if FREETDS_VERSION > 6000
/* do nothing */
-#elif defined(HAVE_FREETDS_VER0_60)
+#elif FREETDS_VERSION == 6000
tds_cnc->config = tds_get_config(tds_cnc->tds, tds_cnc->login, tds_cnc->ctx->locale);
#else
tds_cnc->config = tds_get_config(tds_cnc->tds, tds_cnc->login);
@@ -357,7 +361,7 @@
tds_cnc->database = NULL;
}
if (tds_cnc->config) {
-#ifdef HAVE_FREETDS_VER0_6X
+#if FREETDS_VERSION > 6000
tds_free_connect (tds_cnc->config);
#else
tds_free_config(tds_cnc->config);
@@ -370,7 +374,7 @@
tds_free_socket (tds_cnc->tds);
tds_cnc->tds = NULL;
}
-#if defined(HAVE_FREETDS_VER0_6X) || defined(HAVE_FREETDS_VER0_60)
+#if FREETDS_VERSION >= 6000
if (tds_cnc->ctx) {
/* Clear callback handler */
tds_cnc->ctx->msg_handler = NULL;
@@ -782,7 +786,7 @@
{
GdaFreeTDSConnectionData *tds_cnc;
GdaError *error;
-#ifdef HAVE_FREETDS_VER0_6X
+#if FREETDS_VERSION > 6000
int result_type = 0;
#endif
@@ -802,7 +806,11 @@
}
/* there should not be any result tokens */
-#ifdef HAVE_FREETDS_VER0_6X
+#if FREETDS_VERSION >= 6400
+ while ((tds_cnc->rc = tds_process_tokens (tds_cnc->tds, &tds_cnc->result_type, NULL, TDS_RETURN_ROWFMT | TDS_RETURN_COMPUTEFMT | TDS_RETURN_DONE | TDS_STOPAT_ROW | TDS_STOPAT_COMPUTE | TDS_RETURN_PROC))
+#elif FREETDS_VERSION >= 6200
+ while ((tds_cnc->rc = tds_process_result_tokens (tds_cnc->tds, &tds_cnc->result_type, NULL))
+#elif FREETDS_VERSION > 6000
while ((tds_cnc->rc = tds_process_result_tokens (tds_cnc->tds, &tds_cnc->result_type))
#else
while ((tds_cnc->rc = tds_process_result_tokens (tds_cnc->tds))
@@ -1002,7 +1010,7 @@
provider_class->supports = gda_freetds_provider_supports;
provider_class->get_schema = gda_freetds_provider_get_schema;
-#ifdef HAVE_FREETDS_VER0_5X
+#if FREETDS_VERSION < 6000
if (tds_cbs_initialized == FALSE) {
tds_cbs_initialized = TRUE;
@@ -1025,7 +1033,7 @@
g_return_if_fail (GDA_IS_FREETDS_PROVIDER (provider));
-#ifdef HAVE_FREETDS_VER0_5X
+#if FREETDS_VERSION < 6000
tds_cbs_initialized = FALSE;
g_tds_msg_handler = NULL;
g_tds_err_handler = NULL;
@@ -1058,9 +1066,15 @@
TDS_SUCCEED);
msg = g_strdup_printf(_("Msg %d, Level %d, State %d, Server %s, Line %d\n%s\n"),
+#if FREETDS_VERSION >= 6400
+ msg_info->msgno,
+ msg_info->severity,
+ msg_info->state,
+#else
msg_info->msg_number,
msg_info->msg_level,
msg_info->msg_state,
+#endif
(msg_info->server ? msg_info->server : ""),
msg_info->line_number,
msg_info->message ? msg_info->message : "");
@@ -1070,7 +1084,11 @@
if (cnc != NULL) {
error = gda_error_new ();
gda_error_set_description (error, msg);
+#if FREETDS_VERSION >= 6400
+ gda_error_set_number (error, msg_info->msgno);
+#else
gda_error_set_number (error, msg_info->msg_number);
+#endif
gda_error_set_source (error, "gda-freetds");
if (msg_info->sql_state != NULL) {
gda_error_set_sqlstate (error,
@@ -1095,14 +1113,14 @@
return TDS_SUCCEED;
}
-#if defined(HAVE_FREETDS_VER0_6X) || defined(HAVE_FREETDS_VER0_60)
+#if FREETDS_VERSION >= 6000
/* FIXME: rewrite tds_handle_message as well/use new parameters here */
static int
gda_freetds_provider_tds_handle_info_msg (TDSCONTEXT *ctx, TDSSOCKET *tds,
TDSMSGINFO *msg)
{
return gda_freetds_provider_tds_handle_message ((void *) tds,
-#ifdef HAVE_FREETDS_VER0_6X
+#if FREETDS_VERSION > 6000
(void *) msg,
#else
(void *) tds->msg_info,
@@ -1117,14 +1135,14 @@
}
#endif
-#if defined(HAVE_FREETDS_VER0_6X) || defined(HAVE_FREETDS_VER0_60)
+#if FREETDS_VERSION >= 6000
/* FIXME: rewrite tds_handle_message as well/use new parameters here */
static int
gda_freetds_provider_tds_handle_err_msg (TDSCONTEXT *ctx, TDSSOCKET *tds,
TDSMSGINFO *msg)
{
return gda_freetds_provider_tds_handle_message ((void *) tds,
-#ifdef HAVE_FREETDS_VER0_6X
+#if FREETDS_VERSION > 6000
(void *) msg,
#else
(void *) tds->msg_info,
diff -NurdB libgda-1.2.3/providers/freetds/gda-freetds-provider.h libgda-1.2.3-patched/providers/freetds/gda-freetds-provider.h
--- libgda-1.2.3/providers/freetds/gda-freetds-provider.h 2005-10-27 04:18:24.000000000 -0500
+++ libgda-1.2.3-patched/providers/freetds/gda-freetds-provider.h 2006-08-06 02:13:21.000000000 -0500
@@ -30,14 +30,16 @@
G_BEGIN_DECLS
+#define FREETDS_VERSION (10000*FREETDS_VERSION_MAJOR+100*FREETDS_VERSION_MINOR)
+
/* Compatibility macros */
-#ifdef HAVE_FREETDS_VER0_63
+#if FREETDS_VERSION >= 6300
#define TDSCONNECTINFO TDSCONNECTION
#define TDSCOLINFO TDSCOLUMN
#define TDSMSGINFO TDSMESSAGE
-#endif /* HAVE_FREETDS_VER0_63 */
+#endif /* FREETDS_VERSION >= 6300 */
#define GDA_TYPE_FREETDS_PROVIDER (gda_freetds_provider_get_type())
#define GDA_FREETDS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_FREETDS_PROVIDER, GdaFreeTDSProvider))
@@ -68,11 +70,11 @@
gchar *database; /* database we are connected to */
TDSLOGIN *login; /* tds login struct */
-#if defined(HAVE_FREETDS_VER0_6X) || defined(HAVE_FREETDS_VER0_60)
+#if FREETDS_VERSION >= 6000
TDSCONTEXT *ctx; /* tds context */
#endif
TDSSOCKET *tds; /* connection handle */
-#ifdef HAVE_FREETDS_VER0_6X
+#if FREETDS_VERSION > 6000
TDSCONNECTINFO *config; /* tds connect struct */
#else
TDSCONFIGINFO *config; /* tds config struct */
diff -NurdB libgda-1.2.3/providers/freetds/gda-freetds-recordset.c libgda-1.2.3-patched/providers/freetds/gda-freetds-recordset.c
--- libgda-1.2.3/providers/freetds/gda-freetds-recordset.c 2004-12-28 08:26:11.000000000 -0500
+++ libgda-1.2.3-patched/providers/freetds/gda-freetds-recordset.c 2006-08-06 04:09:11.000000000 -0500
@@ -279,7 +279,7 @@
/* set pointers to NULL */
copy->column_nullbind = NULL;
-#ifdef HAVE_FREETDS_VER0_6X
+#if FREETDS_VERSION > 6000
copy->column_varaddr = NULL;
#else
copy->varaddr = NULL;
@@ -339,9 +339,20 @@
recset->priv->tds_cnc = tds_cnc;
recset->priv->res = tds_cnc->tds->res_info;
-#ifdef HAVE_FREETDS_VER0_6X
+#if FREETDS_VERSION > 6000
+#if FREETDS_VERSION >= 6400
+ while ((tds_cnc->rc = tds_process_tokens (tds_cnc->tds,
+ &tds_cnc->result_type, NULL,
+ TDS_RETURN_ROWFMT | TDS_RETURN_COMPUTEFMT |
+ TDS_RETURN_DONE | TDS_STOPAT_ROW |
+ TDS_STOPAT_COMPUTE | TDS_RETURN_PROC))
+#elif FREETDS_VERSION >= 6200
+ while ((tds_cnc->rc = tds_process_result_tokens (tds_cnc->tds,
+ &tds_cnc->result_type, NULL))
+#else
while ((tds_cnc->rc = tds_process_result_tokens (tds_cnc->tds,
&tds_cnc->result_type))
+#endif
== TDS_SUCCEED) {
if (tds_cnc->result_type == TDS_ROW_RESULT) {
gint row_type, compute_id;
@@ -378,7 +389,11 @@
g_object_unref (recset);
recset = NULL;
return NULL;
+#if FREETDS_VERSION >= 6400
+ } else if (tds_cnc->rc != TDS_NO_MORE_RESULTS) {
+#else
} else if (tds_cnc->rc != TDS_NO_MORE_ROWS) {
+#endif
error = gda_freetds_make_error(tds_cnc->tds,
_("Unexpected freetds return code in tds_process_row_tokens().\n"));
gda_connection_add_error (cnc, error);
diff -NurdB libgda-1.2.3/providers/freetds/gda-freetds-types.c libgda-1.2.3-patched/providers/freetds/gda-freetds-types.c
--- libgda-1.2.3/providers/freetds/gda-freetds-types.c 2003-03-09 13:55:34.000000000 -0500
+++ libgda-1.2.3-patched/providers/freetds/gda-freetds-types.c 2006-08-06 02:13:21.000000000 -0500
@@ -191,7 +191,7 @@
const TDS_INT max_size = 255;
TDS_INT col_size = 0;
gchar *txt = NULL;
-#ifdef HAVE_FREETDS_VER0_6X
+#if FREETDS_VERSION > 6000
CONV_RESULT tds_conv;
#endif
GdaNumeric numeric;
@@ -202,7 +202,7 @@
/* perhaps remove ifdef later on
* tds_cnc is just needed for context structure of 0.6x api for now
*/
-#ifdef HAVE_FREETDS_VER0_6X
+#if FREETDS_VERSION > 6000
g_return_if_fail (tds_cnc != NULL);
g_return_if_fail (tds_cnc->ctx != NULL);
@@ -309,7 +309,7 @@
txt = g_new0 (gchar, col_size);
/* tds_convert api changed to 0.6x */
-#ifdef HAVE_FREETDS_VER0_6X
+#if FREETDS_VERSION > 6000
if (tds_convert (tds_cnc->ctx,
col->column_type, val,
col->column_size, SYBCHAR,
@@ -319,7 +319,7 @@
gda_value_set_string (field,
(tds_conv.c ? tds_conv.c : (tds_conv.ib ? tds_conv.ib : "")));
}
-#elif HAVE_FREETDS_VER0_60
+#elif FREETDS_VERSION == 6000
tds_convert (tds_cnc->ctx,
col->column_type, val,
col->column_size, SYBCHAR,
|