diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/nodes/outfuncs.c | 8 | ||||
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 11 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 9573a9bb0e6..e686a6c199d 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -2505,8 +2505,14 @@ _outValue(StringInfo str, const Value *value) appendStringInfoString(str, value->val.str); break; case T_String: + + /* + * We use _outToken to provide escaping of the string's content, + * but we don't want it to do anything with an empty string. + */ appendStringInfoChar(str, '"'); - _outToken(str, value->val.str); + if (value->val.str[0] != '\0') + _outToken(str, value->val.str); appendStringInfoChar(str, '"'); break; case T_BitString: diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 0781ac826b3..7237e5de839 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3086,7 +3086,16 @@ set_relation_column_names(deparse_namespace *dpns, RangeTblEntry *rte, i = 0; foreach(lc, rte->eref->colnames) { - real_colnames[i] = strVal(lfirst(lc)); + /* + * If the column name shown in eref is an empty string, then it's + * a column that was dropped at the time of parsing the query, so + * treat it as dropped. + */ + char *cname = strVal(lfirst(lc)); + + if (cname[0] == '\0') + cname = NULL; + real_colnames[i] = cname; i++; } } |