| 265 | } |
| 266 | |
| 267 | bool init(thread_db* tdbb) |
| 268 | { |
| 269 | FbStatusVector* status = tdbb->tdbb_status_vector; |
| 270 | |
| 271 | Attachment* att = NULL; |
| 272 | |
| 273 | if (m_ownAttach && !m_attStable.hasData()) |
| 274 | m_attStable = WorkerAttachment::getAttachment(status, getSweepTask()->m_dbb); |
| 275 | |
| 276 | if (m_attStable) |
| 277 | att = m_attStable->getHandle(); |
| 278 | |
| 279 | if (!att) |
| 280 | { |
| 281 | Arg::Gds(isc_bad_db_handle).copyTo(status); |
| 282 | return false; |
| 283 | } |
| 284 | |
| 285 | tdbb->setDatabase(att->att_database); |
| 286 | tdbb->setAttachment(att); |
| 287 | |
| 288 | if (m_ownAttach && !m_tra) |
| 289 | { |
| 290 | const UCHAR sweep_tpb[] = |
| 291 | { |
| 292 | isc_tpb_version1, isc_tpb_read, |
| 293 | isc_tpb_read_committed, isc_tpb_rec_version |
| 294 | }; |
| 295 | |
| 296 | try |
| 297 | { |
| 298 | WorkerContextHolder holder(tdbb, FB_FUNCTION); |
| 299 | m_tra = TRA_start(tdbb, sizeof(sweep_tpb), sweep_tpb); |
| 300 | DPM_scan_pages(tdbb); |
| 301 | } |
| 302 | catch(const Exception& ex) |
| 303 | { |
| 304 | ex.stuffException(tdbb->tdbb_status_vector); |
| 305 | return false; |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | tdbb->setTransaction(m_tra); |
| 310 | tdbb->tdbb_flags |= TDBB_sweeper; |
| 311 | |
| 312 | return true; |
| 313 | } |
| 314 | |
| 315 | bool m_inuse; |
| 316 | bool m_ownAttach; |
no test coverage detected