| 2178 | |
| 2179 | |
| 2180 | void blb::delete_blob(thread_db* tdbb, ULONG prior_page) |
| 2181 | { |
| 2182 | /************************************** |
| 2183 | * |
| 2184 | * d e l e t e _ b l o b |
| 2185 | * |
| 2186 | ************************************** |
| 2187 | * |
| 2188 | * Functional description |
| 2189 | * Delete all disk storage associated with blob. This can be used |
| 2190 | * to either abort a temporary blob or get rid of an unwanted and |
| 2191 | * unloved permanent blob. The routine deletes only blob page -- |
| 2192 | * somebody else will have to worry about the blob root. |
| 2193 | * |
| 2194 | **************************************/ |
| 2195 | SET_TDBB(tdbb); |
| 2196 | Database* const dbb = tdbb->getDatabase(); |
| 2197 | CHECK_DBB(dbb); |
| 2198 | |
| 2199 | const USHORT pageSpaceID = blb_pg_space_id; |
| 2200 | |
| 2201 | if (dbb->readOnly()) |
| 2202 | { |
| 2203 | const USHORT tempSpaceID = dbb->dbb_page_manager.getTempPageSpaceID(tdbb); |
| 2204 | |
| 2205 | if (pageSpaceID != tempSpaceID) |
| 2206 | { |
| 2207 | ERR_post(Arg::Gds(isc_read_only_database)); |
| 2208 | } |
| 2209 | } |
| 2210 | |
| 2211 | // Level 0 blobs don't need cleanup |
| 2212 | |
| 2213 | if (blb_level == 0) |
| 2214 | return; |
| 2215 | |
| 2216 | const PageNumber prior(pageSpaceID, prior_page); |
| 2217 | |
| 2218 | // Level 1 blobs just need the root page level released |
| 2219 | |
| 2220 | vcl::iterator ptr = blb_pages->begin(); |
| 2221 | const vcl::iterator end = blb_pages->end(); |
| 2222 | |
| 2223 | if (blb_level == 1) |
| 2224 | { |
| 2225 | for (; ptr < end; ++ptr) |
| 2226 | { |
| 2227 | if (*ptr) { |
| 2228 | PAG_release_page(tdbb, PageNumber(pageSpaceID, *ptr), prior); |
| 2229 | } |
| 2230 | } |
| 2231 | return; |
| 2232 | } |
| 2233 | |
| 2234 | // Level 2 blobs need a little more work to keep the page precedence |
| 2235 | // in order. The basic problem is that the pointer page has to be |
| 2236 | // released before the data pages that it points to. Sigh. |
| 2237 |
no test coverage detected