Module: sip-router
Branch: janakj/postgres
Commit: b7e455c5cedde68bb979bc0d9506f9f1781f1f47
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b7e455c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Mar 7 18:19:45 2008 +0000
- modules documentation migrated from sgml to xml docbook format
- many thanks to Edson <4lists (at) gmail (dot) com> for providing script to replace headers and rename files
- contact updated
- follows re-sync with todays changes and update of Makefile to generate README and html files from XML
git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3886 689a6050-402a-0410-94f2-e92a70836424
---
modules/db_postgres/km_README | 51 ++++++++++++++++----
.../km_doc/{db_postgres.sgml => db_postgres.xml} | 14 +++--
...db_postgres_user.sgml => db_postgres_admin.xml} | 2 +-
3 files changed, 50 insertions(+), 17 deletions(-)
diff --git a/modules/db_postgres/km_README b/modules/db_postgres/km_README
index fb8b0f4..062dc41 100644
--- a/modules/db_postgres/km_README
+++ b/modules/db_postgres/km_README
@@ -9,9 +9,13 @@ Edited by
Greg Fausak
Copyright � 2003 Greg Fausak
+ Revision History
+ Revision $Revision$ $Date: 2008-03-04 15:15:47 +0200
+ (Tue, 04 Mar 2008) $
__________________________________________________________
Table of Contents
+
1. User's Guide
1.1. Overview
@@ -22,45 +26,72 @@ Greg Fausak
1.3. Exported Parameters
1.4. Exported Functions
- 1.5. Installation & Running
- __________________________________________________________
+ 1.5. Installation and Running
+
+ 2. Frequently Asked Questions
Chapter 1. User's Guide
1.1. Overview
Module description
- __________________________________________________________
1.2. Dependencies
1.2.1. OpenSER Modules
The following modules must be loaded before this module:
-
* No dependencies on other OpenSER modules.
- __________________________________________________________
1.2.2. External Libraries or Applications
The following libraries or applications must be installed
before running OpenSER with this module loaded:
-
* PostgreSQL library - e.g., libpq5.
* PostgreSQL devel library - to compile the module (e.g.,
libpq-dev).
- __________________________________________________________
1.3. Exported Parameters
NONE
- __________________________________________________________
1.4. Exported Functions
NONE
- __________________________________________________________
-1.5. Installation & Running
+1.5. Installation and Running
Notes about installation and running.
+
+Chapter 2. Frequently Asked Questions
+
+ 2.1.
+
+ Where can I find more about OpenSER?
+
+ Take a look at http://openser.org/.
+
+ 2.2.
+
+ Where can I post a question about this module?
+
+ First at all check if your question was already answered on one
+ of our mailing lists:
+ * User Mailing List -
+ http://openser.org/cgi-bin/mailman/listinfo/users
+ * Developer Mailing List -
+ http://openser.org/cgi-bin/mailman/listinfo/devel
+
+ E-mails regarding any stable OpenSER release should be sent to
+ <users(a)openser.org> and e-mails regarding development versions
+ should be sent to <devel(a)openser.org>.
+
+ If you want to keep the mail private, send it to
+ <team(a)openser.org>.
+
+ 2.3.
+
+ How can I report a bug?
+
+ Please follow the guidelines provided at:
+ http://sourceforge.net/tracker/?group_id=139143.
diff --git a/modules/db_postgres/km_doc/db_postgres.sgml b/modules/db_postgres/km_doc/db_postgres.xml
similarity index 64%
rename from modules/db_postgres/km_doc/db_postgres.sgml
rename to modules/db_postgres/km_doc/db_postgres.xml
index 6fee313..40ab07b 100644
--- a/modules/db_postgres/km_doc/db_postgres.sgml
+++ b/modules/db_postgres/km_doc/db_postgres.xml
@@ -1,11 +1,13 @@
-<!DOCTYPE Book PUBLIC "-//OASIS//DTD DocBook V4.2//EN" [
+<?xml version="1.0" encoding='ISO-8859-1'?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
-<!ENTITY user SYSTEM "db_postgres_user.sgml">
-<!ENTITY faq SYSTEM "../../../doc/module_faq.sgml">
+<!ENTITY user SYSTEM "db_postgres_admin.xml">
+<!ENTITY faq SYSTEM "../../../doc/module_faq.xml">
<!-- Include general documentation entities -->
-<!ENTITY % docentities SYSTEM "../../../doc/entities.sgml">
+<!ENTITY % docentities SYSTEM "../../../doc/entities.xml">
%docentities;
]>
@@ -37,8 +39,8 @@
</copyright>
<revhistory>
<revision>
- <revnumber>$Revision$</revnumber>
- <date>$Date$</date>
+ <revnumber>$Revision: 3839 $</revnumber>
+ <date>$Date: 2008-03-04 15:15:47 +0200 (Tue, 04 Mar 2008) $</date>
</revision>
</revhistory>
</bookinfo>
diff --git a/modules/db_postgres/km_doc/db_postgres_user.sgml b/modules/db_postgres/km_doc/db_postgres_admin.xml
similarity index 96%
rename from modules/db_postgres/km_doc/db_postgres_user.sgml
rename to modules/db_postgres/km_doc/db_postgres_admin.xml
index 85dc4e8..2a99096 100644
--- a/modules/db_postgres/km_doc/db_postgres_user.sgml
+++ b/modules/db_postgres/km_doc/db_postgres_admin.xml
@@ -59,7 +59,7 @@
</para>
</section>
<section>
- <title>Installation & Running</title>
+ <title>Installation and Running</title>
<para>Notes about installation and running.</para>
</section>
</chapter>
Module: sip-router
Branch: janakj/postgres
Commit: 393e4acea8ca6795be3ad308dfae887b9aecedb6
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=393e4ac…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Mar 10 11:17:28 2008 +0000
- content of faq removed (mistakenly added by me after Henning did the cleanup for modules' docs; rev 3839)
git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3901 689a6050-402a-0410-94f2-e92a70836424
---
modules/db_postgres/km_README | 43 +---------------------------------------
1 files changed, 2 insertions(+), 41 deletions(-)
diff --git a/modules/db_postgres/km_README b/modules/db_postgres/km_README
index 8304dd8..9c30832 100644
--- a/modules/db_postgres/km_README
+++ b/modules/db_postgres/km_README
@@ -10,8 +10,8 @@ Greg Fausak
Copyright � 2003 Greg Fausak
Revision History
- Revision $Revision$ $Date: 2008-03-07 21:52:29 +0200
- (Fri, 07 Mar 2008) $
+ Revision $Revision$ $Date: 2008-03-08 01:03:56 +0200
+ (Sat, 08 Mar 2008) $
__________________________________________________________
Table of Contents
@@ -28,8 +28,6 @@ Greg Fausak
1.4. Exported Functions
1.5. Installation and Running
- 2. Frequently Asked Questions
-
Chapter 1. User's Guide
1.1. Overview
@@ -62,40 +60,3 @@ Chapter 1. User's Guide
1.5. Installation and Running
Notes about installation and running.
-
-Chapter 2. Frequently Asked Questions
-
- Revision History
- Revision $Revision$ $Date: 2005-06-13 19:47:24 +0300 (Mon,
- 13 Jun 2005) $
-
- 2.1.
-
- Where can I find more about OpenSER?
-
- Take a look at http://openser.org/.
-
- 2.2.
-
- Where can I post a question about this module?
-
- First at all check if your question was already answered on one
- of our mailing lists:
- * User Mailing List -
- http://openser.org/cgi-bin/mailman/listinfo/users
- * Developer Mailing List -
- http://openser.org/cgi-bin/mailman/listinfo/devel
-
- E-mails regarding any stable OpenSER release should be sent to
- <users(a)openser.org> and e-mails regarding development versions
- should be sent to <devel(a)openser.org>.
-
- If you want to keep the mail private, send it to
- <team(a)openser.org>.
-
- 2.3.
-
- How can I report a bug?
-
- Please follow the guidelines provided at:
- http://sourceforge.net/tracker/?group_id=139143.
Module: sip-router
Branch: janakj/postgres
Commit: a9ef20728be5d67c9cf936befeb08995d3523613
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a9ef207…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Thu May 8 16:27:08 2008 +0000
- db_postgres_convert_rows function uses now the same interface like mysql,
simplify the internal logic of this function (remove tmp variables)
- null the result in case of errors in fetch_result
- related to bug #1954586
git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4139 689a6050-402a-0410-94f2-e92a70836424
---
modules/db_postgres/km_dbase.c | 10 +++++--
modules/db_postgres/km_res.c | 59 ++++++++++-----------------------------
modules/db_postgres/km_res.h | 2 +-
3 files changed, 23 insertions(+), 48 deletions(-)
diff --git a/modules/db_postgres/km_dbase.c b/modules/db_postgres/km_dbase.c
index eda49f8..c00029e 100644
--- a/modules/db_postgres/km_dbase.c
+++ b/modules/db_postgres/km_dbase.c
@@ -250,17 +250,21 @@ int db_postgres_fetch_result(const db_con_t* _con, db_res_t** _res, const int nr
if(RES_ROWS(*_res) != NULL) {
db_free_rows(*_res);
}
+ RES_ROWS(*_res) = 0;
RES_ROW_N(*_res) = 0;
}
+ /* Get the number of rows (tuples) in the query result. */
+ RES_NUM_ROWS(*_res) = PQntuples(CON_RESULT(_con));
+
/* determine the number of rows remaining to be processed */
rows = RES_NUM_ROWS(*_res) - RES_LAST_ROW(*_res);
/* If there aren't any more rows left to process, exit */
if (rows <= 0)
return 0;
-
- /* if the fetch count is less than the remaining rows to process */
+
+ /* if the fetch count is less than the remaining rows to process */
/* set the number of rows to process (during this call) equal to the fetch count */
if (nrows < rows)
rows = nrows;
@@ -270,7 +274,7 @@ int db_postgres_fetch_result(const db_con_t* _con, db_res_t** _res, const int nr
LM_DBG("converting row %d of %d count %d\n", RES_LAST_ROW(*_res),
RES_NUM_ROWS(*_res), RES_ROW_N(*_res));
- if (db_postgres_convert_rows(_con, *_res, RES_LAST_ROW(*_res), RES_ROW_N(*_res)) < 0) {
+ if (db_postgres_convert_rows(_con, *_res) < 0) {
LM_ERR("failed to convert rows\n");
if (*_res)
db_free_result(*_res);
diff --git a/modules/db_postgres/km_res.c b/modules/db_postgres/km_res.c
index 1cd9983..f102987 100644
--- a/modules/db_postgres/km_res.c
+++ b/modules/db_postgres/km_res.c
@@ -69,7 +69,7 @@ int db_postgres_convert_result(const db_con_t* _h, db_res_t* _r)
return -2;
}
- if (db_postgres_convert_rows(_h, _r, 0, PQntuples(CON_RESULT(_h))) < 0) {
+ if (db_postgres_convert_rows(_h, _r) < 0) {
LM_ERR("failed to convert rows\n");
db_free_columns(_r);
return -3;
@@ -89,9 +89,6 @@ int db_postgres_get_columns(const db_con_t* _h, db_res_t* _r)
return -1;
}
- /* Get the number of rows (tuples) in the query result. */
- RES_NUM_ROWS(_r) = PQntuples(CON_RESULT(_h));
-
/* Get the number of columns (fields) in each row of the query result. */
RES_COL_N(_r) = PQnfields(CON_RESULT(_h));
@@ -184,60 +181,36 @@ int db_postgres_get_columns(const db_con_t* _h, db_res_t* _r)
/**
* Convert rows from PostgreSQL to db API representation
*/
-int db_postgres_convert_rows(const db_con_t* _h, db_res_t* _r, int row_start,
- int row_count)
+int db_postgres_convert_rows(const db_con_t* _h, db_res_t* _r)
{
- int row, col;
char **row_buf, *s;
- int len, fetch_count;
+ int row, col, len;
if (!_h || !_r) {
- LM_ERR("invalid parameter value\n");
+ LM_ERR("invalid parameter\n");
return -1;
}
- if (row_count == 0) {
- LM_ERR("no rows requested from the query\n");
- return 0;
- }
-
- if (!RES_NUM_ROWS(_r)) {
+ RES_ROW_N(_r) = PQntuples(CON_RESULT(_h));
+ if (!RES_ROW_N(_r)) {
LM_DBG("no rows returned from the query\n");
+ RES_ROWS(_r) = 0;
return 0;
}
- if (row_start < 0) {
- LM_ERR("starting row (%d) cannot be less "
- "then zero, setting it to zero\n", row_start);
- row_start = 0;
- }
-
- if ((row_start + row_count) > RES_NUM_ROWS(_r)) {
- LM_ERR("starting row + row count cannot be > "
- "total rows. Setting row count to read remainder of result set\n");
- row_count = RES_NUM_ROWS(_r) - row_start;
- }
-
- /* Save the number of rows in the current fetch */
- RES_ROW_N(_r) = row_count;
-
- /*
- * Allocate an array of pointers one per column. It that will be used to hold
- * the address of the string representation of each column.
- */
- len = sizeof(char *) * RES_COL_N(_r);
- row_buf = (char **)pkg_malloc(len);
- LM_DBG("allocate for %d columns %d bytes in row buffer at %p\n", RES_COL_N(_r), len, row_buf);
+ len = sizeof(db_row_t) * RES_COL_N(_r);
+ row_buf = (char**)pkg_malloc(len);
if (!row_buf) {
LM_ERR("no private memory left\n");
return -1;
}
+ LM_DBG("allocate for %d columns %d bytes in row buffer at %p\n", RES_COL_N(_r), len, row_buf);
memset(row_buf, 0, len);
/* Allocate a row structure for each row in the current fetch. */
- len = sizeof(db_row_t) * row_count;
+ len = sizeof(db_row_t) * RES_ROW_N(_r);
RES_ROWS(_r) = (db_row_t*)pkg_malloc(len);
- LM_DBG("allocate %d bytes for %d rows at %p\n", len, row_count, RES_ROWS(_r));
+ LM_DBG("allocate %d bytes for %d rows at %p\n", len, RES_ROW_N(_r), RES_ROWS(_r));
if (!RES_ROWS(_r)) {
LM_ERR("no private memory left\n");
@@ -245,8 +218,7 @@ int db_postgres_convert_rows(const db_con_t* _h, db_res_t* _r, int row_start,
}
memset(RES_ROWS(_r), 0, len);
- fetch_count = 0;
- for(row = row_start; row < (row_start + row_count); row++) {
+ for(row = 0; row < RES_ROW_N(_r); row++) {
for(col = 0; col < RES_COL_N(_r); col++) {
/*
* The row data pointer returned by PQgetvalue points to storage
@@ -274,9 +246,9 @@ int db_postgres_convert_rows(const db_con_t* _h, db_res_t* _r, int row_start,
/*
** ASSERT: row_buf contains an entire row in strings
*/
- if(db_postgres_convert_row(_h, _r, &(RES_ROWS(_r)[fetch_count]), row_buf)<0){
+ if(db_postgres_convert_row(_h, _r, &(RES_ROWS(_r)[row]), row_buf)<0){
LM_ERR("failed to convert row #%d\n", row);
- RES_ROW_N(_r) = row - row_start;
+ RES_ROW_N(_r) = row - RES_LAST_ROW(_r);
for (col = 0; col < RES_COL_N(_r); col++) {
LM_DBG("freeing row_buf[%d] at %p\n", col, row_buf[col]);
pkg_free(row_buf[col]);
@@ -328,7 +300,6 @@ int db_postgres_convert_rows(const db_con_t* _h, db_res_t* _r, int row_start,
*/
row_buf[col] = (char *)NULL;
}
- fetch_count++;
}
LM_DBG("freeing row buffer at %p\n", row_buf);
diff --git a/modules/db_postgres/km_res.h b/modules/db_postgres/km_res.h
index 08223d4..860ef56 100644
--- a/modules/db_postgres/km_res.h
+++ b/modules/db_postgres/km_res.h
@@ -34,6 +34,6 @@ int db_postgres_convert_row(const db_con_t* _h, db_res_t* _res, db_row_t* _r,
int db_postgres_get_columns(const db_con_t* _h, db_res_t* _r);
-int db_postgres_convert_rows(const db_con_t* _h, db_res_t* _r, int row_start, int row_count);
+int db_postgres_convert_rows(const db_con_t* _h, db_res_t* _r);
#endif