]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 299212: "already locked" errors should be more informative - Patch by Frédéric...
authorlpsolit%gmail.com <>
Fri, 8 Jul 2005 04:15:20 +0000 (04:15 +0000)
committerlpsolit%gmail.com <>
Fri, 8 Jul 2005 04:15:20 +0000 (04:15 +0000)
Bugzilla/DB/Mysql.pm
Bugzilla/DB/Pg.pm
template/en/default/global/code-error.html.tmpl

index 832034a97bc093dc5b5ae4a5b0895bff7b50dcde..3472a351d25a6ab140d875ef0096987361855d50 100644 (file)
@@ -64,7 +64,7 @@ sub new {
 
     # all class local variables stored in DBI derived class needs to have
     # a prefix 'private_'. See DBI documentation.
-    $self->{private_bz_tables_locked} = 0;
+    $self->{private_bz_tables_locked} = "";
 
     bless ($self, $class);
     
@@ -159,13 +159,15 @@ sub sql_group_by {
 sub bz_lock_tables {
     my ($self, @tables) = @_;
 
+    my $list = join(', ', @tables);
     # Check first if there was no lock before
     if ($self->{private_bz_tables_locked}) {
-        ThrowCodeError("already_locked");
+        ThrowCodeError("already_locked", { current => $self->{private_bz_tables_locked},
+                                           new => $list });
     } else {
-        $self->do('LOCK TABLE ' . join(', ', @tables)); 
+        $self->do('LOCK TABLE ' . $list); 
     
-        $self->{private_bz_tables_locked} = 1;
+        $self->{private_bz_tables_locked} = $list;
     }
 }
 
@@ -180,7 +182,7 @@ sub bz_unlock_tables {
     } else {
         $self->do("UNLOCK TABLES");
     
-        $self->{private_bz_tables_locked} = 0;
+        $self->{private_bz_tables_locked} = "";
     }
 }
 
index a83b75bd927b497c86a4a67856801c675fa77a3d..97473e564f44af010fcb806afc04634e016ee3c5 100644 (file)
@@ -70,7 +70,7 @@ sub new {
 
     # all class local variables stored in DBI derived class needs to have
     # a prefix 'private_'. See DBI documentation.
-    $self->{private_bz_tables_locked} = 0;
+    $self->{private_bz_tables_locked} = "";
 
     bless ($self, $class);
 
@@ -147,9 +147,11 @@ sub sql_string_concat {
 sub bz_lock_tables {
     my ($self, @tables) = @_;
    
+    my $list = join(', ', @tables);
     # Check first if there was no lock before
     if ($self->{private_bz_tables_locked}) {
-        ThrowCodeError("already_locked");
+        ThrowCodeError("already_locked", { current => $self->{private_bz_tables_locked},
+                                           new => $list });
     } else {
         my %read_tables;
         my %write_tables;
@@ -175,7 +177,7 @@ sub bz_lock_tables {
                           ' IN ROW SHARE MODE') if keys %read_tables;
         Bugzilla->dbh->do('LOCK TABLE ' . join(', ', keys %write_tables) .
                           ' IN ROW EXCLUSIVE MODE') if keys %write_tables;
-        $self->{private_bz_tables_locked} = 1;
+        $self->{private_bz_tables_locked} = $list;
     }
 }
 
@@ -188,7 +190,7 @@ sub bz_unlock_tables {
         return if $abort;
         ThrowCodeError("no_matching_lock");
     } else {
-        $self->{private_bz_tables_locked} = 0;
+        $self->{private_bz_tables_locked} = "";
         # End transaction, tables will be unlocked automatically
         if ($abort) {
             $self->bz_rollback_transaction();
index d54163bd847785b49d2432aa0078a9c807286f49..fd3f8fb200835b712eaeb896695744aa55695c70 100644 (file)
     Attempted to end transaction without starting one first.
 
   [% ELSIF error == "already_locked" %]
-    Attempted to lock a table without releasing previous lock first.
+    Attempted to lock a table without releasing previous lock first:
+    <p>Tables already locked:<br>[% current FILTER html %]
+    <p>Tables requesting locking:<br>[% new FILTER html %]
 
   [% ELSIF error == "no_matching_lock" %]
     Attempted to unlock tables without locking them first.