<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    ok, so I got back into the db_text code (as much as I wanted not to
    :-) ) and now it's clearer what's all about. There are practically
    two result structures, one intermediary built internally by db_text
    and from it, one built for the use in modules. I thought it is about
    a single structure that has now to be moved somewhere else.<br>
    <br>
    But with db_text, the first was in connection, the second was in
    db_res, so a new query would reset the intermediary one from
    connection. It makes sense to have both in one place, otherwise
    indeed can end up in issues with a new query before processing
    current result.<br>
    <br>
    You can go ahead and merge the patch.<br>
    <br>
    Regarding DB_CAP_FETCH is set in lib/srdb1 for the modules that
    export the fetch result function.<br>
    <br>
    Thanks,<br>
    Daniel<br>
    <br>
    <div class="moz-cite-prefix">On 13/09/14 14:47, Luis Azedo wrote:<br>
    </div>
    <blockquote
cite="mid:6FFC6465A51B5B4C80DD111E16112FD1BC64BD@mbx022-w1-ca-4.exch022.domain.local"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <div style="direction: ltr;font-family: Tahoma;color:
        #000000;font-size: 10pt;">Hi Daniel,
        <div><br>
        </div>
        <div>
          <div>since db_text doesn't support DB_CAP_FETCH i think this
            wouldn't be a problem.</div>
        </div>
        <div><br>
        </div>
        <div>the internal structure result is saved in db1_res ptr
          field. <span style="font-size: 10pt;">I don't know about the
            other db modules, but a quick look at mysql db module seems
            to show a similar approach with db1_res ptr field, check </span><b
            style="font-size: 10pt;">db_mysql_free_result</b></div>
        <div> </div>
        <div>btw, <b>db_fetch_next</b> tests for <span style="font-size:
            10pt;">DB_CAP_FETCH and i believe this is not set mysql
            db_init, am i missing something?</span></div>
        <div><br>
          <div style="font-family: Times New Roman; color: #000000;
            font-size: 16px">
            <hr tabindex="-1">
            <div id="divRpF806817" style="direction: ltr;"><font
                face="Tahoma" color="#000000" size="2"><b>From:</b>
                Daniel-Constantin Mierla [<a class="moz-txt-link-abbreviated" href="mailto:miconda@gmail.com">miconda@gmail.com</a>]<br>
                <b>Sent:</b> Saturday, September 13, 2014 1:17 AM<br>
                <b>To:</b> Luis Azedo; Kamailio (SER) - Development
                Mailing List; Waite, Hugh; Peter Dunkley<br>
                <b>Subject:</b> Re: [sr-dev] kazoo module updates &
                documentation<br>
              </font><br>
            </div>
            <div>Hello,<br>
              <br>
              this looks like a problem, indeed. Thanks for
              troubleshooting to get down to it.<br>
              <br>
              However, the solution to store the result in local
              variable is still not the good choice. That is because we
              have so called result fetch support, where the result from
              the query is not retrieved all at once from database
              connection, but you can specify the number of rows (e.g.,
              you want to get in db_res only 1000 rows at the moment).
              Therefore, the result of the initial query will not be
              processed entirely if the second query is done over the
              same connection after retrieving only the first
              fetch_rows.<br>
              <br>
              I haven't looked deep at your patch to db_text, it might
              solve it for your module, but overall the problem remains
              with the other db modules (e.g., mysql, ...). We need to
              come up with a fix for everything affected.<br>
              <br>
              One solution is to update the presence module to use two
              connection, one not-pooled (so it will do always a new
              connection, not selecting from existing pool if db_url
              matches). IIRC, there is a similar case in another module,
              developed at that time by Peter or Hugh -- cc-ed them,
              hopefully they can share some insights quickly. I will
              look as well over the issue to see if there are
              alternatives to fix it.<br>
              <br>
              Cheers,<br>
              Daniel<br>
              <br>
              <div class="moz-cite-prefix">On 13/09/14 03:59, Luis Azedo
                wrote:<br>
              </div>
              <blockquote type="cite">
                <div style="direction:ltr; font-family:Tahoma;
                  color:#000000; font-size:10pt">Hi Daniel,
                  <div><br>
                  </div>
                  <div>please take a look at msg_presentity_clean
                    function in publish.c module presence.</div>
                  <div><br>
                  </div>
                  <div>if the initial query returns a result</div>
                  <div>if pres_notifier_processes = 0 (immediate notify)</div>
                  <div>it calls publ_notify function</div>
                  <div>in publ_notify function in notify.c </div>
                  <div>
                    <div>if(p->event->agg_nbody) // dialoginfo
                      aggregates the results</div>
                    <div>{<span class="Apple-tab-span"
                        style="white-space:pre"> </span></div>
                    <div><span class="Apple-tab-span"
                        style="white-space:pre"></span>notify_body = <b>
                        get_p_notify_body</b>(pres_uri, p->event ,
                      offline_etag, NULL);</div>
                  </div>
                  <div>         .....</div>
                  <div><b>get_p_notify_body </b>queries the <b>presentity
                    </b>table to get other records to aggregate body</div>
                  <div>which will override the result in the connection.</div>
                  <div><br>
                  </div>
                  <div>so the process is the same but it calls the query
                    2 times in a row without freeing the 1st result.</div>
                  <div><br>
                  </div>
                  <div><br>
                  </div>
                  <div><br>
                  </div>
                  <div><br>
                  </div>
                  <div>
                    <div style="font-family:Times New Roman;
                      color:#000000; font-size:16px">
                      <hr tabindex="-1">
                      <div id="divRpF523141" style="direction:ltr"><font
                          face="Tahoma" color="#000000" size="2"><b>From:</b>
                          <a moz-do-not-send="true"
                            class="moz-txt-link-abbreviated"
                            href="mailto:sr-dev-bounces@lists.sip-router.org"
                            target="_blank">
                            sr-dev-bounces@lists.sip-router.org</a> [<a
                            moz-do-not-send="true"
                            class="moz-txt-link-abbreviated"
                            href="mailto:sr-dev-bounces@lists.sip-router.org"
                            target="_blank">sr-dev-bounces@lists.sip-router.org</a>]
                          on behalf of Daniel-Constantin Mierla [<a
                            moz-do-not-send="true"
                            class="moz-txt-link-abbreviated"
                            href="mailto:miconda@gmail.com"
                            target="_blank">miconda@gmail.com</a>]<br>
                          <b>Sent:</b> Friday, September 12, 2014 12:15
                          PM<br>
                          <b>To:</b> Kamailio (SER) - Development
                          Mailing List<br>
                          <b>Subject:</b> Re: [sr-dev] kazoo module
                          updates & documentation<br>
                        </font><br>
                      </div>
                      <div>Hello,<br>
                        <br>
                        changes to kazoo modules are ok, you can merge
                        them.<br>
                        <br>
                        But the one for db_text I don't find it (yet)
                        necessary, because it may solve an issue in a
                        wrong way.<br>
                        <br>
                        I asked you to push the other patch on db_text
                        related to blob type handling in freeing the
                        value. That can be done. For the one storing the
                        result on db_res variable, I will comment
                        separately.<br>
                        <br>
                        Daniel<br>
                        <br>
                        <div class="moz-cite-prefix">On 12/09/14 20:55,
                          Luis Azedo wrote:<br>
                        </div>
                        <blockquote type="cite">
                          <style type="text/css" id="owaParaStyle">
<!--
-->
</style>
                          <div style="direction:ltr; font-family:Tahoma;
                            color:#000000; font-size:10pt">Hi,
                            <div><br>
                            </div>
                            <div>i would like to propose the small
                              changes to the kazoo module in branch
                              lazedo/kazoo to go into master.</div>
                            <div>it's mostly code cleanup &
                              dependency removal.</div>
                            <div><br>
                            </div>
                            <div>also added the documentation on that
                              branch and would appreciate any feedback.</div>
                            <div><br>
                            </div>
                            <div><br>
                            </div>
                            <div>there is also a patch to the db_text
                              module. the comment on that commit tells
                              the reason for that patch.</div>
                            <div><br>
                            </div>
                            <div>Thanks</div>
                            <div><br>
                            </div>
                          </div>
                          <br>
                          <fieldset class="mimeAttachmentHeader"
                            target="_blank"></fieldset>
                          <br>
                          <pre>_______________________________________________
sr-dev mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.sip-router.org" target="_blank">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" target="_blank">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://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a>
Next Kamailio Advanced Trainings 2014 - <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
Sep 22-25, Berlin, Germany</pre>
                      </div>
                    </div>
                  </div>
                </div>
              </blockquote>
              <br>
              <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a>
Next Kamailio Advanced Trainings 2014 - <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
Sep 22-25, Berlin, Germany</pre>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Next Kamailio Advanced Trainings 2014 - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
Sep 22-25, Berlin, Germany</pre>
  </body>
</html>