Update libraries and make it build on windows.

Still gets some warnings because compilers have changed. But should work.
This commit is contained in:
Sandu Liviu Catalin committed 2025-06-25 22:34:23 +03:00
1 parent 520a5eacc5
commit f2b7499f85
3038 files changed
+251668 -273857

No files matched your search

+2 -2
View File
@@ -45,7 +45,7 @@ class Transcoder;
namespace Keywords {
static const NullData null = NULL_GENERIC;
static const NullData null = std::nullopt;
} // namespace Keywords
@@ -368,7 +368,7 @@ protected:
private:
using StringList = std::vector<std::string*>;
std::unique_ptr<Transcoder> _pTranscoder;
std::unique_ptr<StringList> _pStrings;
};
+20
View File
@@ -151,6 +151,25 @@ public:
/// - string is empty
/// - getEmptyStringIsNull() returns true
std::string getHeldType() const
/// Returns the held type name, if set.
/// If held type name is not set, returns empty string.
/// Held type is optionally set by calling setHeldType<T>()
/// in child classes.
/// Useful for dynamic_cast failure diagnostics.
{
std::string held;
if (_pHeldType) held = *_pHeldType;
return held;
}
protected:
template<typename T>
void setHeldType()
{
_pHeldType.reset(new std::string(Poco::demangle<T>()));
}
private:
template <typename S>
bool isStringNull(const S& str, bool deflt)
@@ -169,6 +188,7 @@ private:
bool _bulk;
bool _emptyStringIsNull;
bool _forceEmptyString;
std::unique_ptr<std::string> _pHeldType;
};
+147 -63
View File
@@ -21,6 +21,7 @@
#include "Poco/Data/Data.h"
#include "Poco/Data/Constants.h"
#include "Poco/Data/LOB.h"
#include "Poco/Nullable.h"
#include "Poco/UUID.h"
#include "Poco/UTFString.h"
#include "Poco/TextEncoding.h"
@@ -66,97 +67,97 @@ public:
virtual bool extract(std::size_t pos, Poco::Int8& val) = 0;
/// Extracts an Int8. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<Poco::Int8>& val);
virtual bool extract(std::size_t pos, std::vector<Poco::Int8>& val) = 0;
/// Extracts an Int8 vector.
virtual bool extract(std::size_t pos, std::deque<Poco::Int8>& val);
virtual bool extract(std::size_t pos, std::deque<Poco::Int8>& val) = 0;
/// Extracts an Int8 deque.
virtual bool extract(std::size_t pos, std::list<Poco::Int8>& val);
virtual bool extract(std::size_t pos, std::list<Poco::Int8>& val) = 0;
/// Extracts an Int8 list.
virtual bool extract(std::size_t pos, Poco::UInt8& val) = 0;
/// Extracts an UInt8. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<Poco::UInt8>& val);
virtual bool extract(std::size_t pos, std::vector<Poco::UInt8>& val) = 0;
/// Extracts an UInt8 vector.
virtual bool extract(std::size_t pos, std::deque<Poco::UInt8>& val);
virtual bool extract(std::size_t pos, std::deque<Poco::UInt8>& val) = 0;
/// Extracts an UInt8 deque.
virtual bool extract(std::size_t pos, std::list<Poco::UInt8>& val);
virtual bool extract(std::size_t pos, std::list<Poco::UInt8>& val) = 0;
/// Extracts an UInt8 list.
virtual bool extract(std::size_t pos, Poco::Int16& val) = 0;
/// Extracts an Int16. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<Poco::Int16>& val);
virtual bool extract(std::size_t pos, std::vector<Poco::Int16>& val) = 0;
/// Extracts an Int16 vector.
virtual bool extract(std::size_t pos, std::deque<Poco::Int16>& val);
virtual bool extract(std::size_t pos, std::deque<Poco::Int16>& val) = 0;
/// Extracts an Int16 deque.
virtual bool extract(std::size_t pos, std::list<Poco::Int16>& val);
virtual bool extract(std::size_t pos, std::list<Poco::Int16>& val) = 0;
/// Extracts an Int16 list.
virtual bool extract(std::size_t pos, Poco::UInt16& val) = 0;
/// Extracts an UInt16. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<Poco::UInt16>& val);
virtual bool extract(std::size_t pos, std::vector<Poco::UInt16>& val) = 0;
/// Extracts an UInt16 vector.
virtual bool extract(std::size_t pos, std::deque<Poco::UInt16>& val);
virtual bool extract(std::size_t pos, std::deque<Poco::UInt16>& val) = 0;
/// Extracts an UInt16 deque.
virtual bool extract(std::size_t pos, std::list<Poco::UInt16>& val);
virtual bool extract(std::size_t pos, std::list<Poco::UInt16>& val) = 0;
/// Extracts an UInt16 list.
virtual bool extract(std::size_t pos, Poco::Int32& val) = 0;
/// Extracts an Int32. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<Poco::Int32>& val);
virtual bool extract(std::size_t pos, std::vector<Poco::Int32>& val) = 0;
/// Extracts an Int32 vector.
virtual bool extract(std::size_t pos, std::deque<Poco::Int32>& val);
virtual bool extract(std::size_t pos, std::deque<Poco::Int32>& val) = 0;
/// Extracts an Int32 deque.
virtual bool extract(std::size_t pos, std::list<Poco::Int32>& val);
virtual bool extract(std::size_t pos, std::list<Poco::Int32>& val) = 0;
/// Extracts an Int32 list.
virtual bool extract(std::size_t pos, Poco::UInt32& val) = 0;
/// Extracts an UInt32. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<Poco::UInt32>& val);
virtual bool extract(std::size_t pos, std::vector<Poco::UInt32>& val) = 0;
/// Extracts an UInt32 vector.
virtual bool extract(std::size_t pos, std::deque<Poco::UInt32>& val);
virtual bool extract(std::size_t pos, std::deque<Poco::UInt32>& val) = 0;
/// Extracts an UInt32 deque.
virtual bool extract(std::size_t pos, std::list<Poco::UInt32>& val);
virtual bool extract(std::size_t pos, std::list<Poco::UInt32>& val) = 0;
/// Extracts an UInt32 list.
virtual bool extract(std::size_t pos, Poco::Int64& val) = 0;
/// Extracts an Int64. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<Poco::Int64>& val);
virtual bool extract(std::size_t pos, std::vector<Poco::Int64>& val) = 0;
/// Extracts an Int64 vector.
virtual bool extract(std::size_t pos, std::deque<Poco::Int64>& val);
virtual bool extract(std::size_t pos, std::deque<Poco::Int64>& val) = 0;
/// Extracts an Int64 deque.
virtual bool extract(std::size_t pos, std::list<Poco::Int64>& val);
virtual bool extract(std::size_t pos, std::list<Poco::Int64>& val) = 0;
/// Extracts an Int64 list.
virtual bool extract(std::size_t pos, Poco::UInt64& val) = 0;
/// Extracts an UInt64. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<Poco::UInt64>& val);
virtual bool extract(std::size_t pos, std::vector<Poco::UInt64>& val) = 0;
/// Extracts an UInt64 vector.
virtual bool extract(std::size_t pos, std::deque<Poco::UInt64>& val);
virtual bool extract(std::size_t pos, std::deque<Poco::UInt64>& val) = 0;
/// Extracts an UInt64 deque.
virtual bool extract(std::size_t pos, std::list<Poco::UInt64>& val);
virtual bool extract(std::size_t pos, std::list<Poco::UInt64>& val) = 0;
/// Extracts an UInt64 list.
#ifndef POCO_INT64_IS_LONG
@@ -166,74 +167,83 @@ public:
virtual bool extract(std::size_t pos, unsigned long& val) = 0;
/// Extracts an unsigned long. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<long>& val);
virtual bool extract(std::size_t pos, std::vector<long>& val) = 0;
/// Extracts a long vector.
virtual bool extract(std::size_t pos, std::deque<long>& val);
virtual bool extract(std::size_t pos, std::deque<long>& val) = 0;
/// Extracts a long deque.
virtual bool extract(std::size_t pos, std::list<long>& val);
virtual bool extract(std::size_t pos, std::list<long>& val) = 0;
/// Extracts a long list.
virtual bool extract(std::size_t pos, std::vector<unsigned long>& val) = 0;
/// Extracts an unsigned long vector.
virtual bool extract(std::size_t pos, std::deque<unsigned long>& val) = 0;
/// Extracts an unsigned long deque.
virtual bool extract(std::size_t pos, std::list<unsigned long>& val) = 0;
/// Extracts an unsigned long list.
#endif
virtual bool extract(std::size_t pos, bool& val) = 0;
/// Extracts a boolean. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<bool>& val);
virtual bool extract(std::size_t pos, std::vector<bool>& val) = 0;
/// Extracts a boolean vector.
virtual bool extract(std::size_t pos, std::deque<bool>& val);
virtual bool extract(std::size_t pos, std::deque<bool>& val) = 0;
/// Extracts a boolean deque.
virtual bool extract(std::size_t pos, std::list<bool>& val);
virtual bool extract(std::size_t pos, std::list<bool>& val) = 0;
/// Extracts a boolean list.
virtual bool extract(std::size_t pos, float& val) = 0;
/// Extracts a float. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<float>& val);
virtual bool extract(std::size_t pos, std::vector<float>& val) = 0;
/// Extracts a float vector.
virtual bool extract(std::size_t pos, std::deque<float>& val);
virtual bool extract(std::size_t pos, std::deque<float>& val) = 0;
/// Extracts a float deque.
virtual bool extract(std::size_t pos, std::list<float>& val);
virtual bool extract(std::size_t pos, std::list<float>& val) = 0;
/// Extracts a float list.
virtual bool extract(std::size_t pos, double& val) = 0;
/// Extracts a double. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<double>& val);
virtual bool extract(std::size_t pos, std::vector<double>& val) = 0;
/// Extracts a double vector.
virtual bool extract(std::size_t pos, std::deque<double>& val);
virtual bool extract(std::size_t pos, std::deque<double>& val) = 0;
/// Extracts a double deque.
virtual bool extract(std::size_t pos, std::list<double>& val);
virtual bool extract(std::size_t pos, std::list<double>& val) = 0;
/// Extracts a double list.
virtual bool extract(std::size_t pos, char& val) = 0;
/// Extracts a single character. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<char>& val);
virtual bool extract(std::size_t pos, std::vector<char>& val) = 0;
/// Extracts a character vector.
virtual bool extract(std::size_t pos, std::deque<char>& val);
virtual bool extract(std::size_t pos, std::deque<char>& val) = 0;
/// Extracts a character deque.
virtual bool extract(std::size_t pos, std::list<char>& val);
virtual bool extract(std::size_t pos, std::list<char>& val) = 0;
/// Extracts a character list.
virtual bool extract(std::size_t pos, std::string& val) = 0;
/// Extracts a string. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<std::string>& val);
virtual bool extract(std::size_t pos, std::vector<std::string>& val) = 0;
/// Extracts a string vector.
virtual bool extract(std::size_t pos, std::deque<std::string>& val);
virtual bool extract(std::size_t pos, std::deque<std::string>& val) = 0;
/// Extracts a string deque.
virtual bool extract(std::size_t pos, std::list<std::string>& val);
virtual bool extract(std::size_t pos, std::list<std::string>& val) = 0;
/// Extracts a string list.
virtual bool extract(std::size_t pos, UTF16String& val);
@@ -254,58 +264,58 @@ public:
virtual bool extract(std::size_t pos, CLOB& val) = 0;
/// Extracts a CLOB. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<BLOB>& val);
virtual bool extract(std::size_t pos, std::vector<BLOB>& val) = 0;
/// Extracts a BLOB vector.
virtual bool extract(std::size_t pos, std::deque<BLOB>& val);
virtual bool extract(std::size_t pos, std::deque<BLOB>& val) = 0;
/// Extracts a BLOB deque.
virtual bool extract(std::size_t pos, std::list<BLOB>& val);
virtual bool extract(std::size_t pos, std::list<BLOB>& val) = 0;
/// Extracts a BLOB list.
virtual bool extract(std::size_t pos, std::vector<CLOB>& val);
virtual bool extract(std::size_t pos, std::vector<CLOB>& val) = 0;
/// Extracts a CLOB vector.
virtual bool extract(std::size_t pos, std::deque<CLOB>& val);
virtual bool extract(std::size_t pos, std::deque<CLOB>& val) = 0;
/// Extracts a CLOB deque.
virtual bool extract(std::size_t pos, std::list<CLOB>& val);
virtual bool extract(std::size_t pos, std::list<CLOB>& val) = 0;
/// Extracts a CLOB list.
virtual bool extract(std::size_t pos, DateTime& val) = 0;
/// Extracts a DateTime. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<DateTime>& val);
virtual bool extract(std::size_t pos, std::vector<DateTime>& val) = 0;
/// Extracts a DateTime vector.
virtual bool extract(std::size_t pos, std::deque<DateTime>& val);
virtual bool extract(std::size_t pos, std::deque<DateTime>& val) = 0;
/// Extracts a DateTime deque.
virtual bool extract(std::size_t pos, std::list<DateTime>& val);
virtual bool extract(std::size_t pos, std::list<DateTime>& val) = 0;
/// Extracts a DateTime list.
virtual bool extract(std::size_t pos, Date& val) = 0;
/// Extracts a Date. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<Date>& val);
virtual bool extract(std::size_t pos, std::vector<Date>& val) = 0;
/// Extracts a Date vector.
virtual bool extract(std::size_t pos, std::deque<Date>& val);
virtual bool extract(std::size_t pos, std::deque<Date>& val) = 0;
/// Extracts a Date deque.
virtual bool extract(std::size_t pos, std::list<Date>& val);
virtual bool extract(std::size_t pos, std::list<Date>& val) = 0;
/// Extracts a Date list.
virtual bool extract(std::size_t pos, Time& val) = 0;
/// Extracts a Time. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<Time>& val);
virtual bool extract(std::size_t pos, std::vector<Time>& val) = 0;
/// Extracts a Time vector.
virtual bool extract(std::size_t pos, std::deque<Time>& val);
virtual bool extract(std::size_t pos, std::deque<Time>& val) = 0;
/// Extracts a Time deque.
virtual bool extract(std::size_t pos, std::list<Time>& val);
virtual bool extract(std::size_t pos, std::list<Time>& val) = 0;
/// Extracts a Time list.
virtual bool extract(std::size_t pos, UUID& val) = 0;
@@ -323,27 +333,101 @@ public:
virtual bool extract(std::size_t pos, Any& val) = 0;
/// Extracts an Any. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<Any>& val);
virtual bool extract(std::size_t pos, std::vector<Any>& val) = 0;
/// Extracts an Any vector.
virtual bool extract(std::size_t pos, std::deque<Any>& val);
virtual bool extract(std::size_t pos, std::deque<Any>& val) = 0;
/// Extracts an Any deque.
virtual bool extract(std::size_t pos, std::list<Any>& val);
virtual bool extract(std::size_t pos, std::list<Any>& val) = 0;
/// Extracts an Any list.
virtual bool extract(std::size_t pos, Poco::Dynamic::Var& val) = 0;
/// Extracts a Var. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<Poco::Dynamic::Var>& val);
virtual bool extract(std::size_t pos, std::vector<Poco::Dynamic::Var>& val) = 0;
/// Extracts a Var vector.
virtual bool extract(std::size_t pos, std::deque<Poco::Dynamic::Var>& val);
virtual bool extract(std::size_t pos, std::deque<Poco::Dynamic::Var>& val) = 0;
/// Extracts a Var deque.
virtual bool extract(std::size_t pos, std::list<Poco::Dynamic::Var>& val);
virtual bool extract(std::size_t pos, std::list<Poco::Dynamic::Var>& val) = 0;
/// Extracts a Var list.
virtual bool extract(std::size_t pos, Poco::Nullable<Poco::Int8>& val);
/// Extracts a nullable nullable Int8.
virtual bool extract(std::size_t pos, Poco::Nullable<Poco::UInt8>& val);
/// Extracts a nullable nullable UInt8.
virtual bool extract(std::size_t pos, Poco::Nullable<Poco::Int16>& val);
/// Extracts a nullable nullable Int16.
virtual bool extract(std::size_t pos, Poco::Nullable<Poco::UInt16>& val);
/// Extracts a nullable nullable UInt16.
virtual bool extract(std::size_t pos, Poco::Nullable<Poco::Int32>& val);
/// Extracts a nullable nullable Int32.
virtual bool extract(std::size_t pos, Poco::Nullable<Poco::UInt32>& val);
/// Extracts a nullable nullable UInt32.
virtual bool extract(std::size_t pos, Poco::Nullable<Poco::Int64>& val);
/// Extracts a nullable nullable Int64.
virtual bool extract(std::size_t pos, Poco::Nullable<Poco::UInt64>& val);
/// Extracts a nullable nullable UInt64.
#ifndef POCO_INT64_IS_LONG
virtual bool extract(std::size_t pos, Poco::Nullable<long>& val);
/// Extracts a nullable long.
virtual bool extract(std::size_t pos, Poco::Nullable<unsigned long>& val);
/// Extracts a nullable nullable unsigned long.
#endif
virtual bool extract(std::size_t pos, Poco::Nullable<bool>& val);
/// Extracts a nullable boolean.
virtual bool extract(std::size_t pos, Poco::Nullable<float>& val);
/// Extracts a nullable float.
virtual bool extract(std::size_t pos, Poco::Nullable<double>& val);
/// Extracts a nullable double.
virtual bool extract(std::size_t pos, Poco::Nullable<char>& val);
/// Extracts a nullable single character.
virtual bool extract(std::size_t pos, Poco::Nullable<std::string>& val);
/// Extracts a nullable string.
virtual bool extract(std::size_t pos, Poco::Nullable<UTF16String>& val);
/// Extracts a nullable UTF16String.
virtual bool extract(std::size_t pos, Poco::Nullable<BLOB>& val);
/// Extracts a nullable BLOB.
virtual bool extract(std::size_t pos, Poco::Nullable<CLOB>& val);
/// Extracts a nullable CLOB.
virtual bool extract(std::size_t pos, Poco::Nullable<DateTime>& val);
/// Extracts a nullable DateTime.
virtual bool extract(std::size_t pos, Poco::Nullable<Date>& val);
/// Extracts a nullable Date.
virtual bool extract(std::size_t pos, Poco::Nullable<Time>& val);
/// Extracts a nullable Time.
virtual bool extract(std::size_t pos, Poco::Nullable<UUID>& val);
/// Extracts a nullable UUID.
virtual bool extract(std::size_t pos, Poco::Nullable<Any>& val);
/// Extracts a nullable nullable Any.
virtual bool extract(std::size_t pos, Poco::Nullable<Poco::Dynamic::Var>& val);
/// Extracts a nullable Var.
virtual bool isNull(std::size_t col, std::size_t row = POCO_DATA_INVALID_ROW) = 0;
/// Returns true if the value at [col,row] position is null.
+301 -1
View File
@@ -21,6 +21,7 @@
#include "Poco/Data/Data.h"
#include "Poco/RefCountedObject.h"
#include "Poco/Data/LOB.h"
#include "Poco/Nullable.h"
#include "Poco/UUID.h"
#include "Poco/UTFString.h"
#include <vector>
@@ -177,6 +178,15 @@ public:
virtual void prepare(std::size_t pos, const std::list<long>& val);
/// Prepares a long list.
virtual void prepare(std::size_t pos, const std::vector<unsigned long>& val);
/// Prepares a unsigned long vector.
virtual void prepare(std::size_t pos, const std::deque<unsigned long>& val);
/// Prepares a unsigned long deque.
virtual void prepare(std::size_t pos, const std::list<unsigned long>& val);
/// Prepares a unsigned long list.
#endif
virtual void prepare(std::size_t pos, const bool&) = 0;
@@ -239,7 +249,7 @@ public:
virtual void prepare(std::size_t pos, const std::list<std::string>& val);
/// Prepares a character list.
virtual void prepare(std::size_t pos, const UTF16String&);
virtual void prepare(std::size_t pos, const UTF16String&) = 0;
/// Prepares a UTF16String.
virtual void prepare(std::size_t pos, const std::vector<UTF16String>& val);
@@ -347,6 +357,296 @@ public:
virtual void prepare(std::size_t pos, const std::list<Poco::Dynamic::Var>& val);
/// Prepares a Var list.
virtual void prepare(std::size_t pos, const Poco::Nullable<Poco::Int8>&);
/// Prepares an Int8.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<Poco::Int8>>& val);
/// Prepares an Int8 vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<Poco::Int8>>& val);
/// Prepares an Int8 deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<Poco::Int8>>& val);
/// Prepares an Int8 list.
virtual void prepare(std::size_t pos, const Poco::Nullable<Poco::UInt8>&);
/// Prepares an UInt8.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<Poco::UInt8>>& val);
/// Prepares an UInt8 vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<Poco::UInt8>>& val);
/// Prepares an UInt8 deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<Poco::UInt8>>& val);
/// Prepares an UInt8 list.
virtual void prepare(std::size_t pos, const Poco::Nullable<Poco::Int16>&);
/// Prepares an Int16.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<Poco::Int16>>& val);
/// Prepares an Int16 vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<Poco::Int16>>& val);
/// Prepares an Int16 deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<Poco::Int16>>& val);
/// Prepares an Int16 list.
virtual void prepare(std::size_t pos, const Poco::Nullable<Poco::UInt16>&);
/// Prepares an UInt16.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<Poco::UInt16>>& val);
/// Prepares an UInt16 vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<Poco::UInt16>>& val);
/// Prepares an UInt16 deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<Poco::UInt16>>& val);
/// Prepares an UInt16 list.
virtual void prepare(std::size_t pos, const Poco::Nullable<Poco::Int32>&);
/// Prepares an Int32.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<Poco::Int32>>& val);
/// Prepares an Int32 vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<Poco::Int32>>& val);
/// Prepares an Int32 deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<Poco::Int32>>& val);
/// Prepares an Int32 list.
virtual void prepare(std::size_t pos, const Poco::Nullable<Poco::UInt32>&);
/// Prepares an UInt32.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<Poco::UInt32>>& val);
/// Prepares an UInt32 vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<Poco::UInt32>>& val);
/// Prepares an UInt32 deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<Poco::UInt32>>& val);
/// Prepares an UInt32 list.
virtual void prepare(std::size_t pos, const Poco::Nullable<Poco::Int64>&);
/// Prepares an Int64.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<Poco::Int64>>& val);
/// Prepares an Int64 vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<Poco::Int64>>& val);
/// Prepares an Int64 deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<Poco::Int64>>& val);
/// Prepares an Int64 list.
virtual void prepare(std::size_t pos, const Poco::Nullable<Poco::UInt64>&);
/// Prepares an UInt64.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<Poco::UInt64>>& val);
/// Prepares an UInt64 vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<Poco::UInt64>>& val);
/// Prepares an UInt64 deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<Poco::UInt64>>& val);
/// Prepares an UInt64 list.
#ifndef POCO_INT64_IS_LONG
virtual void prepare(std::size_t pos, const Poco::Nullable<long>&);
/// Prepares a long.
virtual void prepare(std::size_t pos, const Poco::Nullable<unsigned long>&);
/// Prepares an unsigned long.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<long>>& val);
/// Prepares a long vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<long>>& val);
/// Prepares a long deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<long>>& val);
/// Prepares a long list.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<unsigned long>>& val);
/// Prepares a unsigned long vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<unsigned long>>& val);
/// Prepares a unsigned long deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<unsigned long>>& val);
/// Prepares a unsigned long list.
#endif
virtual void prepare(std::size_t pos, const Poco::Nullable<bool>&);
/// Prepares a boolean.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<bool>>& val);
/// Prepares a boolean vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<bool>>& val);
/// Prepares a boolean deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<bool>>& val);
/// Prepares a boolean list.
virtual void prepare(std::size_t pos, const Poco::Nullable<float>&);
/// Prepares a float.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<float>>& val);
/// Prepares a float vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<float>>& val);
/// Prepares a float deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<float>>& val);
/// Prepares a float list.
virtual void prepare(std::size_t pos, const Poco::Nullable<double>&);
/// Prepares a double.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<double>>& val);
/// Prepares a double vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<double>>& val);
/// Prepares a double deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<double>>& val);
/// Prepares a double list.
virtual void prepare(std::size_t pos, const Poco::Nullable<char>&);
/// Prepares a single character.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<char>>& val);
/// Prepares a character vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<char>>& val);
/// Prepares a character deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<char>>& val);
/// Prepares a character list.
virtual void prepare(std::size_t pos, const Poco::Nullable<std::string>&);
/// Prepares a string.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<std::string>>& val);
/// Prepares a string vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<std::string>>& val);
/// Prepares a string deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<std::string>>& val);
/// Prepares a character list.
virtual void prepare(std::size_t pos, const Poco::Nullable<UTF16String>&);
/// Prepares a UTF16String.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<UTF16String>>& val);
/// Prepares a UTF16String vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<UTF16String>>& val);
/// Prepares a UTF16String deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<UTF16String>>& val);
/// Prepares a UTF16String list.
virtual void prepare(std::size_t pos, const Poco::Nullable<BLOB>&);
/// Prepares a BLOB.
virtual void prepare(std::size_t pos, const Poco::Nullable<CLOB>&);
/// Prepares a CLOB.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<BLOB>>& val);
/// Prepares a BLOB vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<BLOB>>& val);
/// Prepares a BLOB deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<BLOB>>& val);
/// Prepares a BLOB list.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<CLOB>>& val);
/// Prepares a CLOB vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<CLOB>>& val);
/// Prepares a CLOB deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<CLOB>>& val);
/// Prepares a CLOB list.
virtual void prepare(std::size_t pos, const Poco::Nullable<DateTime>&);
/// Prepares a DateTime.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<DateTime>>& val);
/// Prepares a DateTime vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<DateTime>>& val);
/// Prepares a DateTime deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<DateTime>>& val);
/// Prepares a DateTime list.
virtual void prepare(std::size_t pos, const Poco::Nullable<Date>&);
/// Prepares a Date.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<Date>>& val);
/// Prepares a Date vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<Date>>& val);
/// Prepares a Date deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<Date>>& val);
/// Prepares a Date list.
virtual void prepare(std::size_t pos, const Poco::Nullable<Time>&);
/// Prepares a Time.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<Time>>& val);
/// Prepares a Time vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<Time>>& val);
/// Prepares a Time deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<Time>>& val);
/// Prepares a Time list.
virtual void prepare(std::size_t pos, const Poco::Nullable<UUID>&);
/// Prepares a UUID.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<UUID>>& val);
/// Prepares a UUID vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<UUID>>& val);
/// Prepares a UUID deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<UUID>>& val);
/// Prepares a UUID list.
virtual void prepare(std::size_t pos, const Poco::Nullable<Any>&);
/// Prepares an Any.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<Any>>& val);
/// Prepares an Any vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<Any>>& val);
/// Prepares an Any deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<Any>>& val);
/// Prepares an Any list.
virtual void prepare(std::size_t pos, const Poco::Nullable<Poco::Dynamic::Var>&);
/// Prepares a Var.
virtual void prepare(std::size_t pos, const std::vector<Poco::Nullable<Poco::Dynamic::Var>>& val);
/// Prepares a Var vector.
virtual void prepare(std::size_t pos, const std::deque<Poco::Nullable<Poco::Dynamic::Var>>& val);
/// Prepares a Var deque.
virtual void prepare(std::size_t pos, const std::list<Poco::Nullable<Poco::Dynamic::Var>>& val);
/// Prepares a Var list.
void setLength(Poco::UInt32 length);
/// Sets the length of prepared data.
/// Needed only for data lengths greater than 1 (i.e. for
+95 -6
View File
@@ -55,7 +55,9 @@ public:
_storage(std::string("deque")),
_bulk(false),
_emptyStringIsNull(false),
_forceEmptyString(false)
_forceEmptyString(false),
_sqlParse(false),
_autoCommit(true)
/// Creates the AbstractSessionImpl.
///
/// Adds "storage" property and sets the default internal storage container
@@ -88,6 +90,18 @@ public:
/// While these features can not both be true at the same time, they can both be false,
/// 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",
&AbstractSessionImpl<C>::setStorage,
@@ -108,6 +122,14 @@ public:
addFeature("forceEmptyString",
&AbstractSessionImpl<C>::setForceEmptyString,
&AbstractSessionImpl<C>::getForceEmptyString);
addFeature("sqlParse",
&AbstractSessionImpl<C>::setSQLParse,
&AbstractSessionImpl<C>::getSQLParse);
addFeature("autoCommit",
&AbstractSessionImpl<C>::setAutoCommit,
&AbstractSessionImpl<C>::getAutoCommit);
}
~AbstractSessionImpl()
@@ -115,6 +137,16 @@ public:
{
}
bool hasFeature(const std::string& name) const
/// Looks a feature up in the features map
/// and returns true if there is one.
{
auto it = _features.find(name);
return it != _features.end() &&
it->second.getter &&
it->second.setter;
}
void setFeature(const std::string& name, bool state)
/// Looks a feature up in the features map
/// and calls the feature's setter, if there is one.
@@ -130,7 +162,7 @@ public:
else throw NotSupportedException(name);
}
bool getFeature(const std::string& name)
bool getFeature(const std::string& name) const
/// Looks a feature up in the features map
/// and calls the feature's getter, if there is one.
{
@@ -138,13 +170,23 @@ public:
if (it != _features.end())
{
if (it->second.getter)
return (static_cast<C*>(this)->*it->second.getter)(name);
return (static_cast<const C*>(this)->*it->second.getter)(name);
else
throw NotImplementedException("get", name);
}
else throw NotSupportedException(name);
}
bool hasProperty(const std::string& name) const
/// Looks a property up in the properties map
/// and returns true if there is one.
{
auto it = _properties.find(name);
return it != _properties.end() &&
it->second.getter &&
it->second.setter;
}
void setProperty(const std::string& name, const Poco::Any& value)
/// Looks a property up in the properties map
/// and calls the property's setter, if there is one.
@@ -160,7 +202,7 @@ public:
else throw NotSupportedException(name);
}
Poco::Any getProperty(const std::string& name)
Poco::Any getProperty(const std::string& name) const
/// Looks a property up in the properties map
/// and calls the property's getter, if there is one.
{
@@ -168,7 +210,7 @@ public:
if (it != _properties.end())
{
if (it->second.getter)
return (static_cast<C*>(this)->*it->second.getter)(name);
return (static_cast<const C*>(this)->*it->second.getter)(name);
else
throw NotImplementedException("set", name);
}
@@ -237,7 +279,7 @@ public:
return _emptyStringIsNull;
}
void setForceEmptyString(const std::string& name, bool forceEmptyString)
void setForceEmptyString(const std::string&, bool forceEmptyString)
/// Sets the behavior regarding empty variable length strings.
/// Those are treated as NULL by Oracle and as empty string by
/// most other databases.
@@ -258,6 +300,25 @@ public:
return _forceEmptyString;
}
void setSQLParse(const std::string&, bool doParse)
/// Enables the SQL parsing. Value must be of type bool.
/// When SQL parsing is enabled (default), the Statement attempts
/// to parse the SQL prior to executing it. The parsing is done
/// in non-autocommit mode only, with purpose to determine the
/// type of query and whether to start the transaction automatically.
///
/// See Statement documentation for more information.
{
_sqlParse = doParse;
}
bool getSQLParse(const std::string& name = "") const
/// Returns the value of the SQL parsing flag.
{
return _sqlParse;
}
protected:
void addFeature(const std::string& name, FeatureSetter setter, FeatureGetter getter)
/// Adds a feature to the map of supported features.
@@ -283,6 +344,32 @@ protected:
_properties[name] = property;
}
// most, if not all, back ends support the autocommit feature
// these handlers are added in this class by default,
// but an implementation can easily replace them by registering
// early its own handlers with:
// addFeature("autoCommit", setter, getter)");
//
// these are here to be used by any back end DBMS client that
// does not provide its own autocommit get/set capabilities
void setAutoCommit(const std::string&, bool autoCommit)
/// Enables automatic commit. When this feature is true,
/// every query is automatically commited. When false,
/// every query starts a transaction, except SELECT queries
/// (if properly detected by parser, see set/getSQLParse() and
/// Statement::checkBeginTransaction() documentation).
{
_autoCommit = autoCommit;
}
bool getAutoCommit(const std::string& name = "") const
/// Returns the value of the automatic commit flag.
/// See setAutoCommit() documentation for more details.
{
return _autoCommit;
}
private:
struct Feature
{
@@ -305,6 +392,8 @@ private:
bool _bulk;
bool _emptyStringIsNull;
bool _forceEmptyString;
bool _sqlParse;
bool _autoCommit;
Poco::Any _handle;
};
+2 -1
View File
@@ -180,7 +180,8 @@ public:
ArchiveByAgeStrategy(const std::string& connector,
const std::string& connect,
const std::string& sourceTable,
const std::string& destinationTable = DEFAULT_ARCHIVE_DESTINATION);
const std::string& destinationTable = DEFAULT_ARCHIVE_DESTINATION,
const std::string& age = "");
~ArchiveByAgeStrategy();
+24 -29
View File
@@ -38,7 +38,7 @@ namespace Data {
template <class T>
class Binding: public AbstractBinding
class Binding final: public AbstractBinding
/// Binding maps a value or multiple values (see Binding specializations for STL containers as
/// well as type handlers) to database column(s). Values to be bound can be either mapped
/// directly (by reference) or a copy can be created, depending on the value of the copy argument.
@@ -98,8 +98,7 @@ public:
{
_bound = false;
AbstractBinder::Ptr pBinder = getBinder();
poco_assert_dbg (!pBinder.isNull());
pBinder->reset();
if (pBinder) pBinder->reset();
}
private:
@@ -110,7 +109,7 @@ private:
template <class T>
class CopyBinding: public AbstractBinding
class CopyBinding final: public AbstractBinding
/// Binding maps a value or multiple values (see Binding specializations for STL containers as
/// well as type handlers) to database column(s). Values to be bound can be either mapped
/// directly (by reference) or a copy can be created, depending on the value of the copy argument.
@@ -168,19 +167,17 @@ public:
{
_bound = false;
AbstractBinder::Ptr pBinder = getBinder();
poco_assert_dbg (!pBinder.isNull());
pBinder->reset();
if (pBinder) pBinder->reset();
}
private:
//typedef typename TypeWrapper<T>::TYPE ValueType;
ValPtr _pVal;
bool _bound;
};
template <>
class Binding<const char*>: public AbstractBinding
class Binding<const char*> final: public AbstractBinding
/// Binding const char* specialization wraps char pointer into string.
{
public:
@@ -230,8 +227,7 @@ public:
{
_bound = false;
AbstractBinder::Ptr pBinder = getBinder();
poco_assert_dbg (!pBinder.isNull());
pBinder->reset();
if (pBinder) pBinder->reset();
}
private:
@@ -242,7 +238,7 @@ private:
template <>
class CopyBinding<const char*>: public AbstractBinding
class CopyBinding<const char*> final: public AbstractBinding
/// Binding const char* specialization wraps char pointer into string.
{
public:
@@ -292,8 +288,7 @@ public:
{
_bound = false;
AbstractBinder::Ptr pBinder = getBinder();
poco_assert_dbg (!pBinder.isNull());
pBinder->reset();
if (pBinder) pBinder->reset();
}
private:
@@ -303,7 +298,7 @@ private:
template <class T>
class Binding<std::vector<T>>: public AbstractBinding
class Binding<std::vector<T>> final: public AbstractBinding
/// Specialization for std::vector.
{
public:
@@ -369,7 +364,7 @@ private:
template <class T>
class CopyBinding<std::vector<T>>: public AbstractBinding
class CopyBinding<std::vector<T>> final: public AbstractBinding
/// Specialization for std::vector.
{
public:
@@ -436,7 +431,7 @@ private:
template <>
class Binding<std::vector<bool>>: public AbstractBinding
class Binding<std::vector<bool>> final: public AbstractBinding
/// Specialization for std::vector<bool>.
/// This specialization is necessary due to the nature of std::vector<bool>.
/// For details, see the standard library implementation of std::vector<bool>
@@ -517,7 +512,7 @@ private:
template <>
class CopyBinding<std::vector<bool>>: public AbstractBinding
class CopyBinding<std::vector<bool>> final: public AbstractBinding
/// Specialization for std::vector<bool>.
/// This specialization is necessary due to the nature of std::vector<bool>.
/// For details, see the standard library implementation of std::vector<bool>
@@ -597,7 +592,7 @@ private:
template <class T>
class Binding<std::list<T>>: public AbstractBinding
class Binding<std::list<T>> final: public AbstractBinding
/// Specialization for std::list.
{
public:
@@ -662,7 +657,7 @@ private:
template <class T>
class CopyBinding<std::list<T>>: public AbstractBinding
class CopyBinding<std::list<T>> final: public AbstractBinding
/// Specialization for std::list.
{
public:
@@ -727,7 +722,7 @@ private:
template <class T>
class Binding<std::deque<T>>: public AbstractBinding
class Binding<std::deque<T>> final: public AbstractBinding
/// Specialization for std::deque.
{
public:
@@ -792,7 +787,7 @@ private:
template <class T>
class CopyBinding<std::deque<T>>: public AbstractBinding
class CopyBinding<std::deque<T>> final: public AbstractBinding
/// Specialization for std::deque.
{
public:
@@ -857,7 +852,7 @@ private:
template <class T>
class Binding<std::set<T>>: public AbstractBinding
class Binding<std::set<T>> final: public AbstractBinding
/// Specialization for std::set.
{
public:
@@ -922,7 +917,7 @@ private:
template <class T>
class CopyBinding<std::set<T>>: public AbstractBinding
class CopyBinding<std::set<T>> final: public AbstractBinding
/// Specialization for std::set.
{
public:
@@ -987,7 +982,7 @@ private:
template <class T>
class Binding<std::multiset<T>>: public AbstractBinding
class Binding<std::multiset<T>> final: public AbstractBinding
/// Specialization for std::multiset.
{
public:
@@ -1052,7 +1047,7 @@ private:
template <class T>
class CopyBinding<std::multiset<T>>: public AbstractBinding
class CopyBinding<std::multiset<T>> final: public AbstractBinding
/// Specialization for std::multiset.
{
public:
@@ -1117,7 +1112,7 @@ private:
template <class K, class V>
class Binding<std::map<K, V>>: public AbstractBinding
class Binding<std::map<K, V>> final: public AbstractBinding
/// Specialization for std::map.
{
public:
@@ -1182,7 +1177,7 @@ private:
template <class K, class V>
class CopyBinding<std::map<K, V>>: public AbstractBinding
class CopyBinding<std::map<K, V>> final: public AbstractBinding
/// Specialization for std::map.
{
public:
@@ -1247,7 +1242,7 @@ private:
template <class K, class V>
class Binding<std::multimap<K, V>>: public AbstractBinding
class Binding<std::multimap<K, V>> final: public AbstractBinding
/// Specialization for std::multimap.
{
public:
@@ -1312,7 +1307,7 @@ private:
template <class K, class V>
class CopyBinding<std::multimap<K, V>>: public AbstractBinding
class CopyBinding<std::multimap<K, V>> final: public AbstractBinding
/// Specialization for std::multimap.
{
public:
+4 -4
View File
@@ -403,19 +403,19 @@ public:
/// to start iteration from beginning or end,
/// depending on the position requested.
{
if (row <= (std::size_t) (_pData->size() / 2))
if (row <= (_pData->size() / 2))
{
Iterator it = _pData->begin();
Iterator end = _pData->end();
for (int i = 0; it != end; ++it, ++i)
for (std::size_t i = 0; it != end; ++it, ++i)
if (i == row) return *it;
}
else
{
row = _pData->size() - row;
RIterator it = _pData->rbegin();
RIterator end = _pData->rend();
for (int i = 1; it != end; ++it, ++i)
const RIterator end = _pData->rend();
for (std::size_t i = 1; it != end; ++it, ++i)
if (i == row) return *it;
}
+17 -14
View File
@@ -31,7 +31,7 @@ namespace Dynamic {
class Var;
}
} // namespace Dynamic
namespace Data {
@@ -56,6 +56,9 @@ public:
~Date();
/// Destroys the Date.
Date(const Date & ) = default;
Date(Date && ) = default;
int year() const;
/// Returns the year.
@@ -151,7 +154,8 @@ inline bool Date::operator > (const Date& date) const
}
} } // namespace Poco::Data
} // namespace Data
} // namespace Poco
//
@@ -171,39 +175,38 @@ public:
{
}
~VarHolderImpl()
{
}
~VarHolderImpl() = default;
VarHolderImpl() = delete;
const std::type_info& type() const
const std::type_info& type() const override
{
return typeid(Poco::Data::Date);
}
void convert(Poco::Timestamp& val) const
void convert(Poco::Timestamp& val) const override
{
DateTime dt;
dt.assign(_val.year(), _val.month(), _val.day());
val = dt.timestamp();
}
void convert(Poco::DateTime& val) const
void convert(Poco::DateTime& val) const override
{
val.assign(_val.year(), _val.month(), _val.day());
}
void convert(Poco::LocalDateTime& val) const
void convert(Poco::LocalDateTime& val) const override
{
val.assign(_val.year(), _val.month(), _val.day());
}
void convert(std::string& val) const
void convert(std::string& val) const override
{
DateTime dt(_val.year(), _val.month(), _val.day());
const DateTime dt(_val.year(), _val.month(), _val.day());
val = DateTimeFormatter::format(dt, "%Y/%m/%d");
}
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
{
return cloneHolder(pVarHolder, _val);
}
@@ -214,12 +217,12 @@ public:
}
private:
VarHolderImpl();
Poco::Data::Date _val;
};
} } // namespace Poco::Dynamic
} // namespace Dynamic
} // namespace Poco
#endif // Data_Date_INCLUDED
+6 -9
View File
@@ -492,10 +492,10 @@ private:
template <class C>
class InternalExtraction: public Extraction<C>
/// Container Data Type specialization extension for extraction of values from a query result set.
/// Container Data Type extension for extraction of values from a query result set.
///
/// This class is intended for PocoData internal use - it is used by StatementImpl
/// to automaticaly create internal Extraction in cases when statement returns data and no external storage
/// to automatically create internal Extraction in cases when statement returns data and no external storage
/// was supplied. It is later used by RecordSet to retrieve the fetched data after statement execution.
/// It takes ownership of the Column pointer supplied as constructor argument. Column object, in turn
/// owns the data container pointer.
@@ -503,17 +503,14 @@ class InternalExtraction: public Extraction<C>
/// InternalExtraction objects can not be copied or assigned.
{
public:
using ValType = typename C::value_type;
using ValPtr = SharedPtr<ValType>;
using Type = Extraction<ValType>;
using Ptr = SharedPtr<Type>;
using HeldValType = typename C::value_type;
InternalExtraction(C& result, Column<C>* pColumn, const Position& pos = Position(0)):
Extraction<C>(result, ValType(), pos),
Extraction<C>(result, HeldValType(), pos),
_pColumn(pColumn)
/// Creates InternalExtraction.
{
AbstractExtraction::setHeldType<C>();
}
~InternalExtraction()
@@ -528,7 +525,7 @@ public:
_pColumn->reset();
}
const ValType& value(int index) const
const HeldValType& value(int index) const
{
try
{
+9 -1
View File
@@ -63,7 +63,15 @@ public:
{
}
LOB(const std::basic_string<T>& content):
template<typename U = T>
LOB(const std::enable_if_t<std::is_same_v<T, U> && std::is_same_v<U, char>, std::string>& content):
_pContent(new std::vector<T>(content.begin(), content.end()))
/// Creates a LOB from a string.
{
}
template<typename U = T>
LOB(const std::enable_if_t<std::is_same_v<T, U> && std::is_same_v<U, wchar_t>, std::wstring>& content):
_pContent(new std::vector<T>(content.begin(), content.end()))
/// Creates a LOB from a string.
{
+4 -2
View File
@@ -62,10 +62,12 @@ public:
bool hasTransactionIsolation(Poco::UInt32) const;
bool isTransactionIsolation(Poco::UInt32) const;
const std::string& connectorName() const;
bool hasFeature(const std::string& name) const;
void setFeature(const std::string& name, bool state);
bool getFeature(const std::string& name);
bool getFeature(const std::string& name) const;
bool hasProperty(const std::string& name) const;
void setProperty(const std::string& name, const Poco::Any& value);
Poco::Any getProperty(const std::string& name);
Poco::Any getProperty(const std::string& name) const;
protected:
SessionImpl* access() const;
+2 -1
View File
@@ -50,7 +50,8 @@ public:
void prepare()
/// Prepares data.
{
TypeHandler<T>::prepare(_pos, _val, preparation());
auto pPrep = preparation();
TypeHandler<T>::prepare(_pos, _val, pPrep);
}
private:
+16 -97
View File
@@ -20,7 +20,6 @@
#include "Poco/Data/Data.h"
#include "Poco/Data/Session.h"
#include "Poco/Data/Extraction.h"
#include "Poco/Data/BulkExtraction.h"
#include "Poco/Data/Statement.h"
#include "Poco/Data/RowIterator.h"
@@ -69,7 +68,7 @@ class Data_API RecordSet: private Statement
/// a limit for the Statement.
{
public:
using RowMap = std::map<std::size_t, Row*>;
using RowMap = std::map<std::size_t, std::shared_ptr<Row>>;
using ConstIterator = const RowIterator;
using Iterator = RowIterator;
@@ -133,14 +132,16 @@ public:
/// for large recordsets, so it should be used judiciously.
/// Use totalRowCount() to obtain the total number of rows.
std::size_t affectedRowCount() const;
/// Returns the number of rows affected by the statement execution.
std::size_t extractedRowCount() const;
/// Returns the number of rows extracted during the last statement
/// execution.
/// The number of rows reported is independent of filtering.
POCO_DEPRECATED("Replaced with subTotalRowCount() and getTotalRowCount()")
std::size_t totalRowCount() const;
//@ deprecated
/// Replaced with subTotalRowCount() and getTotalRowCount().
std::size_t getTotalRowCount() const;
/// Returns the total number of rows in the RecordSet.
@@ -163,100 +164,23 @@ public:
/// Returns the number of columns in the recordset.
template <class C>
const Column<C>& column(const std::string& name) const
const Column<C>& column(const std::string& name) const;
/// Returns the reference to the first Column with the specified name.
{
if (isBulkExtraction())
{
using E = InternalBulkExtraction<C>;
return columnImpl<C,E>(name);
}
else
{
using E = InternalExtraction<C>;
return columnImpl<C,E>(name);
}
}
template <class C>
const Column<C>& column(std::size_t pos) const
/// Returns the reference to column at specified position.
{
if (isBulkExtraction())
{
using E = InternalBulkExtraction<C>;
return columnImpl<C,E>(pos);
}
else
{
using E = InternalExtraction<C>;
return columnImpl<C,E>(pos);
}
}
const Column<C>& column(std::size_t pos) const;
Row& row(std::size_t pos);
/// Returns reference to row at position pos.
/// Rows are lazy-created and cached.
template <class T>
const T& value(std::size_t col, std::size_t row, bool useFilter = true) const
const T& value(std::size_t col, std::size_t row, bool useFilter = true) const;
/// Returns the reference to data value at [col, row] location.
{
if (useFilter && isFiltered() && !isAllowed(row))
throw InvalidAccessException("Row not allowed");
switch (storage())
{
case STORAGE_VECTOR:
{
using C = typename std::vector<T>;
return column<C>(col).value(row);
}
case STORAGE_LIST:
{
using C = typename std::list<T>;
return column<C>(col).value(row);
}
case STORAGE_DEQUE:
case STORAGE_UNKNOWN:
{
using C = typename std::deque<T>;
return column<C>(col).value(row);
}
default:
throw IllegalStateException("Invalid storage setting.");
}
}
template <class T>
const T& value(const std::string& name, std::size_t row, bool useFilter = true) const
const T& value(const std::string& name, std::size_t row, bool useFilter = true) const;
/// Returns the reference to data value at named column, row location.
{
if (useFilter && isFiltered() && !isAllowed(row))
throw InvalidAccessException("Row not allowed");
switch (storage())
{
case STORAGE_VECTOR:
{
using C = typename std::vector<T>;
return column<C>(name).value(row);
}
case STORAGE_LIST:
{
using C = typename std::list<T>;
return column<C>(name).value(row);
}
case STORAGE_DEQUE:
case STORAGE_UNKNOWN:
{
using C = typename std::deque<T>;
return column<C>(name).value(row);
}
default:
throw IllegalStateException("Invalid storage setting.");
}
}
Poco::Dynamic::Var value(std::size_t col, std::size_t row, bool checkFiltering = true) const;
/// Returns the data value at column, row location.
@@ -452,27 +376,22 @@ private:
const Column<C>& columnImpl(std::size_t pos) const
/// Returns the reference to column at specified position.
{
using T = typename C::value_type;
using ExtractionVecPtr = const E*;
const AbstractExtractionVec& rExtractions = extractions();
std::size_t s = rExtractions.size();
if (0 == s || pos >= s)
throw RangeException(Poco::format("Invalid column index: %z", pos));
ExtractionVecPtr pExtraction = dynamic_cast<ExtractionVecPtr>(rExtractions[pos].get());
if (pExtraction)
auto pExtraction = rExtractions[pos].cast<E>();
if (!pExtraction)
{
return pExtraction->column();
}
else
{
throw Poco::BadCastException(Poco::format("Type cast failed!\nColumn: %z\nTarget type:\t%s",
throw Poco::BadCastException(Poco::format("Type dynamic cast failed!\n"
"Column: %z\nConversion:\n%s\n%s",
pos,
std::string(typeid(T).name())));
Poco::demangle(typeid(typename E::ValType).name()),
rExtractions[pos]->getHeldType()));
}
return pExtraction->column();
}
bool isAllowed(std::size_t row) const;
+197 -54
View File
@@ -19,21 +19,28 @@
#include "Poco/Data/Data.h"
#include "Poco/Data/Connector.h"
#include "Poco/Data/Session.h"
#include "Poco/Data/Statement.h"
#include "Poco/Logger.h"
#include "Poco/Data/ArchiveStrategy.h"
#include "Poco/Channel.h"
#include "Poco/FileChannel.h"
#include "Poco/Message.h"
#include "Poco/AutoPtr.h"
#include "Poco/String.h"
#include "Poco/NotificationQueue.h"
#include "Poco/Thread.h"
#include "Poco/Stopwatch.h"
#include "Poco/Event.h"
#include <atomic>
#include <atomic>
namespace Poco {
namespace Data {
class Data_API SQLChannel: public Poco::Channel
class Data_API SQLChannel: public Poco::Channel, Poco::Runnable
/// This Channel implements logging to a SQL database.
/// The channel is dependent on the schema. The DDL for
/// table creation (subject to target DDL dialect dependent
@@ -50,38 +57,82 @@ class Data_API SQLChannel: public Poco::Channel
///
/// The table name is configurable through "table" property.
/// Other than DateTime filed name used for optional time-based archiving purposes, currently the
/// field names are not mandated. However, it is recomended to use names as specified above.
/// field names are not mandated. However, it is recommended to use names as specified above.
///
/// To provide as non-intrusive operation as possbile, the log entries are cached and
/// To provide as non-intrusive operation as possible, the log entries are cached and
/// inserted into the target database asynchronously by default. The blocking, however, will occur
/// before the next entry insertion with default timeout of 1 second. The default settings can be
/// overridden (see async, timeout and throw properties for details).
/// If throw property is false, insertion timeouts are ignored, otherwise a TimeoutException is thrown.
/// To force insertion of every entry, set timeout to 0. This setting, however, introduces
/// a risk of long blocking periods in case of remote server communication delays.
///
/// A default-constructed SQLChannel operates without an active DB connection, in a store-and-forward
/// mode. For this mode of operation, a separate service is required to consume and execute the SQL
/// statements from the stored files and insert the log entries into the database. Since this setup
/// stores SQL inserts in the OS file system, it is strongly recommended to take the necessary
/// precautions to limit and secure the access to those files.
{
public:
using Ptr = Poco::AutoPtr<SQLChannel>;
class LogNotification : public Poco::Notification
{
public:
using Ptr = Poco::AutoPtr<LogNotification>;
LogNotification(const Poco::Message& message) :
_message(message)
{
}
const Poco::Message& message() const
{
return _message;
}
private:
Poco::Message _message;
};
static const int DEFAULT_MIN_BATCH_SIZE = 1;
static const int DEFAULT_MAX_BATCH_SIZE = 1000;
static const int DEFAULT_MAX_SQL_SIZE = 65536;
static const int DEFAULT_FLUSH_SECONDS = 10;
SQLChannel();
/// Creates SQLChannel.
/// An SQLChannel without DB connector and local file name
/// only logs SQL inserts into local files. A separate file
/// is created for each insert batch; files are named
/// <YYYYMMDDHH24MISSmmm>.<UUID>.log.sql.
SQLChannel(const std::string& connector,
const std::string& connect,
const std::string& name = "-");
/// Creates a SQLChannel with the given connector, connect string, timeout, table and name.
const std::string& name = "-",
const std::string& table = "T_POCO_LOG",
int timeout = 1000,
int minBatch = DEFAULT_MIN_BATCH_SIZE,
int maxBatch = DEFAULT_MAX_BATCH_SIZE,
int maxSQL = DEFAULT_MAX_SQL_SIZE);
/// Creates an SQLChannel with the given connector, connect string, timeout, table and name.
/// The connector must be already registered.
void open();
void open() override;
/// Opens the SQLChannel.
/// Returns true if succesful.
void close();
void close() override;
/// Closes the SQLChannel.
void log(const Message& msg);
void run() override;
/// Dequeues and sends the logs to the DB.
bool isRunning() const;
/// Returns true if the logging thread is running.
void log(const Message& msg) override;
/// Writes the log message to the database.
void setProperty(const std::string& name, const std::string& value);
void setProperty(const std::string& name, const std::string& value) override;
/// Sets the property with the given value.
///
/// The following properties are supported:
@@ -108,23 +159,55 @@ public:
/// the target, the previous operation must have been either completed
/// or timed out (see timeout and throw properties for details on
/// how abnormal conditos are handled).
/// This property is deprecated and has no effect - all logging
/// is asynchronous since the 1.13.0. release.
///
/// * timeout: Timeout (ms) to wait for previous log operation completion.
/// Values "0" and "" mean no timeout. Only valid when logging
/// is asynchronous, otherwise ignored.
/// Values "0" and "" mean no timeout.
///
/// * throw: Boolean value indicating whether to throw in case of timeout.
/// Setting this property to false may result in log entries being lost.
/// True values are (case insensitive) "true", "t", "yes", "y".
/// Anything else yields false.
///
/// * minBatch: Minimal number of log entries to accumulate before actually sending
/// logs to the destination.
/// Defaults to 1 entry (for compatibility with older versions);
/// can't be zero or larger than `maxBatch`.
///
/// * maxBatch: Maximum number of log entries to accumulate. When the log queue
/// reaches this size, log entries are silently discarded.
/// Defaults to 100, can't be zero or larger than 1000.
///
/// * maxSQL: Maximum total length of the SQL statement. Defaults to 65536.
///
/// * bulk: Do bulk execute (on most DBMS systems, this can speed up things
/// drastically).
///
/// * file Destination file name for the backup FileChannel, used when DB
/// connection is not present to log not executed SQL statements.
///
/// * flush Time in seconds to flush outstanding log entries; since logging
/// is performed in batches of entries, the entries that do not make
/// it into the last logged batch may remain unlogged for a long time
/// during an extened period of inactivity. This setting ensures that
/// unlogged entries are flushed in such circumstances, even when the
/// minimum batch size was not reached.
/// Zero value means no flushing.
std::string getProperty(const std::string& name) const;
std::string getProperty(const std::string& name) const override;
/// Returns the value of the property with the given name.
std::size_t wait();
void stop();
/// Stops and joins the logging thread..
std::size_t wait(int ms = 1000);
/// Waits for the completion of the previous operation and returns
/// the result. If chanel is in synchronous mode, returns 0 immediately.
size_t logged() const;
/// Returns the number of logged entries.
static void registerChannel();
/// Registers the channel with the global LoggingFactory.
@@ -134,58 +217,107 @@ public:
static const std::string PROP_TABLE;
static const std::string PROP_ARCHIVE_TABLE;
static const std::string PROP_MAX_AGE;
static const std::string PROP_ASYNC;
POCO_DEPRECATED("") static const std::string PROP_ASYNC;
static const std::string PROP_TIMEOUT;
static const std::string PROP_MIN_BATCH;
static const std::string PROP_MAX_BATCH;
static const std::string PROP_MAX_SQL;
static const std::string PROP_BULK;
static const std::string PROP_THROW;
static const std::string PROP_DIRECTORY;
static const std::string PROP_FILE;
static const std::string PROP_FLUSH;
protected:
~SQLChannel();
~SQLChannel() override;
private:
static const std::string SQL_INSERT_STMT;
using SessionPtr = Poco::SharedPtr<Session>;
using StatementPtr = Poco::SharedPtr<Statement>;
using Priority = Poco::Message::Priority;
using StrategyPtr = Poco::SharedPtr<ArchiveStrategy>;
void initLogStatement();
/// Initiallizes the log statement.
void reconnect();
/// Closes and opens the DB connection.
void initArchiveStatements();
/// Initiallizes the archive statement.
bool processBatch(int minBatch = 0);
/// Processes a batch of messages.
/// If the number of acummulated messages is greater
/// than minBatch, sends logs to the destination.
/// Returns true if at least one log entry was sent
/// to the destination.
void logAsync(const Message& msg);
/// Waits for previous operation completion and
/// calls logSync(). If the previous operation times out,
/// and _throw is true, TimeoutException is thrown, oterwise
/// the timeout is ignored and log entry is lost.
size_t execSQL(bool flush = false);
/// Executes the log statement.
void logSync(const Message& msg);
/// Inserts the message in the target database.
size_t logSync(bool flush = false);
/// Inserts entries into the target database.
bool isTrue(const std::string& value) const;
/// Returns true is value is "true", "t", "yes" or "y".
/// Case insensitive.
std::string _connector;
std::string _connect;
SessionPtr _pSession;
StatementPtr _pLogStatement;
std::string _name;
std::string _table;
int _timeout;
bool _throw;
bool _async;
size_t logToDB(bool flush = false);
/// Logs cached entries to the DB.
// members for log entry cache (needed for async mode)
std::string _source;
long _pid;
std::string _thread;
long _tid;
int _priority;
std::string _text;
DateTime _dateTime;
size_t logToFile(bool flush = false);
/// Logs cached entries to a file.
/// Called in case DB insertions fail or
/// in the store-and-forward mode of operation.
StrategyPtr _pArchiveStrategy;
void logLocal(const std::string&, Message::Priority prio = Message::PRIO_ERROR);
/// Adds the message to the local SQLChannel log queue, and logs it to the file.
/// Typically used to log DB connection/execution erors.
std::string maskPwd();
/// Masks the password in the connection
/// string, if detected. This is not a
/// bullet-proof method; if not succesful,
/// empty string is returned.
bool shouldFlush() const;
/// Returns true if there are unflushed log entries
/// and the flush timer has expired.
mutable Poco::FastMutex _mutex;
std::string _connector;
std::string _connect;
SessionPtr _pSession;
std::string _sql;
std::string _name;
std::string _table;
std::atomic<bool> _tableChanged;
std::atomic<int> _timeout;
std::atomic<int> _minBatch;
std::atomic<int> _maxBatch;
std::atomic<int> _maxSQL;
std::atomic<bool> _bulk;
std::atomic<bool> _throw;
std::atomic<int> _flush;
// members for log entry cache
std::deque<std::string> _source;
std::deque<long> _pid;
std::deque<std::string> _thread;
std::deque<long> _tid;
std::deque<int> _priority;
std::deque<std::string> _text;
std::deque<DateTime> _dateTime;
Poco::NotificationQueue _logQueue;
std::unique_ptr<Poco::Thread> _pLogThread;
std::atomic<bool> _reconnect;
std::atomic<bool> _stop;
std::atomic<size_t> _logged;
StrategyPtr _pArchiveStrategy;
std::string _file;
std::string _directory;
AutoPtr<FileChannel> _pFileChannel;
Poco::Stopwatch _flushTimer;
Poco::Event _event;
Poco::Logger& _logger = Poco::Logger::get("SQLChannel");
};
@@ -193,14 +325,6 @@ private:
// inlines
//
inline std::size_t SQLChannel::wait()
{
if (_async && _pLogStatement)
return _pLogStatement->wait(_timeout);
return 0;
}
inline bool SQLChannel::isTrue(const std::string& value) const
{
@@ -211,6 +335,25 @@ inline bool SQLChannel::isTrue(const std::string& value) const
}
inline bool SQLChannel::isRunning() const
{
return _pLogThread && _pLogThread->isRunning();
}
inline size_t SQLChannel::logged() const
{
return _logged;
}
inline bool SQLChannel::shouldFlush() const
{
return (_flush > 0 && _source.size() &&
(_flushTimer.elapsedSeconds() >= _flush));
}
} } // namespace Poco::Data
+62 -24
View File
@@ -151,6 +151,12 @@ class Data_API Session
/// If the formatting will occur and the percent sign is part of the query itself, it can be passed to the query by entering it twice (%%).
/// However, if no formatting is used, one percent sign is sufficient as the string will be passed unaltered.
/// For complete list of supported data types with their respective specifications, see the documentation for format in Foundation.
///
/// Transactions are supported via the begin(), commit() and rollback() methods.
/// If the session is in autocommit mode, begin() will temporarily disable autocommit mode for the duration of the transaction.
/// Calls to either commit() or rollback() will re-enable it.
/// Poco::Data::Transaction, a convenient session wrapper class, automates this process and provides RAII-based transactional behavior.
/// For more information, see Transation class documentation.
{
public:
static const std::size_t LOGIN_TIMEOUT_DEFAULT = SessionImpl::LOGIN_TIMEOUT_DEFAULT;
@@ -160,16 +166,16 @@ public:
static const Poco::UInt32 TRANSACTION_SERIALIZABLE = 0x00000008L;
Session(Poco::AutoPtr<SessionImpl> ptrImpl);
/// Creates the Session.
/// Creates the Session from SessionImpl.
Session(const std::string& connector,
const std::string& connectionString,
std::size_t timeout = LOGIN_TIMEOUT_DEFAULT);
std::size_t loginTimeout = LOGIN_TIMEOUT_DEFAULT);
/// Creates a new session, using the given connector (which must have
/// been registered), and connectionString.
Session(const std::string& connection,
std::size_t timeout = LOGIN_TIMEOUT_DEFAULT);
std::size_t loginTimeout = LOGIN_TIMEOUT_DEFAULT);
/// Creates a new session, using the given connection (must be in
/// "connection:///connectionString" format).
@@ -193,11 +199,16 @@ public:
template <typename T>
Statement operator << (const T& t)
/// Creates a Statement with the given data as SQLContent
/// Creates a Statement with the given string as SQLContent.
{
return _statementCreator << t;
return (_statementCreator << t);
}
const std::string& dbmsName() const;
/// Returns the DBMS name. The name must be set by the
/// implementation.
/// Defaults to "unknown".
SharedPtr<StatementImpl> createStatementImpl();
/// Creates a StatementImpl.
@@ -221,6 +232,13 @@ public:
bool isGood();
/// Returns true iff the session is good and can be used, false otherwise.
bool isAutocommit() const;
/// Returns true iff the session is in autocommit mode, false otherwise.
/// If the session does not support autocommit, it is assumed not to
/// be in auto commit mode.
/// This function looks for the "autoCommit" feature and returns its value.
/// It is recommended for all back-end implementations to support this feature.
void setLoginTimeout(std::size_t timeout);
/// Sets the session login timeout value.
@@ -235,12 +253,19 @@ public:
void begin();
/// Starts a transaction.
/// If `session` is in autocommit mode, it is switched to manual commit mode
/// for the duration of the transaction and reverted back to the original mode
/// after transaction completes (on rollback or commit() call).
void commit();
/// Commits and ends a transaction.
/// If `session` was in autocommit mode when the transaction started (begin() call),
/// it is switched back to autocommit mode.
void rollback();
/// Rolls back and ends a transaction.
/// If `session` was in autocommit mode when the transaction started (begin() call),
/// it is switched back to autocommit mode.
bool canTransact();
/// Returns true if session has transaction capabilities.
@@ -273,6 +298,9 @@ public:
/// Utility function that teturns the URI formatted from supplied
/// arguments as "connector:///connectionString".
bool hasFeature(const std::string& name) const;
/// Returns true if session has the named feature.
void setFeature(const std::string& name, bool state);
/// Set the state of a feature.
///
@@ -291,6 +319,9 @@ public:
/// Throws a NotSupportedException if the requested feature is
/// not supported by the underlying implementation.
bool hasProperty(const std::string& name) const;
/// Returns true if session has the named property.
void setProperty(const std::string& name, const Poco::Any& value);
/// Set the value of a property.
///
@@ -316,13 +347,27 @@ private:
Session();
Poco::AutoPtr<SessionImpl> _pImpl;
StatementCreator _statementCreator;
StatementCreator _statementCreator;
bool _wasAutoCommit = false;
};
//
// inlines
//
inline const std::string& Session::dbmsName() const
{
return _pImpl->dbmsName();
}
inline bool Session::isAutocommit() const
{
return _pImpl->isAutocommit();
}
inline SharedPtr<StatementImpl> Session::createStatementImpl()
{
return _pImpl->createStatementImpl();
@@ -383,24 +428,6 @@ inline std::size_t Session::getConnectionTimeout()
}
inline void Session::begin()
{
return _pImpl->begin();
}
inline void Session::commit()
{
return _pImpl->commit();
}
inline void Session::rollback()
{
return _pImpl->rollback();
}
inline bool Session::canTransact()
{
return _pImpl->canTransact();
@@ -456,6 +483,12 @@ inline std::string Session::uri() const
}
inline bool Session::hasFeature(const std::string& name) const
{
return _pImpl->hasFeature(name);
}
inline void Session::setFeature(const std::string& name, bool state)
{
_pImpl->setFeature(name, state);
@@ -468,6 +501,11 @@ inline bool Session::getFeature(const std::string& name) const
}
inline bool Session::hasProperty(const std::string& name) const
{
return _pImpl->hasProperty(name);
}
inline void Session::setProperty(const std::string& name, const Poco::Any& value)
{
_pImpl->setProperty(name, value);
+55 -4
View File
@@ -53,13 +53,23 @@ public:
static const std::size_t CONNECTION_TIMEOUT_DEFAULT = CONNECTION_TIMEOUT_INFINITE;
/// Default connection/login timeout in seconds.
// ODBC only, otherwise no-op
static const int CURSOR_USE_ALWAYS = 0;
static const int CURSOR_USE_IF_NEEDED = 1;
static const int CURSOR_USE_NEVER = 2;
SessionImpl(const std::string& connectionString,
std::size_t timeout = LOGIN_TIMEOUT_DEFAULT);
std::size_t loginTimeout = LOGIN_TIMEOUT_DEFAULT);
/// Creates the SessionImpl.
virtual ~SessionImpl();
/// Destroys the SessionImpl.
const std::string& dbmsName() const;
/// Returns the DBMS name. The name must be set by the
/// implementation.
/// Defaults to "unknown".
virtual Poco::SharedPtr<StatementImpl> createStatementImpl() = 0;
/// Creates a StatementImpl.
@@ -113,7 +123,7 @@ public:
/// Returns true if session has transaction capabilities.
virtual bool isTransaction() const = 0;
/// Returns true iff a transaction is a transaction is in progress, false otherwise.
/// Returns true iff a transaction is in progress, false otherwise.
virtual void setTransactionIsolation(Poco::UInt32) = 0;
/// Sets the transaction isolation level.
@@ -141,6 +151,15 @@ public:
std::string uri() const;
/// Returns the URI for this session.
bool isAutocommit() const;
/// Returns true if autocommit is on, false otherwise.
bool shouldParse() const;
/// Returns true if SQL parser is enabled, false otherwise.
virtual bool hasFeature(const std::string& name) const = 0;
/// Returns true if session has the named feature.
virtual void setFeature(const std::string& name, bool state) = 0;
/// Set the state of a feature.
///
@@ -150,7 +169,7 @@ public:
/// Throws a NotSupportedException if the requested feature is
/// not supported by the underlying implementation.
virtual bool getFeature(const std::string& name) = 0;
virtual bool getFeature(const std::string& name) const = 0;
/// Look up the state of a feature.
///
/// Features are a generic extension mechanism for session implementations.
@@ -159,6 +178,9 @@ public:
/// Throws a NotSupportedException if the requested feature is
/// not supported by the underlying implementation.
virtual bool hasProperty(const std::string& name) const = 0;
/// Returns true if session has the named feature.
virtual void setProperty(const std::string& name, const Poco::Any& value) = 0;
/// Set the value of a property.
///
@@ -168,7 +190,7 @@ public:
/// Throws a NotSupportedException if the requested property is
/// not supported by the underlying implementation.
virtual Poco::Any getProperty(const std::string& name) = 0;
virtual Poco::Any getProperty(const std::string& name) const = 0;
/// Look up the value of a property.
///
/// Properties are a generic extension mechanism for session implementations.
@@ -178,6 +200,9 @@ public:
/// not supported by the underlying implementation.
protected:
void setDBMSName(const std::string& name);
/// Sets the DBMS name.
void setConnectionString(const std::string& connectionString);
/// Sets the connection string. Should only be called on
/// disconnected sessions. Throws InvalidAccessException when called on
@@ -188,6 +213,7 @@ private:
SessionImpl(const SessionImpl&);
SessionImpl& operator = (const SessionImpl&);
std::string _dbmsName;
std::string _connectionString;
std::size_t _loginTimeout;
};
@@ -196,6 +222,19 @@ private:
//
// inlines
//
inline void SessionImpl::setDBMSName(const std::string& name)
{
_dbmsName = name;
}
inline const std::string& SessionImpl::dbmsName() const
{
return _dbmsName;
}
inline const std::string& SessionImpl::connectionString() const
{
return _connectionString;
@@ -227,6 +266,18 @@ inline std::string SessionImpl::uri() const
}
inline bool SessionImpl::isAutocommit() const
{
return hasFeature("autoCommit") && getFeature("autoCommit");
}
inline bool SessionImpl::shouldParse() const
{
return hasFeature("sqlParse") && getFeature("sqlParse");
}
} } // namespace Poco::Data
+17 -17
View File
@@ -146,13 +146,13 @@ public:
void setFeature(const std::string& name, bool state);
/// Sets feature for all the sessions.
bool getFeature(const std::string& name);
bool getFeature(const std::string& name) const;
/// Returns the requested feature.
void setProperty(const std::string& name, const Poco::Any& value);
/// Sets property for all sessions.
Poco::Any getProperty(const std::string& name);
Poco::Any getProperty(const std::string& name) const;
/// Returns the requested property.
void shutdown();
@@ -191,21 +191,21 @@ private:
void closeAll(SessionList& sessionList);
std::string _connector;
std::string _connectionString;
int _minSessions;
int _maxSessions;
int _idleTime;
int _connTimeout;
int _nSessions;
SessionList _idleSessions;
SessionList _activeSessions;
Poco::Timer _janitorTimer;
FeatureMap _featureMap;
PropertyMap _propertyMap;
bool _shutdown;
AddPropertyMap _addPropertyMap;
AddFeatureMap _addFeatureMap;
std::string _connector;
std::string _connectionString;
std::atomic<int> _minSessions;
std::atomic<int> _maxSessions;
std::atomic<int> _idleTime;
std::atomic<int> _connTimeout;
std::atomic<int> _nSessions;
SessionList _idleSessions;
SessionList _activeSessions;
Poco::Timer _janitorTimer;
FeatureMap _featureMap;
PropertyMap _propertyMap;
std::atomic<bool> _shutdown;
AddPropertyMap _addPropertyMap;
AddFeatureMap _addFeatureMap;
mutable
Poco::Mutex _mutex;
+3 -4
View File
@@ -107,20 +107,19 @@ inline std::streamsize SimpleRowFormatter::getSpacing() const
} } // namespace Poco::Data
#ifndef POCO_DOC
namespace std
{
// Note: for an unknown reason, clang refuses to compile this function as noexcept
template<>
inline void swap<Poco::Data::SimpleRowFormatter>(Poco::Data::SimpleRowFormatter& s1,
Poco::Data::SimpleRowFormatter& s2)
#ifndef POCO_COMPILER_CLANG
noexcept
#endif
noexcept(std::is_nothrow_swappable_v<Poco::Data::SimpleRowFormatter>)
/// Full template specalization of std:::swap for SimpleRowFormatter
{
s1.swap(s2);
}
}
#endif
#endif // Data_SimpleRowFormatter_INCLUDED
+153 -8
View File
@@ -30,12 +30,25 @@
#include "Poco/ActiveMethod.h"
#include "Poco/ActiveResult.h"
#include "Poco/Format.h"
#include "Poco/Optional.h"
#include <algorithm>
#ifndef POCO_DATA_NO_SQL_PARSER
namespace hsql {
class SQLParserResult;
}
#endif // POCO_DATA_NO_SQL_PARSER
namespace Poco {
namespace Data {
#ifndef POCO_DATA_NO_SQL_PARSER
namespace Parser = hsql; // namespace Poco::Data::Parser
#endif // POCO_DATA_NO_SQL_PARSER
class AbstractBinding;
class AbstractExtraction;
@@ -70,6 +83,18 @@ class Data_API Statement
/// member function.
/// If no formatter is externally supplied to the statement, the SimpleRowFormatter is lazy
/// created and used.
///
/// If compiled with SQLParser support, Statement knows the number and type of the SQL statement(s)
/// it contains, to the extent that the SQL string is a standard SQL and the staement type is supported.
/// No proprietary SQL extensions are supported.
///
/// Supported statement types are:
///
/// - SELECT
/// - INSERT
/// - UPDATE
/// - DELETE
///
{
public:
typedef void (*Manipulator)(Statement&);
@@ -189,9 +214,9 @@ public:
/// Registers extraction container with the Statement.
{
if (reset) _pImpl->resetExtraction();
typename C::iterator itAE = val.begin();
typename C::iterator itAEEnd = val.end();
for (; itAE != itAEEnd; ++itAE) addExtract(*itAE);
typename C::iterator it = val.begin();
typename C::iterator end = val.end();
for (; it != end; ++it) addExtract(*it);
return *this;
}
@@ -200,9 +225,9 @@ public:
/// Registers container of extraction containers with the Statement.
{
_pImpl->resetExtraction();
typename C::iterator itAEV = val.begin();
typename C::iterator itAEVEnd = val.end();
for (; itAEV != itAEVEnd; ++itAEV) addExtraction(*itAEV, false);
typename C::iterator it = val.begin();
typename C::iterator end = val.end();
for (; it != end; ++it) addExtraction(*it, false);
return *this;
}
@@ -291,6 +316,57 @@ public:
const std::string& toString() const;
/// Creates a string from the accumulated SQL statement.
Optional<std::size_t> statementsCount() const;
/// 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();
/// Parses the SQL statement and returns true if successful.
///
/// Note that parsing is not guaranteed to succeed, as some backends have proprietary
/// 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
/// calling parseError().
///
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
const std::string& parseError();
/// Returns the SQL statement parse error message, if any.
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns an empty string.
Optional<bool> isSelect() const;
/// Returns true if the statement consists only of SELECT statement(s).
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
Optional<bool> isInsert() const;
/// Returns true if the statement consists only of INSERT statement(s).
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
Optional<bool> isUpdate() const;
/// Returns true if the statement consists only of UPDATE statement(s).
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
Optional<bool> isDelete() const;
/// Returns true if the statement consists only of DELETE statement(s).
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
Optional<bool> hasSelect() const;
/// Returns true if the statement contains a SELECT statement.
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
Optional<bool> hasInsert() const;
/// Returns true if the statement contains an INSERT statement.
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
Optional<bool> hasUpdate() const;
/// Returns true if the statement contains an UPDATE statement.
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
Optional<bool> hasDelete() const;
/// Returns true if the statement contains a DELETE statement.
/// For Poco::Data builds with POCO_DATA_NO_SQL_PARSER, it always returns unspecified.
std::size_t execute(bool reset = true);
/// Executes the statement synchronously or asynchronously.
/// Stops when either a limit is hit or the whole statement was executed.
@@ -298,11 +374,35 @@ public:
/// returning data) or number of rows affected (for all other statements).
/// If reset is true (default), associated storage is reset and reused.
/// Otherwise, the results from this execution step are appended.
/// Reset argument has no meaning for unlimited statements that return all rows.
/// The reset argument has no meaning for unlimited statements that return all rows.
/// If isAsync() returns true, the statement is executed asynchronously
/// and the return value from this function is zero.
/// The result of execution (i.e. number of returned or affected rows) can be
/// obtained by calling wait() on the statement at a later point in time.
///
/// When Poco::Data is compiled with SQL parsing support, if session is not already in
/// a transaction and not in autocommit mode, an attempt to parse the SQL is made before
/// statement execution, and if (1) successful, and (2) the statement does not consist
/// only of SELECT statements, a transaction is started.
///
/// Note that parsing is not guaranteed to succeed, as some backends have proprietary
/// 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 calling
/// Statement::parseError().
/// When parsing does not succeed, transaction is not started, and Poco::Data::Session will
/// not reflect its state accurately. The underlying database session, however, will be in
/// transaction state. In such state, in order to complete the transaction and unlock the
/// resources, commit() or rollback() must be called on the Poco::Data::Session; this is
/// true even for a single SELECT statement in non-autocommit mode when parsing does not
/// succeed.
///
/// For Poco::Data builds without SQLParser support, the behavior is the same as
/// for unsuccesful parsing.
void executeDirect(const std::string& query);
/// Executes the query synchronously and directly.
/// Even when isAsync() returns true, the statement is still executed synchronously.
/// For transactional behavior, see execute() documentation.
const Result& executeAsync(bool reset = true);
/// Executes the statement asynchronously.
@@ -312,6 +412,7 @@ public:
/// of rows affected by the statement execution.
/// When executed on a synchronous statement, this method does not alter the
/// statement's synchronous nature.
/// For transactional behavior, see execute() documentation.
void setAsync(bool async = true);
/// Sets the asynchronous flag. If this flag is true, executeAsync() is called
@@ -339,7 +440,10 @@ public:
/// and there is more work to do. When no limit is set, it will always return true after calling execute().
Statement& reset(Session& session);
/// Resets the Statement so that it can be filled with a new SQL command.
/// Resets the Statement and assigns it a new session, so that it can be filled with a new SQL query.
Statement& reset();
/// Resets the Statement so that it can be filled with a new SQL query.
bool canModifyStorage();
/// Returns true if statement is in a state that allows the internal storage to be modified.
@@ -365,6 +469,10 @@ public:
/// Returns the number of rows extracted so far for the data set.
/// Default value indicates current data set (if any).
std::size_t affectedRowCount() const;
/// Returns the number of affected rows.
/// Used to find out the number of rows affected by insert, delete or update.
std::size_t extractionCount() const;
/// Returns the number of extraction storage buffers associated
/// with the current data set.
@@ -416,6 +524,9 @@ protected:
Session session();
/// Returns the underlying session.
void clear() noexcept;
/// Clears the statement.
private:
const Result& doAsyncExec(bool reset = true);
/// Asynchronously executes the statement.
@@ -427,6 +538,34 @@ private:
return *this;
}
void formatQuery();
/// Formats the query string.
void checkBeginTransaction();
/// Checks if the transaction needs to be started
/// and starts it if not.
/// Transaction is automatically started for the first
/// statement on a non-autocommit session.
/// The best effort is made to detect if the query
/// consists of SELECT statements only, in which case
/// transaction does not need to started.
/// However, due to many SQL dialects, this logic is
/// not 100% accurate and transaction MAY be started
/// for SELECT-only queries.
#ifndef POCO_DATA_NO_SQL_PARSER
bool isType(unsigned int type) const;
/// Returns true if the statement is of the argument type.
bool hasType(unsigned int type) const;
/// Returns true if the statement is of the argument type.
Poco::SharedPtr<Parser::SQLParserResult> _pParseResult;
std::string _parseError;
#endif // POCO_DATA_NO_SQL_PARSER
StatementImpl::Ptr _pImpl;
// asynchronous execution related members
@@ -705,6 +844,12 @@ inline void Statement::setStorage(const std::string& storage)
}
inline std::size_t Statement::affectedRowCount() const
{
return static_cast<std::size_t>(_pImpl->affectedRowCount());
}
inline std::size_t Statement::extractionCount() const
{
return _pImpl->extractionCount();
+20
View File
@@ -68,10 +68,30 @@ public:
return stmt;
}
void reset();
/// Resets the StatementCreator.
private:
Poco::AutoPtr<SessionImpl> _ptrImpl;
};
//
// inlines
//
inline void StatementCreator::swap(StatementCreator& other) noexcept
{
using std::swap;
swap(_ptrImpl, other._ptrImpl);
}
inline void StatementCreator::reset()
{
_ptrImpl = nullptr;
}
} } // namespace Poco::Data
+15
View File
@@ -133,6 +133,9 @@ public:
/// this execution step. When reset is false, data is appended to the
/// bound containers during multiple execute calls.
void executeDirect(const std::string& query);
/// Execute query directly.
void reset();
/// Resets the statement, so that we can reuse all bindings and re-execute again.
@@ -199,6 +202,9 @@ protected:
virtual void bindImpl() = 0;
/// Binds parameters.
virtual void execDirectImpl(const std::string& query);
/// Execute query directly.
virtual AbstractExtraction::ExtractorPtr extractor() = 0;
/// Returns the concrete extractor used by the statement.
@@ -253,6 +259,9 @@ protected:
SessionImpl& session();
/// Rteurns session associated with this statement.
const SessionImpl& session() const;
/// Rteurns session associated with this statement.
virtual AbstractBinding::BinderPtr binder() = 0;
/// Returns the concrete binder used by the statement.
@@ -506,6 +515,12 @@ inline SessionImpl& StatementImpl::session()
}
inline const SessionImpl& StatementImpl::session() const
{
return _rSession;
}
inline void StatementImpl::setStorage(Storage storage)
{
_storage = storage;
+15 -13
View File
@@ -29,7 +29,7 @@ namespace Dynamic {
class Var;
}
} // namespace Dynamic
class DateTime;
@@ -56,6 +56,9 @@ public:
~Time();
/// Destroys the Time.
Time(const Time & ) = default;
Time(Time && ) = default;
int hour() const;
/// Returns the hour.
@@ -151,7 +154,8 @@ inline bool Time::operator > (const Time& time) const
}
} } // namespace Poco::Data
} // namespace Data
} // namespace Poco
//
@@ -171,43 +175,42 @@ public:
{
}
~VarHolderImpl()
{
}
~VarHolderImpl() override = default;
VarHolderImpl() = delete;
const std::type_info& type() const
const std::type_info& type() const override
{
return typeid(Poco::Data::Time);
}
void convert(Poco::Timestamp& val) const
void convert(Poco::Timestamp& val) const override
{
Poco::DateTime dt;
dt.assign(dt.year(), dt.month(), dt.day(), _val.hour(), _val.minute(), _val.second());
val = dt.timestamp();
}
void convert(Poco::DateTime& val) const
void convert(Poco::DateTime& val) const override
{
Poco::DateTime dt;
dt.assign(dt.year(), dt.month(), dt.day(), _val.hour(), _val.minute(), _val.second());
val = dt;
}
void convert(Poco::LocalDateTime& val) const
void convert(Poco::LocalDateTime& val) const override
{
Poco::LocalDateTime ldt;
ldt.assign(ldt.year(), ldt.month(), ldt.day(), _val.hour(), _val.minute(), _val.second());
val = ldt;
}
void convert(std::string& val) const
void convert(std::string& val) const override
{
DateTime dt(0, 1, 1, _val.hour(), _val.minute(), _val.second());
const DateTime dt(0, 1, 1, _val.hour(), _val.minute(), _val.second());
val = DateTimeFormatter::format(dt, "%H:%M:%S");
}
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
{
return cloneHolder(pVarHolder, _val);
}
@@ -218,7 +221,6 @@ public:
}
private:
VarHolderImpl();
Poco::Data::Time _val;
};
+12 -4
View File
@@ -107,10 +107,18 @@ public:
/// Passing true value for commit disables rollback during destruction
/// of this Transaction object.
void execute(const std::vector<std::string>& sql);
bool execute(const std::vector<std::string>& sql);
/// Executes all the SQL statements supplied in the vector and, after the last
/// one is sucesfully executed, commits the transaction.
/// If an error occurs during execution, transaction is rolled back.
/// one is sucesfully executed, commits the transaction and returns true.
/// If an error occurs during execution, transaction is rolled back and false is returned.
/// Passing true value for commit disables rollback during destruction
/// of this Transaction object.
bool execute(const std::vector<std::string>& sql, std::string* info);
/// Executes all the SQL statements supplied in the vector and, after the last
/// one is sucesfully executed, commits the transaction and returns true.
/// If an error occurs during execution, transaction is rolled back false is returned
/// and info pointer is assigned to a std::string containing the error message.
/// Passing true value for commit disables rollback during destruction
/// of this Transaction object.
@@ -148,7 +156,7 @@ private:
/// Otherwise does nothing.
Session _rSession;
Logger* _pLogger;
Logger* _pLogger = nullptr;
};
+8 -11
View File
@@ -28,6 +28,10 @@
#include "Poco/SharedPtr.h"
#include <cstddef>
#if defined(POCO_COMPILER_GCC) && (__GNUC__ >= 12)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuse-after-free"
#endif
namespace Poco {
namespace Data {
@@ -288,20 +292,10 @@ public:
static void extract(std::size_t pos, Nullable<T>& obj, const Nullable<T>& , AbstractExtractor::Ptr pExt)
{
poco_assert_dbg (!pExt.isNull());
T val;
if (pExt->extract(pos++, val))
{
obj = std::move(val);
}
else
{
obj.clear();
}
pExt->extract(pos++, obj);
}
private:
TypeHandler();
~TypeHandler();
TypeHandler(const TypeHandler&);
@@ -5750,5 +5744,8 @@ private:
} } // namespace Poco::Data
#if defined(POCO_COMPILER_GCC) && (__GNUC__ >= 12)
#pragma GCC diagnostic pop
#endif
#endif // Data_TypeHandler_INCLUDED