* transformValuesClause - * transforms a VALUES clause that's being used as a standalone SELECT * * We build a Query containing a VALUES RTE, rather as if one had written * SELECT * FROM (VALUES ...) AS "*VALUES*" */
| 1561 | * SELECT * FROM (VALUES ...) AS "*VALUES*" |
| 1562 | */ |
| 1563 | static Query * |
| 1564 | transformValuesClause(ParseState *pstate, SelectStmt *stmt) |
| 1565 | { |
| 1566 | Query *qry = makeNode(Query); |
| 1567 | List *exprsLists = NIL; |
| 1568 | List *coltypes = NIL; |
| 1569 | List *coltypmods = NIL; |
| 1570 | List *colcollations = NIL; |
| 1571 | List **colexprs = NULL; |
| 1572 | int sublist_length = -1; |
| 1573 | bool lateral = false; |
| 1574 | ParseNamespaceItem *nsitem; |
| 1575 | ListCell *lc; |
| 1576 | ListCell *lc2; |
| 1577 | int i; |
| 1578 | |
| 1579 | qry->commandType = CMD_SELECT; |
| 1580 | |
| 1581 | /* Most SELECT stuff doesn't apply in a VALUES clause */ |
| 1582 | Assert(stmt->distinctClause == NIL); |
| 1583 | Assert(stmt->intoClause == NULL); |
| 1584 | Assert(stmt->targetList == NIL); |
| 1585 | Assert(stmt->fromClause == NIL); |
| 1586 | Assert(stmt->whereClause == NULL); |
| 1587 | Assert(stmt->groupClause == NIL); |
| 1588 | Assert(stmt->havingClause == NULL); |
| 1589 | Assert(stmt->scatterClause == NIL); |
| 1590 | Assert(stmt->op == SETOP_NONE); |
| 1591 | |
| 1592 | /* process the WITH clause independently of all else */ |
| 1593 | if (stmt->withClause) |
| 1594 | { |
| 1595 | qry->hasRecursive = stmt->withClause->recursive; |
| 1596 | qry->cteList = transformWithClause(pstate, stmt->withClause); |
| 1597 | qry->hasModifyingCTE = pstate->p_hasModifyingCTE; |
| 1598 | } |
| 1599 | |
| 1600 | /* |
| 1601 | * For each row of VALUES, transform the raw expressions. |
| 1602 | * |
| 1603 | * Note that the intermediate representation we build is column-organized |
| 1604 | * not row-organized. That simplifies the type and collation processing |
| 1605 | * below. |
| 1606 | */ |
| 1607 | foreach(lc, stmt->valuesLists) |
| 1608 | { |
| 1609 | List *sublist = (List *) lfirst(lc); |
| 1610 | |
| 1611 | /* |
| 1612 | * Do basic expression transformation (same as a ROW() expr, but here |
| 1613 | * we disallow SetToDefault) |
| 1614 | */ |
| 1615 | sublist = transformExpressionList(pstate, sublist, |
| 1616 | EXPR_KIND_VALUES, false); |
| 1617 | |
| 1618 | /* |
| 1619 | * All the sublists must be the same length, *after* transformation |
| 1620 | * (which might expand '*' into multiple items). The VALUES RTE can't |
no test coverage detected