+ my ($self, @pfx) = @_;
+ my $sql = 'SELECT k FROM kv';
+ if (defined $pfx[0]) {
+ $sql .= ' WHERE k LIKE ? ESCAPE ?';
+ my $anywhere = !!$pfx[1];
+ $pfx[1] = '\\';
+ $pfx[0] =~ s/([%_\\])/\\$1/g; # glob chars
+ $pfx[0] .= '%';
+ substr($pfx[0], 0, 0, '%') if $anywhere;
+ } else {
+ @pfx = (); # [0] may've been undef
+ }
+ my $sth = $self->dbh->prepare($sql);
+ if (@pfx) {
+ $sth->bind_param(1, $pfx[0], SQL_BLOB);
+ $sth->bind_param(2, $pfx[1]);
+ }