Wednesday 11 of November 2009 19:03:09 Roger Binns napisaƂ(a):
> Can you do this a unified diff please?
>
> In any case it looks like you are trying to manipulate the database pointer
> while a query is running.
>
> Roger

That was my first suspicion that there is some memmove with cursor object or so.
This would mean that sqlite* or maybe other sensitive pointers can not be 
members of cursor object, what is wrong for me.
In order to return correct results of query on my virtual table I must collect 
data from external databases, and I know their file names only in xFilter() 
function  (they are derived from query constaraints).
That is why it is covenient and natural to store connection objects inside 
cursor.

Thanks
GW

Here is requested unified diff:

==================
--- sqlite-3.6.20-ORIGINAL/src/test8.c     2009-10-27 19:07:06.000000000 +0100
+++ sqlite-3.6.20-BUG/src/test8.c        2009-11-09 19:20:19.000000000 +0100
@@ -90,6 +90,7 @@
 struct echo_cursor {
   sqlite3_vtab_cursor base;
   sqlite3_stmt *pStmt;
+  sqlite3      *pDb;            /* Database connection */
 };

 static int simulateVtabError(echo_vtab *p, const char *zMethod){
@@ -568,6 +569,9 @@
   echo_cursor *pCur = (echo_cursor *)cur;
   sqlite3_stmt *pStmt = pCur->pStmt;
   pCur->pStmt = 0;
+  if (pCur->pDb)
+    sqlite3_close(pCur->pDb);
+  pCur->pDb = 0;
   sqlite3_free(pCur);
   rc = sqlite3_finalize(pStmt);
   return rc;
@@ -670,7 +674,10 @@

   echo_cursor *pCur = (echo_cursor *)pVtabCursor;
   echo_vtab *pVtab = (echo_vtab *)pVtabCursor->pVtab;
-  sqlite3 *db = pVtab->db;
+  if (pCur->pDb)
+    sqlite3_close(pCur->pDb);
+  sqlite3_open("/tmp/test.db", &pCur->pDb);
+  sqlite3 *db = pCur->pDb;

   if( simulateVtabError(pVtab, "xFilter") ){
     return SQLITE_ERROR;

=============
--- sqlite-3.6.20--ORIGINAL/test/vtab1.test  2009-10-30 14:34:59.000000000 +0100
+++  sqlite-3.6.20--BUG/test/vtab1.test  2009-11-03 21:22:16.000000000 +0100
@@ -330,6 +330,11 @@
 # Test that a SELECT on t1 doesn't crash. No rows are returned
 # because the underlying real table is currently empty.
 #
+file delete -force "/tmp/test.db"
+file delete -force "/tmp/test.db-journal"
+sqlite3 dbTest "/tmp/test.db"
+dbTest eval {CREATE TABLE IF NOT EXISTS treal(a INTEGER, b INTEGER, c)}
+dbTest eval {CREATE INDEX IF NOT EXISTS treal_idx ON treal(b)}
 do_test vtab1-3.2 {
   execsql {
     SELECT a, b, c FROM t1;
@@ -339,6 +344,9 @@
 # Put some data into the table treal. Then try a few simple SELECT
 # statements on t1.
 #
+dbTest eval {INSERT INTO treal VALUES(1, 2, 3)}
+dbTest eval {INSERT INTO treal VALUES(4, 5, 6)}
+dbTest close
 do_test vtab1-3.3 {
   execsql {
     INSERT INTO treal VALUES(1, 2, 3);
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to