mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
fix(SQLParser): Disable SQL parsing by default #4462
This commit is contained in:
parent
d6dfa257e1
commit
2fe694e4d3
26
.github/workflows/ci.yml
vendored
26
.github/workflows/ci.yml
vendored
@ -725,3 +725,29 @@ jobs:
|
|||||||
sudo -s
|
sudo -s
|
||||||
EXCLUDE_TESTS="ActiveRecord ApacheConnector CppParser CppUnit Crypto Data Data/MySQL Data/PostgreSQL Data/SQLite Encodings Foundation JSON JWT MongoDB Net NetSSL_OpenSSL NetSSL_Win PDF PageCompiler PocoDoc ProGen Prometheus Redis SevenZip Util XML Zip"
|
EXCLUDE_TESTS="ActiveRecord ApacheConnector CppParser CppUnit Crypto Data Data/MySQL Data/PostgreSQL Data/SQLite Encodings Foundation JSON JWT MongoDB Net NetSSL_OpenSSL NetSSL_Win PDF PageCompiler PocoDoc ProGen Prometheus Redis SevenZip Util XML Zip"
|
||||||
./ci/runtests.sh
|
./ci/runtests.sh
|
||||||
|
|
||||||
|
linux-gcc-make-sqlite-no-sqlparser:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:8.1.0
|
||||||
|
env:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: yes
|
||||||
|
MYSQL_USER: pocotest
|
||||||
|
MYSQL_PASSWORD: pocotest
|
||||||
|
MYSQL_DATABASE: pocotest
|
||||||
|
ports:
|
||||||
|
- 3306:3306
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- run: sudo apt -y update
|
||||||
|
- run: ./configure --everything --no-samples --no-sqlparser --omit=ActiveRecord,ApacheConnector,CppParser,Crypto,Data/PostgreSQL,Data/MySQL,Data/ODBC,Encodings,JSON,JWT,MongoDB,Net,NetSSL_OpenSSL,NetSSL_Win,PDF,PageCompiler,PocoDoc,ProGen,Prometheus,Redis,SevenZip,Util,XML,Zip && make all -s -j4 && sudo make install
|
||||||
|
- uses: ./.github/actions/retry-action
|
||||||
|
with:
|
||||||
|
timeout_minutes: 90
|
||||||
|
max_attempts: 3
|
||||||
|
retry_on: any
|
||||||
|
command: >-
|
||||||
|
sudo -s
|
||||||
|
EXCLUDE_TESTS="ActiveRecord ApacheConnector CppParser CppUnit Crypto Data Data/PostgreSQL Data/ODBC Data/MySQL Encodings Foundation JSON JWT MongoDB Net NetSSL_OpenSSL NetSSL_Win PDF PageCompiler PocoDoc ProGen Prometheus Redis SevenZip Util XML Zip"
|
||||||
|
./ci/runtests.sh
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
_bulk(false),
|
_bulk(false),
|
||||||
_emptyStringIsNull(false),
|
_emptyStringIsNull(false),
|
||||||
_forceEmptyString(false),
|
_forceEmptyString(false),
|
||||||
_sqlParse(true),
|
_sqlParse(false),
|
||||||
_autoCommit(true)
|
_autoCommit(true)
|
||||||
/// Creates the AbstractSessionImpl.
|
/// Creates the AbstractSessionImpl.
|
||||||
///
|
///
|
||||||
@ -90,6 +90,18 @@ public:
|
|||||||
/// While these features can not both be true at the same time, they can both be false,
|
/// While these features can not both be true at the same time, they can both be false,
|
||||||
/// resulting in default underlying database behavior.
|
/// resulting in default underlying database behavior.
|
||||||
///
|
///
|
||||||
|
/// Adds "sqlParse" feature and sets it to false; this property enables parsing of the SQL queries,
|
||||||
|
/// to help the Data framework to determine whether to start a transaction automatically in
|
||||||
|
/// non-autocomit mode (ie. not to start transaction if all the queries in an SQL statement are SELECTs).
|
||||||
|
/// Note that the property is not a bullet-proof way to ensure this behavior, because not all SQL dialects
|
||||||
|
/// are supported by the parser. When enabled, the parsing has performance cost, but it is otherwise
|
||||||
|
/// non-intrusive, ie. on parse failure Statement only internally records parsing errors, but does not throw.
|
||||||
|
/// See Poco::Data::Statement documentation for more information.
|
||||||
|
/// This property has no effect when Poco::Data library is compiled with POCO_DATA_NO_SQL_PARSER.
|
||||||
|
///
|
||||||
|
/// Adds "autoCommit" feature and sets it to true. This property enables automatic commit.
|
||||||
|
/// Setting this feature to true renders the `sqlParse` property meaningless, because every query
|
||||||
|
/// is automatically commited.
|
||||||
{
|
{
|
||||||
addProperty("storage",
|
addProperty("storage",
|
||||||
&AbstractSessionImpl<C>::setStorage,
|
&AbstractSessionImpl<C>::setStorage,
|
||||||
|
@ -33,16 +33,23 @@
|
|||||||
#include "Poco/Optional.h"
|
#include "Poco/Optional.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#ifndef POCO_DATA_NO_SQL_PARSER
|
||||||
|
|
||||||
namespace hsql {
|
namespace hsql {
|
||||||
class SQLParserResult;
|
class SQLParserResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // POCO_DATA_NO_SQL_PARSER
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
|
#ifndef POCO_DATA_NO_SQL_PARSER
|
||||||
|
|
||||||
namespace Parser = hsql; // namespace Poco::Data::Parser
|
namespace Parser = hsql; // namespace Poco::Data::Parser
|
||||||
|
|
||||||
|
#endif // POCO_DATA_NO_SQL_PARSER
|
||||||
|
|
||||||
class AbstractBinding;
|
class AbstractBinding;
|
||||||
class AbstractExtraction;
|
class AbstractExtraction;
|
||||||
class Session;
|
class Session;
|
||||||
@ -311,6 +318,8 @@ public:
|
|||||||
|
|
||||||
Optional<std::size_t> statementsCount() const;
|
Optional<std::size_t> statementsCount() const;
|
||||||
/// Returns the total number of SQL statements held in the accummulated SQL statement.
|
/// Returns the total number of SQL statements held in the accummulated SQL statement.
|
||||||
|
///
|
||||||
|
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
|
||||||
|
|
||||||
Optional<bool> parse();
|
Optional<bool> parse();
|
||||||
/// Parses the SQL statement and returns true if successful.
|
/// Parses the SQL statement and returns true if successful.
|
||||||
@ -319,42 +328,44 @@ public:
|
|||||||
/// keywords not supported by the parser. Parsing failures are silent in terms of
|
/// keywords not supported by the parser. Parsing failures are silent in terms of
|
||||||
/// throwing exceptions or logging, but it is possible to get error information by
|
/// throwing exceptions or logging, but it is possible to get error information by
|
||||||
/// calling parseError().
|
/// calling parseError().
|
||||||
|
///
|
||||||
|
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
|
||||||
|
|
||||||
const std::string& parseError();
|
const std::string& parseError();
|
||||||
/// Returns the SQL statement parse error message, if any.
|
/// Returns the SQL statement parse error message, if any.
|
||||||
/// For Poco::Data builds without SQLParser, it always returns empty string.
|
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns an empty string.
|
||||||
|
|
||||||
Optional<bool> isSelect() const;
|
Optional<bool> isSelect() const;
|
||||||
/// Returns true if the statement consists only of SELECT statement(s).
|
/// Returns true if the statement consists only of SELECT statement(s).
|
||||||
/// For Poco::Data builds without SQLParser, it always returns unspecified.
|
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
|
||||||
|
|
||||||
Optional<bool> isInsert() const;
|
Optional<bool> isInsert() const;
|
||||||
/// Returns true if the statement consists only of INSERT statement(s).
|
/// Returns true if the statement consists only of INSERT statement(s).
|
||||||
/// For Poco::Data builds without SQLParser, it always returns unspecified.
|
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
|
||||||
|
|
||||||
Optional<bool> isUpdate() const;
|
Optional<bool> isUpdate() const;
|
||||||
/// Returns true if the statement consists only of UPDATE statement(s).
|
/// Returns true if the statement consists only of UPDATE statement(s).
|
||||||
/// For Poco::Data builds without SQLParser, it always returns unspecified.
|
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
|
||||||
|
|
||||||
Optional<bool> isDelete() const;
|
Optional<bool> isDelete() const;
|
||||||
/// Returns true if the statement consists only of DELETE statement(s).
|
/// Returns true if the statement consists only of DELETE statement(s).
|
||||||
/// For Poco::Data builds without SQLParser, it always returns unspecified.
|
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
|
||||||
|
|
||||||
Optional<bool> hasSelect() const;
|
Optional<bool> hasSelect() const;
|
||||||
/// Returns true if the statement contains a SELECT statement.
|
/// Returns true if the statement contains a SELECT statement.
|
||||||
/// For Poco::Data builds without SQLParser, it always returns unspecified.
|
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
|
||||||
|
|
||||||
Optional<bool> hasInsert() const;
|
Optional<bool> hasInsert() const;
|
||||||
/// Returns true if the statement contains an INSERT statement.
|
/// Returns true if the statement contains an INSERT statement.
|
||||||
/// For Poco::Data builds without SQLParser, it always returns unspecified.
|
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
|
||||||
|
|
||||||
Optional<bool> hasUpdate() const;
|
Optional<bool> hasUpdate() const;
|
||||||
/// Returns true if the statement contains an UPDATE statement.
|
/// Returns true if the statement contains an UPDATE statement.
|
||||||
/// For Poco::Data builds without SQLParser, it always returns unspecified.
|
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
|
||||||
|
|
||||||
Optional<bool> hasDelete() const;
|
Optional<bool> hasDelete() const;
|
||||||
/// Returns true if the statement contains a DELETE statement.
|
/// Returns true if the statement contains a DELETE statement.
|
||||||
/// For Poco::Data builds without SQLParser, it always returns unspecified.
|
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
|
||||||
|
|
||||||
std::size_t execute(bool reset = true);
|
std::size_t execute(bool reset = true);
|
||||||
/// Executes the statement synchronously or asynchronously.
|
/// Executes the statement synchronously or asynchronously.
|
||||||
@ -549,7 +560,8 @@ private:
|
|||||||
|
|
||||||
Poco::SharedPtr<Parser::SQLParserResult> _pParseResult;
|
Poco::SharedPtr<Parser::SQLParserResult> _pParseResult;
|
||||||
std::string _parseError;
|
std::string _parseError;
|
||||||
#endif // POCO_DATA_NO_SQL_PARSER
|
|
||||||
|
#endif // POCO_DATA_NO_SQL_PARSER
|
||||||
|
|
||||||
StatementImpl::Ptr _pImpl;
|
StatementImpl::Ptr _pImpl;
|
||||||
|
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef POCO_DATA_NO_SQL_PARSER
|
||||||
#include "SQLParser.h"
|
#include "SQLParser.h"
|
||||||
|
#endif
|
||||||
#include "Poco/Data/Statement.h"
|
#include "Poco/Data/Statement.h"
|
||||||
#include "Poco/Data/DataException.h"
|
#include "Poco/Data/DataException.h"
|
||||||
#include "Poco/Data/Extraction.h"
|
#include "Poco/Data/Extraction.h"
|
||||||
|
5
configure
vendored
5
configure
vendored
@ -79,9 +79,8 @@ $(ls -C "$base"/build/config/)
|
|||||||
Disables small object optimization.
|
Disables small object optimization.
|
||||||
|
|
||||||
--no-sqlparser
|
--no-sqlparser
|
||||||
Compile with POCO_DATA_NO_SQL_PARSER
|
Compile with -DPOCO_DATA_NO_SQL_PARSER
|
||||||
SQLParser is not enabled by default for c++14 and below,
|
Disables compilation of the SQLParser.
|
||||||
so this option only has meaning for c++17 and above.
|
|
||||||
|
|
||||||
--sqlite-fts=<path>
|
--sqlite-fts=<path>
|
||||||
Compile with -DPOCO_DATA_SQLITE_FTS.
|
Compile with -DPOCO_DATA_SQLITE_FTS.
|
||||||
|
Loading…
Reference in New Issue
Block a user