From f64cb8b599e41432236108783b1ae2573c497f94 Mon Sep 17 00:00:00 2001 From: randomdan Date: Sun, 2 Dec 2012 18:01:55 +0000 Subject: Keep the same DB connection throughout the bulk load process --- project2/sql/sqlBulkLoad.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/project2/sql/sqlBulkLoad.cpp b/project2/sql/sqlBulkLoad.cpp index 4d9604a..b26b0c8 100644 --- a/project2/sql/sqlBulkLoad.cpp +++ b/project2/sql/sqlBulkLoad.cpp @@ -23,11 +23,12 @@ class SqlBulkLoad : public Task { void execute() const { - db->getWritable().beginBulkUpload(targetTable(), extras()); + const DB::Connection & wdb = db->getWritable(); + wdb.beginBulkUpload(targetTable(), extras()); ScopeObject tidy([]{}, - [=]{ db->getWritable().endBulkUpload(NULL); }, - [=]{ db->getWritable().endBulkUpload("Stack unwind in progress"); }); - stream->runStream(boost::bind(&DB::Connection::bulkUploadData, &db->getWritable(), _1, _2)); + [&]{ wdb.endBulkUpload(NULL); }, + [&]{ wdb.endBulkUpload("Stack unwind in progress"); }); + stream->runStream(boost::bind(&DB::Connection::bulkUploadData, &wdb, _1, _2)); } const Variable dataSource; -- cgit v1.2.3