Commit 5b686af2 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.4 into 10.5

parents b40cab65 6cedb671
...@@ -3487,6 +3487,16 @@ a b c d ...@@ -3487,6 +3487,16 @@ a b c d
1 a b 1 1 a b 1
drop table t1; drop table t1;
# #
# MDEV-14667 Assertion `used_parts > 0' failed in ha_partition::init_record_priority_queue.
#
create table t1 (a int);
insert into t1 values (1),(2);
create table t2 (b int, c int, key(c,b)) partition by hash(b) partitions 2;
insert into t2 values (3,4),(5,6);
select straight_join * from t1, t2 where b != NULL;
a b c
drop table t1, t2;
#
# MDEV-17493: Partition pruning doesn't work for nested outer joins # MDEV-17493: Partition pruning doesn't work for nested outer joins
# #
create table t0(a int); create table t0(a int);
......
...@@ -1538,6 +1538,19 @@ select * from t1 where (a = 1 AND b < 'd' AND (c = 'b' OR (c = 'c' AND d = 1)) O ...@@ -1538,6 +1538,19 @@ select * from t1 where (a = 1 AND b < 'd' AND (c = 'b' OR (c = 'c' AND d = 1)) O
(a = 1 AND b >= 'a' AND (c = 'c' OR (c = 'd' AND d = 2)))); (a = 1 AND b >= 'a' AND (c = 'c' OR (c = 'd' AND d = 2))));
drop table t1; drop table t1;
--echo #
--echo # MDEV-14667 Assertion `used_parts > 0' failed in ha_partition::init_record_priority_queue.
--echo #
create table t1 (a int);
insert into t1 values (1),(2);
create table t2 (b int, c int, key(c,b)) partition by hash(b) partitions 2;
insert into t2 values (3,4),(5,6);
select straight_join * from t1, t2 where b != NULL;
drop table t1, t2;
--echo # --echo #
--echo # MDEV-17493: Partition pruning doesn't work for nested outer joins --echo # MDEV-17493: Partition pruning doesn't work for nested outer joins
--echo # --echo #
......
...@@ -318,8 +318,8 @@ ...@@ -318,8 +318,8 @@
FROM information_schema.global_status FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column'; WHERE variable_name = 'innodb_instant_alter_column';
instants instants
-184 -187
+186 +189
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency; SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
# #
# MDEV-18266: Changing an index comment unnecessarily rebuilds index # MDEV-18266: Changing an index comment unnecessarily rebuilds index
...@@ -904,6 +904,14 @@ a b c ...@@ -904,6 +904,14 @@ a b c
1 a NULL 1 a NULL
2 bah 3 2 bah 3
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1(a CHAR(5) CHARACTER SET utf8 PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
INSERT INTO t1 VALUES('barf');
ALTER TABLE t1 ADD b INT FIRST, ALGORITHM=INSTANT;
ALTER TABLE t1 ADD vb INT AS (b);
SELECT * FROM t1;
b a vb
NULL barf NULL
DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
(id INT PRIMARY KEY, c2 INT UNIQUE, (id INT PRIMARY KEY, c2 INT UNIQUE,
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'), c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
...@@ -1753,6 +1761,14 @@ a b c ...@@ -1753,6 +1761,14 @@ a b c
1 a NULL 1 a NULL
2 bah 3 2 bah 3
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1(a CHAR(5) CHARACTER SET utf8 PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPACT;
INSERT INTO t1 VALUES('barf');
ALTER TABLE t1 ADD b INT FIRST, ALGORITHM=INSTANT;
ALTER TABLE t1 ADD vb INT AS (b);
SELECT * FROM t1;
b a vb
NULL barf NULL
DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
(id INT PRIMARY KEY, c2 INT UNIQUE, (id INT PRIMARY KEY, c2 INT UNIQUE,
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'), c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
...@@ -2602,12 +2618,20 @@ a b c ...@@ -2602,12 +2618,20 @@ a b c
1 a NULL 1 a NULL
2 bah 3 2 bah 3
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1(a CHAR(5) CHARACTER SET utf8 PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
INSERT INTO t1 VALUES('barf');
ALTER TABLE t1 ADD b INT FIRST, ALGORITHM=INSTANT;
ALTER TABLE t1 ADD vb INT AS (b);
SELECT * FROM t1;
b a vb
NULL barf NULL
DROP TABLE t1;
disconnect analyze; disconnect analyze;
SELECT variable_value-@old_instant instants SELECT variable_value-@old_instant instants
FROM information_schema.global_status FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column'; WHERE variable_name = 'innodb_instant_alter_column';
instants instants
184 187
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency; SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
# #
# MDEV-18266: Changing an index comment unnecessarily rebuilds index # MDEV-18266: Changing an index comment unnecessarily rebuilds index
......
...@@ -790,6 +790,15 @@ INSERT INTO t1 VALUES(2,'bah',3); ...@@ -790,6 +790,15 @@ INSERT INTO t1 VALUES(2,'bah',3);
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
# MDEV-21088 Table cannot be loaded after instant ADD/DROP COLUMN
eval CREATE TABLE t1(a CHAR(5) CHARACTER SET utf8 PRIMARY KEY) $engine;
INSERT INTO t1 VALUES('barf');
ALTER TABLE t1 ADD b INT FIRST, ALGORITHM=INSTANT;
# this evicts and reloads the table definition until MDEV-17468 is fixed
ALTER TABLE t1 ADD vb INT AS (b);
SELECT * FROM t1;
DROP TABLE t1;
dec $format; dec $format;
let $redundant_4k= 0; let $redundant_4k= 0;
} }
......
...@@ -5266,7 +5266,10 @@ bool ha_partition::init_record_priority_queue() ...@@ -5266,7 +5266,10 @@ bool ha_partition::init_record_priority_queue()
{ {
size_t alloc_len; size_t alloc_len;
uint used_parts= bitmap_bits_set(&m_part_info->read_partitions); uint used_parts= bitmap_bits_set(&m_part_info->read_partitions);
DBUG_ASSERT(used_parts > 0);
if (used_parts == 0) /* Do nothing since no records expected. */
DBUG_RETURN(false);
/* Allocate record buffer for each used partition. */ /* Allocate record buffer for each used partition. */
m_priority_queue_rec_len= m_rec_length + PARTITION_BYTES_IN_POS; m_priority_queue_rec_len= m_rec_length + PARTITION_BYTES_IN_POS;
if (!m_using_extended_keys) if (!m_using_extended_keys)
......
...@@ -483,14 +483,55 @@ static dberr_t btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr) ...@@ -483,14 +483,55 @@ static dberr_t btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr)
/* This metadata record includes a BLOB that identifies /* This metadata record includes a BLOB that identifies
any dropped or reordered columns. */ any dropped or reordered columns. */
ulint trx_id_offset = index->trx_id_offset; ulint trx_id_offset = index->trx_id_offset;
if (!trx_id_offset) { /* If !index->trx_id_offset, the PRIMARY KEY contains
/* The PRIMARY KEY contains variable-length columns. variable-length columns. For the metadata record,
For the metadata record, variable-length columns are variable-length columns should be written with zero
always written with zero length. The DB_TRX_ID will length. However, before MDEV-21088 was fixed, for
start right after any fixed-length columns. */ variable-length encoded PRIMARY KEY column of type
CHAR, we wrote more than zero bytes. That is why we
must determine the actual length of each PRIMARY KEY
column. The DB_TRX_ID will start right after any
PRIMARY KEY columns. */
ut_ad(index->n_uniq);
/* We cannot invoke rec_get_offsets() before
index->table->deserialise_columns(). Therefore,
we must duplicate some logic here. */
if (trx_id_offset) {
} else if (index->table->not_redundant()) {
/* PRIMARY KEY columns can never be NULL.
We can skip the null flag bitmap. */
const byte* lens = rec - (REC_N_NEW_EXTRA_BYTES + 1)
- index->n_core_null_bytes;
unsigned n_add = rec_get_n_add_field(lens);
ut_ad(index->n_core_fields + n_add >= index->n_fields);
lens -= n_add;
for (uint i = index->n_uniq; i--; ) { for (uint i = index->n_uniq; i--; ) {
trx_id_offset += index->fields[i].fixed_len; const dict_field_t& f = index->fields[i];
unsigned len = f.fixed_len;
if (!len) {
len = *lens--;
if ((len & 0x80)
&& DATA_BIG_COL(f.col)) {
/* 1exxxxxxx xxxxxxxx */
len &= 0x3f;
len <<= 8;
len |= *lens--;
}
}
trx_id_offset += len;
} }
} else if (rec_get_1byte_offs_flag(rec)) {
trx_id_offset = rec_1_get_field_end_info(
rec, index->n_uniq - 1);
ut_ad(!(trx_id_offset & REC_1BYTE_SQL_NULL_MASK));
trx_id_offset &= ~REC_1BYTE_SQL_NULL_MASK;
} else {
trx_id_offset = rec_2_get_field_end_info(
rec, index->n_uniq - 1);
ut_ad(!(trx_id_offset & REC_2BYTE_SQL_NULL_MASK));
trx_id_offset &= ~REC_2BYTE_SQL_NULL_MASK;
} }
const byte* ptr = rec + trx_id_offset const byte* ptr = rec + trx_id_offset
......
...@@ -5636,10 +5636,17 @@ static bool innobase_instant_try( ...@@ -5636,10 +5636,17 @@ static bool innobase_instant_try(
case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_BLOB: case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_LONG_BLOB:
variable_length:
/* Store the empty string for 'core' /* Store the empty string for 'core'
variable-length NOT NULL columns. */ variable-length NOT NULL columns. */
dfield_set_data(d, field_ref_zero, 0); dfield_set_data(d, field_ref_zero, 0);
break; break;
case MYSQL_TYPE_STRING:
if (col->mbminlen != col->mbmaxlen
&& user_table->not_redundant()) {
goto variable_length;
}
/* fall through */
default: default:
/* For fixed-length NOT NULL 'core' columns, /* For fixed-length NOT NULL 'core' columns,
get a dummy default value from SQL. Note that get a dummy default value from SQL. Note that
...@@ -5656,7 +5663,6 @@ static bool innobase_instant_try( ...@@ -5656,7 +5663,6 @@ static bool innobase_instant_try(
: NULL, true, (*af)->ptr, len, : NULL, true, (*af)->ptr, len,
dict_table_is_comp(user_table)); dict_table_is_comp(user_table));
ut_ad(new_field->field->pack_length() == len); ut_ad(new_field->field->pack_length() == len);
} }
} }
......
...@@ -291,6 +291,24 @@ inline unsigned rec_get_n_add_field_len(ulint n_add_field) ...@@ -291,6 +291,24 @@ inline unsigned rec_get_n_add_field_len(ulint n_add_field)
return n_add_field < 0x80 ? 1 : 2; return n_add_field < 0x80 ? 1 : 2;
} }
/** Get the added field count in a REC_STATUS_INSTANT record.
@param[in,out] header variable header of a REC_STATUS_INSTANT record
@return number of added fields */
inline unsigned rec_get_n_add_field(const byte*& header)
{
unsigned n_fields_add = *--header;
if (n_fields_add < 0x80) {
ut_ad(rec_get_n_add_field_len(n_fields_add) == 1);
return n_fields_add;
}
n_fields_add &= 0x7f;
n_fields_add |= unsigned(*--header) << 7;
ut_ad(n_fields_add < REC_MAX_N_FIELDS);
ut_ad(rec_get_n_add_field_len(n_fields_add) == 2);
return n_fields_add;
}
/** Set the added field count in a REC_STATUS_INSTANT record. /** Set the added field count in a REC_STATUS_INSTANT record.
@param[in,out] header variable header of a REC_STATUS_INSTANT record @param[in,out] header variable header of a REC_STATUS_INSTANT record
@param[in] n_add number of added fields, minus 1 @param[in] n_add number of added fields, minus 1
......
...@@ -231,24 +231,6 @@ rec_get_n_extern_new( ...@@ -231,24 +231,6 @@ rec_get_n_extern_new(
return(n_extern); return(n_extern);
} }
/** Get the added field count in a REC_STATUS_INSTANT record.
@param[in,out] header variable header of a REC_STATUS_INSTANT record
@return number of added fields */
static inline unsigned rec_get_n_add_field(const byte*& header)
{
unsigned n_fields_add = *--header;
if (n_fields_add < 0x80) {
ut_ad(rec_get_n_add_field_len(n_fields_add) == 1);
return n_fields_add;
}
n_fields_add &= 0x7f;
n_fields_add |= unsigned(*--header) << 7;
ut_ad(n_fields_add < REC_MAX_N_FIELDS);
ut_ad(rec_get_n_add_field_len(n_fields_add) == 2);
return n_fields_add;
}
/** Format of a leaf-page ROW_FORMAT!=REDUNDANT record */ /** Format of a leaf-page ROW_FORMAT!=REDUNDANT record */
enum rec_leaf_format { enum rec_leaf_format {
/** Temporary file record */ /** Temporary file record */
......
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