* updatesetbit_inpage() -- update the given bit to 1 in a given * bitmap page. * * The argument 'firstTidNumber' indicates the first tid location of * the bits stored in this page. This is necessary for locating the bit * of 'tidnum'. * * This update may generate new words that cause this page to overflow. * In this case, we will first check the next bitmap page have enough * space for th
| 621 | * a new bitmap page is created. |
| 622 | */ |
| 623 | static void |
| 624 | updatesetbit_inpage(Relation rel, uint64 tidnum, |
| 625 | Buffer lovBuffer, OffsetNumber lovOffset, |
| 626 | Buffer bitmapBuffer, uint64 firstTidNumber, |
| 627 | bool use_wal) |
| 628 | { |
| 629 | Page bitmapPage; |
| 630 | BMBitmapOpaque bitmapOpaque; |
| 631 | BMBitmap bitmap; |
| 632 | Buffer nextBuffer; |
| 633 | Page nextPage; |
| 634 | BMBitmapOpaque nextOpaque; |
| 635 | BMBitmap nextBitmap; |
| 636 | |
| 637 | uint64 bitNo = 0; |
| 638 | uint32 wordNo; |
| 639 | uint32 free_words; |
| 640 | BM_HRL_WORD word = 0; |
| 641 | bool found = false; |
| 642 | |
| 643 | BMTIDBuffer words; |
| 644 | BMTIDBuffer new_words; |
| 645 | BMTIDBuffer words_left; |
| 646 | |
| 647 | bool new_page; |
| 648 | bool new_lastpage; |
| 649 | int word_no; |
| 650 | |
| 651 | bitmapPage = BufferGetPage(bitmapBuffer); |
| 652 | bitmapOpaque = (BMBitmapOpaque)PageGetSpecialPointer(bitmapPage); |
| 653 | |
| 654 | bitmap = (BMBitmap) PageGetContentsMaxAligned(bitmapPage); |
| 655 | bitNo = 0; |
| 656 | |
| 657 | if (Debug_bitmap_print_insert) |
| 658 | elog(LOG, "Bitmap Insert: updating a set bit in bitmap block %d, " |
| 659 | "lovBlock=%d, lovOffset=%d" |
| 660 | ", firstTidNumber=" INT64_FORMAT |
| 661 | ", bm_last_tid_location=" INT64_FORMAT |
| 662 | ", tidnum=" INT64_FORMAT |
| 663 | ", idxrelid=%u", |
| 664 | BufferGetBlockNumber(bitmapBuffer), |
| 665 | BufferGetBlockNumber(lovBuffer), |
| 666 | lovOffset, |
| 667 | firstTidNumber, |
| 668 | bitmapOpaque->bm_last_tid_location, |
| 669 | tidnum, |
| 670 | RelationGetRelid(rel)); |
| 671 | |
| 672 | /* Find the word that contains the bit of tidnum. */ |
| 673 | for (wordNo = 0; wordNo < bitmapOpaque->bm_hrl_words_used; wordNo++) |
| 674 | { |
| 675 | word = bitmap->cwords[wordNo]; |
| 676 | if (IS_FILL_WORD(bitmap->hwords, wordNo)) |
| 677 | bitNo += FILL_LENGTH(word) * BM_HRL_WORD_SIZE; |
| 678 | else |
| 679 | bitNo += BM_HRL_WORD_SIZE; |
| 680 |
no test coverage detected