summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VERSION2
-rw-r--r--cmake/ssl.cmake5
-rwxr-xr-xmysql-test/mysql-test-run.pl15
-rw-r--r--mysql-test/r/ctype_latin1.result9
-rw-r--r--mysql-test/r/index_merge_myisam.result50
-rw-r--r--mysql-test/r/type_newdecimal.result44
-rw-r--r--mysql-test/t/ctype_latin1.test12
-rw-r--r--mysql-test/t/index_merge_myisam.test35
-rw-r--r--mysql-test/t/type_newdecimal.test45
-rw-r--r--sql/opt_range.cc6
-rw-r--r--strings/ctype-simple.c4
-rw-r--r--strings/decimal.c35
12 files changed, 236 insertions, 26 deletions
diff --git a/VERSION b/VERSION
index 2eee908ea01..163137684a2 100644
--- a/VERSION
+++ b/VERSION
@@ -1,3 +1,3 @@
MYSQL_VERSION_MAJOR=10
MYSQL_VERSION_MINOR=0
-MYSQL_VERSION_PATCH=37
+MYSQL_VERSION_PATCH=38
diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake
index c5985a38621..c76e73927c0 100644
--- a/cmake/ssl.cmake
+++ b/cmake/ssl.cmake
@@ -170,7 +170,7 @@ MACRO (MYSQL_CHECK_SSL)
REGEX "^#define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x[0-9].*"
)
STRING(REGEX REPLACE
- "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9]).*$" "\\1"
+ "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9][0-9][0-9]).*$" "\\1"
OPENSSL_MAJOR_VERSION "${OPENSSL_VERSION_NUMBER}"
)
INCLUDE(CheckSymbolExists)
@@ -182,7 +182,8 @@ MACRO (MYSQL_CHECK_SSL)
SET(OPENSSL_FOUND FALSE)
ENDIF()
- IF(OPENSSL_FOUND AND HAVE_SHA512_DIGEST_LENGTH)
+ IF(OPENSSL_FOUND AND OPENSSL_MAJOR_VERSION STRLESS "101" AND
+ HAVE_SHA512_DIGEST_LENGTH)
MESSAGE(STATUS "OPENSSL_INCLUDE_DIR = ${OPENSSL_INCLUDE_DIR}")
MESSAGE(STATUS "OPENSSL_LIBRARIES = ${OPENSSL_LIBRARIES}")
MESSAGE(STATUS "CRYPTO_LIBRARY = ${CRYPTO_LIBRARY}")
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 63801357dd5..0ea628f75e0 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -1152,7 +1152,7 @@ sub command_line_setup {
'debug' => \$opt_debug,
'debug-common' => \$opt_debug_common,
'debug-server' => \$opt_debug_server,
- 'gdb' => \$opt_gdb,
+ 'gdb=s' => \$opt_gdb,
'client-gdb' => \$opt_client_gdb,
'manual-gdb' => \$opt_manual_gdb,
'manual-lldb' => \$opt_manual_lldb,
@@ -1247,6 +1247,9 @@ sub command_line_setup {
'skip-test-list=s' => \@opt_skip_test_list
);
+ # fix options (that take an optional argument and *only* after = sign
+ my %fixopt = ( '--gdb' => '--gdb=#' );
+ @ARGV = map { $fixopt{$_} or $_ } @ARGV;
GetOptions(%options) or usage("Can't read options");
usage("") if $opt_usage;
list_options(\%options) if $opt_list_options;
@@ -6069,7 +6072,9 @@ sub gdb_arguments {
# Put $args into a single string
$input = $input ? "< $input" : "";
- if ($type ne 'client' and $opt_valgrind_mysqld) {
+ if ($type eq 'client') {
+ mtr_tofile($gdb_init_file, "set args @$$args $input");
+ } elsif ($opt_valgrind_mysqld) {
my $v = $$exe;
my $vargs = [];
valgrind_arguments($vargs, \$v);
@@ -6079,7 +6084,11 @@ shell sleep 1
target remote | /usr/lib64/valgrind/../../bin/vgdb
EOF
} else {
- mtr_tofile($gdb_init_file, "set args @$$args $input\n");
+ mtr_tofile($gdb_init_file,
+ join("\n",
+ "set args @$$args $input",
+ split /;/, $opt_gdb || ""
+ ));
}
if ( $opt_manual_gdb )
diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result
index 8913c8082c8..d2e4cc31097 100644
--- a/mysql-test/r/ctype_latin1.result
+++ b/mysql-test/r/ctype_latin1.result
@@ -7963,5 +7963,14 @@ ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
+# MDEV-17298 ASAN unknown-crash / READ of size 1 in my_strntoul_8bit upon INSERT .. SELECT
+#
+SET NAMES latin1;
+CREATE TABLE t1 (a CHAR);
+CREATE TABLE t2 (b ENUM('foo','bar'));
+INSERT INTO t1 VALUES ('1');
+INSERT INTO t2 SELECT * FROM t1;
+DROP TABLE t1, t2;
+#
# End of 10.0 tests
#
diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result
index b3beff5a967..51b764213ca 100644
--- a/mysql-test/r/index_merge_myisam.result
+++ b/mysql-test/r/index_merge_myisam.result
@@ -1712,3 +1712,53 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY,c1,i,c2 NULL NULL NULL 69 Using where
DROP TABLE t1;
set optimizer_switch= @optimizer_switch_save;
+#
+# MDEV-16695: Estimate for rows of derived tables is very high when we are using index_merge union
+#
+create table t0
+(
+key1 int not null,
+INDEX i1(key1)
+);
+insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8);
+set @d=8;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+alter table t0 add key2 int not null, add index i2(key2);
+alter table t0 add key3 int not null, add index i3(key3);
+alter table t0 add key8 int not null, add index i8(key8);
+update t0 set key2=key1,key3=key1,key8=1024-key1;
+analyze table t0;
+Table Op Msg_type Msg_text
+test.t0 analyze status OK
+set @optimizer_switch_save=@@optimizer_switch;
+set optimizer_switch='derived_merge=off,derived_with_keys=off';
+explain select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where
+2 DERIVED t0 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where
+select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+key1 key2 key3 key8
+3 3 3 1021
+set optimizer_use_condition_selectivity=2;
+explain select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where
+2 DERIVED t0 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where
+select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+key1 key2 key3 key8
+3 3 3 1021
+set @@optimizer_switch= @optimizer_switch_save;
+drop table t0;
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index ab075d29e22..5c7693d92c1 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -1997,8 +1997,50 @@ select 0.0000000001 mod 1;
select 0.01 mod 1;
0.01 mod 1
0.01
+CREATE TABLE t1 (
+`FLD1` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD2` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD3` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD4` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD5` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD6` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD7` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD8` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD9` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD10` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD11` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD12` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD13` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD14` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD15` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD16` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD17` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD18` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD19` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD20` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD21` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD22` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD23` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000
+);
+INSERT INTO t1 VALUES (001.0760,000.9500,001.0000,001.0000,001.0000,
+001.0000,001.0000,001.0000,001.0000,001.0000,001.0000,000.5949,001.0194,
+001.0000,001.0000,001.0000,001.0000,001.0000,001.0000,000.9220,001.1890,001.2130,327.2690);
+select FLD1*FLD2*FLD3*FLD4*FLD5*FLD6*FLD7*FLD8*FLD9*FLD10*FLD11*FLD12*FLD13*FLD14*FLD15*FLD16*FLD17*FLD18*FLD19*FLD20*FLD21*FLD22*FLD23 as calc1 from t1;
+calc1
+269.775757576440530322187032000000
+select FLD23*FLD2*FLD1*FLD4*FLD5*FLD11*FLD12*FLD13*FLD3*FLD15*FLD16*FLD17*FLD18*FLD19*FLD20*FLD21*FLD22*FLD14*FLD6*FLD7*FLD8*FLD9*FLD10 as calc2 from t1;
+calc2
+269.775757576440530322187032000000
+DROP TABLE t1;
+CREATE TABLE t1 AS SELECT 1.0 * 2.000;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `1.0 * 2.000` decimal(6,4) NOT NULL DEFAULT '0.0000'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
#
-# Start of 10.0 tests
+# End of 5.5 tests
#
#
# MDEV-6950 Bad results with joins comparing DATE and INT/ENUM/VARCHAR columns
diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test
index da4d76ee2cf..0ec983b8b74 100644
--- a/mysql-test/t/ctype_latin1.test
+++ b/mysql-test/t/ctype_latin1.test
@@ -265,5 +265,17 @@ SET NAMES latin1;
--echo #
+--echo # MDEV-17298 ASAN unknown-crash / READ of size 1 in my_strntoul_8bit upon INSERT .. SELECT
+--echo #
+
+SET NAMES latin1;
+CREATE TABLE t1 (a CHAR);
+CREATE TABLE t2 (b ENUM('foo','bar'));
+INSERT INTO t1 VALUES ('1');
+INSERT INTO t2 SELECT * FROM t1;
+DROP TABLE t1, t2;
+
+
+--echo #
--echo # End of 10.0 tests
--echo #
diff --git a/mysql-test/t/index_merge_myisam.test b/mysql-test/t/index_merge_myisam.test
index d265007431e..75beb9bd883 100644
--- a/mysql-test/t/index_merge_myisam.test
+++ b/mysql-test/t/index_merge_myisam.test
@@ -243,3 +243,38 @@ DROP TABLE t1;
set optimizer_switch= @optimizer_switch_save;
+--echo #
+--echo # MDEV-16695: Estimate for rows of derived tables is very high when we are using index_merge union
+--echo #
+
+create table t0
+(
+ key1 int not null,
+ INDEX i1(key1)
+);
+
+insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8);
+let $1=7;
+set @d=8;
+while ($1)
+{
+ eval insert into t0 select key1+ @d from t0;
+ eval set @d=@d*2;
+ dec $1;
+}
+alter table t0 add key2 int not null, add index i2(key2);
+alter table t0 add key3 int not null, add index i3(key3);
+alter table t0 add key8 int not null, add index i8(key8);
+
+update t0 set key2=key1,key3=key1,key8=1024-key1;
+analyze table t0;
+
+set @optimizer_switch_save=@@optimizer_switch;
+set optimizer_switch='derived_merge=off,derived_with_keys=off';
+explain select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+set optimizer_use_condition_selectivity=2;
+explain select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+set @@optimizer_switch= @optimizer_switch_save;
+drop table t0;
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index 09149253c67..9de132863dc 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -1581,8 +1581,51 @@ select 0.000000000000000000000000000000000000000000000000001 mod 1;
select 0.0000000001 mod 1;
select 0.01 mod 1;
+#
+# MDEV-17256 Decimal field multiplication bug
+#
+
+CREATE TABLE t1 (
+ `FLD1` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD2` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD3` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD4` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD5` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD6` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD7` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD8` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD9` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD10` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD11` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD12` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD13` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD14` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD15` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD16` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD17` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD18` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD19` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD20` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD21` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD22` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD23` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000
+);
+
+INSERT INTO t1 VALUES (001.0760,000.9500,001.0000,001.0000,001.0000,
+ 001.0000,001.0000,001.0000,001.0000,001.0000,001.0000,000.5949,001.0194,
+ 001.0000,001.0000,001.0000,001.0000,001.0000,001.0000,000.9220,001.1890,001.2130,327.2690);
+
+select FLD1*FLD2*FLD3*FLD4*FLD5*FLD6*FLD7*FLD8*FLD9*FLD10*FLD11*FLD12*FLD13*FLD14*FLD15*FLD16*FLD17*FLD18*FLD19*FLD20*FLD21*FLD22*FLD23 as calc1 from t1;
+select FLD23*FLD2*FLD1*FLD4*FLD5*FLD11*FLD12*FLD13*FLD3*FLD15*FLD16*FLD17*FLD18*FLD19*FLD20*FLD21*FLD22*FLD14*FLD6*FLD7*FLD8*FLD9*FLD10 as calc2 from t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT 1.0 * 2.000;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
--echo #
---echo # Start of 10.0 tests
+--echo # End of 5.5 tests
--echo #
--echo #
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 0fd2cd267fc..3bcaa72e32f 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -3725,6 +3725,12 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item *cond)
}
+ if (quick && (quick->get_type() == QUICK_SELECT_I::QS_TYPE_ROR_UNION ||
+ quick->get_type() == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE))
+ {
+ table->cond_selectivity*= (quick->records/table_records);
+ }
+
bitmap_union(used_fields, &handled_columns);
/* Check if we can improve selectivity estimates by using sampling */
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index 61b14b84820..8d12c05db18 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -454,7 +454,6 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs,
register uint cutlim;
register uint32 i;
register const char *s;
- register uchar c;
const char *save, *e;
int overflow;
@@ -489,8 +488,9 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs,
overflow = 0;
i = 0;
- for (c = *s; s != e; c = *++s)
+ for ( ; s != e; ++s)
{
+ register uchar c= *s;
if (c>='0' && c<='9')
c -= '0';
else if (c>='A' && c<='Z')
diff --git a/strings/decimal.c b/strings/decimal.c
index c6898cd099f..bbfb4e9dc8b 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -2078,26 +2078,21 @@ int decimal_mul(const decimal_t *from1, const decimal_t *from2, decimal_t *to)
}
}
- /* Now we have to check for -0.000 case */
- if (to->sign)
+ /* Remove trailing zero words in frac part */
+ frac0= ROUND_UP(to->frac);
+
+ if (frac0 > 0 && to->buf[intg0 + frac0 - 1] == 0)
{
- dec1 *buf= to->buf;
- dec1 *end= to->buf + intg0 + frac0;
- DBUG_ASSERT(buf != end);
- for (;;)
+ do
{
- if (*buf)
- break;
- if (++buf == end)
- {
- /* We got decimal zero */
- decimal_make_zero(to);
- break;
- }
- }
+ frac0--;
+ } while (frac0 > 0 && to->buf[intg0 + frac0 - 1] == 0);
+ to->frac= DIG_PER_DEC1 * frac0;
}
+
+ /* Remove heading zero words in intg part */
buf1= to->buf;
- d_to_move= intg0 + ROUND_UP(to->frac);
+ d_to_move= intg0 + frac0;
while (!*buf1 && (to->intg > DIG_PER_DEC1))
{
buf1++;
@@ -2110,6 +2105,14 @@ int decimal_mul(const decimal_t *from1, const decimal_t *from2, decimal_t *to)
for (; d_to_move--; cur_d++, buf1++)
*cur_d= *buf1;
}
+
+ /* Now we have to check for -0.000 case */
+ if (to->sign && to->frac == 0 && to->buf[0] == 0)
+ {
+ DBUG_ASSERT(to->intg <= DIG_PER_DEC1);
+ /* We got decimal zero */
+ decimal_make_zero(to);
+ }
return error;
}