| Line | Hits | Source | Commit |
| 2261 |
10539 |
constructSetOpTargetlist(SetOperationStmt *op, List *ltargetlist, List *rtargetlist, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2262 |
- |
List **targetlist, const char *context, ParseState *pstate, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2263 |
- |
bool recursive) |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2264 |
- |
{ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2265 |
10539 |
ListCell *ltl; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2266 |
10539 |
ListCell *rtl; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2267 |
- |
|
- |
| 2268 |
- |
/* |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2269 |
- |
* Verify that the two children have the same number of non-junk columns, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2270 |
- |
* and determine the types of the merged output columns. |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2271 |
- |
*/ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2272 |
31497 |
if (list_length(ltargetlist) != list_length(rtargetlist)) |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2273 |
0 |
ereport(ERROR, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2274 |
- |
(errcode(ERRCODE_SYNTAX_ERROR), |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2275 |
- |
errmsg("each %s query must have the same number of columns", |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2276 |
- |
context), |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2277 |
- |
parser_errposition(pstate, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2278 |
- |
exprLocation((Node *) rtargetlist)))); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2279 |
- |
|
- |
| 2280 |
10539 |
if (targetlist) |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2281 |
3757 |
*targetlist = NIL; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2282 |
10539 |
op->colTypes = NIL; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2283 |
10539 |
op->colTypmods = NIL; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2284 |
10539 |
op->colCollations = NIL; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2285 |
10539 |
op->groupClauses = NIL; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2286 |
- |
|
- |
| 2287 |
43767 |
forboth(ltl, ltargetlist, rtl, rtargetlist) |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2288 |
- |
{ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2289 |
33249 |
TargetEntry *ltle = (TargetEntry *) lfirst(ltl); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2290 |
33249 |
TargetEntry *rtle = (TargetEntry *) lfirst(rtl); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2291 |
33249 |
Node *lcolnode = (Node *) ltle->expr; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2292 |
33249 |
Node *rcolnode = (Node *) rtle->expr; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2293 |
33249 |
Oid lcoltype = exprType(lcolnode); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2294 |
33249 |
Oid rcoltype = exprType(rcolnode); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2295 |
33249 |
Node *bestexpr; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2296 |
33249 |
int bestlocation; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2297 |
33249 |
Oid rescoltype; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2298 |
33249 |
int32 rescoltypmod; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2299 |
33249 |
Oid rescolcoll; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2300 |
- |
|
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2301 |
- |
/* select common type, same as CASE et al */ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2302 |
33249 |
rescoltype = select_common_type(pstate, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2303 |
33249 |
list_make2(lcolnode, rcolnode), |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2304 |
- |
context, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2305 |
- |
&bestexpr); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2306 |
33249 |
bestlocation = exprLocation(bestexpr); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2307 |
- |
|
- |
| 2308 |
- |
/* |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2309 |
- |
* Verify the coercions are actually possible. If not, we'd fail |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2310 |
- |
* later anyway, but we want to fail now while we have sufficient |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2311 |
- |
* context to produce an error cursor position. |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2312 |
- |
* |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2313 |
- |
* For all non-UNKNOWN-type cases, we verify coercibility but we don't |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2314 |
- |
* modify the child's expression, for fear of changing the child |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2315 |
- |
* query's semantics. |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2316 |
- |
* |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2317 |
- |
* If a child expression is an UNKNOWN-type Const or Param, we want to |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2318 |
- |
* replace it with the coerced expression. This can only happen when |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2319 |
- |
* the child is a leaf set-op node. It's safe to replace the |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2320 |
- |
* expression because if the child query's semantics depended on the |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2321 |
- |
* type of this output column, it'd have already coerced the UNKNOWN |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2322 |
- |
* to something else. We want to do this because (a) we want to |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2323 |
- |
* verify that a Const is valid for the target type, or resolve the |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2324 |
- |
* actual type of an UNKNOWN Param, and (b) we want to avoid |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2325 |
- |
* unnecessary discrepancies between the output type of the child |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2326 |
- |
* query and the resolved target type. Such a discrepancy would |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2327 |
- |
* disable optimization in the planner. |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2328 |
- |
* |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2329 |
- |
* If it's some other UNKNOWN-type node, eg a Var, we do nothing |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2330 |
- |
* (knowing that coerce_to_common_type would fail). The planner is |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2331 |
- |
* sometimes able to fold an UNKNOWN Var to a constant before it has |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2332 |
- |
* to coerce the type, so failing now would just break cases that |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2333 |
- |
* might work. |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2334 |
- |
*/ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2335 |
33249 |
if (lcoltype != UNKNOWNOID) |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2336 |
30008 |
lcolnode = coerce_to_common_type(pstate, lcolnode, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2337 |
- |
rescoltype, context); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2338 |
3241 |
else if (IsA(lcolnode, Const) || |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2339 |
- |
IsA(lcolnode, Param)) |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2340 |
- |
{ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2341 |
3241 |
lcolnode = coerce_to_common_type(pstate, lcolnode, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2342 |
- |
rescoltype, context); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2343 |
3241 |
ltle->expr = (Expr *) lcolnode; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2344 |
- |
} |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2345 |
- |
|
- |
| 2346 |
33249 |
if (rcoltype != UNKNOWNOID) |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2347 |
29534 |
rcolnode = coerce_to_common_type(pstate, rcolnode, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2348 |
- |
rescoltype, context); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2349 |
3715 |
else if (IsA(rcolnode, Const) || |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2350 |
- |
IsA(rcolnode, Param)) |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2351 |
- |
{ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2352 |
3715 |
rcolnode = coerce_to_common_type(pstate, rcolnode, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2353 |
- |
rescoltype, context); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2354 |
3712 |
rtle->expr = (Expr *) rcolnode; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2355 |
- |
} |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2356 |
- |
|
- |
| 2357 |
33246 |
rescoltypmod = select_common_typmod(pstate, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2358 |
33246 |
list_make2(lcolnode, rcolnode), |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2359 |
- |
rescoltype); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2360 |
- |
|
- |
| 2361 |
- |
/* |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2362 |
- |
* Select common collation. A common collation is required for all |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2363 |
- |
* set operators except UNION ALL; see SQL:2008 7.13 <query |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2364 |
- |
* expression> Syntax Rule 15c. (If we fail to identify a common |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2365 |
- |
* collation for a UNION ALL column, the colCollations element will be |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2366 |
- |
* set to InvalidOid, which may result in a runtime error if something |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2367 |
- |
* at a higher query level wants to use the column's collation.) |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2368 |
- |
*/ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2369 |
33246 |
rescolcoll = select_common_collation(pstate, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2370 |
33246 |
list_make2(lcolnode, rcolnode), |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2371 |
33246 |
(op->op == SETOP_UNION && op->all)); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2372 |
- |
|
- |
| 2373 |
- |
/* emit results */ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2374 |
33228 |
op->colTypes = lappend_oid(op->colTypes, rescoltype); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2375 |
33228 |
op->colTypmods = lappend_int(op->colTypmods, rescoltypmod); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2376 |
33228 |
op->colCollations = lappend_oid(op->colCollations, rescolcoll); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2377 |
- |
|
- |
| 2378 |
- |
/* |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2379 |
- |
* For all cases except UNION ALL, identify the grouping operators |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2380 |
- |
* (and, if available, sorting operators) that will be used to |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2381 |
- |
* eliminate duplicates. |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2382 |
- |
*/ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2383 |
33228 |
if (op->op != SETOP_UNION || !op->all) |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2384 |
- |
{ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2385 |
13589 |
ParseCallbackState pcbstate; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2386 |
- |
|
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2387 |
13589 |
setup_parser_errposition_callback(&pcbstate, pstate, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2388 |
- |
bestlocation); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2389 |
- |
|
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2390 |
- |
/* If it's a recursive union, we need to require hashing support. */ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2391 |
13589 |
op->groupClauses = lappend(op->groupClauses, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2392 |
13589 |
makeSortGroupClauseForSetOp(rescoltype, recursive)); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2393 |
- |
|
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2394 |
13589 |
cancel_parser_errposition_callback(&pcbstate); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2395 |
- |
} |
- |
| 2396 |
- |
|
- |
| 2397 |
- |
/* |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2398 |
- |
* Construct a dummy tlist entry to return. We use a SetToDefault |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2399 |
- |
* node for the expression, since it carries exactly the fields |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2400 |
- |
* needed, but any other expression node type would do as well. |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2401 |
- |
*/ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2402 |
33228 |
if (targetlist) |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2403 |
- |
{ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2404 |
16267 |
SetToDefault *rescolnode = makeNode(SetToDefault); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2405 |
16267 |
TargetEntry *restle; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2406 |
- |
|
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2407 |
16267 |
rescolnode->typeId = rescoltype; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2408 |
16267 |
rescolnode->typeMod = rescoltypmod; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2409 |
16267 |
rescolnode->collation = rescolcoll; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2410 |
16267 |
rescolnode->location = bestlocation; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2411 |
16267 |
restle = makeTargetEntry((Expr *) rescolnode, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2412 |
- |
0, /* no need to set resno */ |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2413 |
- |
NULL, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2414 |
- |
false); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2415 |
16267 |
*targetlist = lappend(*targetlist, restle); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2416 |
- |
} |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2417 |
- |
} |
- |
| 2418 |
- |
} |
- |