]> git.sesse.net Git - pr0n/blobdiff - perl/Sesse/pr0n/Common.pm
When inserting multiple images at the same time, we could deadlock -- inserting
[pr0n] / perl / Sesse / pr0n / Common.pm
index cb02a154c90912ba5e1b7065d2641203497f5801..d03f46f1f01a01a10b656bb0efeb53aeb1adfb6e 100644 (file)
@@ -31,7 +31,7 @@ BEGIN {
                require Sesse::pr0n::Config_local;
        };
 
-       $VERSION     = "v2.04";
+       $VERSION     = "v2.05";
        @ISA         = qw(Exporter);
        @EXPORT      = qw(&error &dberror);
        %EXPORT_TAGS = qw();
@@ -192,8 +192,8 @@ sub update_width_height {
 
        # update the last_picture cache as well (this should of course be done
        # via a trigger, but this is less complicated :-) )
-       $dbh->do('UPDATE events SET last_picture=(SELECT COALESCE(MAX(date),\'1970-01-01 00:00:00\') FROM images WHERE event=events.id) WHERE id=(SELECT event FROM images WHERE id=?)',
-               undef, $id)
+       $dbh->do('UPDATE last_picture_cache SET last_picture=GREATEST(last_picture, ?) FROM images WHERE event=events.id) WHERE id=(SELECT event FROM images WHERE id=?)',
+               undef, $datetime, $id)
                or die "Couldn't update last_picture in SQL: $!";
 }