From 43c30315491cc8964164178668e855d2a4ae6bcc Mon Sep 17 00:00:00 2001 From: randomdan Date: Thu, 12 Aug 2010 23:04:37 +0000 Subject: Fix early assign of insCmd in sqlmerge Fix bad use of length in binding string --- project2/sqlMergeTask.cpp | 11 +++++++---- project2/sqlMergeTask.h | 2 +- project2/variables.cpp | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/project2/sqlMergeTask.cpp b/project2/sqlMergeTask.cpp index 2fef9e1..495a689 100644 --- a/project2/sqlMergeTask.cpp +++ b/project2/sqlMergeTask.cpp @@ -16,6 +16,7 @@ _SqlMergeTask::_SqlMergeTask(const xmlpp::Element * p) : patchOrder(p->get_attribute_value("patchorder")), earlyKeys(p->get_attribute_value("earlykeys") == "yes"), tempTableCreated(false), + insCmd(NULL), destdb(NULL), dataSource(p->get_attribute_value("datasource")), dtable(p->get_attribute_value("targettable")), @@ -40,10 +41,6 @@ _SqlMergeTask::_SqlMergeTask(const xmlpp::Element * p) : BOOST_FOREACH(xmlpp::Node * psi, p->find("sql")) { sqls.push_back(static_cast(psi)->get_child_text()->get_content()); } - insCmd = insertCommand(); - BOOST_FOREACH(const Iterates::value_type & i, sources) { - attach(i.second, insCmd); - } } _SqlMergeTask::~_SqlMergeTask() @@ -67,6 +64,12 @@ void _SqlMergeTask::execute() const { destdb = &ApplicationEngine::getCurrent()->dataSource<_RdbmsDataSource>(dataSource)->getWritable(); + if (!insCmd) { + insCmd = insertCommand(); + BOOST_FOREACH(const Iterates::value_type & i, sources) { + attach(i.second, insCmd); + } + } createTempTable(); if (earlyKeys) { createTempKey(); diff --git a/project2/sqlMergeTask.h b/project2/sqlMergeTask.h index 968e284..16dcdc7 100644 --- a/project2/sqlMergeTask.h +++ b/project2/sqlMergeTask.h @@ -59,7 +59,7 @@ class _SqlMergeTask : public _Task { std::list sqls; protected: ModifyCommand * insertCommand() const; - ModifyCommand * insCmd; + mutable ModifyCommand * insCmd; public: mutable ODBC::Connection * destdb; diff --git a/project2/variables.cpp b/project2/variables.cpp index a4a064f..3089510 100644 --- a/project2/variables.cpp +++ b/project2/variables.cpp @@ -208,6 +208,7 @@ Variable::create(const Glib::ustring & s, RowUser * dep) case '*': // parser return VariableImplPtr(new VariableParse(s.substr(1))); case '=': // literal (explicit) + return VariableImplPtr(new VariableLiteral(s.substr(1))); default: return VariableImplPtr(new VariableLiteral(s)); } @@ -222,8 +223,7 @@ VariableImpl::VariableImpl(const Glib::ustring & src) : Glib::ustring::const_iterator defaultStart = nameEnd; if (defaultStart != source.end()) { defaultStart++; - Glib::ustring::const_iterator defaultEnd = source.end(); - defaultValue = Glib::ustring(defaultStart, defaultEnd); + defaultValue = Glib::ustring(defaultStart, source.end()); } } -- cgit v1.2.3