← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug-1189784 into lp:zorba/sqlite-module

 

Luis Rodriguez Gonzalez has proposed merging lp:~zorba-coders/zorba/bug-1189784 into lp:zorba/sqlite-module.

Requested reviews:
  Luis Rodriguez Gonzalez (kuraru)
  Chris Hillery (ceejatec)
Related bugs:
  Bug #1189784 in Zorba: "Update non-core module "sqlite""
  https://bugs.launchpad.net/zorba/+bug/1189784

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1189784/+merge/177489
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1189784/+merge/177489
Your team Zorba Coders is subscribed to branch lp:zorba/sqlite-module.
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt	2013-01-24 06:17:00 +0000
+++ src/CMakeLists.txt	2013-07-29 22:35:31 +0000
@@ -17,7 +17,7 @@
 INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
   
 DECLARE_ZORBA_MODULE (
-  URI "http://www.zorba-xquery.com/modules/sqlite";
+  URI "http://zorba.io/modules/sqlite";
   VERSION 1.0
   FILE "sqlite_module.xq"
   LINK_LIBRARIES "${SQLITE_LIBRARIES}")

=== modified file 'src/sqlite_module.xq'
--- src/sqlite_module.xq	2013-06-15 19:48:35 +0000
+++ src/sqlite_module.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-xquery version "3.0";
+jsoniq version "1.0";
 
 (:
  : Copyright 2012 The FLWOR Foundation.
@@ -17,15 +17,15 @@
  :)
 
 (:~
- : <p>This module provides functionality to extract, add and modify data 
- : from SQLite databases.</p>
+ : This module provides functionality to extract, add and modify data 
+ : from SQLite databases.<p/>
  :
  : @author Luis Rodgriguez
  : @library <a href="http://www.sqlite.org/";>SQLite</a>
  : @project DB Drivers/SQLite
  :)
  
-module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+module namespace s = "http://zorba.io/modules/sqlite";;
 declare namespace an = "http://www.zorba-xquery.com/annotations";;
 declare namespace ver = "http://www.zorba-xquery.com/options/versioning";;
 declare option ver:module-version "1.0";
@@ -37,21 +37,23 @@
  :
  : @return the SQLite database object as xs:anyURI.
  :
- : @error s:SQLI0001 if the database name doesn't exist or it couldn't be opened.
- : @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.
+ : @error s:CANT-OPEN-DB if the database name doesn't exist or it couldn't be
+ :     opened.
+ : @error s:COMPILED-WITHOUT-DISK-ACCESS if a non-in-memory database is
+ :     requested and the module is built without filesystem access.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside 
+ :     SQLite library.
  :)
 declare %an:sequential function s:connect(
   $db-name as xs:string
   ) as xs:anyURI external;
 
 (:~
- : Connect to a SQLite database with optional options.
+ : Connect to a SQLite database with optional options.<p/>
  : All options are true/false values. Available options are: open-read-only,
  : open-create, open-no-mutex, and open-shared-cache.
  :
- : <p>The options are of the form: 
+ : The options are of the form: 
  : <pre>
  : {
  :   "open_read_only" : true,
@@ -59,18 +61,20 @@
  :   ... 
  : }
  : </pre>
- : </p>
+ : <p/>
  :
  : @param $db-name the SQLite database name to be opened as xs:string.
  : @param $options a JSON object containing SQLite connection options.
  :
  : @return the SQLite database object as xs:anyURI.
  :
- : @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.
+ : @error s:CANT-OPEN-DB if the database name doesn't exist or it couldn't be
+ :     opened.
+ : @error s:UNKNOWN-OPTION if there is any unknown option specified.
+ : @error s:COMPILED-WITHOUT-DISK-ACCESS if a non-in-memory database is
+ :     requested and the module is built without filesystem access.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:connect(
   $db-name as xs:string,
@@ -82,36 +86,40 @@
  :
  : @param $conn the SQLite database object as xs:anyURI.
  :
- : @return true if the given SQLite database object is connected, false otherwise.
+ : @return true if the given SQLite database object is connected, false
+ :     otherwise.
  :
- : @error s:SQLI0002 if $conn is not a valid SQLite database object.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-SQLITE-OBJECT if $conn is not a valid SQLite database object.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:is-connected(
   $conn as xs:anyURI ) as xs:boolean external;
   
 (:~
- : Commits all the pending update operations in this SQLite database.
+ : Commits all pending update operations in this SQLite database.
  :
  : @param $conn the SQLite database object as xs:anyURI.
  :
  : @return the passed SQLite object.
  :
- : @error s:SQLI0002 if $conn is not a valid SQLite database object.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-SQLITE-OBJECT if $conn is not a valid SQLite database object.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:commit(
   $conn as xs:anyURI ) as xs:anyURI external;
   
 (:~
- : Rollbacks all the pending update operations in this SQLite database.
+ : Rollbacks all pending update operations in this SQLite database.
  :
  : @param $conn the SQLite database object as xs:anyURI.
  :
  : @return the passed SQLite object.
  :
- : @error s:SQLI0002 if $conn is not a valid SQLite database object.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-SQLITE-OBJECT if $conn is not a valid SQLite database object.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:rollback(
   $conn as xs:anyURI ) as xs:anyURI external;
@@ -125,25 +133,27 @@
  :
  : @return a sequence of JSON objects describing each row returned.
  :
- : @error s:SQLI0002 if $conn is not a valid SQLite database object.
- : @error s:SQLI0003 if $stmnt is not a valid sql command.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-SQLITE-OBJECT if $conn is not a valid SQLite database object.
+ : @error s:INVALID-SQL-STATEMENT if $stmnt is not a valid sql command.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:execute-query(
   $conn as xs:anyURI,
   $sqlstr as xs:string ) as object()* external;
   
 (:~
- : Executes a update command over an already opened SQLite database object.
+ : Executes an update command over an already opened SQLite database object.
  :
  : @param $conn an already opened SQLite database object as xs:anyURI.
  : @param $sqlstr the update command to be executed as xs:string.
  :
  : @return the amount of rows modified by such update command.
  :
- : @error s:SQLI0002 if $conn is not a valid SQLite database object.
- : @error s:SQLI0003 if $stmnt is not a valid sql command.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-SQLITE-OBJECT if $conn is not a valid SQLite database object.
+ : @error s:INVALID-SQL-STATEMENT if $stmnt is not a valid sql command.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:execute-update(
   $conn as xs:anyURI,
@@ -152,7 +162,7 @@
 (:~
  : Returns the metadata associated to a given prepared SQLite statement.
  :
- : <p>SQLite metadata is returned in the following form:
+ : SQLite metadata is returned in the following form:
  : <pre>
  : {
  :   "columns" : 
@@ -168,35 +178,39 @@
  :       }*]
  : }
  : </pre>
- : </p>
+ : <p/>
  :
- : @param $pstmnt the sql command as xs:anyURI from which metadata will be extracted.
+ : @param $pstmnt the sql command as xs:anyURI from which metadata will be
+ :     extracted.
  :
  : @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.
+ : @error s:INVALID-PREPARED-STATEMENT if $pstmnt is not a valid SQLite prepared
+ :     statement.
+ : @error s:UNAVAILABLE-METADATA if no metadata is available (SQLite library
+ :     compiled without SQLITE_ENABLE_COLUMN_METADATA).
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:metadata(
   $pstmnt as xs:anyURI ) as object() external;
   
 (:~
  : Compiles a prepared statement based on an already connected SQLite database
- : and a string that defines the sql command.
+ : and a string that defines the sql command.<p/>
  :
- : <p>You can use '?' in the sql command as placeholders so you will
- : be able to bind variables later to such places.</p>
+ : You can use '?' in the sql command as placeholders so you will
+ : be able to bind variables later to such places.<p/>
  :
  : @param $conn the SQLite database object as xs:anyURI.
  : @param $stmnt the sql command as xs:string.
  :
  : @return a xs:anyURI object representing the prepared statement.
  :
- : @error s:SQLI0002 if $conn is not a valid SQLite database object.
- : @error s:SQLI0003 if $stmnt is not a valid sql command.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-SQLITE-OBJECT if $conn is not a valid SQLite database object.
+ : @error s:INVALID-SQL-STATEMENT if $stmnt is not a valid sql command.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:prepare-statement(
   $conn as xs:anyURI,
@@ -212,10 +226,12 @@
  :
  : @return nothing.
  :
- : @error s:SQLI0004 if $pstmnt is not a valid SQLite prepared statement.
- : @error s:SQLI0005 if $param-num is not a valid position.
- : @error s:SQLI0007 if $val is not a valid value.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-PREPARED-STATEMENT if $pstmnt is not a valid SQLite prepared
+ :     statement.
+ : @error s:INVALID-PLACEHOLDER-POSITION if $param-num is not a valid position.
+ : @error s:INVALID-VALUE if $val is not a valid value.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:set-value(
   $pstmnt as xs:anyURI, 
@@ -231,9 +247,11 @@
  :
  : @return nothing.
  :
- : @error s:SQLI0004 if $pstmnt is not a valid SQLite prepared statement.
- : @error s:SQLI0005 if $param-num is not a valid position.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-PREPARED-STATEMENT if $pstmnt is not a valid SQLite prepared
+ :     statement.
+ : @error s:INVALID-PLACEHOLDER-POSITION if $param-num is not a valid position.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:set-boolean(
   $pstmnt as xs:anyURI, 
@@ -249,10 +267,12 @@
  :
  : @return nothing.
  :
- : @error s:SQLI0004 if $pstmnt is not a valid SQLite prepared statement.
- : @error s:SQLI0005 if $param-num is not a valid position.
- : @error s:SQLI0006 if $val is not a valid numeric type.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-PREPARED-STATEMENT if $pstmnt is not a valid SQLite prepared
+ :     statement.
+ : @error s:INVALID-PLACEHOLDER-POSITION if $param-num is not a valid position.
+ : @error s:INVALID-VALUE if $val is not a valid numeric type.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:set-numeric(
   $pstmnt as xs:anyURI, 
@@ -268,9 +288,11 @@
  :
  : @return nothing.
  :
- : @error s:SQLI0004 if $pstmnt is not a valid SQLite prepared statement.
- : @error s:SQLI0005 if $param-num is not a valid position.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-PREPARED-STATEMENT if $pstmnt is not a valid SQLite prepared
+ :     statement.
+ : @error s:INVALID-PLACEHOLDER-POSITION if $param-num is not a valid position.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:set-string(
   $pstmnt as xs:anyURI, 
@@ -285,9 +307,11 @@
  :
  : @return nothing.
  :
- : @error s:SQLI0004 if $pstmnt is not a valid SQLite prepared statement.
- : @error s:SQLI0005 if $param-num is not a valid position.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-PREPARED-STATEMENT if $pstmnt is not a valid SQLite prepared
+ :     statement.
+ : @error s:INVALID-PLACEHOLDER-POSITION if $param-num is not a valid position.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:set-null(
   $pstmnt as xs:anyURI, 
@@ -300,8 +324,10 @@
  :
  : @return nothing.
  :
- : @error s:SQLI0004 if $pstmnt is not a valid SQLite prepared statement.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-PREPARED-STATEMENT if $pstmnt is not a valid SQLite prepared
+ :     statement.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:clear-params(
   $pstmnt as xs:anyURI ) as empty-sequence() external;
@@ -313,7 +339,8 @@
  :
  : @return nothing.
  :
- : @error s:SQLI0004 if $pstmnt is not a valid SQLite prepared statement.
+ : @error s:INVALID-PREPARED-STATEMENT if $pstmnt is not a valid SQLite prepared
+ :     statement.
  :)
 declare %an:sequential function s:close-prepared(
   $pstmnt as xs:anyURI ) as empty-sequence() external;
@@ -326,8 +353,10 @@
  :
  : @return a sequence of JSON objects representing the query results.
  :
- : @error s:SQLI0004 if $pstmnt is not a valid SQLite prepared statement.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-PREPARED-STATEMENT if $pstmnt is not a valid SQLite prepared
+ :     statement.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:execute-query-prepared(
   $pstmnt as xs:anyURI ) as object()* external;
@@ -340,8 +369,10 @@
  :
  : @return an integer that represents the amount of rows affected.
  :
- : @error s:SQLI0004 if $pstmnt is not a valid SQLite prepared statement.
- : @error s:SQLI9999 if there was an internal error inside SQLite library.
+ : @error s:INVALID-PREPARED-STATEMENT if $pstmnt is not a valid SQLite prepared
+ :     statement.
+ : @error s:INTERNAL-SQLITE-PROBLEM if there was an internal error inside SQLite
+ :     library.
  :)
 declare %an:sequential function s:execute-update-prepared(
   $pstmnt as xs:anyURI ) as xs:integer external;

=== modified file 'src/sqlite_module.xq.src/sqlite_module.cpp'
--- src/sqlite_module.xq.src/sqlite_module.cpp	2013-06-21 03:41:36 +0000
+++ src/sqlite_module.xq.src/sqlite_module.cpp	2013-07-29 22:35:31 +0000
@@ -35,6 +35,16 @@
 
 namespace zorba { namespace sqlite {
 
+// Allocating global variables
+zorba::Item SqliteModule::globalNameKey;
+zorba::Item SqliteModule::globalDatabaseKey;
+zorba::Item SqliteModule::globalTableKey;
+zorba::Item SqliteModule::globalTypeKey;
+zorba::Item SqliteModule::globalCollationKey;
+zorba::Item SqliteModule::globalNullableKey;
+zorba::Item SqliteModule::globalPrimaryKey;
+zorba::Item SqliteModule::globalAutoincKey;
+zorba::Item SqliteModule::globalAffectedRowsKey;
 
 /*******************************************************************************
  ******************************************************************************/
@@ -135,6 +145,25 @@
     theFunctions.clear();
   }
 
+  zorba::Item&
+  SqliteModule::getGlobalKey(GLOBAL_KEYS g)
+  {
+      switch(g)
+      {
+      case NAME: return globalNameKey;
+      case DATABASE: return globalDatabaseKey;
+      case TABLE: return globalTableKey;
+      case TYPE: return globalTypeKey;
+      case COLLATION: return globalCollationKey;
+      case NULLABLE: return globalNullableKey;
+      case PRIMARY_KEY: return globalPrimaryKey;
+      case AUTOINC: return globalAutoincKey;
+      case AFFECTED_ROWS: return globalAffectedRowsKey;
+      // Should never touch this case but still ...
+      default: return globalNameKey;
+      }
+  }
+
   /***********************
    *       ConnMap       *
    ***********************/
@@ -324,7 +353,8 @@
   }
 
   sqlite3_stmt* 
-  SqliteFunction::createPreparedStatement(const zorba::DynamicContext* aDctx, std::string aUUID, std::string aQry){
+  SqliteFunction::createPreparedStatement(const zorba::DynamicContext* aDctx,
+                                          std::string aUUID, std::string aQry){
     sqlite3 *lDb;
     sqlite3_stmt *lPstmt;
     int lRc;
@@ -334,7 +364,7 @@
     lDb = lConnMap->getConn(aUUID);
     if(lDb == NULL){
       // throw error, ID not recognized
-      throwError("SQLI0002", getErrorMessage("SQLI0002"));
+      throwError("INVALID-SQLITE-OBJECT", getErrorMessage("INVALID-SQLITE-OBJECT"));
     }
 
     lRc = sqlite3_prepare_v2(lDb, aQry.c_str(), aQry.size(), &lPstmt, &lTail);
@@ -342,10 +372,10 @@
       sqlite3_finalize(lPstmt);
     }
     if(lRc == SQLITE_ERROR) {
-      std::string lErr = getErrorMessage("SQLI0003");
+      std::string lErr = getErrorMessage("INVALID-SQL-STATEMENT");
       lErr += "; ";
       lErr += sqlite3_errmsg(lDb);
-      throwError("SQLI0003", lErr.c_str());
+      throwError("INVALID-SQL-STATEMENT", lErr.c_str());
     } else
       checkForError(lRc, 0, lDb);
 
@@ -364,11 +394,13 @@
     // Get the prepared statement and then set the value
     lPstmt = stmtMap->getStmt(aUUID);
     if(lPstmt == NULL){
-      throwError("SQLI0004", getErrorMessage("SQLI0004"));
+      throwError("INVALID-PREPARED-STATEMENT",
+                 getErrorMessage("INVALID-PREPARED-STATEMENT"));
     }
     lRc = sqlite3_bind_int(lPstmt, aPos, (aVal==true)?1:0);
     if(lRc == SQLITE_RANGE)
-      throwError("SQLI0005", getErrorMessage("SQLI0005"));
+      throwError("INVALID-PLACEHOLDER-POSITION",
+                 getErrorMessage("INVALID-PLACEHOLDER-POSITION"));
     else
       checkForError(lRc, 0, sqlite3_db_handle(lPstmt));
   }
@@ -386,11 +418,13 @@
     // Get the prepared statement and then set the value
     lPstmt = stmtMap->getStmt(aUUID);
     if(lPstmt == NULL){
-      throwError("SQLI0004", getErrorMessage("SQLI0004"));
+      throwError("INVALID-PREPARED-STATEMENT",
+                 getErrorMessage("INVALID-PREPARED-STATEMENT"));
     }
     lRc = sqlite3_bind_int(lPstmt, aPos, aVal);
     if(lRc == SQLITE_RANGE)
-      throwError("SQLI0005", getErrorMessage("SQLI0005"));
+      throwError("INVALID-PLACEHOLDER-POSITION",
+                 getErrorMessage("INVALID-PLACEHOLDER-POSITION"));
     else
       checkForError(lRc, 0, sqlite3_db_handle(lPstmt));
   }
@@ -408,11 +442,13 @@
     // Get the prepared statement and then set the value
     lPstmt = stmtMap->getStmt(aUUID);
     if(lPstmt == NULL){
-      throwError("SQLI0004", getErrorMessage("SQLI0004"));
+      throwError("INVALID-PREPARED-STATEMENT",
+                 getErrorMessage("INVALID-PREPARED-STATEMENT"));
     }
     lRc = sqlite3_bind_double(lPstmt, aPos, aVal);
     if(lRc == SQLITE_RANGE)
-      throwError("SQLI0005", getErrorMessage("SQLI0005"));
+      throwError("INVALID-PLACEHOLDER-POSITION",
+                 getErrorMessage("INVALID-PLACEHOLDER-POSITION"));
     else
       checkForError(lRc, 0, sqlite3_db_handle(lPstmt));
   }
@@ -430,11 +466,13 @@
     // Get the prepared statement and then set the value
     lPstmt = stmtMap->getStmt(aUUID);
     if(lPstmt == NULL){
-      throwError("SQLI0004", getErrorMessage("SQLI0004"));
+      throwError("INVALID-PREPARED-STATEMENT",
+                 getErrorMessage("INVALID-PREPARED-STATEMENT"));
     }
     lRc = sqlite3_bind_text(lPstmt, aPos, aVal.c_str(), aVal.size(), SQLITE_TRANSIENT);
     if(lRc == SQLITE_RANGE)
-      throwError("SQLI0005", getErrorMessage("SQLI0005"));
+      throwError("INVALID-PLACEHOLDER-POSITION",
+                 getErrorMessage("INVALID-PLACEHOLDER-POSITION"));
     else
       checkForError(lRc, 0, sqlite3_db_handle(lPstmt));
   }
@@ -451,11 +489,13 @@
     // Get the prepared statement and then set the value
     lPstmt = stmtMap->getStmt(aUUID);
     if(lPstmt == NULL){
-      throwError("SQLI0004", getErrorMessage("SQLI0004"));
+      throwError("INVALID-PREPARED-STATEMENT",
+                 getErrorMessage("INVALID-PREPARED-STATEMENT"));
     }
     lRc = sqlite3_bind_null(lPstmt, aPos);
     if(lRc == SQLITE_RANGE)
-      throwError("SQLI0005", getErrorMessage("SQLI0005"));
+      throwError("INVALID-PLACEHOLDER-POSITION",
+                 getErrorMessage("INVALID-PLACEHOLDER-POSITION"));
     else
       checkForError(lRc, 0, sqlite3_db_handle(lPstmt));
   }
@@ -470,7 +510,8 @@
     // get the prepared statement if exists
     lPstmt = stmtMap->getStmt(aUUID);
     if(lPstmt == NULL){
-      throwError("SQLI0004", getErrorMessage("SQLI0004"));
+      throwError("INVALID-PREPARED-STATEMENT",
+                 getErrorMessage("INVALID-PREPARED-STATEMENT"));
     }
     sqlite3_clear_bindings(lPstmt);
   }
@@ -502,7 +543,7 @@
     {
       if (!aLocalName)
       {
-        throwError("SQLI9999", sqlite3_errmsg(sql));
+        throwError("INTERNAL-SQLITE-PROBLEM", sqlite3_errmsg(sql));
       }
       else
       {
@@ -539,47 +580,47 @@
 
   const char *
   SqliteFunction::getErrorMessage(std::string error){
-    if(error == "SQLI0001")
+    if(error == "CANT-OPEN-DB")
     {
       return "Database file does not exist or it is not possible to open it";
     } 
-    else if(error == "SQLI0002")
+    else if(error == "INVALID-SQLITE-OBJECT")
     {
       return "Connection ID passed is not valid";
     }
-    else if(error == "SQLI0003")
+    else if(error == "INVALID-SQL-STATEMENT")
     {
       return "Statement passed is not a valid SQL statement";
     }
-    else if(error == "SQLI0004")
+    else if(error == "INVALID-PREPARED-STATEMENT")
     {
       return "Prepared statement passed is not valid";
     }
-    else if(error == "SQLI0005")
+    else if(error == "INVALID-PLACEHOLDER-POSITION")
     {
       return "Parameter position passed is not valid";
     }
-    else if(error == "SQLI0006")
+    else if(error == "INVALID-VALUE")
     {
       return "Parameter passed is not a valid number";
     }
-    else if(error == "SQLI0007")
+    else if(error == "UNKNOWN-OPTION")
     {
       return "Parameter passed is not a valid value";
     }
 #ifndef SQLITE_WITH_FILE_ACCESS
-    else if(error == "SQLI0008")
+    else if(error == "COMPILED-WITHOUT-DISK-ACCESS")
     {
       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")
+    else if(error == "UNAVAILABLE-METADATA")
     {
       return "Metadata not found (SQLite built without SQLITE_ENABLE_COLUMN_METADATA)";
     }
 #endif /* not ZORBA_SQLITE_HAVE_METADATA */
-    else if(error == "SQLI9999")
+    else if(error == "INTERNAL-SQLITE-PROBLEM")
     {
       return "Internal error ocurred";
     }
@@ -632,7 +673,9 @@
       } else
         // Not sure if I should stop here in case that any option
         // are not in the list
-        SqliteFunction::throwError("SQLI0007", (std::string(SqliteFunction::getErrorMessage("SQLI0007")) + " - " + lItemJSONKey.getStringValue().str()).c_str());
+        SqliteFunction::throwError("UNKNOWN-OPTION",
+                                   (std::string(SqliteFunction::getErrorMessage("UNKNOWN-OPTION")) + " - " +
+                                    lItemJSONKey.getStringValue().str()).c_str());
     }
     lIterKeys->close();
   }
@@ -704,10 +747,13 @@
  *                         JSONItemSequence::JSONIterator                      *
  ******************************************************************************/
   void JSONItemSequence::JSONIterator::open(){
+    zorba::Item lColumnName;
+    char* lColumnNameChar;
     // Get data and create the column names
     if(theStmt != NULL){
       theRc = sqlite3_step(theStmt);
-      SqliteFunction::checkForError((theRc==SQLITE_ROW || theRc==SQLITE_DONE)?0:-1, 0, sqlite3_db_handle(theStmt));
+      SqliteFunction::checkForError((theRc==SQLITE_ROW || theRc==SQLITE_DONE)?0:-1, 0,
+                                    sqlite3_db_handle(theStmt));
       if(theRc == SQLITE_DONE)
         isUpdateResult = true;
       theFactory = Zorba::getInstance(0)->getItemFactory();
@@ -715,14 +761,16 @@
       theColumnCount = sqlite3_column_count(theStmt);
       if(theColumnCount > 0)
       {
-        theColumnNames = new char*[theColumnCount];
         for(int i=0; i<theColumnCount; i++)
         {
           const char* lpChar = sqlite3_column_name(theStmt, i);
           int lLen = strlen(lpChar);
-          theColumnNames[i] = new char[lLen+1];
-          memcpy(theColumnNames[i], lpChar, lLen);
-          theColumnNames[i][lLen] = '\0';
+          lColumnNameChar = new char[lLen+1];
+          memcpy(lColumnNameChar, lpChar, lLen);
+          lColumnNameChar[lLen] = '\0';
+          lColumnName = theFactory->createString(lColumnNameChar);
+          theColumnNamesZString.push_back(lColumnName);
+          delete lColumnNameChar;
         }
       }
     }
@@ -730,7 +778,6 @@
 
   bool JSONItemSequence::JSONIterator::next(zorba::Item& aItem){
     int aType, aSize;
-    zorba::Item aKey;
     zorba::Item aValue;
     std::vector<std::pair<zorba::Item, zorba::Item> > elements;
     const char *aBlobPtr;
@@ -739,7 +786,6 @@
       // get the resulting data from the statement
       // in a key = value fashion
       for(int i=0; i<theColumnCount; i++){
-        aKey = theFactory->createString(std::string((const char *)theColumnNames[i]));
         aType = sqlite3_column_type(theStmt, i);
         switch(aType){
         case SQLITE_NULL:
@@ -762,7 +808,7 @@
             zorba::String(str)
           );
         }
-        elements.push_back(std::pair<zorba::Item, zorba::Item>(aKey, aValue));
+        elements.push_back(std::pair<zorba::Item, zorba::Item>(theColumnNamesZString.at(i), aValue));
       }
       aItem = theFactory->createJSONObject(elements);
       elements.clear();
@@ -771,9 +817,8 @@
       return true;
     } else if(isUpdateResult && theRc == SQLITE_DONE){
       // we have a prepared statement that represents a UPDATE and it's already executed
-      aKey = theFactory->createString("Affected Rows");
       aValue = theFactory->createInt(sqlite3_changes(sqlite3_db_handle(theStmt)));
-      elements.push_back(std::pair<zorba::Item, zorba::Item>(aKey, aValue));
+      elements.push_back(std::pair<zorba::Item, zorba::Item>(SqliteModule::getGlobalKey(SqliteModule::AFFECTED_ROWS), aValue));
       aItem = theFactory->createJSONObject(elements);
       elements.clear();
       // be sure it won't be back in here
@@ -787,11 +832,9 @@
   void JSONItemSequence::JSONIterator::close(){
     // Set the Rc to "no more data" and clear the variables
     theRc = SQLITE_ERROR;
-    if((theColumnCount > 0) && theColumnNames)
+    if(theColumnCount > 0)
     {
-      for(int i=0; i<theColumnCount; i++)
-        delete[] theColumnNames[i];
-      delete[] theColumnNames;
+      theColumnNamesZString.clear();
     }
     theColumnCount = 0;
     if(theStmt != NULL)
@@ -806,7 +849,8 @@
     // Get data and create the column names
     if(theStmt != NULL){
       theRc = sqlite3_step(theStmt);
-      SqliteFunction::checkForError((theRc==SQLITE_ROW || theRc==SQLITE_DONE)?0:-1, 0, sqlite3_db_handle(theStmt));
+      SqliteFunction::checkForError((theRc==SQLITE_ROW || theRc==SQLITE_DONE)?0:-1, 0,
+                                    sqlite3_db_handle(theStmt));
       theFactory = Zorba::getInstance(0)->getItemFactory();
 
       theColumnCount = sqlite3_column_count(theStmt);
@@ -821,7 +865,7 @@
   }
 
   bool JSONMetadataItemSequence::JSONMetadataIterator::next(zorba::Item& aItem){
-    zorba::Item aKey;
+    //zorba::Item aKey;
     zorba::Item aValue;
     std::vector<std::pair<zorba::Item, zorba::Item> > elements;
     sqlite3 *lDbHandle;
@@ -850,30 +894,22 @@
                                     &lAutoinc);
       if(lRc != 0)
         SqliteFunction::throwError(0, sqlite3_errmsg(lDbHandle));
-      aKey = theFactory->createString("name");
       aValue = theFactory->createString(lOriginName);
-      elements.push_back(std::pair<zorba::Item, zorba::Item>(aKey, aValue));
-      aKey = theFactory->createString("database");
+      elements.push_back(std::pair<zorba::Item, zorba::Item>(SqliteModule::getGlobalKey(SqliteModule::NAME), aValue));
       aValue = theFactory->createString(lDbName);
-      elements.push_back(std::pair<zorba::Item, zorba::Item>(aKey, aValue));
-      aKey = theFactory->createString("table");
+      elements.push_back(std::pair<zorba::Item, zorba::Item>(SqliteModule::getGlobalKey(SqliteModule::DATABASE), aValue));
       aValue = theFactory->createString(lTableName);
-      elements.push_back(std::pair<zorba::Item, zorba::Item>(aKey, aValue));
-      aKey = theFactory->createString("type");
+      elements.push_back(std::pair<zorba::Item, zorba::Item>(SqliteModule::getGlobalKey(SqliteModule::TABLE), aValue));
       aValue = theFactory->createString(lDataType);
-      elements.push_back(std::pair<zorba::Item, zorba::Item>(aKey, aValue));
-      aKey = theFactory->createString("collation");
+      elements.push_back(std::pair<zorba::Item, zorba::Item>(SqliteModule::getGlobalKey(SqliteModule::TYPE), aValue));
       aValue = theFactory->createString(lCollSequence);
-      elements.push_back(std::pair<zorba::Item, zorba::Item>(aKey, aValue));
-      aKey = theFactory->createString("nullable");
+      elements.push_back(std::pair<zorba::Item, zorba::Item>(SqliteModule::getGlobalKey(SqliteModule::COLLATION), aValue));
       aValue = theFactory->createBoolean((lNotNull==0)?false:true);
-      elements.push_back(std::pair<zorba::Item, zorba::Item>(aKey, aValue));
-      aKey = theFactory->createString("primary key");
+      elements.push_back(std::pair<zorba::Item, zorba::Item>(SqliteModule::getGlobalKey(SqliteModule::NULLABLE), aValue));
       aValue = theFactory->createBoolean((lPrimaryKey==0)?false:true);
-      elements.push_back(std::pair<zorba::Item, zorba::Item>(aKey, aValue));
-      aKey = theFactory->createString("autoincrement");
+      elements.push_back(std::pair<zorba::Item, zorba::Item>(SqliteModule::getGlobalKey(SqliteModule::PRIMARY_KEY), aValue));
       aValue = theFactory->createBoolean((lAutoinc==0)?false:true);
-      elements.push_back(std::pair<zorba::Item, zorba::Item>(aKey, aValue));
+      elements.push_back(std::pair<zorba::Item, zorba::Item>(SqliteModule::getGlobalKey(SqliteModule::AUTOINC), aValue));
       aItem = theFactory->createJSONObject(elements);
       elements.clear();
       // Get more data if available
@@ -927,7 +963,8 @@
 
 #ifndef SQLITE_WITH_FILE_ACCESS
     if (lDbName != ":memory:") {
-      throwError("SQLI0008", getErrorMessage("SQLI0008"));
+      throwError("COMPILED-WITHOUT-DISK-ACCESS",
+                 getErrorMessage("COMPILED-WITHOUT-DISK-ACCESS"));
     }
 #endif /* not SQLITE_WITH_FILE_ACCESS */
     lRc = sqlite3_open_v2(lDbName.c_str(), &lSqldb, lOptions.getOptionsAsInt(), NULL);
@@ -935,7 +972,7 @@
     lStrUUID = createUUID();
     lConnMap->storeConn(lStrUUID, lSqldb);
     if(lRc == SQLITE_CANTOPEN)
-      throwError("SQLI0001", getErrorMessage("SQLI0001"));
+      throwError("CANT-OPEN-DB", getErrorMessage("CANT-OPEN-DB"));
     else
       checkForError(lRc, 0, lSqldb);
 
@@ -981,7 +1018,7 @@
 
     lDb = lConnMap->getConn(lItemUUID.getStringValue().str());
     if(lDb == NULL)
-      throwError("SQLI0002", getErrorMessage("SQLI0002"));
+      throwError("INVALID-SQLITE-OBJECT", getErrorMessage("INVALID-SQLITE-OBJECT"));
 
     return ItemSequence_t(new SingletonItemSequence(lItemUUID));
   }
@@ -1000,7 +1037,7 @@
 
     lDb = lConnMap->getConn(lItemUUID.getStringValue().str());
     if(lDb == NULL)
-      throwError("SQLI0002", getErrorMessage("SQLI0002"));
+      throwError("INVALID-SQLITE-OBJECT", getErrorMessage("INVALID-SQLITE-OBJECT"));
 
     return ItemSequence_t(new SingletonItemSequence(lItemUUID));
   }
@@ -1091,7 +1128,8 @@
     lPstmt = lStmtMap->getStmt(lItemPstmt.getStringValue().str());
     if(lPstmt == NULL){
       // No valid prepared statement id passed
-      throwError("SQLI0004", getErrorMessage("SQLI0004"));
+      throwError("INVALID-PREPARED-STATEMENT",
+                 getErrorMessage("INVALID-PREPARED-STATEMENT"));
     }
 
     // So now create a JSONMetadataItemSequence and let it
@@ -1111,7 +1149,7 @@
     
     return ItemSequence_t(new SingletonItemSequence(lJSONRes));
 #else
-    throwError("SQLI0009", getErrorMessage("SQLI0009"));
+    throwError("UNAVAILABLE-METADATA", getErrorMessage("UNAVAILABLE-METADATA"));
 #endif
   }
 
@@ -1156,27 +1194,33 @@
     lPos = strToInt(lItemPos.getStringValue().str());
     switch(lItem.getTypeCode()){
     case store::XS_BOOLEAN:
-      setValueToStatement(aDctx, lItemUUID.getStringValue().str(), lPos, lItem.getBooleanValue());
+      setValueToStatement(aDctx, lItemUUID.getStringValue().str(),
+                          lPos, lItem.getBooleanValue());
       break;
     case store::XS_BYTE:
     case store::XS_INT:
-      setValueToStatement(aDctx, lItemUUID.getStringValue().str(), lPos, lItem.getIntValue());
+      setValueToStatement(aDctx, lItemUUID.getStringValue().str(),
+                          lPos, lItem.getIntValue());
       break;
     case store::XS_INTEGER:
-      setValueToStatement(aDctx, lItemUUID.getStringValue().str(), lPos, strToInt(lItem.getStringValue().str()));
+      setValueToStatement(aDctx, lItemUUID.getStringValue().str(),
+                          lPos, strToInt(lItem.getStringValue().str()));
       break;
     case store::XS_FLOAT:
     case store::XS_DOUBLE:
-      setValueToStatement(aDctx, lItemUUID.getStringValue().str(), lPos, lItem.getDoubleValue());
+      setValueToStatement(aDctx, lItemUUID.getStringValue().str(),
+                          lPos, lItem.getDoubleValue());
       break;
     case store::XS_DECIMAL:
-      setValueToStatement(aDctx, lItemUUID.getStringValue().str(), lPos, strToDouble(lItem.getStringValue().str()));
+      setValueToStatement(aDctx, lItemUUID.getStringValue().str(),
+                          lPos, strToDouble(lItem.getStringValue().str()));
       break;
     case store::XS_STRING:
-      setValueToStatement(aDctx, lItemUUID.getStringValue().str(), lPos, lItem.getStringValue().str());
+      setValueToStatement(aDctx, lItemUUID.getStringValue().str(),
+                          lPos, lItem.getStringValue().str());
       break;
     default:
-      throwError("SQLI0007", getErrorMessage("SQLI0007"));
+      throwError("INVALID-VALUE", getErrorMessage("INVALID-VALUE"));
     }
     return ItemSequence_t(new EmptySequence());
   }
@@ -1193,7 +1237,8 @@
     Item lItemPos = getOneItem(aArgs, 1);
     Item lItemBool = getOneItem(aArgs, 2);
 
-    setValueToStatement(aDctx, lItemUUID.getStringValue().str(), strToInt(lItemPos.getStringValue().str()), lItemBool.getBooleanValue());
+    setValueToStatement(aDctx, lItemUUID.getStringValue().str(),
+                        strToInt(lItemPos.getStringValue().str()), lItemBool.getBooleanValue());
     return ItemSequence_t(new EmptySequence());
   }
 
@@ -1213,20 +1258,24 @@
     switch(lItemNumeric.getTypeCode()){
     case store::XS_BYTE:
     case store::XS_INT:
-      setValueToStatement(aDctx, lItemUUID.getStringValue().str(), lPos, lItemNumeric.getIntValue());
+      setValueToStatement(aDctx, lItemUUID.getStringValue().str(),
+                          lPos, lItemNumeric.getIntValue());
       break;
     case store::XS_INTEGER:
-      setValueToStatement(aDctx, lItemUUID.getStringValue().str(), lPos, strToInt(lItemNumeric.getStringValue().str()));
+      setValueToStatement(aDctx, lItemUUID.getStringValue().str(),
+                          lPos, strToInt(lItemNumeric.getStringValue().str()));
       break;
     case store::XS_FLOAT:
     case store::XS_DOUBLE:
-      setValueToStatement(aDctx, lItemUUID.getStringValue().str(), lPos, lItemNumeric.getDoubleValue());
+      setValueToStatement(aDctx, lItemUUID.getStringValue().str(),
+                          lPos, lItemNumeric.getDoubleValue());
       break;
     case store::XS_DECIMAL:
-      setValueToStatement(aDctx, lItemUUID.getStringValue().str(), lPos, strToDouble(lItemNumeric.getStringValue().str()));
+      setValueToStatement(aDctx, lItemUUID.getStringValue().str(),
+                          lPos, strToDouble(lItemNumeric.getStringValue().str()));
       break;
     default:
-      throwError("SQLI0006", getErrorMessage("SQLI0006"));
+      throwError("INVALID-VALUE", getErrorMessage("INVALID-VALUE"));
     }
     return ItemSequence_t(new EmptySequence());
   }
@@ -1243,7 +1292,8 @@
     Item lItemPos = getOneItem(aArgs, 1);
     Item lItemString = getOneItem(aArgs, 2);
     
-    setValueToStatement(aDctx, lItemUUID.getStringValue().str(), strToInt(lItemPos.getStringValue().str()), lItemString.getStringValue().str());
+    setValueToStatement(aDctx, lItemUUID.getStringValue().str(),
+                        strToInt(lItemPos.getStringValue().str()), lItemString.getStringValue().str());
     return ItemSequence_t(new EmptySequence());
   }
 
@@ -1258,7 +1308,8 @@
     Item lItemUUID = getOneItem(aArgs, 0);
     Item lItemPos = getOneItem(aArgs, 1);
 
-    setValueToStatement(aDctx, lItemUUID.getStringValue().str(), strToInt(lItemPos.getStringValue().str()));
+    setValueToStatement(aDctx, lItemUUID.getStringValue().str(),
+                        strToInt(lItemPos.getStringValue().str()));
     return ItemSequence_t(new EmptySequence());
   }
 
@@ -1292,7 +1343,8 @@
     stmtMap = getStatementMap(aDctx);
     lPstmt = stmtMap->getStmt(lItemUUID.getStringValue().str());
     if(lPstmt == NULL)
-      throwError("SQLI0004", getErrorMessage("SQLI0004"));
+      throwError("INVALID-PREPARED-STATEMENT",
+                 getErrorMessage("INVALID-PREPARED-STATEMENT"));
 
     // Once we got the prepared statement just get rid of it
     stmtMap->deleteStmt(lItemUUID.getStringValue().str());
@@ -1314,7 +1366,8 @@
     // Get the prepared statement
     lPstmt = stmtMap->getStmt(lItemUUID.getStringValue().str());
     if(lPstmt == NULL)
-      throwError("SQLI0004", getErrorMessage("SQLI0004"));
+      throwError("INVALID-PREPARED-STATEMENT",
+                 getErrorMessage("INVALID-PREPARED-STATEMENT"));
 
     // And let the JSONItemSequence execute it
     std::auto_ptr<JSONItemSequence> lSeq(new JSONItemSequence(lPstmt));
@@ -1337,7 +1390,8 @@
     // Get the prepared statement
     lPstmt = stmtMap->getStmt(lItemUUID.getStringValue().str());
     if(lPstmt == NULL)
-      throwError("SQLI0004", getErrorMessage("SQLI0004"));
+      throwError("INVALID-PREPARED-STATEMENT",
+                 getErrorMessage("INVALID-PREPARED-STATEMENT"));
 
     // And let the JSONItemSequence execute it
     std::auto_ptr<JSONItemSequence> lSeq(new JSONItemSequence(lPstmt));

=== modified file 'src/sqlite_module.xq.src/sqlite_module.h'
--- src/sqlite_module.xq.src/sqlite_module.h	2013-02-18 22:15:44 +0000
+++ src/sqlite_module.xq.src/sqlite_module.h	2013-07-29 22:35:31 +0000
@@ -82,8 +82,33 @@
       typedef std::map<String, ExternalFunction*, ltstr> FuncMap_t;
       FuncMap_t theFunctions;
 
+      static zorba::Item globalNameKey;
+      static zorba::Item globalDatabaseKey;
+      static zorba::Item globalTableKey;
+      static zorba::Item globalTypeKey;
+      static zorba::Item globalCollationKey;
+      static zorba::Item globalNullableKey;
+      static zorba::Item globalPrimaryKey;
+      static zorba::Item globalAutoincKey;
+      static zorba::Item globalAffectedRowsKey;
+
     public:
 
+      enum GLOBAL_KEYS { NAME, DATABASE, TABLE, TYPE, COLLATION, NULLABLE, PRIMARY_KEY, AUTOINC, AFFECTED_ROWS };
+
+      SqliteModule()
+      {
+          globalNameKey = Zorba::getInstance(0)->getItemFactory()->createString("name");
+          globalDatabaseKey = Zorba::getInstance(0)->getItemFactory()->createString("database");
+          globalTableKey = Zorba::getInstance(0)->getItemFactory()->createString("table");
+          globalTypeKey = Zorba::getInstance(0)->getItemFactory()->createString("type");
+          globalCollationKey = Zorba::getInstance(0)->getItemFactory()->createString("collation");
+          globalNullableKey =  Zorba::getInstance(0)->getItemFactory()->createString("nullable");
+          globalPrimaryKey = Zorba::getInstance(0)->getItemFactory()->createString("primary key");
+          globalAutoincKey = Zorba::getInstance(0)->getItemFactory()->createString("autoincrement");
+          globalAffectedRowsKey = Zorba::getInstance(0)->getItemFactory()->createString("Affected Rows");
+      }
+
       virtual ~SqliteModule();
 
       virtual zorba::String
@@ -101,7 +126,10 @@
       }
 
       static zorba::String
-      getModuleURI() { return "http://www.zorba-xquery.com/modules/sqlite";; }
+      getModuleURI() { return "http://zorba.io/modules/sqlite";; }
+
+      static zorba::Item&
+      getGlobalKey(GLOBAL_KEYS g);
 
   };
 
@@ -115,7 +143,7 @@
       {
         protected:
           sqlite3_stmt* theStmt;
-          char** theColumnNames;
+          std::vector<zorba::Item> theColumnNamesZString;
           int theColumnCount;
           int theRc;
           bool isUpdateResult;
@@ -123,7 +151,7 @@
 
         public:
           JSONIterator(sqlite3_stmt* aPrepStmt):
-              theStmt(aPrepStmt),theColumnNames(NULL),theColumnCount(0),
+              theStmt(aPrepStmt),
               theRc(0),isUpdateResult(false) {}
 
           virtual ~JSONIterator() {

=== modified file 'test/Queries/test0.xq'
--- test/Queries/test0.xq	2013-01-09 15:07:19 +0000
+++ test/Queries/test0.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 import module namespace f = "http://expath.org/ns/file";;
 
 let $path := f:path-to-native(resolve-uri("./"))

=== modified file 'test/Queries/test1.xq'
--- test/Queries/test1.xq	2013-01-09 15:07:19 +0000
+++ test/Queries/test1.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 
 let $db := s:connect("")
 

=== modified file 'test/Queries/test10.xq'
--- test/Queries/test10.xq	2013-03-21 01:33:18 +0000
+++ test/Queries/test10.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 
 let $db := s:connect("", { "open-read-only" : false(), "open-create" : false() })
 

=== modified file 'test/Queries/test11.spec'
--- test/Queries/test11.spec	2012-12-06 23:47:48 +0000
+++ test/Queries/test11.spec	2013-07-29 22:35:31 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0003
+Error: http://zorba.io/modules/sqlite:INVALID-SQL-STATEMENT

=== modified file 'test/Queries/test11.xq'
--- test/Queries/test11.xq	2013-01-09 15:07:19 +0000
+++ test/Queries/test11.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 
 let $db := s:connect("")
 

=== modified file 'test/Queries/test12.spec'
--- test/Queries/test12.spec	2012-12-06 23:47:48 +0000
+++ test/Queries/test12.spec	2013-07-29 22:35:31 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0001
+Error: http://zorba.io/modules/sqlite:CANT-OPEN-DB

=== modified file 'test/Queries/test12.xq'
--- test/Queries/test12.xq	2013-03-21 01:33:18 +0000
+++ test/Queries/test12.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 
 let $db := s:connect("non-existent-file.db", {"open-read-only" : false(), "open-create" : false()})
 

=== modified file 'test/Queries/test13.spec'
--- test/Queries/test13.spec	2012-12-06 23:47:48 +0000
+++ test/Queries/test13.spec	2013-07-29 22:35:31 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0002
+Error: http://zorba.io/modules/sqlite:INVALID-SQLITE-OBJECT

=== modified file 'test/Queries/test13.xq'
--- test/Queries/test13.xq	2013-01-09 15:07:19 +0000
+++ test/Queries/test13.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 
 let $db := s:connect("")
 

=== modified file 'test/Queries/test14.spec'
--- test/Queries/test14.spec	2012-12-06 23:47:48 +0000
+++ test/Queries/test14.spec	2013-07-29 22:35:31 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0004
+Error: http://zorba.io/modules/sqlite:INVALID-PREPARED-STATEMENT

=== modified file 'test/Queries/test14.xq'
--- test/Queries/test14.xq	2013-01-09 15:07:19 +0000
+++ test/Queries/test14.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 
 let $db := s:connect("")
 

=== modified file 'test/Queries/test15.spec'
--- test/Queries/test15.spec	2012-12-06 23:47:48 +0000
+++ test/Queries/test15.spec	2013-07-29 22:35:31 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0005
+Error: http://zorba.io/modules/sqlite:INVALID-PLACEHOLDER-POSITION

=== modified file 'test/Queries/test15.xq'
--- test/Queries/test15.xq	2013-01-09 15:07:19 +0000
+++ test/Queries/test15.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 
 let $db := s:connect("")
 

=== modified file 'test/Queries/test16.spec'
--- test/Queries/test16.spec	2012-12-06 23:47:48 +0000
+++ test/Queries/test16.spec	2013-07-29 22:35:31 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0006
+Error: http://zorba.io/modules/sqlite:INVALID-VALUE

=== modified file 'test/Queries/test16.xq'
--- test/Queries/test16.xq	2013-01-09 15:07:19 +0000
+++ test/Queries/test16.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 
 let $db := s:connect("")
 

=== modified file 'test/Queries/test17.spec'
--- test/Queries/test17.spec	2012-12-06 23:47:48 +0000
+++ test/Queries/test17.spec	2013-07-29 22:35:31 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0007
+Error: http://zorba.io/modules/sqlite:UNKNOWN-OPTION

=== modified file 'test/Queries/test17.xq'
--- test/Queries/test17.xq	2013-03-21 01:33:18 +0000
+++ test/Queries/test17.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 
 let $db := s:connect("non-existent-file.db", {"non-existent-option" : true()})
 

=== modified file 'test/Queries/test18.xq'
--- test/Queries/test18.xq	2013-01-08 23:59:00 +0000
+++ test/Queries/test18.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 
 let $db := s:connect("")
 

=== modified file 'test/Queries/test2.xq'
--- test/Queries/test2.xq	2013-01-09 15:07:19 +0000
+++ test/Queries/test2.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 import module namespace f = "http://expath.org/ns/file";;
 
 let $path := f:path-to-native(resolve-uri("./"))

=== modified file 'test/Queries/test3.spec'
--- test/Queries/test3.spec	2013-01-25 23:29:51 +0000
+++ test/Queries/test3.spec	2013-07-29 22:35:31 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0009
+Error: http://zorba.io/modules/sqlite:UNAVAILABLE-METADATA

=== modified file 'test/Queries/test3.xq'
--- test/Queries/test3.xq	2013-01-09 15:07:19 +0000
+++ test/Queries/test3.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 import module namespace f = "http://expath.org/ns/file";;
 
 let $path := f:path-to-native(resolve-uri("./"))

=== modified file 'test/Queries/test4.spec'
--- test/Queries/test4.spec	2013-01-25 23:29:51 +0000
+++ test/Queries/test4.spec	2013-07-29 22:35:31 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0009
+Error: http://zorba.io/modules/sqlite:UNAVAILABLE-METADATA

=== modified file 'test/Queries/test4.xq'
--- test/Queries/test4.xq	2013-01-09 15:07:19 +0000
+++ test/Queries/test4.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 import module namespace f = "http://expath.org/ns/file";;
 
 let $path := f:path-to-native(resolve-uri("./"))

=== modified file 'test/Queries/test5.spec'
--- test/Queries/test5.spec	2013-01-25 23:29:51 +0000
+++ test/Queries/test5.spec	2013-07-29 22:35:31 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/sqlite:SQLI0009
+Error: http://zorba.io/modules/sqlite:UNAVAILABLE-METADATA

=== modified file 'test/Queries/test5.xq'
--- test/Queries/test5.xq	2013-01-09 15:07:19 +0000
+++ test/Queries/test5.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 import module namespace f = "http://expath.org/ns/file";;
 
 let $path := f:path-to-native(resolve-uri("./"))

=== modified file 'test/Queries/test6.xq'
--- test/Queries/test6.xq	2013-01-09 15:07:19 +0000
+++ test/Queries/test6.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 
 let $db := s:connect("small2.db")
 

=== modified file 'test/Queries/test7.xq'
--- test/Queries/test7.xq	2012-12-19 21:58:28 +0000
+++ test/Queries/test7.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 import module namespace f = "http://expath.org/ns/file";;
 
 let $path := f:path-to-native(resolve-uri("./"))
@@ -11,4 +11,4 @@
   let $name := $e("name")
   let $calories := $e("calories")
   return <food><id>{$id}</id><name>{$name}</name><calories>{$calories}</calories></food>
-}
\ No newline at end of file
+}

=== modified file 'test/Queries/test8.xq'
--- test/Queries/test8.xq	2013-01-09 15:07:19 +0000
+++ test/Queries/test8.xq	2013-07-29 22:35:31 +0000
@@ -1,4 +1,4 @@
-import module namespace s = "http://www.zorba-xquery.com/modules/sqlite";;
+import module namespace s = "http://zorba.io/modules/sqlite";;
 
 let $db := s:connect("")
 

=== modified file 'test/Queries/test9.xq'
--- test/Queries/test9.xq	2013-01-08 06:01:04 +0000
+++ test/Queries/test9.xq	2013-07-29 22:35:31 +0000
@@ -1,5 +1,5 @@
 import module namespace s =
-  "http://www.zorba-xquery.com/modules/sqlite";;
+  "http://zorba.io/modules/sqlite";;
 
 let $xml := 
 <root>


Follow ups