On 18-01-05 22:29:07, Landry Breuil wrote:
> Hi,
> 
> while playing with lua & nginx, i stumbled upon
> https://github.com/mwild1/luadbi which is an updated fork of the dead
> upstream luadbi on code.google.com - this one is maintained by a prosody
> developer, and he even released a 0.6 version. $SEARCHENGINE will prefer
> to show you https://github.com/snatchev/Luadbi when loooking for luadbi
> but this one saw no commits...
> 
> builds fine here, and it still seems to connect fine to a postgresql
> database i have lying around. Testing with prosody (backed by a database
> ofc) would be very much welcome.

 Prosody with PostgreSQL, everything (user auth, MAM) still working
 fine.
 
> Landry

> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/databases/luadbi/Makefile,v
> retrieving revision 1.11
> diff -u -r1.11 Makefile
> --- Makefile  21 Aug 2017 18:49:30 -0000      1.11
> +++ Makefile  5 Jan 2018 21:25:22 -0000
> @@ -4,22 +4,19 @@
>  COMMENT-mysql=       MySQL driver for luadbi
>  COMMENT-pgsql=       PostgreSQL driver for luadbi
>  
> -V=           0.5
> -DISTNAME=    luadbi.$V
> -PKGNAME-main=        luadbi-$V
> -PKGNAME-mysql=       luadbi-mysql-$V
> -PKGNAME-pgsql=       luadbi-pgsql-$V
> -REVISION-main=       2
> -REVISION-mysql=      4
> -REVISION-pgsql=      1
> +GH_ACCOUNT=  mwild1
> +GH_PROJECT=  luadbi
> +V=           0.6
> +GH_TAGNAME=  v${V}
> +PKGNAME-main=        ${GH_PROJECT}-${V}
> +PKGNAME-mysql=       ${GH_PROJECT}-mysql-$V
> +PKGNAME-pgsql=       ${GH_PROJECT}-pgsql-$V
>  
>  CATEGORIES=  databases
>  
>  # MIT
>  PERMIT_PACKAGE_CDROM=        Yes
>  
> -MASTER_SITES=                https://distfiles.nl/
> -
>  MULTI_PACKAGES=              -main -mysql -pgsql
>  
>  WANTLIB-main=                sqlite3
> @@ -40,20 +37,18 @@
>  USE_GMAKE=           Yes
>  
>  ALL_TARGET=          free # == sqlite3 mysql postgresql
> +INSTALL_TARGET=              install_free
> +# requires luarocks
>  NO_TEST=             Yes
>  
>  MAKE_FLAGS=  CC="${CC}" \
>               COMMON_LDFLAGS="-L${LOCALBASE}/lib" \
> -             CFLAGS="${CFLAGS} -I${MODLUA_INCL_DIR} -I${LOCALBASE}/include 
> -I${LOCALBASE}/include/mysql \
> -                     -I${LOCALBASE}/include/postgresql/ 
> -I${LOCALBASE}/include/postgresql/server \
> -                     -I. -fpic -shared"
> -
> -WRKDIST=     ${WRKDIR}
> -
> -do-install:
> -     ${INSTALL_DATA_DIR} ${MODLUA_LIBDIR} ${MODLUA_DATADIR}
> -     ${INSTALL_DATA} ${WRKSRC}/DBI.lua ${MODLUA_DATADIR}
> -# XXX: Not using INSTALL_PROGRAM, it strips the library.
> -     ${INSTALL_SCRIPT} ${WRKSRC}/*.so ${MODLUA_LIBDIR}
> +             LUA_INC="-I${MODLUA_INCL_DIR}" \
> +             MYSQL_INC="-I${LOCALBASE}/include/mysql" \
> +             SQLITE3_INC="-I${LOCALBASE}/include" \
> +             PSQL_INC="-I${LOCALBASE}/include/postgresql"
> +
> +FAKE_FLAGS=  LUA_LDIR=${MODLUA_DATADIR} \
> +             LUA_CDIR=${MODLUA_LIBDIR}
>  
>  .include <bsd.port.mk>
> Index: distinfo
> ===================================================================
> RCS file: /cvs/ports/databases/luadbi/distinfo,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 distinfo
> --- distinfo  16 Aug 2012 15:21:30 -0000      1.1.1.1
> +++ distinfo  5 Jan 2018 21:25:22 -0000
> @@ -1,2 +1,2 @@
> -SHA256 (luadbi.0.5.tar.gz) = SRFkWN2ABSU2v11+KyofWg+kKmcc538ctzVe9/rrMx4=
> -SIZE (luadbi.0.5.tar.gz) = 22454
> +SHA256 (luadbi-0.6.tar.gz) = QyiaVdlF4AzRkN9RX2CUgq9G7VkookzOZuppJfS30lU=
> +SIZE (luadbi-0.6.tar.gz) = 28621
> Index: patches/patch-dbd_sqlite3_connection_c
> ===================================================================
> RCS file: patches/patch-dbd_sqlite3_connection_c
> diff -N patches/patch-dbd_sqlite3_connection_c
> --- patches/patch-dbd_sqlite3_connection_c    16 Aug 2012 15:21:30 -0000      
> 1.1.1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,111 +0,0 @@
> -$OpenBSD: patch-dbd_sqlite3_connection_c,v 1.1.1.1 2012/08/16 15:21:30 
> jasper Exp $
> -
> -Fix DBD.SQLite3 transaction handling
> -From upstream svn rev 75
> -
> ---- dbd/sqlite3/connection.c.orig    Sat May  1 06:25:12 2010
> -+++ dbd/sqlite3/connection.c Sun Jul 22 22:23:54 2012
> -@@ -9,20 +9,37 @@ static int run(connection_t *conn, const char *command
> - }
> - 
> - static int commit(connection_t *conn) {
> --    return run(conn, "COMMIT");
> -+    conn->txn_in_progress = 0;
> -+    return run(conn, "COMMIT TRANSACTION");
> - }
> - 
> - 
> - static int begin(connection_t *conn) {
> --    return run(conn, "BEGIN");
> --}
> -+    int err = 0;
> - 
> -+    if (conn->txn_in_progress) {
> -+        err = 0;
> -+    } else {
> -+        conn->txn_in_progress = 1;
> -+        err = run(conn, "BEGIN TRANSACTION");
> -+    }
> - 
> -+    return err;
> -+}
> -+
> - static int rollback(connection_t *conn) {
> --    return run(conn, "ROLLBACK");
> -+    conn->txn_in_progress = 0;
> -+    return run(conn, "ROLLBACK TRANSACTION");
> - }
> - 
> -+int try_begin_transaction(connection_t *conn) {
> -+    if (conn->autocommit) {
> -+        return 1;
> -+    }
> - 
> -+    return begin(conn) == 0;
> -+}
> -+
> - /* 
> -  * connection,err = DBD.SQLite3.New(dbfile)
> -  */
> -@@ -50,7 +67,7 @@ static int connection_new(lua_State *L) {
> -     }
> - 
> -     conn->autocommit = 0;
> --    begin(conn);
> -+    conn->txn_in_progress = 0;
> - 
> -     luaL_getmetatable(L, DBD_SQLITE_CONNECTION);
> -     lua_setmetatable(L, -2);
> -@@ -67,10 +84,13 @@ static int connection_autocommit(lua_State *L) {
> -     int err = 1;
> - 
> -     if (conn->sqlite) {
> --    if (on)
> -+    if (on) {
> -         err = rollback(conn);
> -+        }
> -+        /*
> -     else
> -         err = begin(conn);
> -+        */
> - 
> -     conn->autocommit = on;  
> -     }
> -@@ -88,6 +108,7 @@ static int connection_close(lua_State *L) {
> -     int disconnect = 0;   
> - 
> -     if (conn->sqlite) {
> -+        rollback(conn);
> -     sqlite3_close(conn->sqlite);
> -     disconnect = 1;
> -     conn->sqlite = NULL;
> -@@ -105,12 +126,7 @@ static int connection_commit(lua_State *L) {
> -     int err = 1;
> - 
> -     if (conn->sqlite) {
> --    commit(conn);
> --
> --    if (!conn->autocommit)
> --        err = begin(conn);
> --    else
> --        err = 1;
> -+    err = commit(conn);
> -     }
> - 
> -     lua_pushboolean(L, !err);
> -@@ -176,12 +192,14 @@ static int connection_rollback(lua_State *L) {
> -     int err = 1;
> - 
> -     if (conn->sqlite) {
> --    rollback(conn);
> -+    err =rollback(conn);
> - 
> -+        /*
> -     if (!conn->autocommit)
> -         err = begin(conn);
> -     else
> -         err = 1;
> -+        */
> -     }
> - 
> -     lua_pushboolean(L, !err);
> Index: patches/patch-dbd_sqlite3_dbd_sqlite3_h
> ===================================================================
> RCS file: patches/patch-dbd_sqlite3_dbd_sqlite3_h
> diff -N patches/patch-dbd_sqlite3_dbd_sqlite3_h
> --- patches/patch-dbd_sqlite3_dbd_sqlite3_h   16 Aug 2012 15:21:30 -0000      
> 1.1.1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,24 +0,0 @@
> -$OpenBSD: patch-dbd_sqlite3_dbd_sqlite3_h,v 1.1.1.1 2012/08/16 15:21:30 
> jasper Exp $
> -
> -Fix DBD.SQLite3 transaction handling
> -From upstream svn rev 75
> -
> ---- dbd/sqlite3/dbd_sqlite3.h.orig   Fri Dec 19 07:33:32 2008
> -+++ dbd/sqlite3/dbd_sqlite3.h        Sun Jul 22 22:23:54 2012
> -@@ -10,14 +10,15 @@
> - typedef struct _connection {
> -     sqlite3 *sqlite;
> -     int autocommit;
> -+    int txn_in_progress;
> - } connection_t;
> - 
> - /*
> -  * statement object
> -  */
> - typedef struct _statement {
> -+    connection_t *conn;
> -     sqlite3_stmt *stmt;
> --    sqlite3 *sqlite;
> -     int more_data;
> -     int affected;
> - } statement_t;
> Index: patches/patch-dbd_sqlite3_statement_c
> ===================================================================
> RCS file: patches/patch-dbd_sqlite3_statement_c
> diff -N patches/patch-dbd_sqlite3_statement_c
> --- patches/patch-dbd_sqlite3_statement_c     16 Aug 2012 15:21:30 -0000      
> 1.1.1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,81 +0,0 @@
> -$OpenBSD: patch-dbd_sqlite3_statement_c,v 1.1.1.1 2012/08/16 15:21:30 jasper 
> Exp $
> -
> -Fix DBD.SQLite3 transaction handling
> -From upstream svn rev 75
> -
> ---- dbd/sqlite3/statement.c.orig     Sat May  1 06:25:12 2010
> -+++ dbd/sqlite3/statement.c  Sun Jul 22 22:23:54 2012
> -@@ -1,5 +1,8 @@
> - #include "dbd_sqlite3.h"
> - 
> -+extern int try_begin_transaction(connection_t *conn);
> -+extern int try_end_transaction(connection_t *conn);
> -+
> - /*
> -  * Converts SQLite types to Lua types
> -  */
> -@@ -128,10 +131,12 @@ static int statement_execute(lua_State *L) {
> -      */
> -     if (sqlite3_reset(statement->stmt) != SQLITE_OK) {
> -     lua_pushboolean(L, 0);
> --    lua_pushfstring(L, DBI_ERR_EXECUTE_FAILED, 
> sqlite3_errmsg(statement->sqlite));
> -+    lua_pushfstring(L, DBI_ERR_EXECUTE_FAILED, 
> sqlite3_errmsg(statement->conn->sqlite));
> -     return 2;
> -     }
> - 
> -+    sqlite3_clear_bindings(statement->stmt);
> -+
> -     expected_params = sqlite3_bind_parameter_count(statement->stmt);
> -     if (expected_params != num_bind_params) {
> -     /*
> -@@ -180,18 +185,20 @@ static int statement_execute(lua_State *L) {
> -     if (errstr)
> -         lua_pushfstring(L, DBI_ERR_BINDING_PARAMS, errstr);
> -     else
> --        lua_pushfstring(L, DBI_ERR_BINDING_PARAMS, 
> sqlite3_errmsg(statement->sqlite));
> -+        lua_pushfstring(L, DBI_ERR_BINDING_PARAMS, 
> sqlite3_errmsg(statement->conn->sqlite));
> -     
> -     return 2;
> -     }
> -+    
> -+    try_begin_transaction(statement->conn);
> - 
> -     if (!step(statement)) {
> -     lua_pushboolean(L, 0);
> --    lua_pushfstring(L, DBI_ERR_EXECUTE_FAILED, 
> sqlite3_errmsg(statement->sqlite));
> -+    lua_pushfstring(L, DBI_ERR_EXECUTE_FAILED, 
> sqlite3_errmsg(statement->conn->sqlite));
> -     return 2;
> -     }
> - 
> --    statement->affected = sqlite3_changes(statement->sqlite);
> -+    statement->affected = sqlite3_changes(statement->conn->sqlite);
> - 
> -     lua_pushboolean(L, 1);
> -     return 1;
> -@@ -283,7 +290,7 @@ static int statement_fetch_impl(lua_State *L, statemen
> -         /* 
> -          * reset needs to be called to retrieve the 'real' error message
> -          */
> --        luaL_error(L, DBI_ERR_FETCH_FAILED, 
> sqlite3_errmsg(statement->sqlite));
> -+        luaL_error(L, DBI_ERR_FETCH_FAILED, 
> sqlite3_errmsg(statement->conn->sqlite));
> -     }
> -     }
> - 
> -@@ -357,14 +364,14 @@ int dbd_sqlite3_statement_create(lua_State *L, connect
> -     statement_t *statement = NULL;
> - 
> -     statement = (statement_t *)lua_newuserdata(L, sizeof(statement_t));
> --    statement->sqlite = conn->sqlite;
> -+    statement->conn = conn;
> -     statement->stmt = NULL;
> -     statement->more_data = 0;
> -     statement->affected = 0;
> - 
> --    if (sqlite3_prepare_v2(statement->sqlite, sql_query, strlen(sql_query), 
> &statement->stmt, NULL) != SQLITE_OK) {
> -+    if (sqlite3_prepare_v2(statement->conn->sqlite, sql_query, 
> strlen(sql_query), &statement->stmt, NULL) != SQLITE_OK) {
> -     lua_pushnil(L);
> --    lua_pushfstring(L, DBI_ERR_PREP_STATEMENT, 
> sqlite3_errmsg(statement->sqlite));  
> -+    lua_pushfstring(L, DBI_ERR_PREP_STATEMENT, 
> sqlite3_errmsg(statement->conn->sqlite));    
> -     return 2;
> -     } 
> - 
> Index: pkg/PLIST-main
> ===================================================================
> RCS file: /cvs/ports/databases/luadbi/pkg/PLIST-main,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 PLIST-main
> --- pkg/PLIST-main    16 Aug 2012 15:21:30 -0000      1.1.1.1
> +++ pkg/PLIST-main    5 Jan 2018 21:25:22 -0000
> @@ -1,3 +1,3 @@
>  @comment $OpenBSD: PLIST-main,v 1.1.1.1 2012/08/16 15:21:30 jasper Exp $
> -lib/lua/${MODLUA_VERSION}/dbdsqlite3.so
> +lib/lua/${MODLUA_VERSION}/dbd/sqlite3.so
>  share/lua/${MODLUA_VERSION}/DBI.lua
> Index: pkg/PLIST-mysql
> ===================================================================
> RCS file: /cvs/ports/databases/luadbi/pkg/PLIST-mysql,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 PLIST-mysql
> --- pkg/PLIST-mysql   16 Aug 2012 15:21:30 -0000      1.1.1.1
> +++ pkg/PLIST-mysql   5 Jan 2018 21:25:22 -0000
> @@ -1,2 +1,2 @@
>  @comment $OpenBSD: PLIST-mysql,v 1.1.1.1 2012/08/16 15:21:30 jasper Exp $
> -lib/lua/${MODLUA_VERSION}/dbdmysql.so
> +lib/lua/${MODLUA_VERSION}/dbd/mysql.so
> Index: pkg/PLIST-pgsql
> ===================================================================
> RCS file: /cvs/ports/databases/luadbi/pkg/PLIST-pgsql,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 PLIST-pgsql
> --- pkg/PLIST-pgsql   16 Aug 2012 15:21:30 -0000      1.1.1.1
> +++ pkg/PLIST-pgsql   5 Jan 2018 21:25:22 -0000
> @@ -1,2 +1,2 @@
>  @comment $OpenBSD: PLIST-pgsql,v 1.1.1.1 2012/08/16 15:21:30 jasper Exp $
> -lib/lua/${MODLUA_VERSION}/dbdpostgresql.so
> +lib/lua/${MODLUA_VERSION}/dbd/postgresql.so

Reply via email to