postgres/src
Tom Lane 63ca86318d Fix quoted-substring handling in format parsing for to_char/to_number/etc.
This code evidently intended to treat backslash as an escape character
within double-quoted substrings, but it was sufficiently confused that
cases like ..."foo\\"... did not work right: the second backslash
managed to quote the double-quote after it, despite being quoted itself.
Rewrite to get that right, while preserving the existing behavior
outside double-quoted substrings, which is that backslash isn't special
except in the combination \".

Comparing to Oracle, it seems that their version of to_char() for
timestamps allows literal alphanumerics only within double quotes, while
non-alphanumerics are allowed outside quotes; backslashes aren't special
anywhere; there is no way at all to emit a literal double quote.
(Bizarrely, their to_char() for numbers is different; it doesn't allow
literal text at all AFAICT.)  The fact that they don't treat backslash
as special justifies our existing behavior for backslash outside double
quotes.  I considered making backslash inside double quotes act the same
way (ie, special only if before "), which in a green field would be a
more consistent behavior.  But that would likely break more existing SQL
code than what this patch does.

Add some test cases illustrating this behavior.  (Only the last new
case actually changes behavior in this commit.)

Little of this behavior was documented, either, so fix that.

Discussion: https://postgr.es/m/3626.1510949486@sss.pgh.pa.us
2017-11-18 12:16:37 -05:00
..
backend Fix quoted-substring handling in format parsing for to_char/to_number/etc. 2017-11-18 12:16:37 -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 Support channel binding 'tls-unique' in SCRAM 2017-11-18 10:15:54 -05:00
interfaces Support channel binding 'tls-unique' in SCRAM 2017-11-18 10:15:54 -05: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 Fix quoted-substring handling in format parsing for to_char/to_number/etc. 2017-11-18 12:16:37 -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