Josh Tolley wrote:
>
> The following bug has been logged online:
>
> Bug reference: 2599
> Logged by: Josh Tolley
> Email address: eggyknap@gmail.com
> PostgreSQL version: 8.1.4
> Operating system: Fedora Core 5
> Description: AM/PM doesn't work in to_timestamp in the middle of a
> string
> Details:
>
> eggyknap=# select to_timestamp('30 Aug 06:01:03.223 PM 2006', 'DD Mon
> HH:MI:SS.MS AM YYYY'), to_timestamp('30 Aug 2006 06:01:03.223 PM', 'DD Mon
> YYYY HH:MI:SS.MS AM');
> to_timestamp | to_timestamp
> ---------------------------+----------------------------
> 0001-08-30 18:01:03-08 BC | 2006-08-30 18:01:03.223-06
>
> This appears to happen when AM/PM isn't the last element in the string.
Nice report. The attached patch fixes it, and will be in 8.2. I am not
backpatching because someone might be relying on this behavior.
--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
Index: src/backend/tcop/pquery.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/tcop/pquery.c,v
retrieving revision 1.108
diff -c -c -r1.108 pquery.c
*** src/backend/tcop/pquery.c 2 Sep 2006 18:17:17 -0000 1.108
--- src/backend/tcop/pquery.c 3 Sep 2006 01:13:20 -0000
***************
*** 1347,1353 ****
* we are. In any case, we arrange to fetch the target row
* going forwards.
*/
! if (portal->posOverflow || portal->portalPos == LLONG_MAX ||
count - 1 <= portal->portalPos / 2)
{
DoPortalRewind(portal);
--- 1347,1353 ----
* we are. In any case, we arrange to fetch the target row
* going forwards.
*/
! if (portal->posOverflow || portal->portalPos == FETCH_ALL ||
count - 1 <= portal->portalPos / 2)
{
DoPortalRewind(portal);
Index: src/include/nodes/parsenodes.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/nodes/parsenodes.h,v
retrieving revision 1.327
diff -c -c -r1.327 parsenodes.h
*** src/include/nodes/parsenodes.h 2 Sep 2006 18:17:17 -0000 1.327
--- src/include/nodes/parsenodes.h 3 Sep 2006 01:13:22 -0000
***************
*** 14,19 ****
--- 14,21 ----
#ifndef PARSENODES_H
#define PARSENODES_H
+ #include "limits.h"
+
#include "nodes/primnodes.h"
#include "nodes/value.h"
***************
*** 1439,1445 ****
--- 1441,1452 ----
FETCH_RELATIVE
} FetchDirection;
+ #ifdef HAVE_INT64
#define FETCH_ALL LLONG_MAX
+ #else
+ #define FETCH_ALL LONG_MAX
+ #endif
+
typedef struct FetchStmt
{