| 2168 | |
| 2169 | |
| 2170 | static void expand_view_lock(thread_db* tdbb, jrd_tra* transaction, jrd_rel* relation, |
| 2171 | UCHAR lock_type, const char* option_name, RelationLockTypeMap& lockmap, const int level) |
| 2172 | { |
| 2173 | /************************************** |
| 2174 | * |
| 2175 | * e x p a n d _ v i e w _ l o c k |
| 2176 | * |
| 2177 | ************************************** |
| 2178 | * |
| 2179 | * Functional description |
| 2180 | * A view in a RESERVING will lead to all tables in the |
| 2181 | * view being locked. |
| 2182 | * Some checks only apply when the user reserved directly the table or view. |
| 2183 | * |
| 2184 | **************************************/ |
| 2185 | SET_TDBB(tdbb); |
| 2186 | |
| 2187 | if (level == 30) |
| 2188 | { |
| 2189 | ERR_post(Arg::Gds(isc_bad_tpb_content) << |
| 2190 | Arg::Gds(isc_tpb_reserv_max_recursion) << Arg::Num(30)); |
| 2191 | } |
| 2192 | |
| 2193 | const char* const relation_name = relation->rel_name.c_str(); |
| 2194 | |
| 2195 | // LCK_none < LCK_SR < LCK_PR < LCK_SW < LCK_EX |
| 2196 | UCHAR oldlock; |
| 2197 | const bool found = lockmap.get(relation->rel_id, oldlock); |
| 2198 | |
| 2199 | if (found && oldlock > lock_type) |
| 2200 | { |
| 2201 | const char* newname = get_lockname_v3(lock_type); |
| 2202 | const char* oldname = get_lockname_v3(oldlock); |
| 2203 | |
| 2204 | if (level) |
| 2205 | { |
| 2206 | lock_type = oldlock; // Preserve the old, more powerful lock. |
| 2207 | ERR_post_warning(Arg::Warning(isc_tpb_reserv_stronger_wng) << Arg::Str(relation_name) << |
| 2208 | Arg::Str(oldname) << |
| 2209 | Arg::Str(newname)); |
| 2210 | } |
| 2211 | else |
| 2212 | { |
| 2213 | ERR_post(Arg::Gds(isc_bad_tpb_content) << |
| 2214 | Arg::Gds(isc_tpb_reserv_stronger) << Arg::Str(relation_name) << |
| 2215 | Arg::Str(oldname) << |
| 2216 | Arg::Str(newname)); |
| 2217 | } |
| 2218 | } |
| 2219 | |
| 2220 | if (level == 0) |
| 2221 | { |
| 2222 | fb_assert(!relation->rel_view_rse && !relation->rel_view_contexts.getCount()); |
| 2223 | // Reject explicit attempts to take locks on virtual tables. |
| 2224 | if (relation->isVirtual()) |
| 2225 | { |
| 2226 | ERR_post(Arg::Gds(isc_bad_tpb_content) << |
| 2227 | Arg::Gds(isc_tpb_reserv_virtualtbl) << Arg::Str(relation_name)); |
no test coverage detected