From d32c736b5c2b14ffda203740b0061735cb4418d0 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 27 Jun 2013 01:11:41 +0200 Subject: [PATCH] feature #1613: Function to list the oids of a Pool. --- include/DatastorePool.h | 11 +++++++++++ include/PoolSQL.h | 14 ++++++++++++++ src/pool/PoolSQL.cc | 7 ++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/DatastorePool.h b/include/DatastorePool.h index 7942b48281..37d3d3b2ec 100644 --- a/include/DatastorePool.h +++ b/include/DatastorePool.h @@ -179,6 +179,17 @@ public: return PoolSQL::dump(oss, "DATASTORE_POOL", Datastore::table, where); }; + /** + * Lists the Datastore ids + * @param oids a vector with the oids of the objects. + * + * @return 0 on success + */ + int list(vector& oids) + { + return PoolSQL::list(oids, Datastore::table); + } + private: /** diff --git a/include/PoolSQL.h b/include/PoolSQL.h index 6c09f803a7..fed7b87ff6 100644 --- a/include/PoolSQL.h +++ b/include/PoolSQL.h @@ -97,6 +97,20 @@ public: const char * table, const string& where); + /** + * List the objects in the pool + * @param oids a vector with the oids of the objects. + * @param the name of the DB table. + * + * @return 0 on success + */ + int list( + vector& oids, + const char * table) + { + return search(oids, table, ""); + } + /** * Updates the object's data in the data base. The object mutex SHOULD be * locked. diff --git a/src/pool/PoolSQL.cc b/src/pool/PoolSQL.cc index a971f836de..2c7de17f37 100644 --- a/src/pool/PoolSQL.cc +++ b/src/pool/PoolSQL.cc @@ -561,7 +561,12 @@ int PoolSQL::search( set_callback(static_cast(&PoolSQL::search_cb), static_cast(&oids)); - sql << "SELECT oid FROM " << table << " WHERE " << where; + sql << "SELECT oid FROM " << table; + + if (!where.empty()) + { + sql << " WHERE " << where; + } rc = db->exec(sql, this);