mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Make to_timestamp and friends skip leading spaces before an integer field,
even when not in FM mode. This improves compatibility with Oracle and with our pre-8.4 behavior, as per bug #4862. Brendan Jurd Add a couple of regression test cases for this. In passing, get rid of the labeling of the individual test cases; doesn't seem to be good for anything except causing extra work when inserting a test... Tom Lane
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* formatting.c
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.157 2009/06/11 14:49:03 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.158 2009/06/22 17:54:30 tgl Exp $
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1999-2009, PostgreSQL Global Development Group
|
||||
@ -1817,7 +1817,7 @@ from_char_set_int(int *dest, const int value, const FormatNode *node)
|
||||
* 'dest'. If 'dest' is NULL, the result is discarded.
|
||||
*
|
||||
* In fixed-width mode (the node does not have the FM suffix), consume at most
|
||||
* 'len' characters.
|
||||
* 'len' characters. However, any leading whitespace isn't counted in 'len'.
|
||||
*
|
||||
* We use strtol() to recover the integer value from the source string, in
|
||||
* accordance with the given FormatNode.
|
||||
@ -1840,6 +1840,11 @@ from_char_parse_int_len(int *dest, char **src, const int len, FormatNode *node)
|
||||
char *init = *src;
|
||||
int used;
|
||||
|
||||
/*
|
||||
* Skip any whitespace before parsing the integer.
|
||||
*/
|
||||
*src += strspace_len(*src);
|
||||
|
||||
Assert(len <= DCH_MAX_ITEM_SIZ);
|
||||
used = (int) strlcpy(copy, *src, len + 1);
|
||||
|
||||
|
Reference in New Issue
Block a user