pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix mishandling of quoted-list GUC values in pg_dump and ruleuti 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix mishandling of quoted-list GUC values in pg_dump and ruleuti @ 2018-03-22 00:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2018-03-22 00:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix mishandling of quoted-list GUC values in pg_dump and ruleutils.c. Code that prints out the contents of setconfig or proconfig arrays in SQL format needs to handle GUC_LIST_QUOTE variables differently from other ones, because for those variables, flatten_set_variable_args() already applied a layer of quoting. The value can therefore safely be printed as-is, and indeed must be, or flatten_set_variable_args() will muck it up completely on reload. For all other GUC variables, it's necessary and sufficient to quote the value as a SQL literal. We'd recognized the need for this long ago, but mis-analyzed the need slightly, thinking that all GUC_LIST_INPUT variables needed the special treatment. That's actually wrong, since a valid value of a LIST variable might include characters that need quoting, although no existing variables accept such values. More to the point, we hadn't made any particular effort to keep the various places that deal with this up-to-date with the set of variables that actually need special treatment, meaning that we'd do the wrong thing with, for example, temp_tablespaces values. This affects dumping of SET clauses attached to functions, as well as ALTER DATABASE/ROLE SET commands. In ruleutils.c we can fix it reasonably honestly by exporting a guc.c function that allows discovering the flags for a given GUC variable. But pg_dump doesn't have easy access to that, so continue the old method of having a hard-wired list of affected variable names. At least we can fix it to have just one list not two, and update the list to match current reality. A remaining problem with this is that it only works for built-in GUC variables. pg_dump's list obvious knows nothing of third-party extensions, and even the "ask guc.c" method isn't bulletproof since the relevant extension might not be loaded. There's no obvious solution to that, so for now, we'll just have to discourage extension authors from inventing custom GUCs that need GUC_LIST_QUOTE. This has been busted for a long time, so back-patch to all supported branches. Michael Paquier and Tom Lane, reviewed by Kyotaro Horiguchi and Pavel Stehule Discussion: https://postgr.es/m/20180111064900.GA51030@paquier.xyz Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/742869946f4ff121778c2e5923ab51a451b16497 Modified Files -------------- src/backend/utils/adt/ruleutils.c | 13 +++++++++---- src/backend/utils/misc/guc.c | 28 ++++++++++++++++++++++++++-- src/bin/pg_dump/dumputils.c | 35 +++++++++++++++++++++++++++++++---- src/bin/pg_dump/dumputils.h | 2 ++ src/bin/pg_dump/pg_dump.c | 12 ++++++++---- src/include/utils/guc.h | 1 + src/test/regress/expected/rules.out | 27 +++++++++++++++++++++++++++ src/test/regress/sql/rules.sql | 13 +++++++++++++ 8 files changed, 117 insertions(+), 14 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix mishandling of quoted-list GUC values in pg_dump and ruleuti @ 2018-03-22 00:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2018-03-22 00:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix mishandling of quoted-list GUC values in pg_dump and ruleutils.c. Code that prints out the contents of setconfig or proconfig arrays in SQL format needs to handle GUC_LIST_QUOTE variables differently from other ones, because for those variables, flatten_set_variable_args() already applied a layer of quoting. The value can therefore safely be printed as-is, and indeed must be, or flatten_set_variable_args() will muck it up completely on reload. For all other GUC variables, it's necessary and sufficient to quote the value as a SQL literal. We'd recognized the need for this long ago, but mis-analyzed the need slightly, thinking that all GUC_LIST_INPUT variables needed the special treatment. That's actually wrong, since a valid value of a LIST variable might include characters that need quoting, although no existing variables accept such values. More to the point, we hadn't made any particular effort to keep the various places that deal with this up-to-date with the set of variables that actually need special treatment, meaning that we'd do the wrong thing with, for example, temp_tablespaces values. This affects dumping of SET clauses attached to functions, as well as ALTER DATABASE/ROLE SET commands. In ruleutils.c we can fix it reasonably honestly by exporting a guc.c function that allows discovering the flags for a given GUC variable. But pg_dump doesn't have easy access to that, so continue the old method of having a hard-wired list of affected variable names. At least we can fix it to have just one list not two, and update the list to match current reality. A remaining problem with this is that it only works for built-in GUC variables. pg_dump's list obvious knows nothing of third-party extensions, and even the "ask guc.c" method isn't bulletproof since the relevant extension might not be loaded. There's no obvious solution to that, so for now, we'll just have to discourage extension authors from inventing custom GUCs that need GUC_LIST_QUOTE. This has been busted for a long time, so back-patch to all supported branches. Michael Paquier and Tom Lane, reviewed by Kyotaro Horiguchi and Pavel Stehule Discussion: https://postgr.es/m/20180111064900.GA51030@paquier.xyz Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/66e92878aaec5cd505bba367b2fe6f8eb08715aa Modified Files -------------- src/backend/utils/adt/ruleutils.c | 13 +++++++++---- src/backend/utils/misc/guc.c | 28 ++++++++++++++++++++++++++-- src/bin/pg_dump/dumputils.c | 23 +++++++++++++++++++++++ src/bin/pg_dump/dumputils.h | 2 ++ src/bin/pg_dump/pg_dump.c | 12 ++++++++---- src/bin/pg_dump/pg_dumpall.c | 11 ++++++++--- src/include/utils/guc.h | 1 + src/test/regress/expected/rules.out | 27 +++++++++++++++++++++++++++ src/test/regress/sql/rules.sql | 13 +++++++++++++ 9 files changed, 117 insertions(+), 13 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix mishandling of quoted-list GUC values in pg_dump and ruleuti @ 2018-03-22 00:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2018-03-22 00:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix mishandling of quoted-list GUC values in pg_dump and ruleutils.c. Code that prints out the contents of setconfig or proconfig arrays in SQL format needs to handle GUC_LIST_QUOTE variables differently from other ones, because for those variables, flatten_set_variable_args() already applied a layer of quoting. The value can therefore safely be printed as-is, and indeed must be, or flatten_set_variable_args() will muck it up completely on reload. For all other GUC variables, it's necessary and sufficient to quote the value as a SQL literal. We'd recognized the need for this long ago, but mis-analyzed the need slightly, thinking that all GUC_LIST_INPUT variables needed the special treatment. That's actually wrong, since a valid value of a LIST variable might include characters that need quoting, although no existing variables accept such values. More to the point, we hadn't made any particular effort to keep the various places that deal with this up-to-date with the set of variables that actually need special treatment, meaning that we'd do the wrong thing with, for example, temp_tablespaces values. This affects dumping of SET clauses attached to functions, as well as ALTER DATABASE/ROLE SET commands. In ruleutils.c we can fix it reasonably honestly by exporting a guc.c function that allows discovering the flags for a given GUC variable. But pg_dump doesn't have easy access to that, so continue the old method of having a hard-wired list of affected variable names. At least we can fix it to have just one list not two, and update the list to match current reality. A remaining problem with this is that it only works for built-in GUC variables. pg_dump's list obvious knows nothing of third-party extensions, and even the "ask guc.c" method isn't bulletproof since the relevant extension might not be loaded. There's no obvious solution to that, so for now, we'll just have to discourage extension authors from inventing custom GUCs that need GUC_LIST_QUOTE. This has been busted for a long time, so back-patch to all supported branches. Michael Paquier and Tom Lane, reviewed by Kyotaro Horiguchi and Pavel Stehule Discussion: https://postgr.es/m/20180111064900.GA51030@paquier.xyz Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/8132f0f3856d0d36b140ffadb08bb9a38e4b7837 Modified Files -------------- src/backend/utils/adt/ruleutils.c | 13 +++++++++---- src/backend/utils/misc/guc.c | 28 ++++++++++++++++++++++++++-- src/bin/pg_dump/dumputils.c | 23 +++++++++++++++++++++++ src/bin/pg_dump/dumputils.h | 2 ++ src/bin/pg_dump/pg_dump.c | 12 ++++++++---- src/bin/pg_dump/pg_dumpall.c | 11 ++++++++--- src/include/utils/guc.h | 1 + src/test/regress/expected/rules.out | 27 +++++++++++++++++++++++++++ src/test/regress/sql/rules.sql | 13 +++++++++++++ 9 files changed, 117 insertions(+), 13 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix mishandling of quoted-list GUC values in pg_dump and ruleuti @ 2018-03-22 00:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2018-03-22 00:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix mishandling of quoted-list GUC values in pg_dump and ruleutils.c. Code that prints out the contents of setconfig or proconfig arrays in SQL format needs to handle GUC_LIST_QUOTE variables differently from other ones, because for those variables, flatten_set_variable_args() already applied a layer of quoting. The value can therefore safely be printed as-is, and indeed must be, or flatten_set_variable_args() will muck it up completely on reload. For all other GUC variables, it's necessary and sufficient to quote the value as a SQL literal. We'd recognized the need for this long ago, but mis-analyzed the need slightly, thinking that all GUC_LIST_INPUT variables needed the special treatment. That's actually wrong, since a valid value of a LIST variable might include characters that need quoting, although no existing variables accept such values. More to the point, we hadn't made any particular effort to keep the various places that deal with this up-to-date with the set of variables that actually need special treatment, meaning that we'd do the wrong thing with, for example, temp_tablespaces values. This affects dumping of SET clauses attached to functions, as well as ALTER DATABASE/ROLE SET commands. In ruleutils.c we can fix it reasonably honestly by exporting a guc.c function that allows discovering the flags for a given GUC variable. But pg_dump doesn't have easy access to that, so continue the old method of having a hard-wired list of affected variable names. At least we can fix it to have just one list not two, and update the list to match current reality. A remaining problem with this is that it only works for built-in GUC variables. pg_dump's list obvious knows nothing of third-party extensions, and even the "ask guc.c" method isn't bulletproof since the relevant extension might not be loaded. There's no obvious solution to that, so for now, we'll just have to discourage extension authors from inventing custom GUCs that need GUC_LIST_QUOTE. This has been busted for a long time, so back-patch to all supported branches. Michael Paquier and Tom Lane, reviewed by Kyotaro Horiguchi and Pavel Stehule Discussion: https://postgr.es/m/20180111064900.GA51030@paquier.xyz Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a35d7292316556a172f82796811f1ffb3400160b Modified Files -------------- src/backend/utils/adt/ruleutils.c | 13 +++++++++---- src/backend/utils/misc/guc.c | 28 ++++++++++++++++++++++++++-- src/bin/pg_dump/dumputils.c | 23 +++++++++++++++++++++++ src/bin/pg_dump/dumputils.h | 2 ++ src/bin/pg_dump/pg_dump.c | 12 ++++++++---- src/bin/pg_dump/pg_dumpall.c | 11 ++++++++--- src/include/utils/guc.h | 1 + src/test/regress/expected/rules.out | 27 +++++++++++++++++++++++++++ src/test/regress/sql/rules.sql | 13 +++++++++++++ 9 files changed, 117 insertions(+), 13 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix mishandling of quoted-list GUC values in pg_dump and ruleuti @ 2018-03-22 00:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2018-03-22 00:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix mishandling of quoted-list GUC values in pg_dump and ruleutils.c. Code that prints out the contents of setconfig or proconfig arrays in SQL format needs to handle GUC_LIST_QUOTE variables differently from other ones, because for those variables, flatten_set_variable_args() already applied a layer of quoting. The value can therefore safely be printed as-is, and indeed must be, or flatten_set_variable_args() will muck it up completely on reload. For all other GUC variables, it's necessary and sufficient to quote the value as a SQL literal. We'd recognized the need for this long ago, but mis-analyzed the need slightly, thinking that all GUC_LIST_INPUT variables needed the special treatment. That's actually wrong, since a valid value of a LIST variable might include characters that need quoting, although no existing variables accept such values. More to the point, we hadn't made any particular effort to keep the various places that deal with this up-to-date with the set of variables that actually need special treatment, meaning that we'd do the wrong thing with, for example, temp_tablespaces values. This affects dumping of SET clauses attached to functions, as well as ALTER DATABASE/ROLE SET commands. In ruleutils.c we can fix it reasonably honestly by exporting a guc.c function that allows discovering the flags for a given GUC variable. But pg_dump doesn't have easy access to that, so continue the old method of having a hard-wired list of affected variable names. At least we can fix it to have just one list not two, and update the list to match current reality. A remaining problem with this is that it only works for built-in GUC variables. pg_dump's list obvious knows nothing of third-party extensions, and even the "ask guc.c" method isn't bulletproof since the relevant extension might not be loaded. There's no obvious solution to that, so for now, we'll just have to discourage extension authors from inventing custom GUCs that need GUC_LIST_QUOTE. This has been busted for a long time, so back-patch to all supported branches. Michael Paquier and Tom Lane, reviewed by Kyotaro Horiguchi and Pavel Stehule Discussion: https://postgr.es/m/20180111064900.GA51030@paquier.xyz Branch ------ REL9_4_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/67e02cde7373b09a8f6897b7fea3800ceb91ad9e Modified Files -------------- src/backend/utils/adt/ruleutils.c | 13 +++++++++---- src/backend/utils/misc/guc.c | 28 ++++++++++++++++++++++++++-- src/bin/pg_dump/dumputils.c | 23 +++++++++++++++++++++++ src/bin/pg_dump/dumputils.h | 2 ++ src/bin/pg_dump/pg_dump.c | 12 ++++++++---- src/bin/pg_dump/pg_dumpall.c | 11 ++++++++--- src/include/utils/guc.h | 1 + src/test/regress/expected/rules.out | 25 +++++++++++++++++++++++++ src/test/regress/sql/rules.sql | 12 ++++++++++++ 9 files changed, 114 insertions(+), 13 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix mishandling of quoted-list GUC values in pg_dump and ruleuti @ 2018-03-22 00:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2018-03-22 00:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix mishandling of quoted-list GUC values in pg_dump and ruleutils.c. Code that prints out the contents of setconfig or proconfig arrays in SQL format needs to handle GUC_LIST_QUOTE variables differently from other ones, because for those variables, flatten_set_variable_args() already applied a layer of quoting. The value can therefore safely be printed as-is, and indeed must be, or flatten_set_variable_args() will muck it up completely on reload. For all other GUC variables, it's necessary and sufficient to quote the value as a SQL literal. We'd recognized the need for this long ago, but mis-analyzed the need slightly, thinking that all GUC_LIST_INPUT variables needed the special treatment. That's actually wrong, since a valid value of a LIST variable might include characters that need quoting, although no existing variables accept such values. More to the point, we hadn't made any particular effort to keep the various places that deal with this up-to-date with the set of variables that actually need special treatment, meaning that we'd do the wrong thing with, for example, temp_tablespaces values. This affects dumping of SET clauses attached to functions, as well as ALTER DATABASE/ROLE SET commands. In ruleutils.c we can fix it reasonably honestly by exporting a guc.c function that allows discovering the flags for a given GUC variable. But pg_dump doesn't have easy access to that, so continue the old method of having a hard-wired list of affected variable names. At least we can fix it to have just one list not two, and update the list to match current reality. A remaining problem with this is that it only works for built-in GUC variables. pg_dump's list obvious knows nothing of third-party extensions, and even the "ask guc.c" method isn't bulletproof since the relevant extension might not be loaded. There's no obvious solution to that, so for now, we'll just have to discourage extension authors from inventing custom GUCs that need GUC_LIST_QUOTE. This has been busted for a long time, so back-patch to all supported branches. Michael Paquier and Tom Lane, reviewed by Kyotaro Horiguchi and Pavel Stehule Discussion: https://postgr.es/m/20180111064900.GA51030@paquier.xyz Branch ------ REL9_3_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/be677bb5aa792dfb1d108dff445c484baf7f6f5b Modified Files -------------- src/backend/utils/adt/ruleutils.c | 13 +++++++++---- src/backend/utils/misc/guc.c | 28 ++++++++++++++++++++++++++-- src/bin/pg_dump/dumputils.c | 23 +++++++++++++++++++++++ src/bin/pg_dump/dumputils.h | 2 ++ src/bin/pg_dump/pg_dump.c | 12 ++++++++---- src/bin/pg_dump/pg_dumpall.c | 11 ++++++++--- src/include/utils/guc.h | 1 + src/test/regress/expected/rules.out | 25 +++++++++++++++++++++++++ src/test/regress/sql/rules.sql | 12 ++++++++++++ 9 files changed, 114 insertions(+), 13 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2018-03-22 00:03 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2018-03-22 00:03 pgsql: Fix mishandling of quoted-list GUC values in pg_dump and ruleuti Tom Lane <tgl@sss.pgh.pa.us> 2018-03-22 00:03 pgsql: Fix mishandling of quoted-list GUC values in pg_dump and ruleuti Tom Lane <tgl@sss.pgh.pa.us> 2018-03-22 00:03 pgsql: Fix mishandling of quoted-list GUC values in pg_dump and ruleuti Tom Lane <tgl@sss.pgh.pa.us> 2018-03-22 00:03 pgsql: Fix mishandling of quoted-list GUC values in pg_dump and ruleuti Tom Lane <tgl@sss.pgh.pa.us> 2018-03-22 00:03 pgsql: Fix mishandling of quoted-list GUC values in pg_dump and ruleuti Tom Lane <tgl@sss.pgh.pa.us> 2018-03-22 00:03 pgsql: Fix mishandling of quoted-list GUC values in pg_dump and ruleuti Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox