summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdbpp/connection.cpp5
-rw-r--r--libdbpp/sqlParse.h4
-rw-r--r--libdbpp/sqlParse.ll9
3 files changed, 13 insertions, 5 deletions
diff --git a/libdbpp/connection.cpp b/libdbpp/connection.cpp
index 6bb846e..3d954a6 100644
--- a/libdbpp/connection.cpp
+++ b/libdbpp/connection.cpp
@@ -110,11 +110,8 @@ DB::Connection::inTx() const
void
DB::Connection::executeScript(std::istream & f, const boost::filesystem::path & s)
{
- if (!f.good()) {
- throw SqlParseException("Script stream not in good state.", 0);
- }
DB::SqlExecuteScript p(f, s, this);
- while (p.yylex()) ;
+ p.Execute();
}
void
diff --git a/libdbpp/sqlParse.h b/libdbpp/sqlParse.h
index 1a8c46d..5ab5143 100644
--- a/libdbpp/sqlParse.h
+++ b/libdbpp/sqlParse.h
@@ -30,7 +30,8 @@ namespace DB {
class DLL_PUBLIC SqlParse : public yyFlexLexer {
public:
SqlParse(std::istream &, const boost::filesystem::path &);
- int yylex() override;
+
+ void Execute();
virtual void Comment(const std::string &) const = 0;
virtual void Statement(const std::string &) const = 0;
@@ -39,6 +40,7 @@ namespace DB {
void LexerError(const char *) override;
private:
+ int yylex() override;
const boost::filesystem::path scriptDir;
std::string comment;
std::string statement;
diff --git a/libdbpp/sqlParse.ll b/libdbpp/sqlParse.ll
index 8df4895..18210ac 100644
--- a/libdbpp/sqlParse.ll
+++ b/libdbpp/sqlParse.ll
@@ -147,6 +147,15 @@ namespace DB {
yyFlexLexer(&f, NULL),
scriptDir(s)
{
+ if (!f.good()) {
+ throw SqlParseException("Script stream not in good state.", 0);
+ }
+ }
+
+ void
+ SqlParse::Execute()
+ {
+ while (yylex()) ;
}
void