Found a bug in dbms.r!
[1/1] from: g::santilli::tiscalinet::it at: 22-Apr-2002 17:58
Hello all,
just found a bug in dbms.r that was hiding probably since 1.x
days. (I wonder how come I never saw it before...) Basically it
goes into an infinite loop if you select with something like [col
> 1] and col is indexed. Anyone using dbms.r should fix it
immediately to avoid hours of head scratching trying to understand
why his program hangs. :)
To fix it change:
select-gt: make-selector [
if not integer? val [make error! reform ["Invalid row id in spec:" mold val]]
result: load db/index
forall result [if result/1 > val [break]]
return copy result
] [
tmp: load join db/index. col
if empty? tmp [return []]
tmp: skip tail tmp -2
until [
if tmp/1 <= val [break]
insert tail result tmp/2
head? tmp
]
] [
if val < pick load db/:row col [insert tail result row]
]
to:
select-gt: make-selector [
if not integer? val [make error! reform ["Invalid row id in spec:" mold val]]
result: load db/index
forall result [if result/1 > val [break]]
return copy result
] [
tmp: load join db/index. col
if empty? tmp [return []]
tmp: skip tail tmp -2
until [
if tmp/1 <= val [break]
insert tail result tmp/2
any [head? tmp (tmp: skip tmp -2 false)]
]
] [
if val < pick load db/:row col [insert tail result row]
]
(watch out for wrapping).
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r