mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 13:40:07 +00:00
Fixed sort order fro ENUM fields
This commit is contained in:
@@ -5415,7 +5415,11 @@ sub new {
|
|||||||
PTDEBUG && _d('Ascend params:', Dumper($asc));
|
PTDEBUG && _d('Ascend params:', Dumper($asc));
|
||||||
|
|
||||||
my $from = "$tbl->{name} FORCE INDEX(`$index`)";
|
my $from = "$tbl->{name} FORCE INDEX(`$index`)";
|
||||||
my $order_by = join(', ', map {$q->quote($_)} @{$index_cols});
|
my $order_by = join(', ', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum'
|
||||||
|
? "CONCAT(".$q->quote($_).")" : $q->quote($_)} @{$index_cols});
|
||||||
|
|
||||||
|
my $order_by_dec = join(' DESC,', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum'
|
||||||
|
? "CONCAT(".$q->quote($_).")" : $q->quote($_)} @{$index_cols});
|
||||||
|
|
||||||
my $first_lb_sql
|
my $first_lb_sql
|
||||||
= "SELECT /*!40001 SQL_NO_CACHE */ "
|
= "SELECT /*!40001 SQL_NO_CACHE */ "
|
||||||
@@ -5447,7 +5451,7 @@ sub new {
|
|||||||
. " FROM $from"
|
. " FROM $from"
|
||||||
. ($where ? " WHERE $where" : '')
|
. ($where ? " WHERE $where" : '')
|
||||||
. " ORDER BY "
|
. " ORDER BY "
|
||||||
. join(' DESC, ', map {$q->quote($_)} @{$index_cols}) . ' DESC'
|
. $order_by_dec . ' DESC'
|
||||||
. " LIMIT 1"
|
. " LIMIT 1"
|
||||||
. " /*last upper boundary*/";
|
. " /*last upper boundary*/";
|
||||||
PTDEBUG && _d('Last upper boundary statement:', $last_ub_sql);
|
PTDEBUG && _d('Last upper boundary statement:', $last_ub_sql);
|
||||||
|
@@ -6222,7 +6222,11 @@ sub new {
|
|||||||
PTDEBUG && _d('Ascend params:', Dumper($asc));
|
PTDEBUG && _d('Ascend params:', Dumper($asc));
|
||||||
|
|
||||||
my $from = "$tbl->{name} FORCE INDEX(`$index`)";
|
my $from = "$tbl->{name} FORCE INDEX(`$index`)";
|
||||||
my $order_by = join(', ', map {$q->quote($_)} @{$index_cols});
|
my $order_by = join(', ', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum'
|
||||||
|
? "CONCAT(".$q->quote($_).")" : $q->quote($_)} @{$index_cols});
|
||||||
|
|
||||||
|
my $order_by_dec = join(' DESC,', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum'
|
||||||
|
? "CONCAT(".$q->quote($_).")" : $q->quote($_)} @{$index_cols});
|
||||||
|
|
||||||
my $first_lb_sql
|
my $first_lb_sql
|
||||||
= "SELECT /*!40001 SQL_NO_CACHE */ "
|
= "SELECT /*!40001 SQL_NO_CACHE */ "
|
||||||
@@ -6254,7 +6258,7 @@ sub new {
|
|||||||
. " FROM $from"
|
. " FROM $from"
|
||||||
. ($where ? " WHERE $where" : '')
|
. ($where ? " WHERE $where" : '')
|
||||||
. " ORDER BY "
|
. " ORDER BY "
|
||||||
. join(' DESC, ', map {$q->quote($_)} @{$index_cols}) . ' DESC'
|
. $order_by_dec . ' DESC'
|
||||||
. " LIMIT 1"
|
. " LIMIT 1"
|
||||||
. " /*last upper boundary*/";
|
. " /*last upper boundary*/";
|
||||||
PTDEBUG && _d('Last upper boundary statement:', $last_ub_sql);
|
PTDEBUG && _d('Last upper boundary statement:', $last_ub_sql);
|
||||||
|
@@ -138,7 +138,11 @@ sub new {
|
|||||||
# ORDER BY are the same for all statements. FORCE IDNEX and ORDER BY
|
# ORDER BY are the same for all statements. FORCE IDNEX and ORDER BY
|
||||||
# are needed to ensure deterministic nibbling.
|
# are needed to ensure deterministic nibbling.
|
||||||
my $from = "$tbl->{name} FORCE INDEX(`$index`)";
|
my $from = "$tbl->{name} FORCE INDEX(`$index`)";
|
||||||
my $order_by = join(', ', map {$q->quote($_)} @{$index_cols});
|
my $order_by = join(', ', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum'
|
||||||
|
? "CONCAT(".$q->quote($_).")" : $q->quote($_)} @{$index_cols});
|
||||||
|
|
||||||
|
my $order_by_dec = join(' DESC,', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum'
|
||||||
|
? "CONCAT(".$q->quote($_).")" : $q->quote($_)} @{$index_cols});
|
||||||
|
|
||||||
# The real first row in the table. Usually we start nibbling from
|
# The real first row in the table. Usually we start nibbling from
|
||||||
# this row. Called once in _get_bounds().
|
# this row. Called once in _get_bounds().
|
||||||
@@ -177,7 +181,7 @@ sub new {
|
|||||||
. " FROM $from"
|
. " FROM $from"
|
||||||
. ($where ? " WHERE $where" : '')
|
. ($where ? " WHERE $where" : '')
|
||||||
. " ORDER BY "
|
. " ORDER BY "
|
||||||
. join(' DESC, ', map {$q->quote($_)} @{$index_cols}) . ' DESC'
|
. $order_by_dec . ' DESC'
|
||||||
. " LIMIT 1"
|
. " LIMIT 1"
|
||||||
. " /*last upper boundary*/";
|
. " /*last upper boundary*/";
|
||||||
PTDEBUG && _d('Last upper boundary statement:', $last_ub_sql);
|
PTDEBUG && _d('Last upper boundary statement:', $last_ub_sql);
|
||||||
|
Reference in New Issue
Block a user