Refactor select.c

Modernize it and put in sync with recent changes in
create.c/delete.c/insert.c

Signed-off-by: Thiago Farina <tfarina@chromium.org>