transformValuesClause(ParseState *pstate, SelectStmt *stmt)
{
Query *qry = makeNode(Query);
- List *exprsLists;
+ List *exprsLists = NIL;
List *coltypes = NIL;
List *coltypmods = NIL;
List *colcollations = NIL;
/* Release sub-list's cells to save memory */
list_free(sublist);
+
+ /* Prepare an exprsLists element for this row */
+ exprsLists = lappend(exprsLists, NIL);
}
/*
/*
* Finally, rearrange the coerced expressions into row-organized lists.
*/
- exprsLists = NIL;
- foreach(lc, colexprs[0])
- {
- Node *col = (Node *) lfirst(lc);
- List *sublist;
-
- sublist = list_make1(col);
- exprsLists = lappend(exprsLists, sublist);
- }
- list_free(colexprs[0]);
- for (i = 1; i < sublist_length; i++)
+ for (i = 0; i < sublist_length; i++)
{
forboth(lc, colexprs[i], lc2, exprsLists)
{
List *sublist = lfirst(lc2);
sublist = lappend(sublist, col);
+ lfirst(lc2) = sublist;
}
list_free(colexprs[i]);
}
4567890123456789 | -4567890123456789
(9 rows)
+-- corner case: VALUES with no columns
+CREATE TEMP TABLE nocols();
+INSERT INTO nocols DEFAULT VALUES;
+SELECT * FROM nocols n, LATERAL (VALUES(n.*)) v;
+--
+(1 row)
+
--
-- Test ORDER BY options
--
UNION ALL
TABLE int8_tbl;
+-- corner case: VALUES with no columns
+CREATE TEMP TABLE nocols();
+INSERT INTO nocols DEFAULT VALUES;
+SELECT * FROM nocols n, LATERAL (VALUES(n.*)) v;
+
--
-- Test ORDER BY options
--