From: Bernd Bleßmann Date: Wed, 25 Sep 2013 14:51:34 +0000 (+0200) Subject: Row level lock statt table level lock verwenden. X-Git-Tag: release-3.1.0beta1~69^2 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=f3c5ef3b1eb1ca09d3821538500af85f3b1ffcd2;p=kivitendo-erp.git Row level lock statt table level lock verwenden. Betrifft #2368. --- diff --git a/SL/TransNumber.pm b/SL/TransNumber.pm index 9d6d2993a..fb715b8eb 100644 --- a/SL/TransNumber.pm +++ b/SL/TransNumber.pm @@ -113,8 +113,6 @@ sub create_unique { my %filters = $self->_get_filters(); $self->dbh->begin_work if $self->dbh->{AutoCommit}; - do_query($form, $self->dbh, qq|LOCK TABLE defaults|); - do_query($form, $self->dbh, qq|LOCK TABLE business|) if $self->business_id; my $where = $filters{where} ? ' WHERE ' . $filters{where} : ''; my $query = <dbh, $query, $filters{trans_number}, 'in_use'); my $business_number; - ($business_number) = selectfirst_array_query($form, $self->dbh, qq|SELECT customernumberinit FROM business WHERE id = ?|, $self->business_id) if $self->business_id; + ($business_number) = selectfirst_array_query($form, $self->dbh, qq|SELECT customernumberinit FROM business WHERE id = ? FOR UPDATE|, $self->business_id) if $self->business_id; my $number = $business_number; - ($number) = selectfirst_array_query($form, $self->dbh, qq|SELECT $filters{numberfield} FROM defaults|) if !$number; + ($number) = selectfirst_array_query($form, $self->dbh, qq|SELECT $filters{numberfield} FROM defaults FOR UPDATE|) if !$number; if ($filters{numberfield} eq 'assemblynumber' and length($number) < 1) { $filters{numberfield} = 'articlenumber'; - ($number) = selectfirst_array_query($form, $self->dbh, qq|SELECT $filters{numberfield} FROM defaults|) if !$number; + ($number) = selectfirst_array_query($form, $self->dbh, qq|SELECT $filters{numberfield} FROM defaults FOR UPDATE|) if !$number; } $number ||= ''; my $sequence = SL::PrefixedNumber->new(number => $number);