mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Rationalize handling of single and double quotes in bootstrap data.
Change things around so that proper quoting of values interpolated into the BKI data by initdb is the responsibility of initdb, not something we half-heartedly handle by putting double quotes into the raw BKI data. (Note: experimentation shows that it still doesn't work to put a double quote into the initial superuser username, but that's the fault of inadequate quoting while interpolating the name into SQL scripts; the BKI aspect of it works fine now.) Having done that, we can remove the special-case handling of values that look like "something" from genbki.pl, and instead teach it to escape double --- and single --- quotes properly. This removes the nowhere-documented need to treat those specially in the BKI source data; whatever you write will be passed through unchanged into the inserted data value, modulo Perl's rules about single-quoted strings. Add documentation explaining the (pre-existing) handling of backslashes in the BKI data. Per an earlier discussion with John Naylor. Discussion: https://postgr.es/m/CAJVSVGUNao=-Q2-vAN3PYcdF5tnL5JAHwGwzZGuYHtq+Mk_9ng@mail.gmail.com
This commit is contained in:
@ -184,13 +184,11 @@
|
||||
<programlisting>
|
||||
[
|
||||
|
||||
# LC_COLLATE and LC_CTYPE will be replaced at initdb time with user choices
|
||||
# that might contain non-word characters, so we must double-quote them.
|
||||
|
||||
# A comment could appear here.
|
||||
{ oid => '1', oid_symbol => 'TemplateDbOid',
|
||||
descr => 'database\'s default template',
|
||||
datname => 'template1', datdba => 'PGUID', encoding => 'ENCODING',
|
||||
datcollate => '"LC_COLLATE"', datctype => '"LC_CTYPE"', datistemplate => 't',
|
||||
datcollate => 'LC_COLLATE', datctype => 'LC_CTYPE', datistemplate => 't',
|
||||
datallowconn => 't', datconnlimit => '-1', datlastsysoid => '0',
|
||||
datfrozenxid => '0', datminmxid => '1', dattablespace => '1663',
|
||||
datacl => '_null_' },
|
||||
@ -234,10 +232,16 @@
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
All values must be single-quoted. Escape single quotes used within
|
||||
a value with a backslash. (Backslashes meant as data need not be
|
||||
doubled, however; this follows Perl's rules for simple quoted
|
||||
literals.)
|
||||
All values must be single-quoted. Escape single quotes used within a
|
||||
value with a backslash. Backslashes meant as data can, but need not,
|
||||
be doubled; this follows Perl's rules for simple quoted literals.
|
||||
Note that backslashes appearing as data will be treated as escapes by
|
||||
the bootstrap scanner, according to the same rules as for escape string
|
||||
constants (see <xref linkend="sql-syntax-strings-escape"/>); for
|
||||
example <literal>\t</literal> converts to a tab character. If you
|
||||
actually want a backslash in the final value, you will need to write
|
||||
four of them: Perl strips two, leaving <literal>\\</literal> for the
|
||||
bootstrap scanner to see.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
@ -247,15 +251,6 @@
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
If a value is a macro to be expanded
|
||||
by <application>initdb</application>, it should also contain double
|
||||
quotes as shown above, unless we know that no special characters can
|
||||
appear within the string that will be substituted.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Comments are preceded by <literal>#</literal>, and must be on their
|
||||
|
Reference in New Issue
Block a user