aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1258092dc8c..85055bbb95a 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -9811,31 +9811,18 @@ get_tablefunc(TableFunc *tf, deparse_context *context, bool showimplicit)
ListCell *l5;
int colnum = 0;
- l2 = list_head(tf->coltypes);
- l3 = list_head(tf->coltypmods);
- l4 = list_head(tf->colexprs);
- l5 = list_head(tf->coldefexprs);
-
appendStringInfoString(buf, " COLUMNS ");
- foreach(l1, tf->colnames)
+ forfive(l1, tf->colnames, l2, tf->coltypes, l3, tf->coltypmods,
+ l4, tf->colexprs, l5, tf->coldefexprs)
{
char *colname = strVal(lfirst(l1));
- Oid typid;
- int32 typmod;
- Node *colexpr;
- Node *coldefexpr;
- bool ordinality = tf->ordinalitycol == colnum;
+ Oid typid = lfirst_oid(l2);
+ int32 typmod = lfirst_int(l3);
+ Node *colexpr = (Node *) lfirst(l4);
+ Node *coldefexpr = (Node *) lfirst(l5);
+ bool ordinality = (tf->ordinalitycol == colnum);
bool notnull = bms_is_member(colnum, tf->notnulls);
- typid = lfirst_oid(l2);
- l2 = lnext(l2);
- typmod = lfirst_int(l3);
- l3 = lnext(l3);
- colexpr = (Node *) lfirst(l4);
- l4 = lnext(l4);
- coldefexpr = (Node *) lfirst(l5);
- l5 = lnext(l5);
-
if (colnum > 0)
appendStringInfoString(buf, ", ");
colnum++;
@@ -10349,12 +10336,11 @@ get_from_clause_coldeflist(RangeTblFunction *rtfunc,
appendStringInfoChar(buf, '(');
- /* there's no forfour(), so must chase one list the hard way */
i = 0;
- l4 = list_head(rtfunc->funccolnames);
- forthree(l1, rtfunc->funccoltypes,
- l2, rtfunc->funccoltypmods,
- l3, rtfunc->funccolcollations)
+ forfour(l1, rtfunc->funccoltypes,
+ l2, rtfunc->funccoltypmods,
+ l3, rtfunc->funccolcollations,
+ l4, rtfunc->funccolnames)
{
Oid atttypid = lfirst_oid(l1);
int32 atttypmod = lfirst_int(l2);
@@ -10378,7 +10364,6 @@ get_from_clause_coldeflist(RangeTblFunction *rtfunc,
appendStringInfo(buf, " COLLATE %s",
generate_collation_name(attcollation));
- l4 = lnext(l4);
i++;
}