These may've been causing strange errors[1] in t/imapd.t from the -watch daemon, such as:
Cannot copy to HASH in scalar assignment ../PublicInbox/Over.pm in the Over->dbh() sub. I've only noticed this failure on FreeBSD 13.2 (Perl 5.32.1, DBD::SQLite 1.72 (bundled SQLite 3.39.4), DBI 1.643) so far, so it could also be something to do with the versions used and/or memory layout differences with libc or build toolchain. --- lib/PublicInbox/Over.pm | 13 +++++++++++-- lib/PublicInbox/OverIdx.pm | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm index e3a8adb1..4eed4f46 100644 --- a/lib/PublicInbox/Over.pm +++ b/lib/PublicInbox/Over.pm @@ -82,7 +82,13 @@ sub dbh_close { } } -sub dbh ($) { $_[0]->{dbh} //= $_[0]->dbh_new } # dbh_new may be subclassed +sub dbh ($) { + my ($self) = @_; + $self->{dbh} // do { + my $dbh = $self->dbh_new; # dbh_new may be subclassed + $self->{dbh} = $dbh; + } +} sub load_from_row ($;$) { my ($smsg, $cull) = @_; @@ -256,9 +262,12 @@ SELECT ts,ds,ddd FROM over WHERE $s sub get_art { my ($self, $num) = @_; # caching $sth ourselves is faster than prepare_cached - my $sth = $self->{-get_art} //= dbh($self)->prepare(<<''); + my $sth = $self->{-get_art} // do { + my $sth = dbh($self)->prepare(<<''); SELECT num,tid,ds,ts,ddd FROM over WHERE num = ? LIMIT 1 + $self->{-get_art} = $sth; + }; $sth->execute($num); my $smsg = $sth->fetchrow_hashref; $smsg ? load_from_row($smsg) : undef; diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm index aead375a..c9c25828 100644 --- a/lib/PublicInbox/OverIdx.pm +++ b/lib/PublicInbox/OverIdx.pm @@ -520,7 +520,7 @@ EOM # used for cross-inbox search sub eidx_prep ($) { my ($self) = @_; - $self->{-eidx_prep} //= do { + $self->{-eidx_prep} // do { my $dbh = $self->dbh; $dbh->do(<<''); INSERT OR IGNORE INTO counter (key) VALUES ('eidx_docid') @@ -565,7 +565,7 @@ CREATE TABLE IF NOT EXISTS eidx_meta ( $dbh->do(<<''); CREATE TABLE IF NOT EXISTS eidxq (docid INTEGER PRIMARY KEY NOT NULL) - 1; + $self->{-eidx_prep} = 1; }; }