Callback for sqlite3_finalize()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Callback for sqlite3_finalize()

Stadin, Benjamin
Hi,

I register a custom SQL function using dms_create_function_v2, and in the C callback I create a rather heavy C++ helper class which I need to prepare the result.

I currently use sqlite3_get_auxdata and sqlite3_set_auxdata, but my problem is that the finalization callback  of sqlite3_set_auxdata is called after each step().

Is there a way to hook into sqlite3_finalize(), in order to manage the lifecycle of application data that is created together with a statement and to be destroyed once the statement is finalized?

Ben

_______________________________________________
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: Callback for sqlite3_finalize()

Stadin, Benjamin
That should read sqlite3_create_function_v2


Am 22.11.17, 00:03 schrieb "sqlite-users im Auftrag von Stadin, Benjamin" <[hidden email] im Auftrag von [hidden email]>:

    dms_create_function_v2

_______________________________________________
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: Callback for sqlite3_finalize()

petern
In reply to this post by Stadin, Benjamin
Ben.  Your post was in spam.

Is your extension function an aggregate?

From https://www.sqlite.org/c3ref/get_auxdata.html  "These functions may be
used by (non-aggregate) SQL functions..."

The trace hook API has some statement level modes you might hook for to
manage your cached data:

https://www.sqlite.org/c3ref/c_trace.html

You are also completely free to reference your own data structures by name
from your custom extension.

Thinking about this, it occurs to me again, it would help many if SQLite
also had the similar sqlite3_get_data()  and sqlite3_set_data()  per
connection.   In your case you could organize your data on the connection
and use trace hook to keep it relevant to extension function query(s).  As
it stands the only connection level object appears to be a custom VFS shim
which is overkill for this.

Does DRH read these posts?  The question is why isn't there a connection
level get/set cache API similar to the auxdata calls?

Peter










On Tue, Nov 21, 2017 at 3:03 PM, Stadin, Benjamin <
[hidden email]> wrote:

> Hi,
>
> I register a custom SQL function using dms_create_function_v2, and in the
> C callback I create a rather heavy C++ helper class which I need to prepare
> the result.
>
> I currently use sqlite3_get_auxdata and sqlite3_set_auxdata, but my
> problem is that the finalization callback  of sqlite3_set_auxdata is called
> after each step().
>
> Is there a way to hook into sqlite3_finalize(), in order to manage the
> lifecycle of application data that is created together with a statement and
> to be destroyed once the statement is finalized?
>
> Ben
>
> _______________________________________________
> 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