diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-06-22 17:54:30 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-06-22 17:54:30 +0000 |
commit | 3f1e529e7897a307ff3431a06b739fa7069d792b (patch) | |
tree | 207313375aaf7a236fe2b4ca0bcdaba752b2e8a7 /src/backend/utils/adt/formatting.c | |
parent | 18df0ffbd2e3a8f93640431f12235a6714785755 (diff) | |
download | postgresql-3f1e529e7897a307ff3431a06b739fa7069d792b.tar.gz postgresql-3f1e529e7897a307ff3431a06b739fa7069d792b.zip |
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
Diffstat (limited to 'src/backend/utils/adt/formatting.c')
-rw-r--r-- | src/backend/utils/adt/formatting.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 064993bd87b..66e75995fd0 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -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); |