소스 검색

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
Daniel-Constantin Mierla 13 년 전
부모
커밋
061453b77e
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      lib/srdb1/db.h

+ 6 - 1
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);
 
 
 /**