diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-12 17:24:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-19 11:41:11 +0200 |
commit | f2e4c2c70344dd1a98593cfbe9256d1b3ed54f27 (patch) | |
tree | 713e2b8625aa9db41f2c18194baf68b830df39a3 /common/threads | |
parent | 3fd1098c70a36cdffa256b6d9fd721cf95c6f482 (diff) |
Completion of prepared query support
Diffstat (limited to 'common/threads')
-rw-r--r-- | common/threads/driver.cxx | 20 | ||||
-rw-r--r-- | common/threads/makefile | 2 |
2 files changed, 20 insertions, 2 deletions
diff --git a/common/threads/driver.cxx b/common/threads/driver.cxx index dc4de0d..b8a66f1 100644 --- a/common/threads/driver.cxx +++ b/common/threads/driver.cxx @@ -96,10 +96,25 @@ struct task for (unsigned long j (0); j < sub_iteration_count; ++j) { typedef odb::query<object> query; + typedef odb::prepared_query<object> prep_query; typedef odb::result<object> result; transaction t (db_.begin ()); - result r (db_.query<object> (query::str == "another value", false)); + + { // @@ TMP + + //result r (db_.query<object> (query::str == "another value", false)); + + prep_query pq (db_.lookup_query<object> ("object-query")); + + if (!pq) + { + pq = db_.prepare_query<object> ( + "object-query", query::str == "another value"); + db_.cache_query (pq); + } + + result r (pq.execute (false)); bool found (false); for (result::iterator i (r.begin ()); i != r.end (); ++i) @@ -111,6 +126,9 @@ struct task } } assert (found); + + } // @@ TMP + t.commit (); } diff --git a/common/threads/makefile b/common/threads/makefile index 3c0a041..a9f2a66 100644 --- a/common/threads/makefile +++ b/common/threads/makefile @@ -35,7 +35,7 @@ gen := $(addprefix $(out_base)/,$(genf)) $(gen): $(odb) $(gen): odb := $(odb) $(gen) $(dist): export odb_options += --database $(db_id) --generate-schema \ ---generate-query --table-prefix threads_ +--generate-query --generate-prepared --table-prefix threads_ $(gen): cpp_options := -I$(src_base) $(gen): $(common.l.cpp-options) |