Module: sip-router
Branch: janakj/postgres
Commit: a698aa66d1e3a1576859a35d783136661f2b882a
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a698aa6…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Wed Jul 9 14:30:06 2008 +0000
- fix PGRES_FATAL_ERROR bug in postgres driver
- the result set was cleared in this case, but no error was> returned
- reported from Andrew O. Zhukov, gnugk at telegroup dot com dot ua
- small indention fixes
git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4467 689a6050-402a-0410-94f2-e92a70836424
---
modules/db_postgres/km_dbase.c | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/modules/db_postgres/km_dbase.c b/modules/db_postgres/km_dbase.c
index c00029e..a094c70 100644
--- a/modules/db_postgres/km_dbase.c
+++ b/modules/db_postgres/km_dbase.c
@@ -199,7 +199,7 @@ int db_postgres_fetch_result(const db_con_t* _con, db_res_t** _res, const int nr
if (*_res)
db_free_result(*_res);
- *_res = 0;
+ *_res = 0;
return 0;
}
@@ -223,6 +223,7 @@ int db_postgres_fetch_result(const db_con_t* _con, db_res_t** _res, const int nr
case PGRES_COMMAND_OK:
/* Successful completion of a command returning no data (such as INSERT or UPDATE). */
return 0;
+
case PGRES_TUPLES_OK:
/* Successful completion of a command returning data (such as a SELECT or SHOW). */
if (db_postgres_get_columns(_con, *_res) < 0) {
@@ -230,12 +231,20 @@ int db_postgres_fetch_result(const db_con_t* _con, db_res_t** _res, const int nr
return -2;
}
break;
+
+ case PGRES_FATAL_ERROR:
+ LM_ERR("%p - invalid query, execution aborted\n", _con);
+ LM_ERR("%p - PQresultStatus(%s)\n", _con, PQresStatus(pqresult));
+ if (*_res)
+ db_free_result(*_res);
+ *_res = 0;
+ return -3;
+
case PGRES_EMPTY_QUERY:
case PGRES_COPY_OUT:
case PGRES_COPY_IN:
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
- case PGRES_FATAL_ERROR:
LM_WARN("%p - probable invalid query\n", _con);
default:
LM_WARN("%p - PQresultStatus(%s)\n",
@@ -411,6 +420,7 @@ int db_postgres_store_result(const db_con_t* _con, db_res_t** _r)
/* Successful completion of a command returning no data (such as INSERT or UPDATE). */
rc = 0;
break;
+
case PGRES_TUPLES_OK:
/* Successful completion of a command returning data (such as a SELECT or SHOW). */
if (db_postgres_convert_result(_con, *_r) < 0) {
@@ -422,12 +432,21 @@ int db_postgres_store_result(const db_con_t* _con, db_res_t** _r)
}
rc = 0;
break;
+
+ case PGRES_FATAL_ERROR:
+ LM_ERR("%p - invalid query, execution aborted\n", _con);
+ LM_ERR("%p: %s\n", _con, PQresStatus(pqresult));
+ LM_ERR("%p: %s\n", _con, PQresultErrorMessage(CON_RESULT(_con)));
+ if (*_r) db_free_result(*_r);
+ *_r = 0;
+ rc = -3;
+ break;
+
case PGRES_EMPTY_QUERY:
case PGRES_COPY_OUT:
case PGRES_COPY_IN:
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
- case PGRES_FATAL_ERROR:
LM_WARN("%p Probable invalid query\n", _con);
default:
LM_WARN("%p: %s\n", _con, PQresStatus(pqresult));
Module: sip-router
Branch: janakj/postgres
Commit: 2377652dacb7945f09330b893f8390a91e006727
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2377652…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Thu Jul 10 08:49:27 2008 +0000
- further bug fixes for db_postgres_fetch_result and db_postgres_store_result
- return also for all other abnormal query states an error, as the result set
is here set to zero too
- this is probably a little bit to strict, but in the openser context this
types normally should not happen
- as the old behaviour could lead to crashes if this gets eventually reported
from the driver, this is surely an improvement :-)
(most query user check only for return value < 0, and not for == 0)
- in case for the PGRES_EMPTY_QUERY this could be not recognized as error
from upper layers at all, as this is defined as zero in the pg driver..
- small indention fixes
git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4471 689a6050-402a-0410-94f2-e92a70836424
---
modules/db_postgres/km_dbase.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/modules/db_postgres/km_dbase.c b/modules/db_postgres/km_dbase.c
index a094c70..090f767 100644
--- a/modules/db_postgres/km_dbase.c
+++ b/modules/db_postgres/km_dbase.c
@@ -241,18 +241,21 @@ int db_postgres_fetch_result(const db_con_t* _con, db_res_t** _res, const int nr
return -3;
case PGRES_EMPTY_QUERY:
+ /* notice or warning */
+ case PGRES_NONFATAL_ERROR:
+ /* status for COPY command, not used */
case PGRES_COPY_OUT:
case PGRES_COPY_IN:
+ /* unexpected response */
case PGRES_BAD_RESPONSE:
- case PGRES_NONFATAL_ERROR:
LM_WARN("%p - probable invalid query\n", _con);
default:
LM_WARN("%p - PQresultStatus(%s)\n",
_con, PQresStatus(pqresult));
if (*_res)
db_free_result(*_res);
- *_res = 0;
- return 0;
+ *_res = 0;
+ return -4;
}
} else {
@@ -427,12 +430,12 @@ int db_postgres_store_result(const db_con_t* _con, db_res_t** _r)
LM_ERR("%p Error returned from convert_result()\n", _con);
if (*_r) db_free_result(*_r);
- *_r = 0;
+ *_r = 0;
rc = -4;
}
rc = 0;
break;
-
+ /* query failed */
case PGRES_FATAL_ERROR:
LM_ERR("%p - invalid query, execution aborted\n", _con);
LM_ERR("%p: %s\n", _con, PQresStatus(pqresult));
@@ -443,18 +446,21 @@ int db_postgres_store_result(const db_con_t* _con, db_res_t** _r)
break;
case PGRES_EMPTY_QUERY:
+ /* notice or warning */
+ case PGRES_NONFATAL_ERROR:
+ /* status for COPY command, not used */
case PGRES_COPY_OUT:
case PGRES_COPY_IN:
+ /* unexpected response */
case PGRES_BAD_RESPONSE:
- case PGRES_NONFATAL_ERROR:
LM_WARN("%p Probable invalid query\n", _con);
default:
LM_WARN("%p: %s\n", _con, PQresStatus(pqresult));
- LM_WARN("%p: %s\n", _con, PQresultErrorMessage(CON_RESULT(_con)));
+ LM_WARN("%p: %s\n", _con, PQresultErrorMessage(CON_RESULT(_con)));
if (*_r) db_free_result(*_r);
*_r = 0;
- rc = (int)pqresult;
+ rc = -4;
break;
}
Module: sip-router
Branch: janakj/postgres
Commit: 8cac0d9fbf64f674e917d15a5d326ccaecd3b72f
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8cac0d9…
Author: Klaus Darilion <klaus.darilion(a)pernau.at>
Committer: Klaus Darilion <klaus.darilion(a)pernau.at>
Date: Wed Aug 6 08:20:30 2008 +0000
- renaming: openser -> kamailio
git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4585 689a6050-402a-0410-94f2-e92a70836424
---
modules/db_postgres/km_dbase.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/modules/db_postgres/km_dbase.c b/modules/db_postgres/km_dbase.c
index 69e2e92..29f817c 100644
--- a/modules/db_postgres/km_dbase.c
+++ b/modules/db_postgres/km_dbase.c
@@ -42,7 +42,7 @@
* a call (or multiple calls) to PQgetResult.
* Removed transaction processing calls (BEGIN/COMMIT/ROLLBACK) as
* they added uneeded overhead. Klaus' testing showed in excess of
- * 1ms gain by removing each command. In addition, OpenSER only
+ * 1ms gain by removing each command. In addition, Kamailio only
* issues single queries and is not, at this time transaction aware.
* The transaction processing routines have been left in place
* should this support be needed in the future.