This function is already available in the sqlite3 C interface.

It would be quite easy to implement a virtual table prepared_statements ( db 
int hidden, stmt int, sql text) to allow "select * from prepared_statements 
where db = ?" and bind your db handle.

xBestIndex would need to check for constraint "db" presence

xFilter would call sqlite3_next_stmt with P2 = NULL to retrieve the first 
prepared statement

xNext would call sqlite3_next_stmt with P2 = last retrieved statement

xColumn would call sqlite3_sql on the last retrieved statement to return the 
SQL if stored by a prepare_v2

If no parameter db is specified, the table would return no rows, as there is 
currently no method that I know of available to find all connections.


-----Ursprüngliche Nachricht-----
Von: Simon Slavin [mailto:slav...@bigfraud.org]
Gesendet: Donnerstag, 03. Juli 2014 09:36
An: General Discussion of SQLite Database
Betreff: Re: [sqlite] Problem with many connections


On 3 Jul 2014, at 8:24am, Hick Gunter <h...@scigames.at> wrote:

> How about this?
>
>
> sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
>
> This interface returns a pointer to the next prepared statement after pStmt 
> associated with the database connection pDb. If pStmt is NULL then this 
> interface returns a pointer to the first prepared statement associated with 
> the database connection pDb. If no prepared statement satisfies the 
> conditions of this routine, it returns NULL.
>
> The database connection pointer D in a call to sqlite3_next_stmt(D,S) must 
> refer to an open database connection and in particular must not be a NULL 
> pointer.

I don't know how practical that would be to implement, but it looks good to me. 
 If I understand your design properly some users would pass NULL and see if 
they got NULL back.  Others would iterate down the list.

Simon.

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


-----------------------------------------------------------------------
Gunter Hick
Software Engineer

Scientific Games International GmbH
Klitschgasse 2 – 4, A - 1130 Vienna,
Austria
FN 157284 a, HG Wien
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This e-mail is confidential and may well also be legally privileged. If you 
have received it in error, you are on notice as to its status and accordingly 
please notify us immediately by reply e-mail and then
delete this message from your system. Please do not copy it or use it for any 
purposes, or disclose its contents to any person as to do so could be a breach 
of confidence. Thank you for your cooperation.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to