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

Function coerceSetOpTypes

src/backend/parser/analyze.c:2477–2718  ·  view source on GitHub ↗

* Label every SetOperationStmt in the tree with the given datatypes. */

Source from the content-addressed store, hash-verified

2475 * Label every SetOperationStmt in the tree with the given datatypes.
2476 */
2477static void
2478coerceSetOpTypes(ParseState *pstate, Node *sop,
2479 List *preselected_coltypes, List *preselected_coltypmods,
2480 List **targetlist)
2481{
2482 if (IsA(sop, RangeTblRef))
2483 {
2484 RangeTblEntry *rte = rt_fetch((((RangeTblRef *) sop)->rtindex), pstate->p_rtable);
2485 Query *selectQuery = rte->subquery;
2486 ListCell *tl;
2487
2488 /*
2489 * Extract a list of the non-junk TLEs for upper-level processing.
2490 * This is the same we did in the first pass, in
2491 * transformSetOperationTree_internal().
2492 */
2493 if (targetlist)
2494 {
2495 *targetlist = NIL;
2496 foreach(tl, selectQuery->targetList)
2497 {
2498 TargetEntry *tle = (TargetEntry *) lfirst(tl);
2499
2500 if (!tle->resjunk)
2501 *targetlist = lappend(*targetlist, tle);
2502 }
2503 }
2504 return;
2505 }
2506 else
2507 {
2508 SetOperationStmt *op = (SetOperationStmt *) sop;
2509 List *ltargetlist;
2510 List *rtargetlist;
2511 ListCell *ltl;
2512 ListCell *rtl;
2513 ListCell *pct;
2514 ListCell *pcm;
2515 const char *context;
2516 bool recursive = (pstate->p_parent_cte &&
2517 pstate->p_parent_cte->cterecursive);
2518
2519 Assert(IsA(op, SetOperationStmt));
2520
2521 context = (op->op == SETOP_UNION ? "UNION" :
2522 op->op == SETOP_INTERSECT ? "INTERSECT" :
2523 "EXCEPT");
2524
2525 /* Recurse to determine the children's types first */
2526 coerceSetOpTypes(pstate, op->larg,
2527 preselected_coltypes, preselected_coltypmods,
2528 &ltargetlist);
2529
2530 coerceSetOpTypes(pstate, op->rarg,
2531 preselected_coltypes, preselected_coltypmods,
2532 &rtargetlist);
2533
2534 /*

Callers 2

Calls 15

lappendFunction · 0.85
list_lengthFunction · 0.85
parser_errpositionFunction · 0.85
exprLocationFunction · 0.85
list_headFunction · 0.85
forbothFunction · 0.85
exprTypeFunction · 0.85
exprTypmodFunction · 0.85
select_common_typeFunction · 0.85
coerce_to_common_typeFunction · 0.85
select_common_typmodFunction · 0.85
select_common_collationFunction · 0.85

Tested by

no test coverage detected