summaryrefslogtreecommitdiff
path: root/ADBC
diff options
context:
space:
mode:
authorhillj <hillj@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-01-02 02:24:20 +0000
committerhillj <hillj@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-01-02 02:24:20 +0000
commitc1e8390ae08690f97ac85e2d17be6df54a2fa41e (patch)
treec61a52dbaf2d4f910282c78d1ffd6702732dc056 /ADBC
parentb3dfd14c35471bbf9f33eb0ac39faaa974c08b77 (diff)
downloadATCD-c1e8390ae08690f97ac85e2d17be6df54a2fa41e.tar.gz
Sat Jan 2 02:23:02 UTC 2010 James H. Hill <hillj at cs dot iupui dot edu>
Diffstat (limited to 'ADBC')
-rw-r--r--ADBC/ChangeLog12
-rw-r--r--ADBC/adbc/SQLite/Query.cpp16
-rw-r--r--ADBC/adbc/SQLite/Query.h3
-rw-r--r--ADBC/adbc/SQLite/Query.inl3
-rw-r--r--ADBC/adbc/SQLite/Record.h2
-rw-r--r--ADBC/adbc/SQLite/Record.inl4
6 files changed, 30 insertions, 10 deletions
diff --git a/ADBC/ChangeLog b/ADBC/ChangeLog
index 94f99e9ec71..a466940e296 100644
--- a/ADBC/ChangeLog
+++ b/ADBC/ChangeLog
@@ -1,3 +1,15 @@
+Sat Jan 2 02:23:02 UTC 2010 James H. Hill <hillj at cs dot iupui dot edu>
+
+ * adbc/SQLite/Query.h:
+ * adbc/SQLite/Query.inl:
+ * adbc/SQLite/Query.cpp:
+ * adbc/SQLite/Record.h:
+ * adbc/SQLite/Record.inl:
+
+ execute () no longer allocates a record for each query
+ executed. Instead, it return an embedded record, which
+ should not be deallocated () by the client.
+
Wed Dec 30 22:54:02 UTC 2009 James H. Hill <hillj@dre.vanderbilt.edu>
* adbc/SQLite/Query.h:
diff --git a/ADBC/adbc/SQLite/Query.cpp b/ADBC/adbc/SQLite/Query.cpp
index 662d2f3f129..1cee7ebfe41 100644
--- a/ADBC/adbc/SQLite/Query.cpp
+++ b/ADBC/adbc/SQLite/Query.cpp
@@ -60,6 +60,10 @@ void Query::execute_no_record (void)
// Execute the SQL statement.
int retval = ::sqlite3_step (this->stmt_);
+
+ if (retval == SQLITE_ERROR)
+ throw Exception (this->parent_);
+
this->needs_reseting_ = true;
if (retval != SQLITE_DONE)
@@ -80,14 +84,14 @@ Record * Query::execute (void)
// Initialize the cursor for the record.
int retval = ::sqlite3_step (this->stmt_);
- Record * record = 0;
-
- ACE_NEW_THROW_EX (record,
- Record (*this, retval),
- ACE_bad_alloc ());
+ if (retval == SQLITE_ERROR)
+ throw Exception (this->parent_);
+ // Update the record's state for the new query.
+ this->record_.state_ = retval;
this->needs_reseting_ = true;
- return record;
+
+ return &this->record_;
}
//
diff --git a/ADBC/adbc/SQLite/Query.h b/ADBC/adbc/SQLite/Query.h
index 37f78da8d24..d082e7ec209 100644
--- a/ADBC/adbc/SQLite/Query.h
+++ b/ADBC/adbc/SQLite/Query.h
@@ -125,6 +125,9 @@ private:
/// Collection of parameters for this query.
Parameter_List params_;
+
+ /// Record associated with the statement.
+ Record record_;
};
}
}
diff --git a/ADBC/adbc/SQLite/Query.inl b/ADBC/adbc/SQLite/Query.inl
index 9f7468482c4..be8e8affb64 100644
--- a/ADBC/adbc/SQLite/Query.inl
+++ b/ADBC/adbc/SQLite/Query.inl
@@ -13,7 +13,8 @@ Query::Query (Connection & parent)
: parent_ (parent),
stmt_ (0),
needs_reseting_ (false),
- params_ (*this)
+ params_ (*this),
+ record_ (*this)
{
}
diff --git a/ADBC/adbc/SQLite/Record.h b/ADBC/adbc/SQLite/Record.h
index 6946921f5ab..6da19ecb62e 100644
--- a/ADBC/adbc/SQLite/Record.h
+++ b/ADBC/adbc/SQLite/Record.h
@@ -98,7 +98,7 @@ private:
* @param[in] query Parent of the record
* @param[in] state Initial state
*/
- Record (const Query & query, int state);
+ Record (const Query & query);
/// Parent of the record.
const Query & query_;
diff --git a/ADBC/adbc/SQLite/Record.inl b/ADBC/adbc/SQLite/Record.inl
index bc57257351a..be6ffb8247f 100644
--- a/ADBC/adbc/SQLite/Record.inl
+++ b/ADBC/adbc/SQLite/Record.inl
@@ -9,9 +9,9 @@ namespace SQLite
//
ADBC_INLINE
Record::
-Record (const Query & query, int state)
+Record (const Query & query)
: query_ (query),
- state_ (state)
+ state_ (101) /* SQLITE_DONE */
{
}