Luis Rodriguez Gonzalez has proposed merging 
lp:~zorba-coders/zorba/sqlite-check-for-metadata-availability into 
lp:zorba/sqlite-module.

Requested reviews:
  Chris Hillery (ceejatec)
Related bugs:
  Bug #1102549 in Zorba: "SQLite module doesn't link on MacOS"
  https://bugs.launchpad.net/zorba/+bug/1102549

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/sqlite-check-for-metadata-availability/+merge/145041

- New feature detection code added to CMake to be sure that SQLite is able to 
read metadata (fix for Mac OSX)
-- 
https://code.launchpad.net/~zorba-coders/zorba/sqlite-check-for-metadata-availability/+merge/145041
Your team Zorba Coders is subscribed to branch lp:zorba/sqlite-module.
=== modified file 'cmake_modules/FindSQLite3.cmake'
--- cmake_modules/FindSQLite3.cmake	2012-11-20 16:41:36 +0000
+++ cmake_modules/FindSQLite3.cmake	2013-01-25 23:35:26 +0000
@@ -39,8 +39,9 @@
 
   SET(CMAKE_REQUIRED_INCLUDES "${SQLITE_INCLUDE_DIR}")
   SET(CMAKE_REQUIRED_LIBRARIES "${SQLITE_LIBRARY}")
-#  INCLUDE(CheckFunctionExists)
-#  CHECK_FUNCTION_EXISTS(archive_write_zip_set_compression_deflate #ZORBA_LIBARCHIVE_HAVE_SET_COMPRESSION)
+  
+  INCLUDE(CheckFunctionExists)
+  CHECK_FUNCTION_EXISTS(sqlite3_column_database_name ZORBA_SQLITE_HAVE_METADATA)
 ELSE (SQLITE_INCLUDE_DIR AND SQLITE_LIBRARY)
   SET (SQLITE_FOUND 0)
   SET (SQLITE_LIBRARIES)

=== modified file 'src/config.h.cmake'
--- src/config.h.cmake	2013-01-24 06:17:00 +0000
+++ src/config.h.cmake	2013-01-25 23:35:26 +0000
@@ -21,5 +21,6 @@
 #define ZORBA_SQLITE_CONFIG_H
 
 #cmakedefine SQLITE_WITH_FILE_ACCESS
+#cmakedefine ZORBA_SQLITE_HAVE_METADATA
 
 #endif /* ZORBA_SQLITE_CONFIG_H */

=== modified file 'src/sqlite_module.xq'
--- src/sqlite_module.xq	2013-01-24 06:17:00 +0000
+++ src/sqlite_module.xq	2013-01-25 23:35:26 +0000
@@ -68,6 +68,8 @@
  :
  : @error s:SQLI0001 if the databse name doesn't exist or it couldn't be opened.
  : @error s:SQLI0007 if there is any unknown option specified.
+ : @error s:SQLI0008 if a non-in-memory database is requested and the module
+ :     is built without filesystem access
  : @error s:SQLI9999 if there was an internal error inside SQLite library.
  :)
 declare %an:sequential function s:connect(
@@ -173,6 +175,8 @@
  : @return a object() with the associated the metadata.
  :
  : @error s:SQLI0004 if $pstmnt is not a valid SQLite prepared statement.
+ : @error s:SQLI0009 if no metadata is available (SQLite library compiled without
+ :     SQLITE_ENABLE_COLUMN_METADATA).
  : @error s:SQLI9999 if there was an internal error inside SQLite library.
  :)
 declare %an:sequential function s:metadata(

=== modified file 'src/sqlite_module.xq.src/sqlite_module.cpp'
--- src/sqlite_module.xq.src/sqlite_module.cpp	2013-01-24 06:17:00 +0000
+++ src/sqlite_module.xq.src/sqlite_module.cpp	2013-01-25 23:35:26 +0000
@@ -573,6 +573,12 @@
       return "Only in-memory databases are allowed (Module built without filesystem access)";
     }
 #endif /* not SQLITE_WITH_FILE_ACCESS */
+#ifndef ZORBA_SQLITE_HAVE_METADATA
+    else if(error == "SQLI0009")
+    {
+      return "Metadata not found (SQLite built without SQLITE_ENABLE_COLUMN_METADATA)";
+    }
+#endif /* not ZORBA_SQLITE_HAVE_METADATA */
     else if(error == "SQLI9999")
     {
       return "Internal error ocurred";
@@ -826,6 +832,7 @@
     int lNotNull, lPrimaryKey, lAutoinc, lRc;
 
     if(theRc == SQLITE_ROW){
+#ifdef ZORBA_SQLITE_HAVE_METADATA
       // Get the metadata for 'theActualColumn' column
       // in a key = value fashion
       lDbHandle = sqlite3_db_handle(theStmt);
@@ -867,6 +874,7 @@
       aKey = theFactory->createString("autoincrement");
       aValue = theFactory->createBoolean((lAutoinc==0)?false:true);
       elements.push_back(std::pair<zorba::Item, zorba::Item>(aKey, aValue));
+#endif
       aItem = theFactory->createJSONObject(elements);
       elements.clear();
       // Get more data if available
@@ -1068,6 +1076,7 @@
     const zorba::StaticContext* aSctx,
     const zorba::DynamicContext* aDctx) const 
   {
+#ifdef ZORBA_SQLITE_HAVE_METADATA
     sqlite3_stmt *lPstmt;
     zorba::Item lItemPstmt = getOneItem(aArgs, 0);
     zorba::Item lVecItem, lJSONKey, lJSONArray, lJSONRes;
@@ -1101,6 +1110,9 @@
     lJSONRes = lFactory->createJSONObject(lVectorRes);
     
     return ItemSequence_t(new SingletonItemSequence(lJSONRes));
+#else
+    throwError("SQLI0008", getErrorMessage("SQLI0008"));
+#endif
   }
 
 /*******************************************************************************

=== added file 'test/Queries/test3.spec'
--- test/Queries/test3.spec	1970-01-01 00:00:00 +0000
+++ test/Queries/test3.spec	2013-01-25 23:35:26 +0000
@@ -0,0 +1,1 @@
+Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0009

=== added file 'test/Queries/test4.spec'
--- test/Queries/test4.spec	1970-01-01 00:00:00 +0000
+++ test/Queries/test4.spec	2013-01-25 23:35:26 +0000
@@ -0,0 +1,1 @@
+Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0009

=== added file 'test/Queries/test5.spec'
--- test/Queries/test5.spec	1970-01-01 00:00:00 +0000
+++ test/Queries/test5.spec	2013-01-25 23:35:26 +0000
@@ -0,0 +1,1 @@
+Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0009

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to