postgresql/src
Tom Lane e87d4965bd Prevent to_number() from losing data when template doesn't match exactly.
Non-data template patterns would consume characters whether or not those
characters were what the pattern expected, for example
	SELECT TO_NUMBER('1234', '9,999');
produced 134 because the '2' got eaten by the comma pattern.  This seems
undesirable, not least because it doesn't happen in Oracle.  For the ','
and 'G' template patterns, we can fix this by consuming characters only
if they match what the pattern would output.  For non-data patterns such
as 'L' and 'TH', it seems impractical to tighten things up to the point of
consuming only exact matches to what the pattern would output; but we can
improve matters quite a lot by redefining the behavior as "consume only
characters that aren't digits, signs, decimal point, or comma".

Also, fix it so that the behavior is to consume the number of *characters*
the pattern would output, not the number of *bytes*.  The old coding would
do surprising things with non-ASCII currency symbols, for example.  (It
would be good to apply that rule for literal text as well, but this commit
only fixes it for non-data patterns.)

Oliver Ford, reviewed by Thomas Munro and Nathan Wagner, and whacked around
a bit more by me

Discussion: https://postgr.es/m/CAGMVOdvpbMqPf9XWNzOwBpzJfErkydr_fEGhmuDGa015z97mwg@mail.gmail.com
2017-11-17 12:04:13 -05:00
..
backend Prevent to_number() from losing data when template doesn't match exactly. 2017-11-17 12:04:13 -05:00
bin Fix bogus logic for checking data dirs' versions within pg_upgrade. 2017-11-16 11:16:53 -05:00
common Change TRUE/FALSE to true/false 2017-11-08 11:37:28 -05:00
fe_utils Exclude flex-generated code from coverage testing 2017-10-16 16:28:11 -04:00
include Set proargmodes for satisfies_hash_partition. 2017-11-17 11:53:00 -05:00
interfaces Add post-2010 ecpg tests to checktcp. 2017-11-11 14:35:22 -08:00
makefiles Always use -fPIC, not -fpic, when building shared libraries with gcc. 2017-06-01 13:32:55 -04:00
pl Make PL/Python handle domain-type conversions correctly. 2017-11-16 16:23:04 -05:00
port Rewrite strnlen replacement implementation from 8a241792f9. 2017-10-10 14:50:30 -07:00
template Force "restrict" not to be used when compiling with xlc. 2017-10-13 12:15:06 -07:00
test Prevent to_number() from losing data when template doesn't match exactly. 2017-11-17 12:04:13 -05:00
timezone Update time zone data files to tzdata release 2017c. 2017-10-23 18:15:36 -04:00
tools Provide DSM segment to ExecXXXInitializeWorker functions. 2017-11-16 17:39:18 -08:00
tutorial Distinguish selectivity of < from <= and > from >=. 2017-09-13 11:12:39 -04:00
.gitignore
DEVELOPERS
Makefile Remove redundant coverage target 2017-02-17 08:56:57 -05:00
Makefile.global.in Reinstate genhtml --prefix option for non-vpath builds 2017-10-14 11:44:45 -04:00
Makefile.shlib Remove support for bcc and msvc standalone libpq builds 2017-04-11 15:22:21 +02:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00