From a38f7ab1f5eb157c3deb88285bf819627ec421c5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 29 Dec 2015 04:22:30 +0000 Subject: Default (not supported) bulk upload implementation --- libdbpp/connection.cpp | 18 ++++++++++++++++++ libdbpp/connection.h | 6 +++--- libdbpp/unittests/testConnection.cpp | 4 ---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/libdbpp/connection.cpp b/libdbpp/connection.cpp index b58a0e1..b267af1 100644 --- a/libdbpp/connection.cpp +++ b/libdbpp/connection.cpp @@ -69,6 +69,24 @@ DB::Connection::releaseSavepoint(const std::string & sp) execute("RELEASE SAVEPOINT " + sp); } +void +DB::Connection::beginBulkUpload(const char *, const char *) +{ + throw DB::BulkUploadNotSupported(); +} + +void +DB::Connection::endBulkUpload(const char *) +{ + throw DB::BulkUploadNotSupported(); +} + +size_t +DB::Connection::bulkUploadData(const char *, size_t) const +{ + throw DB::BulkUploadNotSupported(); +} + boost::optional DB::Connection::resolvePlugin(const std::type_info &, const std::string & name) { diff --git a/libdbpp/connection.h b/libdbpp/connection.h index 3c0627a..9690164 100644 --- a/libdbpp/connection.h +++ b/libdbpp/connection.h @@ -127,11 +127,11 @@ namespace DB { /// Begin a bulk upload operation. /// @param table the target table. /// @param opts database specific options to the load command. - virtual void beginBulkUpload(const char * table, const char * opts) const = 0; + virtual void beginBulkUpload(const char * table, const char * opts); /// Finish a bulk upload operation. - virtual void endBulkUpload(const char *) const = 0; + virtual void endBulkUpload(const char *); /// Load data for the current bulk load operation. - virtual size_t bulkUploadData(const char *, size_t) const = 0; + virtual size_t bulkUploadData(const char *, size_t) const; /// Return the Id used in the last insert virtual int64_t insertId() const; diff --git a/libdbpp/unittests/testConnection.cpp b/libdbpp/unittests/testConnection.cpp index a5fc1a6..c42ddca 100644 --- a/libdbpp/unittests/testConnection.cpp +++ b/libdbpp/unittests/testConnection.cpp @@ -29,10 +29,6 @@ class MockDb : public DB::Connection { DB::SelectCommand * newSelectCommand(const std::string &) const { return nullptr; } DB::ModifyCommand * newModifyCommand(const std::string &) const { return nullptr; } - void beginBulkUpload(const char *, const char *) const {} - void endBulkUpload(const char *) const {} - size_t bulkUploadData(const char *, size_t) const {return 0;} - mutable std::vector executed; mutable unsigned int txDepth; }; -- cgit v1.2.3