Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/hash/hash_page.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,15 @@ __ham_getindex_unsorted(dbc, p, key, match, indx)
break;
case H_KEYDATA:
if (t->h_compare != NULL) {
DB_INIT_DBT(pg_dbt,
HKEYDATA_DATA(hk), key->size);
if (t->h_compare(
dbp, key, &pg_dbt) != 0)
break;
/*
* Compare against the stored key at its own
* length -- as __ham_getindex_sorted does --
* and record the result: a 0 return means the
* keys are equal and the search is done.
*/
DB_INIT_DBT(pg_dbt, HKEYDATA_DATA(hk),
LEN_HKEY(dbp, p, dbp->pgsize, i));
res = t->h_compare(dbp, key, &pg_dbt);
} else if (key->size ==
LEN_HKEY(dbp, p, dbp->pgsize, i))
res = memcmp(key->data, HKEYDATA_DATA(hk),
Expand Down
21 changes: 21 additions & 0 deletions test/coverage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,27 @@ timeout, so they cannot hang:
current db, because current off-page dups are already stored as a Recno
tree (P_LRECNO/P_IRECNO), not a flat page chain. A genuine pre-3.1 fixture
is required.
- **Legacy unsorted-hash lookup with a custom comparator** —
`test/db/run_hash_unsorted_cmp.sh` builds `test/db/hash_unsorted_cmp.c`, the
regression test for issue #139. `__ham_getindex_unsorted`
(`src/hash/hash_page.c`) is the linear search over a pre-4.6
`P_HASH_UNSORTED` page; its `t->h_compare != NULL` inline-key branch was
never reached by any test, because the branch needs a legacy page **and** an
explicitly configured `DB->set_h_compare` at the same time (`test093` sets a
comparator but only over current-format sorted pages, which take
`__ham_getindex_sorted`; `run_upgrade.sh` reads legacy pages but never sets a
comparator). The branch called the comparator, dropped its result, and built
the stored-key DBT with the *search* key's length -- so an equal key was
reported absent (`DB->get` → `DB_NOTFOUND`, `DB_NOOVERWRITE` → success plus a
duplicate) and a search key that merely prefixed a stored key compared equal.
The driver manufactures its legacy fixture the same way `run_upgrade.sh`
does, without an old library or a committed blob: it creates a current-format
Hash db (small pages, inline + off-page keys), then rewrites each bucket
page's `PAGE.type` byte from `P_HASH` to `P_HASH_UNSORTED` and the metadata
version back to the 4.5.20 hash version 8 -- exactly what `__ham_getindex`
dispatches to the unsorted path. Every check runs twice, with and without the
comparator, so a failure is attributable to the comparator path and not to
the fixture.
- **Async I/O backends (os_aio)** — `test/os/run_os_aio.sh` builds
`test/os/os_aio_direct.c`, which links the internal libdb symbols and drives
the async-I/O abstraction (`src/os/os_aio.c`) and its backends
Expand Down
1 change: 1 addition & 0 deletions test/coverage/full_run3_combined.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ run_driver db_upgrade "$R/test/db/run_upgrade.sh"
run_driver os_aio "$R/test/os/run_os_aio.sh"
run_driver backup "$R/test/backup/run_backup_direct.sh"
run_driver recd_compact "$R/test/db/run_recd_compact.sh"
run_driver hash_unsorted_cmp "$R/test/db/run_hash_unsorted_cmp.sh"
log " .gcda after C drivers: $(find .libs -name '*.gcda' | wc -l)"

# COV_DEAD_REG: deadlock detector + DB_REGISTER (driver-per-test)
Expand Down
10 changes: 10 additions & 0 deletions test/coverage/run_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,16 @@ if [ "${COV_BACKUP:-1}" = 1 ]; then
else
echo "FAIL recd_handlers (rc=$?)"; tail -5 /tmp/cov-recdhandlers.log
fi
# Legacy P_HASH_UNSORTED lookup with a custom DB->set_h_compare: the
# h_compare branch of __ham_getindex_unsorted needs a pre-4.6 page AND an
# explicit comparator at the same time, which no Tcl test arranges
# (test093 sets a comparator over sorted pages; run_upgrade.sh reads legacy
# pages without one). Regression gate for issue #139.
if sh "$root/test/db/run_hash_unsorted_cmp.sh" >/tmp/cov-hashunsorted.log 2>&1; then
echo "PASS hash_unsorted_cmp"
else
echo "FAIL hash_unsorted_cmp (rc=$?)"; tail -5 /tmp/cov-hashunsorted.log
fi
echo " .gcda files after backup/compact: $(find . -name '*.gcda' | wc -l)"
fi

Expand Down
Loading
Loading