8000 Enable btree duplicate key functionality by elfman2 · Pull Request #3187 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

Enable btree duplicate key functionality #3187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

elfman2
Copy link
@elfman2 elfman2 commented Jul 1, 2017

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

Added a flag definition in modbtree
Added a test
modified btree.rst to describe duplicate key

The test actually triggers a coredump due to berkeleydb bt_delete design error
The issue is reported pfalcon/berkeley-db-1.xx#1

The correction will be provided in the next commit
@pfalcon
Copy link
Contributor
pfalcon commented Jul 27, 2017

Thanks for the patch. The idea of btree module is that it implements a persistent Python dictionary. Python dictionaries don't support duplicate keys, so adding such feature to btree module is of very low priority.

@pfalcon pfalcon changed the title Enable btree duplicate key functionnality Enable btree duplicate key functionality Oct 28, 2017
tannewt added a commit to tannewt/circuitpython that referenced this pull request Aug 1, 2020
@dpgeorge
Copy link
Member
dpgeorge commented May 4, 2021

I'll clo 7751 se this because the fix to berkeley-db has not been merged upstream and this PR does not work without it.

If there's interest in making this work then we would need to fork berkeley-db to fix it.

@dpgeorge dpgeorge closed this May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0