[exim-cvs] cvs commit: exim/exim-src/src/lookups mysql.c

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Nigel Metheringham
Data:  
Para: exim-cvs
Asunto: [exim-cvs] cvs commit: exim/exim-src/src/lookups mysql.c
nm4 2010/03/05 15:59:29 GMT

  Modified files:
    exim-src/src/lookups mysql.c 
  Log:
  Support mysql stored procedures.  Fixes: #965


  Revision  Changes    Path
  1.7       +16 -1     exim/exim-src/src/lookups/mysql.c


  Index: mysql.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/lookups/mysql.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- mysql.c    16 Nov 2009 19:50:38 -0000    1.6
  +++ mysql.c    5 Mar 2010 15:59:29 -0000    1.7
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/lookups/mysql.c,v 1.6 2009/11/16 19:50:38 nm4 Exp $ */
  +/* $Cambridge: exim/exim-src/src/lookups/mysql.c,v 1.7 2010/03/05 15:59:29 nm4 Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -202,7 +202,7 @@
     if (mysql_real_connect(mysql_handle,
         /*  host        user         passwd     database */
         CS sdata[0], CS sdata[2], CS sdata[3], CS sdata[1],
  -      port, CS socket, 0) == NULL)
  +      port, CS socket, CLIENT_MULTI_RESULTS) == NULL)
       {
       *errmsg = string_sprintf("MYSQL connection failed: %s",
         mysql_error(mysql_handle));
  @@ -291,6 +291,21 @@
       }
     }


  +/* more results? -1 = no, >0 = error, 0 = yes (keep looping)
  +   This is needed because of the CLIENT_MULTI_RESULTS on mysql_real_connect(),
  +   we don't expect any more results. */
  +
  +while((i = mysql_next_result(mysql_handle)) >= 0) {
  +   if(i == 0) {   /* Just ignore more results */
  +     DEBUG(D_lookup) debug_printf("MYSQL: got unexpected more results\n");
  +     continue;
  +   }
  +
  +   *errmsg = string_sprintf("MYSQL: lookup result error when checking for more results: %s\n",
  +       mysql_error(mysql_handle));
  +   goto MYSQL_EXIT;
  +}
  +
   /* If result is NULL then no data has been found and so we return FAIL.
   Otherwise, we must terminate the string which has been built; string_cat()
   always leaves enough room for a terminating zero. */