]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
overidx: fix version comparison
authorEric Wong <e@80x24.org>
Sun, 1 Oct 2023 09:54:26 +0000 (09:54 +0000)
committerEric Wong <e@80x24.org>
Sun, 1 Oct 2023 22:41:47 +0000 (22:41 +0000)
We can't use $DBD::SQLite::sqlite_version_number with older versions of
DBD::SQLite.  Thus we need to treat the $DBD::SQLite::sqlite_version
string (e.g. "3.8.3", not v-string) and convert it to a v-string with
eval for version comparisons to determine if we can fork multiple
children when using SQLite.

Fixes: fa04201baae9 ("lei: force --jobs=1,1 for SQLite < 3.8.3")
lib/PublicInbox/OverIdx.pm

index 6cc86d5d038d3669b0991d270aa74234f3937560..5cea37068d48e29a121f6b0552df916f5160b780 100644 (file)
@@ -671,13 +671,14 @@ sub vivify_xvmd {
 }
 
 sub fork_ok {
-       return 1 if $DBD::SQLite::sqlite_version >= 3008003;
+       state $fork_ok = eval("v$DBD::SQLite::sqlite_version") ge v3.8.3;
+       return 1 if $fork_ok;
        my ($opt) = @_;
        my @j = split(/,/, $opt->{jobs} // '');
        state $warned;
-       grep { $_ > 1 } @j and $warned //= warn('DBD::SQLite version is ',
-                $DBD::SQLite::sqlite_version,
-               ", need >= 3008003 (3.8.3) for --jobs > 1\n");
+       grep { $_ > 1 } @j and $warned //= warn(<<EOM);
+DBD::SQLite version is v$DBD::SQLite::sqlite_version, need >= v3.8.3 for --jobs > 1
+EOM
        $opt->{jobs} = '1,1';
        undef;
 }