Skip to content

Commit

Permalink
Merge 10.3 into 10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Mar 12, 2019
2 parents 6d68a34 + 69b33fc commit e450527
Show file tree
Hide file tree
Showing 29 changed files with 253 additions and 75 deletions.
3 changes: 2 additions & 1 deletion client/mysqltest.cc
Expand Up @@ -192,6 +192,7 @@ static char TMPDIR[FN_REFLEN];
static char global_subst_from[200];
static char global_subst_to[200];
static char *global_subst= NULL;
static char *read_command_buf= NULL;
static MEM_ROOT require_file_root;
static const my_bool my_true= 1;
static const my_bool my_false= 0;
Expand Down Expand Up @@ -1531,6 +1532,7 @@ void free_used_memory()
free_defaults(default_argv);
free_root(&require_file_root, MYF(0));
free_re();
my_free(read_command_buf);
#ifdef _WIN32
free_tmp_sh_file();
free_win_path_patterns();
Expand Down Expand Up @@ -6552,7 +6554,6 @@ static inline bool is_escape_char(char c, char in_string)
*/

static char *read_command_buf= NULL;
static size_t read_command_buflen= 0;
static const size_t max_multibyte_length= 6;

Expand Down
13 changes: 13 additions & 0 deletions mysql-test/main/check_constraint.result
Expand Up @@ -222,3 +222,16 @@ ERROR 23000: CONSTRAINT `t.b` failed for `test`.`t`
insert into t values (1,1);
ERROR 23000: CONSTRAINT `b` failed for `test`.`t`
drop table t;
create table t1 (a int auto_increment primary key, b int, check (b > 5));
insert t1 (b) values (1);
ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1`
insert t1 (b) values (10);
select * from t1 where a is null;
a b
set sql_auto_is_null=1;
select * from t1 where a is null;
a b
1 10
insert t1 (b) values (1);
ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1`
drop table t1;
14 changes: 14 additions & 0 deletions mysql-test/main/check_constraint.test
Expand Up @@ -162,3 +162,17 @@ insert into t values (-1, 0);
insert into t values (1,1);

drop table t;

#
# check constraints and auto_is_null typo
#
create table t1 (a int auto_increment primary key, b int, check (b > 5));
--error ER_CONSTRAINT_FAILED
insert t1 (b) values (1);
insert t1 (b) values (10);
select * from t1 where a is null;
set sql_auto_is_null=1;
select * from t1 where a is null;
--error ER_CONSTRAINT_FAILED
insert t1 (b) values (1);
drop table t1;
12 changes: 12 additions & 0 deletions mysql-test/main/func_json.result
Expand Up @@ -831,6 +831,18 @@ select JSON_VALID( '{"a":1]' );
JSON_VALID( '{"a":1]' )
0
#
# MDEV-18886 JSON_ARRAY() does not recognise JSON argument.
#
SELECT JSON_ARRAY(_UTF8 'str', JSON_OBJECT(_LATIN1 'plugin', _LATIN1'unix_socket'));
JSON_ARRAY(_UTF8 'str', JSON_OBJECT(_LATIN1 'plugin', _LATIN1'unix_socket'))
["str", {"plugin": "unix_socket"}]
SELECT CHARSET(JSON_ARRAY());
CHARSET(JSON_ARRAY())
latin1
SELECT CHARSET(JSON_OBJECT());
CHARSET(JSON_OBJECT())
latin1
#
# End of 10.2 tests
#
#
Expand Down
7 changes: 7 additions & 0 deletions mysql-test/main/func_json.test
Expand Up @@ -484,6 +484,13 @@ SET sql_mode=default;

select JSON_VALID( '{"a":1]' );

--echo #
--echo # MDEV-18886 JSON_ARRAY() does not recognise JSON argument.
--echo #
SELECT JSON_ARRAY(_UTF8 'str', JSON_OBJECT(_LATIN1 'plugin', _LATIN1'unix_socket'));
SELECT CHARSET(JSON_ARRAY());
SELECT CHARSET(JSON_OBJECT());

--echo #
--echo # End of 10.2 tests
--echo #
Expand Down
16 changes: 8 additions & 8 deletions mysql-test/main/mysqlbinlog.result
Expand Up @@ -724,7 +724,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1253783037/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
Expand Down Expand Up @@ -778,7 +778,7 @@ DELIMITER /*!*/;
ROLLBACK/*!*/;
SET TIMESTAMP=1253783037/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
Expand Down Expand Up @@ -813,7 +813,7 @@ ROLLBACK /* added by mysqlbinlog */;
DELIMITER /*!*/;
SET TIMESTAMP=1266652094/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
Expand Down Expand Up @@ -855,7 +855,7 @@ ROLLBACK /* added by mysqlbinlog */;
DELIMITER /*!*/;
SET TIMESTAMP=1266652094/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
Expand Down Expand Up @@ -962,7 +962,7 @@ AAAAAAAAAAAAAAAAAAAgrgJSFzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
# Event: Query thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1375907364/*!*/;
SET @@session.pseudo_thread_id=1/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
Expand Down Expand Up @@ -1045,7 +1045,7 @@ AAAAAAAAAAAAAAAAAAA/rQJSGzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
# Event: Query thread_id=1 exec_time=1 error_code=0
SET TIMESTAMP=1375907141/*!*/;
SET @@session.pseudo_thread_id=1/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
Expand Down Expand Up @@ -1128,7 +1128,7 @@ AAAAAAAAAAAAAAAAAAAnrAJSHzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
# Event: Query thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1375906879/*!*/;
SET @@session.pseudo_thread_id=1/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
Expand Down Expand Up @@ -1211,7 +1211,7 @@ AAAAAAAAAAAAAAAAAABbsAJSEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
# Event: Query thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1375907933/*!*/;
SET @@session.pseudo_thread_id=1/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
Expand Down
53 changes: 53 additions & 0 deletions mysql-test/main/reopen_temp_table.result
Expand Up @@ -190,3 +190,56 @@ NULL NULL
DROP TABLE t;
# Cleanup
DROP DATABASE temp_db;
USE test;
create temporary table t1 (f char(255), b int, index(b)) engine=MyISAM;
replace into t1 values (null,1),(null,2);
alter table t1 add fulltext key(f);
alter table t1 change if exists a b int, algorithm=inplace;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1;
f b
NULL 1
NULL 2
drop table t1;
create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=1;
replace into t1 values (null,1),(null,2);
alter table t1 add fulltext key(f);
alter table t1 change if exists a b int, algorithm=inplace;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1;
f b
NULL 1
NULL 2
drop table t1;
create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=0 row_format=page;
replace into t1 values (null,1),(null,2);
alter table t1 add fulltext key(f);
alter table t1 change if exists a b int, algorithm=inplace;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1;
f b
NULL 1
NULL 2
drop table t1;
create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=0 row_format=dynamic;
replace into t1 values (null,1),(null,2);
alter table t1 add fulltext key(f);
alter table t1 change if exists a b int, algorithm=inplace;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1;
f b
NULL 1
NULL 2
drop table t1;
40 changes: 40 additions & 0 deletions mysql-test/main/reopen_temp_table.test
Expand Up @@ -182,3 +182,43 @@ DROP TABLE t;

--echo # Cleanup
DROP DATABASE temp_db;
USE test;

#
# MDEV-17070 Table corruption or Assertion `table->file->stats.records > 0 || error' or Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed upon actions on temporary table
#
create temporary table t1 (f char(255), b int, index(b)) engine=MyISAM;
replace into t1 values (null,1),(null,2);
alter table t1 add fulltext key(f);
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter table t1 change if exists a b int, algorithm=inplace;
check table t1;
select * from t1;
drop table t1;

create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=1;
replace into t1 values (null,1),(null,2);
alter table t1 add fulltext key(f);
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter table t1 change if exists a b int, algorithm=inplace;
check table t1;
select * from t1;
drop table t1;

create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=0 row_format=page;
replace into t1 values (null,1),(null,2);
alter table t1 add fulltext key(f);
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter table t1 change if exists a b int, algorithm=inplace;
check table t1;
select * from t1;
drop table t1;

create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=0 row_format=dynamic;
replace into t1 values (null,1),(null,2);
alter table t1 add fulltext key(f);
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter table t1 change if exists a b int, algorithm=inplace;
check table t1;
select * from t1;
drop table t1;
2 changes: 1 addition & 1 deletion mysql-test/suite/binlog/r/binlog_base64_flag.result
Expand Up @@ -57,7 +57,7 @@ ROLLBACK/*!*/;
<#>
use `test`/*!*/;
SET TIMESTAMP=1196959712/*!*/;
<#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/;
<#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
Expand Down
13 changes: 13 additions & 0 deletions mysql-test/suite/innodb/r/foreign-keys.result
Expand Up @@ -87,6 +87,19 @@ drop table t3;
drop table t2;
drop table t1;
set debug_sync='reset';
#
# MDEV-17595 - Server crashes in copy_data_between_tables or
# Assertion `thd->transaction.stmt.is_empty() ||
# (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)'
# fails in close_tables_for_reopen upon concurrent
# ALTER TABLE and FLUSH
#
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1),(2);
CREATE TABLE t2 (b INT, KEY(b)) ENGINE=InnoDB;
INSERT INTO t2 VALUES(2);
ALTER TABLE t2 ADD FOREIGN KEY(b) REFERENCES t1(a), LOCK=EXCLUSIVE;
DROP TABLE t2, t1;
create table t1 (a int primary key, b int) engine=innodb;
create table t2 (c int primary key, d int,
foreign key (d) references t1 (a) on update cascade) engine=innodb;
Expand Down
15 changes: 15 additions & 0 deletions mysql-test/suite/innodb/t/foreign-keys.test
Expand Up @@ -112,6 +112,21 @@ drop table t2;
drop table t1;
set debug_sync='reset';


--echo #
--echo # MDEV-17595 - Server crashes in copy_data_between_tables or
--echo # Assertion `thd->transaction.stmt.is_empty() ||
--echo # (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)'
--echo # fails in close_tables_for_reopen upon concurrent
--echo # ALTER TABLE and FLUSH
--echo #
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1),(2);
CREATE TABLE t2 (b INT, KEY(b)) ENGINE=InnoDB;
INSERT INTO t2 VALUES(2);
ALTER TABLE t2 ADD FOREIGN KEY(b) REFERENCES t1(a), LOCK=EXCLUSIVE;
DROP TABLE t2, t1;

#
# FK and prelocking:
# child table accesses (reads and writes) wait for locks.
Expand Down
5 changes: 3 additions & 2 deletions sql/item_jsonfunc.cc
Expand Up @@ -1483,9 +1483,10 @@ bool Item_func_json_array::fix_length_and_dec()

if (arg_count == 0)
{
collation.set(&my_charset_utf8_general_ci,
THD* thd= current_thd;
collation.set(thd->variables.collation_connection,
DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
tmp_val.set_charset(&my_charset_utf8_general_ci);
tmp_val.set_charset(thd->variables.collation_connection);
max_length= 2;
return FALSE;
}
Expand Down
1 change: 1 addition & 0 deletions sql/item_strfunc.h
Expand Up @@ -1437,6 +1437,7 @@ class Item_func_conv_charset :public Item_str_func
(cs->state & MY_CS_UNICODE));
}
}
bool is_json_type() { return args[0]->is_json_type(); }
String *val_str(String *);
longlong val_int()
{
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_priv.h
Expand Up @@ -126,7 +126,7 @@
#define TMP_TABLE_ALL_COLUMNS (1ULL << 12) // SELECT, intern
#define OPTION_WARNINGS (1ULL << 13) // THD, user
#define OPTION_AUTO_IS_NULL (1ULL << 14) // THD, user, binlog
#define OPTION_NO_CHECK_CONSTRAINT_CHECKS (1ULL << 14)
#define OPTION_NO_CHECK_CONSTRAINT_CHECKS (1ULL << 15)
#define OPTION_SAFE_UPDATES (1ULL << 16) // THD, user
#define OPTION_BUFFER_RESULT (1ULL << 17) // SELECT, user
#define OPTION_BIN_LOG (1ULL << 18) // THD, user
Expand Down
21 changes: 9 additions & 12 deletions sql/sql_table.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2010, 2018, MariaDB
Copyright (c) 2010, 2019, MariaDB

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -10021,6 +10021,8 @@ do_continue:;
new_table->file->get_foreign_key_list(thd, &fk_list);
while ((fk= fk_list_it++))
{
MDL_request mdl_request;

if (lower_case_table_names)
{
char buf[NAME_LEN];
Expand All @@ -10032,19 +10034,14 @@ do_continue:;
len = my_casedn_str(files_charset_info, buf);
thd->make_lex_string(fk->referenced_table, buf, len);
}
if (table_already_fk_prelocked(table_list, fk->referenced_db,
fk->referenced_table, TL_READ_NO_INSERT))
continue;

TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST));
tl->init_one_table_for_prelocking(fk->referenced_db, fk->referenced_table,
NULL, TL_READ_NO_INSERT, TABLE_LIST::PRELOCK_FK,
NULL, 0, &thd->lex->query_tables_last);
mdl_request.init(MDL_key::TABLE,
fk->referenced_db->str, fk->referenced_table->str,
MDL_SHARED_NO_WRITE, MDL_TRANSACTION);
if (thd->mdl_context.acquire_lock(&mdl_request,
thd->variables.lock_wait_timeout))
goto err_new_table_cleanup;
}

if (open_tables(thd, &table_list->next_global, &tables_opened, 0,
&alter_prelocking_strategy))
goto err_new_table_cleanup;
}
}

Expand Down

0 comments on commit e450527

Please sign in to comment.