* Has the specified refname been selected FOR UPDATE/FOR SHARE? * * This is used when we have not yet done transformLockingClause, but need * to know the correct lock to take during initial opening of relations. * * Note: we pay no attention to whether it's FOR UPDATE vs FOR SHARE, * since the table-level lock is the same either way. */
| 2735 | * since the table-level lock is the same either way. |
| 2736 | */ |
| 2737 | LockingClause * |
| 2738 | getLockedRefname(ParseState *pstate, const char *refname) |
| 2739 | { |
| 2740 | ListCell *l; |
| 2741 | |
| 2742 | /* |
| 2743 | * If we are in a subquery specified as locked FOR UPDATE/SHARE from |
| 2744 | * parent level, then act as though there's a generic FOR UPDATE here. |
| 2745 | */ |
| 2746 | if (pstate->p_lockclause_from_parent) |
| 2747 | return pstate->p_lockclause_from_parent; |
| 2748 | |
| 2749 | foreach(l, pstate->p_locking_clause) |
| 2750 | { |
| 2751 | LockingClause *lc = (LockingClause *) lfirst(l); |
| 2752 | |
| 2753 | if (lc->lockedRels == NIL) |
| 2754 | { |
| 2755 | /* all tables used in query */ |
| 2756 | return lc; |
| 2757 | } |
| 2758 | else |
| 2759 | { |
| 2760 | /* just the named tables */ |
| 2761 | ListCell *l2; |
| 2762 | |
| 2763 | foreach(l2, lc->lockedRels) |
| 2764 | { |
| 2765 | RangeVar *thisrel = (RangeVar *) lfirst(l2); |
| 2766 | |
| 2767 | if (strcmp(refname, thisrel->relname) == 0) |
| 2768 | return lc; |
| 2769 | } |
| 2770 | } |
| 2771 | } |
| 2772 | |
| 2773 | return NULL; |
| 2774 | } |
| 2775 | |
| 2776 | /* |
| 2777 | * isSimplyUpdatableRelation |
no test coverage detected