Re: [sqlite] How often is xDisconnect called? (Was: Suggestion for syntax enhancement for virtual tables)

2015-01-05 Thread Dan Kennedy

On 01/06/2015 11:59 AM, Peter Aronson wrote:
It's this comment that makes me worry that xDisconnect can be called 
at other times than detach or close:


** When an in-memory Table object is deleted (for example when the
** schema is being reloaded for some reason), the VTable objects are not
** deleted and the sqlite3_vtab* handles are not xDisconnect()ed
** immediately. Instead, they are moved from the Table.pVTable list to
** another linked list headed by the sqlite3.pDisconnect member of the
** corresponding sqlite3 structure. They are then deleted/xDisconnected
** next time a statement is prepared using said sqlite3*. This is done
** to avoid deadlock issues involving multiple sqlite3.mutex mutexes.

I'm not sure exactly what this means, but it implies that xDisconnect 
can be called in the middle of a session.


It can. One scenario is if you ROLLBACK a transaction that includes 
schema modifications to the temp database. i.e. executing:


  BEGIN;
CREATE TEMP TABLE t2(x);
  ROLLBACK;

will cause the xDisconnect() method of all virtual tables in the temp 
database to be invoked. New sqlite3_vtab objects will be requested via 
xConnect() the next time the virtual table is accessed.


Dan.






Peter

On 1/2/2015 3:00 PM, Peter Aronson wrote:
If only the xDisconnect method is called on a virtual table create in 
the temp database at disconnect time, is that the only time 
xDisconnect will be called?  The documentation at sqlite.org doesn't 
seem to say.  Jay Krebich's Using SQLite says xDisconnect is "Called 
when a database containing a virtual table instance is detached or 
closed. Called once for each table instance."  But looking at the 
SQLite code and comments, I'm not sure this is true.  Is it?  If so, 
it would be easy enough when writing a Virtual Table Module to note 
that it is being created in the temp database, and do any required 
cleanup in xDisconnect instead of xDestroy for that instance.  But if 
xDisconnect can be called at other times, cleanup could be premature.


Best,

Peter


On Friday, January 2, 2015 12:56 AM, Dan Kennedy 
 wrote:




On 01/02/2015 01:58 PM, Hick Gunter wrote:
Temporary virtual tables sounds like an interesting concept. Does 
the xDestroy() function get called on such a beast (as opposed to 
xDisconnect() when the connection is closed)?

Just xDisconnect().

Dan.



   Should that function delete the backing store (even if a 
non-temporary virtual table is still connected)?


-Ursprüngliche Nachricht-
Von: Baruch Burstein [mailto:bmburst...@gmail.com]
Gesendet: Donnerstag, 01. Jänner 2015 08:38
An: General Discussion of SQLite Database
Betreff: [sqlite] Suggestion for syntax enhancement for virtual tables

For creating temporary virtual tables, currently you need to do:

CREATE VIRTUAL TABLE temp.t ...

Can this syntax be made to work too (similar to creating regular 
tables)?


CREATE VIRTUAL TEMP TABLE t ...
or
CREATE TEMP VIRTUAL TABLE t ...

--
˙uʍop-ǝpısdn sı ɹoʇıuoɯ ɹnoʎ 'sıɥʇ pɐǝɹ uɐɔ noʎ ɟı 
___

sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users




___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] How often is xDisconnect called? (Was: Suggestion for syntax enhancement for virtual tables)

2015-01-05 Thread Peter Aronson
It's this comment that makes me worry that xDisconnect can be called at 
other times than detach or close:


** When an in-memory Table object is deleted (for example when the
** schema is being reloaded for some reason), the VTable objects are not
** deleted and the sqlite3_vtab* handles are not xDisconnect()ed
** immediately. Instead, they are moved from the Table.pVTable list to
** another linked list headed by the sqlite3.pDisconnect member of the
** corresponding sqlite3 structure. They are then deleted/xDisconnected
** next time a statement is prepared using said sqlite3*. This is done
** to avoid deadlock issues involving multiple sqlite3.mutex mutexes.

I'm not sure exactly what this means, but it implies that xDisconnect 
can be called in the middle of a session.


Peter

On 1/2/2015 3:00 PM, Peter Aronson wrote:

If only the xDisconnect method is called on a virtual table create in the temp database 
at disconnect time, is that the only time xDisconnect will be called?  The documentation 
at sqlite.org doesn't seem to say.  Jay Krebich's Using SQLite says xDisconnect is 
"Called when a database containing a virtual table instance is detached or closed.  
Called once for each table instance."  But looking at the SQLite code and comments, 
I'm not sure this is true.  Is it?  If so, it would be easy enough when writing a Virtual 
Table Module to note that it is being created in the temp database, and do any required 
cleanup in xDisconnect instead of xDestroy for that instance.  But if xDisconnect can be 
called at other times, cleanup could be premature.

Best,

Peter


On Friday, January 2, 2015 12:56 AM, Dan Kennedy  wrote:
  



On 01/02/2015 01:58 PM, Hick Gunter wrote:

Temporary virtual tables sounds like an interesting concept. Does the 
xDestroy() function get called on such a beast (as opposed to xDisconnect() 
when the connection is closed)?

Just xDisconnect().

Dan.




   Should that function delete the backing store (even if a non-temporary 
virtual table is still connected)?

-Ursprüngliche Nachricht-
Von: Baruch Burstein [mailto:bmburst...@gmail.com]
Gesendet: Donnerstag, 01. Jänner 2015 08:38
An: General Discussion of SQLite Database
Betreff: [sqlite] Suggestion for syntax enhancement for virtual tables

For creating temporary virtual tables, currently you need to do:

CREATE VIRTUAL TABLE temp.t ...

Can this syntax be made to work too (similar to creating regular tables)?

CREATE VIRTUAL TEMP TABLE t ...
or
CREATE TEMP VIRTUAL TABLE t ...

--
˙uʍop-ǝpısdn sı ɹoʇıuoɯ ɹnoʎ 'sıɥʇ pɐǝɹ uɐɔ noʎ ɟı 
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users




___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users