From: Shigeru Hanada Date: Fri, 19 Nov 2010 01:35:49 +0000 (+0900) Subject: Fix bug caused by the wrong usage of appendStringInfo(). X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=72f1aab26b46117c80dea9cfe32d88c5513dae35;p=users%2Fhanada%2Fpostgres.git Fix bug caused by the wrong usage of appendStringInfo(). --- diff --git a/contrib/postgresql_fdw/postgresql_fdw.c b/contrib/postgresql_fdw/postgresql_fdw.c index b6fd2eff97..16cfe150d9 100644 --- a/contrib/postgresql_fdw/postgresql_fdw.c +++ b/contrib/postgresql_fdw/postgresql_fdw.c @@ -254,7 +254,7 @@ deparseSelectClause(StringInfo sql, ForeignTable *table, TupleDesc tupdesc, aliasname_q = quote_identifier(aliasname); /* deparse SELECT clause */ - appendStringInfo(sql, "SELECT "); + appendStringInfoString(sql, "SELECT "); /* * TODO: omit (deparse to "NULL") columns which are not used in the @@ -302,7 +302,7 @@ deparseSelectClause(StringInfo sql, ForeignTable *table, TupleDesc tupdesc, /* if target list is composed only of system attributes, add dummy column */ if (first) - appendStringInfo(sql, "NULL"); + appendStringInfoString(sql, "NULL"); if (aliasname_q != aliasname) pfree((char *) aliasname_q); @@ -325,9 +325,6 @@ deparseFromClause(StringInfo sql, ForeignTable *table, const char *aliasname, bo /* The alias of relation is used in both SELECT clause and FROM clause. */ aliasname_q = quote_identifier(aliasname); - /* deparse FROM clause */ - appendStringInfo(sql, " FROM "); - /* * If the foreign table has generic option "nspname" and/or "relname", use * them in the foreign query. Otherwise, use local catalog names. @@ -347,7 +344,7 @@ deparseFromClause(StringInfo sql, ForeignTable *table, const char *aliasname, bo relname = get_rel_name(table->relid); nspname_q = quote_identifier(nspname); relname_q = quote_identifier(relname); - appendStringInfo(sql, "%s.%s %s", nspname_q, relname_q, aliasname_q); + appendStringInfo(sql, " FROM %s.%s %s", nspname_q, relname_q, aliasname_q); pfree(nspname); pfree(relname); if (nspname_q != nspname) @@ -452,8 +449,7 @@ deparseSql(ForeignScanState *scanstate) { Node *node; node = (Node *) make_ands_explicit(foreign_expr); - appendStringInfo(&sql, " WHERE "); - appendStringInfo(&sql, + appendStringInfo(&sql, " WHERE %s", deparse_expression(node, context, prefix, false)); /* * The contents of the list MUST NOT be free-ed because they are