Check upper bound on DB indices

Signed-off-by: Michael Buesch <m@bues.ch>