* ExpandSingleTable() * Transforms foo.* into a list of expressions or targetlist entries. * * This handles the case where foo has been determined to be a simple * reference to an RTE, so we can just generate Vars for the expressions. * * The referenced columns are marked as requiring SELECT access. */
| 1368 | * The referenced columns are marked as requiring SELECT access. |
| 1369 | */ |
| 1370 | static List * |
| 1371 | ExpandSingleTable(ParseState *pstate, ParseNamespaceItem *nsitem, |
| 1372 | int sublevels_up, int location, bool make_target_entry) |
| 1373 | { |
| 1374 | if (make_target_entry) |
| 1375 | { |
| 1376 | /* expandNSItemAttrs handles permissions marking */ |
| 1377 | return expandNSItemAttrs(pstate, nsitem, sublevels_up, location); |
| 1378 | } |
| 1379 | else |
| 1380 | { |
| 1381 | RangeTblEntry *rte = nsitem->p_rte; |
| 1382 | List *vars; |
| 1383 | ListCell *l; |
| 1384 | |
| 1385 | vars = expandNSItemVars(nsitem, sublevels_up, location, NULL); |
| 1386 | |
| 1387 | /* |
| 1388 | * Require read access to the table. This is normally redundant with |
| 1389 | * the markVarForSelectPriv calls below, but not if the table has zero |
| 1390 | * columns. We need not do anything if the nsitem is for a join: its |
| 1391 | * component tables will have been marked ACL_SELECT when they were |
| 1392 | * added to the rangetable. (This step changes things only for the |
| 1393 | * target relation of UPDATE/DELETE, which cannot be under a join.) |
| 1394 | */ |
| 1395 | if (rte->rtekind == RTE_RELATION) |
| 1396 | rte->requiredPerms |= ACL_SELECT; |
| 1397 | |
| 1398 | /* Require read access to each column */ |
| 1399 | foreach(l, vars) |
| 1400 | { |
| 1401 | Var *var = (Var *) lfirst(l); |
| 1402 | |
| 1403 | markVarForSelectPriv(pstate, var); |
| 1404 | } |
| 1405 | |
| 1406 | return vars; |
| 1407 | } |
| 1408 | } |
| 1409 | |
| 1410 | /* |
| 1411 | * ExpandRowReference() |
no test coverage detected