Wow, what a great feature. This saves me so much hacking!

I planned on using virtual tables but per-query instance creation and
parameter passing was going to be such a mess.

On Sun, Aug 23, 2015 at 1:55 PM, Richard Hipp <drh at sqlite.org> wrote:

> On 8/23/15, Abilio Marques <abiliojr at gmail.com> wrote:
> >
> > 1. sqlite3 CLI doesn't seem to "load" the .so easily... The generated so
> is
> > called "lua.ext". If I run "*.load lua.ext*" it claims that there is no
> .so
> > available. I went into renaming the file to lua.so, and ran *.load
> lua.so*
> > ... Got: *Error: Shared object "lua.so.so <http://lua.so.so>" not found,
> > required by "sqlite3"* ... then tried with *.load lua* ... I guessed that
> > would work... but got *Error: Shared object "lua.so" not found, required
> by
> > "sqlite3*", even when the file was present at that directory... But then
> I
> > ran *.load ./lua.so* , and even *.load ./lua* ... both loaded without
> > problems... Is that the correct behavior?
>
> Yes. You each have to specify a pathname or else the library must be
> on LD_LIBRARY_PATH.  I think this is a security restriction.  Maybe
> somebody else can shed more light on the matter.
>
> >
> > 2. Which is the convention for the file extension of a loadable module?
> .so
> > and .dll?, or is there any other name used regularly among sqlite3 users?
>
> .so for linux.  .dylib for mac.  .dll for windows.
>
> You can just do ".load ./lua" without the suffix and SQLite will
> supply the correct suffix for your platform.
>
>
> >
> > 3. Lua can return arrays. Also, Lua can return multiple values. Tried to
> > take advantage of those facts, but while reading the SQLite API
> > documentation, found no function where I could map multiple values as the
> > return of a function. Am I wrong? For example:
> >
> > select * from table t where fieldA in (lua('return 1,2,3'));
> >
> > Could be a useful feat in real scripts with real code.
> >
>
> Regular SQL functions always return scalars in SQLite.
>
> See https://www.sqlite.org/src/artifact/b8fb7befd85b3a9b for an
> example of how to implement table-valued functions.  This is a new
> feature so there is no documentation on it yet.  But the example is
> well-commented.  This capability will be in the next release, so
> you'll have to compile from trunk if you want to use it right away -
> it is not found in 3.8.11.1.
>
> --
> D. Richard Hipp
> drh at sqlite.org
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>

Reply via email to