aboutsummaryrefslogtreecommitdiffstats
path: root/testing/csync2/01-csync2-sqlite3.patch
blob: 364dcca792cb8d7cae4352d128402da93c0b7308 (plain)
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
diff -ruN csync2-1.34.vanilla/action.c csync2-1.34/action.c
--- csync2-1.34.vanilla/action.c	2007-07-24 23:04:18.000000000 +0200
+++ csync2-1.34/action.c	2008-06-12 15:36:47.000000000 +0200
@@ -69,7 +69,7 @@
 			"SELECT filename from action WHERE command = '%s' "
 			"and logfile = '%s'", command, logfile)
 	{
-		textlist_add(&tl, SQL_V[0], 0);
+		textlist_add(&tl, SQL_V(0), 0);
 	} SQL_END;
 
 	mark = strstr(command_clr, "%%");
@@ -130,7 +130,7 @@
 	SQL_BEGIN("Checking for sceduled commands",
 			"SELECT command, logfile FROM action GROUP BY command, logfile")
 	{
-		textlist_add2(&tl, SQL_V[0], SQL_V[1], 0);
+		textlist_add2(&tl, SQL_V(0), SQL_V(1), 0);
 	} SQL_END;
 
 	for (t = tl; t != 0; t = t->next)
diff -ruN csync2-1.34.vanilla/check.c csync2-1.34/check.c
--- csync2-1.34.vanilla/check.c	2007-07-24 23:04:18.000000000 +0200
+++ csync2-1.34/check.c	2008-06-12 15:36:47.000000000 +0200
@@ -159,7 +159,7 @@
 			"SELECT filename from file where "
 			"filename = '%s' %s ORDER BY filename", url_encode(file), where_rec)
 	{
-		const char *filename = url_decode(SQL_V[0]);
+		const char *filename = url_decode(SQL_V(0));
 		if ( lstat_strict(prefixsubst(filename), &st) != 0 || csync_check_pure(filename) )
 			textlist_add(&tl, filename, 0);
 	} SQL_END;
@@ -213,8 +213,9 @@
 
 	if ( check_type>0 && lstat_strict(prefixsubst(file), &st) != 0 ) {
 		if ( ignnoent ) return 0;
+		perror("blup");
 		csync_fatal("This should not happen: "
-				"Can't stat %s.\n", file);
+				"Can't stat %s %s %d %d %d.\n", prefixsubst(file), file,stat(file,&st),lstat_strict(file,&st),errno);
 	}
 
 	switch ( check_type )
@@ -231,7 +232,7 @@
 			"filename = '%s'", url_encode(file))
 		{
 			if ( !csync_cmpchecktxt(checktxt,
-						url_decode(SQL_V[0])) ) {
+						url_decode(SQL_V(0))) ) {
 				csync_debug(2, "File has changed: %s\n", file);
 				this_is_dirty = 1;
 			}
diff -ruN csync2-1.34.vanilla/config.h.in csync2-1.34/config.h.in
--- csync2-1.34.vanilla/config.h.in	2007-07-24 23:04:24.000000000 +0200
+++ csync2-1.34/config.h.in	2008-06-12 15:36:47.000000000 +0200
@@ -6,8 +6,8 @@
 /* Define to 1 if you have the `rsync' library (-lrsync). */
 #undef HAVE_LIBRSYNC
 
-/* Define to 1 if you have the `sqlite' library (-lsqlite). */
-#undef HAVE_LIBSQLITE
+/* Define to 1 if you have the `sqlite3' library (-lsqlite3). */
+#undef HAVE_LIBSQLITE3
 
 /* Name of package */
 #undef PACKAGE
diff -ruN csync2-1.34.vanilla/configure csync2-1.34/configure
--- csync2-1.34.vanilla/configure	2007-07-24 23:04:25.000000000 +0200
+++ csync2-1.34/configure	2008-06-12 15:36:47.000000000 +0200
@@ -3671,13 +3671,13 @@
 
 else
 
-{ echo "$as_me:$LINENO: checking for sqlite_exec in -lsqlite" >&5
-echo $ECHO_N "checking for sqlite_exec in -lsqlite... $ECHO_C" >&6; }
-if test "${ac_cv_lib_sqlite_sqlite_exec+set}" = set; then
+{ echo "$as_me:$LINENO: checking for sqlite3_exec in -lsqlite3" >&5
+echo $ECHO_N "checking for sqlite3_exec in -lsqlite3... $ECHO_C" >&6; }
+if test "${ac_cv_lib_sqlite3_sqlite3_exec+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsqlite  $LIBS"
+LIBS="-lsqlite3  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -3691,11 +3691,11 @@
 #ifdef __cplusplus
 extern "C"
 #endif
-char sqlite_exec ();
+char sqlite3_exec ();
 int
 main ()
 {
-return sqlite_exec ();
+return sqlite3_exec ();
   ;
   return 0;
 }
@@ -3718,30 +3718,30 @@
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_sqlite_sqlite_exec=yes
+  ac_cv_lib_sqlite3_sqlite3_exec=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_lib_sqlite_sqlite_exec=no
+	ac_cv_lib_sqlite3_sqlite3_exec=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite_sqlite_exec" >&5
-echo "${ECHO_T}$ac_cv_lib_sqlite_sqlite_exec" >&6; }
-if test $ac_cv_lib_sqlite_sqlite_exec = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_exec" >&5
+echo "${ECHO_T}$ac_cv_lib_sqlite3_sqlite3_exec" >&6; }
+if test $ac_cv_lib_sqlite3_sqlite3_exec = yes; then
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBSQLITE 1
+#define HAVE_LIBSQLITE3 1
 _ACEOF
 
-  LIBS="-lsqlite $LIBS"
+  LIBS="-lsqlite3 $LIBS"
 
 else
-  { { echo "$as_me:$LINENO: error: libsqlite is required" >&5
-echo "$as_me: error: libsqlite is required" >&2;}
+  { { echo "$as_me:$LINENO: error: libsqlite3 is required" >&5
+echo "$as_me: error: libsqlite3 is required" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
diff -ruN csync2-1.34.vanilla/configure.ac csync2-1.34/configure.ac
--- csync2-1.34.vanilla/configure.ac	2007-07-24 23:04:19.000000000 +0200
+++ csync2-1.34/configure.ac	2008-06-12 15:36:47.000000000 +0200
@@ -47,7 +47,7 @@
 	AS_HELP_STRING([--with-libsqlite-source=source-tar-file],
 		[build this libsqlite and link statically against it (hack! hack!)]),
 	AC_SUBST([libsqlite_source_file], $withval),
-	AC_CHECK_LIB([sqlite], [sqlite_exec], , [AC_MSG_ERROR(libsqlite is required)])
+	AC_CHECK_LIB([sqlite3], [sqlite3_exec], , [AC_MSG_ERROR(libsqlite3 is required)])
 )
 AM_CONDITIONAL([PRIVATE_LIBSQLITE], [test -n "$libsqlite_source_file"])
 
diff -ruN csync2-1.34.vanilla/conn.c csync2-1.34/conn.c
--- csync2-1.34.vanilla/conn.c	2007-07-24 23:04:18.000000000 +0200
+++ csync2-1.34/conn.c	2008-06-12 15:36:47.000000000 +0200
@@ -181,7 +181,7 @@
 			"SELECT certdata FROM x509_cert WHERE peername = '%s'",
 			url_encode(peername))
 		{
-			if (!strcmp(SQL_V[0], certdata))
+			if (!strcmp(SQL_V(0), certdata))
 				cert_is_ok = 1;
 			else
 				cert_is_ok = 0;
diff -ruN csync2-1.34.vanilla/csync2.c csync2-1.34/csync2.c
--- csync2-1.34.vanilla/csync2.c	2007-07-24 23:04:18.000000000 +0200
+++ csync2-1.34/csync2.c	2008-06-12 15:36:47.000000000 +0200
@@ -582,8 +582,8 @@
 				SQL_BEGIN("Check all hints",
 					"SELECT filename, recursive FROM hint")
 				{
-					textlist_add(&tl, url_decode(SQL_V[0]),
-							atoi(SQL_V[1]));
+					textlist_add(&tl, url_decode(SQL_V(0)),
+							atoi(SQL_V(1)));
 				} SQL_END;
 
 				for (t = tl; t != 0; t = t->next) {
@@ -659,7 +659,7 @@
 						"SELECT filename FROM file WHERE filename = '%s' %s",
 						url_encode(realname), where_rec)
 					{
-						char *filename = strdup(url_encode(SQL_V[0]));
+						char *filename = strdup(url_encode(SQL_V(0)));
 						csync_mark(filename, 0, 0);
 						free(filename);
 					} SQL_END;
@@ -695,7 +695,7 @@
 			SQL_BEGIN("DB Dump - Hint",
 				"SELECT recursive, filename FROM hint ORDER BY filename")
 			{
-				printf("%s\t%s\n", SQL_V[0], url_decode(SQL_V[1]));
+				printf("%s\t%s\n", SQL_V(0), url_decode(SQL_V(1)));
 				retval = -1;
 			} SQL_END;
 			break;
@@ -705,8 +705,8 @@
 			SQL_BEGIN("DB Dump - File",
 				"SELECT checktxt, filename FROM file ORDER BY filename")
 			{
-				if (csync_find_next(0, url_decode(SQL_V[1]))) {
-					printf("%s\t%s\n", url_decode(SQL_V[0]), url_decode(SQL_V[1]));
+				if (csync_find_next(0, url_decode(SQL_V(1)))) {
+					printf("%s\t%s\n", url_decode(SQL_V(0)), url_decode(SQL_V(1)));
 					retval = -1;
 				}
 			} SQL_END;
@@ -717,8 +717,8 @@
 			SQL_BEGIN("DB Dump - File",
 				"SELECT checktxt, filename FROM file ORDER BY filename")
 			{
-				if ( csync_match_file_host(url_decode(SQL_V[1]), argv[optind], argv[optind+1], 0) ) {
-					printf("%s\t%s\n", url_decode(SQL_V[0]), url_decode(SQL_V[1]));
+				if ( csync_match_file_host(url_decode(SQL_V(1)), argv[optind], argv[optind+1], 0) ) {
+					printf("%s\t%s\n", url_decode(SQL_V(0)), url_decode(SQL_V(1)));
 					retval = -1;
 				}
 			} SQL_END;
@@ -769,9 +769,9 @@
 			SQL_BEGIN("DB Dump - Dirty",
 				"SELECT force, myname, peername, filename FROM dirty ORDER BY filename")
 			{
-				if (csync_find_next(0, url_decode(SQL_V[3]))) {
-					printf("%s\t%s\t%s\t%s\n", atoi(SQL_V[0]) ?  "force" : "chary",
-						url_decode(SQL_V[1]), url_decode(SQL_V[2]), url_decode(SQL_V[3]));
+				if (csync_find_next(0, url_decode(SQL_V(3)))) {
+					printf("%s\t%s\t%s\t%s\n", atoi(SQL_V(0)) ?  "force" : "chary",
+						url_decode(SQL_V(1)), url_decode(SQL_V(2)), url_decode(SQL_V(3)));
 					retval = -1;
 				}
 			} SQL_END;
diff -ruN csync2-1.34.vanilla/csync2.h csync2-1.34/csync2.h
--- csync2-1.34.vanilla/csync2.h	2007-07-24 23:04:18.000000000 +0200
+++ csync2-1.34/csync2.h	2008-06-12 15:36:47.000000000 +0200
@@ -22,6 +22,7 @@
 #define CSYNC2_H 1
 
 #define _GNU_SOURCE
+#define _FILE_OFFSET_BITS 64
 
 #include "config.h"
 #include <stdio.h>
@@ -91,19 +92,24 @@
 extern int csync_db_next(void *vmx, const char *err,
 		int *pN, const char ***pazValue, const char ***pazColName);
 extern void csync_db_fin(void *vmx, const char *err);
+extern void * csync_db_colblob(void *stmtx,int col);
+
 
 #define SQL(e, s, ...) csync_db_sql(e, s, ##__VA_ARGS__)
 
+#define SQL_V(col) \
+	(csync_db_colblob(SQL_VM,col))
+
 #define SQL_BEGIN(e, s, ...) \
 { \
 	char *SQL_ERR = e; \
 	void *SQL_VM = csync_db_begin(SQL_ERR, s, ##__VA_ARGS__); \
 	int SQL_COUNT = 0; \
 	while (1) { \
-		const char **SQL_V, **SQL_N; \
+		const char **notSQL_V, **notSQL_N; \
 		int SQL_C; \
 		if ( !csync_db_next(SQL_VM, SQL_ERR, \
-					&SQL_C, &SQL_V, &SQL_N) ) break; \
+					&SQL_C, &notSQL_V, &notSQL_N) ) break; \
 		SQL_COUNT++;
 
 #define SQL_FIN }{
diff -ruN csync2-1.34.vanilla/daemon.c csync2-1.34/daemon.c
--- csync2-1.34.vanilla/daemon.c	2007-07-24 23:04:18.000000000 +0200
+++ csync2-1.34/daemon.c	2008-06-12 15:36:47.000000000 +0200
@@ -443,8 +443,8 @@
 					strcmp(tag[2], "-") ? url_encode(tag[2]) : "",
 					strcmp(tag[2], "-") ? "'" : "")
 			{
-				if ( csync_match_file_host(url_decode(SQL_V[1]), tag[1], peer, (const char **)&tag[3]) )
-					conn_printf("%s\t%s\n", SQL_V[0], SQL_V[1]);
+				if ( csync_match_file_host(url_decode(SQL_V(1)), tag[1], peer, (const char **)&tag[3]) )
+					conn_printf("%s\t%s\n", SQL_V(0), SQL_V(1));
 			} SQL_END;
 			break;
 
diff -ruN csync2-1.34.vanilla/db.c csync2-1.34/db.c
--- csync2-1.34.vanilla/db.c	2007-07-24 23:04:18.000000000 +0200
+++ csync2-1.34/db.c	2008-06-12 15:36:47.000000000 +0200
@@ -19,7 +19,7 @@
  */
 
 #include "csync2.h"
-#include <sqlite.h>
+#include <sqlite3.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -33,7 +33,7 @@
 int db_blocking_mode = 1;
 int db_sync_mode = 1;
 
-static sqlite *db = 0;
+static sqlite3 *db = 0;
 
 static int get_dblock_timeout()
 {
@@ -128,44 +128,46 @@
 
 void csync_db_open(const char *file)
 {
-	db = sqlite_open(file, 0, 0);
-	if ( db == 0 )
-		csync_fatal("Can't open database: %s\n", file);
+	int r;
+	//db = sqlite_open(file, 0, 0);
+	r=sqlite3_open(file, &db);
+	if ( db == 0 || r)
+		csync_fatal("Can't open database: %s, result %d\n", file,r);
 
 	/* ignore errors on table creation */
 	in_sql_query++;
-	sqlite_exec(db,
+	sqlite3_exec(db,
 		"CREATE TABLE file ("
 		"	filename, checktxt,"
 		"	UNIQUE ( filename ) ON CONFLICT REPLACE"
 		")",
 		0, 0, 0);
-	sqlite_exec(db,
+	sqlite3_exec(db,
 		"CREATE TABLE dirty ("
 		"	filename, force, myname, peername,"
 		"	UNIQUE ( filename, peername ) ON CONFLICT IGNORE"
 		")",
 		0, 0, 0);
-	sqlite_exec(db,
+	sqlite3_exec(db,
 		"CREATE TABLE hint ("
 		"	filename, recursive,"
 		"	UNIQUE ( filename, recursive ) ON CONFLICT IGNORE"
 		")",
 		0, 0, 0);
-	sqlite_exec(db,
+	sqlite3_exec(db,
 		"CREATE TABLE action ("
 		"	filename, command, logfile,"
 		"	UNIQUE ( filename, command ) ON CONFLICT IGNORE"
 		")",
 		0, 0, 0);
-	sqlite_exec(db,
+	sqlite3_exec(db,
 		"CREATE TABLE x509_cert ("
 		"	peername, certdata,"
 		"	UNIQUE ( peername ) ON CONFLICT IGNORE"
 		")",
 		0, 0, 0);
 	if (!db_sync_mode)
-		sqlite_exec(db, "PRAGMA synchronous = OFF", 0, 0, 0);
+		sqlite3_exec(db, "PRAGMA synchronous = OFF", 0, 0, 0);
 	in_sql_query--;
 }
 
@@ -178,7 +180,7 @@
 		SQL("COMMIT TRANSACTION", "COMMIT TRANSACTION");
 		tqueries_counter = -10;
 	}
-	sqlite_close(db);
+	sqlite3_close(db);
 	begin_commit_recursion--;
 	db = 0;
 }
@@ -199,7 +201,7 @@
 	csync_debug(2, "SQL: %s\n", sql);
 
 	while (1) {
-		rc = sqlite_exec(db, sql, 0, 0, 0);
+		rc = sqlite3_exec(db, sql, 0, 0, 0);
 		if ( rc != SQLITE_BUSY ) break;
 		if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
 		csync_debug(2, "Database is busy, sleeping a sec.\n");
@@ -216,7 +218,8 @@
 
 void* csync_db_begin(const char *err, const char *fmt, ...)
 {
-	sqlite_vm *vm;
+	//sqlite_vm *vm;
+	sqlite3_stmt *stmt;
 	char *sql;
 	va_list ap;
 	int rc, busyc = 0;
@@ -231,7 +234,7 @@
 	csync_debug(2, "SQL: %s\n", sql);
 
 	while (1) {
-		rc = sqlite_compile(db, sql, 0, &vm, 0);
+		rc = sqlite3_prepare(db, sql, 0, &stmt, 0);
 		if ( rc != SQLITE_BUSY ) break;
 		if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
 		csync_debug(2, "Database is busy, sleeping a sec.\n");
@@ -242,19 +245,21 @@
 		csync_fatal("Database Error: %s [%d]: %s\n", err, rc, sql);
 	free(sql);
 
-	return vm;
+	return stmt;
 }
 
-int csync_db_next(void *vmx, const char *err,
+int csync_db_next(void *stmtx, const char *err,
 		int *pN, const char ***pazValue, const char ***pazColName)
 {
-	sqlite_vm *vm = vmx;
+	//sqlite_vm *vm = vmx;
+	sqlite3_stmt *stmt = stmtx;
 	int rc, busyc = 0;
 
 	csync_debug(4, "Trying to fetch a row from the database.\n");
 
 	while (1) {
-		rc = sqlite_step(vm, pN, pazValue, pazColName);
+		//rc = sqlite_step(vm, pN, pazValue, pazColName);
+		rc = sqlite3_step(stmt);
 		if ( rc != SQLITE_BUSY ) break;
 		if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
 		csync_debug(2, "Database is busy, sleeping a sec.\n");
@@ -267,16 +272,21 @@
 
 	return rc == SQLITE_ROW;
 }
+void * csync_db_colblob(void *stmtx,int col) {
+	sqlite3_stmt *stmt = stmtx;
+	return sqlite3_column_blob(stmt,col);
+}
 
-void csync_db_fin(void *vmx, const char *err)
+void csync_db_fin(void *stmtx, const char *err)
 {
-	sqlite_vm *vm = vmx;
+	//sqlite_vm *vm = vmx;
+	sqlite3_stmt *stmt=stmtx;
 	int rc, busyc = 0;
 
 	csync_debug(2, "SQL Query finished.\n");
 
 	while (1) {
-		rc = sqlite_finalize(vm, 0);
+		rc = sqlite3_finalize(stmt);
 		if ( rc != SQLITE_BUSY ) break;
 		if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
 		csync_debug(2, "Database is busy, sleeping a sec.\n");
--- src/csync2-1.34/update.c
+++ new/update.c
@@ -545,12 +545,12 @@
 		"SELECT filename, myname, force FROM dirty WHERE peername = '%s' "
 		"ORDER by filename ASC", url_encode(peername))
 	{
-		const char *filename = url_decode(SQL_V[0]);
+		const char *filename = url_decode(SQL_V(0));
 		int i, use_this = patnum == 0;
 		for (i=0; i<patnum && !use_this; i++)
 			if ( compare_files(filename, patlist[i], recursive) ) use_this = 1;
 		if (use_this)
-			textlist_add2(&tl, filename, url_decode(SQL_V[1]), atoi(SQL_V[2]));
+			textlist_add2(&tl, filename, url_decode(SQL_V(1)), atoi(SQL_V(2)));
 	} SQL_END;
 
 	/* just return if there are no files to update */
@@ -626,7 +626,7 @@
 	SQL_BEGIN("Get hosts from dirty table",
 		"SELECT peername FROM dirty GROUP BY peername ORDER BY random()")
 	{
-		textlist_add(&tl, url_decode(SQL_V[0]), 0);
+		textlist_add(&tl, url_decode(SQL_V(0)), 0);
 	} SQL_END;
 
 	for (t = tl; t != 0; t = t->next) {
@@ -798,7 +798,7 @@
 			filename ? url_encode(filename) : "",
 			filename ? "'" : "")
 	{
-		char *l_file = strdup(url_decode(SQL_V[1])), *l_checktxt = strdup(url_decode(SQL_V[0]));
+		char *l_file = strdup(url_decode(SQL_V(1))), *l_checktxt = strdup(url_decode(SQL_V(0)));
 		if ( csync_match_file_host(l_file, myname, peername, 0) ) {
 			if ( remote_eof ) {
 got_remote_eof:
@@ -936,17 +936,17 @@
 		const struct csync_group *g = 0;
 		const struct csync_group_host *h;
 
-		const char *filename = url_decode(SQL_V[0]); 
+		const char *filename = url_decode(SQL_V(0)); 
 
 		while ((g=csync_find_next(g, filename)) != 0) {
-			if (!strcmp(g->myname, SQL_V[1]))
+			if (!strcmp(g->myname, SQL_V(1)))
 				for (h = g->host; h; h = h->next) {
-					if (!strcmp(h->hostname, SQL_V[2]))
+					if (!strcmp(h->hostname, SQL_V(2)))
 						goto this_dirty_record_is_ok;
 				}
 		}
 
-		textlist_add2(&tl, SQL_V[0], SQL_V[2], 0);
+		textlist_add2(&tl, SQL_V(0), SQL_V(2), 0);
 
 this_dirty_record_is_ok:
 		;
@@ -962,8 +962,8 @@
 	SQL_BEGIN("Query file DB",
 	          "SELECT filename FROM file")
 	{
-		if (!csync_find_next(0, url_decode(SQL_V[0])))
-			textlist_add(&tl, SQL_V[0], 0);
+		if (!csync_find_next(0, url_decode(SQL_V(0))))
+			textlist_add(&tl, SQL_V(0), 0);
 	} SQL_END;
 	for (t = tl; t != 0; t = t->next) {
 		csync_debug(1, "Removing %s from file db.\n", t->value);