Merge lp:~zorba-coders/zorba/sqlite-check-for-metadata-availability into lp:zorba/sqlite-module

Proposed by Luis Rodriguez Gonzalez
Status: Merged
Approved by: Chris Hillery
Approved revision: 32
Merged at revision: 30
Proposed branch: lp:~zorba-coders/zorba/sqlite-check-for-metadata-availability
Merge into: lp:zorba/sqlite-module
Diff against target: 147 lines (+26/-3)
8 files modified
cmake_modules/FindSQLite3.cmake (+3/-2)
src/config.h.cmake (+1/-0)
src/sqlite_module.xq (+4/-0)
src/sqlite_module.xq.src/sqlite_module.cpp (+13/-1)
src/sqlite_module.xq.src/sqlite_module.h (+2/-0)
test/Queries/test3.spec (+1/-0)
test/Queries/test4.spec (+1/-0)
test/Queries/test5.spec (+1/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/sqlite-check-for-metadata-availability
Reviewer Review Type Date Requested Status
William Candillon Approve
Chris Hillery Approve
Review via email: mp+145041@code.launchpad.net

Commit message

- New feature detection code added to CMake to be sure that SQLite is able to read metadata (fix for Mac OSX)

Description of the change

- New feature detection code added to CMake to be sure that SQLite is able to read metadata (fix for Mac OSX)

To post a comment you must log in.
31. By Luis Rodriguez Gonzalez

- Fixed bug that affected the error message when trying to use metadata() with a SQLite library that cannot retrieve metadata.

Revision history for this message
Chris Hillery (ceejatec) wrote :

Unless I'm missing something, it'd be cleaner to avoid the compilation of JSONMetadataItemSequence entirely by #ifdef-ing out the class and method definitions in the .cpp and .h files.

review: Needs Fixing
32. By Luis Rodriguez Gonzalez

JSONMetadataItemSequence is now ommited if sqlite is not compiled with Metadata information.

Revision history for this message
Luis Rodriguez Gonzalez (kuraru) wrote :

I think this branch is corrected as Chris suggested. Please re-review.

Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
William Candillon (wcandillon) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job sqlite-check-for-metadata-availability-2013-04-30T18-03-45.308Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmake_modules/FindSQLite3.cmake'
2--- cmake_modules/FindSQLite3.cmake 2012-11-20 16:41:36 +0000
3+++ cmake_modules/FindSQLite3.cmake 2013-02-18 22:18:20 +0000
4@@ -39,8 +39,9 @@
5
6 SET(CMAKE_REQUIRED_INCLUDES "${SQLITE_INCLUDE_DIR}")
7 SET(CMAKE_REQUIRED_LIBRARIES "${SQLITE_LIBRARY}")
8-# INCLUDE(CheckFunctionExists)
9-# CHECK_FUNCTION_EXISTS(archive_write_zip_set_compression_deflate #ZORBA_LIBARCHIVE_HAVE_SET_COMPRESSION)
10+
11+ INCLUDE(CheckFunctionExists)
12+ CHECK_FUNCTION_EXISTS(sqlite3_column_database_name ZORBA_SQLITE_HAVE_METADATA)
13 ELSE (SQLITE_INCLUDE_DIR AND SQLITE_LIBRARY)
14 SET (SQLITE_FOUND 0)
15 SET (SQLITE_LIBRARIES)
16
17=== modified file 'src/config.h.cmake'
18--- src/config.h.cmake 2013-01-24 06:17:00 +0000
19+++ src/config.h.cmake 2013-02-18 22:18:20 +0000
20@@ -21,5 +21,6 @@
21 #define ZORBA_SQLITE_CONFIG_H
22
23 #cmakedefine SQLITE_WITH_FILE_ACCESS
24+#cmakedefine ZORBA_SQLITE_HAVE_METADATA
25
26 #endif /* ZORBA_SQLITE_CONFIG_H */
27
28=== modified file 'src/sqlite_module.xq'
29--- src/sqlite_module.xq 2013-01-24 06:17:00 +0000
30+++ src/sqlite_module.xq 2013-02-18 22:18:20 +0000
31@@ -68,6 +68,8 @@
32 :
33 : @error s:SQLI0001 if the databse name doesn't exist or it couldn't be opened.
34 : @error s:SQLI0007 if there is any unknown option specified.
35+ : @error s:SQLI0008 if a non-in-memory database is requested and the module
36+ : is built without filesystem access
37 : @error s:SQLI9999 if there was an internal error inside SQLite library.
38 :)
39 declare %an:sequential function s:connect(
40@@ -173,6 +175,8 @@
41 : @return a object() with the associated the metadata.
42 :
43 : @error s:SQLI0004 if $pstmnt is not a valid SQLite prepared statement.
44+ : @error s:SQLI0009 if no metadata is available (SQLite library compiled without
45+ : SQLITE_ENABLE_COLUMN_METADATA).
46 : @error s:SQLI9999 if there was an internal error inside SQLite library.
47 :)
48 declare %an:sequential function s:metadata(
49
50=== modified file 'src/sqlite_module.xq.src/sqlite_module.cpp'
51--- src/sqlite_module.xq.src/sqlite_module.cpp 2013-01-24 06:17:00 +0000
52+++ src/sqlite_module.xq.src/sqlite_module.cpp 2013-02-18 22:18:20 +0000
53@@ -30,8 +30,8 @@
54 #include <iostream>
55 #include <stdio.h>
56
57+#include <sqlite_module/config.h>
58 #include "sqlite_module.h"
59-#include <sqlite_module/config.h>
60
61 namespace zorba { namespace sqlite {
62
63@@ -573,6 +573,12 @@
64 return "Only in-memory databases are allowed (Module built without filesystem access)";
65 }
66 #endif /* not SQLITE_WITH_FILE_ACCESS */
67+#ifndef ZORBA_SQLITE_HAVE_METADATA
68+ else if(error == "SQLI0009")
69+ {
70+ return "Metadata not found (SQLite built without SQLITE_ENABLE_COLUMN_METADATA)";
71+ }
72+#endif /* not ZORBA_SQLITE_HAVE_METADATA */
73 else if(error == "SQLI9999")
74 {
75 return "Internal error ocurred";
76@@ -795,6 +801,7 @@
77 /*******************************************************************************
78 * JSONMetadataItemSequence::JSONMetadataIterator *
79 ******************************************************************************/
80+#ifdef ZORBA_SQLITE_HAVE_METADATA
81 void JSONMetadataItemSequence::JSONMetadataIterator::open(){
82 // Get data and create the column names
83 if(theStmt != NULL){
84@@ -888,6 +895,7 @@
85 if(theStmt != NULL)
86 sqlite3_reset(theStmt);
87 }
88+#endif
89
90 /*******************************************************************************
91 ******************************************************************************/
92@@ -1068,6 +1076,7 @@
93 const zorba::StaticContext* aSctx,
94 const zorba::DynamicContext* aDctx) const
95 {
96+#ifdef ZORBA_SQLITE_HAVE_METADATA
97 sqlite3_stmt *lPstmt;
98 zorba::Item lItemPstmt = getOneItem(aArgs, 0);
99 zorba::Item lVecItem, lJSONKey, lJSONArray, lJSONRes;
100@@ -1101,6 +1110,9 @@
101 lJSONRes = lFactory->createJSONObject(lVectorRes);
102
103 return ItemSequence_t(new SingletonItemSequence(lJSONRes));
104+#else
105+ throwError("SQLI0009", getErrorMessage("SQLI0009"));
106+#endif
107 }
108
109 /*******************************************************************************
110
111=== modified file 'src/sqlite_module.xq.src/sqlite_module.h'
112--- src/sqlite_module.xq.src/sqlite_module.h 2013-01-10 21:55:06 +0000
113+++ src/sqlite_module.xq.src/sqlite_module.h 2013-02-18 22:18:20 +0000
114@@ -158,6 +158,7 @@
115
116 /*******************************************************************************
117 ******************************************************************************/
118+#ifdef ZORBA_SQLITE_HAVE_METADATA
119 class JSONMetadataItemSequence : public ItemSequence
120 {
121 public:
122@@ -204,6 +205,7 @@
123 zorba::Iterator_t
124 getIterator() { return new JSONMetadataIterator(thePrepStmt); }
125 };
126+#endif
127
128 /*******************************************************************************
129 ******************************************************************************/
130
131=== added file 'test/Queries/test3.spec'
132--- test/Queries/test3.spec 1970-01-01 00:00:00 +0000
133+++ test/Queries/test3.spec 2013-02-18 22:18:20 +0000
134@@ -0,0 +1,1 @@
135+Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0009
136
137=== added file 'test/Queries/test4.spec'
138--- test/Queries/test4.spec 1970-01-01 00:00:00 +0000
139+++ test/Queries/test4.spec 2013-02-18 22:18:20 +0000
140@@ -0,0 +1,1 @@
141+Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0009
142
143=== added file 'test/Queries/test5.spec'
144--- test/Queries/test5.spec 1970-01-01 00:00:00 +0000
145+++ test/Queries/test5.spec 2013-02-18 22:18:20 +0000
146@@ -0,0 +1,1 @@
147+Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0009

Subscribers

People subscribed via source and target branches

to all changes: