4

I have looked into at least 6 different SQL Lua extensions, and they all seem to have their latest version compatible with up to version 5.1 of Lua. I have had zero success in implementing any of them into my current project which uses Lua 5.2, with the best case scenario ending in either silent program crashes or attempt to call global 'module' (a nil value).
I am not the original project owner, so I am trying not to be forced into changing the source code for it (though more recently, I have even gone down that road now).

And often times, it is unclear if these crashes are related to the way the project itself operates, the way the project implements Lua (as a static library), the way that Lua tries to implement it's extensions, the way the extensions implement their dependencies, a versioning conflict, or some sort of crazy combination of each. It's practically impossible to debug a silent crash in this manner, because the source of evil could literally be anything.

As the answer states in this question, I have even tried supporting the module function (which most lua sql extensions utilize, but was deprecated in 5.2), but the program still crashes or just complains about a seemingly infinite amount of missing dependencies. And after spending hours of tracking down (what would seem to be) all of the dependencies it would complain about, it still crashes.

Changing the project's source code to use the Lua 5.1 source appears to break the functionality of the project, resulting in various compiler errors regarding missing 5.2-related functions. Linking the MySQL C/C++ connector to the project results in rather vague runtime errors, which seem to conflict with the way the project implements Lua 5.2.

Are there ANY sqlite/MySQL extensions out there which actually work with Lua 5.2 on a 32-bit Windows machine? Preferably, "out-of-the-box" precompiled binaries with Lua source/ffi bindings?
OR alternatively, are there any clear instructions on how to get this set up properly, without having to scavenge through separate instructions across the web for each required assembly?

Community
  • 1
  • 1
RectangleEquals
  • 1,825
  • 2
  • 25
  • 44
  • Try to build Lua 5.2 with LUA_COMPAT_MODULE defined. – Egor Skriptunoff Jun 01 '13 at 07:35
  • Thanks, but [this has already been discussed](http://stackoverflow.com/questions/16849422) in the question (3rd paragraph). – RectangleEquals Jun 01 '13 at 07:37
  • 1
    Ops, sorry my inattentiveness. BTW, I usually try to write my Lua scripts to be compatible with both Lua 5.2 and LuaJIT (with some 5.2-features enabled) to avoid future problems with calling an external module. Consider rewriting your main Lua code (and host-side code) to be functional in both Lua versions: emulate some 5.2-functions if needed. – Egor Skriptunoff Jun 01 '13 at 07:54
  • 1
    Are you looking for an extension for SQLite OR MySQL, or for SQLite AND MySQL? If you just want SQLite, then lsqlite3 works fine with Lua 5.2 -- get it via luarocks. http://lua.sqlite.org/ – Doug Currie Jun 01 '13 at 16:45
  • You mean the one [right here](https://github.com/LuaDist/lsqlite3)? I got as far as successfully generating the VC11 project using CMake-gui, and replacing the use of the old `lua_strlen` calls with `lua_rawlen`, but it is evident that this code still uses Lua 5.1... For example, in _lsqlite3.c_ line _650_, they make use of `luaL_typerror` which was removed from 5.2 with the happy note of _"luaL_typerror was removed. Write your own version if you need it."_. – RectangleEquals Jun 01 '13 at 18:59
  • ... and I'd really rather not be forced into compiling my own special version of Lua 5.2 to include (what may be) totally incorrect implementations of whichever functions have been deprecated and removed. If the application still crashes after doing this, then that's just one more thing to add to the list of potential culprits. – RectangleEquals Jun 01 '13 at 19:12
  • No, not the one at LuaDist; go to the source at lua.sqlite.org, or use luarocks to install lsqlite3 (to do that you'll need luarocks installed and a compatible C compiler) – Doug Currie Jun 03 '13 at 14:33

0 Answers0