Commit a44f2c3e authored by Igor Babaev's avatar Igor Babaev

Merge branch '10.4' into bb-10.4-mdev16188

parents 294b8c42 568dd529
......@@ -111,3 +111,20 @@ long_enough_name CREATE TABLE `long_enough_name` (
CONSTRAINT `constr` CHECK (`f6` >= 0)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE long_enough_name;
create table t1 (a int check (a>10)) select 100 as 'a';
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL CHECK (`a` > 10)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a text default(length(now())) check (length(a) > 1));
insert into t1 values ();
insert into t1 values ("ccc");
insert into t1 values ("");
ERROR 23000: CONSTRAINT `t1.a` failed for `test`.`t1`
select * from t1;
a
19
ccc
drop table t1;
......@@ -102,3 +102,23 @@ SELECT * FROM long_enough_name AS tbl;
SHOW CREATE TABLE long_enough_name;
DROP TABLE long_enough_name;
#
# Check that we don't loose constraints as part of CREATE ... SELECT
#
create table t1 (a int check (a>10)) select 100 as 'a';
show create table t1;
drop table t1;
#
# Check that we constraints on field with default expressions work
#
create table t1 (a text default(length(now())) check (length(a) > 1));
insert into t1 values ();
insert into t1 values ("ccc");
--error ER_CONSTRAINT_FAILED
insert into t1 values ("");
select * from t1;
drop table t1;
mysql-wsrep-features#29 : binlog_format=STATEMENT not supported with SR
GCF-574 : CTAS is not supported together with SR
galera_sr_sbr : binlog_format=STATEMENT not supported with SR
galera_sr_table_contents : missing file
CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO ten VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
SET SESSION wsrep_trx_fragment_size = 1;
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4;
wsrep_last_committed_delta
1
SELECT COUNT(*) = 10000 FROM t1;
COUNT(*) = 10000
1
DROP TABLE t1;
DROP TABLE ten;
connection node_2;
connection node_1;
connection node_1;
connection node_2;
connection node_2;
SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log;
COUNT(*) = 0
......
connection node_2;
connection node_1;
connection node_1;
connection node_2;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
SET SESSION wsrep_trx_fragment_size = 1;
SET AUTOCOMMIT=OFF;
......
......@@ -10,4 +10,5 @@ COUNT(*) = 20000
1
wsrep_last_committed_diff
1
connection node_1;
DROP TABLE t1;
CREATE TABLE t1 (id INT) ENGINE=InnoDB;
SET SESSION wsrep_trx_fragment_size = 1;
SET SESSION BINLOG_FORMAT='STATEMENT';
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
INSERT INTO t1 VALUES (4);
INSERT INTO t1 VALUES (5);
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
COMMIT;
SELECT COUNT(*) = 5 FROM t1;
COUNT(*) = 5
1
DROP TABLE t1;
......@@ -6,9 +6,7 @@ CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t2 VALUES (6),(7),(8),(9),(10),(1);
connection node_2;
SET GLOBAL wsrep_slave_threads = 2;
SET GLOBAL DEBUG = 'd,sync.wsrep_apply_cb';
Warnings:
Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
SET GLOBAL debug_dbug = 'd,sync.wsrep_apply_cb';
connection node_1;
SET SESSION wsrep_trx_fragment_size = 1;
SET AUTOCOMMIT=OFF;
......@@ -28,9 +26,7 @@ connection node_1;
Got one of the listed errors
connection node_2;
SET GLOBAL wsrep_slave_threads = 1;
SET GLOBAL DEBUG = '';
Warnings:
Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
SET GLOBAL debug_dbug = '';
SET DEBUG_SYNC='now SIGNAL signal.wsrep_apply_cb';
SET DEBUG_SYNC='now SIGNAL signal.wsrep_apply_cb';
SET DEBUG_SYNC='now SIGNAL signal.wsrep_apply_cb';
......@@ -40,3 +36,4 @@ COUNT(*) = 10
1
DROP TABLE t1;
DROP TABLE t2;
SET DEBUG_SYNC = RESET;
SET SESSION wsrep_trx_fragment_size = 1;
SET SESSION binlog_format = STATEMENT;
create table t1 (id int not null, f_id int not null, f int not null,
primary key(f_id, id)) engine=innodb;
create table t2 (id int not null,s_id int not null,s varchar(200),
primary key(id)) engine=innodb;
INSERT INTO t1 VALUES (8, 1, 3);
INSERT INTO t1 VALUES (1, 2, 1);
INSERT INTO t2 VALUES (1, 0, '');
INSERT INTO t2 VALUES (8, 1, '');
DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
WHERE mm.id IS NULL;
DROP TABLE t1;
DROP TABLE t2;
--source include/galera_cluster.inc
--source include/have_innodb.inc
#
# Test CREATE TABLE ... SELECT with Streaming Replication
#
--connection node_1
CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO ten VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
SET SESSION wsrep_trx_fragment_size = 1;
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4;
--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--disable_query_log
--eval SELECT ($wsrep_last_committed_after - $wsrep_last_committed_before) > 1 AS wsrep_last_committed_delta;
--enable_query_log
--connection node_2
SELECT COUNT(*) = 10000 FROM t1;
--connection node_1
DROP TABLE t1;
DROP TABLE ten;
......@@ -7,6 +7,11 @@
# leave the cluster.
#
# Save original auto_increment_offset values.
--let $node_1=node_1
--let $node_2=node_2
--source ../../galera/include/auto_increment_offset_save.inc
# Start with a clean slate
--connection node_2
SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log;
......@@ -95,3 +100,6 @@ SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log;
DROP TABLE t1;
CALL mtr.add_suppression("points to own listening address, blacklisting");
# Restore original auto_increment_offset values.
--source ../../galera/include/auto_increment_offset_restore.inc
......@@ -2,3 +2,7 @@
[mysqld.1]
wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.recovery=false'
auto_increment_offset=1
[mysqld.2]
auto_increment_offset=2
......@@ -6,6 +6,11 @@
--source include/galera_cluster.inc
--source include/big_test.inc
# Save original auto_increment_offset values.
--let $node_1=node_1
--let $node_2=node_2
--source ../../galera/include/auto_increment_offset_save.inc
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
SET SESSION wsrep_trx_fragment_size = 1;
SET AUTOCOMMIT=OFF;
......@@ -50,4 +55,6 @@ SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT COUNT(*) = 0 FROM t1;
SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log;
--source ../../galera/include/auto_increment_offset_restore.inc
DROP TABLE t1;
......@@ -24,6 +24,9 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
--connection node_1
--disable_query_log
--disable_warnings
set global wsrep_load_data_splitting=ON;
--enable_warnings
--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/galera_sr_load_data.csv' INTO TABLE t1;
--enable_query_log
......@@ -36,4 +39,11 @@ SELECT COUNT(*) = 20000 FROM t1;
--eval SELECT $wsrep_last_committed_after - $wsrep_last_committed_before = 3 AS wsrep_last_committed_diff
--enable_query_log
--connection node_1
--disable_query_log
--disable_warnings
set global wsrep_load_data_splitting=OFF;
--enable_warnings
--enable_query_log
DROP TABLE t1;
--source include/galera_cluster.inc
--source include/have_innodb.inc
#
# Test that SR does not assert in the presence of statement-based replication events
#
--connection node_1
CREATE TABLE t1 (id INT) ENGINE=InnoDB;
SET SESSION wsrep_trx_fragment_size = 1;
SET SESSION BINLOG_FORMAT='STATEMENT';
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
INSERT INTO t1 VALUES (4);
INSERT INTO t1 VALUES (5);
--connection node_2
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
--let $wait_condition = SELECT COUNT(*) > 0 FROM t1;
--source include/wait_condition.inc
--connection node_1
COMMIT;
--connection node_2
SELECT COUNT(*) = 5 FROM t1;
DROP TABLE t1;
......@@ -16,7 +16,7 @@ INSERT INTO t2 VALUES (6),(7),(8),(9),(10),(1);
--connection node_2
SET GLOBAL wsrep_slave_threads = 2;
SET GLOBAL DEBUG = 'd,sync.wsrep_apply_cb';
SET GLOBAL debug_dbug = 'd,sync.wsrep_apply_cb';
# Begin SR transaction
--connection node_1
......@@ -48,7 +48,7 @@ COMMIT;
--connection node_2
SET GLOBAL wsrep_slave_threads = 1;
SET GLOBAL DEBUG = '';
SET GLOBAL debug_dbug = '';
SET DEBUG_SYNC='now SIGNAL signal.wsrep_apply_cb';
SET DEBUG_SYNC='now SIGNAL signal.wsrep_apply_cb';
SET DEBUG_SYNC='now SIGNAL signal.wsrep_apply_cb';
......@@ -58,3 +58,5 @@ SELECT COUNT(*) = 10 FROM t1;
DROP TABLE t1;
DROP TABLE t2;
SET DEBUG_SYNC = RESET;
#
# mysql-wsrep-features#29 Unwarranted deadlock error with SR and a single-node cluster
#
SET SESSION wsrep_trx_fragment_size = 1;
SET SESSION binlog_format = STATEMENT;
create table t1 (id int not null, f_id int not null, f int not null,
primary key(f_id, id)) engine=innodb;
create table t2 (id int not null,s_id int not null,s varchar(200),
primary key(id)) engine=innodb;
INSERT INTO t1 VALUES (8, 1, 3);
INSERT INTO t1 VALUES (1, 2, 1);
INSERT INTO t2 VALUES (1, 0, '');
INSERT INTO t2 VALUES (8, 1, '');
DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
WHERE mm.id IS NULL;
DROP TABLE t1;
DROP TABLE t2;
......@@ -734,6 +734,9 @@ INSERT INTO t1 VALUES (1,1);
ALTER TABLE t1 ADD COLUMN f INT AFTER a;
ALTER TABLE t1 DROP b, DROP f;
DROP TABLE t1;
CREATE TABLE t1(t TEXT NOT NULL, FULLTEXT(t)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
ALTER TABLE t1 MODIFY COLUMN t TEXT;
DROP TABLE t1;
CREATE TABLE t1
(id INT PRIMARY KEY, c2 INT UNIQUE,
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
......@@ -1414,6 +1417,9 @@ INSERT INTO t1 VALUES (1,1);
ALTER TABLE t1 ADD COLUMN f INT AFTER a;
ALTER TABLE t1 DROP b, DROP f;
DROP TABLE t1;
CREATE TABLE t1(t TEXT NOT NULL, FULLTEXT(t)) ENGINE=InnoDB ROW_FORMAT=COMPACT;
ALTER TABLE t1 MODIFY COLUMN t TEXT;
DROP TABLE t1;
CREATE TABLE t1
(id INT PRIMARY KEY, c2 INT UNIQUE,
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
......@@ -2094,10 +2100,13 @@ INSERT INTO t1 VALUES (1,1);
ALTER TABLE t1 ADD COLUMN f INT AFTER a;
ALTER TABLE t1 DROP b, DROP f;
DROP TABLE t1;
CREATE TABLE t1(t TEXT NOT NULL, FULLTEXT(t)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
ALTER TABLE t1 MODIFY COLUMN t TEXT;
DROP TABLE t1;
disconnect analyze;
SELECT variable_value-@old_instant instants
FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column';
instants
170
171
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
......@@ -633,6 +633,11 @@ ALTER TABLE t1 ADD COLUMN f INT AFTER a;
ALTER TABLE t1 DROP b, DROP f;
DROP TABLE t1;
# MDEV-18579 Assertion !ctx->online || num_fts_index == 0
eval CREATE TABLE t1(t TEXT NOT NULL, FULLTEXT(t)) $engine;
ALTER TABLE t1 MODIFY COLUMN t TEXT;
DROP TABLE t1;
dec $format;
}
disconnect analyze;
......
......@@ -89,10 +89,7 @@ int my_close(File fd, myf MyFlags)
my_file_info[fd].type= UNOPEN;
}
#ifndef _WIN32
do
{
err= close(fd);
} while (err == -1 && errno == EINTR);
#else
err= my_win_close(fd);
#endif
......
......@@ -6330,17 +6330,17 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
if (m_sp->agg_type() == GROUP_AGGREGATE)
{
List<Item> list;
list.empty();
for (uint i=0; i < arg_count; i++)
list.push_back(*(args+i));
Item_sum_sp *item_sp;
Query_arena *arena, backup;
arena= thd->activate_stmt_arena_if_needed(&backup);
if (arg_count)
{
List<Item> list;
for (uint i= 0; i < arg_count; i++)
list.push_back(args[i]);
item_sp= new (thd->mem_root) Item_sum_sp(thd, context, m_name, sp, list);
}
else
item_sp= new (thd->mem_root) Item_sum_sp(thd, context, m_name, sp);
......@@ -6354,7 +6354,6 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
if (err)
DBUG_RETURN(TRUE);
list.empty();
DBUG_RETURN(FALSE);
}
......
......@@ -81,7 +81,6 @@ extern uchar *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const uchar *key,
uint nextflag);
extern uchar *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo,
const uchar *key, HASH_INFO *pos);
extern ulong hp_hashnr(HP_KEYDEF *keyinfo,const uchar *key);
extern ulong hp_rec_hashnr(HP_KEYDEF *keyinfo,const uchar *rec);
extern void hp_movelink(HASH_INFO *pos,HASH_INFO *next_link,
HASH_INFO *newlink);
......
......@@ -19,6 +19,7 @@
#include "heapdef.h"
#include <m_ctype.h>
static ulong hp_hashnr(HP_KEYDEF *keydef, const uchar *key);
/*
Find out how many rows there is in the given range
......@@ -209,11 +210,9 @@ void hp_movelink(HASH_INFO *pos, HASH_INFO *next_link, HASH_INFO *newlink)
return;
}
#ifndef NEW_HASH_FUNCTION
/* Calc hashvalue for a key */
ulong hp_hashnr(register HP_KEYDEF *keydef, register const uchar *key)
static ulong hp_hashnr(HP_KEYDEF *keydef, const uchar *key)
{
/*register*/
ulong nr=1, nr2=4;
......@@ -350,136 +349,6 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const uchar *rec)
return(nr);
}
#else
/*
* Fowler/Noll/Vo hash
*
* The basis of the hash algorithm was taken from an idea sent by email to the
* IEEE Posix P1003.2 mailing list from Phong Vo (kpv@research.att.com) and
* Glenn Fowler (gsf@research.att.com). Landon Curt Noll (chongo@toad.com)
* later improved on their algorithm.
*
* The magic is in the interesting relationship between the special prime
* 16777619 (2^24 + 403) and 2^32 and 2^8.
*
* This hash produces the fewest collisions of any function that we've seen so
* far, and works well on both numbers and strings.
*/
ulong hp_hashnr(register HP_KEYDEF *keydef, register const uchar *key)
{
/*
Note, if a key consists of a combination of numeric and
a text columns, it most likely won't work well.
Making text columns work with NEW_HASH_FUNCTION
needs also changes in strings/ctype-xxx.c.
*/
ulong nr= 1, nr2= 4;
HA_KEYSEG *seg,*endseg;
for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++)
{
uchar *pos=(uchar*) key;
key+=seg->length;
if (seg->null_bit)
{
key++;
if (*pos)
{
nr^= (nr << 1) | 1;
/* Add key pack length (2) to key for VARCHAR segments */
if (seg->type == HA_KEYTYPE_VARTEXT1)
key+= 2;
continue;
}
pos++;
}
if (seg->type == HA_KEYTYPE_TEXT)
{
seg->charset->coll->hash_sort(seg->charset, pos, ((uchar*)key)-pos,
&nr, &nr2);
}
else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */
{
uint pack_length= 2; /* Key packing is constant */
uint length= uint2korr(pos);
seg->charset->coll->hash_sort(seg->charset, pos+pack_length, length,
&nr, &nr2);
key+= pack_length;
}
else
{
for ( ; pos < (uchar*) key ; pos++)
{
nr *=16777619;
nr ^=(uint) *pos;
}
}
}
#ifdef ONLY_FOR_HASH_DEBUGGING
DBUG_PRINT("exit", ("hash: 0x%lx", nr));
#endif
return(nr);
}
/* Calc hashvalue for a key in a record */
ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const uchar *rec)
{
ulong nr= 1, nr2= 4;
HA_KEYSEG *seg,*endseg;
for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++)
{
uchar *pos=(uchar*) rec+seg->start;
if (seg->null_bit)
{
if (rec[seg->null_pos] & seg->null_bit)
{
nr^= (nr << 1) | 1;
continue;
}
}
if (seg->type == HA_KEYTYPE_TEXT)
{
uint char_length= seg->length; /* TODO: fix to use my_charpos() */
seg->charset->coll->hash_sort(seg->charset, pos, char_length,
&nr, &nr2);
}
else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */
{
uint pack_length= seg->bit_start;
uint length= (pack_length == 1 ? (uint) *(uchar*) pos : uint2korr(pos));
seg->charset->coll->hash_sort(seg->charset, pos+pack_length,
length, &nr, &nr2);
}
else
{
uchar *end= pos+seg->length;
if (seg->type == HA_KEYTYPE_BIT && seg->bit_length)
{
uchar bits= get_rec_bits(rec + seg->bit_pos,
seg->bit_start, seg->bit_length);
nr *=16777619;
nr ^=(uint) bits;
end--;
}
for ( ; pos < end ; pos++)
{
nr *=16777619;
nr ^=(uint) *pos;
}
}
}
#ifdef ONLY_FOR_HASH_DEBUGGING
DBUG_PRINT("exit", ("hash: 0x%lx", nr));
#endif
return(nr);
}
#endif
/*
Compare keys for two records. Returns 0 if they are identical
......
......@@ -1472,7 +1472,8 @@ instant_alter_column_possible(
& (ALTER_STORED_COLUMN_ORDER | ALTER_DROP_STORED_COLUMN
| ALTER_ADD_STORED_BASE_COLUMN)) {
#if 1 // MDEV-17459: adjust fts_fetch_doc_from_rec() and friends; remove this
if (ib_table.fts) return false;
if (ib_table.fts || innobase_fulltext_exist(altered_table))
return false;
#endif
#if 1 // MDEV-17468: fix bugs with indexed virtual columns & remove this
for (const dict_index_t* index = ib_table.indexes.start;
......@@ -6408,11 +6409,7 @@ prepare_inplace_alter_table_dict(
|| !ctx->new_table->persistent_autoinc);
if (ctx->need_rebuild() && instant_alter_column_possible(
*user_table, ha_alter_info, old_table, altered_table)
#if 1 // MDEV-17459: adjust fts_fetch_doc_from_rec() and friends; remove this
&& !innobase_fulltext_exist(altered_table)
#endif
) {
*user_table, ha_alter_info, old_table, altered_table)) {
for (uint a = 0; a < ctx->num_to_add_index; a++) {
ctx->add_index[a]->table = ctx->new_table;
ctx->add_index[a] = dict_index_add_to_cache(
......
......@@ -3071,10 +3071,12 @@ recv_init_missing_space(dberr_t err, const recv_spaces_t::const_iterator& i)
{
if (srv_operation == SRV_OPERATION_RESTORE
|| srv_operation == SRV_OPERATION_RESTORE_EXPORT) {
if (i->second.name.find(TEMP_TABLE_PATH_PREFIX) != std::string::npos) {
ib::warn() << "Tablespace " << i->first << " was not"
" found at " << i->second.name << " when"
" restoring a (partial?) backup. All redo log"
" for this file will be ignored!";
}
return(err);
}
......
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