mirror of
https://github.com/etlegacy/etlegacy-libs.git
synced 2025-02-24 12:11:11 +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
|
CONFIG= ./config
|
||||||
|
|
||||||
include $(CONFIG)
|
include $(CONFIG)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
LuaSQL - This is a copy of commit/6485f4845ce955bb9d5227cdba12aa90dd241f70
|
LuaSQL
|
||||||
http://keplerproject.github.io/luasql/doc/us/
|
http://keplerproject.github.io/luasql
|
||||||
|
|
||||||
LuaSQL is a simple interface from Lua to a DBMS. It enables a Lua program to:
|
LuaSQL is a simple interface from Lua to a DBMS. It enables a Lua program to:
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
PREFIX ?= /usr
|
PREFIX ?= /usr
|
||||||
|
|
||||||
# Lua version and dirs
|
# Lua version and dirs
|
||||||
LUA_SYS_VER ?= 5.3
|
LUA_SYS_VER ?= 5.2
|
||||||
LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUA_SYS_VER)
|
LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUA_SYS_VER)
|
||||||
LUA_DIR ?= $(PREFIX)/share/lua/$(LUA_SYS_VER)
|
LUA_DIR ?= $(PREFIX)/share/lua/$(LUA_SYS_VER)
|
||||||
LUA_INC ?= $(PREFIX)/include/lua$(LUA_SYS_VER)
|
LUA_INC ?= $(PREFIX)/include/lua$(LUA_SYS_VER)
|
||||||
|
|
|
@ -65,6 +65,27 @@
|
||||||
<h2><a name="history"></a>History</h2>
|
<h2><a name="history"></a>History</h2>
|
||||||
|
|
||||||
<dl class="history">
|
<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>
|
<dt><strong>LuaSQL 2.3.0</strong> [23/May/2012]</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -81,7 +81,7 @@ as Lua 5.1.
|
||||||
<h2><a name="status"></a>Status</h2>
|
<h2><a name="status"></a>Status</h2>
|
||||||
|
|
||||||
<p>
|
<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
|
For more details on the features list please check the product
|
||||||
<a href="history.html">history</a>.
|
<a href="history.html">history</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -86,7 +86,7 @@ somewhere in your product or its documentation.</p>
|
||||||
The implementation is not derived from licensed software.</p>
|
The implementation is not derived from licensed software.</p>
|
||||||
|
|
||||||
<hr/>
|
<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
|
<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
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include <ibase.h> /* The Firebird API*/
|
#include <ibase.h> /* The Firebird API*/
|
||||||
#include <time.h> /* For managing time values */
|
#include <time.h> /* For managing time values */
|
||||||
#include <malloc.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* Lua API */
|
/* Lua API */
|
||||||
|
|
|
@ -371,14 +371,28 @@ static int conn_escape (lua_State *L) {
|
||||||
conn_data *conn = getconnection (L);
|
conn_data *conn = getconnection (L);
|
||||||
size_t len;
|
size_t len;
|
||||||
const char *from = luaL_checklstring (L, 2, &len);
|
const char *from = luaL_checklstring (L, 2, &len);
|
||||||
char to[len*sizeof(char)*2+1];
|
|
||||||
int error;
|
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);
|
len = PQescapeStringConn (conn->pg_conn, to, from, len, &error);
|
||||||
if (error == 0) { /* success ! */
|
if (error == 0) { /* success ! */
|
||||||
lua_pushlstring (L, to, len);
|
#if defined(luaL_pushresultsize)
|
||||||
return 1;
|
luaL_pushresultsize (&b, len);
|
||||||
} else
|
#else
|
||||||
return luasql_failmsg (L, "cannot escape string. PostgreSQL: ", PQerrorMessage (conn->pg_conn));
|
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.
|
** 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) {
|
static int env_connect (lua_State *L) {
|
||||||
const char *sourcename = luaL_checkstring(L, 2);
|
const char *sourcename = luaL_checkstring(L, 2);
|
||||||
|
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;
|
PGconn *conn;
|
||||||
getenvironment (L); /* validate environment */
|
getenvironment (L); /* validate environment */
|
||||||
if ((lua_gettop (L) == 2) && (strchr (sourcename, '=') != NULL))
|
conn = PQsetdbLogin(pghost, pgport, NULL, NULL, sourcename, username, password);
|
||||||
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);
|
|
||||||
|
|
||||||
conn = PQsetdbLogin(pghost, pgport, NULL, NULL,
|
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||||
sourcename, username, password);
|
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);
|
PQsetNoticeProcessor(conn, notice_processor, NULL);
|
||||||
return create_connection(L, 1, conn);
|
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) {
|
static void push_column(lua_State *L, sqlite3_stmt *vm, int column) {
|
||||||
switch (sqlite3_column_type(vm, column)) {
|
switch (sqlite3_column_type(vm, column)) {
|
||||||
case SQLITE_INTEGER:
|
case SQLITE_INTEGER:
|
||||||
|
#if LUA_VERSION_NUM >= 503
|
||||||
lua_pushinteger(L, sqlite3_column_int64(vm, column));
|
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;
|
break;
|
||||||
case SQLITE_FLOAT:
|
case SQLITE_FLOAT:
|
||||||
lua_pushnumber(L, sqlite3_column_double(vm, column));
|
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) {
|
LUASQL_API void luasql_set_info (lua_State *L) {
|
||||||
lua_pushliteral (L, "_COPYRIGHT");
|
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_settable (L, -3);
|
||||||
lua_pushliteral (L, "_DESCRIPTION");
|
lua_pushliteral (L, "_DESCRIPTION");
|
||||||
lua_pushliteral (L, "LuaSQL is a simple interface from Lua to a DBMS");
|
lua_pushliteral (L, "LuaSQL is a simple interface from Lua to a DBMS");
|
||||||
lua_settable (L, -3);
|
lua_settable (L, -3);
|
||||||
lua_pushliteral (L, "_VERSION");
|
lua_pushliteral (L, "_VERSION");
|
||||||
lua_pushliteral (L, "LuaSQL 2.3.0");
|
lua_pushliteral (L, "LuaSQL 2.3.1");
|
||||||
lua_settable (L, -3);
|
lua_settable (L, -3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
-- $Id: postgres.lua,v 1.2 2006/01/25 19:15:21 tomas Exp $
|
-- $Id: postgres.lua,v 1.2 2006/01/25 19:15:21 tomas Exp $
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
DEFAULT_USERNAME = "postgres"
|
||||||
|
|
||||||
table.insert (CUR_METHODS, "numrows")
|
table.insert (CUR_METHODS, "numrows")
|
||||||
table.insert (EXTENSIONS, numrows)
|
table.insert (EXTENSIONS, numrows)
|
||||||
table.insert (CONN_METHODS, "escape")
|
table.insert (CONN_METHODS, "escape")
|
||||||
|
|
|
@ -615,9 +615,6 @@ if type(arg[1]) ~= "string" then
|
||||||
end
|
end
|
||||||
|
|
||||||
driver = arg[1]
|
driver = arg[1]
|
||||||
datasource = arg[2] or "luasql-test"
|
|
||||||
username = arg[3] or nil
|
|
||||||
password = arg[4] or nil
|
|
||||||
|
|
||||||
-- Loading driver specific functions
|
-- Loading driver specific functions
|
||||||
if arg[0] then
|
if arg[0] then
|
||||||
|
@ -636,6 +633,10 @@ if arg[0] then
|
||||||
end
|
end
|
||||||
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
|
-- Complete set of tests
|
||||||
tests = {
|
tests = {
|
||||||
{ "basic checking", basic_test },
|
{ "basic checking", basic_test },
|
||||||
|
|
Loading…
Reference in a new issue