diff options
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) |