Hello,

it seems that there was a problem in dbpgsql.c regarding error handling in db_search_range(): Changed PQntupes(res)>0 to PQntupes(res)==0, now everything works as expected (see patch attached) :-)

Note that this patch includes two additional fixes to ensure correct internal dates when using a non-US PostreSQL DATESTYLE (see also http://mailman.fastxs.nl/pipermail/dbmail/2003-March/002437.html)

Please note that I have had the debian patch applied before making my changes.


So long
Thomas
--- ..\dbmailold\dbmail\pgsql\dbpgsql.c 2003-03-20 18:57:35.000000000 +0100
+++ pgsql\dbpgsql.c     2003-03-20 19:03:42.000000000 +0100
@@ -1,4 +1,4 @@
-/* $Id: dbpgsql.c,v 1.1.1.1 2003/03/20 17:57:35 tsauer Exp $
+/* $Id: dbpgsql.c,v 1.2 2003/03/20 18:03:42 tsauer Exp $
  * (c) 2000-2002 IC&S, The Netherlands (http://www.ic-s.nl)
  *
  * postgresql driver file
@@ -3755,7 +3755,10 @@
 
   char *row;
 
-  snprintf(query, DEF_QUERYSIZE, "SELECT internal_date FROM messages WHERE 
mailbox_idnr = %llu::bigint "
+  /* [EMAIL PROTECTED]  Added missing to_char because otherwise date_sql2imap 
will break */
+  snprintf(query, DEF_QUERYSIZE, 
+          "SELECT to_char(internal_date, 'YYYY-MM-DD HH24:MI:SS') "
+           "FROM messages WHERE mailbox_idnr = %llu::bigint "
           "AND message_idnr = %llu::bigint AND unique_id!=''", mailboxuid, 
msguid);
 
   if (db_query(query) == -1)
@@ -3854,8 +3857,9 @@
   *result = 0;
   *resultsetlen = 0;
 
+  /* [EMAIL PROTECTED]  Added missing to_char because otherwise date_sql2imap 
will break */
   snprintf(query, DEF_QUERYSIZE, "SELECT seen_flag, answered_flag, 
deleted_flag, "
-          "flagged_flag, draft_flag, recent_flag, internal_date, rfcsize, 
message_idnr "
+          "flagged_flag, draft_flag, recent_flag, to_char(internal_date, 
'YYYY-MM-DD HH24:MI:SS'), rfcsize, message_idnr "
           "FROM messages WHERE "
           "message_idnr >= %llu::bigint AND message_idnr <= %llu::bigint AND 
mailbox_idnr = %llu::bigint "
           "AND status<2 AND unique_id != '' "
@@ -4057,7 +4061,10 @@
       return 0;
     }
 
-  if (PQntuples(res)>0)
+  /* [EMAIL PROTECTED] Originally, PQntupes(res)>0 raised the error below,
+     which is not what we want (because below, multiple result set rows
+     are supported.) */
+  if (PQntuples(res) == 0)
     {
       trace (TRACE_ERROR,"db_search_range(): bad range specified\n");
       PQclear(res);

Reply via email to