Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. *Read more...*

Feature #890257 ยป 0004-Update-luasql-to-version-2.6.0.patch

Marko Lindqvist, 2020-10-07 01:18 PM

View differences:

dependencies/luasql/Version
Sources here are fron luasql git tag 2.5.0
(https://github.com/keplerproject/luasql/tree/2.5.0)
Sources here are fron luasql git tag 2.6.0
(https://github.com/keplerproject/luasql/tree/2.6.0)
Only the files needed by freeciv are included here, not entire luasql
source directory hierarchy.
dependencies/luasql/src/ls_mysql.c
** LuaSQL, MySQL driver
** Authors: Eduardo Quintao
** See Copyright Notice in license.html
** $Id: ls_mysql.c,v 1.31 2009/02/07 23:16:23 tomas Exp $
*/
#include <assert.h>
......
int numcols; /* number of columns */
int colnames, coltypes; /* reference to column information tables */
MYSQL_RES *my_res;
MYSQL *my_conn;
} cur_data;
LUASQL_API int luaopen_luasql_mysql (lua_State *L);
/*
** Check for valid environment.
......
}
}
/*
** Get the next result from multiple statements
*/
static int cur_next_result (lua_State *L) {
cur_data *cur = getcursor (L);
MYSQL* con = cur->my_conn;
int status;
if(mysql_more_results(con)){
status = mysql_next_result(con);
if(status == 0){
mysql_free_result(cur->my_res);
cur->my_res = mysql_store_result(con);
if(cur->my_res != NULL){
lua_pushboolean(L, 1);
return 1;
}else{
lua_pushboolean(L, 0);
lua_pushinteger(L, mysql_errno(con));
lua_pushstring(L, mysql_error(con));
return 3;
}
}else{
lua_pushboolean(L, 0);
lua_pushinteger(L, status);
switch(status){
case CR_COMMANDS_OUT_OF_SYNC:
lua_pushliteral(L, "CR_COMMANDS_OUT_OF_SYNC");
break;
case CR_SERVER_GONE_ERROR:
lua_pushliteral(L, "CR_SERVER_GONE_ERROR");
break;
case CR_SERVER_LOST:
lua_pushliteral(L, "CR_SERVER_LOST");
break;
case CR_UNKNOWN_ERROR:
lua_pushliteral(L, "CR_UNKNOWN_ERROR");
break;
default:
lua_pushliteral(L, "Unknown");
}
return 3;
}
}else{
lua_pushboolean(L, 0);
lua_pushinteger(L, -1);
return 2;
}
}
/*
** Check if next result is available
*/
static int cur_has_next_result (lua_State *L) {
cur_data *cur = getcursor (L);
lua_pushboolean(L, mysql_more_results(cur->my_conn));
return 1;
}
/*
** Cursor object collector function
......
/*
** Create a new Cursor object and push it on top of the stack.
*/
static int create_cursor (lua_State *L, int conn, MYSQL_RES *result, int cols) {
static int create_cursor (lua_State *L, MYSQL *my_conn, int conn, MYSQL_RES *result, int cols) {
cur_data *cur = (cur_data *)lua_newuserdata(L, sizeof(cur_data));
luasql_setmeta (L, LUASQL_CURSOR_MYSQL);
......
cur->colnames = LUA_NOREF;
cur->coltypes = LUA_NOREF;
cur->my_res = result;
cur->my_conn = my_conn;
lua_pushvalue (L, conn);
cur->conn = luaL_ref (L, LUA_REGISTRYINDEX);
......
unsigned int num_cols = mysql_field_count(conn->my_conn);
if (res) { /* tuples returned */
return create_cursor (L, 1, res, num_cols);
return create_cursor (L, conn->my_conn, 1, res, num_cols);
}
else { /* mysql_use_result() returned nothing; should it have? */
if(num_cols == 0) { /* no tuples returned */
......
}
/*
** Rollback the current transaction.
*/
......
{"fetch", cur_fetch},
{"numrows", cur_numrows},
{"seek", cur_seek},
{"nextresult", cur_next_result},
{"hasnextresult", cur_has_next_result},
{NULL, NULL},
};
luasql_createmeta (L, LUASQL_ENVIRONMENT_MYSQL, environment_methods);
dependencies/luasql/src/ls_odbc.c
** Authors: Pedro Rabinovitch, Roberto Ierusalimschy, Diego Nehab,
** Tomas Guisasola
** See Copyright Notice in license.html
** $Id: ls_odbc.c,v 1.39 2009/02/07 23:16:23 tomas Exp $
*/
#include <assert.h>
......
}
LUASQL_API int luaopen_luasql_odbc (lua_State *L);
/*
** Registers a given C object in the registry to avoid GC
*/
dependencies/luasql/src/ls_postgres.c
** Authors: Pedro Rabinovitch, Roberto Ierusalimschy, Carlos Cassino
** Tomas Guisasola, Eduardo Quintao
** See Copyright Notice in license.html
** $Id: ls_postgres.c,v 1.11 2009/02/07 23:16:23 tomas Exp $
*/
#include <assert.h>
......
typedef void (*creator) (lua_State *L, cur_data *cur);
LUASQL_API int luaopen_luasql_postgres(lua_State *L);
/*
** Check for valid environment.
*/
dependencies/luasql/src/ls_sqlite3.c
** LuaSQL, SQLite driver
** Author: Tiago Dionizio, Eduardo Quintao
** See Copyright Notice in license.html
** $Id: ls_sqlite3.c,v 1.15 2009/02/07 23:16:23 tomas Exp $
*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
......
sqlite3_stmt *sql_vm;
} cur_data;
LUASQL_API int luaopen_luasql_sqlite3(lua_State *L);
/*
** Check for valid environment.
......
sqlite3 *conn;
const char *errmsg;
int res;
bool readOnlyMode = false;
int mode;
getenvironment(L); /* validate environment */
sourcename = luaL_checkstring(L, 2);
if (lua_isboolean(L, 4)) {
if (lua_toboolean(L, 4)) {
readOnlyMode = true;
}
}
sourcename = luaL_checkstring(L, 2);
#if SQLITE_VERSION_NUMBER > 3006013
if (strstr(sourcename, ":memory:")) /* TODO: rework this and get/add param 'flag' for sqlite3_open_v2 - see TODO below */
{
res = sqlite3_open_v2(sourcename, &conn, SQLITE_OPEN_READWRITE | SQLITE_OPEN_MEMORY, NULL);
if (readOnlyMode) {
mode = SQLITE_OPEN_READONLY | SQLITE_OPEN_MEMORY;
} else {
mode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_MEMORY;
}
}
else
{
res = sqlite3_open_v2(sourcename, &conn, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
if (readOnlyMode) {
mode = SQLITE_OPEN_READONLY;
} else {
mode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
}
}
res = sqlite3_open_v2(sourcename, &conn, mode, NULL);
#else
res = sqlite3_open(sourcename, &conn);
#endif
dependencies/luasql/src/luasql.c
*/
LUASQL_API void luasql_set_info (lua_State *L) {
lua_pushliteral (L, "_COPYRIGHT");
lua_pushliteral (L, "Copyright (C) 2003-2019 Kepler Project");
lua_pushliteral (L, "Copyright (C) 2003-2020 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.5.0 (for "LUA_VERSION")");
lua_pushliteral (L, "LuaSQL 2.6.0 (for "LUA_VERSION")");
lua_settable (L, -3);
}
dependencies/luasql/src/luasql.h
void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
#endif
/* Driver initialization functions prototypes */
LUASQL_API int luaopen_luasql_firebird (lua_State *L);
LUASQL_API int luaopen_luasql_mysql (lua_State *L);
LUASQL_API int luaopen_luasql_oci8 (lua_State *L);
LUASQL_API int luaopen_luasql_odbc (lua_State *L);
LUASQL_API int luaopen_luasql_postgres (lua_State *L);
LUASQL_API int luaopen_luasql_sqlite (lua_State *L);
LUASQL_API int luaopen_luasql_sqlite3 (lua_State *L);
#endif
    (1-1/1)