Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext
Browse files Browse the repository at this point in the history
Conflicts:
	sql/item_cmpfunc.cc
	storage/innobase/buf/buf0flu.cc
	storage/innobase/include/ut0stage.h
	storage/innobase/row/row0upd.cc
  • Loading branch information
Alexey Botchkov committed Aug 11, 2017
2 parents 837aa57 + 79d2853 commit 1a9e13d
Show file tree
Hide file tree
Showing 30 changed files with 231 additions and 46 deletions.
19 changes: 19 additions & 0 deletions mysql-test/r/view.result
Original file line number Diff line number Diff line change
Expand Up @@ -6573,6 +6573,25 @@ Warnings:
Warning 1356 View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
DROP VIEW v;
#
# MDEV-13439: Database permissions are not enough to run a subquery
# with GROUP BY within a view
#
create database test_db;
use test_db;
create table t (i int);
create user foo@localhost;
grant all on test_db.* to foo@localhost;
connect con1,localhost,foo,,;
use test_db;
create view v as select * from (select i from t group by i) sq;
select * from v;
i
disconnect con1;
connection default;
use test;
drop database test_db;
drop user foo@localhost;
#
# End of 10.2 tests
#
#
Expand Down
13 changes: 13 additions & 0 deletions mysql-test/suite/gcol/r/gcol_bugfixes.result
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,19 @@ SELECT 1 FROM t WHERE c GROUP BY b;
COMMIT;
DROP TABLE t;
#
# Bug #25793677 INNODB: FAILING ASSERTION: CLUST_TEMPL_FOR_SEC || LEN ....
#
CREATE TABLE v (
a INT,
c INT,
b CHAR(2) GENERATED ALWAYS AS (a IN (1)) VIRTUAL,
KEY(c,b(1))) charset utf8mb4;
INSERT INTO v (a,c) VALUES (1,1);
SELECT (SELECT MAX(c) FROM v);
(SELECT MAX(c) FROM v)
1
DROP TABLE v;
#
# MDEV-9255 Add generation_expression to information_schema.columns.
#
CREATE TABLE gcol_t1 (
Expand Down
13 changes: 13 additions & 0 deletions mysql-test/suite/gcol/t/gcol_bugfixes.test
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,19 @@ SELECT 1 FROM t WHERE c GROUP BY b;
COMMIT;
DROP TABLE t;

--echo #
--echo # Bug #25793677 INNODB: FAILING ASSERTION: CLUST_TEMPL_FOR_SEC || LEN ....
--echo #

CREATE TABLE v (
a INT,
c INT,
b CHAR(2) GENERATED ALWAYS AS (a IN (1)) VIRTUAL,
KEY(c,b(1))) charset utf8mb4;
INSERT INTO v (a,c) VALUES (1,1);
SELECT (SELECT MAX(c) FROM v);
DROP TABLE v;

--echo #
--echo # MDEV-9255 Add generation_expression to information_schema.columns.
--echo #
Expand Down
20 changes: 20 additions & 0 deletions mysql-test/suite/innodb/r/rename_table.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CREATE DATABASE test_jfg;
CREATE DATABASE test_jfg2;
CREATE TABLE test_jfg.test (a int unsigned PRIMARY KEY) ENGINE=InnoDB;
RENAME TABLE test_jfg.test TO test_jfg2.test;
SELECT REPLACE(path,'\\','/') path
FROM INFORMATION_SCHEMA.INNODB_SYS_DATAFILES WHERE PATH LIKE '%test%';
path
./test_jfg2/test.ibd
DROP DATABASE test_jfg;
DROP DATABASE test_jfg2;
CREATE DATABASE abc_def;
CREATE DATABASE abc_def2;
CREATE TABLE abc_def.test (a int unsigned PRIMARY KEY) ENGINE=InnoDB;
RENAME TABLE abc_def.test TO abc_def2.test1;
SELECT REPLACE(path,'\\','/') path
FROM INFORMATION_SCHEMA.INNODB_SYS_DATAFILES WHERE PATH LIKE '%test%';
path
./abc_def2/test1.ibd
DROP DATABASE abc_def;
DROP DATABASE abc_def2;
2 changes: 2 additions & 0 deletions mysql-test/suite/innodb/t/rename_table.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--innodb
--innodb-sys-datafiles
31 changes: 31 additions & 0 deletions mysql-test/suite/innodb/t/rename_table.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--source include/have_innodb.inc
--source include/not_embedded.inc

CREATE DATABASE test_jfg;
CREATE DATABASE test_jfg2;
CREATE TABLE test_jfg.test (a int unsigned PRIMARY KEY) ENGINE=InnoDB;
RENAME TABLE test_jfg.test TO test_jfg2.test;

SELECT REPLACE(path,'\\','/') path
FROM INFORMATION_SCHEMA.INNODB_SYS_DATAFILES WHERE PATH LIKE '%test%';

DROP DATABASE test_jfg;

--source include/restart_mysqld.inc

DROP DATABASE test_jfg2;

CREATE DATABASE abc_def;
CREATE DATABASE abc_def2;

CREATE TABLE abc_def.test (a int unsigned PRIMARY KEY) ENGINE=InnoDB;
RENAME TABLE abc_def.test TO abc_def2.test1;

SELECT REPLACE(path,'\\','/') path
FROM INFORMATION_SCHEMA.INNODB_SYS_DATAFILES WHERE PATH LIKE '%test%';

DROP DATABASE abc_def;

--source include/restart_mysqld.inc

DROP DATABASE abc_def2;
2 changes: 1 addition & 1 deletion mysql-test/suite/sys_vars/r/sysvars_innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -3074,7 +3074,7 @@ READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_VERSION
SESSION_VALUE NULL
GLOBAL_VALUE 5.7.18
GLOBAL_VALUE 5.7.19
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL
VARIABLE_SCOPE GLOBAL
Expand Down
25 changes: 25 additions & 0 deletions mysql-test/t/view.test
Original file line number Diff line number Diff line change
Expand Up @@ -6274,6 +6274,31 @@ DROP TABLE IF EXISTS t;
SHOW CREATE VIEW v;
DROP VIEW v;

--echo #
--echo # MDEV-13439: Database permissions are not enough to run a subquery
--echo # with GROUP BY within a view
--echo #

create database test_db;
use test_db;
create table t (i int);

create user foo@localhost;
grant all on test_db.* to foo@localhost;

--connect (con1,localhost,foo,,)

use test_db;
create view v as select * from (select i from t group by i) sq;
select * from v;

# Cleanup
--disconnect con1
--connection default
use test;
drop database test_db;
drop user foo@localhost;

--echo #
--echo # End of 10.2 tests
--echo #
Expand Down
4 changes: 2 additions & 2 deletions scripts/wsrep_sst_mysqldump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ then
fi

# Check client version
if ! $MYSQL_CLIENT --version | grep 'Distrib 10.1' >/dev/null
if ! $MYSQL_CLIENT --version | grep 'Distrib 10.' >/dev/null
then
$MYSQL_CLIENT --version >&2
wsrep_log_error "this operation requires MySQL client version 10 or newer"
Expand Down Expand Up @@ -133,7 +133,7 @@ SET_GTID_BINLOG_STATE=""
SQL_LOG_BIN_OFF=""

# Safety check
if echo $SERVER_VERSION | grep '^10.1' > /dev/null
if echo $SERVER_VERSION | grep '^10.' > /dev/null
then
# If binary logging is enabled on the joiner node, we need to copy donor's
# gtid_binlog_state to joiner. In order to do that, a RESET MASTER must be
Expand Down
5 changes: 2 additions & 3 deletions sql/item_cmpfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -550,14 +550,14 @@ bool Arg_comparator::set_cmp_func_string()
{
func= is_owner_equal_func() ? &Arg_comparator::compare_e_json_str:
&Arg_comparator::compare_json_str;
return false;
return 0;
}
else if ((*b)->type() == Item::FUNC_ITEM &&
((Item_func *) (*b))->functype() == Item_func::JSON_EXTRACT_FUNC)
{
func= is_owner_equal_func() ? &Arg_comparator::compare_e_json_str:
&Arg_comparator::compare_str_json;
return false;
return 0;
}
}

Expand Down Expand Up @@ -650,7 +650,6 @@ bool Arg_comparator::set_cmp_func_real()
return false;
}


bool Arg_comparator::set_cmp_func_decimal()
{
THD *thd= current_thd;
Expand Down
5 changes: 4 additions & 1 deletion sql/sql_acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7630,8 +7630,11 @@ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables,
/*
It is subquery in the FROM clause. VIEW set t_ref->derived after
table opening, but this function always called before table opening.

NOTE: is_derived() can't be used here because subquery in this case
the FROM clase (derived tables) can be not be marked yet.
*/
if (!t_ref->referencing_view)
if (t_ref->is_anonymous_derived_table() || t_ref->schema_table)
{
/*
If it's a temporary table created for a subquery in the FROM
Expand Down
10 changes: 8 additions & 2 deletions sql/sql_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,8 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
flags.client_long_flag= MY_TEST(thd->client_capabilities & CLIENT_LONG_FLAG);
flags.client_protocol_41= MY_TEST(thd->client_capabilities &
CLIENT_PROTOCOL_41);
flags.client_depr_eof= MY_TEST(thd->client_capabilities &
CLIENT_DEPRECATE_EOF);
/*
Protocol influences result format, so statement results in the binary
protocol (COM_EXECUTE) cannot be served to statements asking for results
Expand Down Expand Up @@ -1443,12 +1445,13 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
flags.div_precision_increment= thd->variables.div_precincrement;
flags.default_week_format= thd->variables.default_week_format;
DBUG_PRINT("qcache", ("\
long %d, 4.1: %d, bin_proto: %d, more results %d, pkt_nr: %d, \
long %d, 4.1: %d, eof: %d, bin_proto: %d, more results %d, pkt_nr: %d, \
CS client: %u, CS result: %u, CS conn: %u, limit: %lu, TZ: 0x%lx, \
sql mode: 0x%llx, sort len: %lu, conncat len: %lu, div_precision: %lu, \
def_week_frmt: %lu, in_trans: %d, autocommit: %d",
(int)flags.client_long_flag,
(int)flags.client_protocol_41,
(int)flags.client_depr_eof,
(int)flags.protocol_type,
(int)flags.more_results_exists,
flags.pkt_nr,
Expand Down Expand Up @@ -1917,6 +1920,8 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length)
flags.client_long_flag= MY_TEST(thd->client_capabilities & CLIENT_LONG_FLAG);
flags.client_protocol_41= MY_TEST(thd->client_capabilities &
CLIENT_PROTOCOL_41);
flags.client_depr_eof= MY_TEST(thd->client_capabilities &
CLIENT_DEPRECATE_EOF);
flags.protocol_type= (unsigned int) thd->protocol->type();
flags.more_results_exists= MY_TEST(thd->server_status &
SERVER_MORE_RESULTS_EXISTS);
Expand All @@ -1938,12 +1943,13 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length)
flags.default_week_format= thd->variables.default_week_format;
flags.lc_time_names= thd->variables.lc_time_names;
DBUG_PRINT("qcache", ("\
long %d, 4.1: %d, bin_proto: %d, more results %d, pkt_nr: %d, \
long %d, 4.1: %d, eof: %d, bin_proto: %d, more results %d, pkt_nr: %d, \
CS client: %u, CS result: %u, CS conn: %u, limit: %lu, TZ: 0x%lx, \
sql mode: 0x%llx, sort len: %lu, conncat len: %lu, div_precision: %lu, \
def_week_frmt: %lu, in_trans: %d, autocommit: %d",
(int)flags.client_long_flag,
(int)flags.client_protocol_41,
(int)flags.client_depr_eof,
(int)flags.protocol_type,
(int)flags.more_results_exists,
flags.pkt_nr,
Expand Down
1 change: 1 addition & 0 deletions sql/sql_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ struct Query_cache_query_flags
{
unsigned int client_long_flag:1;
unsigned int client_protocol_41:1;
unsigned int client_depr_eof:1;
unsigned int protocol_type:2;
unsigned int more_results_exists:1;
unsigned int in_trans:1;
Expand Down
7 changes: 4 additions & 3 deletions sql/sql_derived.cc
Original file line number Diff line number Diff line change
Expand Up @@ -823,13 +823,14 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
table->derived_select_number= first_select->select_number;
table->s->tmp_table= INTERNAL_TMP_TABLE;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (derived->referencing_view)
if (derived->is_view())
table->grant= derived->grant;
else
{
DBUG_ASSERT(derived->is_derived());
DBUG_ASSERT(derived->is_anonymous_derived_table());
table->grant.privilege= SELECT_ACL;
if (derived->is_derived())
derived->grant.privilege= SELECT_ACL;
derived->grant.privilege= SELECT_ACL;
}
#endif
/* Add new temporary table to list of open derived tables */
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/buf/buf0buf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6038,7 +6038,7 @@ buf_page_io_complete(buf_page_t* bpage, bool evict)
&& fil_page_get_type(frame) == FIL_PAGE_INDEX
&& page_is_leaf(frame)) {

if (bpage && bpage->encrypted) {
if (bpage->encrypted) {
ib::warn()
<< "Table in tablespace "
<< bpage->id.space()
Expand Down
5 changes: 1 addition & 4 deletions storage/innobase/buf/buf0flu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1884,8 +1884,6 @@ buf_flush_batch(

buf_pool_mutex_enter(buf_pool);

ulint count __attribute__((unused))= 0;

/* Note: The buffer pool mutex is released and reacquired within
the flush functions. */
switch (flush_type) {
Expand All @@ -1902,8 +1900,7 @@ buf_flush_batch(

buf_pool_mutex_exit(buf_pool);

DBUG_PRINT("ib_buf", ("flush %u completed, %u pages",
unsigned(flush_type), unsigned(count)));
DBUG_LOG("ib_buf", "flush " << flush_type << " completed");
}

/******************************************************************//**
Expand Down
16 changes: 12 additions & 4 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3292,15 +3292,17 @@ fil_prepare_for_truncate(

/** Reinitialize the original tablespace header with the same space id
for single tablespace
@param[in] id space id of the tablespace
@param[in] table table belongs to tablespace
@param[in] size size in blocks
@param[in] trx Transaction covering truncate */
void
fil_reinit_space_header(
ulint id,
fil_reinit_space_header_for_table(
dict_table_t* table,
ulint size,
trx_t* trx)
{
ulint id = table->space;

ut_a(!is_system_tablespace(id));

/* Invalidate in the buffer pool all pages belonging
Expand All @@ -3309,6 +3311,9 @@ fil_reinit_space_header(
and the dict operation lock during the scan and aquire
it again after the buffer pool scan.*/

/* Release the lock on the indexes too. So that
they won't violate the latch ordering. */
dict_table_x_unlock_indexes(table);
row_mysql_unlock_data_dictionary(trx);

/* Lock the search latch in shared mode to prevent user
Expand All @@ -3317,8 +3322,11 @@ fil_reinit_space_header(
DEBUG_SYNC_C("buffer_pool_scan");
buf_LRU_flush_or_remove_pages(id, BUF_REMOVE_ALL_NO_WRITE, 0);
btr_search_s_unlock_all();

row_mysql_lock_data_dictionary(trx);

dict_table_x_lock_indexes(table);

/* Remove all insert buffer entries for the tablespace */
ibuf_delete_for_discarded_space(id);

Expand Down Expand Up @@ -4636,7 +4644,7 @@ fil_ibd_load(
break;
}

/* Fall through to error handling */
/* fall through */

case DB_TABLESPACE_EXISTS:
return(FIL_LOAD_INVALID);
Expand Down
12 changes: 8 additions & 4 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15648,10 +15648,14 @@ get_foreign_key_info(

if (ref_table == NULL) {

ib::info() << "Foreign Key referenced table "
<< foreign->referenced_table_name
<< " not found for foreign table "
<< foreign->foreign_table_name;
if (!thd_test_options(
thd, OPTION_NO_FOREIGN_KEY_CHECKS)) {
ib::info()
<< "Foreign Key referenced table "
<< foreign->referenced_table_name
<< " not found for foreign table "
<< foreign->foreign_table_name;
}
} else {

dict_table_close(ref_table, TRUE, FALSE);
Expand Down
Loading

0 comments on commit 1a9e13d

Please sign in to comment.