summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2020-04-27 21:40:14 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2020-04-27 21:40:14 +0530
commit6a11300eb6ea1cbbc8ede17d93f2469f795fe0fb (patch)
tree4b5feeffb9cb18eb6817b62881d445bda5b358a1
parent8bb9654253ca354942631d4ef4b696983a1a06c9 (diff)
downloadmariadb-git-bb-10.3-MDEV-19611.tar.gz
MDEV-16288 ALTER TABLE…ALGORITHM=DEFAULT does not override alter_algorithmbb-10.3-MDEV-19611
- ALTER_ALGORITHM variable should be substituted when there is no mention of algorithm in alter statement.
-rw-r--r--mysql-test/suite/innodb/r/innodb-alter-timestamp.result17
-rw-r--r--mysql-test/suite/innodb/t/innodb-alter-timestamp.test22
-rw-r--r--storage/innobase/handler/handler0alter.cc41
3 files changed, 41 insertions, 39 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-alter-timestamp.result b/mysql-test/suite/innodb/r/innodb-alter-timestamp.result
index 355872dc78f..6934484a488 100644
--- a/mysql-test/suite/innodb/r/innodb-alter-timestamp.result
+++ b/mysql-test/suite/innodb/r/innodb-alter-timestamp.result
@@ -125,14 +125,17 @@ SELECT DISTINCT (CURRENT_TIMESTAMP()-d4) <= 60 FROM t1;
1
DROP TABLE t1;
CREATE TABLE t1(f1 int) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1);
+INSERT INTO t1 SELECT * FROM seq_1_to_4096;
+connect purge_control,localhost,root,,;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connection default;
+DELETE FROM t1;
SET sql_mode='STRICT_ALL_TABLES,STRICT_TRANS_TABLES,NO_ZERO_DATE';
ALTER TABLE t1 ADD f2 DATE NOT NULL, ALGORITHM=INPLACE;
+INSERT INTO t1 VALUES (1, now());
+Warnings:
+Note 1265 Data truncated for column 'f2' at row 1
+ALTER TABLE t1 ADD f3 DATE NOT NULL, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
DROP TABLE t1;
-CREATE TABLE t1(f1 int) ENGINE=InnoDB;
-INSERT INTO t1 SELECT * FROM seq_1_to_16000;
-DELETE FROM t1;
-SET sql_mode='STRICT_ALL_TABLES,STRICT_TRANS_TABLES,NO_ZERO_DATE';
-ALTER TABLE t1 ADD b DATE NOT NULL, ALGORITHM=INPLACE;
-DROP TABLE t1;
+disconnect purge_control;
diff --git a/mysql-test/suite/innodb/t/innodb-alter-timestamp.test b/mysql-test/suite/innodb/t/innodb-alter-timestamp.test
index 60b54cd7497..28b09b18e10 100644
--- a/mysql-test/suite/innodb/t/innodb-alter-timestamp.test
+++ b/mysql-test/suite/innodb/t/innodb-alter-timestamp.test
@@ -86,18 +86,20 @@ DROP TABLE t1;
# MDEV-19611 INPLACE ALTER does not fail on bad implicit default value
-# Non-empty Table
-CREATE TABLE t1(f1 int) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1);
-SET sql_mode='STRICT_ALL_TABLES,STRICT_TRANS_TABLES,NO_ZERO_DATE';
---error ER_ALTER_OPERATION_NOT_SUPPORTED
-ALTER TABLE t1 ADD f2 DATE NOT NULL, ALGORITHM=INPLACE;
-DROP TABLE t1;
-
# Empty-table
CREATE TABLE t1(f1 int) ENGINE=InnoDB;
-INSERT INTO t1 SELECT * FROM seq_1_to_16000;
+INSERT INTO t1 SELECT * FROM seq_1_to_4096;
+connect(purge_control,localhost,root,,);
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+
+connection default;
DELETE FROM t1;
SET sql_mode='STRICT_ALL_TABLES,STRICT_TRANS_TABLES,NO_ZERO_DATE';
-ALTER TABLE t1 ADD b DATE NOT NULL, ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD f2 DATE NOT NULL, ALGORITHM=INPLACE;
+
+# Non-empty table
+INSERT INTO t1 VALUES (1, now());
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+ALTER TABLE t1 ADD f3 DATE NOT NULL, ALGORITHM=INPLACE;
DROP TABLE t1;
+disconnect purge_control;
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index ddb9fd15c6e..1aa30d449e9 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -871,32 +871,25 @@ innobase_fts_check_doc_id_col(
@return true if table is empty */
static bool innobase_table_is_empty(const dict_table_t* table)
{
- dict_index_t* clust_index= dict_table_get_first_index(table);
+ dict_index_t *clust_index= dict_table_get_first_index(table);
mtr_t mtr;
btr_pcur_t pcur;
- buf_block_t* block;
- page_cur_t* cur;
- const rec_t* rec;
+ buf_block_t *block;
+ page_cur_t *cur;
+ const rec_t *rec;
bool next_page= false;
mtr.start();
btr_pcur_open_at_index_side(true, clust_index, BTR_SEARCH_LEAF,
&pcur, true, 0, &mtr);
btr_pcur_move_to_next_user_rec(&pcur, &mtr);
- if (rec_is_metadata(btr_pcur_get_rec(&pcur), clust_index))
- {
- mtr.commit();
- return false;
- }
- btr_pcur_move_to_prev_on_page(&pcur);
-
+ if (!rec_is_metadata(btr_pcur_get_rec(&pcur), clust_index))
+ btr_pcur_move_to_prev_on_page(&pcur);
scan_leaf:
- if (!next_page)
- {
- cur= btr_pcur_get_page_cur(&pcur);
- page_cur_move_to_next(cur);
- }
- else
+ cur= btr_pcur_get_page_cur(&pcur);
+ page_cur_move_to_next(cur);
+next_page:
+ if (next_page)
{
ulint next_page_no= btr_page_get_next(page_cur_get_page(cur));
if (next_page_no == FIL_NULL)
@@ -905,10 +898,11 @@ scan_leaf:
return true;
}
+ next_page= false;
block= page_cur_get_block(cur);
block= btr_block_get(page_id_t(block->page.id.space(), next_page_no),
- block->page.size, BTR_SEARCH_LEAF,
- clust_index, &mtr);
+ block->page.size, BTR_SEARCH_LEAF, clust_index,
+ &mtr);
btr_leaf_page_release(page_cur_get_block(cur), BTR_SEARCH_LEAF, &mtr);
page_cur_set_before_first(block, cur);
page_cur_move_to_next(cur);
@@ -916,13 +910,16 @@ scan_leaf:
rec= page_cur_get_rec(cur);
if (rec_get_deleted_flag(rec, dict_table_is_comp(table)));
- else if (page_rec_is_supremum(rec))
- next_page= true;
- else
+ else if (!page_rec_is_supremum(rec))
{
mtr.commit();
return false;
}
+ else
+ {
+ next_page= true;
+ goto next_page;
+ }
goto scan_leaf;
}