* _bitmap_doinsert() -- insert an index tuple for a given tuple. */
| 2542 | * _bitmap_doinsert() -- insert an index tuple for a given tuple. |
| 2543 | */ |
| 2544 | void |
| 2545 | _bitmap_doinsert(Relation rel, ItemPointerData ht_ctid, Datum *attdata, |
| 2546 | bool *nulls) |
| 2547 | { |
| 2548 | uint64 tidOffset; |
| 2549 | TupleDesc tupDesc; |
| 2550 | Buffer metabuf; |
| 2551 | BMMetaPage metapage; |
| 2552 | Relation lovHeap, lovIndex; |
| 2553 | ScanKey scanKeys; |
| 2554 | IndexScanDesc scanDesc; |
| 2555 | int attno; |
| 2556 | |
| 2557 | tupDesc = RelationGetDescr(rel); |
| 2558 | if (tupDesc->natts <= 0) |
| 2559 | return ; |
| 2560 | |
| 2561 | tidOffset = BM_IPTR_TO_INT(&ht_ctid); |
| 2562 | |
| 2563 | /* insert a new bit into the corresponding bitmap using the HRL scheme */ |
| 2564 | metabuf = _bitmap_getbuf(rel, BM_METAPAGE, BM_READ); |
| 2565 | metapage = _bitmap_get_metapage_data(rel, metabuf); |
| 2566 | _bitmap_open_lov_heapandindex(rel, metapage, &lovHeap, &lovIndex, |
| 2567 | RowExclusiveLock); |
| 2568 | |
| 2569 | LockBuffer(metabuf, BUFFER_LOCK_UNLOCK); |
| 2570 | |
| 2571 | scanKeys = (ScanKey) palloc0(tupDesc->natts * sizeof(ScanKeyData)); |
| 2572 | |
| 2573 | for (attno = 0; attno < tupDesc->natts; attno++) |
| 2574 | { |
| 2575 | Oid eq_opr; |
| 2576 | RegProcedure opfuncid; |
| 2577 | ScanKey scanKey; |
| 2578 | |
| 2579 | get_sort_group_operators(TupleDescAttr(tupDesc, attno)->atttypid, |
| 2580 | false, true, false, |
| 2581 | NULL, &eq_opr, NULL, NULL); |
| 2582 | opfuncid = get_opcode(eq_opr); |
| 2583 | |
| 2584 | scanKey = (ScanKey) (((char *)scanKeys) + attno * sizeof(ScanKeyData)); |
| 2585 | |
| 2586 | ScanKeyEntryInitialize(scanKey, |
| 2587 | nulls[attno] ? SK_ISNULL : 0, |
| 2588 | attno + 1, |
| 2589 | BTEqualStrategyNumber, |
| 2590 | InvalidOid, |
| 2591 | lovIndex->rd_indcollation[attno], |
| 2592 | opfuncid, |
| 2593 | attdata[attno]); |
| 2594 | } |
| 2595 | |
| 2596 | scanDesc = index_beginscan(lovHeap, lovIndex, GetActiveSnapshot(), |
| 2597 | tupDesc->natts, 0); |
| 2598 | index_rescan(scanDesc, scanKeys, tupDesc->natts, NULL, 0); |
| 2599 | |
| 2600 | /* insert this new tuple into the bitmap index. */ |
| 2601 | inserttuple(rel, metabuf, tidOffset, ht_ctid, tupDesc, attdata, nulls, |
no test coverage detected