提交 59a46fac 编写于 作者: D Daniel Gustafsson

Revert "Use backend quoting functions instead of libpq"

Revert the patch since it broke tests for gprestore and gptransfer in
the main pipeline. While the test quoted in the original Jira passes
there seems to be more to it than meets the Jira.. Revert for now.
Reverts:

  commit 1bb0b765
  Author: Daniel Gustafsson <dgustafsson@pivotal.io>
  Date:   Wed Apr 5 13:07:10 2017 +0200

    Use backend quoting functions instead of libpq

    libpq is front-end code and shouldn't be used in backend processes.
    The requirement here is to correctly quote the relation name in
    partitioning such that pg_dump/gp_dump can create working DDL for
    the partition hierarchy. For this purpose, quote_literal_internal()
    does the same thing as PQescapeString(). The following relation
    definitions were hitting the previous bug fixed by applying proper
    quoting:
上级 1bb0b765
......@@ -6969,12 +6969,31 @@ partition_rule_def_worker(PartitionRule *rule, Node *start,
if (bLeafTablename) /* MPP-6297: dump by tablename */
{
StringInfoData sid1;
PQExpBuffer pqbuf = createPQExpBuffer();
initStringInfo(&sid1);
/* Always quote to make WITH (tablename=...) work correctly */
/* always quote to make WITH (tablename=...) work correctly */
/* MPP-12243: but don't use quote_identifier if already quoted! */
char *relname = get_rel_name(rule->parchildrelid);
appendStringInfo(&sid1, "tablename=%s", quote_literal_internal(relname));
int len = strlen(relname);
if(strchr(relname, '\\') != NULL)
appendPQExpBufferChar(pqbuf, ESCAPE_STRING_SYNTAX);
appendPQExpBufferChar(pqbuf, '\'');
if(!enlargePQExpBuffer(pqbuf, 2 * len + 2))
elog(ERROR, "failed to increase buffer size for escaping relname %s", relname);
pqbuf->len += PQescapeString(pqbuf->data + pqbuf->len, relname, len);
appendPQExpBufferChar(pqbuf, '\'');
appendStringInfo(&sid1, "tablename=%s", pqbuf->data);
destroyPQExpBuffer(pqbuf);
/* MPP-7191, MPP-7193: fully-qualify storage type if not
* specified (and not a template)
......@@ -7025,16 +7044,36 @@ partition_rule_def_worker(PartitionRule *rule, Node *start,
if (bLeafTablename && part->paristemplate)
{
/*
* Make a fake tablename for template entries to invoke special
* dump/restore magic in parse_partition.c:partition_range_every()
* for EVERY. Note that the tablename is ignored during SET
* SUBPARTITION TEMPLATE because the template rules do not have
* corresponding relations (MPP-6297)
/* hackery! */
/* MPP-6297: Make a fake tablename for template entries to
* invoke special dump/restore magic for EVERY in
* analyze.c:partition_range_every(). Note that the
* tablename is ignored during SET SUBPARTITION TEMPLATE
* because the template rules do not have corresponding
* relations
*
* MPP-10480: use tablename
*/
PQExpBuffer pqbuf = createPQExpBuffer();
char *relname = get_rel_name(part->parrelid);
appendStringInfo(&buf, "tablename=%s", quote_literal_internal(relname));
int len = strlen(relname);
if(strchr(relname, '\\') != NULL)
appendPQExpBufferChar(pqbuf, ESCAPE_STRING_SYNTAX);
appendPQExpBufferChar(pqbuf, '\'');
if(!enlargePQExpBuffer(pqbuf, 2 * len + 2))
elog(ERROR, "failed to increase buffer size for escaping relname %s", relname);
pqbuf->len += PQescapeString(pqbuf->data + pqbuf->len, relname, len);
appendPQExpBufferChar(pqbuf, '\'');
appendStringInfo(&buf, "tablename=%s", pqbuf->data);
destroyPQExpBuffer(pqbuf);
}
opts = rule->parreloptions;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册