postgresql/src
Tom Lane c16a1bbcf4 Add documentation and tests for quote marks in ECPG literal queries.
ECPG's PREPARE ... FROM and EXECUTE IMMEDIATE can optionally take
the target query as a simple literal, rather than the more usual
string-variable reference.  This was previously documented as
being a C string literal, but that's a lie in one critical respect:
you can't write a data double quote as \" in such literals.  That's
because the lexer is in SQL mode at this point, so it'll parse
double-quoted strings as SQL identifiers, within which backslash
is not special, so \" ends the literal.

I looked into making this work as documented, but getting the lexer
to switch behaviors at just the right point is somewhere between
very difficult and impossible.  It's not really worth the trouble,
because these cases are next to useless: if you have a fixed SQL
statement to execute or prepare, you might as well write it as
a direct EXEC SQL, saving the messiness of converting it into
a string literal and gaining the opportunity for compile-time
SQL syntax checking.

Instead, let's just document (and test) the workaround of writing
a double quote as an octal escape (\042) in such cases.

There's no code behavioral change here, so in principle this could
be back-patched, but it's such a niche case I doubt it's worth
the trouble.

Per report from 1250kv.

Discussion: https://postgr.es/m/673825.1603223178@sss.pgh.pa.us
2020-10-22 18:29:46 -04:00
..
backend Extend amcheck to check heap pages. 2020-10-22 08:44:18 -04:00
bin Clean up some unpleasant behaviors in psql's \connect command. 2020-10-22 14:04:28 -04:00
common Fix -Wcast-function-type warnings on Windows/MinGW 2020-10-21 08:17:51 +02:00
fe_utils Standardize the printf format for st_size 2020-09-24 21:04:21 +02:00
include Extend amcheck to check heap pages. 2020-10-22 08:44:18 -04:00
interfaces Add documentation and tests for quote marks in ECPG literal queries. 2020-10-22 18:29:46 -04:00
makefiles Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
pl Fixup some appendStringInfo and appendPQExpBuffer calls 2020-10-15 20:35:17 +13:00
port Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
template Fix compiler warning for ppoll() on Cygwin 2019-12-22 23:20:00 +01:00
test Use croak instead of die in Perl code when appropriate 2020-10-22 13:41:28 +02:00
timezone Update time zone data files to tzdata release 2020c. 2020-10-16 21:53:33 -04:00
tools Extend amcheck to check heap pages. 2020-10-22 08:44:18 -04:00
tutorial Remove support for postfix (right-unary) operators. 2020-09-17 19:38:05 -04:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Split Makefile symbol CFLAGS_VECTOR into two symbols. 2020-09-06 21:28:16 -04:00
Makefile.shlib Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:04:20 +02:00