Index: camel/camel-db.c
===================================================================
--- camel/camel-db.c	(revision 10193)
+++ camel/camel-db.c	(working copy)
@@ -152,11 +152,6 @@ def_subclassed (xTruncate, (sqlite3_file
 def_subclassed (xFileSize, (sqlite3_file *pFile, sqlite3_int64 *pSize), (cFile->old_vfs_file, pSize))
 def_subclassed (xLock, (sqlite3_file *pFile, int lockType), (cFile->old_vfs_file, lockType))
 def_subclassed (xUnlock, (sqlite3_file *pFile, int lockType), (cFile->old_vfs_file, lockType))
-#if SQLITE_VERSION_NUMBER < 3006000
-def_subclassed (xCheckReservedLock, (sqlite3_file *pFile), (cFile->old_vfs_file))
-#else
-def_subclassed (xCheckReservedLock, (sqlite3_file *pFile, int *pResOut), (cFile->old_vfs_file, pResOut))
-#endif
 def_subclassed (xFileControl, (sqlite3_file *pFile, int op, void *pArg), (cFile->old_vfs_file, op, pArg))
 def_subclassed (xSectorSize, (sqlite3_file *pFile), (cFile->old_vfs_file))
 def_subclassed (xDeviceCharacteristics, (sqlite3_file *pFile), (cFile->old_vfs_file))
@@ -164,6 +159,24 @@ def_subclassed (xDeviceCharacteristics, 
 #undef def_subclassed
 
 static int
+camel_sqlite3_file_xCheckReservedLock (sqlite3_file *pFile, int *pResOut)
+{
+	CamelSqlite3File *cFile;
+
+	g_return_val_if_fail (old_vfs != NULL, SQLITE_ERROR);
+	g_return_val_if_fail (pFile != NULL, SQLITE_ERROR);
+
+	cFile = (CamelSqlite3File *) pFile;
+	g_return_val_if_fail (cFile->old_vfs_file->pMethods != NULL, SQLITE_ERROR);
+
+	/* check version in runtime */
+	if (sqlite3_libversion_number () < 3006000)
+		return ((int (*)(sqlite3_file *)) (cFile->old_vfs_file->pMethods->xCheckReservedLock)) (cFile->old_vfs_file);
+	else
+		return ((int (*)(sqlite3_file *, int *)) (cFile->old_vfs_file->pMethods->xCheckReservedLock)) (cFile->old_vfs_file, pResOut);
+}
+
+static int
 camel_sqlite3_file_xClose (sqlite3_file *pFile)
 {
 	CamelSqlite3File *cFile;
@@ -277,6 +290,13 @@ camel_sqlite3_vfs_xOpen (sqlite3_vfs *pV
 		/* initialize our subclass function only once */
 		io_methods.iVersion = cFile->old_vfs_file->pMethods->iVersion;
 
+		/* check version in compile time */
+		#if SQLITE_VERSION_NUMBER < 3006000
+		io_methods.xCheckReservedLock = (int (*)(sqlite3_file *)) camel_sqlite3_file_xCheckReservedLock;
+		#else
+		io_methods.xCheckReservedLock = camel_sqlite3_file_xCheckReservedLock;
+		#endif
+
 		#define use_subclassed(x) io_methods.x = camel_sqlite3_file_ ## x
 		use_subclassed (xClose);
 		use_subclassed (xRead);
@@ -286,7 +306,6 @@ camel_sqlite3_vfs_xOpen (sqlite3_vfs *pV
 		use_subclassed (xFileSize);
 		use_subclassed (xLock);
 		use_subclassed (xUnlock);
-		use_subclassed (xCheckReservedLock);
 		use_subclassed (xFileControl);
 		use_subclassed (xSectorSize);
 		use_subclassed (xDeviceCharacteristics);
Index: camel/ChangeLog
===================================================================
--- camel/ChangeLog	(revision 10193)
+++ camel/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2009-03-30  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #575084
+
+	* camel-db.c: (camel_sqlite3_file_xCheckReservedLock),
+	(camel_sqlite3_vfs_xOpen): Check for actual SQLite3 version in runtime
+	to call xCheckReservedLock with correct number parameters as expected
+	by the actual SQLite3 version it is running, not was compiled.
+
 2009-03-27  Milan Crha  <mcrha@redhat.com>
 
 	** Fix for bug #569700
