From 4acc737e65de676bcab5bdad8461fd64290fd39b Mon Sep 17 00:00:00 2001
From: Tomas Guisasola
-LuaSQL version 2.3.0 (for Lua 5.X) is now available for download.
+LuaSQL version 2.3.1 (for Lua 5.X) is now available for download.
For more details on the features list please check the product
history.
History
+
+
+
diff --git a/doc/us/index.html b/doc/us/index.html
index e717933..adb3eeb 100644
--- a/doc/us/index.html
+++ b/doc/us/index.html
@@ -81,7 +81,7 @@ as Lua 5.1.
Status
Copyright © 2003-2007 The Kepler Project.
+Copyright © 2003-2016 The Kepler Project.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/ls_postgres.c b/src/ls_postgres.c index 826e2fb..fa3ab4d 100644 --- a/src/ls_postgres.c +++ b/src/ls_postgres.c @@ -371,16 +371,27 @@ static int conn_escape (lua_State *L) { conn_data *conn = getconnection (L); size_t len; const char *from = luaL_checklstring (L, 2, &len); - char *to = malloc(len*sizeof(char)*2+1); int error; int ret = 1; + luaL_Buffer b; +#if defined(luaL_buffinitsize) + char *to = luaL_buffinitsize (L, &b, 2*len+1); +#else + char *to; + luaL_buffinit (L, &b); + to = luaL_prepbuffer (&b); +#endif len = PQescapeStringConn (conn->pg_conn, to, from, len, &error); if (error == 0) { /* success ! */ - lua_pushlstring (L, to, len); +#if defined(luaL_pushresultsize) + luaL_pushresultsize (&b, len); +#else + luaL_addsize (&b, len); + luaL_pushresult (&b); +#endif } else { ret = luasql_failmsg (L, "cannot escape string. PostgreSQL: ", PQerrorMessage (conn->pg_conn)); } - free(to); return ret; } diff --git a/src/luasql.c b/src/luasql.c index caf9721..0eb1a14 100644 --- a/src/luasql.c +++ b/src/luasql.c @@ -122,12 +122,12 @@ LUASQL_API void luasql_setmeta (lua_State *L, const char *name) { */ LUASQL_API void luasql_set_info (lua_State *L) { lua_pushliteral (L, "_COPYRIGHT"); - lua_pushliteral (L, "Copyright (C) 2003-2012 Kepler Project"); + lua_pushliteral (L, "Copyright (C) 2003-2016 Kepler Project"); lua_settable (L, -3); lua_pushliteral (L, "_DESCRIPTION"); lua_pushliteral (L, "LuaSQL is a simple interface from Lua to a DBMS"); lua_settable (L, -3); lua_pushliteral (L, "_VERSION"); - lua_pushliteral (L, "LuaSQL 2.3.0"); + lua_pushliteral (L, "LuaSQL 2.3.1"); lua_settable (L, -3); } diff --git a/tests/postgres.lua b/tests/postgres.lua index 52dc506..8cec53d 100644 --- a/tests/postgres.lua +++ b/tests/postgres.lua @@ -3,6 +3,8 @@ -- $Id: postgres.lua,v 1.2 2006/01/25 19:15:21 tomas Exp $ --------------------------------------------------------------------- +DEFAULT_USERNAME = "postgres" + table.insert (CUR_METHODS, "numrows") table.insert (EXTENSIONS, numrows) table.insert (CONN_METHODS, "escape") diff --git a/tests/test.lua b/tests/test.lua index ae2d653..0395a4f 100644 --- a/tests/test.lua +++ b/tests/test.lua @@ -615,9 +615,6 @@ if type(arg[1]) ~= "string" then end driver = arg[1] -datasource = arg[2] or "luasql-test" -username = arg[3] or nil -password = arg[4] or nil -- Loading driver specific functions if arg[0] then @@ -636,6 +633,10 @@ if arg[0] then end end +datasource = arg[2] or DEFAULT_TEST_DATABASE or "luasql-test" +username = arg[3] or DEFAULT_USERNAME or nil +password = arg[4] or DEFAULT_PASSWORD or nil + -- Complete set of tests tests = { { "basic checking", basic_test },