PT-1572 Fixed issue with --chunk-index-columns

This commit is contained in:
Carlos Salguero
2018-08-09 13:58:31 -03:00
parent 03ff3c314a
commit 8c806df658
4 changed files with 43 additions and 12 deletions

View File

@@ -5521,7 +5521,10 @@ sub new {
PTDEBUG && _d('Ascend params:', Dumper($asc)); PTDEBUG && _d('Ascend params:', Dumper($asc));
my $force_concat_enums = $o->has('force-concat-enums') && $o->get('force-concat-enums'); my $force_concat_enums = $o->has('force-concat-enums') && $o->get('force-concat-enums');
my $i=0;
for my $index (@{$index_cols}) { for my $index (@{$index_cols}) {
last if $args{n_chunk_index_cols} && $i >= $args{n_chunk_index_cols};
$i++;
if ($tbl->{tbl_struct}->{type_for}->{$index} eq 'enum') { if ($tbl->{tbl_struct}->{type_for}->{$index} eq 'enum') {
if ($tbl->{tbl_struct}->{defs}->{$index} =~ m/enum\s*\((.*?)\)/) { if ($tbl->{tbl_struct}->{defs}->{$index} =~ m/enum\s*\((.*?)\)/) {
my @items = split(/,\s*/, $1); my @items = split(/,\s*/, $1);

View File

@@ -6372,7 +6372,10 @@ sub new {
PTDEBUG && _d('Ascend params:', Dumper($asc)); PTDEBUG && _d('Ascend params:', Dumper($asc));
my $force_concat_enums = $o->has('force-concat-enums') && $o->get('force-concat-enums'); my $force_concat_enums = $o->has('force-concat-enums') && $o->get('force-concat-enums');
my $i=0;
for my $index (@{$index_cols}) { for my $index (@{$index_cols}) {
last if $args{n_chunk_index_cols} && $i >= $args{n_chunk_index_cols};
$i++;
if ($tbl->{tbl_struct}->{type_for}->{$index} eq 'enum') { if ($tbl->{tbl_struct}->{type_for}->{$index} eq 'enum') {
if ($tbl->{tbl_struct}->{defs}->{$index} =~ m/enum\s*\((.*?)\)/) { if ($tbl->{tbl_struct}->{defs}->{$index} =~ m/enum\s*\((.*?)\)/) {
my @items = split(/,\s*/, $1); my @items = split(/,\s*/, $1);

View File

@@ -137,7 +137,10 @@ sub new {
# Check if enum fields items are sorted or not. # Check if enum fields items are sorted or not.
# If they are sorted we can skip adding CONCAT to improve the queries eficiency. # If they are sorted we can skip adding CONCAT to improve the queries eficiency.
my $force_concat_enums = $o->has('force-concat-enums') && $o->get('force-concat-enums'); my $force_concat_enums = $o->has('force-concat-enums') && $o->get('force-concat-enums');
my $i=0;
for my $index (@{$index_cols}) { for my $index (@{$index_cols}) {
last if $args{n_chunk_index_cols} && $i >= $args{n_chunk_index_cols};
$i++;
if ($tbl->{tbl_struct}->{type_for}->{$index} eq 'enum') { if ($tbl->{tbl_struct}->{type_for}->{$index} eq 'enum') {
if ($tbl->{tbl_struct}->{defs}->{$index} =~ m/enum\s*\((.*?)\)/) { if ($tbl->{tbl_struct}->{defs}->{$index} =~ m/enum\s*\((.*?)\)/) {
my @items = split(/,\s*/, $1); my @items = split(/,\s*/, $1);

View File

@@ -67,6 +67,7 @@ my $in = "/t/lib/samples/NibbleIterator/";
sub make_nibble_iter { sub make_nibble_iter {
my (%args) = @_; my (%args) = @_;
if (my $file = $args{sql_file}) { if (my $file = $args{sql_file}) {
$sb->load_file('master', "$in/$file"); $sb->load_file('master', "$in/$file");
} }
@@ -85,18 +86,19 @@ sub make_nibble_iter {
1 while $si->next(); 1 while $si->next();
my $ni = new NibbleIterator( my $ni = new NibbleIterator(
Cxn => $cxn, Cxn => $cxn,
tbl => $schema->get_table(lc($args{db}), lc($args{tbl})), tbl => $schema->get_table(lc($args{db}), lc($args{tbl})),
chunk_size => $o->get('chunk-size'), chunk_size => $o->get('chunk-size'),
chunk_index => $o->get('chunk-index'), chunk_index => $o->get('chunk-index'),
callbacks => $args{callbacks}, callbacks => $args{callbacks},
select => $args{select}, select => $args{select},
one_nibble => $args{one_nibble}, one_nibble => $args{one_nibble},
resume => $args{resume}, resume => $args{resume},
order_by => $args{order_by}, order_by => $args{order_by},
comments => $args{comments}, comments => $args{comments},
pause_file => $o->get('pause-file'), n_chunk_index_cols => $o->get('chunk-index-columns'),
sleep => $args{sleep} || 60, pause_file => $o->get('pause-file'),
sleep => $args{sleep} || 60,
%common_modules, %common_modules,
); );
@@ -944,6 +946,26 @@ like(
"PT-1572 Don't use CONCAT for sorted ENUM field items without --force-concat-enums", "PT-1572 Don't use CONCAT for sorted ENUM field items without --force-concat-enums",
); );
eval {
$ni = make_nibble_iter(
db => 'test',
tbl => 't1',
argv => [qw(--databases test --chunk-size 3 --chunk-index-columns 2)],
);
};
is(
$EVAL_ERROR,
'',
"PT-1572 No errors on unsorted enum items in index and --chunk-index-columns",
);
like(
$ni->{explain_first_lb_sql},
qr/ORDER BY `f1`, `f2`, `f3`/,
"PT-1572 Don't use CONCAT for sorted ENUM field items without --force-concat-enums & --chunk-index-columns",
);
# ############################################################################# # #############################################################################
# Done. # Done.
# ############################################################################# # #############################################################################