lunarmodules / luasql

LuaSQL is a simple interface from Lua to a DBMS.
http://lunarmodules.github.io/luasql
535 stars 192 forks source link

Missing luaopen_luasql_xxxx() prototypes from luasql.h #120

Closed mileib closed 5 months ago

mileib commented 4 years ago

Hello -

Is there some particular reason why the following prototypes are NOT included in luasql.h?

LUASQL_API int luaopen_luasql_postgres (lua_State L); LUASQL_API int luaopen_luasql_oci8 (lua_State L); LUASQL_API int luaopen_luasql_mysql (lua_State L); LUASQL_API int luaopen_luasql_firebird (lua_State L); LUASQL_API int luaopen_luasql_odbc (lua_State L); LUASQL_API int luaopen_luasql_sqlite3 (lua_State L);

These are not static functions and my application(s) call them directly. I'm hopeful these can be added for the next version?

tomasguisasola commented 4 years ago

luasql.h is meant to be used by the drivers; not to be included by an application. Maybe it would make more sense to provide a header file for each driver. What do you think?

mileib commented 4 years ago

If you wish to make it so that I don't need luasql.h at all and instead only load specific includes for the drivers I'm using, I'm 100% fine with that (I don't seem to use anything else out of luasql.h). Currently, the initialize function protos are not anywhere and I do use them in my C/Lua bindings. Thanks for considering my request.

mileib commented 4 years ago

Also, to clarify, I build luasql to link with my C application statically and make the lua scripts make use of "require" as you have in your examples.

So, in order to statically link luasql and make use of "require" in the script(s), I have coded:

/ Execute the luasql initializers / lua_getglobal(L, "package"); lua_getfield(L, -1, "preload"); lua_pushcfunction(L, luaopen_luasql_postgres); lua_setfield(L, -2, "luasql.postgres"); lua_pop(L, 2);

which, of course, gcc cannot compile w/o knowing the prototype for luaopen_luasql_postgres(). (postgres being just an example - I use more than one db interface)

tomasguisasola commented 5 months ago

Prototypes added to luasql.h