about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Msgmap.pm6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm
index 3fb3805f..a49b61e8 100644
--- a/lib/PublicInbox/Msgmap.pm
+++ b/lib/PublicInbox/Msgmap.pm
@@ -82,10 +82,10 @@ sub created_at {
 sub mid_insert {
         my ($self, $mid) = @_;
         my $dbh = $self->{dbh};
-        use constant MID_INSERT => 'INSERT INTO msgmap (mid) VALUES (?)';
-        my $sth = $self->{mid_insert} ||= $dbh->prepare(MID_INSERT);
+        my $sql = 'INSERT OR IGNORE INTO msgmap (mid) VALUES (?)';
+        my $sth = $self->{mid_insert} ||= $dbh->prepare($sql);
         $sth->bind_param(1, $mid);
-        $sth->execute;
+        return if $sth->execute == 0;
         $dbh->last_insert_id(undef, undef, 'msgmap', 'num');
 }