View | Details | Raw Unified | Return to bug 28966
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_32966.pl (+18 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "28966",
5
    description => "Holds queue view too slow to load for large numbers of holds",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        unless ( primary_key_exists( 'tmp_holdsqueue', 'itemnumber' ) ) {
11
            $dbh->do(
12
                q{ALTER TABLE tmp_holdsqueue ADD PRIMARY KEY (itemnumber)}
13
            );
14
        }
15
16
        say $out "Set primary key for table 'tmp_holdsqueue' to 'itemnumber'";
17
    },
18
};
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 5885-5890 CREATE TABLE `tmp_holdsqueue` ( Link Here
5885
  `notes` mediumtext DEFAULT NULL,
5885
  `notes` mediumtext DEFAULT NULL,
5886
  `item_level_request` tinyint(4) NOT NULL DEFAULT 0,
5886
  `item_level_request` tinyint(4) NOT NULL DEFAULT 0,
5887
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this entry as added/last updated',
5887
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this entry as added/last updated',
5888
  PRIMARY KEY (`itemnumber`),
5888
  KEY `tmp_holdsqueue_ibfk_1` (`itemnumber`),
5889
  KEY `tmp_holdsqueue_ibfk_1` (`itemnumber`),
5889
  KEY `tmp_holdsqueue_ibfk_2` (`biblionumber`),
5890
  KEY `tmp_holdsqueue_ibfk_2` (`biblionumber`),
5890
  KEY `tmp_holdsqueue_ibfk_3` (`borrowernumber`),
5891
  KEY `tmp_holdsqueue_ibfk_3` (`borrowernumber`),
(-)a/t/db_dependent/TestBuilder.t (-13 / +9 lines)
Lines 285-291 subtest 'Test build with NULL values' => sub { Link Here
285
285
286
286
287
subtest 'Tests for delete method' => sub {
287
subtest 'Tests for delete method' => sub {
288
    plan tests => 12;
288
    plan tests => 11;
289
289
290
    $schema->storage->txn_begin;
290
    $schema->storage->txn_begin;
291
291
Lines 304-326 subtest 'Tests for delete method' => sub { Link Here
304
304
305
305
306
    # Test delete in table without primary key (..)
306
    # Test delete in table without primary key (..)
307
    is( $schema->source('TmpHoldsqueue')->primary_columns, 0,
307
    is( $schema->source('AccountCreditTypesBranch')->primary_columns, 0,
308
        'Table without primary key detected' );
308
        'Table without primary key detected' );
309
    my $bibno = $builder->build_sample_biblio->biblionumber;
309
    my $cnt1 = $schema->resultset('AccountCreditTypesBranch')->count;
310
    my $cnt1 = $schema->resultset('TmpHoldsqueue')->count;
310
    # Insert a new record in AccountCreditTypesBranch with that biblionumber
311
    # Insert a new record in TmpHoldsqueue with that biblionumber
311
    my $rec = $builder->build({ source => 'AccountCreditTypesBranch' });
312
    my $val = { biblionumber => $bibno };
312
    my $cnt2 = $schema->resultset('AccountCreditTypesBranch')->count;
313
    my $rec = $builder->build({ source => 'TmpHoldsqueue', value => $val });
314
    my $cnt2 = $schema->resultset('TmpHoldsqueue')->count;
315
    is( defined($rec) && $cnt2 == $cnt1 + 1 , 1, 'Created a record' );
313
    is( defined($rec) && $cnt2 == $cnt1 + 1 , 1, 'Created a record' );
316
    is( $builder->delete({ source => 'TmpHoldsqueue', records => $rec }),
314
    is( $builder->delete({ source => 'AccountCreditTypesBranch', records => $rec }),
317
        undef, 'delete returns undef' );
315
        undef, 'delete returns undef' );
318
    is( $rec->{biblionumber}, $bibno, 'Hash value untouched' );
316
    is( $schema->resultset('AccountCreditTypesBranch')->count, $cnt2,
319
    is( $schema->resultset('TmpHoldsqueue')->count, $cnt2,
320
        "Method did not delete record in table without PK" );
317
        "Method did not delete record in table without PK" );
321
318
322
    # Test delete with NULL values
319
    # Test delete with NULL values
323
    $val = { branchcode => undef };
320
    my $val = { branchcode => undef };
324
    is( $builder->delete({ source => 'Branch', records => $val }), 0,
321
    is( $builder->delete({ source => 'Branch', records => $val }), 0,
325
        'delete returns zero for an undef search with one key' );
322
        'delete returns zero for an undef search with one key' );
326
    $val = { module_bit => 1, #catalogue
323
    $val = { module_bit => 1, #catalogue
327
- 

Return to bug 28966