bruce wrote:
> Josh Tolley wrote:
> > 
> > The following bug has been logged online:
> > 
> > Bug reference:      2599
> > Logged by:          Josh Tolley
> > Email address:      [EMAIL PROTECTED]
> > 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.

Sorry, I attached the wrong patch to the email.  This is the right one.

-- 
  Bruce Momjian   [EMAIL PROTECTED]
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/backend/utils/adt/formatting.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -c -r1.110 -r1.111
*** src/backend/utils/adt/formatting.c	19 Apr 2006 18:49:09 -0000	1.110
--- src/backend/utils/adt/formatting.c	3 Sep 2006 01:22:56 -0000	1.111
***************
*** 1762,1768 ****
  					tmfc->am = TRUE;
  				else
  					AMPM_ERROR;
! 				return strlen(p_inout);
  			}
  			break;
  		case DCH_AM:
--- 1762,1768 ----
  					tmfc->am = TRUE;
  				else
  					AMPM_ERROR;
! 				return strlen(P_M_STR);
  			}
  			break;
  		case DCH_AM:
***************
*** 1781,1787 ****
  					tmfc->am = TRUE;
  				else
  					AMPM_ERROR;
! 				return strlen(p_inout);
  			}
  			break;
  		case DCH_a_m:
--- 1781,1787 ----
  					tmfc->am = TRUE;
  				else
  					AMPM_ERROR;
! 				return strlen(PM_STR);
  			}
  			break;
  		case DCH_a_m:
***************
*** 1800,1806 ****
  					tmfc->am = TRUE;
  				else
  					AMPM_ERROR;
! 				return strlen(p_inout);
  			}
  			break;
  		case DCH_am:
--- 1800,1806 ----
  					tmfc->am = TRUE;
  				else
  					AMPM_ERROR;
! 				return strlen(p_m_STR);
  			}
  			break;
  		case DCH_am:
***************
*** 1819,1825 ****
  					tmfc->am = TRUE;
  				else
  					AMPM_ERROR;
! 				return strlen(p_inout);
  			}
  			break;
  		case DCH_HH:
--- 1819,1825 ----
  					tmfc->am = TRUE;
  				else
  					AMPM_ERROR;
! 				return strlen(pm_STR);
  			}
  			break;
  		case DCH_HH:
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Reply via email to