Commit 16bc9482 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Merge branch '10.1' of https://github.com/mariadb/server into 10.1

parents 32629670 346e4608
...@@ -92,3 +92,16 @@ Warnings: ...@@ -92,3 +92,16 @@ Warnings:
Warning 1088 failed to load FOREIGN KEY constraints Warning 1088 failed to load FOREIGN KEY constraints
ALTER TABLE t1 ADD FULLTEXT INDEX ft2 (f); ALTER TABLE t1 ADD FULLTEXT INDEX ft2 (f);
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-18630 Conditional jump or move depends on uninitialised value
# in ib_push_warning / dict_create_foreign_constraints_low
#
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
ALTER IGNORE TABLE t1 ADD FOREIGN KEY (a) REFERENCES t2 (b);
ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
SHOW WARNINGS;
Level Code Message
Warning 150 Alter table test/#sql-temporary with foreign key constraint failed. Referenced table `test`.`t2` not found in the data dictionary near 'FOREIGN KEY (a) REFERENCES t2 (b)'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
Warning 1215 Cannot add foreign key constraint
DROP TABLE t1;
...@@ -113,3 +113,15 @@ SET SESSION FOREIGN_KEY_CHECKS = ON; ...@@ -113,3 +113,15 @@ SET SESSION FOREIGN_KEY_CHECKS = ON;
ALTER TABLE t1 ADD FULLTEXT INDEX ft1 (f); ALTER TABLE t1 ADD FULLTEXT INDEX ft1 (f);
ALTER TABLE t1 ADD FULLTEXT INDEX ft2 (f); ALTER TABLE t1 ADD FULLTEXT INDEX ft2 (f);
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-18630 Conditional jump or move depends on uninitialised value
--echo # in ib_push_warning / dict_create_foreign_constraints_low
--echo #
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
--replace_regex /#sql-[0-9_a-f-]*/#sql-temporary/
--error ER_CANT_CREATE_TABLE
ALTER IGNORE TABLE t1 ADD FOREIGN KEY (a) REFERENCES t2 (b);
--replace_regex /#sql-[0-9_a-f-]*/#sql-temporary/
SHOW WARNINGS;
DROP TABLE t1;
...@@ -4396,7 +4396,6 @@ dict_create_foreign_constraints_low( ...@@ -4396,7 +4396,6 @@ dict_create_foreign_constraints_low(
const char* create_table_name; const char* create_table_name;
const char* orig; const char* orig;
char create_name[MAX_TABLE_NAME_LEN + 1]; char create_name[MAX_TABLE_NAME_LEN + 1];
char operation[8];
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
...@@ -4407,41 +4406,33 @@ dict_create_foreign_constraints_low( ...@@ -4407,41 +4406,33 @@ dict_create_foreign_constraints_low(
orig = ptr; orig = ptr;
ptr = dict_accept(cs, ptr, "ALTER", &success); ptr = dict_accept(cs, ptr, "ALTER", &success);
strcpy((char *)operation, success ? "Alter " : "Create "); const char* const operation = success ? "Alter " : "Create ";
if (!success) { if (!success) {
orig = ptr; orig = ptr;
ptr = dict_scan_to(ptr, "CREATE"); ptr = dict_scan_to(ptr, "CREATE");
ptr = dict_scan_to(ptr, "TABLE"); ptr = dict_scan_to(ptr, "TABLE");
ptr = dict_accept(cs, ptr, "TABLE", &success); ptr = dict_accept(cs, ptr, "TABLE", &success);
create_table_name = NULL;
if (success) { if (success) {
ptr = dict_scan_table_name(cs, ptr, &table_to_create, name, ptr = dict_scan_table_name(cs, ptr, &table_to_create, name,
&success, heap, &create_table_name); &success, heap, &create_table_name);
} }
if (success) { ptr = orig;
char *bufend; const char* n = create_table_name ? create_table_name : name;
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN, char *bufend = innobase_convert_name(create_name, MAX_TABLE_NAME_LEN,
create_table_name, strlen(create_table_name), n, strlen(n), trx->mysql_thd, TRUE);
trx->mysql_thd, TRUE); create_name[bufend-create_name] = '\0';
create_name[bufend-create_name]='\0'; } else {
ptr = orig; strncpy(create_name, name, sizeof create_name);
} else { create_name[(sizeof create_name) - 1] = '\0';
char *bufend;
ptr = orig;
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
name, strlen(name), trx->mysql_thd, TRUE);
create_name[bufend-create_name]='\0';
}
goto loop;
} }
if (table == NULL) { if (table == NULL) {
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
dict_foreign_error_report_low(ef, create_name); dict_foreign_error_report_low(ef, create_name);
dict_foreign_error_report_low(ef, create_name);
fprintf(ef, "%s table %s with foreign key constraint" fprintf(ef, "%s table %s with foreign key constraint"
" failed. Table %s not found from data dictionary." " failed. Table %s not found from data dictionary."
" Error close to %s.\n", " Error close to %s.\n",
...@@ -4476,19 +4467,13 @@ dict_create_foreign_constraints_low( ...@@ -4476,19 +4467,13 @@ dict_create_foreign_constraints_low(
ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name, ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name,
&success, heap, &referenced_table_name); &success, heap, &referenced_table_name);
if (table_to_alter) { {
char *bufend; const char* n = table_to_alter
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN, ? table_to_alter->name : referenced_table_name;
table_to_alter->name, strlen(table_to_alter->name), char* bufend = innobase_convert_name(
trx->mysql_thd, TRUE); create_name, MAX_TABLE_NAME_LEN, n, strlen(n),
create_name[bufend-create_name]='\0'; trx->mysql_thd, TRUE);
} else {
char *bufend;
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
referenced_table_name, strlen(referenced_table_name),
trx->mysql_thd, TRUE);
create_name[bufend-create_name]='\0'; create_name[bufend-create_name]='\0';
} }
if (!success) { if (!success) {
......
...@@ -695,9 +695,7 @@ static int del(MARIA_HA *info, MARIA_KEY *key, ...@@ -695,9 +695,7 @@ static int del(MARIA_HA *info, MARIA_KEY *key,
key_start= keypos; key_start= keypos;
if (tmp_key.flag & (SEARCH_USER_KEY_HAS_TRANSID | if (tmp_key.flag & (SEARCH_USER_KEY_HAS_TRANSID |
SEARCH_PAGE_KEY_HAS_TRANSID)) SEARCH_PAGE_KEY_HAS_TRANSID))
{
_ma_mark_page_with_transid(share, anc_page); _ma_mark_page_with_transid(share, anc_page);
}
/* Save pointer to next leaf on parent page */ /* Save pointer to next leaf on parent page */
if (!(*keyinfo->get_key)(&ret_key, page_flag, share->base.key_reflength, if (!(*keyinfo->get_key)(&ret_key, page_flag, share->base.key_reflength,
......
...@@ -843,9 +843,8 @@ int _ma_insert(register MARIA_HA *info, MARIA_KEY *key, ...@@ -843,9 +843,8 @@ int _ma_insert(register MARIA_HA *info, MARIA_KEY *key,
a_length+=t_length; a_length+=t_length;
if (key->flag & (SEARCH_USER_KEY_HAS_TRANSID | SEARCH_PAGE_KEY_HAS_TRANSID)) if (key->flag & (SEARCH_USER_KEY_HAS_TRANSID | SEARCH_PAGE_KEY_HAS_TRANSID))
{
_ma_mark_page_with_transid(share, anc_page); _ma_mark_page_with_transid(share, anc_page);
}
anc_page->size= a_length; anc_page->size= a_length;
page_store_size(share, anc_page); page_store_size(share, anc_page);
......
...@@ -777,8 +777,8 @@ struct st_maria_handler ...@@ -777,8 +777,8 @@ struct st_maria_handler
transid_korr((buff) + LSN_STORE_SIZE) transid_korr((buff) + LSN_STORE_SIZE)
#define _ma_store_keypage_flag(share,x,flag) x[(share)->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]= (flag) #define _ma_store_keypage_flag(share,x,flag) x[(share)->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]= (flag)
#define _ma_mark_page_with_transid(share, page) \ #define _ma_mark_page_with_transid(share, page) \
(page)->flag|= KEYPAGE_FLAG_HAS_TRANSID; \ do { (page)->flag|= KEYPAGE_FLAG_HAS_TRANSID; \
(page)->buff[(share)->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]= (page)->flag; (page)->buff[(share)->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]= (page)->flag; } while (0)
#define KEYPAGE_KEY_VERSION(share, x) ((x) + \ #define KEYPAGE_KEY_VERSION(share, x) ((x) + \
(share)->keypage_header - \ (share)->keypage_header - \
......
...@@ -4405,7 +4405,6 @@ dict_create_foreign_constraints_low( ...@@ -4405,7 +4405,6 @@ dict_create_foreign_constraints_low(
const char* create_table_name; const char* create_table_name;
const char* orig; const char* orig;
char create_name[MAX_TABLE_NAME_LEN + 1]; char create_name[MAX_TABLE_NAME_LEN + 1];
char operation[8];
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
...@@ -4416,41 +4415,33 @@ dict_create_foreign_constraints_low( ...@@ -4416,41 +4415,33 @@ dict_create_foreign_constraints_low(
orig = ptr; orig = ptr;
ptr = dict_accept(cs, ptr, "ALTER", &success); ptr = dict_accept(cs, ptr, "ALTER", &success);
strcpy((char *)operation, success ? "Alter " : "Create "); const char* const operation = success ? "Alter " : "Create ";
if (!success) { if (!success) {
orig = ptr; orig = ptr;
ptr = dict_scan_to(ptr, "CREATE"); ptr = dict_scan_to(ptr, "CREATE");
ptr = dict_scan_to(ptr, "TABLE"); ptr = dict_scan_to(ptr, "TABLE");
ptr = dict_accept(cs, ptr, "TABLE", &success); ptr = dict_accept(cs, ptr, "TABLE", &success);
create_table_name = NULL;
if (success) { if (success) {
ptr = dict_scan_table_name(cs, ptr, &table_to_create, name, ptr = dict_scan_table_name(cs, ptr, &table_to_create, name,
&success, heap, &create_table_name); &success, heap, &create_table_name);
} }
if (success) { ptr = orig;
char *bufend; const char* n = create_table_name ? create_table_name : name;
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN, char *bufend = innobase_convert_name(create_name, MAX_TABLE_NAME_LEN,
create_table_name, strlen(create_table_name), n, strlen(n), trx->mysql_thd, TRUE);
trx->mysql_thd, TRUE); create_name[bufend-create_name] = '\0';
create_name[bufend-create_name]='\0'; } else {
ptr = orig; strncpy(create_name, name, sizeof create_name);
} else { create_name[(sizeof create_name) - 1] = '\0';
char *bufend;
ptr = orig;
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
name, strlen(name), trx->mysql_thd, TRUE);
create_name[bufend-create_name]='\0';
}
goto loop;
} }
if (table == NULL) { if (table == NULL) {
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
dict_foreign_error_report_low(ef, create_name); dict_foreign_error_report_low(ef, create_name);
dict_foreign_error_report_low(ef, create_name);
fprintf(ef, "%s table %s with foreign key constraint" fprintf(ef, "%s table %s with foreign key constraint"
" failed. Table %s not found from data dictionary." " failed. Table %s not found from data dictionary."
" Error close to %s.\n", " Error close to %s.\n",
...@@ -4485,19 +4476,13 @@ dict_create_foreign_constraints_low( ...@@ -4485,19 +4476,13 @@ dict_create_foreign_constraints_low(
ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name, ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name,
&success, heap, &referenced_table_name); &success, heap, &referenced_table_name);
if (table_to_alter) { {
char *bufend; const char* n = table_to_alter
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN, ? table_to_alter->name : referenced_table_name;
table_to_alter->name, strlen(table_to_alter->name), char* bufend = innobase_convert_name(
trx->mysql_thd, TRUE); create_name, MAX_TABLE_NAME_LEN, n, strlen(n),
create_name[bufend-create_name]='\0'; trx->mysql_thd, TRUE);
} else {
char *bufend;
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
referenced_table_name, strlen(referenced_table_name),
trx->mysql_thd, TRUE);
create_name[bufend-create_name]='\0'; create_name[bufend-create_name]='\0';
} }
if (!success) { if (!success) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment