* Given an RT index and nesting depth, find the corresponding * ParseNamespaceItem (there must be one). */
| 496 | * ParseNamespaceItem (there must be one). |
| 497 | */ |
| 498 | ParseNamespaceItem * |
| 499 | GetNSItemByRangeTablePosn(ParseState *pstate, |
| 500 | int varno, |
| 501 | int sublevels_up) |
| 502 | { |
| 503 | ListCell *lc; |
| 504 | |
| 505 | while (sublevels_up-- > 0) |
| 506 | { |
| 507 | pstate = pstate->parentParseState; |
| 508 | Assert(pstate != NULL); |
| 509 | } |
| 510 | foreach(lc, pstate->p_namespace) |
| 511 | { |
| 512 | ParseNamespaceItem *nsitem = (ParseNamespaceItem *) lfirst(lc); |
| 513 | |
| 514 | if (nsitem->p_rtindex == varno) |
| 515 | return nsitem; |
| 516 | } |
| 517 | elog(ERROR, "nsitem not found (internal error)"); |
| 518 | return NULL; /* keep compiler quiet */ |
| 519 | } |
| 520 | |
| 521 | /* |
| 522 | * Given an RT index and nesting depth, find the corresponding RTE. |
no test coverage detected