Enable btree duplicate key functionality #3187
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added a flag definition in modbtree
Added a test tests/extmod/btree_dup.py
modified btree.rst to describe duplicate key
The test actually triggers a coredump due to berkeleydb bt_delete design error (see gdb backtrace)
The issue and correction patch is reported pfalcon/berkeley-db-1.xx#1
The correction will be provided in the next commit.
The dbm class used in the test is a candidate to be in dbm module in micropython-lib
Here is the gdb backtrace
gdb micropython
set args ../tests/extmod/btree_dup.py
run
bt
#0 0x00007ffff7173fff in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff716e3be in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x0000000000458622 in __bt_dleaf (t=0x694040, key=0x7fffffffd520,
h=0x6954b0, index=0) at ../lib/berkeley-db-1.xx/btree/bt_delete.c:504
#3 0x0000000000457f3f in __bt_bdelete (t=0x694040, key=0x7fffffffd520)
at ../lib/berkeley-db-1.xx/btree/bt_delete.c:317
#4 0x00000000004576d0 in _bt_delete (dbp=0x6942d0, key=0x7fffffffd520,
flags=0) at ../lib/berkeley-db-1.xx/btree/bt_delete.c:89
#5 0x0000000000456222 in btree_subscr (self_in=0x7ffff6f918e0,
index=0x7ffff6f91c40, value=0x0) at ../extmod/modbtree.c:258
#6 0x0000000000428ae3 in mp_obj_subscr (base=0x7ffff6f918e0,
index=0x7ffff6f91c40, value=0x0) at ../py/obj.c:448
#7 0x0000000000445504 in mp_execute_bytecode (code_state=0x7fffffffd650,
inject_exc=0x0) at ../py/vm.c:473
#8 0x000000000042e871 in fun_bc_call (self_in=0x7ffff6ee7880, n_args=2,
n_kw=0, args=0x7fffffffd7d0) at ../py/objfun.c:269
#9 0x00000000004245f6 in mp_call_function_n_kw (fun_in=0x7ffff6ee7880,
n_args=2, n_kw=0, args=0x7fffffffd7d0) at ../py/runtime.c:600
#10 0x000000000043cd48 in instance_subscr (self_in=0x7ffff6f8c3a0,
index=0x7ffff6f91a00, value=0x0) at ../py/objtype.c:720
#11 0x0000000000428ae3 in mp_obj_subscr (base=0x7ffff6f8c3a0,
index=0x7ffff6f91a00, value=0x0) at ../py/obj.c:448
#12 0x0000000000445504 in mp_execute_bytecode (code_state=0x7ffff6f8c300,
---Type to continue, or q to quit---
inject_exc=0x0) at ../py/vm.c:473
#13 0x000000000042e871 in fun_bc_call (self_in=0x7ffff6ee7660, n_args=0,
n_kw=0, args=0x7fffffffdb00) at ../py/objfun.c:269
#14 0x00000000004245f6 in mp_call_function_n_kw (fun_in=0x7ffff6ee7660,
n_args=0, n_kw=0, args=0x 8000 7fffffffdb00) at ../py/runtime.c:600
#15 0x0000000000445a96 in mp_execute_bytecode (code_state=0x7fffffffdad0,
inject_exc=0x0) at ../py/vm.c:941
#16 0x000000000042e871 in fun_bc_call (self_in=0x7ffff6ee7580, n_args=0,
n_kw=0, args=0x0) at ../py/objfun.c:269
#17 0x00000000004245f6 in mp_call_function_n_kw (fun_in=0x7ffff6ee7580,
n_args=0, n_kw=0, args=0x0) at ../py/runtime.c:600
#18 0x0000000000424533 in mp_call_function_0 (fun=0x7ffff6ee7580)
at ../py/runtime.c:574
#19 0x00000000004524e3 in execute_from_lexer (source_kind=3,
source=0x7fffffffe2df, input_kind=MP_PARSE_FILE_INPUT, is_repl=false)
at main.c:144
#20 0x0000000000452743 in do_file (
file=0x7fffffffe2df "../tests/extmod/btree_dup.py") at main.c:296
#21 0x000000000045351b in main (argc=2, argv=0x7fffffffdf68) at main.c:612
#22 0x0000000000452b2e in main (argc=2, argv=0x7fffffffdf68) at main.c:418