Find stmt that's stopping a DB from closing

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Find stmt that's stopping a DB from closing

curmudgeon
I’m sure the team added a fct that listed the offenders but I can’t find it in the documentation. I would’ve thought it would have been mentioned on the sqlite3_close page but no sign of it. Am I imagining things?



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Find stmt that's stopping a DB from closing

David Raymond
I think you're referring to "The SQLITE_STMT Virtual Table":
https://www.sqlite.org/stmt.html


-----Original Message-----
From: sqlite-users <[hidden email]> On Behalf Of x
Sent: Tuesday, November 5, 2019 2:27 PM
To: [hidden email]
Subject: [sqlite] Find stmt that's stopping a DB from closing

I’m sure the team added a fct that listed the offenders but I can’t find it in the documentation. I would’ve thought it would have been mentioned on the sqlite3_close page but no sign of it. Am I imagining things?



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Find stmt that's stopping a DB from closing

curmudgeon
>I think you're referring to "The SQLITE_STMT Virtual Table":
https://www.sqlite.org/stmt.html

That’s it David. Thanks.

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Find stmt that's stopping a DB from closing

Simon Slavin-3
In reply to this post by curmudgeon
On 5 Nov 2019, at 7:27pm, x <[hidden email]> wrote:

> I’m sure the team added a fct that listed the offenders but I can’t find it in the documentation.

The first statement associated with an open connection is pointed to by the pStmt of that connection.  Once you've found the first statement call

sqlite3_next_stmt()

on it to find the next one.

<https://www.sqlite.org/c3ref/next_stmt.html>

Unfortunately the database connection is documented as 'opaque'.  I'm not certain for the ideal way in C to get the first statement from it.

Simon
--
 http://www.bigfraud.org     | I'd expect if a computer was involved
 No Buffy for you.           | it all would have been much worse.
 Leave quickly now. -- Anya  |                -- John "West" McKenna

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Find stmt that's stopping a DB from closing

curmudgeon
Thanks Simon. Used this

        string str;
        sqlite3_stmt *stmt=NULL;
        do
        {
                stmt=sqlite3_next_stmt(FSQLiteDB,stmt);
                if (stmt) str+=string(sqlite3_sql(stmt))+"\r\n";
        }
        while (stmt);



________________________________
From: sqlite-users <[hidden email]> on behalf of Simon Slavin <[hidden email]>
Sent: Tuesday, November 5, 2019 7:55:12 PM
To: SQLite mailing list <[hidden email]>
Subject: Re: [sqlite] Find stmt that's stopping a DB from closing

On 5 Nov 2019, at 7:27pm, x <[hidden email]> wrote:

> I’m sure the team added a fct that listed the offenders but I can’t find it in the documentation.

The first statement associated with an open connection is pointed to by the pStmt of that connection.  Once you've found the first statement call

sqlite3_next_stmt()

on it to find the next one.

<https://www.sqlite.org/c3ref/next_stmt.html>

Unfortunately the database connection is documented as 'opaque'.  I'm not certain for the ideal way in C to get the first statement from it.

Simon
--
 http://www.bigfraud.org     | I'd expect if a computer was involved
 No Buffy for you.           | it all would have been much worse.
 Leave quickly now. -- Anya  |                -- John "West" McKenna

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Find stmt that's stopping a DB from closing

Keith Medcalf
In reply to this post by Simon Slavin-3

>The first statement associated with an open connection is pointed to by
>the pStmt of that connection.  Once you've found the first statement call

>sqlite3_next_stmt()

>on it to find the next one.

><https://www.sqlite.org/c3ref/next_stmt.html>
>
>Unfortunately the database connection is documented as 'opaque'.  I'm not
>certain for the ideal way in C to get the first statement from it.

It is documented:

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.

This is how the sqlite_stmt vtab finds the non-finalized statements associated with a connection.

--
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.




_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Find stmt that's stopping a DB from closing

Simon Slavin-3
On 5 Nov 2019, at 8:39pm, Keith Medcalf <[hidden email]> wrote:

> If pStmt is NULL then this interface returns a pointer to the first prepared statement associated with the database connection pDb.

Ah, that's brilliant.  I missed that.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users