]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/OverIdx.pm
get rid of unnecessary bytes::length usage
[public-inbox.git] / lib / PublicInbox / OverIdx.pm
index 5f96a5b099ff0a692b5aa33f9f2994bcaec9e678..e0893337e7843461740ad607ecff7aa5e7dd9b6f 100644 (file)
@@ -463,8 +463,8 @@ sub create {
        };
        unless (-r $fn) {
                require File::Path;
-               require File::Basename;
-               File::Path::mkpath(File::Basename::dirname($fn));
+               my ($dir) = ($fn =~ m!(.*?/)[^/]+\z!);
+               File::Path::mkpath($dir);
        }
        # create the DB:
        PublicInbox::Over::dbh($self);
@@ -656,6 +656,26 @@ UPDATE over SET ddd = ? WHERE num = ?
        $sth->execute;
 }
 
+sub merge_xref3 { # used for "-extindex --dedupe"
+       my ($self, $keep_docid, $drop_docid, $oidhex) = @_;
+       my $oidbin = pack('H*', $oidhex);
+       my $sth = $self->{dbh}->prepare_cached(<<'');
+UPDATE OR IGNORE xref3 SET docid = ? WHERE docid = ? AND oidbin = ?
+
+       $sth->bind_param(1, $keep_docid);
+       $sth->bind_param(2, $drop_docid);
+       $sth->bind_param(3, $oidbin, SQL_BLOB);
+       $sth->execute;
+
+       # drop anything that conflicted
+       $sth = $self->{dbh}->prepare_cached(<<'');
+DELETE FROM xref3 WHERE docid = ? AND oidbin = ?
+
+       $sth->bind_param(1, $drop_docid);
+       $sth->bind_param(2, $oidbin, SQL_BLOB);
+       $sth->execute;
+}
+
 sub eidxq_add {
        my ($self, $docid) = @_;
        $self->dbh->prepare_cached(<<'')->execute($docid);