about summary refs log tree commit homepage
path: root/lib/PublicInbox/Over.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:04:50 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commit95da261efcf7c15b5e522344e207a3a04a374961 (patch)
tree34616e111e84d8bbbd1d5f75f2e683e225c7cb1d /lib/PublicInbox/Over.pm
parentde4084d8f5d9765db61c446fc03b80dbb163ee1b (diff)
downloadpublic-inbox-95da261efcf7c15b5e522344e207a3a04a374961.tar.gz
Since it seems somewhat common for IMAP clients to limit
searches by sent Date: or INTERNALDATE, we can rely on
the NNTP/WWW-optimized overview DB.

For other queries, we'll have to depend on the Xapian DB.
Diffstat (limited to 'lib/PublicInbox/Over.pm')
-rw-r--r--lib/PublicInbox/Over.pm13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm
index 286fb7f6..402cbf7c 100644
--- a/lib/PublicInbox/Over.pm
+++ b/lib/PublicInbox/Over.pm
@@ -215,4 +215,17 @@ SELECT num,ts,ds,ddd FROM over WHERE num = ? LIMIT 1
         load_from_row($smsg);
 }
 
+# IMAP search
+sub uid_range {
+        my ($self, $beg, $end, $sql) = @_;
+        my $dbh = $self->connect;
+        my $q = 'SELECT num FROM over WHERE num >= ? AND num <= ?';
+
+        # This is read-only, anyways; but caller should verify it's
+        # only sending \A[0-9]+\z for ds and ts column ranges
+        $q .= $$sql if $sql;
+        $q .= ' ORDER BY num ASC LIMIT ' . DEFAULT_LIMIT;
+        $dbh->selectcol_arrayref($q, undef, $beg, $end);
+}
+
 1;