Commits

Andrew Dunstan committed 84fc477

fix transformArrayExpr case.

  • Participants
  • Parent commits c1977ac
  • Branches rowexprs

Comments (0)

Files changed (2)

File src/backend/parser/gram.y

 				{
 					RowExpr *r = makeNode(RowExpr);
 					r->args = $1;
+					/* r->colnames  will be filled in by transformRowExpr() */
 					r->row_typeid = InvalidOid;	/* not analyzed yet */
 					r->location = @1;
 					$$ = (Node *)r;

File src/backend/parser/parse_expr.c

 					 RowExpr *lrow, RowExpr *rrow, int location);
 static Expr *make_distinct_op(ParseState *pstate, List *opname,
 				 Node *ltree, Node *rtree, int location);
-
+static List *makeDummyColnames(List * args);
 
 /*
  * transformExpr -
 	return (Node *) newa;
 }
 
+static List *
+makeDummyColnames(List * args)
+{
+	List	   *result = NIL;
+	ListCell   *i;
+	char       name[16];
+	int        fnum = 1;
+
+	name[0] = 'f';
+	foreach(i, args)
+	{
+		sprintf(name + 1, "%d", fnum++);
+		result = lappend(result, makeString(pstrdup(name)));
+	}
+	return result;
+}
+
 static Node *
 transformRowExpr(ParseState *pstate, RowExpr *r)
 {
 	/* Barring later casting, we consider the type RECORD */
 	newr->row_typeid = RECORDOID;
 	newr->row_format = COERCE_IMPLICIT_CAST;
-	newr->colnames = NIL;		/* ROW() has anonymous columns */
+	/* ROW() has anonymous columns */
+	newr->colnames = makeDummyColnames(newr->args);
 	newr->location = r->location;
 
 	return (Node *) newr;