MDEV-16365 Setting a column NOT NULL fails to return error for

	NULL values when there is no DEFAULT

- Post push fix for adding n_rows in row_log_t.
parent 46fc864b
...@@ -9,7 +9,3 @@ ...@@ -9,7 +9,3 @@
< 2 0 < 2 0
--- ---
> 2 NULL > 2 NULL
71c68
< Warning 1265 Data truncated for column 'c2' at row 7
---
> Warning 1265 Data truncated for column 'c2' at row 6
...@@ -68,7 +68,7 @@ connection default; ...@@ -68,7 +68,7 @@ connection default;
affected rows: 0 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 1 info: Records: 0 Duplicates: 0 Warnings: 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c2' at row 7 Warning 1265 Data truncated for column 'c2' at row 3
SELECT * FROM t1; SELECT * FROM t1;
c1 c2 c3 c1 c2 c3
1 2 3 1 2 3
......
...@@ -233,6 +233,7 @@ struct row_log_t { ...@@ -233,6 +233,7 @@ struct row_log_t {
defaults */ defaults */
const TABLE* old_table; /*< Use old table in case of error. */ const TABLE* old_table; /*< Use old table in case of error. */
uint64_t n_rows; /*< Number of rows read from the table */
/** Determine whether the log should be in the 'instant ADD' format /** Determine whether the log should be in the 'instant ADD' format
@param[in] index the clustered index of the source table @param[in] index the clustered index of the source table
@return whether to use the 'instant ADD COLUMN' format */ @return whether to use the 'instant ADD COLUMN' format */
...@@ -1483,16 +1484,15 @@ row_log_table_apply_convert_mrec( ...@@ -1483,16 +1484,15 @@ row_log_table_apply_convert_mrec(
const mrec_t* mrec, /*!< in: merge record */ const mrec_t* mrec, /*!< in: merge record */
dict_index_t* index, /*!< in: index of mrec */ dict_index_t* index, /*!< in: index of mrec */
const ulint* offsets, /*!< in: offsets of mrec */ const ulint* offsets, /*!< in: offsets of mrec */
const row_log_t* log, /*!< in: rebuild context */ row_log_t* log, /*!< in: rebuild context */
mem_heap_t* heap, /*!< in/out: memory heap */ mem_heap_t* heap, /*!< in/out: memory heap */
dberr_t* error) /*!< out: DB_SUCCESS or dberr_t* error) /*!< out: DB_SUCCESS or
DB_MISSING_HISTORY or DB_MISSING_HISTORY or
reason of failure */ reason of failure */
{ {
dtuple_t* row; dtuple_t* row;
static ulong n_rows = index->table->stat_n_rows;
n_rows++; log->n_rows++;
*error = DB_SUCCESS; *error = DB_SUCCESS;
/* This is based on row_build(). */ /* This is based on row_build(). */
...@@ -1624,7 +1624,7 @@ row_log_table_apply_convert_mrec( ...@@ -1624,7 +1624,7 @@ row_log_table_apply_convert_mrec(
Field* field = log->old_table->field[col_no]; Field* field = log->old_table->field[col_no];
field->set_warning(Sql_condition::WARN_LEVEL_WARN, field->set_warning(Sql_condition::WARN_LEVEL_WARN,
WARN_DATA_TRUNCATED, 1, n_rows); WARN_DATA_TRUNCATED, 1, log->n_rows);
if (!log->allow_not_null) { if (!log->allow_not_null) {
/* We got a NULL value for a NOT NULL column. */ /* We got a NULL value for a NOT NULL column. */
...@@ -1736,7 +1736,7 @@ row_log_table_apply_insert( ...@@ -1736,7 +1736,7 @@ row_log_table_apply_insert(
row_merge_dup_t* dup) /*!< in/out: for reporting row_merge_dup_t* dup) /*!< in/out: for reporting
duplicate key errors */ duplicate key errors */
{ {
const row_log_t*log = dup->index->online_log; row_log_t*log = dup->index->online_log;
dberr_t error; dberr_t error;
const dtuple_t* row = row_log_table_apply_convert_mrec( const dtuple_t* row = row_log_table_apply_convert_mrec(
mrec, dup->index, offsets, log, heap, &error); mrec, dup->index, offsets, log, heap, &error);
...@@ -2007,7 +2007,7 @@ row_log_table_apply_update( ...@@ -2007,7 +2007,7 @@ row_log_table_apply_update(
of the old value, of the old value,
or PRIMARY KEY if same_pk */ or PRIMARY KEY if same_pk */
{ {
const row_log_t*log = dup->index->online_log; row_log_t* log = dup->index->online_log;
const dtuple_t* row; const dtuple_t* row;
dict_index_t* index = dict_table_get_first_index(log->table); dict_index_t* index = dict_table_get_first_index(log->table);
mtr_t mtr; mtr_t mtr;
...@@ -3072,6 +3072,10 @@ row_log_table_apply( ...@@ -3072,6 +3072,10 @@ row_log_table_apply(
ut_ad(!rw_lock_own(dict_operation_lock, RW_LOCK_S)); ut_ad(!rw_lock_own(dict_operation_lock, RW_LOCK_S));
clust_index = dict_table_get_first_index(old_table); 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;
}
rw_lock_x_lock(dict_index_get_lock(clust_index)); rw_lock_x_lock(dict_index_get_lock(clust_index));
if (!clust_index->online_log) { if (!clust_index->online_log) {
...@@ -3166,6 +3170,7 @@ row_log_allocate( ...@@ -3166,6 +3170,7 @@ row_log_allocate(
ut_ad(!table || log->is_instant(index) == index->is_instant()); ut_ad(!table || log->is_instant(index) == index->is_instant());
log->allow_not_null = allow_not_null; log->allow_not_null = allow_not_null;
log->old_table = old_table; log->old_table = old_table;
log->n_rows = 0;
dict_index_set_online_status(index, ONLINE_INDEX_CREATION); dict_index_set_online_status(index, ONLINE_INDEX_CREATION);
index->online_log = log; index->online_log = log;
......
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