<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<br>
On 12/13/11 4:16 PM, Paul Pankhurst wrote:
<blockquote cite="mid:61F8F956E48446FAA98629168A67314E@pjplaptop"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div dir="ltr">
<div style="font-family: 'Calibri'; color: rgb(0, 0, 0);
font-size: 12pt;">
<div>Thanks for that Daniel.</div>
<div> </div>
<div>I modified the db_url for 2nd db so it used the actual IP
address of my db rather than localhost,</div>
</div>
</div>
</blockquote>
nice idea, indeed -- perhaps can be extended to add some custom
hostnames pointing to same in local computer's /etc/hosts, in case
one would need more dedicated connection. But it would be better if
APi gets extended.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<blockquote cite="mid:61F8F956E48446FAA98629168A67314E@pjplaptop"
type="cite">
<div dir="ltr">
<div style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE:
12pt">
<div> hence it didn’t get pooled, and everything magically
worked.</div>
<div> </div>
<div>I think I’ll extend the db api, it doesn’t look too
difficult to do.</div>
<div> </div>
<div>Paul</div>
<div style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY:
'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT:
normal; TEXT-DECORATION: none">
<div style="FONT: 10pt tahoma">
<div> </div>
<div style="BACKGROUND: #f5f5f5">
<div style="font-color: black"><b>From:</b> <a
moz-do-not-send="true" title="miconda@gmail.com"
href="mailto:miconda@gmail.com">Daniel-Constantin
Mierla</a> </div>
<div><b>Sent:</b> Tuesday, December 13, 2011 12:27 PM</div>
<div><b>To:</b> <a moz-do-not-send="true"
title="sr-dev@lists.sip-router.org"
href="mailto:sr-dev@lists.sip-router.org">Development
mailing list of the sip-router project</a> </div>
<div><b>Cc:</b> <a moz-do-not-send="true"
title="paul@crocodile-rcs.com"
href="mailto:paul@crocodile-rcs.com">Paul Pankhurst</a>
</div>
<div><b>Subject:</b> Re: [sr-dev] db_fetch_next problem
with Postgres?</div>
</div>
</div>
<div> </div>
</div>
<div style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY:
'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT:
normal; TEXT-DECORATION: none">Hello,<br>
<br>
On 12/13/11 1:08 PM, Paul Pankhurst wrote:
<blockquote
cite="mid:F9EDD430CADE4DCF8BF32BD7071530C8@pjplaptop"
type="cite">
<div dir="ltr">
<div style="FONT-FAMILY: 'Calibri'; COLOR: rgb(0,0,0);
FONT-SIZE: 12pt">
<div>should have sent this to list – sorry</div>
<div style="FONT-STYLE: normal; DISPLAY: inline;
FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE:
small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<div style="FONT: 10pt tahoma">
<div> </div>
<div style="BACKGROUND: #f5f5f5">
<div style="font-color: black"><b>From:</b> <a
title="paul@crocodile-rcs.com"
href="mailto:paul@crocodile-rcs.com"
moz-do-not-send="true">Paul Pankhurst</a> </div>
<div><b>Sent:</b> Tuesday, December 13, 2011
12:03 PM</div>
<div><b>To:</b> <a title="miconda@gmail.com"
href="mailto:miconda@gmail.com"
moz-do-not-send="true">miconda@gmail.com</a>
</div>
<div><b>Subject:</b> Re: [sr-dev] db_fetch_next
problem with Postgres?</div>
</div>
</div>
<div> </div>
</div>
<div style="FONT-STYLE: normal; DISPLAY: inline;
FONT-FAMILY: 'Calibri'; COLOR: rgb(0,0,0);
FONT-SIZE: small; FONT-WEIGHT: normal;
TEXT-DECORATION: none">
<div dir="ltr">
<div style="FONT-FAMILY: 'Calibri'; COLOR:
rgb(0,0,0); FONT-SIZE: 12pt">
<div>Hi Daniel,</div>
<div> </div>
<div>I have a bit more information...</div>
<div> </div>
<div>the outline pseudo code for what I am doing
looks like this (removing non relevant stuff)</div>
<div> </div>
<div> </div>
<div>db_fetch_query( xcap_db )</div>
<div> </div>
<div>do</div>
<div style="FONT-STYLE: normal; DISPLAY: inline;
FONT-FAMILY: 'Calibri'; COLOR: rgb(0,0,0);
FONT-SIZE: small; FONT-WEIGHT: normal;
TEXT-DECORATION: none">
<div style="FONT: 10pt tahoma">
<div><font face="Calibri" size="3">{</font></div>
<div> </div>
<div><font face="Calibri" size="3">query(
another_2nd_db )</font></div>
<div> </div>
<div><font face="Calibri" size="3">} while (
db_fetch_next( xcap_db) ) </font></div>
<div> </div>
<div> </div>
<div><font face="Calibri" size="3">it is the
query to the second database that breaks
everything...if I remove it the problem
goes away and db_fetch_next works as
expected.</font></div>
<div><font face="Calibri" size="3">The
access to the 2nd database uses
completely different db_func_t and
db1_cont_t structures to the xcap_db</font></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
if it is the same db_url value, then it results in same
db1_con_t pointers, since the postgres has connection pool
inside and matches an old connection for same db_url when
initializing the second one.<br>
<br>
Some ideas:<br>
- extend db api with a new function init_new that will
always return a new connection -- requires coding in db
modules<br>
- make another database where you add a view to the table in
initial database and work with it for second connection --
should work without touching kamailio code<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<blockquote
cite="mid:F9EDD430CADE4DCF8BF32BD7071530C8@pjplaptop"
type="cite">
<div dir="ltr">
<div style="FONT-FAMILY: 'Calibri'; COLOR: #000000;
FONT-SIZE: 12pt">
<div style="FONT-STYLE: normal; DISPLAY: inline;
FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE:
small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<div dir="ltr">
<div style="FONT-FAMILY: 'Calibri'; COLOR:
#000000; FONT-SIZE: 12pt">
<div style="FONT-STYLE: normal; DISPLAY: inline;
FONT-FAMILY: 'Calibri'; COLOR: #000000;
FONT-SIZE: small; FONT-WEIGHT: normal;
TEXT-DECORATION: none">
<div style="FONT: 10pt tahoma">
<div> </div>
<div><font face="Calibri" size="3">I’ll try
running it with extra debug shortly to
see if I can see what’s happening</font></div>
<div> </div>
<div><font face="Calibri" size="3">Paul</font></div>
<div> </div>
<div style="BACKGROUND: #f5f5f5">
<div style="font-color: black"><b>From:</b>
<a title="miconda@gmail.com"
href="mailto:miconda@gmail.com"
moz-do-not-send="true">Daniel-Constantin
Mierla</a> </div>
<div><b>Sent:</b> Tuesday, December 13,
2011 11:10 AM</div>
<div><b>To:</b> <a
title="sr-dev@lists.sip-router.org"
href="mailto:sr-dev@lists.sip-router.org"
moz-do-not-send="true">Development
mailing list of the sip-router project</a>
</div>
<div><b>Cc:</b> <a
title="paul@crocodile-rcs.com"
href="mailto:paul@crocodile-rcs.com"
moz-do-not-send="true">Paul Pankhurst</a>
</div>
<div><b>Subject:</b> Re: [sr-dev]
db_fetch_next problem with Postgres?</div>
</div>
</div>
<div> </div>
</div>
<div style="FONT-STYLE: normal; DISPLAY: inline;
FONT-FAMILY: 'Calibri'; COLOR: #000000;
FONT-SIZE: small; FONT-WEIGHT: normal;
TEXT-DECORATION: none">Hello,<br>
<br>
On 12/13/11 11:40 AM, Paul Pankhurst wrote:
<blockquote
cite="mid:D3F2C658884F44B6882BA8DB016504E8@pjplaptop"
type="cite">
<div dir="ltr">
<div style="FONT-FAMILY: 'Calibri'; COLOR:
rgb(0,0,0); FONT-SIZE: 12pt">
<div>I am having problems with the
db_fetch_next routine and Postgres.</div>
<div> </div>
<div>I can’t see any problem with my
code that calls it, and as far as I
can tell the problem appears to be in
the db_postgres_fetch_result routine.</div>
<div>On the first invocation of
db_postgres_fetch_result it allocates
a result structure and gives me the
first 5 rows of the 198 that match my
query after calling
db_postgres_convert_rows.</div>
<div>On the 2nd invocation it fails to
retrieve the next 5 rows because
CON_RESULT(_con) is NULL !</div>
<div>Anyone got any suggestions? </div>
</div>
</div>
</blockquote>
can you doublecheck and see if you don't call
free_result() before fetching the next rows?
If you run with debug=3, if there is a
free_result, you should see the log message
from:<br>
<br>
LM_DBG("PQclear(%p) result set\n",
CON_RESULT(_con))<br>
<br>
Cheers,<br>
Daniel<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla -- <a class="moz-txt-link-freetext" href="http://www.asipto.com" moz-do-not-send="true">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://linkedin.com/in/miconda" moz-do-not-send="true">http://linkedin.com/in/miconda</a> -- <a class="moz-txt-link-freetext" href="http://twitter.com/miconda" moz-do-not-send="true">http://twitter.com/miconda</a></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
sr-dev mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla -- <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://linkedin.com/in/miconda">http://linkedin.com/in/miconda</a> -- <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://twitter.com/miconda">http://twitter.com/miconda</a></pre>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
sr-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla -- <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://linkedin.com/in/miconda">http://linkedin.com/in/miconda</a> -- <a class="moz-txt-link-freetext" href="http://twitter.com/miconda">http://twitter.com/miconda</a></pre>
</body>
</html>