Re: BUG #2599: AM/PM doesn't work in to_timestamp in

Поиск
Список
Период
Сортировка
Искать

Re: BUG #2599: AM/PM doesn't work in to_timestamp in

От:
Bruce Momjian <bruce@momjian.us>
Дата:
bruce wrote:
> 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.

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

-- 
  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/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:

Re: BUG #2599: AM/PM doesn't work in to_timestamp in

От:
Andrew - Supernews <andrew+nonews@supernews.com>
Дата:
On 2006-09-03, Bruce Momjian  wrote:
>> 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.

The bug appears to have been introduced just before the 8.1 betas; since
it causes the AM/PM indicator simply to never work except at the end of
the string, I see no possible justification for not backpatching the fix.

-- 
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services

Re: BUG #2599: AM/PM doesn't work in to_timestamp in

От:
Bruce Momjian <bruce@momjian.us>
Дата:
Backpatched to 8.1.X.

---------------------------------------------------------------------------

Andrew - Supernews wrote:
> On 2006-09-03, Bruce Momjian  wrote:
> >> 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.
> 
> The bug appears to have been introduced just before the 8.1 betas; since
> it causes the AM/PM indicator simply to never work except at the end of
> the string, I see no possible justification for not backpatching the fix.
> 
> -- 
> Andrew, Supernews
> http://www.supernews.com - individual and corporate NNTP services
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faq

-- 
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
FAQ