Re: [sqlite] load extension -- unload hook?

2009-08-30 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

sub sk79 wrote:
> 1. Is it possible to register a callback which is invoked on database
close?

There is a hacky way of finding out when a particular db is closed.
Register a collation with an unused name (eg "_AX1") and provide an
xDestroy callback.  That callback will fire when the db closes.

> 2. or is there a plan to add something like: sqlite3_extension_end() which
> can be used for this?

You can register a function callable from SQL that directs your code to
discard any information/cache it has calculated.

> 3.  and if answer to 2 is yes, how about add an 'unload' command for
> extensions as well so that we can unload extensions when they are no more
> needed?

The only time SQLite is truly quiescent is when sqlite3_shutdown has
been called.  If you are calling that then you can clean up your own
stuff too.

If you are in an embedded environment then you have total control over
what is going on.  In a normal environment, allocated memory that isn't
being used will end up swapped out.

Roger
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqbOGAACgkQmOOfHg372QQugwCcDNXji1lqV7LlVsr90Ggr6ToH
GPcAnizoUXPc2B9OuL8bNhY7m/TgEvfg
=wXMn
-END PGP SIGNATURE-
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] ANN: SQLite 3.6.16.C#

2009-08-30 Thread Filip Navara
On Sat, Aug 29, 2009 at 9:51 PM, Yves
Goergen wrote:
> On 01.08.2009 16:19 CE(S)T, Noah Hart wrote:
>> This is not a driver, dll, or wrapper.  This is a port of the underlying
>> SQLite software.
>
> Hm, yes, but isn't the other C# SQLite assembly also the entire DB
> engine? I mean, there's no client/server driver; if you can access
> SQLite files, you already have the entire engine in your hands. And the
> other one doesn't need any additional files, it's just one .NET
> assembly. And a huge one. So I cannot imagine that it's just some
> bindings to a native DLL.

It's both bindings and the native code in one DLL. The SQLite code
there is not managed and is compiled only for single platform.

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


Re: [sqlite] BUG in SQLite? Still the rowid question

2009-08-30 Thread Wanadoo Hartwig

Am 30.08.2009 um 17:56 schrieb Kit:

> 2009/8/29 Wanadoo Hartwig :
>> The largest and last row id is 4. Why is SQLite returning 5? I think
>> it has to do with the FTS3 module but still the trigger statement
>> should shield the row ids from the trigger statement, or?
>> Hartwig
>
> CREATE TABLE Simple (ID integer primary key, Name text);
> CREATE TABLE SimpleFTS (Name);
> CREATE TRIGGER DeleteTrigger AFTER DELETE ON Simple FOR EACH ROW
>   BEGIN
>   DELETE FROM SimpleFTS WHERE (rowid=OLD.ID);
>   END;
> CREATE TRIGGER InsertTrigger AFTER INSERT ON Simple FOR EACH ROW
>   BEGIN
>   INSERT INTO SimpleFTS (rowid,Name) VALUES(NEW.ID,NEW.Name);
>   END;
> INSERT INTO Simple (Name) VALUES('one');
> INSERT INTO Simple (Name) VALUES('two');
> DELETE FROM Simple WHERE (ID = 1);
> INSERT INTO Simple (Name) VALUES('three');
> SELECT * FROM Simple;
> 2|two
> 3|three
> SELECT last_insert_rowid() FROM Simple;
> 3
> 3
>
> Perfect.
>

I know. Therefore, you have to use FTS3.

BTW: RTree seems to work.

> sqlite> CREATE VIRTUAL TABLE SimpleFTS USING FTS3 (Name);
> SQL error: no such module: FTS3
>
> What's FTS3? http://dotnetperls.com/sqlite-fts3 ?
>

FTS3 is the built-in full-text search engine. You have to compile  
SQLite with SQLITE_ENABLE_FTS3.

> Virtual tables are a new feature in SQLite (currently still only
> available from the development version on CVS)
> -- 
> Kit
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Hartwig


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


[sqlite] load extension -- unload hook?

2009-08-30 Thread sub sk79
Hi,

When we load an extension it invokes  sqlite3_extension_init(). Lets say, in
addition to creating functions, the loaded extension library also does some
internal data structure allocations,  initializations etc here.

Now, when the database is closed the loaded extension needs  to do cleanup.
To do that:
1. Is it possible to register a callback which is invoked on database close?
2. or is there a plan to add something like: sqlite3_extension_end() which
can be used for this?
3.  and if answer to 2 is yes, how about add an 'unload' command for
extensions as well so that we can unload extensions when they are no more
needed?

4. If none of the above functionality exists yet, is there a workaround
available today to achieve this?

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


Re: [sqlite] BUG in SQLite? Still the rowid question

2009-08-30 Thread Kit
2009/8/29 Wanadoo Hartwig :
> The largest and last row id is 4. Why is SQLite returning 5? I think
> it has to do with the FTS3 module but still the trigger statement
> should shield the row ids from the trigger statement, or?
> Hartwig

CREATE TABLE Simple (ID integer primary key, Name text);
CREATE TABLE SimpleFTS (Name);
CREATE TRIGGER DeleteTrigger AFTER DELETE ON Simple FOR EACH ROW
   BEGIN
   DELETE FROM SimpleFTS WHERE (rowid=OLD.ID);
   END;
CREATE TRIGGER InsertTrigger AFTER INSERT ON Simple FOR EACH ROW
   BEGIN
   INSERT INTO SimpleFTS (rowid,Name) VALUES(NEW.ID,NEW.Name);
   END;
INSERT INTO Simple (Name) VALUES('one');
INSERT INTO Simple (Name) VALUES('two');
DELETE FROM Simple WHERE (ID = 1);
INSERT INTO Simple (Name) VALUES('three');
SELECT * FROM Simple;
2|two
3|three
SELECT last_insert_rowid() FROM Simple;
3
3

Perfect.

sqlite> CREATE VIRTUAL TABLE SimpleFTS USING FTS3 (Name);
SQL error: no such module: FTS3

What's FTS3? http://dotnetperls.com/sqlite-fts3 ?

Virtual tables are a new feature in SQLite (currently still only
available from the development version on CVS)
-- 
Kit
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users