Don't crash if N is > number of index columns.

This commit is contained in:
Daniel Nichter
2012-06-11 07:55:23 -04:00
parent 28637d8c95
commit 583bc2957e
3 changed files with 41 additions and 2 deletions

View File

@@ -9,7 +9,7 @@ BEGIN {
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More tests => 25;
use Test::More tests => 26;
use TableParser;
use TableNibbler;
@@ -325,6 +325,39 @@ is_deeply(
'Use only N left-most columns of the index',
);
is_deeply(
$n->generate_asc_stmt(
tbl_struct => $t,
cols => $t->{cols},
index => 'rental_date',
n_index_cols => 5,
),
{
cols => [qw(rental_id rental_date inventory_id customer_id
return_date staff_id last_update)],
index => 'rental_date',
where => '((`rental_date` > ?) OR (`rental_date` = ? AND `inventory_id` > ?)'
. ' OR (`rental_date` = ? AND `inventory_id` = ? AND `customer_id` >= ?))',
slice => [1, 1, 2, 1, 2, 3],
scols => [qw(rental_date rental_date inventory_id rental_date inventory_id customer_id)],
boundaries => {
'>=' => '((`rental_date` > ?) OR (`rental_date` = ? AND '
. '`inventory_id` > ?) OR (`rental_date` = ? AND `inventory_id` '
. '= ? AND `customer_id` >= ?))',
'>' => '((`rental_date` > ?) OR (`rental_date` = ? AND '
. '`inventory_id` > ?) OR (`rental_date` = ? AND `inventory_id` '
. '= ? AND `customer_id` > ?))',
'<=' => '((`rental_date` < ?) OR (`rental_date` = ? AND '
. '`inventory_id` < ?) OR (`rental_date` = ? AND `inventory_id` '
. '= ? AND `customer_id` <= ?))',
'<' => '((`rental_date` < ?) OR (`rental_date` = ? AND '
. '`inventory_id` < ?) OR (`rental_date` = ? AND `inventory_id` '
. '= ? AND `customer_id` < ?))',
},
},
"Don't crash if N > number of index columns"
);
is_deeply(
$n->generate_asc_stmt(
tbl_struct => $t,

View File

@@ -25,7 +25,7 @@ if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 14;
plan tests => 15;
}
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
@@ -199,6 +199,11 @@ ok(
),
"--chunk-index index:n"
);
pt_table_checksum::main(
$master_dsn, '--max-load', '',
qw(--lock-wait-timeout 3 --chunk-size 5000 -t sakila.rental),
qw(--chunk-index rental_date:5 --explain --explain));
# #############################################################################
# Done.