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.
parent f5b60857
......@@ -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;
......
......@@ -7205,7 +7205,7 @@ ha_innobase::inplace_alter_table(
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());
......
......@@ -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));
/******************************************************//**
......
......@@ -3052,13 +3052,15 @@ row_log_table_apply_ops(
@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));
......
......@@ -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 @@ row_merge_read_clustered_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 @@ row_merge_read_clustered_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 @@ row_merge_read_clustered_index(
/* 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 @@ row_merge_read_clustered_index(
}
if (row == NULL) {
if (old_table != new_table) {
new_table->stat_n_rows = n_rows;
}
goto all_done;
}
......
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