mirror of
https://github.com/etlegacy/etlegacy-libs.git
synced 2025-02-23 20:01:06 +00:00
libs: updated to latest LuaSQL
This commit is contained in:
parent
aa43b3c0e8
commit
b62e4ff6ca
12 changed files with 73 additions and 38 deletions
|
@ -1,4 +1,4 @@
|
|||
V= 2.3.0
|
||||
V= 2.3.1
|
||||
CONFIG= ./config
|
||||
|
||||
include $(CONFIG)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
LuaSQL - This is a copy of commit/6485f4845ce955bb9d5227cdba12aa90dd241f70
|
||||
http://keplerproject.github.io/luasql/doc/us/
|
||||
LuaSQL
|
||||
http://keplerproject.github.io/luasql
|
||||
|
||||
LuaSQL is a simple interface from Lua to a DBMS. It enables a Lua program to:
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
PREFIX ?= /usr
|
||||
|
||||
# Lua version and dirs
|
||||
LUA_SYS_VER ?= 5.3
|
||||
LUA_SYS_VER ?= 5.2
|
||||
LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUA_SYS_VER)
|
||||
LUA_DIR ?= $(PREFIX)/share/lua/$(LUA_SYS_VER)
|
||||
LUA_INC ?= $(PREFIX)/include/lua$(LUA_SYS_VER)
|
||||
|
|
|
@ -65,6 +65,27 @@
|
|||
<h2><a name="history"></a>History</h2>
|
||||
|
||||
<dl class="history">
|
||||
<dt><strong>LuaSQL 2.3.3</strong> [16/May/2016]</dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<li>Bug correction in Postgres driver: generating error message after failed connection (thanks to seanpringle)</li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
<dt><strong>LuaSQL 2.3.2</strong> [14/May/2016]</dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<li>Bug correction in Postgres driver: freeing memory after failed connection opening (thanks to seanpringle)</li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
<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>
|
||||
|
|
|
@ -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.3 (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>
|
||||
|
|
|
@ -86,7 +86,7 @@ somewhere in your product or its documentation.</p>
|
|||
The implementation is not derived from licensed software.</p>
|
||||
|
||||
<hr/>
|
||||
<p>Copyright © 2003-2007 The Kepler Project.</p>
|
||||
<p>Copyright © 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
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <ibase.h> /* The Firebird API*/
|
||||
#include <time.h> /* For managing time values */
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Lua API */
|
||||
|
|
|
@ -371,14 +371,28 @@ 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[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);
|
||||
return 1;
|
||||
} else
|
||||
return luasql_failmsg (L, "cannot escape string. PostgreSQL: ", PQerrorMessage (conn->pg_conn));
|
||||
#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));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -484,30 +498,22 @@ static void notice_processor (void *arg, const char *message) {
|
|||
|
||||
/*
|
||||
** Connects to a data source.
|
||||
** This driver provides two ways to connect to a data source:
|
||||
** (1) giving the connection parameters as a set of pairs separated
|
||||
** by whitespaces in a string (first method parameter)
|
||||
** (2) giving one string for each connection parameter, said
|
||||
** datasource, username, password, host and port.
|
||||
*/
|
||||
static int env_connect (lua_State *L) {
|
||||
const char *sourcename = luaL_checkstring(L, 2);
|
||||
PGconn *conn;
|
||||
getenvironment (L); /* validate environment */
|
||||
if ((lua_gettop (L) == 2) && (strchr (sourcename, '=') != NULL))
|
||||
conn = PQconnectdb (sourcename);
|
||||
else {
|
||||
const char *username = luaL_optstring(L, 3, NULL);
|
||||
const char *password = luaL_optstring(L, 4, NULL);
|
||||
const char *pghost = luaL_optstring(L, 5, NULL);
|
||||
const char *pgport = luaL_optstring(L, 6, NULL);
|
||||
PGconn *conn;
|
||||
getenvironment (L); /* validate environment */
|
||||
conn = PQsetdbLogin(pghost, pgport, NULL, NULL, sourcename, username, password);
|
||||
|
||||
conn = PQsetdbLogin(pghost, pgport, NULL, NULL,
|
||||
sourcename, username, password);
|
||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||
int rc = luasql_failmsg(L, "error connecting to database. PostgreSQL: ", PQerrorMessage(conn));
|
||||
PQfinish(conn);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (PQstatus(conn) == CONNECTION_BAD)
|
||||
return luasql_failmsg(L, "error connecting to database. PostgreSQL: ", PQerrorMessage(conn));
|
||||
PQsetNoticeProcessor(conn, notice_processor, NULL);
|
||||
return create_connection(L, 1, conn);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,12 @@ static int finalize(lua_State *L, cur_data *cur) {
|
|||
static void push_column(lua_State *L, sqlite3_stmt *vm, int column) {
|
||||
switch (sqlite3_column_type(vm, column)) {
|
||||
case SQLITE_INTEGER:
|
||||
#if LUA_VERSION_NUM >= 503
|
||||
lua_pushinteger(L, sqlite3_column_int64(vm, column));
|
||||
#else
|
||||
// Preserves precision of integers up to 2^53.
|
||||
lua_pushnumber(L, sqlite3_column_int64(vm, column));
|
||||
#endif
|
||||
break;
|
||||
case SQLITE_FLOAT:
|
||||
lua_pushnumber(L, sqlite3_column_double(vm, column));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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 },
|
||||
|
|
Loading…
Reference in a new issue