summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-08-12 23:04:37 +0000
committerrandomdan <randomdan@localhost>2010-08-12 23:04:37 +0000
commit43c30315491cc8964164178668e855d2a4ae6bcc (patch)
tree2cad52830e6ffa91ea0d03f5491b86a7398a572b
parentBind merge populators recursively to leafs (diff)
downloadproject2-43c30315491cc8964164178668e855d2a4ae6bcc.tar.bz2
project2-43c30315491cc8964164178668e855d2a4ae6bcc.tar.xz
project2-43c30315491cc8964164178668e855d2a4ae6bcc.zip
Fix early assign of insCmd in sqlmerge
Fix bad use of length in binding string
-rw-r--r--project2/sqlMergeTask.cpp11
-rw-r--r--project2/sqlMergeTask.h2
-rw-r--r--project2/variables.cpp4
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<xmlpp::Element *>(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<std::string> 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());
}
}