user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] search: use "z:" instead of "bytes:" prefix
Date: Thu,  4 Mar 2021 19:10:58 -0800	[thread overview]
Message-ID: <20210305031058.31851-1-e@80x24.org> (raw)

So far, searching by size has never been publicly documented,
and IMHO, of questionable utility.  In any case, "z:" is what
mairix(1) uses, so it may be familiar to existing mairix users
(I've never used this prefix myself).

So far, this prefix is only used internally in tests and in
auto-translated queries from IMAP; thus this incompatible change
is unlikely to affect anyone.
---
 lib/PublicInbox/IMAPsearchqp.pm | 6 +++---
 lib/PublicInbox/LeiXSearch.pm   | 2 +-
 lib/PublicInbox/Search.pm       | 2 +-
 t/lei-externals.t               | 2 +-
 t/lei-import-imap.t             | 4 ++--
 t/lei-import-nntp.t             | 4 ++--
 xt/lei-sigpipe.t                | 2 +-
 7 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/lib/PublicInbox/IMAPsearchqp.pm b/lib/PublicInbox/IMAPsearchqp.pm
index 2fb92bb8..9f0c1205 100644
--- a/lib/PublicInbox/IMAPsearchqp.pm
+++ b/lib/PublicInbox/IMAPsearchqp.pm
@@ -165,7 +165,7 @@ sub msn_set {
 # things that should not match
 sub impossible {
 	my ($self) = @_;
-	push @{$self->{xap}}, 'bytes:..0';
+	push @{$self->{xap}}, 'z:..0';
 	my $sql = $self->{sql} or return 1;
 	$$sql .= ' AND num < 0';
 }
@@ -217,8 +217,8 @@ BEFORE_date : 'BEFORE' date { $q->BEFORE(\%item) }
 
 MSN_set : sequence_set { $q->msn_set($item{sequence_set}) }
 UID_set : "UID" sequence_set { $q->uid_set($item{sequence_set}) }
-LARGER_number : "LARGER" number { $q->xap_only("bytes:$item{number}..") }
-SMALLER_number : "SMALLER" number { $q->xap_only("bytes:..$item{number}") }
+LARGER_number : "LARGER" number { $q->xap_only("z:$item{number}..") }
+SMALLER_number : "SMALLER" number { $q->xap_only("z:..$item{number}") }
 
 DELETED : "DELETED" { $q->impossible }
 OLD : "OLD" { $q->impossible }
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index 059aa284..3270b420 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -92,7 +92,7 @@ sub recent {
 	my ($self, $qstr, $opt) = @_;
 	$opt //= {};
 	$opt->{relevance} //= -2;
-	$self->mset($qstr //= 'bytes:1..', $opt);
+	$self->mset($qstr //= 'z:1..', $opt);
 }
 
 sub over {}
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index c5a1bd69..209969c5 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -481,7 +481,7 @@ sub qparse_new ($) {
 	$cb->($qp, $NVRP->new(DT, 'dt:'));
 
 	# for IMAP, undocumented for WWW and may be split off go away
-	$cb->($qp, $NVRP->new(BYTES, 'bytes:'));
+	$cb->($qp, $NVRP->new(BYTES, 'z:'));
 	$cb->($qp, $NVRP->new(TS, 'rt:'));
 	$cb->($qp, $NVRP->new(UID, 'uid:'));
 
diff --git a/t/lei-externals.t b/t/lei-externals.t
index b78b5580..29667640 100644
--- a/t/lei-externals.t
+++ b/t/lei-externals.t
@@ -40,7 +40,7 @@ SKIP: {
 		pipe(my ($r, $w)) or BAIL_OUT $!;
 		open my $err, '+>', undef or BAIL_OUT $!;
 		my $opt = { run_mode => 0, 1 => $w, 2 => $err };
-		my $cmd = [qw(lei q -qt), @$out, 'bytes:1..'];
+		my $cmd = [qw(lei q -qt), @$out, 'z:1..'];
 		my $tp = start_script($cmd, undef, $opt);
 		close $w;
 		sysread($r, my $buf, 1);
diff --git a/t/lei-import-imap.t b/t/lei-import-imap.t
index a6ba805f..15a355ab 100644
--- a/t/lei-import-imap.t
+++ b/t/lei-import-imap.t
@@ -13,11 +13,11 @@ my $td = start_script($cmd, $env, { 3 => $sock }) or BAIL_OUT("-imapd: $?");
 my $host_port = tcp_host_port($sock);
 undef $sock;
 test_lei({ tmpdir => $tmpdir }, sub {
-	lei_ok(qw(q bytes:1..));
+	lei_ok(qw(q z:1..));
 	my $out = json_utf8->decode($lei_out);
 	is_deeply($out, [ undef ], 'nothing imported, yet');
 	lei_ok('import', "imap://$host_port/t.v2.0");
-	lei_ok(qw(q bytes:1..));
+	lei_ok(qw(q z:1..));
 	$out = json_utf8->decode($lei_out);
 	ok(scalar(@$out) > 1, 'got imported messages');
 	is(pop @$out, undef, 'trailing JSON null element was null');
diff --git a/t/lei-import-nntp.t b/t/lei-import-nntp.t
index 3fb78fbc..1fc6dbad 100644
--- a/t/lei-import-nntp.t
+++ b/t/lei-import-nntp.t
@@ -13,12 +13,12 @@ my $td = start_script($cmd, $env, { 3 => $sock }) or BAIL_OUT("-nntpd $?");
 my $host_port = tcp_host_port($sock);
 undef $sock;
 test_lei({ tmpdir => $tmpdir }, sub {
-	lei_ok(qw(q bytes:1..));
+	lei_ok(qw(q z:1..));
 	my $out = json_utf8->decode($lei_out);
 	is_deeply($out, [ undef ], 'nothing imported, yet');
 	lei_ok('import', "nntp://$host_port/t.v2");
 	diag $lei_err;
-	lei_ok(qw(q bytes:1..));
+	lei_ok(qw(q z:1..));
 	diag $lei_err;
 	$out = json_utf8->decode($lei_out);
 	ok(scalar(@$out) > 1, 'got imported messages');
diff --git a/xt/lei-sigpipe.t b/xt/lei-sigpipe.t
index ba2d23c8..44020bad 100644
--- a/xt/lei-sigpipe.t
+++ b/xt/lei-sigpipe.t
@@ -15,7 +15,7 @@ my $do_test = sub {
 		pipe(my ($r, $w)) or BAIL_OUT $!;
 		open my $err, '+>', undef or BAIL_OUT $!;
 		my $opt = { run_mode => 0, 1 => $w, 2 => $err };
-		my $cmd = [qw(lei q -q -t), @$out, 'bytes:1..'];
+		my $cmd = [qw(lei q -q -t), @$out, 'z:1..'];
 		my $tp = start_script($cmd, $env, $opt);
 		close $w;
 		sysread($r, my $buf, 1);

                 reply	other threads:[~2021-03-05  3:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210305031058.31851-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    --subject='Re: [PATCH] search: use "z:" instead of "bytes:" prefix' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).