From f3c5ef3b1eb1ca09d3821538500af85f3b1ffcd2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Wed, 25 Sep 2013 16:51:34 +0200 Subject: [PATCH] Row level lock statt table level lock verwenden. Betrifft #2368. --- SL/TransNumber.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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); -- 2.20.1