MCPcopy Create free account
hub / github.com/apache/cloudberry / transformSelectStmt

Function transformSelectStmt

src/backend/parser/analyze.c:1404–1554  ·  view source on GitHub ↗

* transformSelectStmt - * transforms a Select Statement * * Note: this covers only cases with no set operations and no VALUES lists; * see below for the other cases. */

Source from the content-addressed store, hash-verified

1402 * see below for the other cases.
1403 */
1404static Query *
1405transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
1406{
1407 Query *qry = makeNode(Query);
1408 Node *qual;
1409 ListCell *l;
1410
1411 qry->commandType = CMD_SELECT;
1412
1413 /* process the WITH clause independently of all else */
1414 if (stmt->withClause)
1415 {
1416 qry->hasRecursive = stmt->withClause->recursive;
1417 qry->cteList = transformWithClause(pstate, stmt->withClause);
1418 qry->hasModifyingCTE = pstate->p_hasModifyingCTE;
1419 }
1420
1421 /* Complain if we get called from someplace where INTO is not allowed */
1422 if (stmt->intoClause)
1423 ereport(ERROR,
1424 (errcode(ERRCODE_SYNTAX_ERROR),
1425 errmsg("SELECT ... INTO is not allowed here"),
1426 parser_errposition(pstate,
1427 exprLocation((Node *) stmt->intoClause))));
1428
1429 /* make FOR UPDATE/FOR SHARE info available to addRangeTableEntry */
1430 pstate->p_locking_clause = stmt->lockingClause;
1431
1432 /* make WINDOW info available for window functions, too */
1433 pstate->p_windowdefs = stmt->windowClause;
1434
1435 /* process the FROM clause */
1436 transformFromClause(pstate, stmt->fromClause);
1437
1438 /* transform targetlist */
1439 qry->targetList = transformTargetList(pstate, stmt->targetList,
1440 EXPR_KIND_SELECT_TARGET);
1441
1442 /* mark column origins */
1443 markTargetListOrigins(pstate, qry->targetList);
1444
1445 /* transform WHERE */
1446 qual = transformWhereClause(pstate, stmt->whereClause,
1447 EXPR_KIND_WHERE, "WHERE");
1448
1449 /* initial processing of HAVING clause is much like WHERE clause */
1450 qry->havingQual = transformWhereClause(pstate, stmt->havingClause,
1451 EXPR_KIND_HAVING, "HAVING");
1452
1453 /*
1454 * Transform sorting/grouping stuff. Do ORDER BY first because both
1455 * transformGroupClause and transformDistinctClause need the results. Note
1456 * that these functions can also change the targetList, so it's passed to
1457 * them by reference.
1458 */
1459 qry->sortClause = transformSortClause(pstate,
1460 stmt->sortClause,
1461 &qry->targetList,

Callers 1

transformStmtFunction · 0.85

Calls 15

transformWithClauseFunction · 0.85
parser_errpositionFunction · 0.85
exprLocationFunction · 0.85
transformFromClauseFunction · 0.85
transformTargetListFunction · 0.85
markTargetListOriginsFunction · 0.85
transformWhereClauseFunction · 0.85
transformSortClauseFunction · 0.85
transformGroupClauseFunction · 0.85
transformScatterClauseFunction · 0.85
transformDistinctClauseFunction · 0.85

Tested by

no test coverage detected