diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
commit | a175314c3e5827eb193872241446f2f8f5c9d33c (patch) | |
tree | cd3d60ca99ae00829c52a6ca79150a5b6e62528b /mysql-test/suite/plugins/t | |
parent | Initial commit. (diff) | |
download | mariadb-10.5-a175314c3e5827eb193872241446f2f8f5c9d33c.tar.xz mariadb-10.5-a175314c3e5827eb193872241446f2f8f5c9d33c.zip |
Adding upstream version 1:10.5.12.upstream/1%10.5.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/suite/plugins/t')
47 files changed, 2573 insertions, 0 deletions
diff --git a/mysql-test/suite/plugins/t/audit_null.test b/mysql-test/suite/plugins/t/audit_null.test new file mode 100644 index 00000000..63f5f51e --- /dev/null +++ b/mysql-test/suite/plugins/t/audit_null.test @@ -0,0 +1,61 @@ + +--source include/not_embedded.inc + +if (!$ADT_NULL_SO) { + skip No NULL_AUDIT plugin; +} + +set @old_global_general_log=@@global.general_log; +set global general_log=OFF; + +create user testuser@localhost; +grant select on *.* to testuser@localhost; + +--disable_ps_protocol +install plugin audit_null soname 'adt_null'; + +select 1; +--error 1054 +select foobar; + +show status like 'audit_null%'; + +create procedure au1(x char(16)) select concat("test1", x); +call au1("-12"); + +show status like 'audit_null%'; + +create table t1 (a int); +insert t1 values (1), (2); +select * from t1; +rename table t1 to t2; +alter table t2 add column b int; + +create definer=testuser@localhost view v1 as select t2.a+1, t2_copy.a+2 from t2, t2 as t2_copy; +select * from v1; +drop view v1; + +# temp table generates no audit events +create temporary table t2 (a date); +insert t2 values ('2020-10-09'); +select * from t2; +alter table t2 add column b int; # MDEV-4565 ALTER on a temporary table generates an audit event +drop table t2; + +# internal temp table generates no audit events +explain select distinct * from t2; +select distinct * from t2; + +drop table t2; + +uninstall plugin audit_null; +--enable_ps_protocol + +drop procedure au1; +drop user testuser@localhost; +set global general_log=@old_global_general_log; + +let $MYSQLD_DATADIR= `SELECT @@datadir`; +--replace_regex /::1// /127.0.0.1// +cat_file $MYSQLD_DATADIR/audit_null_tables.log; + diff --git a/mysql-test/suite/plugins/t/audit_null_debug.test b/mysql-test/suite/plugins/t/audit_null_debug.test new file mode 100644 index 00000000..52c50f13 --- /dev/null +++ b/mysql-test/suite/plugins/t/audit_null_debug.test @@ -0,0 +1,36 @@ +--source include/have_debug.inc +--source include/not_embedded.inc + +if (!$ADT_NULL_SO) { + skip No NULL_AUDIT plugin; +} + +alter table mysql.plugin engine=myisam; + +set @old_dbug=@@debug_dbug; +call mtr.add_suppression("Index for table.*mysql.plugin.MYI"); +call mtr.add_suppression("Index for table 'plugin' is corrupt; try to repair it"); + +# +# MySQL BUG#14485479 - INSTALL AUDIT PLUGIN HANGS IF WE TRY TO DISABLE AND ENABLED DURING DDL OPERATION +# (a.k.a. audit event caused by the table access during audit plugin initialization) +# +SET debug_dbug='+d,myisam_pretend_crashed_table_on_usage'; +--replace_result \\ / +--error 126 +install plugin audit_null soname 'adt_null'; +SET debug_dbug=@old_dbug; + +install plugin audit_null soname 'adt_null'; +SET debug_dbug='+d,myisam_pretend_crashed_table_on_usage'; +--replace_result \\ / +--error 126 +uninstall plugin audit_null; +SET debug_dbug=@old_dbug; + +uninstall plugin audit_null; +--error ER_SP_DOES_NOT_EXIST +uninstall plugin audit_null; + +delete from mysql.plugin where name='audit_null'; +alter table mysql.plugin engine=aria; diff --git a/mysql-test/suite/plugins/t/auth_ed25519.test b/mysql-test/suite/plugins/t/auth_ed25519.test new file mode 100644 index 00000000..8e0bdd1d --- /dev/null +++ b/mysql-test/suite/plugins/t/auth_ed25519.test @@ -0,0 +1,57 @@ +# +# MDEV-12160 Modern alternative to the SHA1 authentication plugin +# +source include/not_embedded.inc; +if (!$AUTH_ED25519_SO) { + skip No auth_ed25519 plugin; +} + +replace_result dll so; +eval create function ed25519_password returns string soname "$AUTH_ED25519_SO"; +error ER_CANT_INITIALIZE_UDF; +select ed25519_password(); +error ER_CANT_INITIALIZE_UDF; +select ed25519_password(1); +error ER_CANT_INITIALIZE_UDF; +select ed25519_password("foo", "bar"); +error ER_CANT_INITIALIZE_UDF; +select ed25519_password("foo"); + +install soname 'auth_ed25519'; +select ed25519_password("foo"); +select ed25519_password("foobar"); +select ed25519_password("foo bar"); +select ed25519_password(NULL); + +replace_result dll so; +query_vertical select * from information_schema.plugins where plugin_name='ed25519'; +let $pwd=`select ed25519_password("secret")`; +eval create user test1@localhost identified via ed25519 using '$pwd'; +show grants for test1@localhost; +drop user test1@localhost; +--error ER_PASSWD_LENGTH +create user test1@localhost identified via ed25519 using 'foo'; +--error ER_PASSWD_LENGTH +create user test1@localhost identified via ed25519 using '>>>1234567890123456789012345678901234567890'; +create user test1@localhost identified via ed25519 using password('foo'); +show grants for test1@localhost; +select ed25519_password('foo'); +set password for test1@localhost = password('bar'); +show create user test1@localhost; +select ed25519_password('bar'); +eval set password for test1@localhost = '$pwd'; +show create user test1@localhost; + +replace_result $MASTER_MYPORT PORT $MASTER_MYSOCK SOCKET; +error ER_ACCESS_DENIED_ERROR; +connect con1, localhost, test1, public; +connect con1, localhost, test1, secret; +select current_user(); +disconnect con1; +connection default; + +drop user test1@localhost; +uninstall plugin ed25519; +error ER_CANT_INITIALIZE_UDF; +select ed25519_password("foo"); +drop function ed25519_password; diff --git a/mysql-test/suite/plugins/t/auth_v0100.test b/mysql-test/suite/plugins/t/auth_v0100.test new file mode 100644 index 00000000..5d0f6f40 --- /dev/null +++ b/mysql-test/suite/plugins/t/auth_v0100.test @@ -0,0 +1,28 @@ +--source include/not_embedded.inc + +if (!$AUTH_0X0100_SO) { + skip No auth_0x0100 plugin; +} + +install soname 'auth_0x0100'; + +select plugin_name, plugin_type_version from information_schema.plugins where +plugin_type='authentication' and plugin_library is not null order by plugin_name; + +create user tt identified via auth_0x0100; +create user zzzzzzzzzzzzzzzz; +grant select on test.* to zzzzzzzzzzzzzzzz; + +--replace_result $MASTER_MYSOCK MASTER_MYSOCK $MASTER_MYPORT MASTER_MYPORT +--error ER_ACCESS_DENIED_ERROR +connect (c0,localhost,tt); + +grant proxy on zzzzzzzzzzzzzzzz to tt; +connect (c1,localhost,tt); +connection c1; + +--query_vertical select user(), current_user(), @@external_user +connection default; +drop user tt; +drop user zzzzzzzzzzzzzzzz; +uninstall plugin auth_0x0100; diff --git a/mysql-test/suite/plugins/t/binlog-simple_plugin_check.test b/mysql-test/suite/plugins/t/binlog-simple_plugin_check.test new file mode 100644 index 00000000..773dafe8 --- /dev/null +++ b/mysql-test/suite/plugins/t/binlog-simple_plugin_check.test @@ -0,0 +1,31 @@ +--source include/not_embedded.inc +--source include/have_binlog_format_statement.inc + +if (!$SIMPLE_PASSWORD_CHECK_SO) { + skip No SIMPLE_PASSWORD_CHECK plugin; +} + +INSTALL SONAME "simple_password_check"; +SELECT PLUGIN_NAME FROM INFORMATION_SCHEMA.PLUGINS +WHERE PLUGIN_NAME='simple_password_check'; + + +--echo # +--echo # MDEV-14031 Password policy causes replication failure +--echo # + +--disable_query_log +RESET MASTER; # get rid of previous tests binlog +--enable_query_log + +CREATE USER user1@localhost IDENTIFIED BY 'BsG9#9.cem#!85'; + +--error ER_NOT_VALID_PASSWORD +CREATE USER user2@localhost IDENTIFIED BY 'bsg9#d.cem#!85'; + +DROP USER user1@localhost; + +--let $binlog_file = LAST +source include/show_binlog_events.inc; + +UNINSTALL PLUGIN simple_password_check; diff --git a/mysql-test/suite/plugins/t/cassandra.opt b/mysql-test/suite/plugins/t/cassandra.opt new file mode 100644 index 00000000..76639e7d --- /dev/null +++ b/mysql-test/suite/plugins/t/cassandra.opt @@ -0,0 +1 @@ +--plugin-load-add=$HA_CASSANDRA_SO --loose-cassandra=on diff --git a/mysql-test/suite/plugins/t/cassandra.test b/mysql-test/suite/plugins/t/cassandra.test new file mode 100644 index 00000000..b12de78e --- /dev/null +++ b/mysql-test/suite/plugins/t/cassandra.test @@ -0,0 +1,758 @@ +# +# Tests for cassandra storage engine +# +if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'cassandra' AND support IN ('YES', 'DEFAULT', 'ENABLED')`) +{ + --skip Test requires Cassandra. +} + +--disable_warnings +drop table if exists t0, t1; +--enable_warnings + +--echo # +--echo # Check variables and status counters +--echo # +show status like 'cassandra%'; +show variables like 'cassandra%'; + +--echo # +--echo # Test various errors on table creation. +--echo # +--error ER_REQUIRES_PRIMARY_KEY +create table t1 (a int) engine=cassandra + thrift_host='localhost' keyspace='foo' column_family='colfam'; + +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE +create table t1 (a int primary key, b int) engine=cassandra + thrift_host='localhost' keyspace='foo' column_family='colfam'; + +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE +create table t1 (rowkey char(10) primary key, column1 char(10)) engine=cassandra + thrift_host='127.0.0.2' keyspace='foo' column_family='colfam'; + +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE +create table t1 (rowkey char(10) primary key, column1 char(10)) engine=cassandra + thrift_host='localhost' keyspace='no_such_keyspace' column_family='colfam'; + +# No column family specified +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE +create table t1 (rowkey char(10) primary key, column1 char(10)) engine=cassandra + thrift_host='localhost' keyspace='no_such_keyspace'; + +############################################################################ +## Cassandra initialization +############################################################################ + +# Step 1: remove the keyspace that could be left over from the previous test +--remove_files_wildcard $MYSQLTEST_VARDIR cassandra_test_cleanup.cql +--write_file $MYSQLTEST_VARDIR/cassandra_test_cleanup.cql +drop keyspace mariadbtest2; +EOF +--error 0,1,2 +--system cqlsh -3 -f $MYSQLTEST_VARDIR/cassandra_test_cleanup.cql + +# Step 2: create new keyspace and test column families +--remove_files_wildcard $MYSQLTEST_VARDIR cassandra_test_init.cql +--write_file $MYSQLTEST_VARDIR/cassandra_test_init.cql + +CREATE KEYSPACE mariadbtest2 + WITH strategy_class = 'org.apache.cassandra.locator.SimpleStrategy' + AND strategy_options:replication_factor='1'; + +USE mariadbtest2; +create columnfamily cf1 ( pk varchar primary key, data1 varchar, data2 bigint); + +create columnfamily cf2 (rowkey bigint primary key, a bigint); + +create columnfamily cf3 (rowkey bigint primary key, intcol int); + +create columnfamily cf4 (rowkey bigint primary key, datecol timestamp); + +create columnfamily cf5 (rowkey bigint primary key, uuidcol uuid); + +create columnfamily cf6 (rowkey uuid primary key, col1 int); + +create columnfamily cf7 (rowkey int primary key, boolcol boolean); + +create columnfamily cf8 (rowkey varchar primary key, countercol counter); +update cf8 set countercol=countercol+1 where rowkey='cnt1'; +update cf8 set countercol=countercol+100 where rowkey='cnt2'; + +create columnfamily cf9 (rowkey varchar primary key, varint_col varint); +insert into cf9 (rowkey, varint_col) values ('val-01', 1); +insert into cf9 (rowkey, varint_col) values ('val-0x123456', 1193046); +insert into cf9 (rowkey, varint_col) values ('val-0x12345678', 305419896); + +create columnfamily cf11 (rowkey varchar primary key, decimal_col decimal); +insert into cf11 (rowkey, decimal_col) values ('val_0.5', 0.5); +insert into cf11 (rowkey, decimal_col) values ('val_1.5', 1.5); +insert into cf11 (rowkey, decimal_col) values ('val_1234', 1234); + +create columnfamily cf12 (rowkey varchar primary key, decimal_col decimal); + +create columnfamily cf13 (rowkey int primary key, b blob); + +create columnfamily cf14 ( rowkey int primary key, a int ); + +EOF +--error 0,1,2 +--system cqlsh -3 -f $MYSQLTEST_VARDIR/cassandra_test_init.cql + + +# Step 3: Cassandra's CQL doesn't allow certain kinds of queries. Run them in +# CLI +--remove_files_wildcard $MYSQLTEST_VARDIR cassandra_test_init.cli +--write_file $MYSQLTEST_VARDIR/cassandra_test_init.cli +use mariadbtest2; +CREATE COLUMN FAMILY cf10 + WITH comparator = UTF8Type + AND key_validation_class=UTF8Type + AND default_validation_class = UTF8Type; + +CREATE COLUMN FAMILY cfd1 + WITH comparator = UTF8Type + AND key_validation_class=UTF8Type + AND default_validation_class = UTF8Type; +SET cfd1['1']['very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_long_name']='1'; + +CREATE COLUMN FAMILY cfd2 + WITH comparator = UTF8Type + AND key_validation_class=Int32Type + AND default_validation_class = UTF8Type; + +EOF + +--error 0,1,2 +--system cassandra-cli -f $MYSQLTEST_VARDIR/cassandra_test_init.cli + +############################################################################ +## Cassandra initialization ends +############################################################################ + +--echo # Now, create a table for real and insert data +create table t1 (pk varchar(36) primary key, data1 varchar(60), data2 bigint) engine=cassandra + thrift_host='localhost' keyspace='mariadbtest2' column_family='cf1'; + +--echo # Just in case there were left-overs from previous: +delete from t1; +select * from t1; + +insert into t1 values ('rowkey10', 'data1-value', 123456); +insert into t1 values ('rowkey11', 'data1-value2', 34543); +insert into t1 values ('rowkey12', 'data1-value3', 454); +select * from t1; + +explain +select * from t1 where pk='rowkey11'; +select * from t1 where pk='rowkey11'; + +# Deletion functions weirdly: it sets all columns to NULL +# but when If I do this in cassandra-cli: +# +# del cf1[ascii('rowkey10')] +# +# Subsequent 'list cf1' command also gives +# +# RowKey: rowkey10 +# +# without any columns. +# +# CQL seems to simply ignore all "incomplete" records. + +delete from t1 where pk='rowkey11'; +select * from t1; + +delete from t1; +select * from t1; + +--echo # +--echo # A query with filesort (check that table_flags() & HA_REC_NOT_IN_SEQ, +--echo # also check ::rnd_pos() +--echo # +insert into t1 values ('rowkey10', 'data1-value', 123456); +insert into t1 values ('rowkey11', 'data1-value2', 34543); +insert into t1 values ('rowkey12', 'data1-value3', 454); +select * from t1 order by data2; + +delete from t1; +drop table t1; + +--echo # +--echo # MDEV-476: Cassandra: Server crashes in calculate_key_len on DELETE with ORDER BY +--echo # +CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2'; + +INSERT INTO t1 VALUES (1,1),(2,2); +DELETE FROM t1 ORDER BY a LIMIT 1; + +DROP TABLE t1; + +--echo # +--echo # Batched INSERT +--echo # +show variables like 'cassandra_insert_batch_size'; +show status like 'cassandra_row_insert%'; +CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2'; + +delete from t1; +INSERT INTO t1 VALUES (1,1),(2,2); +DELETE FROM t1 ORDER BY a LIMIT 1; + +DROP TABLE t1; +show status like 'cassandra_row_insert%'; + +--echo # FLUSH STATUS doesn't work for our variables, just like with InnoDB. +flush status; +show status like 'cassandra_row_insert%'; + +--echo # +--echo # Batched Key Access +--echo # + +--echo # Control variable (we are not yet able to make use of MRR's buffer) +show variables like 'cassandra_multi%'; + +--echo # MRR-related status variables: +show status like 'cassandra_multi%'; + +CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2'; +delete from t1; +INSERT INTO t1 VALUES (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); + +set @tmp_jcl=@@join_cache_level; +set join_cache_level=8; +explain select * from t1 A, t1 B where B.rowkey=A.a; + +select * from t1 A, t1 B where B.rowkey=A.a; +show status like 'cassandra_multi%'; + +# The following INSERTs are really UPDATEs +insert into t1 values(1, 8); +insert into t1 values(3, 8); +insert into t1 values(5, 8); +insert into t1 values(7, 8); + +select * from t1 A, t1 B where B.rowkey=A.a; +show status like 'cassandra_multi%'; + +delete from t1; +drop table t1; + +--echo # +--echo # MDEV-480: TRUNCATE TABLE on a Cassandra table does not remove rows +--echo # +CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2'; +INSERT INTO t1 VALUES (0,0),(1,1),(2,2); +truncate table t1; +select * from t1; +drop table t1; + +--echo # +--echo # MDEV-494, part #1: phantom row for big full-scan selects +--echo # +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2'; + +insert into t1 select A.a + 10 * B.a + 100*C.a, 12345 from t0 A, t0 B, t0 C; + +select count(*) from t1; +select count(*) from t1 where a=12345; + +delete from t1; +drop table t1; +drop table t0; + +--echo # 32-bit INT type support +CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, intcol INT) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf3'; +insert into t1 values (10,10); +insert into t1 values (12,12); +delete from t1; +drop table t1; + +--echo # +--echo # Try accessing column family w/o explicitly defined columns +--echo # +--error ER_INTERNAL_ERROR +CREATE TABLE t1 (my_primary_key varchar(10) PRIMARY KEY) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf10'; + +CREATE TABLE t1 (rowkey varchar(10) PRIMARY KEY) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf10'; + +DROP TABLE t1; + +--echo # +--echo # Timestamp datatype support +--echo # +CREATE TABLE t2 (rowkey bigint PRIMARY KEY, datecol timestamp) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf4'; + +delete from t2; +insert into t2 values (1, '2012-08-29 01:23:45'); +select * from t2; +delete from t2; + +--echo # MDEV-498: Cassandra: Inserting a timestamp does not work on a 32-bit system +INSERT INTO t2 VALUES (10,'2012-12-12 12:12:12'); +SELECT * FROM t2; +delete from t2; + +--echo # +--echo # (no MDEV#) Check that insert counters work correctly +--echo # +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +let $start_inserts=`select variable_value from information_schema.SESSION_STATUS + where variable_name ='Cassandra_row_inserts'`; +let $start_insert_batches=`select variable_value from information_schema.SESSION_STATUS + where variable_name ='Cassandra_row_insert_batches'`; + +set cassandra_insert_batch_size=10; +insert into t2 select A.a+10*B.a, now() from t0 A, t0 B; + +--disable_query_log +eval select + (select variable_value - $start_inserts from information_schema.SESSION_STATUS + where variable_name ='Cassandra_row_inserts') + AS 'inserts', + (select variable_value - $start_insert_batches from information_schema.SESSION_STATUS + where variable_name ='Cassandra_row_insert_batches') + AS 'insert_batches'; +--enable_query_log + +let $start_inserts=`select variable_value from information_schema.SESSION_STATUS + where variable_name ='Cassandra_row_inserts'`; +let $start_insert_batches=`select variable_value from information_schema.SESSION_STATUS + where variable_name ='Cassandra_row_insert_batches'`; + +set cassandra_insert_batch_size=1; +insert into t2 select A.a+10*B.a+100, now() from t0 A, t0 B; + +--disable_query_log +eval select + (select variable_value - $start_inserts from information_schema.SESSION_STATUS + where variable_name ='Cassandra_row_inserts') + AS 'inserts', + (select variable_value - $start_insert_batches from information_schema.SESSION_STATUS + where variable_name ='Cassandra_row_insert_batches') + AS 'insert_batches'; +--enable_query_log + +delete from t2; +drop table t2; +drop table t0; + +--echo # +--echo # UUID datatype support +--echo # +#create columnfamily cf5 (rowkey bigint primary key, uuidcol uuid); +CREATE TABLE t2 (rowkey bigint PRIMARY KEY, uuidcol char(36)) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; +delete from t2; + +insert into t2 values(1,'9b5658dc-f32f-11e1-94cd-f46d046e9f09'); + +--error ER_WARN_DATA_OUT_OF_RANGE +insert into t2 values(2,'not-an-uuid'); + +--error ER_WARN_DATA_OUT_OF_RANGE +insert into t2 values(3,'9b5658dc-f32f-11e1=94cd-f46d046e9f09'); + +--error ER_WARN_DATA_OUT_OF_RANGE +insert into t2 values(4,'9b5658dc-fzzf-11e1-94cd-f46d046e9f09'); + +--error ER_WARN_DATA_OUT_OF_RANGE +insert into t2 values + (5,'9b5658dc-f11f-11e1-94cd-f46d046e9f09'), + (6,'9b5658dc-f11f011e1-94cd-f46d046e9f09'); + +select * from t2; + +delete from t2; +drop table t2; + +# create columnfamily cf6 (rowkey uuid primary key, col1 int); +CREATE TABLE t2 (rowkey char(36) PRIMARY KEY, col1 int) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf6'; +delete from t2; + +insert into t2 values('9b5658dc-f32f-11e1-94cd-f46d046e9f09', 1234); + +--error ER_WARN_DATA_OUT_OF_RANGE +insert into t2 values('not-an-uuid', 563); + +select * from t2; +delete from t2; +drop table t2; + + +--echo # +--echo # boolean datatype support +--echo # +# create columnfamily cf7 (rowkey int primary key, boolcol boolean); +CREATE TABLE t2 (rowkey int PRIMARY KEY, boolcol bool) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf7'; +insert into t2 values (0, 0); +insert into t2 values (1, 1); +select * from t2; +delete from t2; +drop table t2; + + +--echo # +--echo # Counter datatype support (read-only) +--echo # +# create columnfamily cf8 (rowkey int primary key, countercol counter); +CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, countercol bigint) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf8'; +select * from t2; +drop table t2; + +--echo # +--echo # Check that @@cassandra_default_thrift_host works +--echo # +show variables like 'cassandra_default_thrift_host'; +set @tmp=@@cassandra_default_thrift_host; +--error ER_GLOBAL_VARIABLE +set cassandra_default_thrift_host='localhost'; +set global cassandra_default_thrift_host='localhost'; + +--echo # Try creating a table without specifying thrift_host: +CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, countercol bigint) ENGINE=CASSANDRA + keyspace='mariadbtest2' column_family = 'cf8'; +select * from t2; +drop table t2; + +set global cassandra_default_thrift_host=@tmp; + +--echo # +--echo # Consistency settings +--echo # +show variables like 'cassandra_%consistency'; +set @tmp=@@cassandra_write_consistency; + +--echo # Unfortunately, there is no easy way to check if setting have the effect.. +set cassandra_write_consistency='ONE'; +set cassandra_write_consistency='QUORUM'; +set cassandra_write_consistency='LOCAL_QUORUM'; +set cassandra_write_consistency='EACH_QUORUM'; +set cassandra_write_consistency='ALL'; +set cassandra_write_consistency='ANY'; +set cassandra_write_consistency='TWO'; +set cassandra_write_consistency='THREE'; + +set cassandra_write_consistency=@tmp; + +--echo # +--echo # varint datatype support +--echo # +# create columnfamily cf9 (rowkey varchar primary key, varint_col varint); +CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, varint_col varbinary(32)) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf9'; +--sorted_result +select rowkey, hex(varint_col) from t2; +drop table t2; + +--echo # now, let's check what happens when MariaDB's column is not wide enough: +CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, varint_col varbinary(2)) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf9'; +--sorted_result +--error ER_INTERNAL_ERROR +select rowkey, hex(varint_col) from t2; +drop table t2; + +--echo # +--echo # Decimal datatype support +--echo # +CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, decimal_col varbinary(32)) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf11'; +select rowkey, hex(decimal_col) from t2; +drop table t2; + +--echo # +--echo # Mapping TIMESTAMP -> int64 +--echo # +set @save_tz= @@time_zone; +set time_zone='UTC'; +CREATE TABLE t2 (rowkey bigint PRIMARY KEY, datecol timestamp) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf4'; +insert into t2 values (1, '2012-08-29 01:23:45'); +INSERT INTO t2 VALUES (10,'2012-08-29 01:23:46'); +drop table t2; + +CREATE TABLE t2 (rowkey bigint PRIMARY KEY, datecol bigint) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf4'; +select * from t2; +delete from t2; +drop table t2; +set time_zone=@save_tz; + +--echo # +--echo # Check whether changing parameters with ALTER TABLE works. +--echo # +CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, decimal_col varbinary(32)) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf11'; + +#--error ER_INTERNAL_ERROR +#alter table t2 column_family='cf9'; + +drop table t2; + +CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, decimal_col varbinary(32)) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf11'; + +let $c1= `select variable_value from information_schema.global_status + where variable_name like 'cassandra_row_inserts'`; +alter table t2 column_family='cf12'; +let $c2= `select variable_value from information_schema.global_status + where variable_name like 'cassandra_row_inserts'`; + +--disable_query_log +eval select ($c2 - $c1) as 'Writes made during ALTER TABLE'; +--enable_query_log + +drop table t2; + +--echo # +--echo # UPDATE command support +--echo # +create table t1 (pk varchar(36) primary key, data1 varchar(60), data2 bigint) engine=cassandra + thrift_host='localhost' keyspace='mariadbtest2' column_family='cf1'; + +insert into t1 values ('rowkey10', 'data1-value', 123456); +insert into t1 values ('rowkey11', 'data1-value2', 34543); +insert into t1 values ('rowkey12', 'data1-value3', 454); +select * from t1; + +update t1 set data1='updated-1' where pk='rowkey11'; +select * from t1; +update t1 set pk='new-rowkey12' where pk='rowkey12'; +select * from t1; + +delete from t1; +drop table t1; + +--echo # +--echo # Dynamic columns support +--echo # +CREATE TABLE t2 (rowkey bigint PRIMARY KEY, uuidcol blob DYNAMIC_COLUMN_STORAGE=1) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; +drop table t2; + +--echo #error: dynamic column is not a blob +--error ER_WRONG_FIELD_SPEC +CREATE TABLE t2 (rowkey bigint PRIMARY KEY, uuidcol char(36) DYNAMIC_COLUMN_STORAGE=1) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; + +--echo #error: double dynamic column +--error ER_WRONG_FIELD_SPEC +CREATE TABLE t2 (rowkey bigint PRIMARY KEY, uuidcol blob DYNAMIC_COLUMN_STORAGE=1, textcol blob DYNAMIC_COLUMN_STORAGE=1) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; + +--echo # +--echo # Dynamic column read +--echo # +#prepare data +CREATE TABLE t2 (rowkey bigint PRIMARY KEY, uuidcol char(36)) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; +delete from t2; +insert into t2 values(1,'9b5658dc-f32f-11e1-94cd-f46d046e9f09'); +insert into t2 values(2,'9b5658dc-f32f-11e1-94cd-f46d046e9f0a'); +drop table t2; + +#test dynamic column read +CREATE TABLE t2 (rowkey bigint PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; +select rowkey, column_list(dyn), column_get(dyn, 'uuidcol' as char) from t2; +drop table t2; + +#cleanup data +CREATE TABLE t2 (rowkey bigint PRIMARY KEY, uuidcol char(36)) ENGINE=CASSANDRA + thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; +delete from t2; +drop table t2; + +--echo # +--echo # Dynamic column insert +--echo # +CREATE TABLE t2 (rowkey bigint PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; +insert into t2 values (1, column_create("dyn1", 1, "dyn2", "two")); +select rowkey, column_json(dyn) from t2; +delete from t2; +drop table t2; +--echo # bigint +CREATE TABLE t1 (rowkey bigint PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2'; +insert into t1 values (1, column_create("dyn1", 1, "dyn2", "two", 'a', 254324)); +insert into t1 values (2, column_create("dyn1", 1, "dyn2", "two", 'a', 2543)); +select rowkey, column_json(dyn) from t1; +delete from t1; +drop table t1; +--echo # int +CREATE TABLE t1 (rowkey bigint PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf3'; +insert into t1 values (1, column_create("dyn1", 1, "dyn2", "two", 'intcol', 254324)); +insert into t1 values (2, column_create("dyn1", 1, "dyn2", "two", 'intcol', 2543)); +select rowkey, column_json(dyn) from t1; +delete from t1; +drop table t1; +--echo # timestamp +CREATE TABLE t1 (rowkey bigint PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf4'; +insert into t1 values (1, column_create("dyn1", 1, "dyn2", "two", 'datecol', 254324)); +insert into t1 values (2, column_create("dyn1", 1, "dyn2", "two", 'datecol', 2543)); +select rowkey, column_json(dyn) from t1; +delete from t1; +drop table t1; +--echo # boolean +CREATE TABLE t1 (rowkey int PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf7'; +insert into t1 values (1, column_create("dyn1", 1, "dyn2", "two", 'boolcol', 254324)); +insert into t1 values (2, column_create("dyn1", 1, "dyn2", "two", 'boolcol', 0)); +select rowkey, column_json(dyn) from t1; +select rowkey, column_json(dyn) from t1; +update t1 set dyn=column_add(dyn, "dyn2", null, "dyn3", "3"); +select rowkey, column_json(dyn) from t1; +update t1 set dyn=column_add(dyn, "dyn1", null) where rowkey= 1; +select rowkey, column_json(dyn) from t1; +update t1 set dyn=column_add(dyn, "dyn3", null, "a", "ddd"); +select rowkey, column_json(dyn) from t1; +update t1 set dyn=column_add(dyn, "12345678901234", "ddd"); +select rowkey, column_json(dyn) from t1; +update t1 set dyn=column_add(dyn, "12345678901234", null); +select rowkey, column_json(dyn) from t1; +update t1 set dyn=column_add(dyn, 'boolcol', null) where rowkey= 2; +select rowkey, column_json(dyn) from t1; +update t1 set rowkey= 3, dyn=column_add(dyn, "dyn1", null, 'boolcol', 0) where rowkey= 2; +select rowkey, column_json(dyn) from t1; +delete from t1; +drop table t1; + +CREATE TABLE t1 (rowkey varchar(10) PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd1'; +--error ER_INTERNAL_ERROR +select * from t1; +drop table t1; + +# MDEV-560 +CREATE TABLE t1 (rowkey int PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) +ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd2'; +DELETE FROM t1; +insert into t1 values (1, column_create("dyn", 1)); +select rowkey, column_list(dyn) from t1; +# Cleanup +delete from t1; +DROP TABLE t1; + +# MDEV-561 (incorrect format data to dynamic column) +CREATE TABLE t1 (rowkey int PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) +ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd2'; +--error ER_DYN_COL_WRONG_FORMAT +insert into t1 values (1,'9b5658dc-f32f-11e1-94cd-f46d046e9f0a'); +delete from t1; +DROP TABLE t1; + +--echo # +--echo # MDEV-565: Server crashes in ha_cassandra::write_row on +--echo # inserting NULL into a dynamic column +--echo # +CREATE TABLE t1 (rowkey int PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) +ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd2'; +insert into t1 values (1, NULL); +delete from t1; +DROP TABLE t1; + +--echo # +--echo # strange side effect of Cassandra - remiving all columns of primary +--echo # key removes all row. +--echo # +CREATE TABLE t1 (rowkey int PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) +ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd2'; +INSERT INTO t1 VALUES(2,column_create("ab","ab")); +select rowkey, column_json(dyn) from t1; +UPDATE t1 set dyn=NULL; +select rowkey, column_json(dyn) from t1; +INSERT INTO t1 VALUES(2,column_create("ab","ab")); +select rowkey, column_json(dyn) from t1; +UPDATE t1 set dyn=""; +select rowkey, column_json(dyn) from t1; +delete from t1; +DROP TABLE t1; + +--echo # +--echo # MDEV-4005 #Server crashes on creating a Cassandra table +--echo # with a mix of static and dynamic columns +--echo # +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +--remove_files_wildcard $MYSQLTEST_VARDIR cassandra_test_cleanup.cql +--write_file $MYSQLTEST_VARDIR/cassandra_test_cleanup.cql +drop keyspace bug; +EOF +--error 0,1,2 +--system cqlsh -3 -f $MYSQLTEST_VARDIR/cassandra_test_cleanup.cql + +--remove_files_wildcard $MYSQLTEST_VARDIR cassandra_test_init.cql +--write_file $MYSQLTEST_VARDIR/cassandra_test_init.cql + +CREATE KEYSPACE bug + WITH strategy_class = 'org.apache.cassandra.locator.SimpleStrategy' + AND strategy_options:replication_factor='1'; + +USE bug; +create columnfamily cf1 ( pk int primary key, col_int int, a bigint ); +EOF + +--system cqlsh -3 -f $MYSQLTEST_VARDIR/cassandra_test_init.cql + + +CREATE TABLE t1 ( + pk int primary key, + col_int int, + dyncol blob DYNAMIC_COLUMN_STORAGE=yes +) ENGINE=cassandra keyspace='bug' thrift_host = '127.0.0.1' column_family='cf1'; + +drop table t1; + + +--echo # +--echo # MDEV-4000: Mapping between Cassandra blob (BytesType) and MySQL BLOB does not work +--echo # + +create table t1 (rowkey int primary key, b blob ) ENGINE=CASSANDRA thrift_host = '127.0.0.1' `keyspace`='mariadbtest2' `column_family`='cf13'; + +insert into t1 values (1, 'fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-bar'); +insert into t1 values (2, 'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq-baz'); + +select * from t1; +drop table t1; + +--echo # +--echo # MDEV-4001: Cassandra: server crashes in ha_cassandra::end_bulk_insert on INSERT .. SELECT with a non-existing column +--echo # +create table t1 (rowkey int primary key, a int) ENGINE=cassandra thrift_host='127.0.0.1' keyspace='mariadbtest2' column_family='cf14'; +--error ER_BAD_FIELD_ERROR +insert into t1 (a) select b from t1; +drop table t1; + +############################################################################ +## Cassandra cleanup +############################################################################ +--disable_parsing +drop columnfamily cf1; +drop columnfamily cf2; +drop columnfamily cf3; +drop columnfamily cf4; +drop columnfamily cf5; +drop columnfamily cf6; +drop columnfamily cf7; + +drop columnfamily cf13; +drop columnfamily cf14; +--enable_parsing +############################################################################ +## Cassandra cleanup ends +############################################################################ + diff --git a/mysql-test/suite/plugins/t/cassandra_qcache.opt b/mysql-test/suite/plugins/t/cassandra_qcache.opt new file mode 100644 index 00000000..76639e7d --- /dev/null +++ b/mysql-test/suite/plugins/t/cassandra_qcache.opt @@ -0,0 +1 @@ +--plugin-load-add=$HA_CASSANDRA_SO --loose-cassandra=on diff --git a/mysql-test/suite/plugins/t/cassandra_qcache.test b/mysql-test/suite/plugins/t/cassandra_qcache.test new file mode 100644 index 00000000..5ccce461 --- /dev/null +++ b/mysql-test/suite/plugins/t/cassandra_qcache.test @@ -0,0 +1,59 @@ +# +# Tests for cassandra storage engine +# +-- source include/have_query_cache.inc + +if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'cassandra' AND support IN ('YES', 'DEFAULT', 'ENABLED')`) +{ + --skip Test requires Cassandra. +} + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + +############################################################################ +## Cassandra initialization +############################################################################ + +# Step 1: remove the keyspace that could be left over from the previous test +--remove_files_wildcard $MYSQLTEST_VARDIR cassandra_test_cleanup.cql +--write_file $MYSQLTEST_VARDIR/cassandra_test_cleanup.cql +drop keyspace mariadbtest2; +EOF +--error 0,1,2 +--system cqlsh -3 -f $MYSQLTEST_VARDIR/cassandra_test_cleanup.cql + +# Step 2: create new keyspace and test column families +--remove_files_wildcard $MYSQLTEST_VARDIR cassandra_test_init.cql +--write_file $MYSQLTEST_VARDIR/cassandra_test_init.cql + +CREATE KEYSPACE mariadbtest2 + WITH strategy_class = 'org.apache.cassandra.locator.SimpleStrategy' + AND strategy_options:replication_factor='1'; + +USE mariadbtest2; +create columnfamily cf1 ( rowkey int primary key, a int ); +EOF + +--error 0,1,2 +--system cqlsh -3 -f $MYSQLTEST_VARDIR/cassandra_test_init.cql + +############################################################################ +## The test itsef: +############################################################################ + +create table t1 (rowkey int primary key, a int) engine=cassandra + thrift_host='localhost' keyspace='mariadbtest2' column_family='cf1'; +create table t2 like t1; + +set global query_cache_size=1024*1024; + +select * from t1; +insert into t2 values (1,1); + +select * from t1; +select sql_no_cache * from t1; + +drop table t1,t2; +set global QUERY_CACHE_SIZE=0; diff --git a/mysql-test/suite/plugins/t/cassandra_reinstall.test b/mysql-test/suite/plugins/t/cassandra_reinstall.test new file mode 100644 index 00000000..95e4f7b6 --- /dev/null +++ b/mysql-test/suite/plugins/t/cassandra_reinstall.test @@ -0,0 +1,16 @@ +# +# MDEV-4403 Attempting to use cassandra storage engine causes "service 'my_snprintf_service' interface version mismatch" +# +if (!$HA_CASSANDRA_SO) { + skip No Cassandra engine; +} + +install soname 'ha_cassandra'; +select plugin_name,plugin_status,plugin_library from information_schema.plugins where plugin_name = 'cassandra'; +uninstall plugin cassandra; +select plugin_name,plugin_status,plugin_library from information_schema.plugins where plugin_name = 'cassandra'; +install soname 'ha_cassandra'; +select plugin_name,plugin_status,plugin_library from information_schema.plugins where plugin_name = 'cassandra'; +uninstall plugin cassandra; +select plugin_name,plugin_status,plugin_library from information_schema.plugins where plugin_name = 'cassandra'; + diff --git a/mysql-test/suite/plugins/t/cracklib_password_check.test b/mysql-test/suite/plugins/t/cracklib_password_check.test new file mode 100644 index 00000000..89b53b65 --- /dev/null +++ b/mysql-test/suite/plugins/t/cracklib_password_check.test @@ -0,0 +1,45 @@ +--source include/not_embedded.inc + +if (!$CRACKLIB_PASSWORD_CHECK_SO) { + skip No CRACKLIB_PASSWORD_CHECK plugin; +} + +install soname "cracklib_password_check"; + +--vertical_results +--replace_result .dll .so +select * from information_schema.plugins where plugin_name='cracklib_password_check'; +--horizontal_results + +--error ER_NOT_VALID_PASSWORD +grant select on *.* to foocar identified by 'foocar'; +show warnings; + +--error ER_NOT_VALID_PASSWORD +grant select on *.* to foocar identified by 'racoof'; +show warnings; + +--error ER_NOT_VALID_PASSWORD +grant select on *.* to foo@barbar identified by 'barbar'; +show warnings; + +--error ER_NOT_VALID_PASSWORD +grant select on *.* to foobar identified by 'qwerty'; +show warnings; + +grant select on *.* to foobar identified by 'q$%^&*rty'; +drop user foobar; + +--echo # +--echo # MDEV-9851: CREATE USER w/o IDENTIFIED BY clause causes crash +--echo # when using cracklib plugin +--echo # + +--error ER_NOT_VALID_PASSWORD +create user 'newuser'@'localhost'; + +uninstall plugin cracklib_password_check; + +create user foo1 identified by 'pwd'; +drop user foo1; + diff --git a/mysql-test/suite/plugins/t/dialog.test b/mysql-test/suite/plugins/t/dialog.test new file mode 100644 index 00000000..1dd52cfd --- /dev/null +++ b/mysql-test/suite/plugins/t/dialog.test @@ -0,0 +1,52 @@ +# +# test for the client "dialog" plugin +# + +--source include/not_embedded.inc + +if (!$DIALOG_SO) { + skip No dialog auth plugin; +} +if (!$DIALOG_EXAMPLES_SO) { + skip No dialog auth plugin; +} + +--replace_result .dll .so +eval install plugin three_attempts soname '$DIALOG_EXAMPLES_SO'; +create user test_dialog identified via three_attempts using 'SECRET'; + +--write_file $MYSQLTEST_VARDIR/tmp/dialog_good.txt +foo +1234 +SECRET +select user(), current_user(); +EOF + +--write_file $MYSQLTEST_VARDIR/tmp/dialog_bad.txt +foo +1234 +wrong +SECRET +EOF + +--echo # +--echo # -pSECRET is picked up, no questions asked. +--echo # +--exec echo "select user(), current_user();"|$MYSQL_TEST -u test_dialog -pSECRET + +--echo # +--echo # without -p. up to three questions are asked on the stdin. +--echo # athentication is successful, the correct pasword is on the third line +--echo # +--exec $MYSQL_TEST -u test_dialog < $MYSQLTEST_VARDIR/tmp/dialog_good.txt + +--echo # +--echo # athentication is unsuccessful, first three lines are all wrong +--echo # +--error 1 +--exec $MYSQL_TEST -u test_dialog < $MYSQLTEST_VARDIR/tmp/dialog_bad.txt + +--remove_file $MYSQLTEST_VARDIR/tmp/dialog_good.txt +--remove_file $MYSQLTEST_VARDIR/tmp/dialog_bad.txt +drop user test_dialog; +uninstall plugin three_attempts; diff --git a/mysql-test/suite/plugins/t/false_dupes-6543.test b/mysql-test/suite/plugins/t/false_dupes-6543.test new file mode 100644 index 00000000..ebdbe00e --- /dev/null +++ b/mysql-test/suite/plugins/t/false_dupes-6543.test @@ -0,0 +1,18 @@ +# +# MDEV-6543 Crash if enable 'federatedx' when 'federated' plugin already enabled, and vice-versa +# +if(!$HA_FEDERATED_SO) { + skip Needs ha_federated.so; +} +if(!$HA_FEDERATEDX_SO) { + skip Needs ha_federatedx.so; +} + +install soname 'ha_federated'; +# note: no error below! install soname ignores already loaded plugins +install soname 'ha_federated'; +# note: an error here, even though plugin name is the same! +--error ER_UDF_EXISTS +install soname 'ha_federatedx'; +uninstall soname 'ha_federated'; + diff --git a/mysql-test/suite/plugins/t/feedback_plugin_install.opt b/mysql-test/suite/plugins/t/feedback_plugin_install.opt new file mode 100644 index 00000000..a711ae94 --- /dev/null +++ b/mysql-test/suite/plugins/t/feedback_plugin_install.opt @@ -0,0 +1 @@ +--loose-feedback diff --git a/mysql-test/suite/plugins/t/feedback_plugin_install.test b/mysql-test/suite/plugins/t/feedback_plugin_install.test new file mode 100644 index 00000000..559dcebf --- /dev/null +++ b/mysql-test/suite/plugins/t/feedback_plugin_install.test @@ -0,0 +1,17 @@ +--source include/not_embedded.inc + +if (`select length('$FEEDBACK_SO') = 0`) { + skip No feedback plugin; +} + +--replace_regex /\.dll/.so/ +eval install plugin feedback soname '$FEEDBACK_SO'; +select plugin_status from information_schema.plugins where plugin_name='feedback'; +--replace_result https http +--sorted_result +select * from information_schema.feedback where variable_name like 'feed%' + and variable_name not like '%_uid' + and variable_name not like '%debug%'; + +uninstall plugin feedback; + diff --git a/mysql-test/suite/plugins/t/feedback_plugin_load.opt b/mysql-test/suite/plugins/t/feedback_plugin_load.opt new file mode 100644 index 00000000..6bf7594c --- /dev/null +++ b/mysql-test/suite/plugins/t/feedback_plugin_load.opt @@ -0,0 +1,2 @@ +--loose-feedback +--plugin-load-add=$FEEDBACK_SO diff --git a/mysql-test/suite/plugins/t/feedback_plugin_load.test b/mysql-test/suite/plugins/t/feedback_plugin_load.test new file mode 100644 index 00000000..ecf678eb --- /dev/null +++ b/mysql-test/suite/plugins/t/feedback_plugin_load.test @@ -0,0 +1,44 @@ +if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'feedback' and plugin_status='active'`) +{ + --skip Feedback plugin is not active +} +if (`select @@feedback_url = ""`) +{ + --skip Feedback plugin is not active +} + +select plugin_status from information_schema.plugins where plugin_name='feedback'; + +# Every SELECT from INFORMATION_SCHEMA.FEEDBACK increases the value of 'FEEDBACK used'. +# We cannot record the actual value, because the test can be executed more than once, +# but we can check that the value indeed increases as expected. +# There is still a room for some race condition, e.g. if at the very moment +# between first SELECT to store the value and the next SELECT to check that it increases, +# the feedback plugin is activated. But the probability of it is close to 0, +# so lets get back to it if it ever happens. + +# Lets say the plugin was used X times before this SELECT +SELECT variable_value INTO @feedback_used FROM information_schema.feedback where variable_name = 'FEEDBACK used'; + +# Now $feedback_used == X+1, and 'FEEDBACK used' is also X+1. And variable_value is increased again when we run the next SELECT +SELECT variable_value = @feedback_used + 1 as 'MUST BE 1' FROM information_schema.feedback where variable_name = 'FEEDBACK used'; + +# Now when we are happy with 'FEEDBACK used', we can check everything else + +--replace_result https http +--sorted_result +select * from information_schema.feedback where variable_name like 'feed%' + and variable_name not like '%_uid' and variable_name not like 'FEEDBACK used' + and variable_name not like '%debug%'; + +# Embedded server does not use the table mysqld.user and thus +# does not automatically use utf8mb4 on startup. Use it manually. +--disable_query_log +if (`SELECT VERSION() LIKE '%embedded%'`) +{ + create temporary table t1 (a json); +} +--enable_query_log +SELECT VARIABLE_VALUE>0, VARIABLE_NAME FROM INFORMATION_SCHEMA.FEEDBACK +WHERE VARIABLE_NAME LIKE 'Collation used %' +ORDER BY VARIABLE_NAME; diff --git a/mysql-test/suite/plugins/t/feedback_plugin_send.test b/mysql-test/suite/plugins/t/feedback_plugin_send.test new file mode 100644 index 00000000..b28f9d4c --- /dev/null +++ b/mysql-test/suite/plugins/t/feedback_plugin_send.test @@ -0,0 +1,43 @@ +# Restart of server does not work for embedded. +--source include/not_embedded.inc + +source feedback_plugin_load.test; + +if (!$MTR_FEEDBACK_PLUGIN) { + skip MTR_FEEDBACK_PLUGIN is not set; +} + +# +# Yep. The plugin waits 5 minutes before sending anything, +# and there's no way to force it to send anything sooner. +# Let's wait, and hope that mtr is started with --parallel and +# is doing some work in other workers. +# + +sleep 100; +set global sql_mode=ONLY_FULL_GROUP_BY; +sleep 210; + + +# The test expects that the plugin will send a report at least 2 times, +# now (5 min after loading) and on server shutdown which happens below. +# Since we have already waited for 5 min, let's be generous +# and make sure the server has enough time to shut down properly. +# We won't lose anything if the shutdown is fast, but if it's slow, the plugin +# will still be able to finish the job and write about it in the error log. + +--let $shutdown_timeout= 60 +source include/restart_mysqld.inc; + +replace_result https http 2 6; +perl; + $log_error= $ENV{'MYSQLTEST_VARDIR'} . '/log/mysqld.1.err'; + open(LOG, '<', $log_error) or die "open(< $log_error): $!"; + + %logg=(); + while ($_=<LOG>) { + $logg{$&}++ if /feedback plugin:.*/; + } + print "$logg{$_}: $_\n" for sort keys %logg; + close LOG; +EOF diff --git a/mysql-test/suite/plugins/t/fulltext_plugin.test b/mysql-test/suite/plugins/t/fulltext_plugin.test new file mode 100644 index 00000000..e9b4343e --- /dev/null +++ b/mysql-test/suite/plugins/t/fulltext_plugin.test @@ -0,0 +1,17 @@ +--source include/have_simple_parser.inc + +# +# BUG#39746 - Debug flag breaks struct definition (server crash) +# +--replace_result .dll .so +eval INSTALL PLUGIN simple_parser SONAME '$MYPLUGLIB_SO'; +CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a) WITH PARSER simple_parser); +ALTER TABLE t1 ADD FULLTEXT(b) WITH PARSER simple_parser; +DROP TABLE t1; +UNINSTALL PLUGIN simple_parser; + +# +# Bug #69682 - mysqld crashes after uninstall of plugin with "first" status var +# +show status like 'a%status'; + diff --git a/mysql-test/suite/plugins/t/locales.opt b/mysql-test/suite/plugins/t/locales.opt new file mode 100644 index 00000000..21f53ca3 --- /dev/null +++ b/mysql-test/suite/plugins/t/locales.opt @@ -0,0 +1,3 @@ +--loose-locale +--plugin-load-add=$LOCALES_SO + diff --git a/mysql-test/suite/plugins/t/locales.test b/mysql-test/suite/plugins/t/locales.test new file mode 100644 index 00000000..a3afe750 --- /dev/null +++ b/mysql-test/suite/plugins/t/locales.test @@ -0,0 +1,13 @@ +if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'locales' and plugin_status='active'`) +{ + --skip LOCALES plugin is not active +} + +select * from information_schema.locales; +show locales; +--error ER_PARSE_ERROR +show locales like '%spanish%'; +show locales where description like '%spanish%'; +--error ER_PARSE_ERROR +flush locales; + diff --git a/mysql-test/suite/plugins/t/max_password_errors_auth_named_pipe.opt b/mysql-test/suite/plugins/t/max_password_errors_auth_named_pipe.opt new file mode 100644 index 00000000..52bf94f3 --- /dev/null +++ b/mysql-test/suite/plugins/t/max_password_errors_auth_named_pipe.opt @@ -0,0 +1 @@ +--loose-enable-named-pipe --plugin-load=$AUTH_NAMED_PIPE_SO diff --git a/mysql-test/suite/plugins/t/max_password_errors_auth_named_pipe.test b/mysql-test/suite/plugins/t/max_password_errors_auth_named_pipe.test new file mode 100644 index 00000000..79aeb7d3 --- /dev/null +++ b/mysql-test/suite/plugins/t/max_password_errors_auth_named_pipe.test @@ -0,0 +1,22 @@ +# Tests that max_password_errors has no effect on login errors with +# passwordless plugins (Windows version / auth_named_pipe) + +--source include/not_embedded.inc +--source include/have_auth_named_pipe.inc +if (`SELECT '$USERNAME' = 'nosuchuser'`) { + skip skipped for nosuchuser; +} +set @old_max_password_errors=@@max_password_errors; +create user nosuchuser identified with 'named_pipe'; + +set global max_password_errors=1; +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +error ER_ACCESS_DENIED_NO_PASSWORD_ERROR; +connect(pipe_con,localhost,nosuchuser,,,,,PIPE); +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +error ER_ACCESS_DENIED_NO_PASSWORD_ERROR; +connect(pipe_con,localhost,nosuchuser,,,,,PIPE); + +DROP USER nosuchuser; +FLUSH PRIVILEGES; +set global max_password_errors=@old_max_password_errors; diff --git a/mysql-test/suite/plugins/t/max_password_errors_auth_socket.opt b/mysql-test/suite/plugins/t/max_password_errors_auth_socket.opt new file mode 100644 index 00000000..91bb73e3 --- /dev/null +++ b/mysql-test/suite/plugins/t/max_password_errors_auth_socket.opt @@ -0,0 +1 @@ +--loose-enable-named-pipe --plugin-load=$AUTH_SOCKET_SO diff --git a/mysql-test/suite/plugins/t/max_password_errors_auth_socket.test b/mysql-test/suite/plugins/t/max_password_errors_auth_socket.test new file mode 100644 index 00000000..495a68a0 --- /dev/null +++ b/mysql-test/suite/plugins/t/max_password_errors_auth_socket.test @@ -0,0 +1,23 @@ +# Tests that max_password_errors has no effect on login errors with +# passwordless plugins (Unix version / auth_unix_socket) + +--source include/not_embedded.inc +--source include/have_unix_socket.inc + +if (`SELECT '$USER' = 'nosuchuser'`) { + skip USER is nosuchuser; +} +set @old_max_password_errors=@@max_password_errors; +create user nosuchuser identified with 'unix_socket'; + +set global max_password_errors=1; +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +error ER_ACCESS_DENIED_NO_PASSWORD_ERROR; +connect(pipe_con,localhost,nosuchuser); +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +error ER_ACCESS_DENIED_NO_PASSWORD_ERROR; +connect(pipe_con,localhost,nosuchuser); + +DROP USER nosuchuser; +FLUSH PRIVILEGES; +set global max_password_errors=@old_max_password_errors; diff --git a/mysql-test/suite/plugins/t/multiauth.test b/mysql-test/suite/plugins/t/multiauth.test new file mode 100644 index 00000000..f0eea21e --- /dev/null +++ b/mysql-test/suite/plugins/t/multiauth.test @@ -0,0 +1,214 @@ +--source include/not_ubsan.inc +--source include/platform.inc + +let $REGEX_VERSION_ID=/$mysql_get_server_version/VERSION_ID/; +let $REGEX_PASSWORD_LAST_CHANGED=/password_last_changed": [0-9]*/password_last_changed": #/; +let $REGEX_GLOBAL_PRIV=$REGEX_PASSWORD_LAST_CHANGED $REGEX_VERSION_ID; + +# +# MDEV-11340 Allow multiple alternative authentication methods for the same user +# +--source include/have_unix_socket.inc +if (`SELECT '$USER' = 'mysqltest1'`) { + skip USER is mysqltest1; +} +if (!$AUTH_ED25519_SO) { + skip No auth_ed25519 plugin; +} + +--let $plugindir=`SELECT @@global.plugin_dir` +install soname 'auth_ed25519'; + +--let $try_auth=$MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/peercred_test.txt 2>&1 + +--write_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt +--let $replace1=$USER@localhost +--let $replace2=$USER@% +--replace_result $replace1 "USER@localhost" $replace2 "USER@%" +select user(), current_user(), database(); +EOF + +--let $creplace=create user '$USER' +--let $dreplace=drop user '$USER' + +# +# socket,password +# +--replace_result $creplace "create user 'USER'" +eval $creplace identified via unix_socket OR mysql_native_password as password("GOOD"); +create user mysqltest1 identified via unix_socket OR mysql_native_password as password("good"); +show create user mysqltest1; +--echo # name match = ok +--exec $try_auth -u $USER +--echo # name does not match, password good = ok +--exec $try_auth -u mysqltest1 -pgood +--echo # name does not match, password bad = failure +--error 1 +--exec $try_auth -u mysqltest1 -pbad +--replace_result $dreplace "drop user 'USER'" +eval $dreplace, mysqltest1; + +# +# password,socket +# +--replace_result $creplace "create user 'USER'" +eval $creplace identified via mysql_native_password as password("GOOD") OR unix_socket; +create user mysqltest1 identified via mysql_native_password as password("good") OR unix_socket; +show create user mysqltest1; +--echo # name match = ok +--exec $try_auth -u $USER +--echo # name does not match, password good = ok +--exec $try_auth -u mysqltest1 -pgood +--echo # name does not match, password bad = failure +--error 1 +--exec $try_auth -u mysqltest1 -pbad +--replace_result $dreplace "drop user 'USER'" +eval $dreplace, mysqltest1; + +# +# socket,ed25519 +# +--replace_result $creplace "create user 'USER'" +eval $creplace identified via unix_socket OR ed25519 as password("GOOD"); +create user mysqltest1 identified via unix_socket OR ed25519 as password("good"); +show create user mysqltest1; +--echo # name match = ok +--exec $try_auth -u $USER +--echo # name does not match, password good = ok +--exec $try_auth -u mysqltest1 -pgood +--echo # name does not match, password bad = failure +--error 1 +--exec $try_auth -u mysqltest1 -pbad +--replace_result $dreplace "drop user 'USER'" +eval $dreplace, mysqltest1; + +# +# ed25519,socket +# +--replace_result $creplace "create user 'USER'" +eval $creplace identified via ed25519 as password("GOOD") OR unix_socket; +create user mysqltest1 identified via ed25519 as password("good") OR unix_socket; +show create user mysqltest1; +--echo # name match = ok +--exec $try_auth -u $USER +--echo # name does not match, password good = ok +--exec $try_auth -u mysqltest1 -pgood +--echo # name does not match, password bad = failure +--error 1 +--exec $try_auth -u mysqltest1 -pbad +--replace_result $dreplace "drop user 'USER'" +eval $dreplace, mysqltest1; + +# +# ed25519,socket,password +# +--replace_result $creplace "create user 'USER'" +eval $creplace identified via ed25519 as password("GOOD") OR unix_socket OR mysql_native_password as password("works"); +create user mysqltest1 identified via ed25519 as password("good") OR unix_socket OR mysql_native_password as password("works"); +show create user mysqltest1; +--echo # name match = ok +--exec $try_auth -u $USER +--echo # name does not match, password good = ok +--exec $try_auth -u mysqltest1 -pgood +--echo # name does not match, second password works = ok +--exec $try_auth -u mysqltest1 -pworks +--echo # name does not match, password bad = failure +--error 1 +--exec $try_auth -u mysqltest1 -pbad +--replace_result $dreplace "drop user 'USER'" +eval $dreplace, mysqltest1; + +# +# password,password +# +create user mysqltest1 identified via mysql_native_password as password("good") OR mysql_native_password as password("works"); +show create user mysqltest1; +--echo # password good = ok +--exec $try_auth -u mysqltest1 -pgood +--echo # second password works = ok +--exec $try_auth -u mysqltest1 -pworks +--echo # password bad = failure +--error 1 +--exec $try_auth -u mysqltest1 -pbad +drop user mysqltest1; + +# +# show grants, flush privileges, set password, alter user +# +create user mysqltest1 identified via ed25519 as password("good") OR unix_socket OR mysql_native_password as password("works"); +show grants for mysqltest1; +--replace_regex $REGEX_GLOBAL_PRIV +select json_detailed(priv) from mysql.global_priv where user='mysqltest1'; +select password,plugin,authentication_string from mysql.user where user='mysqltest1'; +flush privileges; +show create user mysqltest1; +set password for mysqltest1 = password('foobar'); +show create user mysqltest1; +alter user mysqltest1 identified via unix_socket OR mysql_native_password as password("some"); +show create user mysqltest1; +set password for mysqltest1 = password('foobar'); +show create user mysqltest1; +alter user mysqltest1 identified via unix_socket; +--error ER_SET_PASSWORD_AUTH_PLUGIN +set password for mysqltest1 = password('bla'); +alter user mysqltest1 identified via mysql_native_password as password("some") or unix_socket; +show create user mysqltest1; +drop user mysqltest1; + +--source include/switch_to_mysql_user.inc +--replace_regex /\d{6}/XX.YY.ZZ/ +--error ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE +create user mysqltest1 identified via ed25519 as password("good") OR unix_socket OR mysql_native_password as password("works"); +--source include/switch_to_mysql_global_priv.inc + +# +# invalid password,socket +# +--replace_result $creplace "create user 'USER'" +eval $creplace identified via mysql_native_password as '1234567890123456789012345678901234567890a' OR unix_socket; +create user mysqltest1 identified via mysql_native_password as '1234567890123456789012345678901234567890a' OR unix_socket; +update mysql.global_priv set priv=replace(priv, '1234567890123456789012345678901234567890a', 'invalid password'); +flush privileges; +show create user mysqltest1; +--echo # name match = ok +--exec $try_auth -u $USER +--echo # name does not match = failure +--error 1 +--exec $try_auth -u mysqltest1 +--echo # SET PASSWORD helps +set password for mysqltest1 = password('bla'); +--exec $try_auth -u mysqltest1 -pbla +--replace_result $dreplace "drop user 'USER'" +eval $dreplace, mysqltest1; + +# +# missing client-side plugin +# +create user mysqltest1 identified via ed25519 as password("good"); +show create user mysqltest1; +--echo # no plugin = failure +--replace_result $plugindir <PLUGINDIR> +--error 1 +--exec $try_auth -u mysqltest1 -pgood --plugin-dir=$plugindir/no +alter user mysqltest1 identified via ed25519 as password("good") OR mysql_native_password as password("works"); +show create user mysqltest1; +--echo # no plugin = failure +--error 1 +--exec $try_auth -u mysqltest1 -pgood --plugin-dir=$plugindir/no +--echo # no plugin, second password works = ok +--exec $try_auth -u mysqltest1 -pworks --plugin-dir=$plugindir/no +drop user mysqltest1; + +uninstall soname 'auth_ed25519'; +--remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt + +# +# MDEV-21928 ALTER USER doesn't remove excess authentication plugins from mysql.global_priv +# +create user mysqltest1 identified via mysql_native_password as password("good") OR unix_socket; +show create user mysqltest1; +alter user mysqltest1 identified via mysql_native_password as password("better"); +show create user mysqltest1; +flush privileges; +show create user mysqltest1; +drop user mysqltest1; diff --git a/mysql-test/suite/plugins/t/pam.test b/mysql-test/suite/plugins/t/pam.test new file mode 100644 index 00000000..2611f25e --- /dev/null +++ b/mysql-test/suite/plugins/t/pam.test @@ -0,0 +1,81 @@ +let $PAM_PLUGIN_VERSION= $AUTH_PAM_SO; +--source pam_init.inc + +--write_file $MYSQLTEST_VARDIR/tmp/pam_good.txt +not very secret challenge +9225 +select user(), current_user(), database(); +EOF + +--write_file $MYSQLTEST_VARDIR/tmp/pam_bad.txt +not very secret challenge +9224 +select user(), current_user(), database(); +EOF + +--write_file $MYSQLTEST_VARDIR/tmp/pam_ugly.txt +crash pam module +616 +select user(), current_user(), database(); +EOF + +--write_file $MYSQLTEST_VARDIR/tmp/pam_good2.txt +9212 +select user(), current_user(), database(); +EOF + +--echo # +--echo # athentication is successful, challenge/pin are ok +--echo # note that current_user() differs from user() +--echo # +--exec $MYSQL_TEST -u test_pam < $MYSQLTEST_VARDIR/tmp/pam_good.txt + +--echo # +--echo # athentication is unsuccessful +--echo # +--error 1 +--exec $MYSQL_TEST -u test_pam < $MYSQLTEST_VARDIR/tmp/pam_bad.txt + +--echo # +--echo # athentication is unsuccessful +--echo # +--error 1 +--exec $MYSQL_TEST -u test_pam < $MYSQLTEST_VARDIR/tmp/pam_ugly.txt + +--echo # +--echo # athentication is successful +--echo # +--error 0 +--exec $MYSQL_TEST -u test_pam -pgoodpassword < $MYSQLTEST_VARDIR/tmp/pam_good2.txt + +--echo # +--echo # athentication is unsuccessful +--echo # +--error 1 +--exec $MYSQL_TEST -u test_pam -pbadpassword < $MYSQLTEST_VARDIR/tmp/pam_good2.txt + +drop user test_pam; +drop user pam_test; +create user PAM_TEST identified via pam using 'mariadb_mtr'; + +--echo # +--echo # athentication is unsuccessful +--echo # +--error 1 +--exec $MYSQL_TEST -u PAM_TEST < $MYSQLTEST_VARDIR/tmp/pam_good.txt + +set global pam_winbind_workaround=1; +--echo # +--echo # athentication is successful +--echo # +--exec $MYSQL_TEST -u PAM_TEST < $MYSQLTEST_VARDIR/tmp/pam_good.txt + +--remove_file $MYSQLTEST_VARDIR/tmp/pam_good.txt +--remove_file $MYSQLTEST_VARDIR/tmp/pam_good2.txt +--remove_file $MYSQLTEST_VARDIR/tmp/pam_bad.txt +--remove_file $MYSQLTEST_VARDIR/tmp/pam_ugly.txt +drop user PAM_TEST; + +let $count_sessions= 1; +--source include/wait_until_count_sessions.inc +uninstall plugin pam; diff --git a/mysql-test/suite/plugins/t/pam_cleartext.opt b/mysql-test/suite/plugins/t/pam_cleartext.opt new file mode 100644 index 00000000..aa270885 --- /dev/null +++ b/mysql-test/suite/plugins/t/pam_cleartext.opt @@ -0,0 +1 @@ +--loose-pam-use-cleartext-plugin diff --git a/mysql-test/suite/plugins/t/pam_cleartext.test b/mysql-test/suite/plugins/t/pam_cleartext.test new file mode 100644 index 00000000..0824ee8f --- /dev/null +++ b/mysql-test/suite/plugins/t/pam_cleartext.test @@ -0,0 +1,37 @@ +let $PAM_PLUGIN_VERSION= $AUTH_PAM_SO; +--source pam_init.inc + +show variables like 'pam_use_%'; + +--write_file $MYSQLTEST_VARDIR/tmp/pam_good.txt +not very secret challenge +9225 +select user(), current_user(), database(); +EOF + +--echo # +--echo # same test as in pam.test now fails +--echo # +--error 1 +--exec $MYSQL_TEST -u test_pam < $MYSQLTEST_VARDIR/tmp/pam_good.txt +--error 1 +--exec $MYSQL_TEST -u test_pam -p'something' < $MYSQLTEST_VARDIR/tmp/pam_good.txt + +--remove_file $MYSQLTEST_VARDIR/tmp/pam_good.txt + +--echo # +--echo # success +--echo # +--exec $MYSQL -u test_pam -p'cleartext good' -e 'select user(), current_user(), database()' + +--echo # +--echo # failure +--echo # +--error 1 +--exec $MYSQL -u test_pam -p'cleartext bad' -e 'select user(), current_user(), database()' + +drop user test_pam; +drop user pam_test; +let $count_sessions= 1; +--source include/wait_until_count_sessions.inc +uninstall plugin pam; diff --git a/mysql-test/suite/plugins/t/pam_init.inc b/mysql-test/suite/plugins/t/pam_init.inc new file mode 100644 index 00000000..131b787f --- /dev/null +++ b/mysql-test/suite/plugins/t/pam_init.inc @@ -0,0 +1,14 @@ + +--source include/not_embedded.inc + +if (!$PAM_PLUGIN_VERSION) { + skip No pam auth plugin; +} + +eval install plugin pam soname '$PAM_PLUGIN_VERSION'; +create user test_pam identified via pam using 'mariadb_mtr'; +create user pam_test; +grant proxy on pam_test to test_pam; + +let $plugindir=`SELECT @@global.plugin_dir`; + diff --git a/mysql-test/suite/plugins/t/pam_v1.test b/mysql-test/suite/plugins/t/pam_v1.test new file mode 100644 index 00000000..75425116 --- /dev/null +++ b/mysql-test/suite/plugins/t/pam_v1.test @@ -0,0 +1,52 @@ +let $PAM_PLUGIN_VERSION= $AUTH_PAM_V1_SO; +--source pam_init.inc + +--write_file $MYSQLTEST_VARDIR/tmp/pam_good.txt +not very secret challenge +9225 +select user(), current_user(), database(); +EOF + +--write_file $MYSQLTEST_VARDIR/tmp/pam_bad.txt +not very secret challenge +9224 +select user(), current_user(), database(); +EOF + +--write_file $MYSQLTEST_VARDIR/tmp/pam_good2.txt +9212 +select user(), current_user(), database(); +EOF + +--echo # +--echo # athentication is successful, challenge/pin are ok +--echo # note that current_user() differs from user() +--echo # +--exec $MYSQL_TEST -u test_pam < $MYSQLTEST_VARDIR/tmp/pam_good.txt + +--echo # +--echo # athentication is unsuccessful +--echo # +--error 1 +--exec $MYSQL_TEST -u test_pam < $MYSQLTEST_VARDIR/tmp/pam_bad.txt + +--echo # +--echo # athentication is successful +--echo # +--error 0 +--exec $MYSQL_TEST -u test_pam -pgoodpassword < $MYSQLTEST_VARDIR/tmp/pam_good2.txt + +--echo # +--echo # athentication is unsuccessful +--echo # +--error 1 +--exec $MYSQL_TEST -u test_pam -pbadpassword < $MYSQLTEST_VARDIR/tmp/pam_good2.txt + +--remove_file $MYSQLTEST_VARDIR/tmp/pam_good.txt +--remove_file $MYSQLTEST_VARDIR/tmp/pam_good2.txt +--remove_file $MYSQLTEST_VARDIR/tmp/pam_bad.txt +drop user test_pam; +drop user pam_test; +let $count_sessions= 1; +--source include/wait_until_count_sessions.inc +uninstall plugin pam; diff --git a/mysql-test/suite/plugins/t/processlist.test b/mysql-test/suite/plugins/t/processlist.test new file mode 100644 index 00000000..39b715b8 --- /dev/null +++ b/mysql-test/suite/plugins/t/processlist.test @@ -0,0 +1,20 @@ +# +# MDEV-15359 Thread stay in "cleaning up" status after finishing +# +source include/have_innodb.inc; + +create table t1 (a int) engine=innodb; +start transaction; +insert t1 values (1); +let id=`select connection_id()`; +connect con2,localhost,root; +let $wait_condition=select state='' from information_schema.processlist where id = $id; +--source include/wait_condition.inc +replace_regex /\"/-/; #" +let s=`show engine innodb status`; +disable_query_log; +eval select regexp_replace("$s", '(?s)^.*MySQL thread id $id,.*root([^\n]*)\n.*', '\\\\1') as `state from show engine innodb status, must be empty`; +enable_query_log; +disconnect con2; +connection default; +drop table t1; diff --git a/mysql-test/suite/plugins/t/qc_info.test b/mysql-test/suite/plugins/t/qc_info.test new file mode 100644 index 00000000..8803e907 --- /dev/null +++ b/mysql-test/suite/plugins/t/qc_info.test @@ -0,0 +1,26 @@ +set @save_query_cache_size=@@global.query_cache_size; +--source include/default_charset.inc +--source qc_info_init.inc + +# test that hits are correctly incremented +reset query cache; +select * from t1; +select * from t1; +select hits, statement_text from information_schema.query_cache_info; + +drop table t1; +# the query was invalidated +select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_info; + +set global query_cache_size = 0; +select * from information_schema.query_cache_info; + +set global query_cache_size= default; +set global query_cache_type=default; + +--error ER_PARSE_ERROR +show query_cache_info; +--error ER_PARSE_ERROR +flush query_cache_info; + +set @@global.query_cache_size=@save_query_cache_size; diff --git a/mysql-test/suite/plugins/t/qc_info_init.inc b/mysql-test/suite/plugins/t/qc_info_init.inc new file mode 100644 index 00000000..c3f700f0 --- /dev/null +++ b/mysql-test/suite/plugins/t/qc_info_init.inc @@ -0,0 +1,34 @@ +if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'query_cache_info' and plugin_status='active'`) +{ + --skip QUERY_CACHE_INFO plugin is not active +} + +set global query_cache_type=ON; +set local query_cache_type=ON; +set global query_cache_size=1355776; + +create table t1 (a int not null); +insert into t1 values (1),(2),(3); +select * from t1; +select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_info; + +select @@time_zone into @time_zone; +select @@default_week_format into @default_week_format; +select @@character_set_client into @character_set_client; +select @@character_set_results into @character_set_results; +select @@sql_mode into @sql_mode; +select @@div_precision_increment into @div_precision_increment; +select @@lc_time_names into @lc_time_names; +select @@max_sort_length into @max_sort_length; +select @@autocommit into @autocommit; +select @@group_concat_max_len into @group_concat_max_len; +select Name into @new_time_zone from mysql.time_zone_name limit 1; +set time_zone=@new_time_zone,default_week_format=4,character_set_client='binary',character_set_results='utf32',collation_connection='utf32_bin',sql_mode='STRICT_ALL_TABLES',div_precision_increment=7,lc_time_names='ar_SD',autocommit=0, group_concat_max_len=513, max_sort_length=1011; +--disable_result_log +select * from t1; +--enable_result_log +set time_zone= @time_zone, default_week_format= @default_week_format, character_set_client= @character_set_client,character_set_results= @character_set_results, sql_mode= @sql_mode, div_precision_increment= @div_precision_increment, lc_time_names= @lc_time_names, autocommit= @autocommit, group_concat_max_len= @group_concat_max_len, max_sort_length= @max_sort_length; + +--sorted_result +--replace_column 5 # 19 # 23 # +select * from information_schema.query_cache_info; diff --git a/mysql-test/suite/plugins/t/qc_info_init.opt b/mysql-test/suite/plugins/t/qc_info_init.opt new file mode 100644 index 00000000..53b4ff31 --- /dev/null +++ b/mysql-test/suite/plugins/t/qc_info_init.opt @@ -0,0 +1,2 @@ +--loose-query_cache_info +--plugin-load-add=$QUERY_CACHE_INFO_SO diff --git a/mysql-test/suite/plugins/t/qc_info_priv.test b/mysql-test/suite/plugins/t/qc_info_priv.test new file mode 100644 index 00000000..59258731 --- /dev/null +++ b/mysql-test/suite/plugins/t/qc_info_priv.test @@ -0,0 +1,16 @@ +set @save_query_cache_size=@@global.query_cache_size; +--source include/not_embedded.inc +--source qc_info_init.inc + +# try an unprivileged user +create user mysqltest; +connect (conn1,localhost,mysqltest,,); +connection conn1; +select a from t1; +select count(*) from information_schema.query_cache_info; +connection default; +drop user mysqltest; +drop table t1; + +set @@global.query_cache_size=@save_query_cache_size; +set global query_cache_type=default; diff --git a/mysql-test/suite/plugins/t/server_audit.opt b/mysql-test/suite/plugins/t/server_audit.opt new file mode 100644 index 00000000..089ed94b --- /dev/null +++ b/mysql-test/suite/plugins/t/server_audit.opt @@ -0,0 +1,2 @@ +--thread_handling='one-thread-per-connection' + diff --git a/mysql-test/suite/plugins/t/server_audit.test b/mysql-test/suite/plugins/t/server_audit.test new file mode 100644 index 00000000..01da4975 --- /dev/null +++ b/mysql-test/suite/plugins/t/server_audit.test @@ -0,0 +1,235 @@ +--source include/have_plugin_auth.inc +--source include/not_embedded.inc + +if (!$SERVER_AUDIT_SO) { + skip No SERVER_AUDIT plugin; +} + +# An unfortunate wait for check-testcase.test to complete disconnect. +let count_sessions= 1; +source include/wait_until_count_sessions.inc; + +let $MYSQLD_DATADIR= `SELECT @@datadir`; +let SEARCH_FILE= $MYSQLD_DATADIR/server_audit.log; + +install plugin server_audit soname 'server_audit'; + +show variables like 'server_audit%'; +set global server_audit_file_path=null; +set global server_audit_incl_users=null; +set global server_audit_file_path='server_audit.log'; +set global server_audit_output_type=file; +set global server_audit_logging=on; + +--error ER_WRONG_VALUE_FOR_VAR +set global server_audit_incl_users= repeat("'root',", 10000); +show variables like 'server_audit_incl_users'; +--error ER_WRONG_VALUE_FOR_VAR +set global server_audit_excl_users= repeat("'root',", 10000); +show variables like 'server_audit_excl_users'; +let SEARCH_COUNT= 5; +source include/wait_for_line_count_in_file.inc; + +connect (con1,localhost,root,,mysql); +disconnect con1; +let SEARCH_COUNT= 7; +source include/wait_for_line_count_in_file.inc; + +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +--error ER_ACCESS_DENIED_ERROR +connect (con1,localhost,no_such_user,,mysql); +let SEARCH_COUNT= 9; +source include/wait_for_line_count_in_file.inc; + +connection default; +set global server_audit_incl_users='odin, dva, tri'; +create table t1 (id int); +set global server_audit_incl_users='odin, root, dva, tri'; +create table t2 (id int); +set global server_audit_excl_users='odin, dva, tri'; +insert into t1 values (1), (2); +select * from t1; +set global server_audit_incl_users='odin, root, dva, tri'; +insert into t2 values (1), (2); +select * from t2; +alter table t1 rename renamed_t1; +set global server_audit_events='connect,query'; +select 1, + 2, +# comment + 3; +insert into t2 values (1), (2); +select * from t2; +--disable_ps_protocol +--error ER_NO_SUCH_TABLE +select * from t_doesnt_exist; +--enable_ps_protocol +--error 1064 +syntax_error_query; +drop table renamed_t1, t2; +show variables like 'server_audit%'; +set global server_audit_mode=1; +set global server_audit_events=''; +create database sa_db; +let SEARCH_COUNT= 47; +source include/wait_for_line_count_in_file.inc; + +connect (con1,localhost,root,,test); +create table t1 (id2 int); +insert into t1 values (1), (2); +select * from t1; +drop table t1; +use sa_db; +create table sa_t1(id int); +insert into sa_t1 values (1), (2); +drop table sa_t1; +drop database sa_db; +disconnect con1; +let SEARCH_COUNT= 80; +source include/wait_for_line_count_in_file.inc; + +connection default; +create database sa_db; +use sa_db; +CREATE USER u1 IDENTIFIED BY 'pwd-123'; +GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; +SET PASSWORD FOR u1 = PASSWORD('pwd 098'); +CREATE USER u3 IDENTIFIED BY ''; +ALTER USER u3 IDENTIFIED BY 'pwd-456'; +drop user u1, u2, u3; + +set global server_audit_events='query_ddl'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +(select 2); +/*! select 2*/; +/*comment*/ select 2; +drop table t1; + +create procedure pr1() insert into test.t1 values ("foo", 42); +create function fn1(i int) returns int deterministic return i+1; +drop procedure pr1; +drop function fn1; + +set global server_audit_events='query_ddl,query_dml'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +drop table t1; +set global server_audit_events='query_dml'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +(select 2); +/*! select 2*/; +/*comment*/ select 2; +drop table t1; +set global server_audit_events='query_dcl'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +CREATE USER u1 IDENTIFIED BY 'pwd-123'; +GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; +SET PASSWORD +# comment +FOR u1 = PASSWORD('pwd 098'); +--error 1064 +SET PASSWORD FOR u1=<secret>; +CREATE USER u3 IDENTIFIED BY ''; +drop user u1, u2, u3; +select 2; +(select 2); +/*! select 2*/; +/*comment*/ select 2; +drop table t1; +set global server_audit_events='query_dml_no_select'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +drop table t1; +create procedure pr1() insert into test.t1 values ("foo", 42); +create function fn1(i int) returns int deterministic return i+1; +drop procedure pr1; +drop function fn1; + +create procedure pr1() insert into test.t1 values ("foo", 42); +create function fn1(i int) returns int deterministic return i+1; +drop procedure pr1; +drop function fn1; + +set global server_audit_events='table'; +set global server_audit_incl_users='user1'; + +create user user1@localhost; +grant all on sa_db.* to user1@localhost; + +connect (cn1,localhost,user1,,sa_db); +connection cn1; + +create table t1(id int) engine=myisam; +insert delayed into t1 values (1); +connection default; +--echo # Waiting until INSERT DELAYED thread does the insert. +let $wait_condition= SELECT COUNT(*) = 1 FROM t1; +--source include/wait_condition.inc +drop table t1; + +set global server_audit_logging= off; +set global server_audit_incl_users='root'; +set global server_audit_logging= on; +disconnect cn1; +let $count_sessions=1; +source include/wait_until_count_sessions.inc; + +drop user user1@localhost; + +set global server_audit_events=''; +set global server_audit_incl_users='root, plug_dest'; + +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +--sleep 2 +--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK +--error ER_ACCESS_DENIED_ERROR : this should fail : no grant +connect(plug_con,localhost,plug,plug_dest); +--sleep 2 +GRANT PROXY ON plug_dest TO plug; +--sleep 2 +connect(plug_con,localhost,plug,plug_dest); +connection plug_con; +select USER(),CURRENT_USER(); +connection default; +disconnect plug_con; +--sleep 2 +--sleep 2 +DROP USER plug; +DROP USER plug_dest; + +set global server_audit_query_log_limit= 15; +select (1), (2), (3), (4); +select 'A', 'B', 'C', 'D'; +set global server_audit_query_log_limit= 1024; +drop database sa_db; + +set global server_audit_file_path='.'; +--replace_regex /\.[\\\/]/HOME_DIR\// +show status like 'server_audit_current_log'; +set global server_audit_file_path=''; +show status like 'server_audit_current_log'; +set global server_audit_file_path=' '; +show status like 'server_audit_current_log'; +set global server_audit_file_path='nonexisting_dir/'; +show status like 'server_audit_current_log'; +show variables like 'server_audit%'; +uninstall plugin server_audit; + +# replace the timestamp and the hostname with constant values +--replace_regex /[0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\,[^,]*\,/TIME,HOSTNAME,/ /\,[1-9][0-9]*\,/,1,/ /\,[1-9][0-9]*/,ID/ +cat_file $MYSQLD_DATADIR/server_audit.log; +remove_file $MYSQLD_DATADIR/server_audit.log; + diff --git a/mysql-test/suite/plugins/t/show_all_plugins.test b/mysql-test/suite/plugins/t/show_all_plugins.test new file mode 100644 index 00000000..f8f37597 --- /dev/null +++ b/mysql-test/suite/plugins/t/show_all_plugins.test @@ -0,0 +1,30 @@ +if (!$DIALOG_EXAMPLES_SO) { skip requires dialog_examples.so; } +if (!$HA_EXAMPLE_SO) { skip requires ha_examples.so; } +if (!$LIBDAEMON_EXAMPLE_SO) { skip requires libdaemon_examples.so; } +if (!$UDF_EXAMPLE_SO) { skip requires udf_example.so; } +if (!$EXAMPLE_KEY_MANAGEMENT_SO) { skip requires example_key_management.so; } +if (`SELECT VERSION() LIKE '%embedded%'`) { skip Disabled for embedded until MDEV-8664 is resolved; } + +flush status; +show status like '%libraries%'; +#--sorted_result +#select * from information_schema.all_plugins; +#show status like '%libraries%'; +--replace_result .dll .so +--replace_column 5 MYSQL_VERSION_ID +eval select * from information_schema.all_plugins where plugin_library='$HA_EXAMPLE_SO'; +show status like '%libraries%'; +--sorted_result +--replace_result .dll .so +eval show plugins soname '$HA_EXAMPLE_SO'; +show status like '%libraries%'; +--sorted_result +--replace_result .dll .so +show plugins soname like '%example%'; +--replace_result 8 7 +show status like '%libraries%'; +--sorted_result +--replace_result .dll .so +eval show plugins soname where library = '$HA_EXAMPLE_SO'; +select variable_value > 10 from information_schema.global_status where variable_name like '%libraries%'; + diff --git a/mysql-test/suite/plugins/t/simple_password_check.test b/mysql-test/suite/plugins/t/simple_password_check.test new file mode 100644 index 00000000..b7d631ab --- /dev/null +++ b/mysql-test/suite/plugins/t/simple_password_check.test @@ -0,0 +1,124 @@ +--source include/not_embedded.inc + +if (!$SIMPLE_PASSWORD_CHECK_SO) { + skip No SIMPLE_PASSWORD_CHECK plugin; +} + +install soname "simple_password_check"; + +--vertical_results +--replace_result .dll .so +select * from information_schema.plugins where plugin_name='simple_password_check'; + +select * from information_schema.system_variables where variable_name like 'simple_password_check%' order by 1; +--horizontal_results + +--error ER_NOT_VALID_PASSWORD +create user foo1 identified by 'pwd'; + +# Create user with no password. +--error ER_NOT_VALID_PASSWORD +create user foo1; + +--error ER_NOT_VALID_PASSWORD +grant select on *.* to foo1 identified by 'pwd'; + +--error ER_NOT_VALID_PASSWORD +grant select on *.* to `FooBar1!` identified by 'FooBar1!'; + +grant select on *.* to `BarFoo1!` identified by 'FooBar1!'; +drop user `BarFoo1!`; + +create user foo1 identified by 'aA.12345'; +grant select on *.* to foo1; +drop user foo1; + +set global simple_password_check_digits=3; +set global simple_password_check_letters_same_case=3; +set global simple_password_check_other_characters=3; +show variables like 'simple_password_check_%'; + +create user foo1 identified by '123:qwe:ASD!'; +drop user foo1; + +--error ER_NOT_VALID_PASSWORD +create user foo1 identified by '-23:qwe:ASD!'; + +--error ER_NOT_VALID_PASSWORD +create user foo1 identified by '123:4we:ASD!'; + +--error ER_NOT_VALID_PASSWORD +create user foo1 identified by '123:qwe:4SD!'; + +--error ER_NOT_VALID_PASSWORD +create user foo1 identified by '123:qwe:ASD4'; + +create user foo1 identified by '123:qwe:ASD!'; +--error ER_NOT_VALID_PASSWORD +set password for foo1 = password('qwe:-23:ASD!'); +--error ER_NOT_VALID_PASSWORD +set password for foo1 = old_password('4we:123:ASD!'); +--error ER_NOT_VALID_PASSWORD +set password for foo1 = password('qwe:123:4SD!'); +--error ER_NOT_VALID_PASSWORD +set password for foo1 = old_password('qwe:123:ASD4'); +set password for foo1 = password('qwe:123:ASD!'); + +# now, strict_password_validation +select @@strict_password_validation; + +--error ER_NOT_VALID_PASSWORD +set password for foo1 = ''; +--error ER_OPTION_PREVENTS_STATEMENT +set password for foo1 = '2222222222222222'; +--error ER_OPTION_PREVENTS_STATEMENT +set password for foo1 = '11111111111111111111111111111111111111111'; +--error ER_OPTION_PREVENTS_STATEMENT +create user foo2 identified by password '11111111111111111111111111111111111111111'; +--error ER_OPTION_PREVENTS_STATEMENT +grant select on *.* to foo2 identified by password '2222222222222222'; +--error ER_OPTION_PREVENTS_STATEMENT +create user foo2 identified with mysql_native_password using '11111111111111111111111111111111111111111'; +--error ER_OPTION_PREVENTS_STATEMENT +grant select on *.* to foo2 identified with mysql_old_password using '2222222222222222'; +--error ER_NOT_VALID_PASSWORD +create user foo2 identified with mysql_native_password using ''; +--error ER_NOT_VALID_PASSWORD +grant select on *.* to foo2 identified with mysql_old_password using ''; +--error ER_NOT_VALID_PASSWORD +grant select on *.* to foo2 identified with mysql_old_password; + +# direct updates are not protected +update mysql.global_priv set priv=json_set(priv, '$.authentication_string', 'xxx') where user='foo1'; + +set global strict_password_validation=0; + +--error ER_NOT_VALID_PASSWORD +set password for foo1 = ''; +set password for foo1 = '2222222222222222'; +set password for foo1 = '11111111111111111111111111111111111111111'; +create user foo2 identified by password '11111111111111111111111111111111111111111'; +drop user foo2; +grant select on *.* to foo2 identified by password '2222222222222222'; +drop user foo2; +create user foo2 identified with mysql_native_password using '11111111111111111111111111111111111111111'; +drop user foo2; +grant select on *.* to foo2 identified with mysql_old_password using '2222222222222222'; +drop user foo2; + +set global strict_password_validation=1; +drop user foo1; + +# +# MDEV-9940 CREATE ROLE blocked by password validation plugin +# +create role r1; +drop role r1; + +flush privileges; + +uninstall plugin simple_password_check; + +create user foo1 identified by 'pwd'; +drop user foo1; + diff --git a/mysql-test/suite/plugins/t/sql_error_log.test b/mysql-test/suite/plugins/t/sql_error_log.test new file mode 100644 index 00000000..6c83e965 --- /dev/null +++ b/mysql-test/suite/plugins/t/sql_error_log.test @@ -0,0 +1,75 @@ + +--source include/not_embedded.inc + +if (!$SQL_ERRLOG_SO) { + skip No SQL_ERROR_LOG plugin; +} + +--disable_warnings +drop procedure if exists test_error; +drop table if exists t1; +--enable_warnings + +install plugin SQL_ERROR_LOG soname 'sql_errlog'; + +show variables like 'sql_error_log%'; +set global sql_error_log_rate=1; +--error ER_NO_SUCH_TABLE +select * from t_doesnt_exist; +--error 1064 +syntax_error_query; + +delimiter |; + +CREATE PROCEDURE test_error() +BEGIN +DECLARE CONTINUE HANDLER +FOR 1146 +BEGIN +RESIGNAL SQLSTATE '40000' SET +MYSQL_ERRNO = 1000, +MESSAGE_TEXT = 'new message'; +END; +SELECT `c` FROM `temptab`; +END| + +delimiter ;| + +--error 1000 +CALL test_error(); +drop procedure test_error; + +SET SQL_MODE = STRICT_ALL_TABLES; +create table t1(id int); +--error 1366 +insert into t1 values ('aa'); +SET SQL_MODE = ''; +drop table t1; + +SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'not_exists' AND TABLE_NAME = 'not_exists'; + +# +# MDEV-6421 SQL_ERROR_LOG doesn't log comments in Events +# actually testing SP call is enough for that. + +DELIMITER |; + +CREATE procedure e1() +BEGIN + START TRANSACTION; + INSERT INTO test.non_exists VALUES (0,0,0) /* e1 */; + COMMIT; +END| + +DELIMITER ;| +--error ER_NO_SUCH_TABLE +CALL e1(); +DROP PROCEDURE e1; + +uninstall plugin SQL_ERROR_LOG; + +let $MYSQLD_DATADIR= `SELECT @@datadir`; +# replace the timestamp and the hostname with constant values +--replace_regex /[1-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [^E]*/TIME HOSTNAME / +cat_file $MYSQLD_DATADIR/sql_errors.log; + diff --git a/mysql-test/suite/plugins/t/test_sql_service.opt b/mysql-test/suite/plugins/t/test_sql_service.opt new file mode 100644 index 00000000..089ed94b --- /dev/null +++ b/mysql-test/suite/plugins/t/test_sql_service.opt @@ -0,0 +1,2 @@ +--thread_handling='one-thread-per-connection' + diff --git a/mysql-test/suite/plugins/t/test_sql_service.test b/mysql-test/suite/plugins/t/test_sql_service.test new file mode 100644 index 00000000..3384b523 --- /dev/null +++ b/mysql-test/suite/plugins/t/test_sql_service.test @@ -0,0 +1,18 @@ + +--source include/not_embedded.inc + +if (!$TEST_SQL_SERVICE_SO) { + skip No TEST_SQL_SERVICE plugin; +} + +# An unfortunate wait for check-testcase.test to complete disconnect. +let count_sessions= 1; +source include/wait_until_count_sessions.inc; + +install plugin test_sql_service soname 'test_sql_service'; + +set global test_sql_service_run_test= 1; +show status like 'test_sql_service%'; + +uninstall plugin test_sql_service; + diff --git a/mysql-test/suite/plugins/t/thread_pool_server_audit.opt b/mysql-test/suite/plugins/t/thread_pool_server_audit.opt new file mode 100644 index 00000000..30953d0c --- /dev/null +++ b/mysql-test/suite/plugins/t/thread_pool_server_audit.opt @@ -0,0 +1,2 @@ +--thread_handling=pool-of-threads + diff --git a/mysql-test/suite/plugins/t/thread_pool_server_audit.test b/mysql-test/suite/plugins/t/thread_pool_server_audit.test new file mode 100644 index 00000000..7347d8f9 --- /dev/null +++ b/mysql-test/suite/plugins/t/thread_pool_server_audit.test @@ -0,0 +1,149 @@ +--source include/not_embedded.inc +--source include/have_pool_of_threads.inc + +if (!$SERVER_AUDIT_SO) { + skip No SERVER_AUDIT plugin; +} + +install plugin server_audit soname 'server_audit'; + +show variables like 'server_audit%'; +set global server_audit_file_path=null; +set global server_audit_incl_users=null; +set global server_audit_file_path='server_audit.log'; +set global server_audit_output_type=file; +set global server_audit_logging=on; +--sleep 2 +connect (con1,localhost,root,,mysql); +connection default; +disconnect con1; +--sleep 2 +--sleep 2 +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +--error ER_ACCESS_DENIED_ERROR +connect (con1,localhost,no_such_user,,mysql); +connection default; +--sleep 2 +set global server_audit_incl_users='odin, dva, tri'; +create table t1 (id int); +set global server_audit_incl_users='odin, root, dva, tri'; +create table t2 (id int); +set global server_audit_excl_users='odin, dva, tri'; +insert into t1 values (1), (2); +select * from t1; +set global server_audit_incl_users='odin, root, dva, tri'; +insert into t2 values (1), (2); +select * from t2; +alter table t1 rename renamed_t1; +set global server_audit_events='connect,query'; +select 1, + 2, +# comment + 3; +insert into t2 values (1), (2); +select * from t2; +--disable_ps_protocol +--error ER_NO_SUCH_TABLE +select * from t_doesnt_exist; +--enable_ps_protocol +--error 1064 +syntax_error_query; +drop table renamed_t1, t2; +show variables like 'server_audit%'; +set global server_audit_mode=1; +set global server_audit_events=''; +create database sa_db; +--sleep 2 +connect (con1,localhost,root,,test); +connection con1; +--sleep 2 +--sleep 2 +create table t1 (id2 int); +insert into t1 values (1), (2); +select * from t1; +drop table t1; +use sa_db; +create table sa_t1(id int); +insert into sa_t1 values (1), (2); +drop table sa_t1; +drop database sa_db; +connection default; +disconnect con1; +--sleep 2 +--sleep 2 +create database sa_db; +use sa_db; +CREATE USER u1 IDENTIFIED BY 'pwd-123'; +GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; +SET PASSWORD FOR u1 = PASSWORD('pwd 098'); +CREATE USER u3 IDENTIFIED BY ''; +drop user u1, u2, u3; + +set global server_audit_events='query_ddl'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +(select 2); +/*! select 2*/; +/*comment*/ select 2; +drop table t1; +set global server_audit_events='query_ddl,query_dml'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +drop table t1; +set global server_audit_events='query_dml'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +(select 2); +/*! select 2*/; +/*comment*/ select 2; +drop table t1; +set global server_audit_events='query_dcl'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +CREATE USER u1 IDENTIFIED BY 'pwd-123'; +GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; +SET PASSWORD +# comment +FOR u1 = PASSWORD('pwd 098'); +--error 1064 +SET PASSWORD FOR u1=<secret>; +CREATE USER u3 IDENTIFIED BY ''; +drop user u1, u2, u3; +select 2; +(select 2); +/*! select 2*/; +/*comment*/ select 2; +drop table t1; +set global server_audit_events=''; + +set global server_audit_query_log_limit= 15; +select (1), (2), (3), (4); +select 'A', 'B', 'C', 'D'; +set global server_audit_query_log_limit= 1024; +drop database sa_db; + +set global server_audit_file_path='.'; +--replace_regex /\.[\\\/]/HOME_DIR\// +show status like 'server_audit_current_log'; +set global server_audit_file_path=''; +show status like 'server_audit_current_log'; +set global server_audit_file_path=' '; +show status like 'server_audit_current_log'; +set global server_audit_file_path='nonexisting_dir/'; +show status like 'server_audit_current_log'; +show variables like 'server_audit%'; +uninstall plugin server_audit; + +let $MYSQLD_DATADIR= `SELECT @@datadir`; +# replace the timestamp and the hostname with constant values +--replace_regex /[0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\,[^,]*\,/TIME,HOSTNAME,/ /\,[1-9][0-9]*\,/,1,/ /\,[1-9][0-9]*/,ID/ +cat_file $MYSQLD_DATADIR/server_audit.log; +remove_file $MYSQLD_DATADIR/server_audit.log; + diff --git a/mysql-test/suite/plugins/t/two_password_validations.test b/mysql-test/suite/plugins/t/two_password_validations.test new file mode 100644 index 00000000..89a5c7ae --- /dev/null +++ b/mysql-test/suite/plugins/t/two_password_validations.test @@ -0,0 +1,38 @@ +--source include/not_embedded.inc + +if (!$CRACKLIB_PASSWORD_CHECK_SO) { + skip No CRACKLIB_PASSWORD_CHECK plugin; +} + +if (!$SIMPLE_PASSWORD_CHECK_SO) { + skip No SIMPLE_PASSWORD_CHECK plugin; +} + +let $only_simple=grant select on *.* to Fff_fff1 identified by '1fff_ffF'; +let $only_crack=grant select on *.* to foobar identified by 'q-%^&*rty'; + +install soname "simple_password_check"; + +eval $only_simple; +drop user Fff_fff1; + +install soname "cracklib_password_check"; + +grant select on *.* to foobar identified by 'q$%^&*R1234ty'; +drop user foobar; + +--error ER_NOT_VALID_PASSWORD +eval $only_simple; +show warnings; + +--error ER_NOT_VALID_PASSWORD +eval $only_crack; +show warnings; + +uninstall plugin simple_password_check; + +eval $only_crack; +drop user foobar; + +uninstall plugin cracklib_password_check; + diff --git a/mysql-test/suite/plugins/t/unix_socket.test b/mysql-test/suite/plugins/t/unix_socket.test new file mode 100644 index 00000000..be2afb0c --- /dev/null +++ b/mysql-test/suite/plugins/t/unix_socket.test @@ -0,0 +1,51 @@ +--source include/have_unix_socket.inc + +--echo # +--echo # with named user +--echo # + +--let $replace=create user '$USER' +--replace_result $replace "create user 'USER'" +eval create user '$USER' identified via unix_socket; + +--write_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt +--let $replace1=$USER@localhost +--let $replace2=$USER@% +--replace_result $replace1 "USER@localhost" $replace2 "USER@%" +select user(), current_user(), database(); +EOF + +--echo # +--echo # name match = ok +--echo # +--exec $MYSQL_TEST -u $USER < $MYSQLTEST_VARDIR/tmp/peercred_test.txt + +--echo # +--echo # name does not match = failure +--echo # +--error 1 +--exec $MYSQL_TEST -u foobar < $MYSQLTEST_VARDIR/tmp/peercred_test.txt + +--let $replace=drop user '$USER' +--replace_result $replace "drop user 'USER'" +eval drop user '$USER'; + +--echo # +--echo # and now with anonymous user +--echo # +grant SELECT ON test.* TO '' identified via unix_socket; +--echo # +--echo # name match = ok +--echo # +--exec $MYSQL_TEST -u $USER < $MYSQLTEST_VARDIR/tmp/peercred_test.txt + +--echo # +--echo # name does not match = failure +--echo # +--error 1 +--exec $MYSQL_TEST -u foobar < $MYSQLTEST_VARDIR/tmp/peercred_test.txt + +# restoring mysql.user to the original state. +delete from mysql.user where user=''; +FLUSH PRIVILEGES; +--remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt |