From 0a54661bb0b85fe5bc4c419ef4c3ca0c46bbd2dd Mon Sep 17 00:00:00 2001 From: Alex Fabijanic Date: Fri, 18 Apr 2014 21:32:30 -0500 Subject: [PATCH] - added optional SQLite Full Text Search support - Powershell build fixes: 1) Add platform for MSbuild 2) fixed omit array handling --- Data/SQLite/SQLite_vs120.vcxproj | 1 + Data/SQLite/include/Poco/Data/SQLite/Config.h | 69 +++++++++++++++++++ Data/SQLite/include/Poco/Data/SQLite/SQLite.h | 13 +--- Data/SQLite/src/sqlite3.c | 1 + Data/SQLite/testsuite/src/SQLiteTest.cpp | 48 +++++++++++++ Data/SQLite/testsuite/src/SQLiteTest.h | 2 + Foundation/include/Poco/Config.h | 4 ++ buildwin.ps1 | 20 +++--- configure | 7 ++ 9 files changed, 142 insertions(+), 23 deletions(-) create mode 100644 Data/SQLite/include/Poco/Data/SQLite/Config.h diff --git a/Data/SQLite/SQLite_vs120.vcxproj b/Data/SQLite/SQLite_vs120.vcxproj index 960a64177..04b61fc64 100644 --- a/Data/SQLite/SQLite_vs120.vcxproj +++ b/Data/SQLite/SQLite_vs120.vcxproj @@ -274,6 +274,7 @@ + diff --git a/Data/SQLite/include/Poco/Data/SQLite/Config.h b/Data/SQLite/include/Poco/Data/SQLite/Config.h new file mode 100644 index 000000000..26ca40636 --- /dev/null +++ b/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 diff --git a/Data/SQLite/include/Poco/Data/SQLite/SQLite.h b/Data/SQLite/include/Poco/Data/SQLite/SQLite.h index 15ea80b9b..cc8ad624a 100644 --- a/Data/SQLite/include/Poco/Data/SQLite/SQLite.h +++ b/Data/SQLite/include/Poco/Data/SQLite/SQLite.h @@ -4,7 +4,7 @@ // $Id: //poco/Main/Data/SQLite/include/Poco/Data/SQLite/SQLite.h#3 $ // // Library: SQLite -// Package: SQLIte +// Package: SQLite // Module: SQLite // // Basic definitions for the Poco SQLite library. @@ -81,15 +81,4 @@ #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 diff --git a/Data/SQLite/src/sqlite3.c b/Data/SQLite/src/sqlite3.c index 7c6d3e280..61a33e2b5 100644 --- a/Data/SQLite/src/sqlite3.c +++ b/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 ** version 3.8.4.1. By combining all the individual C code files into this diff --git a/Data/SQLite/testsuite/src/SQLiteTest.cpp b/Data/SQLite/testsuite/src/SQLiteTest.cpp index 498fca1d9..1d392906b 100644 --- a/Data/SQLite/testsuite/src/SQLiteTest.cpp +++ b/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 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() { } @@ -3385,6 +3432,7 @@ CppUnit::Test* SQLiteTest::suite() CppUnit_addTest(pSuite, SQLiteTest, testSessionTransaction); CppUnit_addTest(pSuite, SQLiteTest, testTransaction); CppUnit_addTest(pSuite, SQLiteTest, testTransactor); + CppUnit_addTest(pSuite, SQLiteTest, testFTS3); return pSuite; } diff --git a/Data/SQLite/testsuite/src/SQLiteTest.h b/Data/SQLite/testsuite/src/SQLiteTest.h index bac29ea2e..ecbd3f830 100644 --- a/Data/SQLite/testsuite/src/SQLiteTest.h +++ b/Data/SQLite/testsuite/src/SQLiteTest.h @@ -152,6 +152,8 @@ public: void testTransaction(); void testTransactor(); + void testFTS3(); + void setUp(); void tearDown(); diff --git a/Foundation/include/Poco/Config.h b/Foundation/include/Poco/Config.h index 19efc6263..adc6dd0a7 100644 --- a/Foundation/include/Poco/Config.h +++ b/Foundation/include/Poco/Config.h @@ -176,6 +176,10 @@ // #define POCO_NET_NO_IPv6 +// Enable SQLite Full Text Search +#define POCO_DATA_SQLITE_FTS + + // Windows CE has no locale support #if defined(_WIN32_WCE) #define POCO_NO_LOCALE diff --git a/buildwin.ps1 b/buildwin.ps1 index adfb87157..c1c4f5cc4 100644 --- a/buildwin.ps1 +++ b/buildwin.ps1 @@ -60,9 +60,6 @@ Param ) -$omitArray = @() - - function Set-Environment { if ($poco_base -eq '') { $script:poco_base = Get-Location } @@ -172,10 +169,6 @@ function Process-Input if ($omit -ne '') { Write-Host "Omit: $omit" - - $omit.Split(',;') | ForEach { - $omitArray += "$_" - } } if ($openssl_base -ne '') @@ -208,14 +201,14 @@ function Build-MSBuild([string] $vsProject) { $projectConfig = "$cfg" $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 { $projectConfig = "$config" $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 += "_$mode" - Invoke-Expression "msbuild $vsProject /t:$action /p:Configuration=$projectConfig" + Invoke-Expression "msbuild $vsProject /t:$action /p:Configuration=$projectConfig /p:Platform=$platform" } } else #config { $projectConfig = "$config" $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('/') $componentName = $componentArr[$componentArr.Length - 1] $suffix = "_vs$vs_version" + + $omitArray = @() + $omit.Split(',;') | ForEach { + $omitArray += "$_" + } if ($omitArray -NotContains $component) { diff --git a/configure b/configure index 6b663470c..a3309d7ae 100755 --- a/configure +++ b/configure @@ -63,6 +63,10 @@ Options: Compile with -DPOCO_NET_NO_IPv6. For systems that don't support IPv6. + --sqlite-fts= + Compile with -DPOCO_DATA_SQLITE_FTS. + Compile SQLite with Full Text Search support. + --omit={,} Do not build the specified component(s). Example: --omit=Data/MySQL,Data/ODBC,Zip @@ -173,6 +177,9 @@ while [ $# -ge 1 ]; do --no-ipv6) flags="$flags -DPOCO_NET_NO_IPv6" ;; + --sqlite-fts) + flags="$flags -DPOCO_DATA_SQLITE_FTS" ;; + --poquito) flags="$flags -DPOCO_NO_FILECHANNEL -DPOCO_NO_SPLITTERCHANNEL -DPOCO_NO_SYSLOGCHANNEL -DPOCO_UTIL_NO_INIFILECONFIGURATION -DPOCO_UTIL_NO_JSONCONFIGURATION -DPOCO_UTIL_NO_XMLCONFIGURATION" ;;