Improvement on compiler requirements from Postgres driver: it does not depend upon dynamic array allocation (which is not supported in all modern C compiler).

Generalizing tests to allow configuration of the database default username.
master
Tomas Guisasola 2016-03-28 09:16:46 -03:00 committed by Tomás Guisasola
parent 25eebb2222
commit 4acc737e65
8 changed files with 32 additions and 11 deletions

View File

@ -1,4 +1,4 @@
V= 2.3.0
V= 2.3.1
CONFIG= ./config
include $(CONFIG)

View File

@ -65,6 +65,13 @@
<h2><a name="history"></a>History</h2>
<dl class="history">
<dt><strong>LuaSQL 2.3.1</strong> [28/Mar/2016]</dt>
<dd>
<ul>
<li>Improvement on the Postgres driver to avoid the need of compiler support of dynamic array allocation</li>
</ul>
</dd>
<dt><strong>LuaSQL 2.3.0</strong> [23/May/2012]</dt>
<dd>
<ul>

View File

@ -81,7 +81,7 @@ as Lua 5.1.
<h2><a name="status"></a>Status</h2>
<p>
LuaSQL version 2.3.0 (for Lua 5.X) is now available for <a href="#download">download</a>.
LuaSQL version 2.3.1 (for Lua 5.X) is now available for <a href="#download">download</a>.
For more details on the features list please check the product
<a href="history.html">history</a>.
</p>

View File

@ -86,7 +86,7 @@ somewhere in your product or its documentation.</p>
The implementation is not derived from licensed software.</p>
<hr/>
<p>Copyright &copy; 2003-2007 The Kepler Project.</p>
<p>Copyright &copy; 2003-2016 The Kepler Project.</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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")

View File

@ -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 },