| 158 | } |
| 159 | |
| 160 | void VerbAction::mergeTo(thread_db* tdbb, jrd_tra* transaction, VerbAction* nextAction) |
| 161 | { |
| 162 | // Post bitmap of modified records and undo data to the next savepoint. |
| 163 | // |
| 164 | // Notes: |
| 165 | // |
| 166 | // If previous savepoint already touched a record, undo data must be dropped and |
| 167 | // all BLOBs it refers to should be cleaned out because under no circumstances |
| 168 | // this undo data can become an active record. |
| 169 | |
| 170 | // Merge undo records first |
| 171 | |
| 172 | if (vct_undo && vct_undo->getFirst()) |
| 173 | { |
| 174 | do |
| 175 | { |
| 176 | UndoItem& item = vct_undo->current(); |
| 177 | |
| 178 | if (item.hasData()) // this item wasn't released yet |
| 179 | { |
| 180 | const SINT64 recordNumber = item.generate(NULL, item); |
| 181 | |
| 182 | if (nextAction && !(RecordBitmap::test(nextAction->vct_records, recordNumber))) |
| 183 | { |
| 184 | if (!nextAction->vct_undo) |
| 185 | { |
| 186 | nextAction->vct_undo = |
| 187 | FB_NEW_POOL(*transaction->tra_pool) UndoItemTree(*transaction->tra_pool); |
| 188 | // We cannot just push whole current undo items list, some items still may be released |
| 189 | } |
| 190 | else |
| 191 | { |
| 192 | if (nextAction->vct_undo->locate(recordNumber)) |
| 193 | { |
| 194 | // It looks like something went wrong on previous loop and undo record |
| 195 | // was moved to next action but record bit in bitmap wasn't set |
| 196 | fb_assert(false); |
| 197 | item.clear(); |
| 198 | continue; |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | nextAction->vct_undo->add(item); |
| 203 | item.clear(); // Do not release undo data, it now belongs to next action |
| 204 | continue; |
| 205 | } |
| 206 | |
| 207 | // garbage cleanup and release |
| 208 | // because going version for sure has all index entries successfully set up (in contrast with undo) |
| 209 | // we can use lightweigth version of garbage collection without collection of full staying list |
| 210 | |
| 211 | AutoTempRecord this_ver(item.setupRecord(transaction)); |
| 212 | |
| 213 | garbageCollectIdxLite(tdbb, transaction, recordNumber, nextAction, this_ver); |
| 214 | |
| 215 | item.release(transaction); |
| 216 | } |
| 217 | } while (vct_undo->getNext()); |
no test coverage detected