unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH 0/5] some minor SQLite-related cleanups
@ 2020-08-26  8:17 Eric Wong
  2020-08-26  8:17 ` [PATCH 1/5] over: rename ->connect method to ->dbh Eric Wong
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Eric Wong @ 2020-08-26  8:17 UTC (permalink / raw)
  To: meta

Dropping some expensive dead code and avoiding some overloaded
method names to reduce confusion.

Eric Wong (5):
  over: rename ->connect method to ->dbh
  over: rename ->disconnect to ->dbh_close
  over: recent: remove expensive COUNT query
  over*: use v5.10.1, drop warnings
  msgmap: use v5.10.1

 lib/PublicInbox/Inbox.pm      |  2 +-
 lib/PublicInbox/Msgmap.pm     |  3 ++-
 lib/PublicInbox/Over.pm       | 33 +++++++++++++--------------------
 lib/PublicInbox/OverIdx.pm    | 15 +++++++--------
 lib/PublicInbox/V2Writable.pm |  4 ++--
 lib/PublicInbox/Xapcmd.pm     |  2 +-
 scripts/dupe-finder           |  2 +-
 t/indexlevels-mirror.t        | 29 +++++++++++++++--------------
 t/over.t                      | 11 +++++------
 t/search-thr-index.t          |  4 ++--
 t/v1reindex.t                 |  2 +-
 t/v2reindex.t                 |  2 +-
 t/v2writable.t                |  4 +++-
 t/watch_maildir_v2.t          | 30 +++++++++++++++---------------
 14 files changed, 69 insertions(+), 74 deletions(-)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/5] over: rename ->connect method to ->dbh
  2020-08-26  8:17 [PATCH 0/5] some minor SQLite-related cleanups Eric Wong
@ 2020-08-26  8:17 ` Eric Wong
  2020-08-26  8:17 ` [PATCH 2/5] over: rename ->disconnect to ->dbh_close Eric Wong
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2020-08-26  8:17 UTC (permalink / raw)
  To: meta

`->connect' is confused with the perlfunc for the `connect(2)'
syscall, and also `DBI->connect'.  Since SQLite doesn't use
sockets, the word "connect" needlessly confuses me.  Give
it a short name to match the field name we use for it, which
also matches the variable name used by the DBI(3pm) and
DBD::SQLite(3pm) manpages.
---
 lib/PublicInbox/Inbox.pm   |  2 +-
 lib/PublicInbox/Over.pm    | 19 +++++++++----------
 lib/PublicInbox/OverIdx.pm |  4 ++--
 lib/PublicInbox/Xapcmd.pm  |  2 +-
 scripts/dupe-finder        |  2 +-
 t/over.t                   |  9 ++++-----
 t/search-thr-index.t       |  4 ++--
 t/v1reindex.t              |  2 +-
 t/v2reindex.t              |  2 +-
 9 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 55e546e1..241001d3 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -211,7 +211,7 @@ sub over ($) {
 	my $srch = search($self, 1) or return;
 	$self->{over} //= eval {
 		my $over = $srch->{over_ro};
-		$over->connect; # may fail
+		$over->dbh; # may fail
 		$over;
 	}
 }
diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm
index 3e74b7a6..0ebc8003 100644
--- a/lib/PublicInbox/Over.pm
+++ b/lib/PublicInbox/Over.pm
@@ -80,7 +80,7 @@ sub disconnect {
 	}
 }
 
-sub connect { $_[0]->{dbh} //= $_[0]->dbh_new }
+sub dbh ($) { $_[0]->{dbh} //= $_[0]->dbh_new } # dbh_new may be subclassed
 
 sub load_from_row ($;$) {
 	my ($smsg, $cull) = @_;
@@ -97,10 +97,9 @@ sub load_from_row ($;$) {
 
 sub do_get {
 	my ($self, $sql, $opts, @args) = @_;
-	my $dbh = $self->connect;
 	my $lim = (($opts->{limit} || 0) + 0) || DEFAULT_LIMIT;
 	$sql .= "LIMIT $lim";
-	my $msgs = $dbh->selectall_arrayref($sql, { Slice => {} }, @args);
+	my $msgs = dbh($self)->selectall_arrayref($sql, { Slice => {} }, @args);
 	my $cull = $opts->{cull};
 	load_from_row($_, $cull) for @$msgs;
 	$msgs
@@ -135,7 +134,7 @@ sub nothing () { wantarray ? (0, []) : [] };
 
 sub get_thread {
 	my ($self, $mid, $prev) = @_;
-	my $dbh = $self->connect;
+	my $dbh = dbh($self);
 	my $opts = { cull => 1 };
 
 	my $id = $dbh->selectrow_array(<<'', undef, $mid);
@@ -202,7 +201,7 @@ ORDER BY $sort_col DESC
 # returns true if we have IDs, undef if not
 sub expand_thread {
 	my ($self, $ctx) = @_;
-	my $dbh = $self->connect;
+	my $dbh = dbh($self);
 	do {
 		defined(my $num = $ctx->{ids}->[0]) or return;
 		my ($tid) = $dbh->selectrow_array(<<'', undef, $num);
@@ -259,7 +258,7 @@ SELECT COUNT(num) FROM over WHERE num > 0
 sub get_art {
 	my ($self, $num) = @_;
 	# caching $sth ourselves is faster than prepare_cached
-	my $sth = $self->{-get_art} //= $self->connect->prepare(<<'');
+	my $sth = $self->{-get_art} //= dbh($self)->prepare(<<'');
 SELECT num,tid,ds,ts,ddd FROM over WHERE num = ? LIMIT 1
 
 	$sth->execute($num);
@@ -269,7 +268,7 @@ SELECT num,tid,ds,ts,ddd FROM over WHERE num = ? LIMIT 1
 
 sub next_by_mid {
 	my ($self, $mid, $id, $prev) = @_;
-	my $dbh = $self->connect;
+	my $dbh = dbh($self);
 
 	unless (defined $$id) {
 		my $sth = $dbh->prepare_cached(<<'', undef, 1);
@@ -293,7 +292,7 @@ ORDER BY num ASC LIMIT 1
 # IMAP search, this is limited by callers to UID_SLICE size (50K)
 sub uid_range {
 	my ($self, $beg, $end, $sql) = @_;
-	my $dbh = $self->connect;
+	my $dbh = dbh($self);
 	my $q = 'SELECT num FROM over WHERE num >= ? AND num <= ?';
 
 	# This is read-only, anyways; but caller should verify it's
@@ -305,7 +304,7 @@ sub uid_range {
 
 sub max {
 	my ($self) = @_;
-	my $sth = $self->connect->prepare_cached(<<'', undef, 1);
+	my $sth = dbh($self)->prepare_cached(<<'', undef, 1);
 SELECT MAX(num) FROM over WHERE num > 0
 
 	$sth->execute;
@@ -314,7 +313,7 @@ SELECT MAX(num) FROM over WHERE num > 0
 
 sub imap_exists {
 	my ($self, $uid_base, $uid_end) = @_;
-	my $sth = $self->connect->prepare_cached(<<'', undef, 1);
+	my $sth = dbh($self)->prepare_cached(<<'', undef, 1);
 SELECT COUNT(num) FROM over WHERE num > ? AND num <= ?
 
 	$sth->execute($uid_base, $uid_end);
diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm
index 9f4a56fb..c521464a 100644
--- a/lib/PublicInbox/OverIdx.pm
+++ b/lib/PublicInbox/OverIdx.pm
@@ -443,7 +443,7 @@ sub commit_lazy {
 sub begin_lazy {
 	my ($self) = @_;
 	return if $self->{txn};
-	my $dbh = $self->connect or return;
+	my $dbh = $self->dbh or return;
 	$dbh->begin_work;
 	# $dbh->{Profile} = 2;
 	$self->{txn} = 1;
@@ -469,7 +469,7 @@ sub create {
 		File::Path::mkpath(File::Basename::dirname($self->{filename}));
 	}
 	# create the DB:
-	PublicInbox::Over::connect($self);
+	PublicInbox::Over::dbh($self);
 	$self->disconnect;
 }
 
diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm
index fffac99c..6a74daf9 100644
--- a/lib/PublicInbox/Xapcmd.pm
+++ b/lib/PublicInbox/Xapcmd.pm
@@ -37,7 +37,7 @@ sub commit_changes ($$$$) {
 			defined $new or die "BUG: $over exists when culling v2";
 			$over = PublicInbox::Over->new($over);
 			my $tmp_over = "$new/over.sqlite3";
-			$over->connect->sqlite_backup_to_file($tmp_over);
+			$over->dbh->sqlite_backup_to_file($tmp_over);
 			$over = undef;
 			$over_chg = 1;
 		}
diff --git a/scripts/dupe-finder b/scripts/dupe-finder
index 6f873b6e..04714cbd 100644
--- a/scripts/dupe-finder
+++ b/scripts/dupe-finder
@@ -21,7 +21,7 @@ if (index($repo, '@') > 0) {
 }
 $ibx or die "No inbox";
 $ibx->search or die "search not available for inbox";
-my $dbh = $ibx->search->{over_ro}->connect;
+my $dbh = $ibx->search->{over_ro}->dbh;
 my $over = PublicInbox::Over->new($dbh->sqlite_db_filename);
 
 sub emit ($) {
diff --git a/t/over.t b/t/over.t
index 8bf64ecb..6c4c8ee6 100644
--- a/t/over.t
+++ b/t/over.t
@@ -9,7 +9,7 @@ require_mods('DBD::SQLite');
 use_ok 'PublicInbox::OverIdx';
 my ($tmpdir, $for_destroy) = tmpdir();
 my $over = PublicInbox::OverIdx->new("$tmpdir/over.sqlite3");
-$over->connect;
+$over->dbh; # open file
 is($over->max, 0, 'max is zero on new DB (scalar context)');
 is_deeply([$over->max], [0], 'max is zero on new DB (list context)');
 my $x = $over->next_tid;
@@ -26,11 +26,10 @@ ok(!$over->{dbh}->{ReadOnly}, 'OverIdx is not ReadOnly');
 $over->disconnect;
 
 $over = PublicInbox::Over->new("$tmpdir/over.sqlite3");
-$over->connect;
-ok($over->{dbh}->{ReadOnly}, 'Over is ReadOnly');
+ok($over->dbh->{ReadOnly}, 'Over is ReadOnly');
 
 $over = PublicInbox::OverIdx->new("$tmpdir/over.sqlite3");
-$over->connect;
+$over->dbh;
 is($over->sid('hello-world'), $x, 'idempotent across reopen');
 $over->each_by_mid('never', sub { fail('should not be called') });
 
@@ -71,7 +70,7 @@ SKIP: {
 	skip("no WAL in SQLite version $v < 3.7.0", 1) if $v lt v3.7.0;
 	$over->{dbh}->do('PRAGMA journal_mode = WAL');
 	$over = PublicInbox::OverIdx->new("$tmpdir/over.sqlite3");
-	is($over->connect->selectrow_array('PRAGMA journal_mode'), 'wal',
+	is($over->dbh->selectrow_array('PRAGMA journal_mode'), 'wal',
 		'WAL journal_mode not clobbered if manually set');
 }
 
diff --git a/t/search-thr-index.t b/t/search-thr-index.t
index 914807a8..b5a5ff1f 100644
--- a/t/search-thr-index.t
+++ b/t/search-thr-index.t
@@ -60,7 +60,7 @@ foreach (reverse split(/\n\n/, $data)) {
 
 my $prev;
 my %tids;
-my $dbh = $rw->{over}->connect;
+my $dbh = $rw->{over}->dbh;
 foreach my $mid (@mids) {
 	my $msgs = $rw->{over}->get_thread($mid);
 	is(3, scalar(@$msgs), "got all messages from $mid");
@@ -84,7 +84,7 @@ Message-Id: <1-bw@g>
 From: bw@g
 To: git@vger.kernel.org
 
-	my $dbh = $rw->{over}->connect;
+	my $dbh = $rw->{over}->dbh;
 	my ($id, $prev);
 	my $reidx = $rw->{over}->next_by_mid('1-bw@g', \$id, \$prev);
 	ok(defined $reidx);
diff --git a/t/v1reindex.t b/t/v1reindex.t
index d70ed4b9..a5c85ffb 100644
--- a/t/v1reindex.t
+++ b/t/v1reindex.t
@@ -434,7 +434,7 @@ ok(!-d $xap, 'Xapian directories removed again');
 	my $ibx = PublicInbox::Inbox->new({ %$ibx_config });
 	my $f = $ibx->over->{dbh}->sqlite_db_filename;
 	my $over = PublicInbox::OverIdx->new($f);
-	my $dbh = $over->connect;
+	my $dbh = $over->dbh;
 	my $non_ghost_tids = sub {
 		$dbh->selectall_arrayref(<<'');
 SELECT tid FROM over WHERE num > 0 ORDER BY tid ASC
diff --git a/t/v2reindex.t b/t/v2reindex.t
index ea2b24e5..a2fc2075 100644
--- a/t/v2reindex.t
+++ b/t/v2reindex.t
@@ -432,7 +432,7 @@ my $check_rethread = sub {
 	my $ibx = PublicInbox::Inbox->new(\%config);
 	my $f = $ibx->over->{dbh}->sqlite_db_filename;
 	my $over = PublicInbox::OverIdx->new($f);
-	my $dbh = $over->connect;
+	my $dbh = $over->dbh;
 	my $non_ghost_tids = sub {
 		$dbh->selectall_arrayref(<<'');
 SELECT tid FROM over WHERE num > 0 ORDER BY tid ASC

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] over: rename ->disconnect to ->dbh_close
  2020-08-26  8:17 [PATCH 0/5] some minor SQLite-related cleanups Eric Wong
  2020-08-26  8:17 ` [PATCH 1/5] over: rename ->connect method to ->dbh Eric Wong
@ 2020-08-26  8:17 ` Eric Wong
  2020-08-26  8:17 ` [PATCH 3/5] over: recent: remove expensive COUNT query Eric Wong
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2020-08-26  8:17 UTC (permalink / raw)
  To: meta

Since we got rid of over->connect, `disconnect' no longer pairs
with it.  So name it after the `close(2)' syscall it ultimately
issues.
---
 lib/PublicInbox/Over.pm       | 4 ++--
 lib/PublicInbox/OverIdx.pm    | 6 +++---
 lib/PublicInbox/V2Writable.pm | 4 ++--
 t/over.t                      | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm
index 0ebc8003..a2cf9f21 100644
--- a/lib/PublicInbox/Over.pm
+++ b/lib/PublicInbox/Over.pm
@@ -72,7 +72,7 @@ sub new {
 	bless { filename => $f }, $class;
 }
 
-sub disconnect {
+sub dbh_close {
 	my ($self) = @_;
 	if (my $dbh = delete $self->{dbh}) {
 		delete $self->{-get_art};
@@ -328,7 +328,7 @@ sub check_inodes {
 		my $st = pack('dd', $st[0], $st[1]);
 
 		# don't actually reopen, just let {dbh} be recreated later
-		disconnect($self) if $st ne ($self->{st} // $st);
+		dbh_close($self) if $st ne ($self->{st} // $st);
 	} else {
 		warn "W: stat $f: $!\n";
 	}
diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm
index c521464a..512c5f46 100644
--- a/lib/PublicInbox/OverIdx.pm
+++ b/lib/PublicInbox/OverIdx.pm
@@ -455,10 +455,10 @@ sub rollback_lazy {
 	$self->{dbh}->rollback;
 }
 
-sub disconnect {
+sub dbh_close {
 	my ($self) = @_;
 	die "in transaction" if $self->{txn};
-	$self->SUPER::disconnect;
+	$self->SUPER::dbh_close;
 }
 
 sub create {
@@ -470,7 +470,7 @@ sub create {
 	}
 	# create the DB:
 	PublicInbox::Over::dbh($self);
-	$self->disconnect;
+	$self->dbh_close;
 }
 
 sub rethread_prepare {
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index c926446c..f2288904 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -679,8 +679,8 @@ sub done {
 			$err .= "shard close: $@\n" if $@;
 		}
 	}
-	eval { $self->{over}->disconnect };
-	$err .= "over disconnect: $@\n" if $@;
+	eval { $self->{over}->dbh_close };
+	$err .= "over close: $@\n" if $@;
 	delete $self->{bnote};
 	my $nbytes = $self->{total_bytes};
 	$self->{total_bytes} = 0;
diff --git a/t/over.t b/t/over.t
index 6c4c8ee6..41c13872 100644
--- a/t/over.t
+++ b/t/over.t
@@ -23,7 +23,7 @@ $y = $over->sid('hello-WORLD');
 is($y, $x+1, 'sid increases');
 is($over->sid('hello-world'), $x, 'idempotent');
 ok(!$over->{dbh}->{ReadOnly}, 'OverIdx is not ReadOnly');
-$over->disconnect;
+$over->dbh_close;
 
 $over = PublicInbox::Over->new("$tmpdir/over.sqlite3");
 ok($over->dbh->{ReadOnly}, 'Over is ReadOnly');

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] over: recent: remove expensive COUNT query
  2020-08-26  8:17 [PATCH 0/5] some minor SQLite-related cleanups Eric Wong
  2020-08-26  8:17 ` [PATCH 1/5] over: rename ->connect method to ->dbh Eric Wong
  2020-08-26  8:17 ` [PATCH 2/5] over: rename ->disconnect to ->dbh_close Eric Wong
@ 2020-08-26  8:17 ` Eric Wong
  2020-08-26  8:17 ` [PATCH 4/5] over*: use v5.10.1, drop warnings Eric Wong
  2020-08-26  8:17 ` [PATCH 5/5] msgmap: use v5.10.1 Eric Wong
  4 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2020-08-26  8:17 UTC (permalink / raw)
  To: meta

As noted in commit 87dca6d8d5988c5eb54019cca342450b0b7dd6b7
("www: rework query responses to avoid COUNT in SQLite"),
COUNT on many rows is expensive on big SQLite DBs.

We've already stopped using that code path long ago in WWW
while -imapd and -nntpd never used it.  So we'll adjust our
remaining test cases to not need it, either.
---
 lib/PublicInbox/Over.pm |  8 +-------
 t/indexlevels-mirror.t  | 29 +++++++++++++++--------------
 t/v2writable.t          |  4 +++-
 t/watch_maildir_v2.t    | 30 +++++++++++++++---------------
 4 files changed, 34 insertions(+), 37 deletions(-)

diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm
index a2cf9f21..6b7d5216 100644
--- a/lib/PublicInbox/Over.pm
+++ b/lib/PublicInbox/Over.pm
@@ -244,15 +244,9 @@ sub recent {
 			$s = '+num > 0 ORDER BY ts DESC';
 		}
 	}
-	my $msgs = do_get($self, <<"", $opts, @v);
+	do_get($self, <<"", $opts, @v);
 SELECT ts,ds,ddd FROM over WHERE $s
 
-	return $msgs unless wantarray;
-
-	my $nr = $self->{dbh}->selectrow_array(<<'');
-SELECT COUNT(num) FROM over WHERE num > 0
-
-	($nr, $msgs);
 }
 
 sub get_art {
diff --git a/t/indexlevels-mirror.t b/t/indexlevels-mirror.t
index 859c2c17..27533546 100644
--- a/t/indexlevels-mirror.t
+++ b/t/indexlevels-mirror.t
@@ -49,8 +49,8 @@ my $import_index_incremental = sub {
 		inboxdir => $ibx->{inboxdir},
 		indexlevel => $level
 	});
-	my ($nr, $msgs) = $ro_master->recent;
-	is($nr, 1, 'only one message in master, so far');
+	my $msgs = $ro_master->recent;
+	is(scalar(@$msgs), 1, 'only one message in master, so far');
 	is($msgs->[0]->{mid}, 'm@1', 'first message in master indexed');
 
 	# clone
@@ -79,8 +79,8 @@ my $import_index_incremental = sub {
 		inboxdir => $mirror,
 		indexlevel => $level,
 	});
-	($nr, $msgs) = $ro_mirror->recent;
-	is($nr, 1, 'only one message, so far');
+	$msgs = $ro_mirror->recent;
+	is(scalar(@$msgs), 1, 'only one message, so far');
 	is($msgs->[0]->{mid}, 'm@1', 'read first message');
 
 	# update master
@@ -91,16 +91,16 @@ my $import_index_incremental = sub {
 	# mirror updates
 	is(xsys('git', "--git-dir=$fetch_dir", qw(fetch -q)), 0, 'fetch OK');
 	ok(run_script([qw(-index -j0), $mirror]), "v$v index mirror again OK");
-	($nr, $msgs) = $ro_mirror->recent;
-	is($nr, 2, '2nd message seen in mirror');
+	$msgs = $ro_mirror->recent;
+	is(scalar(@$msgs), 2, '2nd message seen in mirror');
 	is_deeply([sort { $a cmp $b } map { $_->{mid} } @$msgs],
 		['m@1','m@2'], 'got both messages in mirror');
 
 	# incremental index master (required for v1)
 	ok(run_script([qw(-index -j0), $ibx->{inboxdir}, "-L$level"]),
 		'index master OK');
-	($nr, $msgs) = $ro_master->recent;
-	is($nr, 2, '2nd message seen in master');
+	$msgs = $ro_master->recent;
+	is(scalar(@$msgs), 2, '2nd message seen in master');
 	is_deeply([sort { $a cmp $b } map { $_->{mid} } @$msgs],
 		['m@1','m@2'], 'got both messages in master');
 
@@ -121,15 +121,15 @@ my $import_index_incremental = sub {
 		is(PublicInbox::Admin::detect_indexlevel($ro_mirror), $level,
 		   'indexlevel detectable by Admin after xcpdb v' .$v.$level);
 		delete $ro_mirror->{$_} for (qw(over search));
-		($nr, $msgs) = $ro_mirror->search->query('m:m@2');
-		is($nr, 1, "v$v found m\@2 via Xapian on $level");
+		$msgs = $ro_mirror->search->query('m:m@2');
+		is(scalar(@$msgs), 1, "v$v found m\@2 via Xapian on $level");
 	}
 
 	# sync the mirror
 	is(xsys('git', "--git-dir=$fetch_dir", qw(fetch -q)), 0, 'fetch OK');
 	ok(run_script([qw(-index -j0), $mirror]), "v$v index mirror again OK");
-	($nr, $msgs) = $ro_mirror->recent;
-	is($nr, 1, '2nd message gone from mirror');
+	$msgs = $ro_mirror->recent;
+	is(scalar(@$msgs), 1, '2nd message gone from mirror');
 	is_deeply([map { $_->{mid} } @$msgs], ['m@1'],
 		'message unavailable in mirror');
 
@@ -138,8 +138,9 @@ my $import_index_incremental = sub {
 			 'no Xapian shard directories for v2 basic');
 	}
 	if ($level ne 'basic') {
-		($nr, $msgs) = $ro_mirror->search->reopen->query('m:m@2');
-		is($nr, 0, "v$v m\@2 gone from Xapian in mirror on $level");
+		$msgs = $ro_mirror->search->reopen->query('m:m@2');
+		is(scalar(@$msgs), 0,
+			"v$v m\@2 gone from Xapian in mirror on $level");
 	}
 
 	# add another message to master and have the mirror
diff --git a/t/v2writable.t b/t/v2writable.t
index 2bd7a400..9e4547ba 100644
--- a/t/v2writable.t
+++ b/t/v2writable.t
@@ -120,7 +120,9 @@ if ('ensure git configs are correct') {
 	$mime->header_set('References', '<zz-mid@b>');
 	ok($im->add($mime), 'message with multiple Message-ID');
 	$im->done;
-	my ($total, undef) = $ibx->over->recent;
+	my $total = $ibx->over->dbh->selectrow_array(<<'');
+SELECT COUNT(*) FROM over WHERE num > 0
+
 	is($ibx->mm->num_highwater, $total, 'got expected highwater value');
 	my $srch = $ibx->search;
 	my $mset1 = $srch->reopen->query('m:abcde@1', { mset => 1 });
diff --git a/t/watch_maildir_v2.t b/t/watch_maildir_v2.t
index f5b8e932..59ec247e 100644
--- a/t/watch_maildir_v2.t
+++ b/t/watch_maildir_v2.t
@@ -50,7 +50,7 @@ ok($ibx, 'found inbox by name');
 my $srch = $ibx->search;
 
 PublicInbox::WatchMaildir->new($config)->scan('full');
-my ($total, undef) = $srch->reopen->query('');
+my $total = scalar @{$srch->reopen->query('')};
 is($total, 1, 'got one revision');
 
 # my $git = PublicInbox::Git->new("$inboxdir/git/0.git");
@@ -70,7 +70,7 @@ my $write_spam = sub {
 $write_spam->();
 is(unlink(glob("$maildir/new/*")), 1, 'unlinked old spam');
 PublicInbox::WatchMaildir->new($config)->scan('full');
-is(($srch->reopen->query(''))[0], 0, 'deleted file');
+is_deeply($srch->reopen->query(''), [], 'deleted file');
 is(unlink(glob("$spamdir/cur/*")), 1, 'unlinked trained spam');
 
 # check with scrubbing
@@ -81,16 +81,16 @@ the body of a message to majordomo\@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html\n);
 	PublicInbox::Emergency->new($maildir)->prepare(\$msg);
 	PublicInbox::WatchMaildir->new($config)->scan('full');
-	my ($nr, $msgs) = $srch->reopen->query('');
-	is($nr, 1, 'got one file back');
+	my $msgs = $srch->reopen->query('');
+	is(scalar(@$msgs), 1, 'got one file back');
 	my $mref = $ibx->msg_by_smsg($msgs->[0]);
 	like($$mref, qr/something\n\z/s, 'message scrubbed on import');
 
 	is(unlink(glob("$maildir/new/*")), 1, 'unlinked spam');
 	$write_spam->();
 	PublicInbox::WatchMaildir->new($config)->scan('full');
-	($nr, $msgs) = $srch->reopen->query('');
-	is($nr, 0, 'inbox is empty again');
+	$msgs = $srch->reopen->query('');
+	is(scalar(@$msgs), 0, 'inbox is empty again');
 	is(unlink(glob("$spamdir/cur/*")), 1, 'unlinked trained spam');
 }
 
@@ -105,8 +105,8 @@ More majordomo info at  http://vger.kernel.org/majordomo-info.html\n);
 		local $SIG{__WARN__} = sub {}; # quiet spam check warning
 		PublicInbox::WatchMaildir->new($config)->scan('full');
 	}
-	my ($nr, $msgs) = $srch->reopen->query('');
-	is($nr, 0, 'inbox is still empty');
+	my $msgs = $srch->reopen->query('');
+	is(scalar(@$msgs), 0, 'inbox is still empty');
 	is(unlink(glob("$maildir/new/*")), 1);
 }
 
@@ -118,8 +118,8 @@ More majordomo info at  http://vger.kernel.org/majordomo-info.html\n);
 	PublicInbox::Emergency->new($maildir)->prepare(\$msg);
 	$config->{'publicinboxwatch.spamcheck'} = 'spamc';
 	PublicInbox::WatchMaildir->new($config)->scan('full');
-	my ($nr, $msgs) = $srch->reopen->query('');
-	is($nr, 1, 'inbox has one mail after spamc OK-ed a message');
+	my $msgs = $srch->reopen->query('');
+	is(scalar(@$msgs), 1, 'inbox has one mail after spamc OK-ed a message');
 	my $mref = $ibx->msg_by_smsg($msgs->[0]);
 	like($$mref, qr/something\n\z/s, 'message scrubbed on import');
 	delete $config->{'publicinboxwatch.spamcheck'};
@@ -131,11 +131,11 @@ More majordomo info at  http://vger.kernel.org/majordomo-info.html\n);
 	$msg = do { local $/; <$fh> };
 	PublicInbox::Emergency->new($maildir)->prepare(\$msg);
 	PublicInbox::WatchMaildir->new($config)->scan('full');
-	my ($nr, $msgs) = $srch->reopen->query('dfpost:6e006fd7');
-	is($nr, 1, 'diff postimage found');
+	my $msgs = $srch->reopen->query('dfpost:6e006fd7');
+	is(scalar(@$msgs), 1, 'diff postimage found');
 	my $post = $msgs->[0];
-	($nr, $msgs) = $srch->query('dfpre:090d998b6c2c');
-	is($nr, 1, 'diff preimage found');
+	$msgs = $srch->query('dfpre:090d998b6c2c');
+	is(scalar(@$msgs), 1, 'diff preimage found');
 	is($post->{blob}, $msgs->[0]->{blob}, 'same message');
 }
 
@@ -162,7 +162,7 @@ both
 EOF
 	PublicInbox::Emergency->new($maildir)->prepare(\$both);
 	PublicInbox::WatchMaildir->new($config)->scan('full');
-	my ($total, $msgs) = $srch->reopen->query('m:both@b.com');
+	my $msgs = $srch->reopen->query('m:both@b.com');
 	my $v1 = $config->lookup_name('v1');
 	my $msg = $v1->git->cat_file($msgs->[0]->{blob});
 	is($both, $$msg, 'got original message back from v1');

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] over*: use v5.10.1, drop warnings
  2020-08-26  8:17 [PATCH 0/5] some minor SQLite-related cleanups Eric Wong
                   ` (2 preceding siblings ...)
  2020-08-26  8:17 ` [PATCH 3/5] over: recent: remove expensive COUNT query Eric Wong
@ 2020-08-26  8:17 ` Eric Wong
  2020-08-26  8:17 ` [PATCH 5/5] msgmap: use v5.10.1 Eric Wong
  4 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2020-08-26  8:17 UTC (permalink / raw)
  To: meta

v5.10.1 lets us use the lighter parent.pm instead of base.pm,
and we'll rely on the shebang to enable warnings (or not).

While we're in the area, drop a no-longer-necessary import for
PublicInbox::Search, since OverIdx doesn't require search.
---
 lib/PublicInbox/Over.pm    | 2 +-
 lib/PublicInbox/OverIdx.pm | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm
index 6b7d5216..0957cbdd 100644
--- a/lib/PublicInbox/Over.pm
+++ b/lib/PublicInbox/Over.pm
@@ -6,7 +6,7 @@
 # tweaked/updated over time and rebuilt.
 package PublicInbox::Over;
 use strict;
-use warnings;
+use v5.10.1;
 use DBI;
 use DBD::SQLite;
 use PublicInbox::Smsg;
diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm
index 512c5f46..67f8cf65 100644
--- a/lib/PublicInbox/OverIdx.pm
+++ b/lib/PublicInbox/OverIdx.pm
@@ -9,14 +9,13 @@
 # are denoted by a negative NNTP article number.
 package PublicInbox::OverIdx;
 use strict;
-use warnings;
-use base qw(PublicInbox::Over);
+use v5.10.1;
+use parent qw(PublicInbox::Over);
 use IO::Handle;
 use DBI qw(:sql_types); # SQL_BLOB
 use PublicInbox::MID qw/id_compress mids_for_index references/;
 use PublicInbox::Smsg qw(subject_normalized);
 use Compress::Zlib qw(compress);
-use PublicInbox::Search;
 use Carp qw(croak);
 
 sub dbh_new {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] msgmap: use v5.10.1
  2020-08-26  8:17 [PATCH 0/5] some minor SQLite-related cleanups Eric Wong
                   ` (3 preceding siblings ...)
  2020-08-26  8:17 ` [PATCH 4/5] over*: use v5.10.1, drop warnings Eric Wong
@ 2020-08-26  8:17 ` Eric Wong
  4 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2020-08-26  8:17 UTC (permalink / raw)
  To: meta

We use the defined-or (`//', `//=') operators in 5.10,
so require 5.10.1 like the rest of our codebase.  Update
an outdated comment while we're at it.
---
 lib/PublicInbox/Msgmap.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm
index d28e96c8..d696ce83 100644
--- a/lib/PublicInbox/Msgmap.pm
+++ b/lib/PublicInbox/Msgmap.pm
@@ -6,9 +6,10 @@
 # numbers for NNTP and allows prefix lookups for partial Message-IDs
 # in case URLs get truncated from copy-n-paste errors by users.
 #
-# This is maintained by ::SearchIdx
+# This is maintained by ::SearchIdx (v1) and ::V2Writable (v2)
 package PublicInbox::Msgmap;
 use strict;
+use v5.10.1;
 use DBI;
 use DBD::SQLite;
 use PublicInbox::Over;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-26  8:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26  8:17 [PATCH 0/5] some minor SQLite-related cleanups Eric Wong
2020-08-26  8:17 ` [PATCH 1/5] over: rename ->connect method to ->dbh Eric Wong
2020-08-26  8:17 ` [PATCH 2/5] over: rename ->disconnect to ->dbh_close Eric Wong
2020-08-26  8:17 ` [PATCH 3/5] over: recent: remove expensive COUNT query Eric Wong
2020-08-26  8:17 ` [PATCH 4/5] over*: use v5.10.1, drop warnings Eric Wong
2020-08-26  8:17 ` [PATCH 5/5] msgmap: use v5.10.1 Eric Wong

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).