Module: sip-router
Branch: janakj/postgres
Commit: bd30d4f936fabd4cb273fc09d9d82fe08200f5e3
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bd30d4f…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Tue Feb 17 23:20:09 2009 +0100
Merge db_postgres module from kamailio/trunk into db_postgres modules
in sip-router.
* kamailio/db_postgres: (58 commits)
- fix regression during value conversion when input SQL string is NULL,
- another error condition fix for a problem that gets introduced by a
- add one DBG log to each drivers error condition, that the mem is freed
- improve two errors messages, inform the user that the query is aborted
- db_postgres_convert_rows needs to free the row_buf on all error conditions
- partial revert of commit rev5359 for db_mysql module
- fix a few line breaks in errors logs
- unify common rows and row allocation functionality in the DB API core
- remove LM_ERR probe that slipped into previous commit
- change behaviour of db_str2val, this now copy strings
- add 'db_postgres' prefix to free_query function
- fix a bunch of doxygen errors (mostly in modules, some in the core)
- fix a bunch of errors in doxygen
- fix memory leak in db_postgres module related to BLOBs (also caused an
- fix postgres NULL value behaviour: as in postgres a NULL value is
- docs extension: explain fetch_result functionality better to prevent errors
- remove not reached return statement at the end of val2str functions
- make small wrapper around PQclear void, nobody checks the return state
- doxygen conversion, write new documentation, small cleanups
- initial support for BIGINT database in DB core and SQL based database
...
---
Module: sip-router
Branch: janakj/postgres
Commit: a7bac3b9ab8829dcb2cd933cf3302adaf8f81cfa
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a7bac3b…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Wed Feb 18 01:22:22 2009 +0100
Various changes to get rid of conflicts and make km_ files compile.
List of changes:
* Path to header files updated to point to lib/srdb1
* Comment out MODULE_VERSION (already used pg_mod.c)
* cmd_export_t renamed to kam_cmd_export_t
* exports structure renamed to kam_exports (exports symbol is already
defined by pg_mod.c)
* module_exports renamed to kam_module_exports
* db_con_t renamed to db1_con_t
* db_res_t renamed to db1_res_t
* DB field types renamed to DB1_*
---
modules/db_postgres/km_db_postgres.c | 10 +++---
modules/db_postgres/km_dbase.c | 42 +++++++++++++++---------------
modules/db_postgres/km_dbase.h | 34 ++++++++++++------------
modules/db_postgres/km_pg_con.h | 4 +-
modules/db_postgres/km_res.c | 48 +++++++++++++++++-----------------
modules/db_postgres/km_res.h | 10 +++---
modules/db_postgres/km_val.c | 16 +++++-----
modules/db_postgres/km_val.h | 2 +-
8 files changed, 83 insertions(+), 83 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=a7b…
Module: sip-router
Branch: janakj/postgres
Commit: f7cc8a190ae22ae3f99e2ceaa6f609061e281d8d
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f7cc8a1…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Wed Feb 18 01:10:10 2009 +0100
Merge branch 'master' of ssh://janakj@git.sip-router.org/sip-router into postgres
* 'master' of ssh://janakj@git.sip-router.org/sip-router:
Fixed matching of db flags names at the beginning of line.
Two small fixes in regular expressions.
---
Module: sip-router
Branch: janakj/postgres
Commit: f09596d32a99108f6c34f5fa3641be3dd6470b24
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f09596d…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Mon Nov 24 17:38:46 2008 +0000
- fix memory leak in db_postgres module related to BLOBs (also caused an
abort in a assertion when DBG_QM_MALLOC memory manager is used)
- PQunescapeBytea is used for BLOBs, this allocates new memory, which could
not freed from us later in pkg_free in the DB core
- thus we need to allocate new memory for this datatype, copy the string and
free the postgres result after that
- small comment fix
git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5250 689a6050-402a-0410-94f2-e92a70836424
---
modules/db_postgres/km_val.c | 30 ++++++++++++++++++++++--------
1 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/modules/db_postgres/km_val.c b/modules/db_postgres/km_val.c
index d5a3115..9b7d12b 100644
--- a/modules/db_postgres/km_val.c
+++ b/modules/db_postgres/km_val.c
@@ -61,6 +61,7 @@
int db_postgres_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int _l)
{
static str dummy_string = {"", 0};
+ char *tmp_s;
if (!_v) {
LM_ERR("invalid parameter value\n");
@@ -159,19 +160,32 @@ int db_postgres_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const
case DB_BLOB:
LM_DBG("converting BLOB [%.*s]\n", _l, _s);
- /* PQunescapeBytea: Converts a string representation of binary data
- * into binary data - the reverse of PQescapeBytea.
- * This is needed when retrieving bytea data in text format,
- * but not when retrieving it in binary format.
+ /*
+ * The string is stored in new allocated memory, which we could
+ * not free later thus we need to copy it to some new memory here.
*/
- VAL_BLOB(_v).s = (char*)PQunescapeBytea((unsigned char*)_s,
- (size_t*)(void*)&(VAL_BLOB(_v).len) );
+ tmp_s = (char*)PQunescapeBytea((unsigned char*)_s, (size_t*)(void*)&(VAL_BLOB(_v).len));
+ if(tmp_s==NULL) {
+ LM_ERR("PQunescapeBytea failed\n");
+ return -7;
+ }
+ VAL_BLOB(_v).s = pkg_malloc(VAL_BLOB(_v).len);
+ if (VAL_BLOB(_v).s == NULL) {
+ LM_ERR("no private memory left\n");
+ PQfreemem(tmp_s);
+ return -8;
+ }
+ LM_DBG("allocate %d bytes memory for BLOB at %p", VAL_BLOB(_v).len, VAL_BLOB(_v).s);
+ memcpy(VAL_BLOB(_v).s, tmp_s, VAL_BLOB(_v).len);
+ PQfreemem(tmp_s);
+
VAL_TYPE(_v) = DB_BLOB;
VAL_FREE(_v) = 1;
+
LM_DBG("got blob len %d\n", _l);
return 0;
}
- return -7;
+ return -9;
}
@@ -314,7 +328,7 @@ int db_postgres_val2str(const db_con_t* _con, const db_val_t* _v, char* _s, int*
(size_t)l, (size_t*)&tmp_len);
if(tmp_s==NULL)
{
- LM_ERR("PQescapeBytea failed\n");
+ LM_ERR("PQescapeByteaConn failed\n");
return -9;
}
if (tmp_len > *_len) {