From 8039e10f1d300aaaf1b56263db5336c6c38cfd49 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Fri, 30 Oct 2009 00:12:57 +0000 Subject: Ensure a client-side cursor is used, and change to static cursor to improve performance. When adding a new record that has a persistence ID, wait until after the Update to retrieve the new id from the new record. Fixes QPID-2168. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@831167 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/store/ms-sql/BlobRecordset.cpp | 3 ++- cpp/src/qpid/store/ms-sql/Recordset.cpp | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/qpid/store/ms-sql/BlobRecordset.cpp b/cpp/src/qpid/store/ms-sql/BlobRecordset.cpp index 977eb6d5d2..5a5d23c797 100644 --- a/cpp/src/qpid/store/ms-sql/BlobRecordset.cpp +++ b/cpp/src/qpid/store/ms-sql/BlobRecordset.cpp @@ -49,9 +49,10 @@ BlobRecordset::add(const qpid::broker::Persistable& item) { BlobEncoder blob (item); // Marshall item info to a blob rs->AddNew(); - item.setPersistenceId(rs->Fields->Item["persistenceId"]->Value); rs->Fields->GetItem("fieldTableBlob")->AppendChunk(blob); rs->Update(); + uint64_t id = rs->Fields->Item["persistenceId"]->Value; + item.setPersistenceId(id); } void diff --git a/cpp/src/qpid/store/ms-sql/Recordset.cpp b/cpp/src/qpid/store/ms-sql/Recordset.cpp index 49232ababa..e1a5158c87 100644 --- a/cpp/src/qpid/store/ms-sql/Recordset.cpp +++ b/cpp/src/qpid/store/ms-sql/Recordset.cpp @@ -82,9 +82,13 @@ Recordset::open(DatabaseConnection* conn, const std::string& table) { _ConnectionPtr p = *conn; TESTHR(rs.CreateInstance(__uuidof(::Recordset))); + // Client-side cursors needed to get access to newly added + // identity column immediately. Recordsets need this to get the + // persistence ID for the broker objects. + rs->CursorLocation = adUseClient; rs->Open(table.c_str(), _variant_t((IDispatch *)p, true), - adOpenKeyset, + adOpenStatic, adLockOptimistic, adCmdTable); tableName = table; -- cgit v1.2.1