Sqlite intarray issue

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

Sqlite intarray issue

Roman Ivasyshyn
Hello sqlite team,



I faced with an issue of creating int array with the same name without
closing connection.

I use sqlite3_intarray_create to create int array on a second call I
receive SQLITE_MISUSE error.

What I found inside create function that it tries to create module that
already exist with sqlite3_create_module_v2 function and drop table, before
second call, makes no effect on that module.



Please advice if it’s expected behavior and it there any workarounds on
that?



Regards,

Roman Ivasyshyn
_______________________________________________
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: Sqlite intarray issue

Richard Hipp-3
On 10/31/18, Roman Ivasyshyn <[hidden email]> wrote:
>
> I faced with an issue of creating int array with the same name without
> closing connection.

That is not allowed.  But you can use sqlite3_intarray_bind() to
change the array to which the intarray table is bound, or the length
of the array.

Another option is to use the carray() table-valued-function instead of
the intarray virtual table.  The carray() function requires you to
bind the array, the array length, and the array datatype at run-time.
Multiple instances of the carray() table valued function, each with
different array bindings, can participate in the same join.  You do
not need to create multiple instances of carray(), one for each array.
Indeed, that is not even allowed.  Instead in the single carray()
table valued function can be reused for each array.

More information on carray here: https://www.sqlite.org/carray.html

The intarray virtual table predates the ability to have table valued
functions in SQLite.  Intarray continues to be used for testing
purposes but is no longer recommended for production use.  I have
added a warning to this effect in the header comment.
--
D. Richard Hipp
[hidden email]
_______________________________________________
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: Sqlite intarray issue

Roman Ivasyshyn
Thank you for the clarification.

On Wed, Oct 31, 2018 at 6:03 PM Richard Hipp <[hidden email]> wrote:

> On 10/31/18, Roman Ivasyshyn <[hidden email]> wrote:
> >
> > I faced with an issue of creating int array with the same name without
> > closing connection.
>
> That is not allowed.  But you can use sqlite3_intarray_bind() to
> change the array to which the intarray table is bound, or the length
> of the array.
>
> Another option is to use the carray() table-valued-function instead of
> the intarray virtual table.  The carray() function requires you to
> bind the array, the array length, and the array datatype at run-time.
> Multiple instances of the carray() table valued function, each with
> different array bindings, can participate in the same join.  You do
> not need to create multiple instances of carray(), one for each array.
> Indeed, that is not even allowed.  Instead in the single carray()
> table valued function can be reused for each array.
>
> More information on carray here: https://www.sqlite.org/carray.html
>
> The intarray virtual table predates the ability to have table valued
> functions in SQLite.  Intarray continues to be used for testing
> purposes but is no longer recommended for production use.  I have
> added a warning to this effect in the header comment.
> --
> D. Richard Hipp
> [hidden email]
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users