Browse Source

- added optional SQLite Full Text Search support
- Powershell build fixes:
1) Add platform for MSbuild
2) fixed omit array handling

Alex Fabijanic 12 years ago
parent
commit
0a54661bb0

+ 1 - 0
Data/SQLite/SQLite_vs120.vcxproj

@@ -274,6 +274,7 @@
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <ItemGroup>
   <ItemGroup>
     <ClInclude Include="include\Poco\Data\SQLite\Binder.h" />
     <ClInclude Include="include\Poco\Data\SQLite\Binder.h" />
+    <ClInclude Include="include\Poco\Data\SQLite\Config.h" />
     <ClInclude Include="include\Poco\Data\SQLite\Connector.h" />
     <ClInclude Include="include\Poco\Data\SQLite\Connector.h" />
     <ClInclude Include="include\Poco\Data\SQLite\Extractor.h" />
     <ClInclude Include="include\Poco\Data\SQLite\Extractor.h" />
     <ClInclude Include="include\Poco\Data\SQLite\Notifier.h" />
     <ClInclude Include="include\Poco\Data\SQLite\Notifier.h" />

+ 69 - 0
Data/SQLite/include/Poco/Data/SQLite/Config.h

@@ -0,0 +1,69 @@
+//
+// Config.h
+//
+// $Id: //poco/Main/Data/SQLite/include/Poco/Data/SQLite/Config.h#3 $
+//
+// Library: SQLite
+// Package: SQLite
+// Module:  SQLite
+//
+// Basic configuration definitions for the underlying SQLite library.
+// In order for configuration definitions to take effect, this file must
+// be included from sqlite3.c file.
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+// 
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+//
+
+
+#ifndef SQLite_Config_INCLUDED
+#define SQLite_Config_INCLUDED
+
+
+#include "Poco/Config.h"
+
+
+//
+// Thread safety mode defaults to "serialized".
+// See http://www.sqlite.org/threadsafe.html for details.
+// Threading mode may significantly affect performance 
+// (see TestSuite::benchmarkThreadModesTiming)
+//
+#ifndef SQLITE_THREADSAFE
+	#define SQLITE_THREADSAFE 1
+#endif // SQLITE_THREADSAFE
+
+
+#ifdef POCO_DATA_SQLITE_FTS	
+	#ifndef SQLITE_ENABLE_FTS3
+		#define SQLITE_ENABLE_FTS3
+	#endif
+	#ifndef SQLITE_ENABLE_FTS3_PARENTHESIS
+		#define SQLITE_ENABLE_FTS3_PARENTHESIS
+	#endif
+#endif // POCO_DATA_SQLITE_FTS
+
+
+#endif // SQLite_SQLite_INCLUDED

+ 1 - 12
Data/SQLite/include/Poco/Data/SQLite/SQLite.h

@@ -4,7 +4,7 @@
 // $Id: //poco/Main/Data/SQLite/include/Poco/Data/SQLite/SQLite.h#3 $
 // $Id: //poco/Main/Data/SQLite/include/Poco/Data/SQLite/SQLite.h#3 $
 //
 //
 // Library: SQLite
 // Library: SQLite
-// Package: SQLIte
+// Package: SQLite
 // Module:  SQLite
 // Module:  SQLite
 //
 //
 // Basic definitions for the Poco SQLite library.
 // Basic definitions for the Poco SQLite library.
@@ -81,15 +81,4 @@
 #endif
 #endif
 
 
 
 
-//
-// Thread safety mode defaults to "serialized".
-// See http://www.sqlite.org/threadsafe.html for details.
-// Threading mode may significantly affect performance 
-// (see TestSuite::benchmarkThreadModesTiming)
-//
-#ifndef SQLITE_THREADSAFE
-	#define SQLITE_THREADSAFE 1
-#endif
-
-
 #endif // SQLite_SQLite_INCLUDED
 #endif // SQLite_SQLite_INCLUDED

+ 1 - 0
Data/SQLite/src/sqlite3.c

@@ -1,3 +1,4 @@
+#include "Poco/Data/SQLite/Config.h"
 /******************************************************************************
 /******************************************************************************
 ** This file is an amalgamation of many separate C source files from SQLite
 ** This file is an amalgamation of many separate C source files from SQLite
 ** version 3.8.4.1.  By combining all the individual C code files into this 
 ** version 3.8.4.1.  By combining all the individual C code files into this 

+ 48 - 0
Data/SQLite/testsuite/src/SQLiteTest.cpp

@@ -3287,6 +3287,53 @@ void SQLiteTest::testTransactor()
 }
 }
 
 
 
 
+#ifdef POCO_DATA_SQLITE_FTS
+
+
+void SQLiteTest::testFTS3()
+{
+	Session session(Poco::Data::SQLite::Connector::KEY, "dummy.db");
+	assert(session.isConnected());
+
+	session << "DROP TABLE IF EXISTS docs", now;
+	session << "CREATE VIRTUAL TABLE docs USING fts3()", now;
+
+	session << "INSERT INTO docs(docid, content) VALUES(1, 'a database is a software system')", now;
+	session << "INSERT INTO docs(docid, content) VALUES(2, 'sqlite is a software system')", now;
+	session << "INSERT INTO docs(docid, content) VALUES(3, 'sqlite is a database')", now;
+
+	int docid = 0;
+	session << "SELECT docid FROM docs WHERE docs MATCH 'sqlite AND database'", into(docid), now;
+	assert(docid == 3);
+
+	docid = 0;
+	session << "SELECT docid FROM docs WHERE docs MATCH 'database sqlite'", into(docid), now;
+	assert(docid == 3);
+
+	std::vector<int> docids;
+	session << "SELECT docid FROM docs WHERE docs MATCH 'sqlite OR database' ORDER BY docid", 
+		into(docids), now;
+	assert(docids.size() == 3);
+	assert(docids[0] == 1);
+	assert(docids[1] == 2);
+	assert(docids[2] == 3);
+
+	std::string content;
+	docid = 0;
+	session << "SELECT docid, content FROM docs WHERE docs MATCH 'database NOT sqlite'", 
+		into(docid), into(content), now;
+	assert(docid == 1);
+	assert(content == "a database is a software system");
+
+	docid = 0;
+	session << "SELECT count(*) FROM docs WHERE docs MATCH 'database and sqlite'", into(docid), now;
+	assert(docid == 0);
+}
+
+
+#endif // POCO_DATA_SQLITE_FTS
+
+
 void SQLiteTest::setUp()
 void SQLiteTest::setUp()
 {
 {
 }
 }
@@ -3385,6 +3432,7 @@ CppUnit::Test* SQLiteTest::suite()
 	CppUnit_addTest(pSuite, SQLiteTest, testSessionTransaction);
 	CppUnit_addTest(pSuite, SQLiteTest, testSessionTransaction);
 	CppUnit_addTest(pSuite, SQLiteTest, testTransaction);
 	CppUnit_addTest(pSuite, SQLiteTest, testTransaction);
 	CppUnit_addTest(pSuite, SQLiteTest, testTransactor);
 	CppUnit_addTest(pSuite, SQLiteTest, testTransactor);
+	CppUnit_addTest(pSuite, SQLiteTest, testFTS3);
 
 
 	return pSuite;
 	return pSuite;
 }
 }

+ 2 - 0
Data/SQLite/testsuite/src/SQLiteTest.h

@@ -152,6 +152,8 @@ public:
 	void testTransaction();
 	void testTransaction();
 	void testTransactor();
 	void testTransactor();
 
 
+	void testFTS3();
+
 	void setUp();
 	void setUp();
 	void tearDown();
 	void tearDown();
 
 

+ 4 - 0
Foundation/include/Poco/Config.h

@@ -176,6 +176,10 @@
 // #define POCO_NET_NO_IPv6
 // #define POCO_NET_NO_IPv6
 
 
 
 
+// Enable SQLite Full Text Search
+#define POCO_DATA_SQLITE_FTS
+
+
 // Windows CE has no locale support
 // Windows CE has no locale support
 #if defined(_WIN32_WCE)
 #if defined(_WIN32_WCE)
 	#define POCO_NO_LOCALE
 	#define POCO_NO_LOCALE

+ 9 - 11
buildwin.ps1

@@ -60,9 +60,6 @@ Param
 )
 )
 
 
 
 
-$omitArray = @()
-
-
 function Set-Environment
 function Set-Environment
 {
 {
   if ($poco_base -eq '') { $script:poco_base = Get-Location }
   if ($poco_base -eq '') { $script:poco_base = Get-Location }
@@ -172,10 +169,6 @@ function Process-Input
     if ($omit -ne '')
     if ($omit -ne '')
     {
     {
       Write-Host "Omit:          $omit"
       Write-Host "Omit:          $omit"
-    
-      $omit.Split(',;') | ForEach {
-        $omitArray += "$_"
-      }
     }
     }
 
 
     if ($openssl_base -ne '')
     if ($openssl_base -ne '')
@@ -208,14 +201,14 @@ function Build-MSBuild([string] $vsProject)
         {
         {
           $projectConfig = "$cfg"
           $projectConfig = "$cfg"
           $projectConfig += "_$mode"
           $projectConfig += "_$mode"
-          Invoke-Expression "msbuild $vsProject /t:$action /p:Configuration=$projectConfig"
+          Invoke-Expression "msbuild $vsProject /t:$action /p:Configuration=$projectConfig /p:Platform=$platform"
         }
         }
       }
       }
       else #config
       else #config
       {
       {
         $projectConfig = "$config"
         $projectConfig = "$config"
         $projectConfig += "_$mode"
         $projectConfig += "_$mode"
-        Invoke-Expression "msbuild $vsProject /t:$action /p:Configuration=$projectConfig"
+        Invoke-Expression "msbuild $vsProject /t:$action /p:Configuration=$projectConfig /p:Platform=$platform"
       }
       }
     }
     }
   }
   }
@@ -228,14 +221,14 @@ function Build-MSBuild([string] $vsProject)
       {
       {
         $projectConfig = "$cfg"
         $projectConfig = "$cfg"
         $projectConfig += "_$mode"
         $projectConfig += "_$mode"
-        Invoke-Expression "msbuild $vsProject /t:$action /p:Configuration=$projectConfig"
+        Invoke-Expression "msbuild $vsProject /t:$action /p:Configuration=$projectConfig /p:Platform=$platform"
       }
       }
     }
     }
     else #config
     else #config
     {
     {
       $projectConfig = "$config"
       $projectConfig = "$config"
       $projectConfig += "_$linkmode"
       $projectConfig += "_$linkmode"
-      Invoke-Expression "msbuild $vsProject /t:$action /p:Configuration=$projectConfig"
+      Invoke-Expression "msbuild $vsProject /t:$action /p:Configuration=$projectConfig /p:Platform=$platform"
     }
     }
   }
   }
 }
 }
@@ -322,6 +315,11 @@ function Build
     $componentArr = $_.split('/')
     $componentArr = $_.split('/')
     $componentName = $componentArr[$componentArr.Length - 1]
     $componentName = $componentArr[$componentArr.Length - 1]
     $suffix = "_vs$vs_version"
     $suffix = "_vs$vs_version"
+    
+    $omitArray = @()
+    $omit.Split(',;') | ForEach {
+        $omitArray += "$_"
+    }
 
 
     if ($omitArray -NotContains $component)
     if ($omitArray -NotContains $component)
     {
     {

+ 7 - 0
configure

@@ -63,6 +63,10 @@ Options:
     Compile with -DPOCO_NET_NO_IPv6.
     Compile with -DPOCO_NET_NO_IPv6.
     For systems that don't support IPv6.
     For systems that don't support IPv6.
 
 
+  --sqlite-fts=<path>
+    Compile with -DPOCO_DATA_SQLITE_FTS.
+    Compile SQLite with Full Text Search support.
+
   --omit=<component>{,<component>}
   --omit=<component>{,<component>}
     Do not build the specified component(s).
     Do not build the specified component(s).
     Example: --omit=Data/MySQL,Data/ODBC,Zip
     Example: --omit=Data/MySQL,Data/ODBC,Zip
@@ -173,6 +177,9 @@ while [ $# -ge 1 ]; do
 	--no-ipv6)
 	--no-ipv6)
 		flags="$flags -DPOCO_NET_NO_IPv6" ;;
 		flags="$flags -DPOCO_NET_NO_IPv6" ;;
 
 
+	--sqlite-fts)
+		flags="$flags -DPOCO_DATA_SQLITE_FTS" ;;
+
 	--poquito)
 	--poquito)
 		flags="$flags -DPOCO_NO_FILECHANNEL -DPOCO_NO_SPLITTERCHANNEL -DPOCO_NO_SYSLOGCHANNEL -DPOCO_UTIL_NO_INIFILECONFIGURATION -DPOCO_UTIL_NO_JSONCONFIGURATION -DPOCO_UTIL_NO_XMLCONFIGURATION" ;;
 		flags="$flags -DPOCO_NO_FILECHANNEL -DPOCO_NO_SPLITTERCHANNEL -DPOCO_NO_SYSLOGCHANNEL -DPOCO_UTIL_NO_INIFILECONFIGURATION -DPOCO_UTIL_NO_JSONCONFIGURATION -DPOCO_UTIL_NO_XMLCONFIGURATION" ;;