summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2018-06-26 14:10:58 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2018-06-26 14:10:58 +0530
commitfe76e68e0e858c6012ddd0bef6b24a4fbae828d2 (patch)
treea992668c2b6ef544918a71ef93977b501e9fa2ee
parentf5b60857f49f886926530b2e28cbf9e179658014 (diff)
downloadmariadb-git-fe76e68e0e858c6012ddd0bef6b24a4fbae828d2.tar.gz
MDEV-16365 Setting a column NOT NULL fails to return error for
NULL values when there is no DEFAULT - Fixed the test failure, assigned number of rows read to new table.
-rw-r--r--mysql-test/suite/innodb/r/innodb-table-online.result2
-rw-r--r--storage/innobase/handler/handler0alter.cc5
-rw-r--r--storage/innobase/include/row0log.h4
-rw-r--r--storage/innobase/row/row0log.cc6
-rw-r--r--storage/innobase/row/row0merge.cc14
5 files changed, 20 insertions, 11 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-table-online.result b/mysql-test/suite/innodb/r/innodb-table-online.result
index dc7e7e4538f..5b5c4d6b9e1 100644
--- a/mysql-test/suite/innodb/r/innodb-table-online.result
+++ b/mysql-test/suite/innodb/r/innodb-table-online.result
@@ -428,7 +428,7 @@ INSERT INTO t1 VALUES(33101,347,NULL,'');
SET DEBUG_SYNC = 'now SIGNAL ins_done0';
# session con1
connection con1;
-ERROR 01000: Data truncated for column 'c3' at row 1
+ERROR 01000: Data truncated for column 'c3' at row 323
SET @@sql_mode = @old_sql_mode;
# session default
connection default;
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 665dd40250e..fbec55f97f4 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -7205,7 +7205,7 @@ oom:
DEBUG_SYNC_C("row_log_table_apply1_before");
error = row_log_table_apply(
ctx->thr, m_prebuilt->table, altered_table,
- ctx->m_stage);
+ ctx->m_stage, ctx->new_table);
}
/* Init online ddl status variables */
@@ -8685,7 +8685,8 @@ commit_try_rebuild(
error = row_log_table_apply(
ctx->thr, user_table, altered_table,
static_cast<ha_innobase_inplace_ctx*>(
- ha_alter_info->handler_ctx)->m_stage);
+ ha_alter_info->handler_ctx)->m_stage,
+ ctx->new_table);
if (s_templ) {
ut_ad(ctx->need_rebuild());
diff --git a/storage/innobase/include/row0log.h b/storage/innobase/include/row0log.h
index 544de02db70..723cf310f95 100644
--- a/storage/innobase/include/row0log.h
+++ b/storage/innobase/include/row0log.h
@@ -211,13 +211,15 @@ row_log_table_blob_alloc(
@param[in,out] stage performance schema accounting object, used by
ALTER TABLE. stage->begin_phase_log_table() will be called initially and then
stage->inc() will be called for each block of log that is applied.
+@param[in] new_table Altered table
@return DB_SUCCESS, or error code on failure */
dberr_t
row_log_table_apply(
que_thr_t* thr,
dict_table_t* old_table,
struct TABLE* table,
- ut_stage_alter_t* stage)
+ ut_stage_alter_t* stage,
+ dict_table_t* new_table)
MY_ATTRIBUTE((warn_unused_result));
/******************************************************//**
diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc
index 9a4ee17d663..7347f4f04c6 100644
--- a/storage/innobase/row/row0log.cc
+++ b/storage/innobase/row/row0log.cc
@@ -3052,13 +3052,15 @@ func_exit:
@param[in,out] stage performance schema accounting object, used by
ALTER TABLE. stage->begin_phase_log_table() will be called initially and then
stage->inc() will be called for each block of log that is applied.
+@param[in] new_table Altered table
@return DB_SUCCESS, or error code on failure */
dberr_t
row_log_table_apply(
que_thr_t* thr,
dict_table_t* old_table,
struct TABLE* table,
- ut_stage_alter_t* stage)
+ ut_stage_alter_t* stage,
+ dict_table_t* new_table)
{
dberr_t error;
dict_index_t* clust_index;
@@ -3073,7 +3075,7 @@ row_log_table_apply(
clust_index = dict_table_get_first_index(old_table);
if (clust_index->online_log->n_rows == 0) {
- clust_index->online_log->n_rows = old_table->stat_n_rows;
+ clust_index->online_log->n_rows = new_table->stat_n_rows;
}
rw_lock_x_lock(dict_index_get_lock(clust_index));
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index 8f1bb43041f..abf6a0850ab 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -1682,7 +1682,7 @@ row_merge_read_clustered_index(
trx_t* trx,
struct TABLE* table,
const dict_table_t* old_table,
- const dict_table_t* new_table,
+ dict_table_t* new_table,
bool online,
dict_index_t** index,
dict_index_t* fts_sort_idx,
@@ -1916,7 +1916,7 @@ row_merge_read_clustered_index(
mach_write_to_8(new_sys_trx_start, trx->id);
mach_write_to_8(new_sys_trx_end, TRX_ID_MAX);
- ulong n_rows = 0;
+ uint64_t n_rows = 0;
/* Scan the clustered index. */
for (;;) {
@@ -2049,8 +2049,6 @@ end_of_index:
rec = page_cur_get_rec(cur);
- n_rows++;
-
if (online) {
offsets = rec_get_offsets(rec, clust_index, NULL, true,
ULINT_UNDEFINED, &row_heap);
@@ -2185,7 +2183,8 @@ end_of_index:
null_field->set_warning(
Sql_condition::WARN_LEVEL_WARN,
- WARN_DATA_TRUNCATED, 1, n_rows);
+ WARN_DATA_TRUNCATED, 1,
+ ulong(n_rows + 1));
if (!allow_not_null) {
err = DB_INVALID_NULL;
@@ -2328,6 +2327,7 @@ write_buffers:
/* Build all entries for all the indexes to be created
in a single scan of the clustered index. */
+ n_rows++;
ulint s_idx_cnt = 0;
bool skip_sort = skip_pk_sort
&& dict_index_is_clust(merge_buf[0]->index);
@@ -2708,6 +2708,10 @@ write_buffers:
}
if (row == NULL) {
+ if (old_table != new_table) {
+ new_table->stat_n_rows = n_rows;
+ }
+
goto all_done;
}