LumoSQL/archive1-LumoSQL-on-github

Compile error with LMDB >= 0.9.19

Closed this issue · 3 comments

Error message
✂
./libtool --mode=compile --tag=CC gcc   -I../lmdb/libraries/liblmdb -DSQLITE_OS_UNIX=1 -I. -I../sqlightning/src -I../sqlightning/ext/rtree -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite -DNDEBUG  -I/usr/include -DSQLITE_THREADSAFE=1 -DSQLITE_OMIT_LOAD_EXTENSION=1   -DSQLITE_TEMP_STORE=1 -c sqlite3.c
libtool: compile:  gcc -I../lmdb/libraries/liblmdb -DSQLITE_OS_UNIX=1 -I. -I../sqlightning/src -I../sqlightning/ext/rtree -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite -DNDEBUG -I/usr/include -DSQLITE_THREADSAFE=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_TEMP_STORE=1 -c sqlite3.c  -fPIC -DPIC -o .libs/sqlite3.o
sqlite3.c: In function ‘sqlite3BtreePutData’:
sqlite3.c:37311:19: warning: passing argument 1 of ‘mdb_node_read’ from incompatible pointer type [-Wincompatible-pointer-types]
37311 |   mdb_node_read(mc->mc_txn, node, &data);
      |                 ~~^~~~~~~~
      |                   |
      |                   MDB_txn * {aka struct MDB_txn *}
In file included from sqlite3.c:37102:
../lmdb/libraries/liblmdb/mdb.c:5703:27: note: expected ‘MDB_cursor *’ {aka ‘struct MDB_cursor *’} but argument is of type ‘MDB_txn *’ {aka ‘struct MDB_txn *’}
 5703 | mdb_node_read(MDB_cursor *mc, MDB_node *leaf, MDB_val *data)
      |               ~~~~~~~~~~~~^~
sqlite3.c: In function ‘sqlite3BtreeClose’:
sqlite3.c:37458:37: error: ‘LOCKSUFF’ undeclared (first use in this function)
37458 |  path = sqlite3_malloc(len + sizeof(LOCKSUFF));
      |                                     ^~~~~~~~
sqlite3.c:37458:37: note: each undeclared identifier is reported only once for each function it appears in
sqlite3.c: In function ‘sqlite3BtreeData’:
sqlite3.c:37799:19: warning: passing argument 1 of ‘mdb_node_read’ from incompatible pointer type [-Wincompatible-pointer-types]
37799 |   mdb_node_read(mc->mc_txn, node, &data);
      |                 ~~^~~~~~~~
      |                   |
      |                   MDB_txn * {aka struct MDB_txn *}
In file included from sqlite3.c:37102:
../lmdb/libraries/liblmdb/mdb.c:5703:27: note: expected ‘MDB_cursor *’ {aka ‘struct MDB_cursor *’} but argument is of type ‘MDB_txn *’ {aka ‘struct MDB_txn *’}
 5703 | mdb_node_read(MDB_cursor *mc, MDB_node *leaf, MDB_val *data)
      |               ~~~~~~~~~~~~^~
sqlite3.c: In function ‘sqlite3BtreeDataFetch’:
sqlite3.c:37859:21: warning: passing argument 1 of ‘mdb_node_read’ from incompatible pointer type [-Wincompatible-pointer-types]
37859 |     mdb_node_read(mc->mc_txn, node, &data);
      |                   ~~^~~~~~~~
      |                     |
      |                     MDB_txn * {aka struct MDB_txn *}
In file included from sqlite3.c:37102:
../lmdb/libraries/liblmdb/mdb.c:5703:27: note: expected ‘MDB_cursor *’ {aka ‘struct MDB_cursor *’} but argument is of type ‘MDB_txn *’ {aka ‘struct MDB_txn *’}
 5703 | mdb_node_read(MDB_cursor *mc, MDB_node *leaf, MDB_val *data)
      |               ~~~~~~~~~~~~^~
sqlite3.c: In function ‘sqlite3BtreeDataSize’:
sqlite3.c:37884:21: warning: passing argument 1 of ‘mdb_node_read’ from incompatible pointer type [-Wincompatible-pointer-types]
37884 |     mdb_node_read(mc->mc_txn, node, &data);
      |                   ~~^~~~~~~~
      |                     |
      |                     MDB_txn * {aka struct MDB_txn *}
In file included from sqlite3.c:37102:
../lmdb/libraries/liblmdb/mdb.c:5703:27: note: expected ‘MDB_cursor *’ {aka ‘struct MDB_cursor *’} but argument is of type ‘MDB_txn *’ {aka ‘struct MDB_txn *’}
 5703 | mdb_node_read(MDB_cursor *mc, MDB_node *leaf, MDB_val *data)
      |               ~~~~~~~~~~~~^~
sqlite3.c: In function ‘sqlite3BtreeInsert’:
sqlite3.c:38274:18: warning: passing argument 1 of ‘mdb_node_read’ from incompatible pointer type [-Wincompatible-pointer-types]
38274 |  mdb_node_read(mc->mc_txn, node, &data);
      |                ~~^~~~~~~~
      |                  |
      |                  MDB_txn * {aka struct MDB_txn *}
In file included from sqlite3.c:37102:
../lmdb/libraries/liblmdb/mdb.c:5703:27: note: expected ‘MDB_cursor *’ {aka ‘struct MDB_cursor *’} but argument is of type ‘MDB_txn *’ {aka ‘struct MDB_txn *’}
 5703 | mdb_node_read(MDB_cursor *mc, MDB_node *leaf, MDB_val *data)
      |               ~~~~~~~~~~~~^~
sqlite3.c: In function ‘sqlite3BtreeOpen’:
sqlite3.c:38657:48: error: ‘LOCKSUFF’ undeclared (first use in this function)
38657 |    pBt->lockname = sqlite3_malloc(len + sizeof(LOCKSUFF));
      |                                                ^~~~~~~~
sqlite3.c:38664:31: error: expected ‘)’ before ‘LOCKSUFF’
38664 |    sprintf(pBt->lockname, "%s" LOCKSUFF, dirPathName);
      |                               ^~~~~~~~~
      |                               )
make: *** [Makefile:553: sqlite3.lo] Error 1
make: Leaving directory '/run/host/var/srv/lumosql/bld-mdb'

make bld-LMDB_0.9.19 or make bld-LMDB_0.9.21 will now reproduce this error

diff --git a/src/btree.c b/src/btree.c
index 19a4bac..fb0b084 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -5,6 +5,16 @@
 #include "mdb.c"
 #include "midl.c"
 
+#ifndef LOCKSUFF
+#define LOCKSUFF (mdb_suffixes[1][1])
+#endif
+
+#if MDB_VERSION_FULL < MDB_VERINT(0,9,19)
+#define MC_READ(mc) (mc)->mc_txn
+#else
+#define MC_READ(mc) (mc)
+#endif
+
 #if 0
 #define LOG(fmt,...)   sqlite3DebugPrintf("%s:%d " fmt "\n", __func__, __LINE__, __VA_ARGS__)
 #else
@@ -211,7 +221,7 @@ int sqlite3BtreePutData(BtCursor *pCsr, u32 offset, u32 amt, void *z){
        return errmap(rc);
 
   node = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
-  mdb_node_read(mc->mc_txn, node, &data);
+  mdb_node_read(MC_READ(mc), node, &data);
   if (data.mv_size < offset+amt)
        return SQLITE_CORRUPT_BKPT;
 
@@ -699,7 +709,7 @@ int sqlite3BtreeData(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
   MDB_node *node = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
   int rc = SQLITE_OK;
   
-  mdb_node_read(mc->mc_txn, node, &data);
+  mdb_node_read(MC_READ(mc), node, &data);
   if (offset+amt <= data.mv_size) {
     memcpy(pBuf, (char *)data.mv_data+offset, amt);
   } else {
@@ -759,7 +769,7 @@ const void *sqlite3BtreeDataFetch(BtCursor *pCur, int *pAmt){
   }
   if(mc->mc_flags & C_INITIALIZED) {
        MDB_node *node = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
-    mdb_node_read(mc->mc_txn, node, &data);
+    mdb_node_read(MC_READ(mc), node, &data);
        *pAmt = data.mv_size;
        return data.mv_data;
   } else {
@@ -784,7 +794,7 @@ int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
   MDB_val data;
   if(mc->mc_flags & C_INITIALIZED) {
        MDB_node *node = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
-    mdb_node_read(mc->mc_txn, node, &data);
+    mdb_node_read(MC_READ(mc), node, &data);
        *pSize = data.mv_size;
   }
   LOG("done",0);
@@ -1174,7 +1184,7 @@ int sqlite3BtreeInsert(
     sqlite3DbFree(pCur->pKeyInfo->db, pFree);
   else if (nZero && rc == 0) {
        MDB_node *node = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
-       mdb_node_read(mc->mc_txn, node, &data);
+       mdb_node_read(MC_READ(mc), node, &data);
        memset((char *)data.mv_data+nData, 0, nZero);
   }
   LOG("rc=%d",rc);
@@ -1564,7 +1574,7 @@ int sqlite3BtreeOpen(
                rc = SQLITE_NOMEM;
                goto done;
          }
-         sprintf(pBt->lockname, "%s" LOCKSUFF, dirPathName);
+         sprintf(pBt->lockname, "%s%s", dirPathName,  LOCKSUFF);
        }
        pBt->db = db;
        pBt->openFlags = flags;