Implement name_scan.

Implement name_scan.  The implementation tries to emulate the ordering
behaviour of namecoind's name_scan, although it doesn't fully do it for
binary data.  Also, this order is not "natural" with respect to SQLite.