[sr-dev] git:master: lib/srdb1: updated DB API prototype for replace

Daniel-Constantin Mierla miconda at gmail.com
Tue Mar 13 14:20:17 CET 2012


Module: sip-router
Branch: master
Commit: 061453b77e82e2fa92af2f57db67b6f9f8ac8302
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=061453b77e82e2fa92af2f57db67b6f9f8ac8302

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Tue Mar 13 13:58:27 2012 +0100

lib/srdb1: updated DB API prototype for replace

- replace method takes two more parameters to allow implementation of
  replace functionality inside the db connector module, via update,
  affected rows and insert
- first is the number of column-value pairs to be used as unique key.
  They have to be located at the beginning of the array given so far as
  parameter to replace
- second is a mode, that will allow doing custom replace by:
	- update, if affected rows == 0 then insert
	- insert, if duplicate key error, then update
- for the db connectors that have access to a native REPLACE command in
  the DB backend, the new parameters are ignored

---

 lib/srdb1/db.h |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/lib/srdb1/db.h b/lib/srdb1/db.h
index e27969f..6d3a45d 100644
--- a/lib/srdb1/db.h
+++ b/lib/srdb1/db.h
@@ -245,10 +245,15 @@ typedef int (*db_update_f) (const db1_con_t* _h, const db_key_t* _k, const db_op
  * \param _k key names
  * \param _v values of the keys
  * \param _n number of key=value pairs
+ * \param _un number of keys to build the unique key, starting from first _k
+ * \param _m mode - first update, then insert, or first insert, then update
+ * \note the last two parameters are used only if the DB server does not
+ * have native replace command (like postgres - the module doing an internal
+ * implementation using synchronized update/affected rows/insert mechanism)
  * \return returns 0 if everything is OK, otherwise returns value < 0
 */
 typedef int (*db_replace_f) (const db1_con_t* handle, const db_key_t* keys,
-				const db_val_t* vals, const int n);
+			const db_val_t* vals, const int n, const int _un, const int _m);
 
 
 /**




More information about the sr-dev mailing list