summaryrefslogtreecommitdiff
path: root/lib/lua/sqlite
diff options
context:
space:
mode:
authormbalmer <mbalmer@NetBSD.org>2012-11-02 12:24:52 +0000
committermbalmer <mbalmer@NetBSD.org>2012-11-02 12:24:52 +0000
commit007a0006ad8300b2d15287029c08b9c3bcf60340 (patch)
treeca0dba021ee137069f25cb6a5931945b05d2933b /lib/lua/sqlite
parentea602365f30a72ade0fbd3e99fb16817c884ba29 (diff)
- Update to the version on github.com.
- Fix stmt_bind(): SQLite makes a copy of the string passed (which can be garbage collected). Problem found by Kubo Takehiro.
Diffstat (limited to 'lib/lua/sqlite')
-rw-r--r--lib/lua/sqlite/sqlite.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/lib/lua/sqlite/sqlite.c b/lib/lua/sqlite/sqlite.c
index 3d1f7b056ab..f533a2dd4e6 100644
--- a/lib/lua/sqlite/sqlite.c
+++ b/lib/lua/sqlite/sqlite.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sqlite.c,v 1.4 2012/03/15 02:02:21 joerg Exp $ */
+/* $NetBSD: sqlite.c,v 1.5 2012/11/02 12:24:52 mbalmer Exp $ */
/*
* Copyright (c) 2011 Marc Balmer <marc@msys.ch>
@@ -207,7 +207,7 @@ stmt_bind(lua_State *L)
break;
case LUA_TSTRING:
lua_pushinteger(L, sqlite3_bind_text(*stmt, pidx,
- lua_tostring(L, 3), -1, NULL));
+ lua_tostring(L, 3), -1, SQLITE_TRANSIENT));
break;
case LUA_TNIL:
lua_pushinteger(L, sqlite3_bind_null(*stmt, pidx));
@@ -391,13 +391,14 @@ static void
gpio_set_info(lua_State *L)
{
lua_pushliteral(L, "_COPYRIGHT");
- lua_pushliteral(L, "Copyright (C) 2011 Marc Balmer <marc@msys.ch>");
+ lua_pushliteral(L, "Copyright (C) 2011, 2012 by "
+ "Marc Balmer <marc@msys.ch>");
lua_settable(L, -3);
lua_pushliteral(L, "_DESCRIPTION");
lua_pushliteral(L, "SQLite interface for Lua");
lua_settable(L, -3);
lua_pushliteral(L, "_VERSION");
- lua_pushliteral(L, "sqlite 1.0.0");
+ lua_pushliteral(L, "sqlite 1.0.2");
lua_settable(L, -3);
}
@@ -405,36 +406,36 @@ int
luaopen_sqlite(lua_State* L)
{
static const struct luaL_Reg sqlite_methods[] = {
- { "initialize", sqlite_initialize },
- { "shutdown", sqlite_shutdown },
- { "open", sqlite_open },
- { "libversion", sqlite_libversion },
- { "libversion_number", sqlite_libversion_number },
- { "sourceid", sqlite_sourceid },
- { NULL, NULL }
+ { "initialize", sqlite_initialize },
+ { "shutdown", sqlite_shutdown },
+ { "open", sqlite_open },
+ { "libversion", sqlite_libversion },
+ { "libversion_number", sqlite_libversion_number },
+ { "sourceid", sqlite_sourceid },
+ { NULL, NULL }
};
static const struct luaL_Reg db_methods[] = {
- { "close", db_close },
- { "prepare", db_prepare },
- { "exec", db_exec },
- { "errcode", db_errcode },
- { "errmsg", db_errmsg },
- { "get_autocommit", db_get_autocommit },
- { "changes", db_changes },
- { NULL, NULL }
+ { "close", db_close },
+ { "prepare", db_prepare },
+ { "exec", db_exec },
+ { "errcode", db_errcode },
+ { "errmsg", db_errmsg },
+ { "get_autocommit", db_get_autocommit },
+ { "changes", db_changes },
+ { NULL, NULL }
};
static const struct luaL_Reg stmt_methods[] = {
- { "bind", stmt_bind },
+ { "bind", stmt_bind },
{ "bind_parameter_count", stmt_bind_parameter_count },
{ "bind_parameter_index", stmt_bind_parameter_index },
{ "bind_parameter_name", stmt_bind_parameter_name },
- { "step", stmt_step },
- { "column", stmt_column },
- { "reset", stmt_reset },
- { "clear_bindings", stmt_clear_bindings },
- { "finalize", stmt_finalize },
- { "column_name", stmt_column_name },
- { "column_count", stmt_column_count },
+ { "step", stmt_step },
+ { "column", stmt_column },
+ { "reset", stmt_reset },
+ { "clear_bindings", stmt_clear_bindings },
+ { "finalize", stmt_finalize },
+ { "column_name", stmt_column_name },
+ { "column_count", stmt_column_count },
{ NULL, NULL }
};
int n;