summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2021-07-21 20:11:07 +0200
committerSergei Golubchik <serg@mariadb.org>2021-07-21 20:11:07 +0200
commit6190a02f3593f82e2d4916ed660afb5e5d631a5a (patch)
treef6fc56fd7aad1a332f9fc6850b2d579198d09ff8
parentcf6d83e7d68bd2bc0af0404bf4dd15218847074d (diff)
parent4c387945f0f8d5df84ae987c4a4bba7675815c72 (diff)
downloadmariadb-git-6190a02f3593f82e2d4916ed660afb5e5d631a5a.tar.gz
Merge branch '10.2' into 10.3
-rw-r--r--cmake/for_clients.cmake2
-rw-r--r--debian/control4
-rw-r--r--extra/innochecksum.cc32
-rw-r--r--extra/mariabackup/innobackupex.cc2
-rw-r--r--extra/mariabackup/xtrabackup.cc2
m---------libmariadb0
-rwxr-xr-xmysql-test/dgcov.pl38
-rw-r--r--mysql-test/lib/My/SafeProcess.pm18
-rw-r--r--mysql-test/lib/mtr_process.pl8
-rw-r--r--mysql-test/main/cte_nonrecursive.result67
-rw-r--r--mysql-test/main/cte_nonrecursive.test50
-rw-r--r--mysql-test/main/cte_recursive.result27
-rw-r--r--mysql-test/main/cte_recursive.test21
-rw-r--r--mysql-test/main/mysql_client_test.result5
-rw-r--r--mysql-test/main/mysql_client_test.test4
-rw-r--r--mysql-test/main/order_by_innodb.result52
-rw-r--r--mysql-test/main/order_by_innodb.test51
-rw-r--r--mysql-test/main/selectivity_innodb.result51
-rw-r--r--mysql-test/main/selectivity_innodb.test55
-rw-r--r--mysql-test/main/selectivity_no_engine.result20
-rw-r--r--mysql-test/main/selectivity_no_engine.test21
-rw-r--r--mysql-test/main/skip_name_resolve.result22
-rw-r--r--mysql-test/main/skip_name_resolve.test26
-rw-r--r--mysql-test/main/win.result287
-rw-r--r--mysql-test/main/win.test147
-rwxr-xr-xmysql-test/mysql-test-run.pl111
-rw-r--r--mysql-test/suite/binlog/include/binlog.test18
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_binlog.result23
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_binlog.result24
-rw-r--r--mysql-test/suite/encryption/r/tempfiles_encrypted.result287
-rw-r--r--mysql-test/suite/encryption/t/innodb_encryption_filekeys.test18
-rw-r--r--mysql-test/suite/gcol/inc/gcol_ins_upd.inc74
-rw-r--r--mysql-test/suite/gcol/inc/gcol_keys.inc2
-rw-r--r--mysql-test/suite/gcol/inc/gcol_partition.inc16
-rw-r--r--mysql-test/suite/gcol/inc/gcol_view.inc55
-rw-r--r--mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result220
-rw-r--r--mysql-test/suite/gcol/r/gcol_ins_upd_myisam.result70
-rw-r--r--mysql-test/suite/gcol/r/gcol_keys_innodb.result2
-rw-r--r--mysql-test/suite/gcol/r/gcol_keys_myisam.result2
-rw-r--r--mysql-test/suite/gcol/r/gcol_partition_innodb.result15
-rw-r--r--mysql-test/suite/gcol/r/gcol_partition_myisam.result15
-rw-r--r--mysql-test/suite/gcol/r/gcol_view_innodb.result41
-rw-r--r--mysql-test/suite/gcol/r/gcol_view_myisam.result41
-rw-r--r--mysql-test/suite/gcol/t/gcol_ins_upd_innodb.test2
-rw-r--r--mysql-test/suite/roles/set_default_role_for.result4
-rw-r--r--mysql-test/suite/roles/set_default_role_invalid.result6
-rw-r--r--mysql-test/suite/roles/set_role-recursive.result2
-rw-r--r--mysql-test/suite/rpl/r/create_or_replace_mix.result3
-rw-r--r--mysql-test/suite/rpl/r/create_or_replace_row.result3
-rw-r--r--mysql-test/suite/rpl/r/create_or_replace_statement.result2
-rw-r--r--mysql-test/suite/vcol/r/binlog.result14
-rw-r--r--mysql-test/suite/vcol/t/binlog.test14
-rw-r--r--scripts/mysqld_safe.sh4
-rw-r--r--sql/field.cc10
-rw-r--r--sql/ha_partition.cc3
-rw-r--r--sql/item.h7
-rw-r--r--sql/key.cc2
-rw-r--r--sql/sql_acl.cc9
-rw-r--r--sql/sql_admin.cc4
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_class.cc4
-rw-r--r--sql/sql_cte.cc19
-rw-r--r--sql/sql_insert.cc9
-rw-r--r--sql/sql_prepare.cc7
-rw-r--r--sql/sql_select.cc45
-rw-r--r--sql/sql_union.cc32
-rw-r--r--sql/sql_update.cc2
-rw-r--r--sql/sql_window.cc12
-rw-r--r--sql/sql_window.h5
-rw-r--r--sql/sql_yacc.yy46
-rw-r--r--sql/sql_yacc_ora.yy46
-rw-r--r--sql/table.cc49
-rw-r--r--sql/table.h5
-rw-r--r--storage/innobase/trx/trx0trx.cc2
-rw-r--r--storage/spider/mysql-test/spider/include/init_master_1.inc5
-rw-r--r--storage/spider/mysql-test/spider/r/spider_fixes_part.result34
-rw-r--r--storage/spider/mysql-test/spider/t/spider_fixes_part.test35
-rw-r--r--storage/spider/spd_db_conn.cc42
-rw-r--r--support-files/CMakeLists.txt2
-rw-r--r--tests/mysql_client_test.c66
80 files changed, 2383 insertions, 221 deletions
diff --git a/cmake/for_clients.cmake b/cmake/for_clients.cmake
index 2c2c965df64..27b1430f33e 100644
--- a/cmake/for_clients.cmake
+++ b/cmake/for_clients.cmake
@@ -21,7 +21,7 @@ MACRO(EXTRACT_LINK_LIBRARIES target var)
FOREACH(lib ${${target}_LIB_DEPENDS})
# Filter out "general", it is not a library, just CMake hint
# Also, remove duplicates
- IF(NOT lib STREQUAL "general" AND NOT ${var} MATCHES "-l${lib} ")
+ IF(NOT lib STREQUAL "general" AND NOT ${var} MATCHES "-l${lib} " AND NOT lib STREQUAL "zlib")
IF (lib MATCHES "^\\-")
SET(${var} "${${var}} ${lib} ")
ELSEIF(lib MATCHES "^/")
diff --git a/debian/control b/debian/control
index 1510a858816..be8d2b87506 100644
--- a/debian/control
+++ b/debian/control
@@ -224,14 +224,14 @@ Architecture: all
Depends: mysql-common,
${misc:Depends},
${shlibs:Depends}
-Description: MariaDB database common files (e.g. /etc/mysql/conf.d/mariadb.cnf)
+Description: MariaDB database common files (e.g. /etc/mysql/mariadb.conf.d/)
MariaDB is a fast, stable and true multi-user, multi-threaded SQL database
server. SQL (Structured Query Language) is the most popular database query
language in the world. The main goals of MariaDB are speed, robustness and
ease of use.
.
This package includes files needed by all versions of the client library
- (e.g. /etc/mysql/conf.d/mariadb.cnf).
+ (e.g. /etc/mysql/mariadb.conf.d/ or /etc/mysql/mariadb.cnf).
Package: mariadb-client-core-10.3
Architecture: any
diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc
index 583a0db04f9..1af2d6e54a4 100644
--- a/extra/innochecksum.cc
+++ b/extra/innochecksum.cc
@@ -815,6 +815,16 @@ write_file(
return(true);
}
+// checks using current xdes page whether the page is free
+static bool page_is_free(const byte *xdes, page_size_t page_size,
+ ulonglong page_no)
+{
+ const byte *des=
+ xdes + XDES_ARR_OFFSET +
+ XDES_SIZE * ((page_no & (page_size.physical() - 1)) / FSP_EXTENT_SIZE);
+ return xdes_get_bit(des, XDES_FREE_BIT, page_no % FSP_EXTENT_SIZE);
+}
+
/*
Parse the page and collect/dump the information about page type
@param [in] page buffer page
@@ -900,17 +910,8 @@ parse_page(
}
/* update per-index statistics */
{
- if (index_ids.count(id) == 0) {
- index_ids[id] = per_index_stats();
- }
- std::map<unsigned long long, per_index_stats>::iterator it;
- it = index_ids.find(id);
- per_index_stats &index = (it->second);
- const byte* des = xdes + XDES_ARR_OFFSET
- + XDES_SIZE * ((page_no & (page_size.physical() - 1))
- / FSP_EXTENT_SIZE);
- if (xdes_get_bit(des, XDES_FREE_BIT,
- page_no % FSP_EXTENT_SIZE)) {
+ per_index_stats &index = index_ids[id];
+ if (page_is_free(xdes, page_size, page_no)) {
index.free_pages++;
return;
}
@@ -1048,7 +1049,6 @@ parse_page(
case FIL_PAGE_TYPE_FSP_HDR:
page_type.n_fil_page_type_fsp_hdr++;
- memcpy(xdes, page, page_size.physical());
if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tFile Space "
"Header\t\t|\t%s\n", cur_page_num, str);
@@ -1057,7 +1057,6 @@ parse_page(
case FIL_PAGE_TYPE_XDES:
page_type.n_fil_page_type_xdes++;
- memcpy(xdes, page, page_size.physical());
if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tExtent descriptor "
"page\t\t|\t%s\n", cur_page_num, str);
@@ -1784,6 +1783,8 @@ int main(
printf("page %llu ", cur_page_num);
}
+ memcpy(xdes, buf, physical_page_size);
+
if (page_type_summary || page_type_dump) {
parse_page(buf, xdes, fil_page_type, page_size, is_encrypted);
}
@@ -1962,6 +1963,7 @@ first_non_zero:
/* If no-check is enabled, skip the
checksum verification.*/
if (!no_check
+ && !page_is_free(xdes, page_size, cur_page_num)
&& !skip_page
&& (exit_status = verify_checksum(
buf, page_size,
@@ -1984,6 +1986,10 @@ first_non_zero:
printf("page %llu ", cur_page_num);
}
+ if (page_get_page_no(buf) % physical_page_size == 0) {
+ memcpy(xdes, buf, physical_page_size);
+ }
+
if (page_type_summary || page_type_dump) {
parse_page(buf, xdes, fil_page_type, page_size, is_encrypted);
}
diff --git a/extra/mariabackup/innobackupex.cc b/extra/mariabackup/innobackupex.cc
index 324bd9a4b14..0a963c25ee3 100644
--- a/extra/mariabackup/innobackupex.cc
+++ b/extra/mariabackup/innobackupex.cc
@@ -307,7 +307,7 @@ static struct my_option ibx_long_options[] =
{"force-non-empty-directories", OPT_FORCE_NON_EMPTY_DIRS, "This "
"option, when specified, makes --copy-back or --move-back transfer "
"files to non-empty directories. Note that no existing files will be "
- "overwritten. If --copy-back or --nove-back has to copy a file from "
+ "overwritten. If --copy-back or --move-back has to copy a file from "
"the backup directory which already exists in the destination "
"directory, it will still fail with an error.",
(uchar *) &opt_ibx_force_non_empty_dirs,
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index aa0f62fefaa..3ab9a5f7c9f 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -1277,7 +1277,7 @@ struct my_option xb_client_options[]= {
"This "
"option, when specified, makes --copy-back or --move-back transfer "
"files to non-empty directories. Note that no existing files will be "
- "overwritten. If --copy-back or --nove-back has to copy a file from "
+ "overwritten. If --copy-back or --move-back has to copy a file from "
"the backup directory which already exists in the destination "
"directory, it will still fail with an error.",
(uchar *) &opt_force_non_empty_dirs, (uchar *) &opt_force_non_empty_dirs,
diff --git a/libmariadb b/libmariadb
-Subproject 802ce584a26fdc0ba67fcf35e277bf3c7440956
+Subproject 7d3d7c5ff4a9772cf6c73901757d6e39c6a20e9
diff --git a/mysql-test/dgcov.pl b/mysql-test/dgcov.pl
index fbc5540e697..2c00c64d1ff 100755
--- a/mysql-test/dgcov.pl
+++ b/mysql-test/dgcov.pl
@@ -155,32 +155,34 @@ END
sub gcov_one_file {
return unless /\.gcda$/;
unless ($opt_skip_gcov) {
- $cmd= "gcov -i '$_' 2>/dev/null >/dev/null";
+ $cmd= "gcov -il '$_' 2>/dev/null >/dev/null";
print STDERR ++$file_no,"\r" if not $opt_verbose and -t STDERR;
logv "Running: $cmd";
system($cmd)==0 or die "system($cmd): $? $!";
}
# now, read the generated file
- open FH, '<', "$_.gcov" or die "open(<$_.gcov): $!";
- my $fname;
- while (<FH>) {
- chomp;
- if (/^function:/) {
- next;
- }
- if (/^file:/) {
- $fname=realpath($');
- next;
- }
- next if /^lcount:\d+,-\d+/; # whatever that means
- unless (/^lcount:(\d+),(\d+)/ and $fname) {
- warn "unknown line '$_' after running '$cmd'";
- next;
+ for my $gcov_file (<$_*.gcov>) {
+ open FH, '<', "$gcov_file" or die "open(<$gcov_file): $!";
+ my $fname;
+ while (<FH>) {
+ chomp;
+ if (/^function:/) {
+ next;
+ }
+ if (/^file:/) {
+ $fname=realpath(-f $' ? $' : $root.$');
+ next;
+ }
+ next if /^lcount:\d+,-\d+/; # whatever that means
+ unless (/^lcount:(\d+),(\d+)/ and $fname) {
+ warn "unknown line '$_' in $gcov_file";
+ next;
+ }
+ $cov{$fname}->{$1}+=$2;
}
- $cov{$fname}->{$1}+=$2;
+ close(FH);
}
- close(FH);
}
sub write_coverage {
diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm
index 4f7464daf44..30c8fe54642 100644
--- a/mysql-test/lib/My/SafeProcess.pm
+++ b/mysql-test/lib/My/SafeProcess.pm
@@ -395,10 +395,10 @@ sub _collect {
# 1 Still running
#
sub wait_one {
- my ($self, $timeout)= @_;
- croak "usage: \$safe_proc->wait_one([timeout])" unless ref $self;
+ my ($self, $timeout, $keep)= @_;
+ croak "usage: \$safe_proc->wait_one([timeout] [, keep])" unless ref $self;
- _verbose("wait_one $self, $timeout");
+ _verbose("wait_one $self, $timeout, $keep");
if ( ! defined($self->{SAFE_PID}) ) {
# No pid => not running
@@ -472,16 +472,16 @@ sub wait_one {
return 1;
}
- if ( not $blocking and $retpid == -1 ) {
- # still running
- _verbose("still running");
- return 1;
- }
+ #if ( not $blocking and $retpid == -1 ) {
+ # # still running
+ # _verbose("still running");
+ # return 1;
+ #}
#warn "wait_one: expected pid $pid but got $retpid"
# unless( $retpid == $pid );
- $self->_collect($exit_code);
+ $self->_collect($exit_code) unless $keep;
return 0;
}
diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl
index cee9f2b6ed6..2ff78c0e10a 100644
--- a/mysql-test/lib/mtr_process.pl
+++ b/mysql-test/lib/mtr_process.pl
@@ -40,7 +40,7 @@ BEGIN
eval 'sub USE_NETPING { $use_netping }';
}
-sub sleep_until_file_created ($$$$);
+sub sleep_until_file_created ($$$$$);
sub mtr_ping_port ($);
sub mtr_ping_port ($) {
@@ -102,8 +102,9 @@ sub mtr_ping_port ($) {
# FIXME check that the pidfile contains the expected pid!
-sub sleep_until_file_created ($$$$) {
+sub sleep_until_file_created ($$$$$) {
my $pidfile= shift;
+ my $expectfile = shift;
my $timeout= shift;
my $proc= shift;
my $warn_seconds = shift;
@@ -120,8 +121,9 @@ sub sleep_until_file_created ($$$$) {
my $seconds= ($loop * $sleeptime) / 1000;
# Check if it died after the fork() was successful
- if ( defined $proc and ! $proc->wait_one(0) )
+ if ( defined $proc and ! $proc->wait_one(0, 1) )
{
+ return 1 if -r $expectfile;
mtr_warning("Process $proc died after mysql-test-run waited $seconds " .
"seconds for $pidfile to be created.");
return 0;
diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result
index 550864b20c6..2c3555755cd 100644
--- a/mysql-test/main/cte_nonrecursive.result
+++ b/mysql-test/main/cte_nonrecursive.result
@@ -2019,6 +2019,73 @@ drop procedure sp1;
drop procedure sp2;
drop procedure sp3;
drop table t1;
+#
+# MDEV-26095: missing RECURSIVE for the recursive definition of CTE
+# embedded into another CTE definition
+#
+create table t1 (a int);
+insert into t1 values (5), (7);
+with cte_e as (
+with recursive cte_r as (
+select a from t1 union select a+1 as a from cte_r r where a < 10
+) select * from cte_r
+) select * from cte_e;
+a
+5
+7
+6
+8
+9
+10
+with cte_e as (
+with cte_r as (
+select a from t1 union select a+1 as a from cte_r r where a < 10
+) select * from cte_r
+) select * from cte_e;
+ERROR 42S02: Table 'test.cte_r' doesn't exist
+drop table t1;
+#
+# MDEV-26025: query with two usage of a CTE executing via PS /SP
+#
+create table t1 (a int, b int);
+insert into t1 value (1,3), (3,2), (1,3), (4,1);
+prepare stmt from "with
+cte1 as ( select a,b from t1 where a = 1 AND b = 3 ),
+cte2 as ( select a,b from cte1 ),
+cte3 as ( select a,b from cte2 )
+select * from cte3, cte2";
+execute stmt;
+a b a b
+1 3 1 3
+1 3 1 3
+1 3 1 3
+1 3 1 3
+execute stmt;
+a b a b
+1 3 1 3
+1 3 1 3
+1 3 1 3
+1 3 1 3
+deallocate prepare stmt;
+create procedure sp() with
+cte1 as ( select a,b from t1 where a = 1 AND b = 3 ),
+cte2 as ( select a,b from cte1 ),
+cte3 as ( select a,b from cte2 )
+select * from cte3, cte2;
+call sp();
+a b a b
+1 3 1 3
+1 3 1 3
+1 3 1 3
+1 3 1 3
+call sp();
+a b a b
+1 3 1 3
+1 3 1 3
+1 3 1 3
+1 3 1 3
+drop procedure sp;
+drop table t1;
# End of 10.2 tests
#
# MDEV-21673: several references to CTE that uses
diff --git a/mysql-test/main/cte_nonrecursive.test b/mysql-test/main/cte_nonrecursive.test
index ac74683ad44..dfb14e65f2c 100644
--- a/mysql-test/main/cte_nonrecursive.test
+++ b/mysql-test/main/cte_nonrecursive.test
@@ -1492,6 +1492,56 @@ drop procedure sp3;
drop table t1;
+--echo #
+--echo # MDEV-26095: missing RECURSIVE for the recursive definition of CTE
+--echo # embedded into another CTE definition
+--echo #
+
+create table t1 (a int);
+insert into t1 values (5), (7);
+
+with cte_e as (
+ with recursive cte_r as (
+ select a from t1 union select a+1 as a from cte_r r where a < 10
+ ) select * from cte_r
+) select * from cte_e;
+
+--ERROR ER_NO_SUCH_TABLE
+with cte_e as (
+ with cte_r as (
+ select a from t1 union select a+1 as a from cte_r r where a < 10
+ ) select * from cte_r
+) select * from cte_e;
+
+drop table t1;
+
+--echo #
+--echo # MDEV-26025: query with two usage of a CTE executing via PS /SP
+--echo #
+
+create table t1 (a int, b int);
+insert into t1 value (1,3), (3,2), (1,3), (4,1);
+
+let $q=
+with
+ cte1 as ( select a,b from t1 where a = 1 AND b = 3 ),
+ cte2 as ( select a,b from cte1 ),
+ cte3 as ( select a,b from cte2 )
+select * from cte3, cte2;
+
+eval prepare stmt from "$q";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+eval create procedure sp() $q;
+
+call sp();
+call sp();
+
+drop procedure sp;
+drop table t1;
+
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result
index 21c6b225a89..50d3e889c4c 100644
--- a/mysql-test/main/cte_recursive.result
+++ b/mysql-test/main/cte_recursive.result
@@ -4500,6 +4500,33 @@ deallocate prepare stmt;
drop table folks;
set big_tables=@save_big_tables;
#
+# MDEV-26135: execution of PS for query with hanging recursive CTE
+#
+create table t1 (a int);
+insert into t1 values (5), (7);
+create table t2 (b int);
+insert into t2 values (3), (7), (1);
+with recursive r as (select a from t1 union select a+1 from r where a < 10)
+select * from t2;
+b
+3
+7
+1
+prepare stmt from "with recursive r as (select a from t1 union select a+1 from r where a < 10)
+select * from t2";
+execute stmt;
+b
+3
+7
+1
+execute stmt;
+b
+3
+7
+1
+deallocate prepare stmt;
+drop table t1,t2;
+#
# End of 10.2 tests
#
#
diff --git a/mysql-test/main/cte_recursive.test b/mysql-test/main/cte_recursive.test
index c3537e5bd0c..4937784fbe4 100644
--- a/mysql-test/main/cte_recursive.test
+++ b/mysql-test/main/cte_recursive.test
@@ -2855,6 +2855,27 @@ drop table folks;
set big_tables=@save_big_tables;
--echo #
+--echo # MDEV-26135: execution of PS for query with hanging recursive CTE
+--echo #
+
+create table t1 (a int);
+insert into t1 values (5), (7);
+create table t2 (b int);
+insert into t2 values (3), (7), (1);
+
+let $q=
+with recursive r as (select a from t1 union select a+1 from r where a < 10)
+select * from t2;
+
+eval $q;
+eval prepare stmt from "$q";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+drop table t1,t2;
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/main/mysql_client_test.result b/mysql-test/main/mysql_client_test.result
index 8a2921f28b5..26afee9e4d7 100644
--- a/mysql-test/main/mysql_client_test.result
+++ b/mysql-test/main/mysql_client_test.result
@@ -127,6 +127,11 @@ Data:
EOF
mysql_stmt_next_result(): 0; field_count: 0
# ------------------------------------
+# cat MYSQL_TMP_DIR/test_mdev26145.out.log
+# ------------------------------------
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def MAX(a) MAX(a) 3 11 0 Y 32768 0 63
+# ------------------------------------
# cat MYSQL_TMP_DIR/test_explain_meta.out.log
diff --git a/mysql-test/main/mysql_client_test.test b/mysql-test/main/mysql_client_test.test
index fc2e3a00ed5..07d4b43154a 100644
--- a/mysql-test/main/mysql_client_test.test
+++ b/mysql-test/main/mysql_client_test.test
@@ -36,6 +36,10 @@ echo ok;
--echo # ------------------------------------
--cat_file $MYSQL_TMP_DIR/test_wl4435.out.log
--echo # ------------------------------------
+--echo # cat MYSQL_TMP_DIR/test_mdev26145.out.log
+--echo # ------------------------------------
+--cat_file $MYSQL_TMP_DIR/test_mdev26145.out.log
+--echo # ------------------------------------
--echo
--echo
diff --git a/mysql-test/main/order_by_innodb.result b/mysql-test/main/order_by_innodb.result
index 9cdf9800cee..14b9b861a14 100644
--- a/mysql-test/main/order_by_innodb.result
+++ b/mysql-test/main/order_by_innodb.result
@@ -147,4 +147,56 @@ i n
656 eight
set optimizer_switch= @save_optimizer_switch;
DROP TABLE t1,t2,t3;
+#
+# MDEV-25858: Query results are incorrect when indexes are added
+#
+CREATE TABLE t1 (id int NOT NULL PRIMARY KEY) engine=innodb;
+insert into t1 values (1),(2),(3);
+CREATE TABLE t2 (
+id int NOT NULL PRIMARY KEY,
+id2 int NOT NULL,
+d1 datetime,
+d2 timestamp NOT NULL,
+KEY id2 (id2)
+) engine=innodb;
+insert into t2 values
+(1,2,'2019-03-05 00:00:00','2019-03-06 00:00:00'),
+(2,3,'2019-03-05 00:00:00','2019-03-06 00:00:00'),
+(3,3,'2019-03-06 00:00:00','2019-03-05 00:00:00');
+select
+t1.id,t2.id
+from
+t1 left join
+t2 on t2.id2 = t1.id and
+t2.id = (select dd.id
+from t2 dd
+where
+dd.id2 = t1.id and
+d1 > '2019-02-06 00:00:00'
+ order by
+dd.d1 desc, dd.d2 desc, dd.id desc limit 1
+);
+id id
+1 NULL
+2 1
+3 3
+create index for_latest_sort on t2 (d1 desc, d2 desc, id desc);
+select
+t1.id,t2.id
+from
+t1 left join
+t2 on t2.id2 = t1.id and
+t2.id = (select dd.id
+from t2 dd
+where
+dd.id2 = t1.id and
+d1 > '2019-02-06 00:00:00'
+ order by
+dd.d1 desc, dd.d2 desc, dd.id desc limit 1
+);
+id id
+1 NULL
+2 1
+3 3
+drop table t1,t2;
# End of 10.2 tests
diff --git a/mysql-test/main/order_by_innodb.test b/mysql-test/main/order_by_innodb.test
index f4c738263ae..97c043b8dbc 100644
--- a/mysql-test/main/order_by_innodb.test
+++ b/mysql-test/main/order_by_innodb.test
@@ -135,4 +135,55 @@ set optimizer_switch= @save_optimizer_switch;
DROP TABLE t1,t2,t3;
+--echo #
+--echo # MDEV-25858: Query results are incorrect when indexes are added
+--echo #
+
+CREATE TABLE t1 (id int NOT NULL PRIMARY KEY) engine=innodb;
+insert into t1 values (1),(2),(3);
+
+CREATE TABLE t2 (
+ id int NOT NULL PRIMARY KEY,
+ id2 int NOT NULL,
+ d1 datetime,
+ d2 timestamp NOT NULL,
+ KEY id2 (id2)
+) engine=innodb;
+
+insert into t2 values
+ (1,2,'2019-03-05 00:00:00','2019-03-06 00:00:00'),
+ (2,3,'2019-03-05 00:00:00','2019-03-06 00:00:00'),
+ (3,3,'2019-03-06 00:00:00','2019-03-05 00:00:00');
+
+select
+ t1.id,t2.id
+from
+ t1 left join
+ t2 on t2.id2 = t1.id and
+ t2.id = (select dd.id
+ from t2 dd
+ where
+ dd.id2 = t1.id and
+ d1 > '2019-02-06 00:00:00'
+ order by
+ dd.d1 desc, dd.d2 desc, dd.id desc limit 1
+ );
+
+create index for_latest_sort on t2 (d1 desc, d2 desc, id desc);
+
+select
+ t1.id,t2.id
+from
+ t1 left join
+ t2 on t2.id2 = t1.id and
+ t2.id = (select dd.id
+ from t2 dd
+ where
+ dd.id2 = t1.id and
+ d1 > '2019-02-06 00:00:00'
+ order by
+ dd.d1 desc, dd.d2 desc, dd.id desc limit 1
+ );
+drop table t1,t2;
+
--echo # End of 10.2 tests
diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result
index 34951c858c8..53fa6e663fb 100644
--- a/mysql-test/main/selectivity_innodb.result
+++ b/mysql-test/main/selectivity_innodb.result
@@ -2103,6 +2103,57 @@ drop view v1;
#
# End of 10.1 tests
#
+#
+# MDEV-17783: AddressSanitizer: stack-buffer-overflow in table_cond_selectivity
+#
+set
+@tmp_jcl=@@join_cache_level,
+@tmp_sel=@@optimizer_use_condition_selectivity;
+set
+join_cache_level=3,
+optimizer_use_condition_selectivity=2;
+CREATE TABLE t1 (
+c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, c8 int, c9 int, c10 int,
+c11 int, c12 int, c13 int, c14 int, c15 int, c16 int, c17 int, c18 int, c19 int,
+c20 int, c21 int, c22 int, c23 int, c24 int, c25 int, c26 int, c27 int, c28 int,
+c29 int, c30 int, c31 int, c32 int, c33 int, c34 int
+) ENGINE=InnoDB;
+SELECT * FROM t1
+WHERE
+(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10,
+c11, c12, c13, c14, c15, c16, c17, c18, c19,
+c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,
+c30, c31, c32, c33, c34) IN (SELECT * FROM t1) ;
+c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34
+set
+join_cache_level=@tmp_jcl,
+optimizer_use_condition_selectivity=@tmp_sel;
+drop table t1;
+#
+# MDEV-25013: SIGSEGV in best_extension_by_limited_search | SIGSEGV in restore_prev_nj_state
+#
+SET join_cache_level=3;
+CREATE TABLE t1 (
+TEXT1 TEXT, TEXT2 TEXT, TEXT3 TEXT, TEXT4 TEXT, TEXT5 TEXT,
+TEXT6 TEXT, TEXT7 TEXT, TEXT8 TEXT, TEXT9 TEXT, TEXT10 TEXT,
+TEXT11 TEXT, TEXT12 TEXT,TEXT13 TEXT,TEXT14 TEXT,TEXT15 TEXT,
+TEXT16 TEXT,TEXT17 TEXT,TEXT18 TEXT,TEXT19 TEXT,TEXT20 TEXT,
+TEXT21 TEXT,TEXT22 TEXT,TEXT23 TEXT,TEXT24 TEXT,TEXT25 TEXT,
+TEXT26 TEXT,TEXT27 TEXT,TEXT28 TEXT,TEXT29 TEXT,TEXT30 TEXT,
+TEXT31 TEXT,TEXT32 TEXT,TEXT33 TEXT,TEXT34 TEXT,TEXT35 TEXT,
+TEXT36 TEXT,TEXT37 TEXT,TEXT38 TEXT,TEXT39 TEXT,TEXT40 TEXT,
+TEXT41 TEXT,TEXT42 TEXT,TEXT43 TEXT,TEXT44 TEXT,TEXT45 TEXT,
+TEXT46 TEXT,TEXT47 TEXT,TEXT48 TEXT,TEXT49 TEXT,TEXT50 TEXT
+) ENGINE=InnoDB;
+EXPLAIN SELECT 1 FROM t1 NATURAL JOIN t1 AS t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where
+1 SIMPLE t2 hash_ALL NULL #hash#$hj 150 test.t1.TEXT1,test.t1.TEXT2,test.t1.TEXT3,test.t1.TEXT4,test.t1.TEXT5,test.t1.TEXT6,test.t1.TEXT7,test.t1.TEXT8,test.t1.TEXT9,test.t1.TEXT10,test.t1.TEXT11,test.t1.TEXT12,test.t1.TEXT13,test.t1.TEXT14,test.t1.TEXT15,test.t1.TEXT16,test.t1.TEXT17,test.t1.TEXT18,test.t1.TEXT19,test.t1.TEXT20,test.t1.TEXT21,test.t1.TEXT22,test.t1.TEXT23,test.t1.TEXT24,test.t1.TEXT25,test.t1.TEXT26,test.t1.TEXT27,test.t1.TEXT28,test.t1.TEXT29,test.t1.TEXT30,test.t1.TEXT31,test.t1.TEXT32,test.t1.TEXT33,test.t1.TEXT34,test.t1.TEXT35,test.t1.TEXT36,test.t1.TEXT37,test.t1.TEXT38,test.t1.TEXT39,test.t1.TEXT40,test.t1.TEXT41,test.t1.TEXT42,test.t1.TEXT43,test.t1.TEXT44,test.t1.TEXT45,test.t1.TEXT46,test.t1.TEXT47,test.t1.TEXT48,test.t1.TEXT49,test.t1.TEXT50 1 Using where; Using join buffer (flat, BNLH join)
+set join_cache_level=@tmp_jcl;
+drop table t1;
+#
+# End of 10.1 tests
+#
set use_stat_tables= @tmp_ust;
set optimizer_use_condition_selectivity= @tmp_oucs;
set @@global.histogram_size=@save_histogram_size;
diff --git a/mysql-test/main/selectivity_innodb.test b/mysql-test/main/selectivity_innodb.test
index 6c457e2848b..057a36fcf62 100644
--- a/mysql-test/main/selectivity_innodb.test
+++ b/mysql-test/main/selectivity_innodb.test
@@ -174,6 +174,61 @@ drop view v1;
--echo # End of 10.1 tests
--echo #
+--echo #
+--echo # MDEV-17783: AddressSanitizer: stack-buffer-overflow in table_cond_selectivity
+--echo #
+
+set
+ @tmp_jcl=@@join_cache_level,
+ @tmp_sel=@@optimizer_use_condition_selectivity;
+set
+ join_cache_level=3,
+ optimizer_use_condition_selectivity=2;
+
+CREATE TABLE t1 (
+ c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, c8 int, c9 int, c10 int,
+ c11 int, c12 int, c13 int, c14 int, c15 int, c16 int, c17 int, c18 int, c19 int,
+ c20 int, c21 int, c22 int, c23 int, c24 int, c25 int, c26 int, c27 int, c28 int,
+ c29 int, c30 int, c31 int, c32 int, c33 int, c34 int
+) ENGINE=InnoDB;
+
+SELECT * FROM t1
+WHERE
+ (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10,
+ c11, c12, c13, c14, c15, c16, c17, c18, c19,
+ c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,
+ c30, c31, c32, c33, c34) IN (SELECT * FROM t1) ;
+
+set
+ join_cache_level=@tmp_jcl,
+ optimizer_use_condition_selectivity=@tmp_sel;
+drop table t1;
+
+--echo #
+--echo # MDEV-25013: SIGSEGV in best_extension_by_limited_search | SIGSEGV in restore_prev_nj_state
+--echo #
+
+SET join_cache_level=3;
+CREATE TABLE t1 (
+ TEXT1 TEXT, TEXT2 TEXT, TEXT3 TEXT, TEXT4 TEXT, TEXT5 TEXT,
+ TEXT6 TEXT, TEXT7 TEXT, TEXT8 TEXT, TEXT9 TEXT, TEXT10 TEXT,
+ TEXT11 TEXT, TEXT12 TEXT,TEXT13 TEXT,TEXT14 TEXT,TEXT15 TEXT,
+ TEXT16 TEXT,TEXT17 TEXT,TEXT18 TEXT,TEXT19 TEXT,TEXT20 TEXT,
+ TEXT21 TEXT,TEXT22 TEXT,TEXT23 TEXT,TEXT24 TEXT,TEXT25 TEXT,
+ TEXT26 TEXT,TEXT27 TEXT,TEXT28 TEXT,TEXT29 TEXT,TEXT30 TEXT,
+ TEXT31 TEXT,TEXT32 TEXT,TEXT33 TEXT,TEXT34 TEXT,TEXT35 TEXT,
+ TEXT36 TEXT,TEXT37 TEXT,TEXT38 TEXT,TEXT39 TEXT,TEXT40 TEXT,
+ TEXT41 TEXT,TEXT42 TEXT,TEXT43 TEXT,TEXT44 TEXT,TEXT45 TEXT,
+ TEXT46 TEXT,TEXT47 TEXT,TEXT48 TEXT,TEXT49 TEXT,TEXT50 TEXT
+) ENGINE=InnoDB;
+EXPLAIN SELECT 1 FROM t1 NATURAL JOIN t1 AS t2;
+
+set join_cache_level=@tmp_jcl;
+drop table t1;
+--echo #
+--echo # End of 10.1 tests
+--echo #
+
set use_stat_tables= @tmp_ust;
set optimizer_use_condition_selectivity= @tmp_oucs;
set @@global.histogram_size=@save_histogram_size;
diff --git a/mysql-test/main/selectivity_no_engine.result b/mysql-test/main/selectivity_no_engine.result
index 7fc3c6e9909..c513c19133d 100644
--- a/mysql-test/main/selectivity_no_engine.result
+++ b/mysql-test/main/selectivity_no_engine.result
@@ -293,6 +293,26 @@ SELECT * FROM t1 WHERE t1.d = 0 AND t1.p = '1' AND t1.i != '-1' AND t1.n = 'some
i n d p
set optimizer_use_condition_selectivity= @tmp_mdev8779;
DROP TABLE t1;
+#
+# MDEV-23937: SIGSEGV in looped best_extension_by_limited_search from greedy_search
+# (Testcase only)
+#
+set
+@tmp_jcl= @@join_cache_level,
+@tmp_ucs= @@optimizer_use_condition_selectivity;
+set
+join_cache_level=3,
+optimizer_use_condition_selectivity=2;
+CREATE TABLE t1 AS SELECT * FROM mysql.user;
+CREATE TABLE t3 (b VARCHAR (1));
+CREATE TABLE t2 (c2 INT);
+INSERT INTO t2 VALUES (1);
+EXPLAIN
+SELECT * FROM t1 AS a NATURAL JOIN t1 AS b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE a ALL NULL NULL NULL NULL 4
+1 SIMPLE b hash_ALL NULL #hash#$hj 828 test.a.Host,test.a.User,test.a.Password,test.a.Select_priv,test.a.Insert_priv,test.a.Update_priv,test.a.Delete_priv,test.a.Create_priv,test.a.Drop_priv,test.a.Reload_priv,test.a.Shutdown_priv,test.a.Process_priv,test.a.File_priv,test.a.Grant_priv,test.a.References_priv,test.a.Index_priv,test.a.Alter_priv,test.a.Show_db_priv,test.a.Super_priv,test.a.Create_tmp_table_priv,test.a.Lock_tables_priv,test.a.Execute_priv,test.a.Repl_slave_priv,test.a.Repl_client_priv,test.a.Create_view_priv,test.a.Show_view_priv,test.a.Create_routine_priv,test.a.Alter_routine_priv,test.a.Create_user_priv,test.a.Event_priv,test.a.Trigger_priv,test.a.Create_tablespace_priv,test.a.Delete_history_priv,test.a.ssl_type,test.a.ssl_cipher,test.a.x509_issuer,test.a.x509_subject,test.a.max_questions,test.a.max_updates,test.a.max_connections,test.a.max_user_connections,test.a.plugin,test.a.authentication_string,test.a.password_expired,test.a.is_role,test.a.default_role,test.a.max_statement_time 4 Using where; Using join buffer (flat, BNLH join)
+DROP TABLE t1,t2,t3;
#
# End of the test file
#
diff --git a/mysql-test/main/selectivity_no_engine.test b/mysql-test/main/selectivity_no_engine.test
index 345b7bd1e8a..b5f52dd167d 100644
--- a/mysql-test/main/selectivity_no_engine.test
+++ b/mysql-test/main/selectivity_no_engine.test
@@ -228,6 +228,27 @@ SELECT * FROM t1 WHERE t1.d = 0 AND t1.p = '1' AND t1.i != '-1' AND t1.n = 'some
set optimizer_use_condition_selectivity= @tmp_mdev8779;
DROP TABLE t1;
+--echo #
+--echo # MDEV-23937: SIGSEGV in looped best_extension_by_limited_search from greedy_search
+--echo # (Testcase only)
+--echo #
+set
+ @tmp_jcl= @@join_cache_level,
+ @tmp_ucs= @@optimizer_use_condition_selectivity;
+set
+ join_cache_level=3,
+ optimizer_use_condition_selectivity=2;
+
+CREATE TABLE t1 AS SELECT * FROM mysql.user;
+CREATE TABLE t3 (b VARCHAR (1));
+CREATE TABLE t2 (c2 INT);
+INSERT INTO t2 VALUES (1);
+
+EXPLAIN
+SELECT * FROM t1 AS a NATURAL JOIN t1 AS b;
+
+DROP TABLE t1,t2,t3;
+
--echo #
--echo # End of the test file
--echo #
diff --git a/mysql-test/main/skip_name_resolve.result b/mysql-test/main/skip_name_resolve.result
index 9a903ebf472..fe71b714cbc 100644
--- a/mysql-test/main/skip_name_resolve.result
+++ b/mysql-test/main/skip_name_resolve.result
@@ -39,4 +39,24 @@ SET @@LOCAL.skip_name_resolve=0;
ERROR HY000: Variable 'skip_name_resolve' is a read only variable
SET @@GLOBAL.skip_name_resolve=0;
ERROR HY000: Variable 'skip_name_resolve' is a read only variable
-End of 5.1 tests
+#
+# End of 5.1 tests
+#
+#
+# MDEV-26081 set role crashes when a hostname cannot be resolved
+#
+create user u1@`%`;
+create role r1;
+create role r2;
+grant r2 to r1;
+grant r1 to u1@`%`;
+connect u1,127.0.0.1,u1,,,$MASTER_MYPORT;
+set role r2;
+ERROR OP000: User `u1`@`%` has not been granted role `r2`
+disconnect u1;
+connection default;
+drop user u1@`%`;
+drop role r1, r2;
+#
+# End of 10.2 tests
+#
diff --git a/mysql-test/main/skip_name_resolve.test b/mysql-test/main/skip_name_resolve.test
index b0c5118f970..0ff19092b82 100644
--- a/mysql-test/main/skip_name_resolve.test
+++ b/mysql-test/main/skip_name_resolve.test
@@ -50,4 +50,28 @@ SET @@LOCAL.skip_name_resolve=0;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@GLOBAL.skip_name_resolve=0;
---echo End of 5.1 tests
+--echo #
+--echo # End of 5.1 tests
+--echo #
+
+--echo #
+--echo # MDEV-26081 set role crashes when a hostname cannot be resolved
+--echo #
+
+create user u1@`%`;
+create role r1;
+create role r2;
+grant r2 to r1;
+grant r1 to u1@`%`;
+
+connect u1,127.0.0.1,u1,,,$MASTER_MYPORT;
+error ER_INVALID_ROLE;
+set role r2;
+disconnect u1;
+connection default;
+drop user u1@`%`;
+drop role r1, r2;
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result
index 7f0c2b88a41..3cc88125b12 100644
--- a/mysql-test/main/win.result
+++ b/mysql-test/main/win.result
@@ -3911,6 +3911,293 @@ sum(i) over () IN ( SELECT 1 FROM t1 a)
0
DROP TABLE t1;
#
+# MDEV-25565: 2-nd call of SP with SELECT from view / derived table / CTE
+# returning the result of calculation of 2 window
+# functions that use the same window specification
+#
+create table t1 (a int);
+insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5);
+create view v2 as select a from t1 group by a;
+create view v1 as select * from v2;
+create procedure sp1() select v1.a,
+sum(v1.a) over (partition by v1.a order by v1.a) as k,
+avg(v1.a) over (partition by v1.a order by v1.a) as m
+from v1;
+call sp1();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp1();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "select v1.a,
+sum(v1.a) over (partition by v1.a order by v1.a) as k,
+avg(v1.a) over (partition by v1.a order by v1.a) as m
+from v1";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp2() select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from (select * from v2) as dt1
+) as dt;
+call sp2();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp2();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from (select * from v2) as dt1
+) as dt";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp3() select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from ( select * from (select * from t1 group by a) as dt2 ) as dt1
+) as dt;
+call sp3();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp3();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from ( select * from (select * from t1 group by a) as dt2 ) as dt1
+) as dt";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp4() with cte1 as (select * from (select * from t1 group by a) as dt2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp4();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp4();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with cte1 as (select * from (select * from t1 group by a) as dt2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp5() with cte1 as (select * from v2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp5();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp5();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with cte1 as (select * from v2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp6() with
+cte1 as (with cte2 as (select * from t1 group by a) select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp6();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp6();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with
+cte1 as (with cte2 as (select * from t1 group by a) select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp7() with
+cte2 as (select * from v1),
+cte1 as (select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp7();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp7();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with
+cte2 as (select * from v1),
+cte1 as (select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+drop procedure sp1;
+drop procedure sp2;
+drop procedure sp3;
+drop procedure sp4;
+drop procedure sp5;
+drop procedure sp6;
+drop procedure sp7;
+drop view v1,v2;
+drop table t1;
+#
# End of 10.2 tests
#
#
diff --git a/mysql-test/main/win.test b/mysql-test/main/win.test
index 2e859007d0f..5a547b363b7 100644
--- a/mysql-test/main/win.test
+++ b/mysql-test/main/win.test
@@ -2557,6 +2557,153 @@ SELECT sum(i) over () IN ( SELECT 1 FROM t1 a) FROM t1;
DROP TABLE t1;
--echo #
+--echo # MDEV-25565: 2-nd call of SP with SELECT from view / derived table / CTE
+--echo # returning the result of calculation of 2 window
+--echo # functions that use the same window specification
+--echo #
+
+create table t1 (a int);
+insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5);
+
+create view v2 as select a from t1 group by a;
+create view v1 as select * from v2;
+
+let $q1=
+select v1.a,
+ sum(v1.a) over (partition by v1.a order by v1.a) as k,
+ avg(v1.a) over (partition by v1.a order by v1.a) as m
+from v1;
+
+eval create procedure sp1() $q1;
+call sp1();
+call sp1();
+
+eval prepare stmt from "$q1";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+let $q2=
+select * from
+ ( select dt1.a,
+ sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+ avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+ from (select * from v2) as dt1
+ ) as dt;
+
+eval create procedure sp2() $q2;
+call sp2();
+call sp2();
+
+eval prepare stmt from "$q2";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+let $q3=
+select * from
+ ( select dt1.a,
+ sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+ avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+ from ( select * from (select * from t1 group by a) as dt2 ) as dt1
+ ) as dt;
+
+eval create procedure sp3() $q3;
+call sp3();
+call sp3();
+
+eval prepare stmt from "$q3";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+let $q4=
+with cte1 as (select * from (select * from t1 group by a) as dt2),
+ cte as
+ ( select cte1.a,
+ sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+ avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+ from cte1 )
+select * from cte;
+
+eval create procedure sp4() $q4;
+call sp4();
+call sp4();
+
+eval prepare stmt from "$q4";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+let $q5=
+with cte1 as (select * from v2),
+ cte as
+ ( select cte1.a,
+ sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+ avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+ from cte1 )
+select * from cte;
+
+eval create procedure sp5() $q5;
+call sp5();
+call sp5();
+
+eval prepare stmt from "$q5";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+let $q6=
+with
+cte1 as (with cte2 as (select * from t1 group by a) select * from cte2),
+ cte as
+ ( select cte1.a,
+ sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+ avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+ from cte1 )
+select * from cte;
+
+eval create procedure sp6() $q6;
+call sp6();
+call sp6();
+
+eval prepare stmt from "$q6";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+let $q7=
+with
+ cte2 as (select * from v1),
+ cte1 as (select * from cte2),
+ cte as
+ ( select cte1.a,
+ sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+ avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+ from cte1 )
+select * from cte;
+
+eval create procedure sp7() $q7;
+call sp7();
+call sp7();
+
+eval prepare stmt from "$q7";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+
+drop procedure sp1;
+drop procedure sp2;
+drop procedure sp3;
+drop procedure sp4;
+drop procedure sp5;
+drop procedure sp6;
+drop procedure sp7;
+drop view v1,v2;
+drop table t1;
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 30e41727f44..52e772991bd 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -2829,7 +2829,9 @@ sub mysql_server_start($) {
if (!$opt_embedded_server)
{
- mysqld_start($mysqld,$extra_opts);
+ mysqld_start($mysqld, $extra_opts) or
+ mtr_error("Failed to start mysqld ".$mysqld->name()." with command "
+ . $ENV{MYSQLD_LAST_CMD});
# Save this test case information, so next can examine it
$mysqld->{'started_tinfo'}= $tinfo;
@@ -2852,11 +2854,11 @@ sub mysql_server_start($) {
sub mysql_server_wait {
my ($mysqld, $tinfo) = @_;
+ my $expect_file= "$opt_vardir/tmp/".$mysqld->name().".expect";
- if (!sleep_until_file_created($mysqld->value('pid-file'),
- $opt_start_timeout,
- $mysqld->{'proc'},
- $warn_seconds))
+ if (!sleep_until_file_created($mysqld->value('pid-file'), $expect_file,
+ $opt_start_timeout, $mysqld->{'proc'},
+ $warn_seconds))
{
$tinfo->{comment}= "Failed to start ".$mysqld->name() . "\n";
return 1;
@@ -4163,9 +4165,12 @@ sub run_testcase ($$) {
# ----------------------------------------------------
# Check if it was an expected crash
# ----------------------------------------------------
- my $check_crash = check_expected_crash_and_restart($wait_for_proc);
+ my @mysqld = grep($wait_for_proc eq $_->{proc}, mysqlds());
+ goto SRVDIED unless @mysqld;
+ my $check_crash = check_expected_crash_and_restart($mysqld[0]);
if ($check_crash == 0) # unexpected exit/crash of $wait_for_proc
{
+ $proc= $mysqld[0]->{proc};
goto SRVDIED;
}
elsif ($check_crash == 1) # $wait_for_proc was started again by check_expected_crash_and_restart()
@@ -4723,61 +4728,52 @@ sub check_warnings_post_shutdown {
}
#
-# Loop through our list of processes and look for and entry
-# with the provided pid, if found check for the file indicating
-# expected crash and restart it.
+# Check for the file indicating expected crash and restart it.
#
sub check_expected_crash_and_restart {
- my ($proc)= @_;
+ my $mysqld = shift;
- foreach my $mysqld ( mysqlds() )
+ # Check if crash expected by looking at the .expect file
+ # in var/tmp
+ my $expect_file= "$opt_vardir/tmp/".$mysqld->name().".expect";
+ if ( -f $expect_file )
{
- next unless ( $mysqld->{proc} and $mysqld->{proc} eq $proc );
+ mtr_verbose("Crash was expected, file '$expect_file' exists");
- # Check if crash expected by looking at the .expect file
- # in var/tmp
- my $expect_file= "$opt_vardir/tmp/".$mysqld->name().".expect";
- if ( -f $expect_file )
+ for (my $waits = 0; $waits < 50; mtr_milli_sleep(100), $waits++)
{
- mtr_verbose("Crash was expected, file '$expect_file' exists");
-
- for (my $waits = 0; $waits < 50; mtr_milli_sleep(100), $waits++)
+ # Race condition seen on Windows: try again until file not empty
+ next if -z $expect_file;
+ # If last line in expect file starts with "wait"
+ # sleep a little and try again, thus allowing the
+ # test script to control when the server should start
+ # up again. Keep trying for up to 5s at a time.
+ my $last_line= mtr_lastlinesfromfile($expect_file, 1);
+ if ($last_line =~ /^wait/ )
{
- # Race condition seen on Windows: try again until file not empty
- next if -z $expect_file;
- # If last line in expect file starts with "wait"
- # sleep a little and try again, thus allowing the
- # test script to control when the server should start
- # up again. Keep trying for up to 5s at a time.
- my $last_line= mtr_lastlinesfromfile($expect_file, 1);
- if ($last_line =~ /^wait/ )
- {
- mtr_verbose("Test says wait before restart") if $waits == 0;
- next;
- }
-
- # Ignore any partial or unknown command
- next unless $last_line =~ /^restart/;
- # If last line begins "restart:", the rest of the line is read as
- # extra command line options to add to the restarted mysqld.
- # Anything other than 'wait' or 'restart:' (with a colon) will
- # result in a restart with original mysqld options.
- if ($last_line =~ /restart:(.+)/) {
- my @rest_opt= split(' ', $1);
- $mysqld->{'restart_opts'}= \@rest_opt;
- } else {
- delete $mysqld->{'restart_opts'};
- }
- unlink($expect_file);
-
- # Start server with same settings as last time
- mysqld_start($mysqld, $mysqld->{'started_opts'});
+ mtr_verbose("Test says wait before restart") if $waits == 0;
+ next;
+ }
- return 1;
+ # Ignore any partial or unknown command
+ next unless $last_line =~ /^restart/;
+ # If last line begins "restart:", the rest of the line is read as
+ # extra command line options to add to the restarted mysqld.
+ # Anything other than 'wait' or 'restart:' (with a colon) will
+ # result in a restart with original mysqld options.
+ if ($last_line =~ /restart:(.+)/) {
+ my @rest_opt= split(' ', $1);
+ $mysqld->{'restart_opts'}= \@rest_opt;
+ } else {
+ delete $mysqld->{'restart_opts'};
}
- # Loop ran through: we should keep waiting after a re-check
- return 2;
+ unlink($expect_file);
+
+ # Start server with same settings as last time
+ return mysqld_start($mysqld, $mysqld->{'started_opts'});
}
+ # Loop ran through: we should keep waiting after a re-check
+ return 2;
}
# Not an expected crash
@@ -5134,6 +5130,7 @@ sub mysqld_start ($$) {
if ( defined $exe )
{
+ mtr_tofile($output, "\$ $exe @$args\n");
pre_write_errorlog($output);
$mysqld->{'proc'}= My::SafeProcess->new
(
@@ -5152,17 +5149,11 @@ sub mysqld_start ($$) {
mtr_verbose("Started $mysqld->{proc}");
}
- if (!sleep_until_file_created($mysqld->value('pid-file'),
- $opt_start_timeout, $mysqld->{'proc'}, $warn_seconds))
- {
- my $mname= $mysqld->name();
- mtr_error("Failed to start mysqld $mname with command $exe");
- }
-
- # Remember options used when starting
$mysqld->{'started_opts'}= $extra_opts;
- return;
+ my $expect_file= "$opt_vardir/tmp/".$mysqld->name().".expect";
+ return sleep_until_file_created($mysqld->value('pid-file'), $expect_file,
+ $opt_start_timeout, $mysqld->{'proc'}, $warn_seconds);
}
diff --git a/mysql-test/suite/binlog/include/binlog.test b/mysql-test/suite/binlog/include/binlog.test
index 40befc9d3d1..6c7d374b41b 100644
--- a/mysql-test/suite/binlog/include/binlog.test
+++ b/mysql-test/suite/binlog/include/binlog.test
@@ -408,4 +408,22 @@ SHOW SESSION VARIABLES LIKE "unique_checks";
DROP TABLE t1;
disconnect fresh;
+connection default;
+--echo #
+--echo # MDEV-25595 DROP part of failed CREATE OR REPLACE is not written into binary log
+--echo #
+reset master;
+--error ER_DUP_FIELDNAME
+create table t as select 1 as b, 2 as b;
+create table t (old_table_field int);
+--error ER_DUP_FIELDNAME
+create or replace table t as select 1 as b, 2 as b;
+--error ER_DUP_FIELDNAME
+create or replace temporary table t as select 1 as b, 2 as b;
+create table t (new_table_field int);
+
+--source include/show_binlog_events.inc
+
+# cleanup
+drop table t;
diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result
index 4068a80771c..948ccee58ca 100644
--- a/mysql-test/suite/binlog/r/binlog_row_binlog.result
+++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result
@@ -1073,3 +1073,26 @@ Variable_name Value
unique_checks OFF
DROP TABLE t1;
disconnect fresh;
+connection default;
+#
+# MDEV-25595 DROP part of failed CREATE OR REPLACE is not written into binary log
+#
+reset master;
+create table t as select 1 as b, 2 as b;
+ERROR 42S21: Duplicate column name 'b'
+create table t (old_table_field int);
+create or replace table t as select 1 as b, 2 as b;
+ERROR 42S21: Duplicate column name 'b'
+create or replace temporary table t as select 1 as b, 2 as b;
+ERROR 42S21: Duplicate column name 'b'
+create table t (new_table_field int);
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; create table t (old_table_field int)
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */
+master-bin.000001 # Query # # ROLLBACK
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; create table t (new_table_field int)
+drop table t;
diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
index 872ba40e05f..5016ed70242 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
@@ -673,3 +673,27 @@ Variable_name Value
unique_checks OFF
DROP TABLE t1;
disconnect fresh;
+connection default;
+#
+# MDEV-25595 DROP part of failed CREATE OR REPLACE is not written into binary log
+#
+reset master;
+create table t as select 1 as b, 2 as b;
+ERROR 42S21: Duplicate column name 'b'
+create table t (old_table_field int);
+create or replace table t as select 1 as b, 2 as b;
+ERROR 42S21: Duplicate column name 'b'
+create or replace temporary table t as select 1 as b, 2 as b;
+ERROR 42S21: Duplicate column name 'b'
+create table t (new_table_field int);
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; create table t (old_table_field int)
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; create table t (new_table_field int)
+drop table t;
diff --git a/mysql-test/suite/encryption/r/tempfiles_encrypted.result b/mysql-test/suite/encryption/r/tempfiles_encrypted.result
index c8078d72153..a58f375d2bd 100644
--- a/mysql-test/suite/encryption/r/tempfiles_encrypted.result
+++ b/mysql-test/suite/encryption/r/tempfiles_encrypted.result
@@ -3917,6 +3917,293 @@ sum(i) over () IN ( SELECT 1 FROM t1 a)
0
DROP TABLE t1;
#
+# MDEV-25565: 2-nd call of SP with SELECT from view / derived table / CTE
+# returning the result of calculation of 2 window
+# functions that use the same window specification
+#
+create table t1 (a int);
+insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5);
+create view v2 as select a from t1 group by a;
+create view v1 as select * from v2;
+create procedure sp1() select v1.a,
+sum(v1.a) over (partition by v1.a order by v1.a) as k,
+avg(v1.a) over (partition by v1.a order by v1.a) as m
+from v1;
+call sp1();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp1();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "select v1.a,
+sum(v1.a) over (partition by v1.a order by v1.a) as k,
+avg(v1.a) over (partition by v1.a order by v1.a) as m
+from v1";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp2() select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from (select * from v2) as dt1
+) as dt;
+call sp2();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp2();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from (select * from v2) as dt1
+) as dt";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp3() select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from ( select * from (select * from t1 group by a) as dt2 ) as dt1
+) as dt;
+call sp3();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp3();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from ( select * from (select * from t1 group by a) as dt2 ) as dt1
+) as dt";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp4() with cte1 as (select * from (select * from t1 group by a) as dt2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp4();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp4();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with cte1 as (select * from (select * from t1 group by a) as dt2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp5() with cte1 as (select * from v2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp5();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp5();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with cte1 as (select * from v2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp6() with
+cte1 as (with cte2 as (select * from t1 group by a) select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp6();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp6();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with
+cte1 as (with cte2 as (select * from t1 group by a) select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp7() with
+cte2 as (select * from v1),
+cte1 as (select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp7();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp7();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with
+cte2 as (select * from v1),
+cte1 as (select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+drop procedure sp1;
+drop procedure sp2;
+drop procedure sp3;
+drop procedure sp4;
+drop procedure sp5;
+drop procedure sp6;
+drop procedure sp7;
+drop view v1,v2;
+drop table t1;
+#
# End of 10.2 tests
#
#
diff --git a/mysql-test/suite/encryption/t/innodb_encryption_filekeys.test b/mysql-test/suite/encryption/t/innodb_encryption_filekeys.test
index 03447bbcfa6..cd5724638b1 100644
--- a/mysql-test/suite/encryption/t/innodb_encryption_filekeys.test
+++ b/mysql-test/suite/encryption/t/innodb_encryption_filekeys.test
@@ -48,6 +48,12 @@ while ($cnt)
{
real_sleep 1;
dec $cnt;
+ if ($cnt == 200)
+ {
+ --disable_query_log
+ set global innodb_encrypt_tables = on;
+ --enable_query_log
+ }
}
}
if (!$success)
@@ -78,6 +84,12 @@ while ($cnt)
{
real_sleep 1;
dec $cnt;
+ if ($cnt == 200)
+ {
+ --disable_query_log
+ set global innodb_encrypt_tables = off;
+ --enable_query_log
+ }
}
}
if (!$success)
@@ -107,6 +119,12 @@ while ($cnt)
{
real_sleep 1;
dec $cnt;
+ if ($cnt == 200)
+ {
+ --disable_query_log
+ set global innodb_encrypt_tables=on;
+ --enable_query_log
+ }
}
}
if (!$success)
diff --git a/mysql-test/suite/gcol/inc/gcol_ins_upd.inc b/mysql-test/suite/gcol/inc/gcol_ins_upd.inc
index 7fde9c2e852..e02a3828ea2 100644
--- a/mysql-test/suite/gcol/inc/gcol_ins_upd.inc
+++ b/mysql-test/suite/gcol/inc/gcol_ins_upd.inc
@@ -607,4 +607,78 @@ DELETE FROM t1;
DROP TEMPORARY TABLE t1;
+--echo #
+--echo # Original test case from MDEV-17890
+--echo #
+
+CREATE TABLE t1 (
+ pk BIGINT AUTO_INCREMENT,
+ b BIT(15),
+ v BIT(10) AS (b) VIRTUAL,
+ PRIMARY KEY(pk),
+ UNIQUE(v)
+);
+
+INSERT IGNORE INTO t1 (b) VALUES (b'101110001110100'),(b'011101');
+SELECT pk, b FROM t1 INTO OUTFILE 'load.data';
+--error ER_DATA_TOO_LONG
+LOAD DATA INFILE 'load.data' REPLACE INTO TABLE t1 (pk, b);
+
+# Cleanup
+DROP TABLE t1;
+--let $datadir= `SELECT @@datadir`
+--remove_file $datadir/test/load.data
+
+
+--echo #
+--echo # MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+--echo #
+
+CREATE TABLE t1 (
+ id INT NOT NULL AUTO_INCREMENT,
+ f ENUM('a','b','c'),
+ v ENUM('a','b','c') AS (f),
+ KEY(v,id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (f) VALUES ('a'),('b');
+INSERT IGNORE INTO t1 SELECT * FROM t1;
+
+# Cleanup
+DROP TABLE t1;
+
+
+CREATE TABLE t1 (
+ id INT NOT NULL AUTO_INCREMENT,
+ f ENUM('a','b','c'),
+ v ENUM('a','b','c') AS (f),
+ KEY(v,id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (f) VALUES ('a'),('b');
+INSERT IGNORE INTO t1 SELECT * FROM t1;
+
+# Cleanup
+DROP TABLE t1;
+
}
+
+--echo #
+--echo # MDEV-23597 Assertion `marked_for_read()' failed while evaluating DEFAULT
+--echo #
+
+CREATE TABLE t1 (a INT UNIQUE, b INT DEFAULT (c+1), c int);
+INSERT INTO t1 VALUES (1,1,1);
+UPDATE t1 SET b=DEFAULT;
+SELECT * from t1;
+
+REPLACE t1 VALUES(1,1,1);
+INSERT INTO t1 VALUES (1,1,1) ON DUPLICATE KEY UPDATE b= DEFAULT;
+SELECT * from t1;
+
+REPLACE t1 VALUES(1,1,1);
+CREATE TABLE t2 (a INT, b INT DEFAULT (c+1), c int);
+INSERT INTO t2 VALUES (5,5,5);
+UPDATE t1 join t2 set t1.b= DEFAULT, t2.b= DEFAULT;
+SELECT * from t1, t2;
+
+DROP TABLE t1, t2;
+
diff --git a/mysql-test/suite/gcol/inc/gcol_keys.inc b/mysql-test/suite/gcol/inc/gcol_keys.inc
index e5f7f976120..cf0612b0d0c 100644
--- a/mysql-test/suite/gcol/inc/gcol_keys.inc
+++ b/mysql-test/suite/gcol/inc/gcol_keys.inc
@@ -812,7 +812,7 @@ DROP TABLE t1;
--echo # MDEV-19011 Assertion `file->s->base.reclength < file->s->vreclength'
--echo # failed in ha_myisam::setup_vcols_for_repair
-CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL) ENGINE=MyISAM;
+CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL);
ALTER TABLE t1 ADD KEY (a);
DROP TABLE t1;
diff --git a/mysql-test/suite/gcol/inc/gcol_partition.inc b/mysql-test/suite/gcol/inc/gcol_partition.inc
index df199e86c68..4e4af4f0023 100644
--- a/mysql-test/suite/gcol/inc/gcol_partition.inc
+++ b/mysql-test/suite/gcol/inc/gcol_partition.inc
@@ -153,3 +153,19 @@ CHECK TABLE t EXTENDED;
FLUSH TABLES;
CHECK TABLE t EXTENDED;
DROP TABLE t;
+
+--echo #
+--echo # MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+--echo #
+CREATE TABLE t1 (
+ a INT,
+ b INT,
+ c BIT(4) NOT NULL DEFAULT b'0',
+ pk INTEGER AUTO_INCREMENT,
+ d BIT(4) AS (c) VIRTUAL,
+ PRIMARY KEY(pk),
+ KEY (b,d)
+) PARTITION BY HASH(pk);
+INSERT INTO t1 () VALUES (),();
+UPDATE t1 SET a = 0 WHERE b IS NULL ORDER BY pk;
+DROP TABLE t1;
diff --git a/mysql-test/suite/gcol/inc/gcol_view.inc b/mysql-test/suite/gcol/inc/gcol_view.inc
index 51cb9b5d725..6f9ce673199 100644
--- a/mysql-test/suite/gcol/inc/gcol_view.inc
+++ b/mysql-test/suite/gcol/inc/gcol_view.inc
@@ -221,3 +221,58 @@ select * from t1;
drop view v1;
drop table t1;
+
+--echo #
+--echo # MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+--echo #
+
+CREATE TABLE t1 (d DATETIME(3), v DATETIME(2) AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),
+ ('1985-12-24 10:15:08.456');
+DELETE FROM v1 ORDER BY v LIMIT 4;
+
+# Cleanup
+DROP VIEW v1;
+DROP TABLE t1;
+
+--echo #
+--echo # [duplicate] MDEV-19306 Assertion `marked_for_read()' failed in
+--echo # Field_blob::val_str with virtual columns and views
+--echo #
+
+CREATE TABLE t1 (a BLOB, b TEXT AS (a) VIRTUAL);
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (a) VALUES ('foo'),('bar');
+DELETE FROM v1 ORDER BY b LIMIT 2;
+
+# Cleanup
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (d INT, v TINYINT AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004'),('1985') ;
+DELETE FROM v1 ORDER BY v LIMIT 4;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+
+CREATE TABLE t1 (d VARCHAR(64), v VARCHAR(63) AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),('1985-12-24 10:15:08.456') ;
+DELETE FROM v1 ORDER BY v LIMIT 4;
+
+DROP TABLE t1;
+DROP VIEW v1;
+
+
+--echo #
+--echo # MDEV-18249 ASSERT_COLUMN_MARKED_FOR_READ failed in ANALYZE TABLE
+--echo #
+
+create table t1 (c varchar(3) not null, v varchar(4) as (c) virtual);
+insert into t1 (c) values ('a'),('b');
+analyze table t1 persistent for columns (v) indexes ();
+
diff --git a/mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result b/mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result
index 3024b58da54..143e1b725c4 100644
--- a/mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result
+++ b/mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result
@@ -435,6 +435,26 @@ UPDATE t1 SET col1 = 2;
UPDATE t1 SET col7 = DEFAULT;
UPDATE t1 SET col8 = DEFAULT;
DROP TABLE t1;
+Bug#20797344: WL#8149: ALLOCATED SPACE FOR INDEXED BLOB VGC CAN BE
+OVERWRITTEN FOR UPDATE
+#
+CREATE TABLE t (a varchar(100), b blob,
+c blob GENERATED ALWAYS AS (concat(a,b)) VIRTUAL,
+d blob GENERATED ALWAYS AS (b) VIRTUAL,
+e int(11) GENERATED ALWAYS AS (10) VIRTUAL,
+h int(11) NOT NULL, PRIMARY KEY (h), key(c(20)));
+INSERT INTO t(a,b,h) VALUES('aaaaaaa','1111111', 11);
+INSERT INTO t(a,b,h) VALUES('bbbbbbb','2222222', 22);
+SELECT c FROM t;
+c
+aaaaaaa1111111
+bbbbbbb2222222
+UPDATE t SET a='ccccccc';
+SELECT c FROM t;
+c
+ccccccc1111111
+ccccccc2222222
+DROP TABLE t;
# Bug#21081742: ASSERTION !TABLE || (!TABLE->WRITE_SET ||
# BITMAP_IS_SET(TABLE->WRITE_SET
#
@@ -491,6 +511,21 @@ SELECT * FROM t;
x y gc
2 1 3
DROP TABLE t;
+CREATE TABLE t (
+x INT, y INT, gc INT GENERATED ALWAYS AS (x+1), KEY (x,gc)
+);
+INSERT INTO t VALUES ();
+UPDATE t t1, t t2 SET t1.x = 1, t2.y = 2;
+SELECT * FROM t;
+x y gc
+1 2 2
+SELECT gc FROM t;
+gc
+2
+CHECK TABLE t;
+Table Op Msg_type Msg_text
+test.t check status OK
+DROP TABLE t;
# stored
CREATE TABLE C (
col_varchar_nokey VARCHAR(1),
@@ -552,6 +587,99 @@ SELECT * from C;
col_varchar_nokey col_varchar_key
a aa
DROP TABLE C;
+# virtual, indexed
+CREATE TABLE C (
+col_varchar_nokey VARCHAR(1),
+col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
+(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL,
+KEY (col_varchar_key, col_varchar_nokey)
+);
+INSERT INTO C (col_varchar_nokey) VALUES ('c');
+EXPLAIN UPDATE C AS OUTR1, C AS OUTR2
+SET OUTR1.`col_varchar_nokey` = 'f',
+OUTR2.`col_varchar_nokey` = "a";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE OUTR1 ALL NULL NULL NULL NULL 1
+1 SIMPLE OUTR2 ALL NULL NULL NULL NULL 1
+UPDATE C AS OUTR1, C AS OUTR2
+SET OUTR1.`col_varchar_nokey` = 'f',
+OUTR2.`col_varchar_nokey` = "a";
+SELECT * from C;
+col_varchar_nokey col_varchar_key
+a aa
+DROP TABLE C;
+#
+# Bug #21530366 CRASH/ASSERTION, CORRUPTION WITH INDEXES +
+# VIRTUAL COLUMNS, BLOB
+#
+CREATE TABLE t (
+a INTEGER,
+b BLOB GENERATED ALWAYS AS (a) VIRTUAL,
+INDEX (b(57))
+);
+INSERT INTO t (a) VALUES (9);
+UPDATE t SET a = 10;
+DELETE FROM t WHERE a = 10;
+DROP TABLE t;
+# Bug#21807818: Generated columns not updated with empty insert list
+CREATE TABLE t (
+a BLOB GENERATED ALWAYS AS ('') VIRTUAL,
+b TIMESTAMP(4) GENERATED ALWAYS AS ('') VIRTUAL,
+KEY (a(183),b)
+);
+INSERT IGNORE INTO t VALUES(), (), ();
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b' at row 2
+Warning 1265 Data truncated for column 'b' at row 3
+DELETE IGNORE FROM t;
+DROP TABLE t;
+#
+# Bug#22195458:GCOLS: ASSERTION 0 AND CORRUPTION...
+#
+CREATE TABLE t (
+a INT,
+b YEAR GENERATED ALWAYS AS ('a') VIRTUAL,
+c YEAR GENERATED ALWAYS AS ('aaaa') VIRTUAL,
+b1 YEAR GENERATED ALWAYS AS ('a') STORED,
+c1 YEAR GENERATED ALWAYS AS ('aaaa') STORED,
+UNIQUE(b),
+UNIQUE(b1)
+);
+INSERT IGNORE INTO t VALUES();
+SELECT b from t;
+b
+0000
+SELECT b1 from t;
+b1
+0000
+SELECT * from t;
+a b c b1 c1
+NULL 0000 0000 0000 0000
+DELETE FROM t;
+CHECK TABLE t EXTENDED;
+Table Op Msg_type Msg_text
+test.t check status OK
+DROP TABLE t;
+# Bug#22195364:GCOLS: FAILING ASSERTION:
+# DFIELD_IS_NULL(DFIELD2) || DFIELD2->DATA
+CREATE TABLE t (
+a INT,
+c BLOB GENERATED ALWAYS AS ('') VIRTUAL,
+UNIQUE KEY(c(1),a)
+);
+INSERT INTO t(a) VALUES(1) ON DUPLICATE KEY UPDATE a=2;
+SELECT * FROM t;
+a c
+1
+INSERT INTO t(a) VALUES(1) ON DUPLICATE KEY UPDATE a=2;
+SELECT * FROM t;
+a c
+2
+SELECT GROUP_CONCAT(c ORDER BY c) FROM t;
+GROUP_CONCAT(c ORDER BY c)
+
+DROP TABLE t;
#Bug#21929967:GCOLS:GCOL VALUE CHANGES WHEN SESSION CHANGES SQL_MODE
CREATE TABLE t(c1 INT GENERATED ALWAYS AS (1) VIRTUAL,
c2 INT GENERATED ALWAYS AS(2) STORED);
@@ -593,6 +721,98 @@ i1 i2
5 10
5 10
DROP TABLE t1,t2;
+#
+# Bug#22070021 GCOL:ASSERTION `!TABLE || (!TABLE->WRITE_SET ||
+# BITMAP_IS_SET(TABLE->WRITE_SET,
+#
+CREATE TABLE t1(
+c1 INT,
+c2 INT GENERATED ALWAYS AS (c1 + c1) VIRTUAL,
+KEY(c2)
+);
+INSERT INTO t1(c1) VALUES(0);
+DELETE O1.* FROM t1 AS O1, t1 AS O2;
+SELECT * FROM t1;
+c1 c2
+DROP TABLE t1;
+#
+# Bug#21944199 SIMPLE DELETE QUERY CAUSES INNODB: FAILING ASSERTION: 0
+# & DATA CORRUPTION
+#
+CREATE TEMPORARY TABLE t1 (
+a INTEGER NOT NULL,
+b INTEGER GENERATED ALWAYS AS (a+1) VIRTUAL
+);
+INSERT INTO t1 (a) VALUES (0), (0), (0);
+ALTER TABLE t1 ADD INDEX idx (b);
+DELETE FROM t1;
+DROP TEMPORARY TABLE t1;
+#
+# Original test case from MDEV-17890
+#
+CREATE TABLE t1 (
+pk BIGINT AUTO_INCREMENT,
+b BIT(15),
+v BIT(10) AS (b) VIRTUAL,
+PRIMARY KEY(pk),
+UNIQUE(v)
+);
+INSERT IGNORE INTO t1 (b) VALUES (b'101110001110100'),(b'011101');
+Warnings:
+Warning 1264 Out of range value for column 'v' at row 1
+SELECT pk, b FROM t1 INTO OUTFILE 'load.data';
+LOAD DATA INFILE 'load.data' REPLACE INTO TABLE t1 (pk, b);
+ERROR 22001: Data too long for column 'v' at row 1
+DROP TABLE t1;
+#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+CREATE TABLE t1 (
+id INT NOT NULL AUTO_INCREMENT,
+f ENUM('a','b','c'),
+v ENUM('a','b','c') AS (f),
+KEY(v,id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (f) VALUES ('a'),('b');
+INSERT IGNORE INTO t1 SELECT * FROM t1;
+Warnings:
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+DROP TABLE t1;
+CREATE TABLE t1 (
+id INT NOT NULL AUTO_INCREMENT,
+f ENUM('a','b','c'),
+v ENUM('a','b','c') AS (f),
+KEY(v,id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (f) VALUES ('a'),('b');
+INSERT IGNORE INTO t1 SELECT * FROM t1;
+Warnings:
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+DROP TABLE t1;
+#
+# MDEV-23597 Assertion `marked_for_read()' failed while evaluating DEFAULT
+#
+CREATE TABLE t1 (a INT UNIQUE, b INT DEFAULT (c+1), c int);
+INSERT INTO t1 VALUES (1,1,1);
+UPDATE t1 SET b=DEFAULT;
+SELECT * from t1;
+a b c
+1 2 1
+REPLACE t1 VALUES(1,1,1);
+INSERT INTO t1 VALUES (1,1,1) ON DUPLICATE KEY UPDATE b= DEFAULT;
+SELECT * from t1;
+a b c
+1 2 1
+REPLACE t1 VALUES(1,1,1);
+CREATE TABLE t2 (a INT, b INT DEFAULT (c+1), c int);
+INSERT INTO t2 VALUES (5,5,5);
+UPDATE t1 join t2 set t1.b= DEFAULT, t2.b= DEFAULT;
+SELECT * from t1, t2;
+a b c a b c
+1 2 1 5 6 5
+DROP TABLE t1, t2;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
diff --git a/mysql-test/suite/gcol/r/gcol_ins_upd_myisam.result b/mysql-test/suite/gcol/r/gcol_ins_upd_myisam.result
index c7e5cab4f8c..2c883b2de35 100644
--- a/mysql-test/suite/gcol/r/gcol_ins_upd_myisam.result
+++ b/mysql-test/suite/gcol/r/gcol_ins_upd_myisam.result
@@ -571,13 +571,13 @@ UNIQUE(b1)
INSERT IGNORE INTO t VALUES();
SELECT b from t;
b
-2000
+0000
SELECT b1 from t;
b1
0000
SELECT * from t;
a b c b1 c1
-NULL 2000 0000 0000 0000
+NULL 0000 0000 0000 0000
DELETE FROM t;
CHECK TABLE t EXTENDED;
Table Op Msg_type Msg_text
@@ -669,6 +669,72 @@ INSERT INTO t1 (a) VALUES (0), (0), (0);
ALTER TABLE t1 ADD INDEX idx (b);
DELETE FROM t1;
DROP TEMPORARY TABLE t1;
+#
+# Original test case from MDEV-17890
+#
+CREATE TABLE t1 (
+pk BIGINT AUTO_INCREMENT,
+b BIT(15),
+v BIT(10) AS (b) VIRTUAL,
+PRIMARY KEY(pk),
+UNIQUE(v)
+);
+INSERT IGNORE INTO t1 (b) VALUES (b'101110001110100'),(b'011101');
+Warnings:
+Warning 1264 Out of range value for column 'v' at row 1
+SELECT pk, b FROM t1 INTO OUTFILE 'load.data';
+LOAD DATA INFILE 'load.data' REPLACE INTO TABLE t1 (pk, b);
+ERROR 22001: Data too long for column 'v' at row 1
+DROP TABLE t1;
+#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+CREATE TABLE t1 (
+id INT NOT NULL AUTO_INCREMENT,
+f ENUM('a','b','c'),
+v ENUM('a','b','c') AS (f),
+KEY(v,id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (f) VALUES ('a'),('b');
+INSERT IGNORE INTO t1 SELECT * FROM t1;
+Warnings:
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+DROP TABLE t1;
+CREATE TABLE t1 (
+id INT NOT NULL AUTO_INCREMENT,
+f ENUM('a','b','c'),
+v ENUM('a','b','c') AS (f),
+KEY(v,id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (f) VALUES ('a'),('b');
+INSERT IGNORE INTO t1 SELECT * FROM t1;
+Warnings:
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+DROP TABLE t1;
+#
+# MDEV-23597 Assertion `marked_for_read()' failed while evaluating DEFAULT
+#
+CREATE TABLE t1 (a INT UNIQUE, b INT DEFAULT (c+1), c int);
+INSERT INTO t1 VALUES (1,1,1);
+UPDATE t1 SET b=DEFAULT;
+SELECT * from t1;
+a b c
+1 2 1
+REPLACE t1 VALUES(1,1,1);
+INSERT INTO t1 VALUES (1,1,1) ON DUPLICATE KEY UPDATE b= DEFAULT;
+SELECT * from t1;
+a b c
+1 2 1
+REPLACE t1 VALUES(1,1,1);
+CREATE TABLE t2 (a INT, b INT DEFAULT (c+1), c int);
+INSERT INTO t2 VALUES (5,5,5);
+UPDATE t1 join t2 set t1.b= DEFAULT, t2.b= DEFAULT;
+SELECT * from t1, t2;
+a b c a b c
+1 2 1 5 6 5
+DROP TABLE t1, t2;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
diff --git a/mysql-test/suite/gcol/r/gcol_keys_innodb.result b/mysql-test/suite/gcol/r/gcol_keys_innodb.result
index 37b350c0c32..2d8b81a0ea1 100644
--- a/mysql-test/suite/gcol/r/gcol_keys_innodb.result
+++ b/mysql-test/suite/gcol/r/gcol_keys_innodb.result
@@ -879,7 +879,7 @@ ERROR 22003: Out of range value for column 'vi' at row 1
DROP TABLE t1;
# MDEV-19011 Assertion `file->s->base.reclength < file->s->vreclength'
# failed in ha_myisam::setup_vcols_for_repair
-CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL) ENGINE=MyISAM;
+CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL);
ALTER TABLE t1 ADD KEY (a);
DROP TABLE t1;
#
diff --git a/mysql-test/suite/gcol/r/gcol_keys_myisam.result b/mysql-test/suite/gcol/r/gcol_keys_myisam.result
index 643c4a304a3..17b15826813 100644
--- a/mysql-test/suite/gcol/r/gcol_keys_myisam.result
+++ b/mysql-test/suite/gcol/r/gcol_keys_myisam.result
@@ -879,7 +879,7 @@ ERROR 22003: Out of range value for column 'vi' at row 1
DROP TABLE t1;
# MDEV-19011 Assertion `file->s->base.reclength < file->s->vreclength'
# failed in ha_myisam::setup_vcols_for_repair
-CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL) ENGINE=MyISAM;
+CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL);
ALTER TABLE t1 ADD KEY (a);
DROP TABLE t1;
DROP VIEW IF EXISTS v1,v2;
diff --git a/mysql-test/suite/gcol/r/gcol_partition_innodb.result b/mysql-test/suite/gcol/r/gcol_partition_innodb.result
index e5a68cdb177..d3f211c9b9a 100644
--- a/mysql-test/suite/gcol/r/gcol_partition_innodb.result
+++ b/mysql-test/suite/gcol/r/gcol_partition_innodb.result
@@ -89,6 +89,21 @@ Table Op Msg_type Msg_text
test.t check status OK
DROP TABLE t;
#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+CREATE TABLE t1 (
+a INT,
+b INT,
+c BIT(4) NOT NULL DEFAULT b'0',
+pk INTEGER AUTO_INCREMENT,
+d BIT(4) AS (c) VIRTUAL,
+PRIMARY KEY(pk),
+KEY (b,d)
+) PARTITION BY HASH(pk);
+INSERT INTO t1 () VALUES (),();
+UPDATE t1 SET a = 0 WHERE b IS NULL ORDER BY pk;
+DROP TABLE t1;
+#
# MDEV-16980 Wrongly set tablename len while opening the
# table for purge thread
#
diff --git a/mysql-test/suite/gcol/r/gcol_partition_myisam.result b/mysql-test/suite/gcol/r/gcol_partition_myisam.result
index 81324da6fcd..75e216f903b 100644
--- a/mysql-test/suite/gcol/r/gcol_partition_myisam.result
+++ b/mysql-test/suite/gcol/r/gcol_partition_myisam.result
@@ -86,6 +86,21 @@ CHECK TABLE t EXTENDED;
Table Op Msg_type Msg_text
test.t check status OK
DROP TABLE t;
+#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+CREATE TABLE t1 (
+a INT,
+b INT,
+c BIT(4) NOT NULL DEFAULT b'0',
+pk INTEGER AUTO_INCREMENT,
+d BIT(4) AS (c) VIRTUAL,
+PRIMARY KEY(pk),
+KEY (b,d)
+) PARTITION BY HASH(pk);
+INSERT INTO t1 () VALUES (),();
+UPDATE t1 SET a = 0 WHERE b IS NULL ORDER BY pk;
+DROP TABLE t1;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
diff --git a/mysql-test/suite/gcol/r/gcol_view_innodb.result b/mysql-test/suite/gcol/r/gcol_view_innodb.result
index ec82c792493..03c4a15620a 100644
--- a/mysql-test/suite/gcol/r/gcol_view_innodb.result
+++ b/mysql-test/suite/gcol/r/gcol_view_innodb.result
@@ -271,6 +271,47 @@ a b c
1 -1 -1
drop view v1;
drop table t1;
+#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+CREATE TABLE t1 (d DATETIME(3), v DATETIME(2) AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),
+('1985-12-24 10:15:08.456');
+DELETE FROM v1 ORDER BY v LIMIT 4;
+DROP VIEW v1;
+DROP TABLE t1;
+#
+# [duplicate] MDEV-19306 Assertion `marked_for_read()' failed in
+# Field_blob::val_str with virtual columns and views
+#
+CREATE TABLE t1 (a BLOB, b TEXT AS (a) VIRTUAL);
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (a) VALUES ('foo'),('bar');
+DELETE FROM v1 ORDER BY b LIMIT 2;
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (d INT, v TINYINT AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004'),('1985') ;
+DELETE FROM v1 ORDER BY v LIMIT 4;
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (d VARCHAR(64), v VARCHAR(63) AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),('1985-12-24 10:15:08.456') ;
+DELETE FROM v1 ORDER BY v LIMIT 4;
+DROP TABLE t1;
+DROP VIEW v1;
+#
+# MDEV-18249 ASSERT_COLUMN_MARKED_FOR_READ failed in ANALYZE TABLE
+#
+create table t1 (c varchar(3) not null, v varchar(4) as (c) virtual);
+insert into t1 (c) values ('a'),('b');
+analyze table t1 persistent for columns (v) indexes ();
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
diff --git a/mysql-test/suite/gcol/r/gcol_view_myisam.result b/mysql-test/suite/gcol/r/gcol_view_myisam.result
index 13cb74ebcb5..a030c73401c 100644
--- a/mysql-test/suite/gcol/r/gcol_view_myisam.result
+++ b/mysql-test/suite/gcol/r/gcol_view_myisam.result
@@ -271,6 +271,47 @@ a b c
1 -1 -1
drop view v1;
drop table t1;
+#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+CREATE TABLE t1 (d DATETIME(3), v DATETIME(2) AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),
+('1985-12-24 10:15:08.456');
+DELETE FROM v1 ORDER BY v LIMIT 4;
+DROP VIEW v1;
+DROP TABLE t1;
+#
+# [duplicate] MDEV-19306 Assertion `marked_for_read()' failed in
+# Field_blob::val_str with virtual columns and views
+#
+CREATE TABLE t1 (a BLOB, b TEXT AS (a) VIRTUAL);
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (a) VALUES ('foo'),('bar');
+DELETE FROM v1 ORDER BY b LIMIT 2;
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (d INT, v TINYINT AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004'),('1985') ;
+DELETE FROM v1 ORDER BY v LIMIT 4;
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (d VARCHAR(64), v VARCHAR(63) AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),('1985-12-24 10:15:08.456') ;
+DELETE FROM v1 ORDER BY v LIMIT 4;
+DROP TABLE t1;
+DROP VIEW v1;
+#
+# MDEV-18249 ASSERT_COLUMN_MARKED_FOR_READ failed in ANALYZE TABLE
+#
+create table t1 (c varchar(3) not null, v varchar(4) as (c) virtual);
+insert into t1 (c) values ('a'),('b');
+analyze table t1 persistent for columns (v) indexes ();
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
diff --git a/mysql-test/suite/gcol/t/gcol_ins_upd_innodb.test b/mysql-test/suite/gcol/t/gcol_ins_upd_innodb.test
index 23d97a797e0..15a0db29615 100644
--- a/mysql-test/suite/gcol/t/gcol_ins_upd_innodb.test
+++ b/mysql-test/suite/gcol/t/gcol_ins_upd_innodb.test
@@ -36,7 +36,7 @@ eval SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
-let $support_virtual_index= 0;
+let $support_virtual_index= 1;
--source suite/gcol/inc/gcol_ins_upd.inc
#------------------------------------------------------------------------------#
diff --git a/mysql-test/suite/roles/set_default_role_for.result b/mysql-test/suite/roles/set_default_role_for.result
index 9fde39ca6e4..4c8163b7459 100644
--- a/mysql-test/suite/roles/set_default_role_for.result
+++ b/mysql-test/suite/roles/set_default_role_for.result
@@ -14,7 +14,7 @@ set default role role_a for user_a@localhost;
set default role invalid_role for user_a@localhost;
ERROR OP000: Invalid role specification `invalid_role`
set default role role_b for user_a@localhost;
-ERROR OP000: User `user_a@localhost` has not been granted role `role_b`
+ERROR OP000: User `root`@`localhost` has not been granted role `role_b`
set default role role_b for user_b@localhost;
show grants;
Grants for user_a@localhost
@@ -37,7 +37,7 @@ user host default_role
user_a localhost role_a
user_b localhost role_b
set default role role_b for current_user;
-ERROR OP000: User `user_a@localhost` has not been granted role `role_b`
+ERROR OP000: User `user_a`@`localhost` has not been granted role `role_b`
show grants;
Grants for user_b@localhost
GRANT `role_b` TO `user_b`@`localhost`
diff --git a/mysql-test/suite/roles/set_default_role_invalid.result b/mysql-test/suite/roles/set_default_role_invalid.result
index d6a48b67305..ffe8689e715 100644
--- a/mysql-test/suite/roles/set_default_role_invalid.result
+++ b/mysql-test/suite/roles/set_default_role_invalid.result
@@ -48,7 +48,7 @@ CREATE USER b;
CREATE ROLE r1;
CREATE ROLE r2;
SET DEFAULT ROLE r1 FOR a;
-ERROR OP000: User `a@%` has not been granted role `r1`
+ERROR OP000: User `root`@`localhost` has not been granted role `r1`
GRANT r1 TO b;
GRANT r2 TO b;
SET DEFAULT ROLE r1 FOR b;
@@ -100,7 +100,7 @@ GRANT USAGE ON *.* TO `b`@`%`
GRANT SELECT, UPDATE ON `mysql`.* TO `b`@`%`
SET DEFAULT ROLE `r2` FOR `b`@`%`
SET DEFAULT ROLE r1 FOR a;
-ERROR OP000: User `a@%` has not been granted role `r1`
+ERROR OP000: User `b`@`%` has not been granted role `r1`
SET DEFAULT ROLE invalid_role;
ERROR OP000: Invalid role specification `invalid_role`
SET DEFAULT ROLE invalid_role FOR a;
@@ -117,7 +117,7 @@ SET DEFAULT ROLE None;
# Change user b (session 3: role granted to user a)
SET DEFAULT ROLE r1 FOR a;
SET DEFAULT ROLE r2 FOR a;
-ERROR OP000: User `a@%` has not been granted role `r2`
+ERROR OP000: User `b`@`%` has not been granted role `r2`
SET DEFAULT ROLE invalid_role;
ERROR OP000: Invalid role specification `invalid_role`
SET DEFAULT ROLE invalid_role FOR a;
diff --git a/mysql-test/suite/roles/set_role-recursive.result b/mysql-test/suite/roles/set_role-recursive.result
index d9fb3f11849..d1378f327a8 100644
--- a/mysql-test/suite/roles/set_role-recursive.result
+++ b/mysql-test/suite/roles/set_role-recursive.result
@@ -66,7 +66,7 @@ Grants for test_user@localhost
GRANT USAGE ON *.* TO `test_user`@`localhost`
GRANT `test_role1` TO `test_user`@`localhost`
set role test_role2;
-ERROR OP000: User `test_user@localhost` has not been granted role `test_role2`
+ERROR OP000: User `test_user`@`localhost` has not been granted role `test_role2`
select current_user(), current_role();
current_user() current_role()
test_user@localhost NULL
diff --git a/mysql-test/suite/rpl/r/create_or_replace_mix.result b/mysql-test/suite/rpl/r/create_or_replace_mix.result
index 661278aa7ef..b44b2a5c10f 100644
--- a/mysql-test/suite/rpl/r/create_or_replace_mix.result
+++ b/mysql-test/suite/rpl/r/create_or_replace_mix.result
@@ -100,6 +100,9 @@ include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; create table t1 (a int)
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */
+master-bin.000001 # Query # # ROLLBACK
drop table if exists t1,t2;
Warnings:
Note 1051 Unknown table 'test.t1'
diff --git a/mysql-test/suite/rpl/r/create_or_replace_row.result b/mysql-test/suite/rpl/r/create_or_replace_row.result
index c45daefd671..16f92b5e4b6 100644
--- a/mysql-test/suite/rpl/r/create_or_replace_row.result
+++ b/mysql-test/suite/rpl/r/create_or_replace_row.result
@@ -128,6 +128,9 @@ include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; create table t1 (a int)
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */
+master-bin.000001 # Query # # ROLLBACK
drop table if exists t1,t2;
Warnings:
Note 1051 Unknown table 'test.t1'
diff --git a/mysql-test/suite/rpl/r/create_or_replace_statement.result b/mysql-test/suite/rpl/r/create_or_replace_statement.result
index f95b451e5ec..4d6409b1710 100644
--- a/mysql-test/suite/rpl/r/create_or_replace_statement.result
+++ b/mysql-test/suite/rpl/r/create_or_replace_statement.result
@@ -103,6 +103,8 @@ include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; create table t1 (a int)
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */
drop table if exists t1,t2;
Warnings:
Note 1051 Unknown table 'test.t1'
diff --git a/mysql-test/suite/vcol/r/binlog.result b/mysql-test/suite/vcol/r/binlog.result
index d4893b7ed3c..463928b97b8 100644
--- a/mysql-test/suite/vcol/r/binlog.result
+++ b/mysql-test/suite/vcol/r/binlog.result
@@ -80,4 +80,18 @@ Warnings:
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'b' at row 2
DROP TABLE t1;
+#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+SET SESSION binlog_row_image= noblob;
+CREATE TEMPORARY TABLE t1 SELECT UUID();
+show create table t1;
+Table Create Table
+t1 CREATE TEMPORARY TABLE `t1` (
+ `UUID()` varchar(36) CHARACTER SET utf8 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+CREATE TABLE t2 (a INT PRIMARY KEY, b TEXT, c INT GENERATED ALWAYS AS(b));
+INSERT INTO t2 (a,b) VALUES (1,1);
+SET SESSION binlog_row_image= default;
+DROP TABLE t2;
include/rpl_end.inc
diff --git a/mysql-test/suite/vcol/t/binlog.test b/mysql-test/suite/vcol/t/binlog.test
index aa939086f12..edf0a8957b9 100644
--- a/mysql-test/suite/vcol/t/binlog.test
+++ b/mysql-test/suite/vcol/t/binlog.test
@@ -66,4 +66,18 @@ UPDATE IGNORE t1 SET a = NULL;
DROP TABLE t1;
+--echo #
+--echo # MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+--echo #
+
+SET SESSION binlog_row_image= noblob;
+CREATE TEMPORARY TABLE t1 SELECT UUID();
+show create table t1;
+CREATE TABLE t2 (a INT PRIMARY KEY, b TEXT, c INT GENERATED ALWAYS AS(b));
+INSERT INTO t2 (a,b) VALUES (1,1);
+
+SET SESSION binlog_row_image= default;
+DROP TABLE t2;
+
+
--source include/rpl_end.inc
diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh
index 8a26060c67f..0076e2964d2 100644
--- a/scripts/mysqld_safe.sh
+++ b/scripts/mysqld_safe.sh
@@ -73,12 +73,14 @@ usage () {
cat <<EOF
Usage: $0 [OPTIONS]
--no-defaults Don't read the system defaults file
- --core-file-size=LIMIT Limit core files to the specified size
--defaults-file=FILE Use the specified defaults file
--defaults-extra-file=FILE Also use defaults from the specified file
+ --defaults-group-suffix=X Additionally read default groups with X appended
+ as a suffix
--ledir=DIRECTORY Look for mysqld in the specified directory
--open-files-limit=LIMIT Limit the number of open files
--crash-script=FILE Script to call when mysqld crashes
+ --core-file-size=LIMIT Limit core files to the specified size
--timezone=TZ Set the system timezone
--malloc-lib=LIB Preload shared library LIB if available
--mysqld=FILE Use the specified file as mysqld
diff --git a/sql/field.cc b/sql/field.cc
index 76d9a3ccf95..383c2bb34aa 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -6288,6 +6288,7 @@ bool Field_timef::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
int Field_year::store(const char *from, size_t len,CHARSET_INFO *cs)
{
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
+ THD *thd= get_thd();
char *end;
int error;
longlong nr= cs->cset->strntoull10rnd(cs, from, len, 0, &end, &error);
@@ -6299,7 +6300,14 @@ int Field_year::store(const char *from, size_t len,CHARSET_INFO *cs)
set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1);
return 1;
}
- if (get_thd()->count_cuted_fields > CHECK_FIELD_EXPRESSION &&
+
+ if (thd->count_cuted_fields <= CHECK_FIELD_EXPRESSION && error == MY_ERRNO_EDOM)
+ {
+ *ptr= 0;
+ return 1;
+ }
+
+ if (thd->count_cuted_fields > CHECK_FIELD_EXPRESSION &&
(error= check_int(cs, from, len, end, error)))
{
if (unlikely(error == 1) /* empty or incorrect string */)
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 2e0bf57492c..9fa4d448639 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -5402,8 +5402,7 @@ int ha_partition::index_init(uint inx, bool sorted)
do
{
for (i= 0; i < (*key_info)->user_defined_key_parts; i++)
- bitmap_set_bit(table->read_set,
- (*key_info)->key_part[i].field->field_index);
+ (*key_info)->key_part[i].field->register_field_in_read_map();
} while (*(++key_info));
}
for (i= bitmap_get_first_set(&m_part_info->read_partitions);
diff --git a/sql/item.h b/sql/item.h
index a0c7fe4ee55..ebea56217a8 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -5880,13 +5880,15 @@ public:
class Item_default_value : public Item_field
{
+ bool vcol_assignment_ok;
void calculate();
public:
Item *arg;
Field *cached_field;
- Item_default_value(THD *thd, Name_resolution_context *context_arg, Item *a)
+ Item_default_value(THD *thd, Name_resolution_context *context_arg, Item *a,
+ bool vcol_assignment_arg)
:Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,
- &null_clex_str),
+ &null_clex_str), vcol_assignment_ok(vcol_assignment_arg),
arg(a), cached_field(NULL) {}
enum Type type() const { return DEFAULT_VALUE_ITEM; }
bool eq(const Item *item, bool binary_cmp) const;
@@ -5923,6 +5925,7 @@ public:
if (field && field->default_value)
field->default_value->expr->update_used_tables();
}
+ bool vcol_assignment_allowed_value() const { return vcol_assignment_ok; }
Field *get_tmp_table_field() { return 0; }
Item *get_tmp_table_item(THD *thd) { return this; }
Item_field *field_for_view_update() { return 0; }
diff --git a/sql/key.cc b/sql/key.cc
index 6f0a1112497..72f4e603023 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -467,7 +467,7 @@ void key_unpack(String *to, TABLE *table, KEY *key)
bool is_key_used(TABLE *table, uint idx, const MY_BITMAP *fields)
{
- table->mark_columns_used_by_index(idx, &table->tmp_set);
+ table->mark_index_columns(idx, &table->tmp_set);
return bitmap_is_overlapping(&table->tmp_set, fields);
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 75959540c56..848b37fec62 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -2634,7 +2634,6 @@ end:
my_error(ER_INVALID_ROLE, MYF(0), rolename);
break;
case 1:
- StringBuffer<1024> c_usr;
LEX_CSTRING role_lex;
/* First, check if current user can see mysql database. */
bool read_access= !check_access(thd, SELECT_ACL, "mysql", NULL, NULL, 1, 1);
@@ -2655,11 +2654,9 @@ end:
NULL) == -1))
{
/* Role is not granted but current user can see the role */
- c_usr.append(user, strlen(user));
- c_usr.append('@');
- c_usr.append(host, strlen(host));
- my_printf_error(ER_INVALID_ROLE, "User %`s has not been granted role %`s",
- MYF(0), c_usr.c_ptr(), rolename);
+ my_printf_error(ER_INVALID_ROLE, "User %`s@%`s has not been granted role %`s",
+ MYF(0), thd->security_ctx->priv_user,
+ thd->security_ctx->priv_host, rolename);
}
else
{
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index 5a625eb4f62..71afba74215 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -859,7 +859,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
enum enum_field_types type= (*field_ptr)->type();
if (type < MYSQL_TYPE_MEDIUM_BLOB ||
type > MYSQL_TYPE_BLOB)
- bitmap_set_bit(tab->read_set, fields);
+ tab->field[fields]->register_field_in_read_map();
else
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_NO_EIS_FOR_FIELD,
@@ -887,7 +887,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
enum enum_field_types type= tab->field[pos]->type();
if (type < MYSQL_TYPE_MEDIUM_BLOB ||
type > MYSQL_TYPE_BLOB)
- bitmap_set_bit(tab->read_set, pos);
+ tab->field[pos]->register_field_in_read_map();
else
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_NO_EIS_FOR_FIELD,
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index be3736cdc40..2b06cf27d9b 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -6120,7 +6120,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
TABLE *table= field_to_set->table;
DBUG_ASSERT(table);
if (thd->column_usage == MARK_COLUMNS_READ)
- bitmap_set_bit(table->read_set, field_to_set->field_index);
+ field_to_set->register_field_in_read_map();
else
bitmap_set_bit(table->write_set, field_to_set->field_index);
}
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 6e89da1ee14..d9fb8181cd8 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -6960,8 +6960,8 @@ void THD::binlog_prepare_row_images(TABLE *table)
{
case BINLOG_ROW_IMAGE_MINIMAL:
/* MINIMAL: Mark only PK */
- table->mark_columns_used_by_index(table->s->primary_key,
- &table->tmp_set);
+ table->mark_index_columns(table->s->primary_key,
+ &table->tmp_set);
break;
case BINLOG_ROW_IMAGE_NOBLOB:
/**
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index 933b36f423f..0c04bd7fb0a 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -1027,6 +1027,7 @@ st_select_lex_unit *With_element::clone_parsed_spec(LEX *old_lex,
bool parse_status= false;
st_select_lex *with_select;
+ st_select_lex *last_clone_select;
char save_end= unparsed_spec.str[unparsed_spec.length];
const_cast<char*>(unparsed_spec.str)[unparsed_spec.length]= '\0';
@@ -1114,11 +1115,6 @@ st_select_lex_unit *With_element::clone_parsed_spec(LEX *old_lex,
lex->unit.include_down(with_table->select_lex);
lex->unit.set_slave(with_select);
lex->unit.cloned_from= spec;
- old_lex->all_selects_list=
- (st_select_lex*) (lex->all_selects_list->
- insert_chain_before(
- (st_select_lex_node **) &(old_lex->all_selects_list),
- with_select));
/*
Now all references to the CTE defined outside of the cloned specification
@@ -1134,6 +1130,15 @@ st_select_lex_unit *With_element::clone_parsed_spec(LEX *old_lex,
goto err;
}
+ last_clone_select= lex->all_selects_list;
+ while (last_clone_select->next_select_in_list())
+ last_clone_select= last_clone_select->next_select_in_list();
+ old_lex->all_selects_list=
+ (st_select_lex*) (lex->all_selects_list->
+ insert_chain_before(
+ (st_select_lex_node **) &(old_lex->all_selects_list),
+ last_clone_select));
+
lex->sphead= NULL; // in order not to delete lex->sphead
lex_end(lex);
err:
@@ -1271,6 +1276,7 @@ bool With_element::is_anchor(st_select_lex *sel)
With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table)
{
With_element *found= NULL;
+ With_clause *containing_with_clause= NULL;
st_select_lex_unit *master_unit;
st_select_lex *outer_sl;
for (st_select_lex *sl= this; sl; sl= outer_sl)
@@ -1283,6 +1289,7 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table)
*/
With_clause *attached_with_clause= sl->get_with_clause();
if (attached_with_clause &&
+ attached_with_clause != containing_with_clause &&
(found= attached_with_clause->find_table_def(table, NULL)))
break;
master_unit= sl->master_unit();
@@ -1290,7 +1297,7 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table)
With_element *with_elem= sl->get_with_element();
if (with_elem)
{
- With_clause *containing_with_clause= with_elem->get_owner();
+ containing_with_clause= with_elem->get_owner();
With_element *barrier= containing_with_clause->with_recursive ?
NULL : with_elem;
if ((found= containing_with_clause->find_table_def(table, barrier)))
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 09d15133e6d..f8b91df7941 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -4525,8 +4525,17 @@ select_create::prepare(List<Item> &_values, SELECT_LEX_UNIT *u)
DEBUG_SYNC(thd,"create_table_select_before_check_if_exists");
if (!(table= create_table_from_items(thd, &values, &extra_lock, hook_ptr)))
+ {
+ if (create_info->or_replace())
+ {
+ /* Original table was deleted. We have to log it */
+ log_drop_table(thd, &create_table->db, &create_table->table_name,
+ thd->lex->tmp_table());
+ }
+
/* abort() deletes table */
DBUG_RETURN(-1);
+ }
if (create_info->tmp_table())
{
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index ae070ec8db0..8138e633f3e 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1619,7 +1619,12 @@ static int mysql_test_select(Prepared_statement *stmt,
if (!lex->describe && !thd->lex->analyze_stmt && !stmt->is_sql_prepare())
{
/* Make copy of item list, as change_columns may change it */
- List<Item> fields(lex->select_lex.item_list);
+ SELECT_LEX_UNIT* master_unit= unit->first_select()->master_unit();
+ bool is_union_op=
+ master_unit->is_unit_op() || master_unit->fake_select_lex;
+
+ List<Item> fields(is_union_op ? unit->item_list :
+ lex->select_lex.item_list);
/* Change columns if a procedure like analyse() */
if (unit->last_procedure && unit->last_procedure->change_columns(thd, fields))
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 7a97ae5294f..fdee9c81997 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1537,7 +1537,7 @@ int JOIN::init_join_caches()
if (table->file->keyread_enabled())
{
if (!(table->file->index_flags(table->file->keyread, 0, 1) & HA_CLUSTERED_INDEX))
- table->mark_columns_used_by_index(table->file->keyread, table->read_set);
+ table->mark_index_columns(table->file->keyread, table->read_set);
}
else if ((tab->read_first_record == join_read_first ||
tab->read_first_record == join_read_last) &&
@@ -8539,7 +8539,9 @@ static
double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
table_map rem_tables)
{
- uint16 ref_keyuse_steps[MAX_REF_PARTS - 1];
+ uint16 ref_keyuse_steps_buf[MAX_REF_PARTS];
+ uint ref_keyuse_size= MAX_REF_PARTS;
+ uint16 *ref_keyuse_steps= ref_keyuse_steps_buf;
Field *field;
TABLE *table= s->table;
MY_BITMAP *read_set= table->read_set;
@@ -8686,6 +8688,29 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
}
if (keyparts > 1)
{
+ /*
+ Prepare to set ref_keyuse_steps[keyparts-2]: resize the array
+ if it is not large enough
+ */
+ if (keyparts - 2 >= ref_keyuse_size)
+ {
+ uint new_size= MY_MAX(ref_keyuse_size*2, keyparts);
+ void *new_buf;
+ if (!(new_buf= my_malloc(sizeof(*ref_keyuse_steps)*new_size,
+ MYF(0))))
+ {
+ sel= 1.0; // As if no selectivity was computed
+ goto exit;
+ }
+ memcpy(new_buf, ref_keyuse_steps,
+ sizeof(*ref_keyuse_steps)*ref_keyuse_size);
+ if (ref_keyuse_steps != ref_keyuse_steps_buf)
+ my_free(ref_keyuse_steps);
+
+ ref_keyuse_steps= (uint16*)new_buf;
+ ref_keyuse_size= new_size;
+ }
+
ref_keyuse_steps[keyparts-2]= (uint16)(keyuse - prev_ref_keyuse);
prev_ref_keyuse= keyuse;
}
@@ -8740,7 +8765,9 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
sel*= table_multi_eq_cond_selectivity(join, idx, s, rem_tables,
keyparts, ref_keyuse_steps);
-
+exit:
+ if (ref_keyuse_steps != ref_keyuse_steps_buf)
+ my_free(ref_keyuse_steps);
return sel;
}
@@ -22881,6 +22908,12 @@ check_reverse_order:
if (select->quick == save_quick)
save_quick= 0; // make_reverse() consumed it
select->set_quick(tmp);
+ /* Cancel "Range checked for each record" */
+ if (tab->use_quick == 2)
+ {
+ tab->use_quick= 1;
+ tab->read_first_record= join_init_read_record;
+ }
}
else if (tab->type != JT_NEXT && tab->type != JT_REF_OR_NULL &&
tab->ref.key >= 0 && tab->ref.key_parts <= used_key_parts)
@@ -22893,6 +22926,12 @@ check_reverse_order:
*/
tab->read_first_record= join_read_last_key;
tab->read_record.read_record_func= join_read_prev_same;
+ /* Cancel "Range checked for each record" */
+ if (tab->use_quick == 2)
+ {
+ tab->use_quick= 1;
+ tab->read_first_record= join_init_read_record;
+ }
/*
Cancel Pushed Index Condition, as it doesn't work for reverse scans.
*/
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index af6f5233972..a4ad67ae74e 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -30,6 +30,7 @@
#include "filesort.h" // filesort_free_buffers
#include "sql_view.h"
#include "sql_cte.h"
+#include "item_windowfunc.h"
bool mysql_union(THD *thd, LEX *lex, select_result *result,
SELECT_LEX_UNIT *unit, ulong setup_tables_done_option)
@@ -1875,7 +1876,8 @@ bool st_select_lex_unit::cleanup()
{
DBUG_RETURN(FALSE);
}
- if (with_element && with_element->is_recursive && union_result)
+ if (with_element && with_element->is_recursive && union_result &&
+ with_element->rec_outer_references)
{
select_union_recursive *result= with_element->rec_result;
if (++result->cleanup_count == with_element->rec_outer_references)
@@ -2044,6 +2046,29 @@ static void cleanup_order(ORDER *order)
}
+static void cleanup_window_funcs(List<Item_window_func> &win_funcs)
+{
+ List_iterator_fast<Item_window_func> it(win_funcs);
+ Item_window_func *win_func;
+ while ((win_func= it++))
+ {
+ Window_spec *win_spec= win_func->window_spec;
+ if (!win_spec)
+ continue;
+ if (win_spec->save_partition_list)
+ {
+ win_spec->partition_list= win_spec->save_partition_list;
+ win_spec->save_partition_list= NULL;
+ }
+ if (win_spec->save_order_list)
+ {
+ win_spec->order_list= win_spec->save_order_list;
+ win_spec->save_order_list= NULL;
+ }
+ }
+}
+
+
bool st_select_lex::cleanup()
{
bool error= FALSE;
@@ -2053,6 +2078,8 @@ bool st_select_lex::cleanup()
cleanup_order(group_list.first);
cleanup_ftfuncs(this);
+ cleanup_window_funcs(window_funcs);
+
if (join)
{
List_iterator<TABLE_LIST> ti(leaf_tables);
@@ -2079,7 +2106,8 @@ bool st_select_lex::cleanup()
for (SELECT_LEX_UNIT *lex_unit= first_inner_unit(); lex_unit ;
lex_unit= lex_unit->next_unit())
{
- if (lex_unit->with_element && lex_unit->with_element->is_recursive)
+ if (lex_unit->with_element && lex_unit->with_element->is_recursive &&
+ lex_unit->with_element->rec_outer_references)
continue;
error= (bool) ((uint) error | (uint) lex_unit->cleanup());
}
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 1c4d5cd9b52..e808d7f5de0 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -244,7 +244,7 @@ static void prepare_record_for_error_message(int error, TABLE *table)
/* Create unique_map with all fields used by that index. */
my_bitmap_init(&unique_map, unique_map_buf, table->s->fields, FALSE);
- table->mark_columns_used_by_index(keynr, &unique_map);
+ table->mark_index_columns(keynr, &unique_map);
/* Subtract read_set and write_set. */
bitmap_subtract(&unique_map, table->read_set);
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index abb3937096f..876ddef8f65 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -592,9 +592,15 @@ int compare_window_funcs_by_window_specs(Item_window_func *win_func1,
Let's use only one of the lists.
*/
if (!win_spec1->name() && win_spec2->name())
+ {
+ win_spec1->save_partition_list= win_spec1->partition_list;
win_spec1->partition_list= win_spec2->partition_list;
+ }
else
+ {
+ win_spec2->save_partition_list= win_spec2->partition_list;
win_spec2->partition_list= win_spec1->partition_list;
+ }
cmp= compare_order_lists(win_spec1->order_list,
win_spec2->order_list);
@@ -607,9 +613,15 @@ int compare_window_funcs_by_window_specs(Item_window_func *win_func1,
Let's use only one of the lists.
*/
if (!win_spec1->name() && win_spec2->name())
+ {
+ win_spec1->save_order_list= win_spec2->order_list;
win_spec1->order_list= win_spec2->order_list;
+ }
else
+ {
+ win_spec1->save_order_list= win_spec2->order_list;
win_spec2->order_list= win_spec1->order_list;
+ }
cmp= compare_window_frames(win_spec1->window_frame,
win_spec2->window_frame);
diff --git a/sql/sql_window.h b/sql/sql_window.h
index 373b367b211..5e76a33dcd0 100644
--- a/sql/sql_window.h
+++ b/sql/sql_window.h
@@ -111,8 +111,10 @@ class Window_spec : public Sql_alloc
LEX_CSTRING *window_ref;
SQL_I_List<ORDER> *partition_list;
+ SQL_I_List<ORDER> *save_partition_list;
SQL_I_List<ORDER> *order_list;
+ SQL_I_List<ORDER> *save_order_list;
Window_frame *window_frame;
@@ -123,7 +125,8 @@ class Window_spec : public Sql_alloc
SQL_I_List<ORDER> *ord_list,
Window_frame *win_frame)
: window_names_are_checked(false), window_ref(win_ref),
- partition_list(part_list), order_list(ord_list),
+ partition_list(part_list), save_partition_list(NULL),
+ order_list(ord_list), save_order_list(NULL),
window_frame(win_frame), referenced_win_spec(NULL) {}
virtual const char *name() { return NULL; }
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 3f46f0bb9d7..b915667a239 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1937,7 +1937,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
table_wild simple_expr column_default_non_parenthesized_expr udf_expr
primary_expr string_factor_expr mysql_concatenation_expr
select_sublist_qualified_asterisk
- expr_or_default set_expr_or_default
+ expr_or_ignore expr_or_ignore_or_default set_expr_or_default
geometry_function signed_literal expr_or_literal
sp_opt_default
simple_ident_nospvar
@@ -2426,7 +2426,7 @@ execute_var_list:
;
execute_var_ident:
- expr_or_default
+ expr_or_ignore_or_default
{
if (unlikely(Lex->prepared_stmt_params.push_back($1,
thd->mem_root)))
@@ -10354,7 +10354,7 @@ column_default_non_parenthesized_expr:
if (unlikely(il))
my_yyabort_error((ER_WRONG_COLUMN_NAME, MYF(0), il->my_name()->str));
$$= new (thd->mem_root) Item_default_value(thd, Lex->current_context(),
- $3);
+ $3, 0);
if (unlikely($$ == NULL))
MYSQL_YYABORT;
Lex->default_used= TRUE;
@@ -13592,7 +13592,7 @@ ident_eq_list:
;
ident_eq_value:
- simple_ident_nospvar equal expr_or_default
+ simple_ident_nospvar equal expr_or_ignore_or_default
{
LEX *lex=Lex;
if (unlikely(lex->field_list.push_back($1, thd->mem_root)) ||
@@ -13662,12 +13662,12 @@ opt_values_with_names:
;
values:
- values ',' expr_or_default
+ values ',' expr_or_ignore_or_default
{
if (unlikely(Lex->insert_list->push_back($3, thd->mem_root)))
MYSQL_YYABORT;
}
- | expr_or_default
+ | expr_or_ignore_or_default
{
if (unlikely(Lex->insert_list->push_back($1, thd->mem_root)))
MYSQL_YYABORT;
@@ -13675,7 +13675,7 @@ values:
;
values_with_names:
- values_with_names ',' remember_name expr_or_default remember_end
+ values_with_names ',' remember_name expr_or_ignore_or_default remember_end
{
if (unlikely(Lex->insert_list->push_back($4, thd->mem_root)))
MYSQL_YYABORT;
@@ -13683,7 +13683,7 @@ values_with_names:
if (!$4->name.str || $4->name.str == item_empty_name)
$4->set_name(thd, $3, (uint) ($5 - $3), thd->charset());
}
- | remember_name expr_or_default remember_end
+ | remember_name expr_or_ignore_or_default remember_end
{
if (unlikely(Lex->insert_list->push_back($2, thd->mem_root)))
MYSQL_YYABORT;
@@ -13693,17 +13693,21 @@ values_with_names:
}
;
-expr_or_default:
+expr_or_ignore:
expr { $$= $1;}
- | DEFAULT
+ | IGNORE_SYM
{
- $$= new (thd->mem_root) Item_default_specification(thd);
+ $$= new (thd->mem_root) Item_ignore_specification(thd);
if (unlikely($$ == NULL))
MYSQL_YYABORT;
}
- | IGNORE_SYM
+ ;
+
+expr_or_ignore_or_default:
+ expr_or_ignore { $$= $1;}
+ | DEFAULT
{
- $$= new (thd->mem_root) Item_ignore_specification(thd);
+ $$= new (thd->mem_root) Item_default_specification(thd);
if (unlikely($$ == NULL))
MYSQL_YYABORT;
}
@@ -13765,10 +13769,16 @@ update_list:
;
update_elem:
- simple_ident_nospvar equal expr_or_default
+ simple_ident_nospvar equal DEFAULT
+ {
+ Item *def= new (thd->mem_root) Item_default_value(thd,
+ Lex->current_context(), $1, 1);
+ if (!def || add_item_to_list(thd, $1) || add_value_to_list(thd, def))
+ MYSQL_YYABORT;
+ }
+ | simple_ident_nospvar equal expr_or_ignore
{
- if (unlikely(add_item_to_list(thd, $1)) ||
- unlikely(add_value_to_list(thd, $3)))
+ if (add_item_to_list(thd, $1) || add_value_to_list(thd, $3))
MYSQL_YYABORT;
}
;
@@ -13779,7 +13789,7 @@ insert_update_list:
;
insert_update_elem:
- simple_ident_nospvar equal expr_or_default
+ simple_ident_nospvar equal expr_or_ignore_or_default
{
LEX *lex= Lex;
if (unlikely(lex->update_list.push_back($1, thd->mem_root)) ||
@@ -15046,7 +15056,7 @@ load_data_set_list:
;
load_data_set_elem:
- simple_ident_nospvar equal remember_name expr_or_default remember_end
+ simple_ident_nospvar equal remember_name expr_or_ignore_or_default remember_end
{
LEX *lex= Lex;
if (unlikely(lex->update_list.push_back($1, thd->mem_root)) ||
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index f74af1008c4..3e292fe7ea4 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -1338,7 +1338,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
table_wild simple_expr column_default_non_parenthesized_expr udf_expr
primary_expr string_factor_expr mysql_concatenation_expr
select_sublist_qualified_asterisk
- expr_or_default set_expr_or_default
+ expr_or_ignore expr_or_ignore_or_default set_expr_or_default
geometry_function signed_literal expr_or_literal
sp_opt_default
simple_ident_nospvar
@@ -1848,7 +1848,7 @@ execute_var_list:
;
execute_var_ident:
- expr_or_default
+ expr_or_ignore_or_default
{
if (unlikely(Lex->prepared_stmt_params.push_back($1,
thd->mem_root)))
@@ -10293,7 +10293,7 @@ column_default_non_parenthesized_expr:
if (unlikely(il))
my_yyabort_error((ER_WRONG_COLUMN_NAME, MYF(0), il->my_name()->str));
$$= new (thd->mem_root) Item_default_value(thd, Lex->current_context(),
- $3);
+ $3, 0);
if (unlikely($$ == NULL))
MYSQL_YYABORT;
Lex->default_used= TRUE;
@@ -13546,7 +13546,7 @@ ident_eq_list:
;
ident_eq_value:
- simple_ident_nospvar equal expr_or_default
+ simple_ident_nospvar equal expr_or_ignore_or_default
{
LEX *lex=Lex;
if (unlikely(lex->field_list.push_back($1, thd->mem_root)) ||
@@ -13616,12 +13616,12 @@ opt_values_with_names:
;
values:
- values ',' expr_or_default
+ values ',' expr_or_ignore_or_default
{
if (unlikely(Lex->insert_list->push_back($3, thd->mem_root)))
MYSQL_YYABORT;
}
- | expr_or_default
+ | expr_or_ignore_or_default
{
if (unlikely(Lex->insert_list->push_back($1, thd->mem_root)))
MYSQL_YYABORT;
@@ -13629,7 +13629,7 @@ values:
;
values_with_names:
- values_with_names ',' remember_name expr_or_default remember_end
+ values_with_names ',' remember_name expr_or_ignore_or_default remember_end
{
if (unlikely(Lex->insert_list->push_back($4, thd->mem_root)))
MYSQL_YYABORT;
@@ -13637,7 +13637,7 @@ values_with_names:
if (!$4->name.str || $4->name.str == item_empty_name)
$4->set_name(thd, $3, (uint) ($5 - $3), thd->charset());
}
- | remember_name expr_or_default remember_end
+ | remember_name expr_or_ignore_or_default remember_end
{
if (unlikely(Lex->insert_list->push_back($2, thd->mem_root)))
MYSQL_YYABORT;
@@ -13647,17 +13647,21 @@ values_with_names:
}
;
-expr_or_default:
+expr_or_ignore:
expr { $$= $1;}
- | DEFAULT
+ | IGNORE_SYM
{
- $$= new (thd->mem_root) Item_default_specification(thd);
+ $$= new (thd->mem_root) Item_ignore_specification(thd);
if (unlikely($$ == NULL))
MYSQL_YYABORT;
}
- | IGNORE_SYM
+ ;
+
+expr_or_ignore_or_default:
+ expr_or_ignore { $$= $1;}
+ | DEFAULT
{
- $$= new (thd->mem_root) Item_ignore_specification(thd);
+ $$= new (thd->mem_root) Item_default_specification(thd);
if (unlikely($$ == NULL))
MYSQL_YYABORT;
}
@@ -13719,10 +13723,16 @@ update_list:
;
update_elem:
- simple_ident_nospvar equal expr_or_default
+ simple_ident_nospvar equal DEFAULT
+ {
+ Item *def= new (thd->mem_root) Item_default_value(thd,
+ Lex->current_context(), $1, 1);
+ if (!def || add_item_to_list(thd, $1) || add_value_to_list(thd, def))
+ MYSQL_YYABORT;
+ }
+ | simple_ident_nospvar equal expr_or_ignore
{
- if (unlikely(add_item_to_list(thd, $1)) ||
- unlikely(add_value_to_list(thd, $3)))
+ if (add_item_to_list(thd, $1) || add_value_to_list(thd, $3))
MYSQL_YYABORT;
}
;
@@ -13733,7 +13743,7 @@ insert_update_list:
;
insert_update_elem:
- simple_ident_nospvar equal expr_or_default
+ simple_ident_nospvar equal expr_or_ignore_or_default
{
LEX *lex= Lex;
if (unlikely(lex->update_list.push_back($1, thd->mem_root)) ||
@@ -15006,7 +15016,7 @@ load_data_set_list:
;
load_data_set_elem:
- simple_ident_nospvar equal remember_name expr_or_default remember_end
+ simple_ident_nospvar equal remember_name expr_or_ignore_or_default remember_end
{
LEX *lex= Lex;
if (unlikely(lex->update_list.push_back($1, thd->mem_root)) ||
diff --git a/sql/table.cc b/sql/table.cc
index cf5a95e0929..00db9d7135a 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -6448,7 +6448,7 @@ void TABLE::prepare_for_position()
if ((file->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX) &&
s->primary_key < MAX_KEY)
{
- mark_columns_used_by_index_no_reset(s->primary_key, read_set);
+ mark_index_columns_for_read(s->primary_key);
/* signal change */
file->column_bitmaps_signal();
}
@@ -6464,7 +6464,7 @@ MY_BITMAP *TABLE::prepare_for_keyread(uint index, MY_BITMAP *map)
file->ha_start_keyread(index);
if (map != read_set || !(file->index_flags(index, 0, 1) & HA_CLUSTERED_INDEX))
{
- mark_columns_used_by_index(index, map);
+ mark_index_columns(index, map);
column_bitmaps_set(map);
}
DBUG_RETURN(backup);
@@ -6475,12 +6475,12 @@ MY_BITMAP *TABLE::prepare_for_keyread(uint index, MY_BITMAP *map)
Mark that only fields from one key is used. Useful before keyread.
*/
-void TABLE::mark_columns_used_by_index(uint index, MY_BITMAP *bitmap)
+void TABLE::mark_index_columns(uint index, MY_BITMAP *bitmap)
{
- DBUG_ENTER("TABLE::mark_columns_used_by_index");
+ DBUG_ENTER("TABLE::mark_index_columns");
bitmap_clear_all(bitmap);
- mark_columns_used_by_index_no_reset(index, bitmap);
+ mark_index_columns_no_reset(index, bitmap);
DBUG_VOID_RETURN;
}
@@ -6504,23 +6504,36 @@ void TABLE::restore_column_maps_after_keyread(MY_BITMAP *backup)
DBUG_VOID_RETURN;
}
+static void do_mark_index_columns(TABLE *table, uint index,
+ MY_BITMAP *bitmap, bool read)
+{
+ KEY_PART_INFO *key_part= table->key_info[index].key_part;
+ uint key_parts= table->key_info[index].user_defined_key_parts;
+ for (uint k= 0; k < key_parts; k++)
+ if (read)
+ key_part[k].field->register_field_in_read_map();
+ else
+ bitmap_set_bit(bitmap, key_part[k].fieldnr-1);
+ if (table->file->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX &&
+ table->s->primary_key != MAX_KEY && table->s->primary_key != index)
+ do_mark_index_columns(table, table->s->primary_key, bitmap, read);
+}
/*
mark columns used by key, but don't reset other fields
*/
-void TABLE::mark_columns_used_by_index_no_reset(uint index, MY_BITMAP *bitmap)
+inline void TABLE::mark_index_columns_no_reset(uint index, MY_BITMAP *bitmap)
{
- KEY_PART_INFO *key_part= key_info[index].key_part;
- KEY_PART_INFO *key_part_end= (key_part + key_info[index].user_defined_key_parts);
- for (;key_part != key_part_end; key_part++)
- bitmap_set_bit(bitmap, key_part->fieldnr-1);
- if (file->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX &&
- s->primary_key != MAX_KEY && s->primary_key != index)
- mark_columns_used_by_index_no_reset(s->primary_key, bitmap);
+ do_mark_index_columns(this, index, bitmap, false);
}
+inline void TABLE::mark_index_columns_for_read(uint index)
+{
+ do_mark_index_columns(this, index, read_set, true);
+}
+
/*
Mark auto-increment fields as used fields in both read and write maps
@@ -6539,7 +6552,7 @@ void TABLE::mark_auto_increment_column()
bitmap_set_bit(read_set, found_next_number_field->field_index);
bitmap_set_bit(write_set, found_next_number_field->field_index);
if (s->next_number_keypart)
- mark_columns_used_by_index_no_reset(s->next_number_index, read_set);
+ mark_index_columns_for_read(s->next_number_index);
file->column_bitmaps_signal();
}
@@ -6595,7 +6608,7 @@ void TABLE::mark_columns_needed_for_delete()
file->use_hidden_primary_key();
else
{
- mark_columns_used_by_index_no_reset(s->primary_key, read_set);
+ mark_index_columns_for_read(s->primary_key);
need_signal= true;
}
}
@@ -6688,7 +6701,7 @@ void TABLE::mark_columns_needed_for_update()
file->use_hidden_primary_key();
else
{
- mark_columns_used_by_index_no_reset(s->primary_key, read_set);
+ mark_index_columns_for_read(s->primary_key);
need_signal= true;
}
}
@@ -6848,7 +6861,7 @@ void TABLE::mark_columns_per_binlog_row_image()
if ((my_field->flags & PRI_KEY_FLAG) ||
(my_field->type() != MYSQL_TYPE_BLOB))
{
- bitmap_set_bit(read_set, my_field->field_index);
+ my_field->register_field_in_read_map();
bitmap_set_bit(rpl_write_set, my_field->field_index);
}
}
@@ -6860,7 +6873,7 @@ void TABLE::mark_columns_per_binlog_row_image()
We don't need to mark the primary key in the rpl_write_set as the
binary log will include all columns read anyway.
*/
- mark_columns_used_by_index_no_reset(s->primary_key, read_set);
+ mark_index_columns_for_read(s->primary_key);
if (versioned())
{
// TODO: After MDEV-18432 we don't pass history rows, so remove this:
diff --git a/sql/table.h b/sql/table.h
index 325d4030f4e..53403bd00fe 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1459,8 +1459,9 @@ public:
MY_BITMAP *prepare_for_keyread(uint index, MY_BITMAP *map);
MY_BITMAP *prepare_for_keyread(uint index)
{ return prepare_for_keyread(index, &tmp_set); }
- void mark_columns_used_by_index(uint index, MY_BITMAP *map);
- void mark_columns_used_by_index_no_reset(uint index, MY_BITMAP *map);
+ void mark_index_columns(uint index, MY_BITMAP *bitmap);
+ void mark_index_columns_no_reset(uint index, MY_BITMAP *bitmap);
+ void mark_index_columns_for_read(uint index);
void restore_column_maps_after_keyread(MY_BITMAP *backup);
void mark_auto_increment_column(void);
void mark_columns_needed_for_update(void);
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index c20a1270bb9..d7375f98b6f 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -1203,12 +1203,12 @@ trx_flush_log_if_needed_low(
bool flush = srv_file_flush_method != SRV_NOSYNC;
switch (srv_flush_log_at_trx_commit) {
- case 3:
case 2:
/* Write the log but do not flush it to disk */
flush = false;
/* fall through */
case 1:
+ case 3:
/* Write the log and optionally flush it to disk */
log_write_up_to(lsn, flush);
return;
diff --git a/storage/spider/mysql-test/spider/include/init_master_1.inc b/storage/spider/mysql-test/spider/include/init_master_1.inc
index 2c45d0bd65d..460142b9c7d 100644
--- a/storage/spider/mysql-test/spider/include/init_master_1.inc
+++ b/storage/spider/mysql-test/spider/include/init_master_1.inc
@@ -152,6 +152,11 @@ let $MASTER_1_COMMENT_TEXT_PK1_1=
COMMENT 'tbl "t1", srv "s_2_1"';
let $MASTER_1_COMMENT_TEXT_KEY1_1=
COMMENT 'tbl "t1", srv "s_2_1"';
+let $MASTER_1_COMMENT_MDEV_25985=
+ COMMENT='table "t1"'
+ PARTITION BY LIST COLUMNS(`a`) (
+ PARTITION `pt1` DEFAULT COMMENT = 'srv "s_2_1"'
+ );
let $MASTER_1_CHECK_DIRECT_UPDATE_STATUS=
SHOW STATUS LIKE 'Spider_direct_update';
let $MASTER_1_CHECK_DIRECT_DELETE_STATUS=
diff --git a/storage/spider/mysql-test/spider/r/spider_fixes_part.result b/storage/spider/mysql-test/spider/r/spider_fixes_part.result
index 234d52fed0d..571af94c1f2 100644
--- a/storage/spider/mysql-test/spider/r/spider_fixes_part.result
+++ b/storage/spider/mysql-test/spider/r/spider_fixes_part.result
@@ -262,6 +262,40 @@ a b c d e f
56B68DA68D6D4A04A08B453D09AD7B70 821E71E6ABB4404EBAA349BB681089F8 51041110620310 2018-08-02 13:48:28 510411 0
51ECF2C0CD3C48D99C91792E99D3C1A0 017B8A460DBC444682B791305EF75356 51041110620308 2018-08-02 13:48:29 510411 0
093B37A93A534DF883787AF5F6799674 996C7F14989D480589A553717D735E3E 51041110620302 2018-08-02 13:48:30 510411 0
+#
+# MDEV-25985 Spider handle ">=" as ">" in some cases
+#
+connection child2_1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a int,
+b int,
+c int,
+PRIMARY KEY (a),
+KEY (b,c)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+INSERT INTO t1 VALUES (1, 1, 1), (2, 2, 1);
+connection master_1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a int,
+b int,
+c int,
+PRIMARY KEY (a),
+KEY (b,c)
+) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "t1"'
+ PARTITION BY LIST COLUMNS(`a`) (
+PARTITION `pt1` DEFAULT COMMENT = 'srv "s_2_1"'
+ );
+connection master_1;
+SELECT * FROM t1 WHERE c > 0 AND b >= 1 AND b <= 2;
+a b c
+1 1 1
+2 2 1
+SELECT * FROM t1 WHERE c < 3 AND b <= 2;
+a b c
+1 1 1
+2 2 1
Crash from b4a2baffa82e5c07b96a1c752228560dcac1359b (MDEV-11084)
Fixed with 4968049799193394d442f26b4e3a8d95b185be72
diff --git a/storage/spider/mysql-test/spider/t/spider_fixes_part.test b/storage/spider/mysql-test/spider/t/spider_fixes_part.test
index b0b9ce86588..d2be62a6d31 100644
--- a/storage/spider/mysql-test/spider/t/spider_fixes_part.test
+++ b/storage/spider/mysql-test/spider/t/spider_fixes_part.test
@@ -726,6 +726,41 @@ if ($HAVE_PARTITION)
}
}
+
+--echo #
+--echo # MDEV-25985 Spider handle ">=" as ">" in some cases
+--echo #
+
+--connection child2_1
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+eval CREATE TABLE t1 (
+ a int,
+ b int,
+ c int,
+ PRIMARY KEY (a),
+ KEY (b,c)
+) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+
+INSERT INTO t1 VALUES (1, 1, 1), (2, 2, 1);
+
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+eval CREATE TABLE t1 (
+ a int,
+ b int,
+ c int,
+ PRIMARY KEY (a),
+ KEY (b,c)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_MDEV_25985;
+
+--connection master_1
+SELECT * FROM t1 WHERE c > 0 AND b >= 1 AND b <= 2;
+SELECT * FROM t1 WHERE c < 3 AND b <= 2;
+
--echo
--echo Crash from b4a2baffa82e5c07b96a1c752228560dcac1359b (MDEV-11084)
--echo Fixed with 4968049799193394d442f26b4e3a8d95b185be72
diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc
index 424f22d46ee..c488dfcb806 100644
--- a/storage/spider/spd_db_conn.cc
+++ b/storage/spider/spd_db_conn.cc
@@ -1921,12 +1921,20 @@ int spider_db_append_key_where_internal(
case HA_READ_AFTER_KEY:
if (sql_kind == SPIDER_SQL_KIND_SQL)
{
+ const char* op_str;
+ uint32 op_len;
+ if (start_key_part_map == 1) {
+ op_str = SPIDER_SQL_GT_STR;
+ op_len = SPIDER_SQL_GT_LEN;
+ } else {
+ op_str = SPIDER_SQL_GTEQUAL_STR;
+ op_len = SPIDER_SQL_GTEQUAL_LEN;
+ }
if (str->reserve(store_length + key_name_length +
- /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 +
- SPIDER_SQL_GT_LEN))
+ /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + op_len))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
dbton_share->append_column_name(str, field->field_index);
- str->q_append(SPIDER_SQL_GT_STR, SPIDER_SQL_GT_LEN);
+ str->q_append(op_str, op_len);
if (spider_dbton[dbton_id].db_util->
append_column_value(spider, str, field, ptr,
share->access_charset))
@@ -1981,12 +1989,20 @@ int spider_db_append_key_where_internal(
result_list->desc_flg = TRUE;
if (sql_kind == SPIDER_SQL_KIND_SQL)
{
+ const char* op_str;
+ uint32 op_len;
+ if (start_key_part_map == 1) {
+ op_str = SPIDER_SQL_LT_STR;
+ op_len = SPIDER_SQL_LT_LEN;
+ } else {
+ op_str = SPIDER_SQL_LTEQUAL_STR;
+ op_len = SPIDER_SQL_LTEQUAL_LEN;
+ }
if (str->reserve(store_length + key_name_length +
- /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 +
- SPIDER_SQL_LT_LEN))
+ /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + op_len))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
dbton_share->append_column_name(str, field->field_index);
- str->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN);
+ str->q_append(op_str, op_len);
if (spider_dbton[dbton_id].db_util->
append_column_value(spider, str, field, ptr,
share->access_charset))
@@ -2351,12 +2367,20 @@ int spider_db_append_key_where_internal(
case HA_READ_BEFORE_KEY:
if (sql_kind == SPIDER_SQL_KIND_SQL)
{
+ const char* op_str;
+ uint32 op_len;
+ if (end_key_part_map == 1) {
+ op_str = SPIDER_SQL_LT_STR;
+ op_len = SPIDER_SQL_LT_LEN;
+ } else {
+ op_str = SPIDER_SQL_LTEQUAL_STR;
+ op_len = SPIDER_SQL_LTEQUAL_LEN;
+ }
if (str->reserve(store_length + key_name_length +
- /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 +
- SPIDER_SQL_LT_LEN))
+ /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + op_len))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
dbton_share->append_column_name(str, field->field_index);
- str->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN);
+ str->q_append(op_str, op_len);
if (spider_dbton[dbton_id].db_util->
append_column_value(spider, str, field, ptr,
share->access_charset))
diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt
index 7ceccfbbf12..2d9e808019e 100644
--- a/support-files/CMakeLists.txt
+++ b/support-files/CMakeLists.txt
@@ -79,7 +79,7 @@ IF(UNIX)
INSTALL(FILES ${out} DESTINATION ${inst_location}/policy/selinux COMPONENT SupportFiles)
ENDFOREACH()
IF(RPM)
- EXECUTE_PROCESS(COMMAND rpm -q --qf "%{VERSION}-%{RELEASE}" libsepol
+ EXECUTE_PROCESS(COMMAND rpm -q --qf "%{VERSION}" libsepol
OUTPUT_VARIABLE LIBSEPOL_VERSION RESULT_VARIABLE err)
IF (NOT err)
SET(CPACK_RPM_server_PACKAGE_REQUIRES
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 3c0b05cf187..554eec83644 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -20520,6 +20520,71 @@ static void test_ps_params_in_ctes()
myquery(rc);
}
+void display_result_metadata(MYSQL_FIELD *field,
+ uint num_fields)
+{
+ MYSQL_FIELD* field_end;
+
+ mct_log("Catalog\tDatabase\tTable\tTable_alias\tColumn\t"
+ "Column_alias\tType\tLength\tMax length\tIs_null\t"
+ "Flags\tDecimals\tCharsetnr\n");
+ for (field_end= field+num_fields; field < field_end; field++)
+ {
+ mct_log("%s\t", field->catalog);
+ mct_log("%s\t", field->db);
+ mct_log("%s\t", field->org_table);
+ mct_log("%s\t", field->table);
+ mct_log("%s\t", field->org_name);
+ mct_log("%s\t", field->name);
+ mct_log("%u\t", field->type);
+ mct_log("%lu\t", field->length);
+ mct_log("%lu\t", field->max_length);
+ mct_log("%s\t", (IS_NOT_NULL(field->flags) ? "N" : "Y"));
+ mct_log("%u\t", field->flags);
+ mct_log("%u\t", field->decimals);
+ mct_log("%u\n", field->charsetnr);
+ }
+}
+
+static void test_mdev_26145()
+{
+ MYSQL_STMT *stmt;
+ MYSQL_RES *result;
+ MYSQL_FIELD *fields;
+ int rc, num_fields;
+
+ myheader("test_mdev_26145");
+
+ rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
+ myquery(rc);
+
+ rc= mysql_query(mysql, "CREATE TABLE t1(a INT)");
+ myquery(rc);
+
+ stmt= mysql_simple_prepare(
+ mysql, "(SELECT MAX(a) FROM t1) UNION (SELECT MAX(a) FROM t1)");
+ check_stmt(stmt);
+
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+
+ result= mysql_stmt_result_metadata(stmt);
+ DIE_UNLESS(result);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ fields= mysql_fetch_fields(result);
+
+ mct_start_logging("test_mdev26145");
+ display_result_metadata(fields, num_fields);
+ mct_close_log();
+
+ mysql_free_result(result);
+ mysql_stmt_close(stmt);
+
+ rc= mysql_query(mysql, "DROP TABLE t1");
+
+ myquery(rc);
+}
static void print_metadata(MYSQL_RES *rs_metadata, int num_fields)
{
@@ -21011,6 +21076,7 @@ static void test_mdev19838()
static struct my_tests_st my_tests[]= {
+ { "test_mdev_26145", test_mdev_26145 },
{ "disable_query_logs", disable_query_logs },
{ "test_view_sp_list_fields", test_view_sp_list_fields },
{ "client_query", client_query },