Author: cazfi Date: Wed Apr 13 16:06:39 2016 New Revision: 32378 URL: http://svn.gna.org/viewcvs/freeciv?rev=32378&view=rev Log: Updated included luasql files to match upstream release 2.3.1.
See patch #7084 Modified: branches/S2_6/dependencies/luasql/README branches/S2_6/dependencies/luasql/Version branches/S2_6/dependencies/luasql/src/ls_mysql.c branches/S2_6/dependencies/luasql/src/ls_postgres.c branches/S2_6/dependencies/luasql/src/ls_sqlite3.c branches/S2_6/dependencies/luasql/src/luasql.c Modified: branches/S2_6/dependencies/luasql/README URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/dependencies/luasql/README?rev=32378&r1=32377&r2=32378&view=diff ============================================================================== --- branches/S2_6/dependencies/luasql/README (original) +++ branches/S2_6/dependencies/luasql/README Wed Apr 13 16:06:39 2016 @@ -1,20 +1,14 @@ -LuaSQL 2.1 -http://www.keplerproject.org/luasql/ +LuaSQL +http://keplerproject.github.io/luasql/doc/us/ LuaSQL is a simple interface from Lua to a DBMS. It enables a Lua program to: - * Connect to ODBC, ADO, Oracle, MySQL, SQLite and PostgreSQL databases; + * Connect to ODBC, ADO, Oracle, MySQL, SQLite, Firebird and PostgreSQL databases; * Execute arbitrary SQL statements; * Retrieve results in a row-by-row cursor fashion. LuaSQL is free software and uses the same license as Lua 5.1. -Source code for LuaSQL can be downloaded from the LuaForge page. +Source code for LuaSQL can be downloaded from its GitHub repository. -If you are using LuaBinaries a Windows binary version of LuaSQL can be found at the same LuaForge page. - -LuaSQL 2.1.1 [29/Oct/2007] -* Fixed a bug in the SQLite3 error handling (patch by David Burgess) -* Fixed bug [#1834] for SQLite 3 (found by Savin Zlobec, patch by Marc Nijdam) -* Fixed bug [#1770] for SQLite 3 (found by Enrico Tassi, patch by Marc Nijdam) Modified: branches/S2_6/dependencies/luasql/Version URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/dependencies/luasql/Version?rev=32378&r1=32377&r2=32378&view=diff ============================================================================== --- branches/S2_6/dependencies/luasql/Version (original) +++ branches/S2_6/dependencies/luasql/Version Wed Apr 13 16:06:39 2016 @@ -1,6 +1,6 @@ -Sources here are fron luasql git tag v2.3.0 -(https://github.com/keplerproject/luasql/tree/v2.3.0) +Sources here are fron luasql git tag v2.3.1 +(https://github.com/keplerproject/luasql/tree/v2.3.1) -Following commits since the release have been backported: -7a099cfa0eb582bdf0e641bd8e869655ef8e7f02 Use _v2 APIs for SQLite version 3.6.13 and above. -c39aba1079dce7cc57d32ccc30bd67fef8ed4cb0 Bug correction in the implementation of luaL_setfuncs +Only the files needed by freeciv are included here, not entire luasql +source directory hierarchy. +The ls_*.h files are our own additions to use those backends directly. Modified: branches/S2_6/dependencies/luasql/src/ls_mysql.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/dependencies/luasql/src/ls_mysql.c?rev=32378&r1=32377&r2=32378&view=diff ============================================================================== --- branches/S2_6/dependencies/luasql/src/ls_mysql.c (original) +++ branches/S2_6/dependencies/luasql/src/ls_mysql.c Wed Apr 13 16:06:39 2016 @@ -183,7 +183,7 @@ /* ** Closes the cursos and nullify all structure fields. */ -static void cur_nullify (lua_State *L, cur_data *cur) { +static int cur_nullify (lua_State *L, cur_data *cur) { /* Nullify structure fields. */ cur->closed = 1; mysql_free_result(cur->my_res); @@ -282,7 +282,7 @@ ** a reference to it on the cursor structure. */ static void _pushtable (lua_State *L, cur_data *cur, size_t off) { - int *ref = (int *)(cur + off/sizeof(int)); + int *ref = (int *)((char *)cur + off); /* If colnames or coltypes do not exist, create both. */ if (*ref == LUA_NOREF) @@ -316,7 +316,7 @@ ** Push the number of rows. */ static int cur_numrows (lua_State *L) { - lua_pushnumber (L, (lua_Number)mysql_num_rows (getcursor(L)->my_res)); + lua_pushinteger (L, (lua_Number)mysql_num_rows (getcursor(L)->my_res)); return 1; } @@ -409,7 +409,7 @@ else { /* mysql_use_result() returned nothing; should it have? */ if(num_cols == 0) { /* no tuples returned */ /* query does not return data (it was not a SELECT) */ - lua_pushnumber(L, mysql_affected_rows(conn->my_conn)); + lua_pushinteger(L, mysql_affected_rows(conn->my_conn)); return 1; } else /* mysql_use_result() should have returned data */ @@ -460,7 +460,7 @@ */ static int conn_getlastautoid (lua_State *L) { conn_data *conn = getconnection(L); - lua_pushnumber(L, mysql_insert_id(conn->my_conn)); + lua_pushinteger(L, mysql_insert_id(conn->my_conn)); return 1; } Modified: branches/S2_6/dependencies/luasql/src/ls_postgres.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/dependencies/luasql/src/ls_postgres.c?rev=32378&r1=32377&r2=32378&view=diff ============================================================================== --- branches/S2_6/dependencies/luasql/src/ls_postgres.c (original) +++ branches/S2_6/dependencies/luasql/src/ls_postgres.c Wed Apr 13 16:06:39 2016 @@ -320,7 +320,7 @@ static void sql_begin(conn_data *conn) { - PQclear(PQexec(conn->pg_conn, "BEGIN")); + PQclear(PQexec(conn->pg_conn, "BEGIN")); } @@ -371,14 +371,28 @@ 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; } @@ -415,7 +429,7 @@ conn_data *conn = getconnection (L); sql_commit(conn); if (conn->auto_commit == 0) { - sql_begin(conn); + sql_begin(conn); lua_pushboolean (L, 1); } else lua_pushboolean (L, 0); @@ -430,7 +444,7 @@ conn_data *conn = getconnection (L); sql_rollback(conn); if (conn->auto_commit == 0) { - sql_begin(conn); + sql_begin(conn); lua_pushboolean (L, 1); } else lua_pushboolean (L, 0); Modified: branches/S2_6/dependencies/luasql/src/ls_sqlite3.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/dependencies/luasql/src/ls_sqlite3.c?rev=32378&r1=32377&r2=32378&view=diff ============================================================================== --- branches/S2_6/dependencies/luasql/src/ls_sqlite3.c (original) +++ branches/S2_6/dependencies/luasql/src/ls_sqlite3.c Wed Apr 13 16:06:39 2016 @@ -126,7 +126,12 @@ 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)); Modified: branches/S2_6/dependencies/luasql/src/luasql.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/dependencies/luasql/src/luasql.c?rev=32378&r1=32377&r2=32378&view=diff ============================================================================== --- branches/S2_6/dependencies/luasql/src/luasql.c (original) +++ branches/S2_6/dependencies/luasql/src/luasql.c Wed Apr 13 16:06:39 2016 @@ -70,9 +70,9 @@ luaL_checkstack(L, nup+1, "too many upvalues"); for (; l->name != NULL; l++) { /* fill the table with given functions */ int i; - lua_pushstring(L, l->name); + lua_pushstring(L, l->name); for (i = 0; i < nup; i++) /* copy upvalues to the top */ - lua_pushvalue(L, -(nup + 1)); + lua_pushvalue(L, -(nup + 1)); lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ lua_settable(L, -(nup + 3)); } @@ -122,12 +122,12 @@ */ 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); } _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits