1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-29 22:49:41 +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:
Tom Lane
2018-04-17 19:53:50 -04:00
parent 9ffcccdb95
commit 55d26ff638
6 changed files with 89 additions and 38 deletions

View File

@@ -12,14 +12,11 @@
[
# POSTGRES will be replaced at initdb time with a user choice that might
# contain non-word characters, so we must double-quote it.
# The C code typically refers to these roles using the #define symbols,
# so make sure every entry has an oid_symbol value.
{ oid => '10', oid_symbol => 'BOOTSTRAP_SUPERUSERID',
rolname => '"POSTGRES"', rolsuper => 't', rolinherit => 't',
rolname => 'POSTGRES', rolsuper => 't', rolinherit => 't',
rolcreaterole => 't', rolcreatedb => 't', rolcanlogin => 't',
rolreplication => 't', rolbypassrls => 't', rolconnlimit => '-1',
rolpassword => '_null_', rolvaliduntil => '_null_' },

View File

@@ -12,13 +12,10 @@
[
# 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.
{ oid => '1', oid_symbol => 'TemplateDbOid',
descr => 'default template for new databases',
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_' },

View File

@@ -2417,7 +2417,7 @@
{ oid => '1216', descr => 'get description for table column',
proname => 'col_description', prolang => '14', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid int4',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = \'\'pg_catalog.pg_class\'\'::pg_catalog.regclass and objsubid = $2' },
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = \'pg_catalog.pg_class\'::pg_catalog.regclass and objsubid = $2' },
{ oid => '1993',
descr => 'get description for object id and shared catalog name',
proname => 'shobj_description', prolang => '14', procost => '100',
@@ -3483,11 +3483,11 @@
{ oid => '879', descr => 'left-pad string to length',
proname => 'lpad', prolang => '14', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.lpad($1, $2, \'\' \'\')' },
prosrc => 'select pg_catalog.lpad($1, $2, \' \')' },
{ oid => '880', descr => 'right-pad string to length',
proname => 'rpad', prolang => '14', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.rpad($1, $2, \'\' \'\')' },
prosrc => 'select pg_catalog.rpad($1, $2, \' \')' },
{ oid => '881', descr => 'trim spaces from left end of string',
proname => 'ltrim', prorettype => 'text', proargtypes => 'text',
prosrc => 'ltrim1' },
@@ -6930,7 +6930,7 @@
descr => 'disk space usage for the main fork of the specified table or index',
proname => 'pg_relation_size', prolang => '14', provolatile => 'v',
prorettype => 'int8', proargtypes => 'regclass',
prosrc => 'select pg_catalog.pg_relation_size($1, \'\'main\'\')' },
prosrc => 'select pg_catalog.pg_relation_size($1, \'main\')' },
{ oid => '2332',
descr => 'disk space usage for the specified fork of a table or index',
proname => 'pg_relation_size', provolatile => 'v', prorettype => 'int8',
@@ -8168,7 +8168,7 @@
{ oid => '2932', descr => 'evaluate XPath expression',
proname => 'xpath', prolang => '14', prorettype => '_xml',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath($1, $2, \'\'{}\'\'::pg_catalog.text[])' },
prosrc => 'select pg_catalog.xpath($1, $2, \'{}\'::pg_catalog.text[])' },
{ oid => '2614', descr => 'test XML value against XPath expression',
proname => 'xmlexists', prorettype => 'bool', proargtypes => 'text xml',
@@ -8181,7 +8181,7 @@
{ oid => '3050', descr => 'test XML value against XPath expression',
proname => 'xpath_exists', prolang => '14', prorettype => 'bool',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath_exists($1, $2, \'\'{}\'\'::pg_catalog.text[])' },
prosrc => 'select pg_catalog.xpath_exists($1, $2, \'{}\'::pg_catalog.text[])' },
{ oid => '3051', descr => 'determine if a string is well formed XML',
proname => 'xml_is_well_formed', provolatile => 's', prorettype => 'bool',
proargtypes => 'text', prosrc => 'xml_is_well_formed' },