Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

sqlite extension is broken #35

Open
IPv6 opened this Issue · 1 comment

1 participant

@IPv6

Found two issues trying to use sqlite extension:
1. luaopen_wax_sqlite did not clear stack after creating global table. Should be
BEGIN_STACK_MODIFY(L);
luaL_newmetatable(L, WAX_SQLITE_METATABLE_NAME);

luaL_register(L, NULL, metaFunctions);
luaL_register(L, WAX_SQLITE_METATABLE_NAME, functions);

END_STACK_MODIFY(L, 0);

  1. wax_sqlite_operation.m referes to wax_copyObject in operationComplete. wax_copyObject/wax_copyTable was removed from wax_helpers.h/.m in Feb 2010 (can be found through history though)

After fixing issues above all seems to work fine :)
One suggestion: give an option to return error codes to lua from executing sqlite commands. for now there is exceptions which is not cool at all

@IPv6

another nifty snippet since extension does not support variables binding: string escaping

static int conn_escape(lua_State *L)
{
// From lua kepler project
    BEGIN_STACK_MODIFY(L);
    const char *from = luaL_checkstring(L, 1);
    char *escaped = sqlite3_mprintf("%q", from);
    if (escaped == NULL)
    {
        lua_pushnil(L);
    }
    else
    {
        lua_pushstring(L, escaped);
        sqlite3_free(escaped);
    }
    END_STACK_MODIFY(L, 1);
    return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.