summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/suite/maria/alter.result43
-rw-r--r--mysql-test/suite/maria/alter.test35
-rw-r--r--mysys/my_pread.c2
-rw-r--r--sql/sql_admin.cc28
-rw-r--r--sql/sql_table.cc2
-rw-r--r--storage/maria/ma_blockrec.c2
-rw-r--r--storage/maria/ma_pagecache.c3
7 files changed, 101 insertions, 14 deletions
diff --git a/mysql-test/suite/maria/alter.result b/mysql-test/suite/maria/alter.result
index c63688dddd6..ea72328a38f 100644
--- a/mysql-test/suite/maria/alter.result
+++ b/mysql-test/suite/maria/alter.result
@@ -47,3 +47,46 @@ t1 CREATE TABLE `t1` (
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
CREATE TABLE t2 SELECT * FROM t1;
DROP TABLE t1, t2;
+#
+# MDEV-19055 Assertion `(_my_thread_var())->thr_errno != 0' failed in pagecache_read
+#
+CREATE OR REPLACE TABLE t1 (x INT) ENGINE=Aria;
+CREATE TEMPORARY TABLE t2 (a TIME) ENGINE=Aria;
+ALTER TABLE t2 ADD b DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE t2 ADD CHECK (b = 4);
+INSERT IGNORE INTO t2 () VALUES (),(),(),();
+ALTER IGNORE TABLE t2 ADD c INT;
+SELECT count(a),sum(a) FROM t2;
+count(a) sum(a)
+0 NULL
+DELETE FROM t2 ORDER BY c LIMIT 1;
+INSERT IGNORE INTO t2 SELECT * FROM t2;
+OPTIMIZE TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 optimize status OK
+SELECT count(a),sum(a) FROM t2;
+count(a) sum(a)
+0 NULL
+INSERT IGNORE INTO t2 SELECT * FROM t2;
+SET SQL_MODE= 'STRICT_ALL_TABLES';
+SELECT count(a),sum(a) FROM t2;
+count(a) sum(a)
+0 NULL
+ALTER TABLE t2 CHANGE IF EXISTS d c INT;
+ERROR 22007: Incorrect datetime value: '4'
+SELECT count(a),sum(a) FROM t2;
+count(a) sum(a)
+0 NULL
+ALTER IGNORE TABLE t2 ADD IF NOT EXISTS e BIT;
+ALTER TABLE t1 MODIFY IF EXISTS xx INT;
+INSERT IGNORE INTO t2 () VALUES (),(),(),();
+SELECT count(a),sum(a) FROM t2;
+count(a) sum(a)
+0 NULL
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+check table t2;
+Table Op Msg_type Msg_text
+test.t2 check status OK
+DROP TABLE t1,t2;
diff --git a/mysql-test/suite/maria/alter.test b/mysql-test/suite/maria/alter.test
index 09672cdfa3b..ef21ab2e5d2 100644
--- a/mysql-test/suite/maria/alter.test
+++ b/mysql-test/suite/maria/alter.test
@@ -42,3 +42,38 @@ ALTER TABLE t1 ORDER BY unknown_column;
SHOW CREATE TABLE t1;
CREATE TABLE t2 SELECT * FROM t1;
DROP TABLE t1, t2;
+
+--echo #
+--echo # MDEV-19055 Assertion `(_my_thread_var())->thr_errno != 0' failed in pagecache_read
+--echo #
+
+--disable_warnings
+CREATE OR REPLACE TABLE t1 (x INT) ENGINE=Aria;
+CREATE TEMPORARY TABLE t2 (a TIME) ENGINE=Aria;
+ALTER TABLE t2 ADD b DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE t2 ADD CHECK (b = 4);
+INSERT IGNORE INTO t2 () VALUES (),(),(),();
+ALTER IGNORE TABLE t2 ADD c INT;
+SELECT count(a),sum(a) FROM t2;
+DELETE FROM t2 ORDER BY c LIMIT 1;
+INSERT IGNORE INTO t2 SELECT * FROM t2;
+OPTIMIZE TABLE t2;
+SELECT count(a),sum(a) FROM t2;
+INSERT IGNORE INTO t2 SELECT * FROM t2;
+SET SQL_MODE= 'STRICT_ALL_TABLES';
+SELECT count(a),sum(a) FROM t2;
+--error ER_TRUNCATED_WRONG_VALUE
+ALTER TABLE t2 CHANGE IF EXISTS d c INT;
+SELECT count(a),sum(a) FROM t2;
+ALTER IGNORE TABLE t2 ADD IF NOT EXISTS e BIT;
+ALTER TABLE t1 MODIFY IF EXISTS xx INT;
+INSERT IGNORE INTO t2 () VALUES (),(),(),();
+SELECT count(a),sum(a) FROM t2;
+--enable_warnings
+check table t1;
+check table t2;
+DROP TABLE t1,t2;
+
+#
+# End of 10.2 tests
+#
diff --git a/mysys/my_pread.c b/mysys/my_pread.c
index 08285738528..15586d00a6f 100644
--- a/mysys/my_pread.c
+++ b/mysys/my_pread.c
@@ -68,6 +68,8 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset,
if (readbytes != Count)
{
+ /* We should never read with wrong file descriptor! */
+ DBUG_ASSERT(my_errno != 9);
my_errno= errno;
if (errno == 0 || (readbytes != (size_t) -1 &&
(MyFlags & (MY_NABP | MY_FNABP))))
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index ed5ba93c3fe..ab95fdc340c 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -697,19 +697,23 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
MDL_SHARED_NO_READ_WRITE lock (MDL_SHARED_WRITE cannot be upgraded)
by *not* having HA_CONCURRENT_OPTIMIZE table_flag.
*/
- if (lock_type == TL_WRITE && !table->table->s->tmp_table &&
- table->mdl_request.type > MDL_SHARED_WRITE)
+ if (lock_type == TL_WRITE && table->mdl_request.type > MDL_SHARED_WRITE)
{
- if (wait_while_table_is_used(thd, table->table, HA_EXTRA_NOT_USED))
- goto err;
- DEBUG_SYNC(thd, "after_admin_flush");
- /* Flush entries in the query cache involving this table. */
- query_cache_invalidate3(thd, table->table, 0);
- /*
- XXX: hack: switch off open_for_modify to skip the
- flush that is made later in the execution flow.
- */
- open_for_modify= 0;
+ if (table->table->s->tmp_table)
+ thd->close_unused_temporary_table_instances(tables);
+ else
+ {
+ if (wait_while_table_is_used(thd, table->table, HA_EXTRA_NOT_USED))
+ goto err;
+ DEBUG_SYNC(thd, "after_admin_flush");
+ /* Flush entries in the query cache involving this table. */
+ query_cache_invalidate3(thd, table->table, 0);
+ /*
+ XXX: hack: switch off open_for_modify to skip the
+ flush that is made later in the execution flow.
+ */
+ open_for_modify= 0;
+ }
}
if (table->table->s->crashed && operator_func == &handler::ha_check)
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index a64e17e2d3b..522d18b3701 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -9536,6 +9536,8 @@ do_continue:;
DEBUG_SYNC(thd, "alter_table_copy_after_lock_upgrade");
}
+ else
+ thd->close_unused_temporary_table_instances(table_list);
// It's now safe to take the table level lock.
if (lock_tables(thd, table_list, alter_ctx.tables_opened, 0))
diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c
index c38b27d0f6c..13323dcae55 100644
--- a/storage/maria/ma_blockrec.c
+++ b/storage/maria/ma_blockrec.c
@@ -5244,6 +5244,8 @@ my_bool _ma_scan_init_block_record(MARIA_HA *info)
{
MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_scan_init_block_record");
+ DBUG_ASSERT(info->dfile.file == share->bitmap.file.file);
+
/*
bitmap_buff may already be allocated if this is the second call to
rnd_init() without a rnd_end() in between, see sql/handler.h
diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c
index 7b0f395f926..f8c83e12a18 100644
--- a/storage/maria/ma_pagecache.c
+++ b/storage/maria/ma_pagecache.c
@@ -3464,8 +3464,6 @@ restart:
pagecache_pthread_mutex_lock(&pagecache->cache_lock);
#endif
}
- if (status & PCBLOCK_ERROR)
- my_errno= block->error;
}
remove_reader(block);
@@ -3497,6 +3495,7 @@ restart:
if (status & PCBLOCK_ERROR)
{
+ my_errno= block->error;
DBUG_ASSERT(my_errno != 0);
DBUG_PRINT("error", ("Got error %d when doing page read", my_errno));
DBUG_RETURN((uchar *) 0);