* _bitmap_write_new_bitmapwords() -- write a given buffer of new bitmap words * into the end of bitmap page(s). * * If the last bitmap page does not have enough space for all these new * words, new pages will be allocated here. * * We consider a write to one bitmap page as one atomic-action WAL * record. The WAL record for the write to the last bitmap page also * includes updates on the l
| 1226 | * during WAL logic replay. |
| 1227 | */ |
| 1228 | static void |
| 1229 | _bitmap_write_new_bitmapwords(Relation rel, |
| 1230 | Buffer lovBuffer, OffsetNumber lovOffset, |
| 1231 | BMTIDBuffer* buf, bool use_wal) |
| 1232 | { |
| 1233 | Page lovPage; |
| 1234 | BMLOVItem lovItem; |
| 1235 | bool first_page_needs_init = false; |
| 1236 | List *perpage_buffers = NIL; |
| 1237 | List *perpage_xlrecs = NIL; |
| 1238 | ListCell *lcb; |
| 1239 | |
| 1240 | lovPage = BufferGetPage(lovBuffer); |
| 1241 | lovItem = (BMLOVItem) PageGetItem(lovPage, |
| 1242 | PageGetItemId(lovPage, lovOffset)); |
| 1243 | |
| 1244 | /* |
| 1245 | * Write changes to bitmap pages, if needed. (We might get away by |
| 1246 | * updating just the last words stored on the LOV item.) |
| 1247 | */ |
| 1248 | if (buf->curword > 0) |
| 1249 | { |
| 1250 | ListCell *lcp; |
| 1251 | BlockNumber first_blkno; |
| 1252 | BlockNumber last_blkno; |
| 1253 | List *perpage_tmppages = NIL; |
| 1254 | bool is_first; |
| 1255 | ListCell *buffer_cell; |
| 1256 | int start_wordno; |
| 1257 | |
| 1258 | /* |
| 1259 | * Write bitmap words, one page at a time, allocating new pages as |
| 1260 | * required. |
| 1261 | */ |
| 1262 | is_first = true; |
| 1263 | start_wordno = 0; |
| 1264 | do |
| 1265 | { |
| 1266 | Buffer bitmapBuffer; |
| 1267 | bool bitmapBufferNeedsInit = false; |
| 1268 | Page bitmapPage; |
| 1269 | BMBitmapOpaque bitmapPageOpaque; |
| 1270 | uint32 numFreeWords; |
| 1271 | uint32 words_written; |
| 1272 | xl_bm_bitmapwords_perpage *xlrec_perpage; |
| 1273 | Page tmppage = NULL; |
| 1274 | |
| 1275 | if (is_first && lovItem->bm_lov_head != InvalidBlockNumber) |
| 1276 | { |
| 1277 | bitmapBuffer = _bitmap_getbuf(rel, lovItem->bm_lov_tail, BM_WRITE); |
| 1278 | |
| 1279 | /* Append to an existing LOV page as much as fits */ |
| 1280 | bitmapPage = BufferGetPage(bitmapBuffer); |
| 1281 | bitmapPageOpaque = |
| 1282 | (BMBitmapOpaque) PageGetSpecialPointer(bitmapPage); |
| 1283 | |
| 1284 | numFreeWords = BM_NUM_OF_HRL_WORDS_PER_PAGE - |
| 1285 | bitmapPageOpaque->bm_hrl_words_used; |
no test coverage detected