mirror of
https://github.com/postgres/postgres.git
synced 2026-01-26 09:41:40 +03:00
Continuing to support this backwards-compatibility feature has
nontrivial costs; in particular it is potentially a security hazard
if an application somehow gets confused about which setting the
server is using. We changed the default to ON fifteen years ago,
which seems like enough time for applications to have adapted.
Let's remove support for the legacy string syntax.
We should not remove the GUC altogether, since client-side code will
still test it, pg_dump scripts will attempt to set it to ON, etc.
Instead, just prevent it from being set to OFF. There is precedent
for this approach (see commit de66987ad).
This patch does remove the related GUC escape_string_warning, however.
That setting does nothing when standard_conforming_strings is on,
so it's now useless. We could leave it in place as a do-nothing
setting to avoid breaking clients that still set it, if there are any.
But it seems likely that any such client is also trying to turn off
standard_conforming_strings, so it'll need work anyway.
The client-side changes in this patch are pretty minimal, because even
though we are dropping the server's support, most of our clients still
need to be able to talk to older server versions. We could remove
dead client code only once we disclaim compatibility with pre-v19
servers, which is surely years away. One change of note is that
pg_dump/pg_dumpall now set standard_conforming_strings = on in their
source session, rather than accepting the source server's default.
This ensures that literals in view definitions and such will be
printed in a way that's acceptable to v19+. In particular,
pg_upgrade will work transparently even if the source installation has
standard_conforming_strings = off. (However, pg_restore will behave
the same as before if given an archive file containing
standard_conforming_strings = off. Such an archive will not be safely
restorable into v19+, but we shouldn't break the ability to extract
valid data from it for use with an older server.)
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/3279216.1767072538@sss.pgh.pa.us
52 lines
1.1 KiB
Plaintext
52 lines
1.1 KiB
Plaintext
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
EXEC SQL INCLUDE ../regression;
|
|
|
|
int main() {
|
|
EXEC SQL BEGIN DECLARE SECTION;
|
|
char var[25];
|
|
int i, loopcount;
|
|
EXEC SQL END DECLARE SECTION;
|
|
|
|
ECPGdebug(1, stderr);
|
|
EXEC SQL CONNECT TO REGRESSDB1;
|
|
|
|
EXEC SQL SET AUTOCOMMIT TO ON;
|
|
EXEC SQL WHENEVER SQLWARNING SQLPRINT;
|
|
EXEC SQL WHENEVER SQLERROR STOP;
|
|
|
|
EXEC SQL CREATE TABLE "My_Table" ( Item1 int, Item2 text );
|
|
|
|
EXEC SQL SET standard_conforming_strings TO on;
|
|
|
|
EXEC SQL SHOW standard_conforming_strings INTO :var;
|
|
printf("Standard conforming strings: %s\n", var);
|
|
|
|
/* this is a\\\\b actually */
|
|
EXEC SQL INSERT INTO "My_Table" VALUES ( 2, 'a\\\\b' );
|
|
/* this is a\\b */
|
|
EXEC SQL INSERT INTO "My_Table" VALUES ( 2, E'a\\\\b' );
|
|
|
|
EXEC SQL BEGIN;
|
|
EXEC SQL DECLARE C CURSOR FOR SELECT * FROM "My_Table";
|
|
|
|
EXEC SQL OPEN C;
|
|
|
|
EXEC SQL WHENEVER NOT FOUND DO BREAK;
|
|
|
|
for (loopcount = 0; loopcount < 100; loopcount++)
|
|
{
|
|
EXEC SQL FETCH C INTO :i, :var;
|
|
printf("value: %d %s\n", i, var);
|
|
}
|
|
|
|
EXEC SQL ROLLBACK;
|
|
EXEC SQL DROP TABLE "My_Table";
|
|
|
|
EXEC SQL DISCONNECT ALL;
|
|
|
|
return 0;
|
|
}
|