* ExpandAllTables() * Transforms '*' (in the target list) into a list of targetlist entries. * * tlist entries are generated for each relation visible for unqualified * column name access. We do not consider qualified-name-only entries because * that would include input tables of aliasless JOINs, NEW/OLD pseudo-entries, * etc. * * The referenced relations/columns are marked as requiring
| 1290 | * The referenced relations/columns are marked as requiring SELECT access. |
| 1291 | */ |
| 1292 | static List * |
| 1293 | ExpandAllTables(ParseState *pstate, int location) |
| 1294 | { |
| 1295 | List *target = NIL; |
| 1296 | bool found_table = false; |
| 1297 | ListCell *l; |
| 1298 | |
| 1299 | foreach(l, pstate->p_namespace) |
| 1300 | { |
| 1301 | ParseNamespaceItem *nsitem = (ParseNamespaceItem *) lfirst(l); |
| 1302 | |
| 1303 | /* Ignore table-only items */ |
| 1304 | if (!nsitem->p_cols_visible) |
| 1305 | continue; |
| 1306 | /* Should not have any lateral-only items when parsing targetlist */ |
| 1307 | Assert(!nsitem->p_lateral_only); |
| 1308 | /* Remember we found a p_cols_visible item */ |
| 1309 | found_table = true; |
| 1310 | |
| 1311 | target = list_concat(target, |
| 1312 | expandNSItemAttrs(pstate, |
| 1313 | nsitem, |
| 1314 | 0, |
| 1315 | location)); |
| 1316 | } |
| 1317 | |
| 1318 | /* |
| 1319 | * Check for "SELECT *;". We do it this way, rather than checking for |
| 1320 | * target == NIL, because we want to allow SELECT * FROM a zero_column |
| 1321 | * table. |
| 1322 | */ |
| 1323 | if (!found_table) |
| 1324 | ereport(ERROR, |
| 1325 | (errcode(ERRCODE_SYNTAX_ERROR), |
| 1326 | errmsg("SELECT * with no tables specified is not valid"), |
| 1327 | parser_errposition(pstate, location))); |
| 1328 | |
| 1329 | return target; |
| 1330 | } |
| 1331 | |
| 1332 | /* |
| 1333 | * ExpandIndirectionStar() |
no test coverage detected