Commit c4804fb4 authored by mkanat%kerio.com's avatar mkanat%kerio.com

Bug 285397: Untested parts of Bugzilla::DB are broken (when running on PostgreSQL)

Patch By Max Kanat-Alexander <mkanat@kerio.com> r=Tomas.Kopal, a=justdave
parent a46f353a
...@@ -478,12 +478,11 @@ sub bz_start_transaction { ...@@ -478,12 +478,11 @@ sub bz_start_transaction {
my ($self) = @_; my ($self) = @_;
if ($self->{private_bz_in_transaction}) { if ($self->{private_bz_in_transaction}) {
carp("Can't start transaction within another transaction");
ThrowCodeError("nested_transaction"); ThrowCodeError("nested_transaction");
} else { } else {
# Turn AutoCommit off and start a new transaction # Turn AutoCommit off and start a new transaction
$self->begin_work(); $self->begin_work();
$self->{privateprivate_bz_in_transaction} = 1; $self->{private_bz_in_transaction} = 1;
} }
} }
...@@ -491,7 +490,6 @@ sub bz_commit_transaction { ...@@ -491,7 +490,6 @@ sub bz_commit_transaction {
my ($self) = @_; my ($self) = @_;
if (!$self->{private_bz_in_transaction}) { if (!$self->{private_bz_in_transaction}) {
carp("Can't commit without a transaction");
ThrowCodeError("not_in_transaction"); ThrowCodeError("not_in_transaction");
} else { } else {
$self->commit(); $self->commit();
...@@ -504,7 +502,6 @@ sub bz_rollback_transaction { ...@@ -504,7 +502,6 @@ sub bz_rollback_transaction {
my ($self) = @_; my ($self) = @_;
if (!$self->{private_bz_in_transaction}) { if (!$self->{private_bz_in_transaction}) {
carp("Can't rollback without a transaction");
ThrowCodeError("not_in_transaction"); ThrowCodeError("not_in_transaction");
} else { } else {
$self->rollback(); $self->rollback();
......
...@@ -42,7 +42,6 @@ package Bugzilla::DB::Mysql; ...@@ -42,7 +42,6 @@ package Bugzilla::DB::Mysql;
use strict; use strict;
use Bugzilla::Error; use Bugzilla::Error;
use Carp;
# This module extends the DB interface via inheritance # This module extends the DB interface via inheritance
use base qw(Bugzilla::DB); use base qw(Bugzilla::DB);
...@@ -149,7 +148,6 @@ sub bz_lock_tables { ...@@ -149,7 +148,6 @@ sub bz_lock_tables {
# Check first if there was no lock before # Check first if there was no lock before
if ($self->{private_bz_tables_locked}) { if ($self->{private_bz_tables_locked}) {
carp("Tables already locked");
ThrowCodeError("already_locked"); ThrowCodeError("already_locked");
} else { } else {
$self->do('LOCK TABLE ' . join(', ', @tables)); $self->do('LOCK TABLE ' . join(', ', @tables));
...@@ -165,7 +163,6 @@ sub bz_unlock_tables { ...@@ -165,7 +163,6 @@ sub bz_unlock_tables {
if (!$self->{private_bz_tables_locked}) { if (!$self->{private_bz_tables_locked}) {
# Abort is allowed even without previous lock for error handling # Abort is allowed even without previous lock for error handling
return if $abort; return if $abort;
carp("No matching lock");
ThrowCodeError("no_matching_lock"); ThrowCodeError("no_matching_lock");
} else { } else {
$self->do("UNLOCK TABLES"); $self->do("UNLOCK TABLES");
......
...@@ -42,7 +42,6 @@ package Bugzilla::DB::Pg; ...@@ -42,7 +42,6 @@ package Bugzilla::DB::Pg;
use strict; use strict;
use Bugzilla::Error; use Bugzilla::Error;
use Carp;
# This module extends the DB interface via inheritance # This module extends the DB interface via inheritance
use base qw(Bugzilla::DB); use base qw(Bugzilla::DB);
...@@ -146,7 +145,6 @@ sub bz_lock_tables { ...@@ -146,7 +145,6 @@ sub bz_lock_tables {
# Check first if there was no lock before # Check first if there was no lock before
if ($self->{private_bz_tables_locked}) { if ($self->{private_bz_tables_locked}) {
carp("Tables already locked");
ThrowCodeError("already_locked"); ThrowCodeError("already_locked");
} else { } else {
my %read_tables; my %read_tables;
...@@ -173,6 +171,7 @@ sub bz_lock_tables { ...@@ -173,6 +171,7 @@ sub bz_lock_tables {
' IN ROW SHARE MODE') if keys %read_tables; ' IN ROW SHARE MODE') if keys %read_tables;
Bugzilla->dbh->do('LOCK TABLE ' . join(', ', keys %write_tables) . Bugzilla->dbh->do('LOCK TABLE ' . join(', ', keys %write_tables) .
' IN ROW EXCLUSIVE MODE') if keys %write_tables; ' IN ROW EXCLUSIVE MODE') if keys %write_tables;
$self->{private_bz_tables_locked} = 1;
} }
} }
...@@ -183,10 +182,9 @@ sub bz_unlock_tables { ...@@ -183,10 +182,9 @@ sub bz_unlock_tables {
if (!$self->{private_bz_tables_locked}) { if (!$self->{private_bz_tables_locked}) {
# Abort is allowed even without previous lock for error handling # Abort is allowed even without previous lock for error handling
return if $abort; return if $abort;
carp("No matching lock");
ThrowCodeError("no_matching_lock"); ThrowCodeError("no_matching_lock");
} else { } else {
$self->{private_bz_tables_locked} = 0;
# End transaction, tables will be unlocked automatically # End transaction, tables will be unlocked automatically
if ($abort) { if ($abort) {
$self->bz_rollback_transaction(); $self->bz_rollback_transaction();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment