diff options
Diffstat (limited to 'mysql-test')
155 files changed, 22887 insertions, 155 deletions
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 4ea634688fe..991c8116f1b 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -103,6 +103,8 @@ TEST_DIRS = t r include std_data std_data/parts collections \ suite/parts suite/parts/t suite/parts/r suite/parts/inc \ suite/pbxt/t suite/pbxt/r \ suite/innodb suite/innodb/t suite/innodb/r suite/innodb/include \ + suite/vcol suite/vcol/t suite/vcol/r suite/vcol/inc \ + suite/oqgraph suite/oqgraph/t suite/oqgraph/r suite/oqgraph/include \ suite/innodb_plugin suite/innodb_plugin/t suite/innodb_plugin/r suite/innodb_plugin/include \ suite/percona \ suite/engines suite/engines/funcs suite/engines/iuds suite/engines/rr_trx \ diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index b068b2e542e..7bdb0e37604 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -1117,6 +1117,16 @@ sub collect_one_test_case { } } + if ( $tinfo->{'oqgraph_test'} ) + { + if ( !$ENV{'GRAPH_ENGINE_SO'} ) + { + $tinfo->{'skip'}= 1; + $tinfo->{'comment'}= "Test requires the OQGraph storage engine"; + return $tinfo; + } + } + # Set extra config file to use if (defined $defaults_extra_file) { @@ -1176,6 +1186,7 @@ my @tags= ["include/not_embedded.inc", "not_embedded", 1], ["include/not_valgrind.inc", "not_valgrind", 1], ["include/have_example_plugin.inc", "example_plugin_test", 1], + ["include/have_oqgraph_engine.inc", "oqgraph_test", 1], ["include/have_ssl.inc", "need_ssl", 1], ); diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index eb51d385f77..678f5ff23bf 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -130,7 +130,7 @@ my $path_config_file; # The generated config file, var/my.cnf # executables will be used by the test suite. our $opt_vs_config = $ENV{'MTR_VS_CONFIG'}; -my $DEFAULT_SUITES= "main,binlog,federated,rpl,maria,parts,innodb,innodb_plugin,percona"; +my $DEFAULT_SUITES= "main,binlog,federated,rpl,maria,parts,innodb,innodb_plugin,percona,vcol,oqgraph"; my $opt_suites; our $opt_verbose= 0; # Verbose output, enable with --verbose @@ -1320,21 +1320,18 @@ sub command_line_setup { if ($opt_gdb) { - mtr_warning("Silently converting --gdb to --client-gdb in embedded mode"); $opt_client_gdb= $opt_gdb; $opt_gdb= undef; } if ($opt_ddd) { - mtr_warning("Silently converting --ddd to --client-ddd in embedded mode"); $opt_client_ddd= $opt_ddd; $opt_ddd= undef; } if ($opt_debugger) { - mtr_warning("Silently converting --debugger to --client-debugger in embedded mode"); $opt_client_debugger= $opt_debugger; $opt_debugger= undef; } @@ -5395,20 +5392,12 @@ sub gdb_arguments { if ( $type eq "client" ) { # write init file for client - mtr_tofile($gdb_init_file, - "set args $str\n" . - "break main\n"); + mtr_tofile($gdb_init_file, "set args $str\n"); } else { # write init file for mysqld - mtr_tofile($gdb_init_file, - "set args $str\n" . - "break mysql_parse\n" . - "commands 1\n" . - "disable 1\n" . - "end\n" . - "run"); + mtr_tofile($gdb_init_file, "set args $str\n"); } if ( $opt_manual_gdb ) @@ -5459,20 +5448,12 @@ sub ddd_arguments { if ( $type eq "client" ) { # write init file for client - mtr_tofile($gdb_init_file, - "set args $str\n" . - "break main\n"); + mtr_tofile($gdb_init_file, "set args $str\n"); } else { # write init file for mysqld - mtr_tofile($gdb_init_file, - "file $$exe\n" . - "set args $str\n" . - "break mysql_parse\n" . - "commands 1\n" . - "disable 1\n" . - "end"); + mtr_tofile($gdb_init_file, "file $$exe\nset args $str\n"); } if ( $opt_manual_ddd ) diff --git a/mysql-test/r/change_user.result b/mysql-test/r/change_user.result index 679e656c381..3c1e2b6f262 100644 --- a/mysql-test/r/change_user.result +++ b/mysql-test/r/change_user.result @@ -1,3 +1,36 @@ +grant select on test.* to test_nopw; +grant select on test.* to test_oldpw identified by password "09301740536db389"; +grant select on test.* to test_newpw identified by "newpw"; +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +concat('<', user(), '>') concat('<', current_user(), '>') database() +<root@localhost> <root@localhost> test +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +concat('<', user(), '>') concat('<', current_user(), '>') database() +<test_nopw@localhost> <test_nopw@%> NULL +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +concat('<', user(), '>') concat('<', current_user(), '>') database() +<test_oldpw@localhost> <test_oldpw@%> NULL +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +concat('<', user(), '>') concat('<', current_user(), '>') database() +<test_newpw@localhost> <test_newpw@%> NULL +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +concat('<', user(), '>') concat('<', current_user(), '>') database() +<root@localhost> <root@localhost> NULL +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +concat('<', user(), '>') concat('<', current_user(), '>') database() +<test_nopw@localhost> <test_nopw@%> test +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +concat('<', user(), '>') concat('<', current_user(), '>') database() +<test_oldpw@localhost> <test_oldpw@%> test +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +concat('<', user(), '>') concat('<', current_user(), '>') database() +<test_newpw@localhost> <test_newpw@%> test +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +concat('<', user(), '>') concat('<', current_user(), '>') database() +<root@localhost> <root@localhost> test +drop user test_nopw; +drop user test_oldpw; +drop user test_newpw; Bug#20023 SELECT @@session.sql_big_selects; @@session.sql_big_selects diff --git a/mysql-test/r/connect.result b/mysql-test/r/connect.result index fbe562c283c..690a6fb3bc3 100644 --- a/mysql-test/r/connect.result +++ b/mysql-test/r/connect.result @@ -225,3 +225,17 @@ Connection on extra port 2 ok # ------------------------------------------------------------------ # -- End of 5.1 tests # ------------------------------------------------------------------ +CREATE USER mysqltest_up1 IDENTIFIED VIA mysql_native_password using '*E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB'; +CREATE USER mysqltest_up2 IDENTIFIED VIA mysql_old_password using '09301740536db389'; +connect(localhost,mysqltest_up1,foo,test,MASTER_PORT,MASTER_SOCKET); +ERROR 28000: Access denied for user 'mysqltest_up1'@'localhost' (using password: YES) +select user(), current_user(); +user() current_user() +mysqltest_up1@localhost mysqltest_up1@% +connect(localhost,mysqltest_up2,newpw,test,MASTER_PORT,MASTER_SOCKET); +ERROR 28000: Access denied for user 'mysqltest_up2'@'localhost' (using password: YES) +select user(), current_user(); +user() current_user() +mysqltest_up2@localhost mysqltest_up2@% +DROP USER mysqltest_up1@'%'; +DROP USER mysqltest_up2@'%'; diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result index 50bfa97c59f..da53790acd6 100644 --- a/mysql-test/r/events_bugs.result +++ b/mysql-test/r/events_bugs.result @@ -729,9 +729,8 @@ set @@sql_mode= pow(2,32)-1; create event e1 on schedule every 1 day do select 1; select @@sql_mode; @@sql_mode -REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,?,ONLY_FULL_GROUP_BY,NO_UNSIGNED_SUBTRACTION,NO_DIR_IN_CREATE,POSTGRESQL,ORACLE,MSSQL,DB2,MAXDB,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,MYSQL323,MYSQL40,ANSI,NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,HIGH_NOT_PRECEDENCE,NO_ENGINE_SUBSTITUTION,PAD_CHAR_TO_FULL_LENGTH +REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,IGNORE_BAD_TABLE_OPTIONS,ONLY_FULL_GROUP_BY,NO_UNSIGNED_SUBTRACTION,NO_DIR_IN_CREATE,POSTGRESQL,ORACLE,MSSQL,DB2,MAXDB,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,MYSQL323,MYSQL40,ANSI,NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,HIGH_NOT_PRECEDENCE,NO_ENGINE_SUBSTITUTION,PAD_CHAR_TO_FULL_LENGTH set @@sql_mode= @old_mode; -select replace(@full_mode, '?', 'NOT_USED') into @full_mode; select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode; select name from mysql.event where name = 'p' and sql_mode = @full_mode; name diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index b8f13723eb8..f410b26a1fe 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -13,8 +13,8 @@ GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3 GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost' grant delete on mysqltest.* to mysqltest_1@localhost; select * from mysql.user where user="mysqltest_1"; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED EDH-RSA-DES-CBC3-SHA 0 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED EDH-RSA-DES-CBC3-SHA 0 0 0 0 show grants for mysqltest_1@localhost; Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA' @@ -44,15 +44,15 @@ delete from mysql.user where user='mysqltest_1'; flush privileges; grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 10; select * from mysql.user where user="mysqltest_1"; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 10 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 10 0 0 0 show grants for mysqltest_1@localhost; Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_QUERIES_PER_HOUR 10 grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 20 max_connections_per_hour 30; select * from mysql.user where user="mysqltest_1"; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 10 20 30 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 10 20 30 0 show grants for mysqltest_1@localhost; Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_QUERIES_PER_HOUR 10 MAX_UPDATES_PER_HOUR 20 MAX_CONNECTIONS_PER_HOUR 30 @@ -164,6 +164,7 @@ Warnings: Warning 1364 Field 'ssl_cipher' doesn't have a default value Warning 1364 Field 'x509_issuer' doesn't have a default value Warning 1364 Field 'x509_subject' doesn't have a default value +Warning 1364 Field 'auth_string' doesn't have a default value insert into mysql.db (host, db, user, select_priv) values ('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y'); alter table mysql.db order by db asc; diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index 12269f0cb1c..ee3fe1540b9 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -287,6 +287,7 @@ Warnings: Warning 1364 Field 'ssl_cipher' doesn't have a default value Warning 1364 Field 'x509_issuer' doesn't have a default value Warning 1364 Field 'x509_subject' doesn't have a default value +Warning 1364 Field 'auth_string' doesn't have a default value create user mysqltest_A@'%'; rename user mysqltest_B@'%' to mysqltest_C@'%'; drop user mysqltest_C@'%'; @@ -354,6 +355,7 @@ Warnings: Warning 1364 Field 'ssl_cipher' doesn't have a default value Warning 1364 Field 'x509_issuer' doesn't have a default value Warning 1364 Field 'x509_subject' doesn't have a default value +Warning 1364 Field 'auth_string' doesn't have a default value INSERT INTO mysql.db (host, db, user, select_priv) VALUES ('%','TESTDB','mysqltest_1','Y'); FLUSH PRIVILEGES; diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index f58e92b186f..ee8b91631bb 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -45,6 +45,7 @@ NOT (table_schema = 'INFORMATION_SCHEMA' AND table_name LIKE 'PBXT_%'); select * from v1 ORDER BY c COLLATE utf8_bin; c CHARACTER_SETS +CLIENT_STATISTICS COLLATIONS COLLATION_CHARACTER_SET_APPLICABILITY COLUMNS @@ -54,6 +55,7 @@ EVENTS FILES GLOBAL_STATUS GLOBAL_VARIABLES +INDEX_STATISTICS INNODB_BUFFER_POOL_PAGES INNODB_BUFFER_POOL_PAGES_BLOB INNODB_BUFFER_POOL_PAGES_INDEX @@ -69,6 +71,7 @@ INNODB_SYS_INDEXES INNODB_SYS_TABLES INNODB_TABLE_STATS INNODB_TRX +KEY_CACHES KEY_COLUMN_USAGE PARTITIONS PLUGINS @@ -84,8 +87,10 @@ STATISTICS TABLES TABLE_CONSTRAINTS TABLE_PRIVILEGES +TABLE_STATISTICS TRIGGERS USER_PRIVILEGES +USER_STATISTICS VIEWS XTRADB_ADMIN_COMMAND XTRADB_ENHANCEMENTS @@ -124,6 +129,7 @@ c table_name TABLES TABLES TABLE_CONSTRAINTS TABLE_CONSTRAINTS TABLE_PRIVILEGES TABLE_PRIVILEGES +TABLE_STATISTICS TABLE_STATISTICS TRIGGERS TRIGGERS tables_priv tables_priv time_zone time_zone @@ -143,6 +149,7 @@ c table_name TABLES TABLES TABLE_CONSTRAINTS TABLE_CONSTRAINTS TABLE_PRIVILEGES TABLE_PRIVILEGES +TABLE_STATISTICS TABLE_STATISTICS TRIGGERS TRIGGERS tables_priv tables_priv time_zone time_zone @@ -162,6 +169,7 @@ c table_name TABLES TABLES TABLE_CONSTRAINTS TABLE_CONSTRAINTS TABLE_PRIVILEGES TABLE_PRIVILEGES +TABLE_STATISTICS TABLE_STATISTICS TRIGGERS TRIGGERS tables_priv tables_priv time_zone time_zone @@ -610,7 +618,7 @@ proc body longblob proc definer char(77) proc created timestamp proc modified timestamp -proc sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') +proc sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') proc comment char(64) proc character_set_client char(32) proc collation_connection char(32) @@ -643,12 +651,13 @@ from information_schema.tables where table_schema='information_schema' limit 2; TABLE_NAME TABLE_TYPE ENGINE CHARACTER_SETS SYSTEM VIEW MEMORY -COLLATIONS SYSTEM VIEW MEMORY +CLIENT_STATISTICS SYSTEM VIEW MEMORY show tables from information_schema like "T%"; Tables_in_information_schema (T%) TABLES TABLE_CONSTRAINTS TABLE_PRIVILEGES +TABLE_STATISTICS TRIGGERS create database information_schema; ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' @@ -658,6 +667,7 @@ Tables_in_information_schema (T%) Table_type TABLES SYSTEM VIEW TABLE_CONSTRAINTS SYSTEM VIEW TABLE_PRIVILEGES SYSTEM VIEW +TABLE_STATISTICS SYSTEM VIEW TRIGGERS SYSTEM VIEW create table t1(a int); ERROR 42S02: Unknown table 't1' in information_schema @@ -670,6 +680,7 @@ Tables_in_information_schema (T%) TABLES TABLE_CONSTRAINTS TABLE_PRIVILEGES +TABLE_STATISTICS TRIGGERS select table_name from tables where table_name='user'; table_name @@ -859,6 +870,7 @@ TABLE_NAME COLUMN_NAME PRIVILEGES COLUMNS TABLE_NAME select COLUMN_PRIVILEGES TABLE_NAME select FILES TABLE_NAME select +INDEX_STATISTICS TABLE_NAME select INNODB_BUFFER_POOL_PAGES_INDEX table_name select INNODB_INDEX_STATS table_name select INNODB_TABLE_STATS table_name select @@ -869,6 +881,7 @@ STATISTICS TABLE_NAME select TABLES TABLE_NAME select TABLE_CONSTRAINTS TABLE_NAME select TABLE_PRIVILEGES TABLE_NAME select +TABLE_STATISTICS TABLE_NAME select VIEWS TABLE_NAME select delete from mysql.user where user='mysqltest_4'; delete from mysql.db where user='mysqltest_4'; diff --git a/mysql-test/r/information_schema_all_engines.result b/mysql-test/r/information_schema_all_engines.result index a2f34fad221..dfe7570266c 100644 --- a/mysql-test/r/information_schema_all_engines.result +++ b/mysql-test/r/information_schema_all_engines.result @@ -2,6 +2,7 @@ use INFORMATION_SCHEMA; show tables; Tables_in_information_schema CHARACTER_SETS +CLIENT_STATISTICS COLLATIONS COLLATION_CHARACTER_SET_APPLICABILITY COLUMNS @@ -11,6 +12,8 @@ EVENTS FILES GLOBAL_STATUS GLOBAL_VARIABLES +INDEX_STATISTICS +KEY_CACHES KEY_COLUMN_USAGE PARTITIONS PLUGINS @@ -26,8 +29,10 @@ STATISTICS TABLES TABLE_CONSTRAINTS TABLE_PRIVILEGES +TABLE_STATISTICS TRIGGERS USER_PRIVILEGES +USER_STATISTICS VIEWS INNODB_BUFFER_POOL_PAGES PBXT_STATISTICS @@ -63,6 +68,7 @@ c2.column_name LIKE '%SCHEMA%' ); table_name column_name CHARACTER_SETS CHARACTER_SET_NAME +CLIENT_STATISTICS CLIENT COLLATIONS COLLATION_NAME COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME COLUMNS TABLE_SCHEMA @@ -72,6 +78,8 @@ EVENTS EVENT_SCHEMA FILES TABLE_SCHEMA GLOBAL_STATUS VARIABLE_NAME GLOBAL_VARIABLES VARIABLE_NAME +INDEX_STATISTICS TABLE_SCHEMA +KEY_CACHES KEY_CACHE_NAME KEY_COLUMN_USAGE CONSTRAINT_SCHEMA PARTITIONS TABLE_SCHEMA PLUGINS PLUGIN_NAME @@ -87,8 +95,10 @@ STATISTICS TABLE_SCHEMA TABLES TABLE_SCHEMA TABLE_CONSTRAINTS CONSTRAINT_SCHEMA TABLE_PRIVILEGES TABLE_SCHEMA +TABLE_STATISTICS TABLE_SCHEMA TRIGGERS TRIGGER_SCHEMA USER_PRIVILEGES GRANTEE +USER_STATISTICS USER VIEWS TABLE_SCHEMA INNODB_BUFFER_POOL_PAGES page_type PBXT_STATISTICS ID @@ -124,6 +134,7 @@ c2.column_name LIKE '%SCHEMA%' ); table_name column_name CHARACTER_SETS CHARACTER_SET_NAME +CLIENT_STATISTICS CLIENT COLLATIONS COLLATION_NAME COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME COLUMNS TABLE_SCHEMA @@ -133,6 +144,8 @@ EVENTS EVENT_SCHEMA FILES TABLE_SCHEMA GLOBAL_STATUS VARIABLE_NAME GLOBAL_VARIABLES VARIABLE_NAME +INDEX_STATISTICS TABLE_SCHEMA +KEY_CACHES KEY_CACHE_NAME KEY_COLUMN_USAGE CONSTRAINT_SCHEMA PARTITIONS TABLE_SCHEMA PLUGINS PLUGIN_NAME @@ -148,8 +161,10 @@ STATISTICS TABLE_SCHEMA TABLES TABLE_SCHEMA TABLE_CONSTRAINTS CONSTRAINT_SCHEMA TABLE_PRIVILEGES TABLE_SCHEMA +TABLE_STATISTICS TABLE_SCHEMA TRIGGERS TRIGGER_SCHEMA USER_PRIVILEGES GRANTEE +USER_STATISTICS USER VIEWS TABLE_SCHEMA INNODB_BUFFER_POOL_PAGES page_type PBXT_STATISTICS ID @@ -191,6 +206,7 @@ group by c2.column_type order by num limit 1) group by t.table_name order by num1, t.table_name; table_name group_concat(t.table_schema, '.', t.table_name) num1 CHARACTER_SETS information_schema.CHARACTER_SETS 1 +CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1 COLLATIONS information_schema.COLLATIONS 1 COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1 COLUMNS information_schema.COLUMNS 1 @@ -200,6 +216,7 @@ EVENTS information_schema.EVENTS 1 FILES information_schema.FILES 1 GLOBAL_STATUS information_schema.GLOBAL_STATUS 1 GLOBAL_VARIABLES information_schema.GLOBAL_VARIABLES 1 +INDEX_STATISTICS information_schema.INDEX_STATISTICS 1 INNODB_BUFFER_POOL_PAGES information_schema.INNODB_BUFFER_POOL_PAGES 1 INNODB_BUFFER_POOL_PAGES_BLOB information_schema.INNODB_BUFFER_POOL_PAGES_BLOB 1 INNODB_BUFFER_POOL_PAGES_INDEX information_schema.INNODB_BUFFER_POOL_PAGES_INDEX 1 @@ -215,6 +232,7 @@ INNODB_SYS_INDEXES information_schema.INNODB_SYS_INDEXES 1 INNODB_SYS_TABLES information_schema.INNODB_SYS_TABLES 1 INNODB_TABLE_STATS information_schema.INNODB_TABLE_STATS 1 INNODB_TRX information_schema.INNODB_TRX 1 +KEY_CACHES information_schema.KEY_CACHES 1 KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1 PARTITIONS information_schema.PARTITIONS 1 PBXT_STATISTICS information_schema.PBXT_STATISTICS 1 @@ -231,8 +249,10 @@ STATISTICS information_schema.STATISTICS 1 TABLES information_schema.TABLES 1 TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1 TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1 +TABLE_STATISTICS information_schema.TABLE_STATISTICS 1 TRIGGERS information_schema.TRIGGERS 1 USER_PRIVILEGES information_schema.USER_PRIVILEGES 1 +USER_STATISTICS information_schema.USER_STATISTICS 1 VIEWS information_schema.VIEWS 1 XTRADB_ENHANCEMENTS information_schema.XTRADB_ENHANCEMENTS 1 Database: information_schema @@ -240,6 +260,7 @@ Database: information_schema | Tables | +---------------------------------------+ | CHARACTER_SETS | +| CLIENT_STATISTICS | | COLLATIONS | | COLLATION_CHARACTER_SET_APPLICABILITY | | COLUMNS | @@ -249,6 +270,8 @@ Database: information_schema | FILES | | GLOBAL_STATUS | | GLOBAL_VARIABLES | +| INDEX_STATISTICS | +| KEY_CACHES | | KEY_COLUMN_USAGE | | PARTITIONS | | PLUGINS | @@ -264,8 +287,10 @@ Database: information_schema | TABLES | | TABLE_CONSTRAINTS | | TABLE_PRIVILEGES | +| TABLE_STATISTICS | | TRIGGERS | | USER_PRIVILEGES | +| USER_STATISTICS | | VIEWS | | INNODB_BUFFER_POOL_PAGES | | PBXT_STATISTICS | @@ -291,6 +316,7 @@ Database: INFORMATION_SCHEMA | Tables | +---------------------------------------+ | CHARACTER_SETS | +| CLIENT_STATISTICS | | COLLATIONS | | COLLATION_CHARACTER_SET_APPLICABILITY | | COLUMNS | @@ -300,6 +326,8 @@ Database: INFORMATION_SCHEMA | FILES | | GLOBAL_STATUS | | GLOBAL_VARIABLES | +| INDEX_STATISTICS | +| KEY_CACHES | | KEY_COLUMN_USAGE | | PARTITIONS | | PLUGINS | @@ -315,8 +343,10 @@ Database: INFORMATION_SCHEMA | TABLES | | TABLE_CONSTRAINTS | | TABLE_PRIVILEGES | +| TABLE_STATISTICS | | TRIGGERS | | USER_PRIVILEGES | +| USER_STATISTICS | | VIEWS | | INNODB_BUFFER_POOL_PAGES | | PBXT_STATISTICS | @@ -345,5 +375,5 @@ Wildcard: inf_rmation_schema +--------------------+ SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA; table_schema count(*) -information_schema 46 +information_schema 51 mysql 22 diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result index a6f81d7688b..b5be0137520 100644 --- a/mysql-test/r/information_schema_db.result +++ b/mysql-test/r/information_schema_db.result @@ -7,6 +7,7 @@ Tables_in_information_schema (T%) TABLES TABLE_CONSTRAINTS TABLE_PRIVILEGES +TABLE_STATISTICS TRIGGERS create database `inf%`; create database mbase; diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result index 08d8059f61b..8ebc8ff1fa0 100644 --- a/mysql-test/r/key_cache.result +++ b/mysql-test/r/key_cache.result @@ -1,5 +1,7 @@ drop table if exists t1, t2, t3; -SET @save_key_buffer=@@key_buffer_size; +SET @save_key_buffer_size=@@key_buffer_size; +SET @save_key_cache_block_size=@@key_cache_block_size; +SET @save_key_cache_segments=@@key_cache_segments; SELECT @@key_buffer_size, @@small.key_buffer_size; @@key_buffer_size @@small.key_buffer_size 2097152 131072 @@ -37,7 +39,7 @@ SELECT @@small.key_buffer_size; SELECT @@medium.key_buffer_size; @@medium.key_buffer_size 0 -SET @@global.key_buffer_size=@save_key_buffer; +SET @@global.key_buffer_size=@save_key_buffer_size; SELECT @@default.key_buffer_size; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'default.key_buffer_size' at line 1 SELECT @@skr.storage_engine="test"; @@ -366,3 +368,432 @@ Variable_name Value key_cache_block_size 1536 SET GLOBAL key_cache_block_size= @bug28478_key_cache_block_size; DROP TABLE t1; +set global key_buffer_size=@save_key_buffer_size; +set global key_cache_block_size=@save_key_cache_block_size; +select @@key_buffer_size; +@@key_buffer_size +2097152 +select @@key_cache_block_size; +@@key_cache_block_size +1024 +select @@key_cache_segments; +@@key_cache_segments +0 +create table t1 ( +p int not null auto_increment primary key, +a char(10)); +create table t2 ( +p int not null auto_increment primary key, +i int, a char(10), key k1(i), key k2(a)); +select @@key_cache_segments; +@@key_cache_segments +0 +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default NULL NULL 2097152 1024 0 # 0 0 0 0 0 +small NULL NULL 1048576 1024 1 # 0 1 0 2 1 +insert into t1 values (1, 'qqqq'), (2, 'yyyy'); +insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'), +(3, 1, 'yyyy'), (4, 3, 'zzzz'); +select * from t1; +p a +1 qqqq +2 yyyy +select * from t2; +p i a +1 1 qqqq +2 1 pppp +3 1 yyyy +4 3 zzzz +update t1 set p=3 where p=1; +update t2 set i=2 where i=1; +show status like 'key_%'; +Variable_name Value +Key_blocks_not_flushed 0 +Key_blocks_unused KEY_BLOCKS_UNUSED +Key_blocks_used 4 +Key_read_requests 22 +Key_reads 0 +Key_write_requests 26 +Key_writes 6 +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default NULL NULL 2097152 1024 4 # 0 22 0 26 6 +small NULL NULL 1048576 1024 1 # 0 1 0 2 1 +delete from t2 where a='zzzz'; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default NULL NULL 2097152 1024 4 # 0 29 0 32 9 +small NULL NULL 1048576 1024 1 # 0 1 0 2 1 +delete from t1; +delete from t2; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default NULL NULL 2097152 1024 4 # 0 29 0 32 9 +small NULL NULL 1048576 1024 1 # 0 1 0 2 1 +set global key_cache_segments=2; +select @@key_cache_segments; +@@key_cache_segments +2 +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 2097152 1024 0 # 0 0 0 0 0 +small NULL NULL 1048576 1024 1 # 0 1 0 2 1 +insert into t1 values (1, 'qqqq'), (2, 'yyyy'); +insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'), +(3, 1, 'yyyy'), (4, 3, 'zzzz'); +select * from t1; +p a +1 qqqq +2 yyyy +select * from t2; +p i a +1 1 qqqq +2 1 pppp +3 1 yyyy +4 3 zzzz +update t1 set p=3 where p=1; +update t2 set i=2 where i=1; +show status like 'key_%'; +Variable_name Value +Key_blocks_not_flushed 0 +Key_blocks_unused KEY_BLOCKS_UNUSED +Key_blocks_used 4 +Key_read_requests 22 +Key_reads 0 +Key_write_requests 26 +Key_writes 6 +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 2097152 1024 4 # 0 22 0 26 6 +small NULL NULL 1048576 1024 1 # 0 1 0 2 1 +delete from t1; +delete from t2; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 2097152 1024 4 # 0 22 0 26 6 +small NULL NULL 1048576 1024 1 # 0 1 0 2 1 +set global key_cache_segments=1; +select @@key_cache_segments; +@@key_cache_segments +1 +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 1 NULL 2097152 1024 0 # 0 0 0 0 0 +small NULL NULL 1048576 1024 1 # 0 1 0 2 1 +insert into t1 values (1, 'qqqq'), (2, 'yyyy'); +insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'), +(3, 1, 'yyyy'), (4, 3, 'zzzz'); +select * from t1; +p a +1 qqqq +2 yyyy +select * from t2; +p i a +1 1 qqqq +2 1 pppp +3 1 yyyy +4 3 zzzz +update t1 set p=3 where p=1; +update t2 set i=2 where i=1; +show status like 'key_%'; +Variable_name Value +Key_blocks_not_flushed 0 +Key_blocks_unused KEY_BLOCKS_UNUSED +Key_blocks_used 4 +Key_read_requests 22 +Key_reads 0 +Key_write_requests 26 +Key_writes 6 +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 1 NULL 2097152 1024 4 # 0 22 0 26 6 +small NULL NULL 1048576 1024 1 # 0 1 0 2 1 +delete from t1; +delete from t2; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 1 NULL 2097152 1024 4 # 0 22 0 26 6 +small NULL NULL 1048576 1024 1 # 0 1 0 2 1 +flush tables; +flush status; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 1 NULL 2097152 1024 4 # 0 0 0 0 0 +small NULL NULL 1048576 1024 1 # 0 0 0 0 0 +set global key_buffer_size=32*1024; +select @@key_buffer_size; +@@key_buffer_size +32768 +set global key_cache_segments=2; +select @@key_cache_segments; +@@key_cache_segments +2 +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 0 # 0 0 0 0 0 +small NULL NULL 1048576 1024 1 # 0 0 0 0 0 +insert into t1 values (1, 'qqqq'), (2, 'yyyy'); +insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'), +(3, 1, 'yyyy'), (4, 3, 'zzzz'); +select * from t1; +p a +1 qqqq +2 yyyy +select * from t2; +p i a +1 1 qqqq +2 1 pppp +3 1 yyyy +4 3 zzzz +update t1 set p=3 where p=1; +update t2 set i=2 where i=1; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 4 # 0 22 0 26 6 +small NULL NULL 1048576 1024 1 # 0 0 0 0 0 +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 6733 # 3684 103 +small NULL NULL 1048576 1024 # # 0 0 # 0 0 +select * from t1 where p between 1010 and 1020 ; +p a +select * from t2 where p between 1010 and 1020 ; +p i a +1010 2 pppp +1011 2 yyyy +1012 3 zzzz +1013 2 qqqq +1014 2 pppp +1015 2 yyyy +1016 3 zzzz +1017 2 qqqq +1018 2 pppp +1019 2 yyyy +1020 3 zzzz +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 6750 # 3684 103 +small NULL NULL 1048576 1024 # # 0 0 # 0 0 +flush tables; +flush status; +update t1 set a='zzzz' where a='qqqq'; +update t2 set i=1 where i=2; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3076 18 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +set global keycache1.key_buffer_size=256*1024; +select @@keycache1.key_buffer_size; +@@keycache1.key_buffer_size +262144 +set global keycache1.key_cache_segments=7; +select @@keycache1.key_cache_segments; +@@keycache1.key_cache_segments +7 +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3076 18 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache1 7 NULL 262143 2048 # # 0 0 0 0 0 +select * from information_schema.key_caches where key_cache_name like "key%" + and segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +keycache1 7 NULL 262143 2048 0 # 0 0 0 0 0 +cache index t1 key (`primary`) in keycache1; +Table Op Msg_type Msg_text +test.t1 assign_to_keycache status OK +explain select p from t1 where p between 1010 and 1020; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where; Using index +select p from t1 where p between 1010 and 1020; +p +explain select i from t2 where p between 1010 and 1020; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 28 Using where +select i from t2 where p between 1010 and 1020; +i +1 +1 +3 +1 +1 +1 +3 +1 +1 +1 +3 +explain select count(*) from t1, t2 where t1.p = t2.i; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 index k1 k1 5 NULL 1024 Using index +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.i 1 Using index +select count(*) from t1, t2 where t1.p = t2.i; +count(*) +256 +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3172 24 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache1 7 NULL 262143 2048 # # 0 14 3 0 0 +select * from information_schema.key_caches where key_cache_name like "key%" + and segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +keycache1 7 NULL 262143 2048 3 # 0 14 3 0 0 +cache index t2 in keycache1; +Table Op Msg_type Msg_text +test.t2 assign_to_keycache status OK +update t2 set p=p+3000, i=2 where a='qqqq'; +select * from information_schema.key_caches where key_cache_name like "key%" + and segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +keycache1 7 NULL 262143 2048 25 # 0 2082 25 1071 19 +set global keycache2.key_buffer_size=1024*1024; +cache index t2 in keycache2; +Table Op Msg_type Msg_text +test.t2 assign_to_keycache status OK +insert into t2 values (2000, 3, 'yyyy'); +select * from information_schema.key_caches where key_cache_name like "keycache2" + and segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +keycache2 NULL NULL 1048576 1024 6 # 0 6 6 3 3 +select * from information_schema.key_caches where key_cache_name like "key%" +and segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +keycache1 7 NULL 262143 2048 25 # 0 2082 25 1071 19 +keycache2 NULL NULL 1048576 1024 6 # 0 6 6 3 3 +cache index t2 in keycache1; +Table Op Msg_type Msg_text +test.t2 assign_to_keycache status OK +update t2 set p=p+5000 where a='zzzz'; +select * from t2 where p between 1010 and 1020; +p i a +1010 1 pppp +1011 1 yyyy +1014 1 pppp +1015 1 yyyy +1018 1 pppp +1019 1 yyyy +explain select p from t2 where p between 1010 and 1020; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 7 Using where; Using index +select p from t2 where p between 1010 and 1020; +p +1010 +1011 +1014 +1015 +1018 +1019 +explain select i from t2 where a='yyyy' and i=3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref k1,k2 k1 5 const 188 Using where +select i from t2 where a='yyyy' and i=3; +i +3 +explain select a from t2 where a='yyyy' and i=3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref k1,k2 k1 5 const 188 Using where +select a from t2 where a='yyyy' and i=3 ; +a +yyyy +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3172 24 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache1 7 NULL 262143 2048 # # 0 3201 43 1594 30 +keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 +set global keycache1.key_cache_block_size=2*1024; +insert into t2 values (7000, 3, 'yyyy'); +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3172 24 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache1 7 NULL 262143 2048 # # 0 6 6 3 3 +keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 +set global keycache1.key_cache_block_size=8*1024; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3172 24 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache1 3 NULL 262143 8192 # # 0 0 0 0 0 +keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 +insert into t2 values (8000, 3, 'yyyy'); +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3172 24 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache1 3 NULL 262143 8192 # # 0 6 5 3 3 +keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 +set global keycache1.key_buffer_size=64*1024; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3172 24 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 +set global keycache1.key_cache_block_size=2*1024; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3172 24 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache1 3 NULL 65535 2048 # # 0 0 0 0 0 +keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 +set global keycache1.key_cache_block_size=8*1024; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3172 24 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 +set global keycache1.key_buffer_size=0; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3172 24 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 +set global keycache1.key_cache_block_size=8*1024; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3172 24 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 +set global keycache1.key_buffer_size=0; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3172 24 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 +set global keycache1.key_buffer_size=128*1024; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3172 24 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache1 1 NULL 131072 8192 # # 0 0 0 0 0 +keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 +set global keycache1.key_cache_block_size=1024; +select * from information_schema.key_caches where segment_number is null; +KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES +default 2 NULL 32768 1024 # # 0 3172 24 1552 18 +small NULL NULL 1048576 1024 # # 0 0 0 0 0 +keycache1 7 NULL 131068 1024 # # 0 0 0 0 0 +keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 +drop table t1,t2; +set global keycache1.key_buffer_size=0; +set global keycache2.key_buffer_size=0; +set global key_buffer_size=@save_key_buffer_size; +set global key_cache_segments=@save_key_cache_segments; diff --git a/mysql-test/r/log_slow.result b/mysql-test/r/log_slow.result index 57d12a64f5a..b6341109556 100644 --- a/mysql-test/r/log_slow.result +++ b/mysql-test/r/log_slow.result @@ -56,5 +56,6 @@ last_insert_id int(11) NO NULL insert_id int(11) NO NULL server_id int(10) unsigned NO NULL sql_text mediumtext NO NULL +flush slow query logs; set @@log_slow_filter=default; set @@log_slow_verbosity=default; diff --git a/mysql-test/r/partition_example.result b/mysql-test/r/partition_example.result new file mode 100644 index 00000000000..2129eea0818 --- /dev/null +++ b/mysql-test/r/partition_example.result @@ -0,0 +1,31 @@ +install plugin example soname 'ha_example.so'; +create table t1 (a int not null) +engine=example +partition by list (a) +(partition p0 values in (1), partition p1 values in (2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL +) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (1) ENGINE = EXAMPLE, + PARTITION p1 VALUES IN (2) ENGINE = EXAMPLE) */ +drop table t1; +create table t1 (a int not null) +engine=example ull=12340 +partition by list (a) +(partition p0 values in (1), partition p1 values in (2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL +) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `ull`=12340 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (1) ENGINE = EXAMPLE, + PARTITION p1 VALUES IN (2) ENGINE = EXAMPLE) */ +drop table t1; +select 1; +1 +1 +uninstall plugin example; diff --git a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result index 782d2a5a9a4..8169bd458e8 100644 --- a/mysql-test/r/plugin.result +++ b/mysql-test/r/plugin.result @@ -12,6 +12,15 @@ CREATE TABLE t1(a int) ENGINE=EXAMPLE; SELECT * FROM t1; a DROP TABLE t1; +set global example_ulong_var=500; +set global example_enum_var= e1; +show status like 'example%'; +Variable_name Value +example_func_example enum_var is 0, ulong_var is 500, really +show variables like 'example%'; +Variable_name Value +example_enum_var e1 +example_ulong_var 500 UNINSTALL PLUGIN example; UNINSTALL PLUGIN EXAMPLE; ERROR 42000: PLUGIN EXAMPLE does not exist @@ -53,4 +62,64 @@ select @@global.example_ulong_var; set session sql_mode=@old_sql_mode; set session old=bla; ERROR HY000: Variable 'old' is a read only variable +#legal values +CREATE TABLE t1 ( a int complex='c,f,f,f' ) ENGINE=example ULL=10000 STR='dskj' one_or_two='one' YESNO=0; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `complex`='c,f,f,f' +) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `ULL`=10000 `STR`='dskj' `one_or_two`='one' `YESNO`=0 +drop table t1; +SET @OLD_SQL_MODE=@@SQL_MODE; +SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS'; +#illegal value fixed +CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS; +Warnings: +Warning 1652 Incorrect value '10000000000000000000' for option 'ULL' +Warning 1652 Incorrect value 'ttt' for option 'one_or_two' +Warning 1652 Incorrect value 'SSS' for option 'YESNO' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `ULL`=10000000000000000000 `one_or_two`='ttt' `YESNO`=SSS +#alter table +alter table t1 ULL=10000000; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `one_or_two`='ttt' `YESNO`=SSS `ULL`=10000000 +alter table t1 change a a int complex='c,c,c'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `complex`='c,c,c' +) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `one_or_two`='ttt' `YESNO`=SSS `ULL`=10000000 +drop table t1; +#illegal value error +SET SQL_MODE=''; +CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS; +ERROR HY000: Incorrect value '10000000000000000000' for option 'ULL' +CREATE TABLE t1 (a int) ENGINE=example ULL=10.00; +ERROR 42000: Only integers allowed as number here near '10.00' at line 1 +CREATE TABLE t1 (a int) ENGINE=example ULL=1e2; +ERROR 42000: Only integers allowed as number here near '1e2' at line 1 +CREATE TABLE t1 (a int) ENGINE=example ULL=0x1234; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `ULL`=4660 +ALTER TABLE t1 ULL=DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 +DROP TABLE t1; +SET @@SQL_MODE=@OLD_SQL_MODE; +select 1; +1 +1 UNINSTALL PLUGIN example; diff --git a/mysql-test/r/plugin_maturity.result b/mysql-test/r/plugin_maturity.result new file mode 100644 index 00000000000..97147459f6f --- /dev/null +++ b/mysql-test/r/plugin_maturity.result @@ -0,0 +1,2 @@ +INSTALL PLUGIN example SONAME 'ha_example.so'; +ERROR HY000: Can't open shared library 'ha_example.so' (errno: 0 Loading of experimental plugins is prohibited by --plugin-maturity=stable) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index f21f1d83acd..c802fc0f209 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1194,13 +1194,13 @@ SET @aux= "SELECT COUNT(*) prepare my_stmt from @aux; execute my_stmt; COUNT(*) -39 +41 execute my_stmt; COUNT(*) -39 +41 execute my_stmt; COUNT(*) -39 +41 deallocate prepare my_stmt; drop procedure if exists p1| drop table if exists t1| diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result new file mode 100644 index 00000000000..c1aa5704f56 --- /dev/null +++ b/mysql-test/r/select_pkeycache.result @@ -0,0 +1,4799 @@ +drop table if exists t1,t2,t3,t4,t11; +drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; +drop view if exists v1; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +); +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range fld3 fld3 30 NULL 2 Using where; Using index +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range fld1 fld1 4 NULL 2 Using where; Using index +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range fld1 fld1 4 NULL 4 Using where; Using index +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +218401 faithful +018007 fanatic +228311 fated +018017 featherweight +218022 feed +088303 feminine +058004 Fenton +038017 fetched +018054 fetters +208101 fiftieth +238007 filial +013606 fingerings +218008 finishers +038205 firearm +188505 fitting +202301 Fitzpatrick +238008 fixedly +012001 flanking +018103 flint +018104 flopping +188007 flurried +013602 foldout +226205 foothill +232102 forgivably +228306 forthcoming +186002 freakish +208113 freest +231315 freezes +036002 funereal +226209 furnishings +198006 furthermore +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +37 +36 +50 +58 +29 +40 +53 +65 +41 +34 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%"; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +create temporary table tmp engine = myisam select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET SQL_BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET SQL_BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; +fld3 count(*) +affixed 1 +and 1 +annoyers 1 +Anthony 1 +assayed 1 +assurers 1 +attendants 1 +bedlam 1 +bedpost 1 +boasted 1 +SET SQL_BIG_TABLES=1; +select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; +fld3 count(*) +affixed 1 +and 1 +annoyers 1 +Anthony 1 +assayed 1 +assurers 1 +attendants 1 +bedlam 1 +bedpost 1 +boasted 1 +SET SQL_BIG_TABLES=0; +select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; +fld3 repeat("a",length(fld3)) count(*) +circus aaaaaa 1 +cited aaaaa 1 +Colombo aaaaaaa 1 +congresswoman aaaaaaaaaaaaa 1 +contrition aaaaaaaaaa 1 +corny aaaaa 1 +cultivation aaaaaaaaaaa 1 +definiteness aaaaaaaaaaaa 1 +demultiplex aaaaaaaaaaa 1 +disappointing aaaaaaaaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort +1 SIMPLE t3 ref period period 4 test.t1.period 4181 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 index period period 4 NULL 1 +1 SIMPLE t1 ref period period 4 test.t3.period 4181 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index period period 4 NULL 1 +1 SIMPLE t3 ref period period 4 test.t1.period 4181 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 const fld1 fld1 4 const 1 +1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1 +select fld3,period from t2,t1 where companynr*10 = 37*10; +fld3 period +breaking 9410 +Romans 9410 +intercepted 9410 +bewilderingly 9410 +astound 9410 +admonishing 9410 +sumac 9410 +flanking 9410 +combed 9410 +subjective 9410 +scatterbrain 9410 +Eulerian 9410 +Kane 9410 +overlay 9410 +perturb 9410 +goblins 9410 +annihilates 9410 +Wotan 9410 +snatching 9410 +concludes 9410 +laterally 9410 +yelped 9410 +grazing 9410 +Baird 9410 +celery 9410 +misunderstander 9410 +handgun 9410 +foldout 9410 +mystic 9410 +succumbed 9410 +Nabisco 9410 +fingerings 9410 +aging 9410 +afield 9410 +ammonium 9410 +boat 9410 +intelligibility 9410 +Augustine 9410 +teethe 9410 +dreaded 9410 +scholastics 9410 +audiology 9410 +wallet 9410 +parters 9410 +eschew 9410 +quitter 9410 +neat 9410 +Steinberg 9410 +jarring 9410 +tinily 9410 +balled 9410 +persist 9410 +attainments 9410 +fanatic 9410 +measures 9410 +rightfulness 9410 +capably 9410 +impulsive 9410 +starlet 9410 +terminators 9410 +untying 9410 +announces 9410 +featherweight 9410 +pessimist 9410 +daughter 9410 +decliner 9410 +lawgiver 9410 +stated 9410 +readable 9410 +attrition 9410 +cascade 9410 +motors 9410 +interrogate 9410 +pests 9410 +stairway 9410 +dopers 9410 +testicle 9410 +Parsifal 9410 +leavings 9410 +postulation 9410 +squeaking 9410 +contrasted 9410 +leftover 9410 +whiteners 9410 +erases 9410 +Punjab 9410 +Merritt 9410 +Quixotism 9410 +sweetish 9410 +dogging 9410 +scornfully 9410 +bellow 9410 +bills 9410 +cupboard 9410 +sureties 9410 +puddings 9410 +fetters 9410 +bivalves 9410 +incurring 9410 +Adolph 9410 +pithed 9410 +Miles 9410 +trimmings 9410 +tragedies 9410 +skulking 9410 +flint 9410 +flopping 9410 +relaxing 9410 +offload 9410 +suites 9410 +lists 9410 +animized 9410 +multilayer 9410 +standardizes 9410 +Judas 9410 +vacuuming 9410 +dentally 9410 +humanness 9410 +inch 9410 +Weissmuller 9410 +irresponsibly 9410 +luckily 9410 +culled 9410 +medical 9410 +bloodbath 9410 +subschema 9410 +animals 9410 +Micronesia 9410 +repetitions 9410 +Antares 9410 +ventilate 9410 +pityingly 9410 +interdependent 9410 +Graves 9410 +neonatal 9410 +chafe 9410 +honoring 9410 +realtor 9410 +elite 9410 +funereal 9410 +abrogating 9410 +sorters 9410 +Conley 9410 +lectured 9410 +Abraham 9410 +Hawaii 9410 +cage 9410 +hushes 9410 +Simla 9410 +reporters 9410 +Dutchman 9410 +descendants 9410 +groupings 9410 +dissociate 9410 +coexist 9410 +Beebe 9410 +Taoism 9410 +Connally 9410 +fetched 9410 +checkpoints 9410 +rusting 9410 +galling 9410 +obliterates 9410 +traitor 9410 +resumes 9410 +analyzable 9410 +terminator 9410 +gritty 9410 +firearm 9410 +minima 9410 +Selfridge 9410 +disable 9410 +witchcraft 9410 +betroth 9410 +Manhattanize 9410 +imprint 9410 +peeked 9410 +swelling 9410 +interrelationships 9410 +riser 9410 +Gandhian 9410 +peacock 9410 +bee 9410 +kanji 9410 +dental 9410 +scarf 9410 +chasm 9410 +insolence 9410 +syndicate 9410 +alike 9410 +imperial 9410 +convulsion 9410 +railway 9410 +validate 9410 +normalizes 9410 +comprehensive 9410 +chewing 9410 +denizen 9410 +schemer 9410 +chronicle 9410 +Kline 9410 +Anatole 9410 +partridges 9410 +brunch 9410 +recruited 9410 +dimensions 9410 +Chicana 9410 +announced 9410 +praised 9410 +employing 9410 +linear 9410 +quagmire 9410 +western 9410 +relishing 9410 +serving 9410 +scheduling 9410 +lore 9410 +eventful 9410 +arteriole 9410 +disentangle 9410 +cured 9410 +Fenton 9410 +avoidable 9410 +drains 9410 +detectably 9410 +husky 9410 +impelling 9410 +undoes 9410 +evened 9410 +squeezes 9410 +destroyer 9410 +rudeness 9410 +beaner 9410 +boorish 9410 +Everhart 9410 +encompass 9410 +mushrooms 9410 +Alison 9410 +externally 9410 +pellagra 9410 +cult 9410 +creek 9410 +Huffman 9410 +Majorca 9410 +governing 9410 +gadfly 9410 +reassigned 9410 +intentness 9410 +craziness 9410 +psychic 9410 +squabbled 9410 +burlesque 9410 +capped 9410 +extracted 9410 +DiMaggio 9410 +exclamation 9410 +subdirectory 9410 +Gothicism 9410 +feminine 9410 +metaphysically 9410 +sanding 9410 +Miltonism 9410 +freakish 9410 +index 9410 +straight 9410 +flurried 9410 +denotative 9410 +coming 9410 +commencements 9410 +gentleman 9410 +gifted 9410 +Shanghais 9410 +sportswriting 9410 +sloping 9410 +navies 9410 +leaflet 9410 +shooter 9410 +Joplin 9410 +babies 9410 +assails 9410 +admiring 9410 +swaying 9410 +Goldstine 9410 +fitting 9410 +Norwalk 9410 +analogy 9410 +deludes 9410 +cokes 9410 +Clayton 9410 +exhausts 9410 +causality 9410 +sating 9410 +icon 9410 +throttles 9410 +communicants 9410 +dehydrate 9410 +priceless 9410 +publicly 9410 +incidentals 9410 +commonplace 9410 +mumbles 9410 +furthermore 9410 +cautioned 9410 +parametrized 9410 +registration 9410 +sadly 9410 +positioning 9410 +babysitting 9410 +eternal 9410 +hoarder 9410 +congregates 9410 +rains 9410 +workers 9410 +sags 9410 +unplug 9410 +garage 9410 +boulder 9410 +specifics 9410 +Teresa 9410 +Winsett 9410 +convenient 9410 +buckboards 9410 +amenities 9410 +resplendent 9410 +sews 9410 +participated 9410 +Simon 9410 +certificates 9410 +Fitzpatrick 9410 +Evanston 9410 +misted 9410 +textures 9410 +save 9410 +count 9410 +rightful 9410 +chaperone 9410 +Lizzy 9410 +clenched 9410 +effortlessly 9410 +accessed 9410 +beaters 9410 +Hornblower 9410 +vests 9410 +indulgences 9410 +infallibly 9410 +unwilling 9410 +excrete 9410 +spools 9410 +crunches 9410 +overestimating 9410 +ineffective 9410 +humiliation 9410 +sophomore 9410 +star 9410 +rifles 9410 +dialysis 9410 +arriving 9410 +indulge 9410 +clockers 9410 +languages 9410 +Antarctica 9410 +percentage 9410 +ceiling 9410 +specification 9410 +regimented 9410 +ciphers 9410 +pictures 9410 +serpents 9410 +allot 9410 +realized 9410 +mayoral 9410 +opaquely 9410 +hostess 9410 +fiftieth 9410 +incorrectly 9410 +decomposition 9410 +stranglings 9410 +mixture 9410 +electroencephalography 9410 +similarities 9410 +charges 9410 +freest 9410 +Greenberg 9410 +tinting 9410 +expelled 9410 +warm 9410 +smoothed 9410 +deductions 9410 +Romano 9410 +bitterroot 9410 +corset 9410 +securing 9410 +environing 9410 +cute 9410 +Crays 9410 +heiress 9410 +inform 9410 +avenge 9410 +universals 9410 +Kinsey 9410 +ravines 9410 +bestseller 9410 +equilibrium 9410 +extents 9410 +relatively 9410 +pressure 9410 +critiques 9410 +befouled 9410 +rightfully 9410 +mechanizing 9410 +Latinizes 9410 +timesharing 9410 +Aden 9410 +embassies 9410 +males 9410 +shapelessly 9410 +mastering 9410 +Newtonian 9410 +finishers 9410 +abates 9410 +teem 9410 +kiting 9410 +stodgy 9410 +feed 9410 +guitars 9410 +airships 9410 +store 9410 +denounces 9410 +Pyle 9410 +Saxony 9410 +serializations 9410 +Peruvian 9410 +taxonomically 9410 +kingdom 9410 +stint 9410 +Sault 9410 +faithful 9410 +Ganymede 9410 +tidiness 9410 +gainful 9410 +contrary 9410 +Tipperary 9410 +tropics 9410 +theorizers 9410 +renew 9410 +already 9410 +terminal 9410 +Hegelian 9410 +hypothesizer 9410 +warningly 9410 +journalizing 9410 +nested 9410 +Lars 9410 +saplings 9410 +foothill 9410 +labeled 9410 +imperiously 9410 +reporters 9410 +furnishings 9410 +precipitable 9410 +discounts 9410 +excises 9410 +Stalin 9410 +despot 9410 +ripeness 9410 +Arabia 9410 +unruly 9410 +mournfulness 9410 +boom 9410 +slaughter 9410 +Sabine 9410 +handy 9410 +rural 9410 +organizer 9410 +shipyard 9410 +civics 9410 +inaccuracy 9410 +rules 9410 +juveniles 9410 +comprised 9410 +investigations 9410 +stabilizes 9410 +seminaries 9410 +Hunter 9410 +sporty 9410 +test 9410 +weasels 9410 +CERN 9410 +tempering 9410 +afore 9410 +Galatean 9410 +techniques 9410 +error 9410 +veranda 9410 +severely 9410 +Cassites 9410 +forthcoming 9410 +guides 9410 +vanish 9410 +lied 9410 +sawtooth 9410 +fated 9410 +gradually 9410 +widens 9410 +preclude 9410 +evenhandedly 9410 +percentage 9410 +disobedience 9410 +humility 9410 +gleaning 9410 +petted 9410 +bloater 9410 +minion 9410 +marginal 9410 +apiary 9410 +measures 9410 +precaution 9410 +repelled 9410 +primary 9410 +coverings 9410 +Artemia 9410 +navigate 9410 +spatial 9410 +Gurkha 9410 +meanwhile 9410 +Melinda 9410 +Butterfield 9410 +Aldrich 9410 +previewing 9410 +glut 9410 +unaffected 9410 +inmate 9410 +mineral 9410 +impending 9410 +meditation 9410 +ideas 9410 +miniaturizes 9410 +lewdly 9410 +title 9410 +youthfulness 9410 +creak 9410 +Chippewa 9410 +clamored 9410 +freezes 9410 +forgivably 9410 +reduce 9410 +McGovern 9410 +Nazis 9410 +epistle 9410 +socializes 9410 +conceptions 9410 +Kevin 9410 +uncovering 9410 +chews 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +raining 9410 +infest 9410 +compartment 9410 +minting 9410 +ducks 9410 +roped 9410 +waltz 9410 +Lillian 9410 +repressions 9410 +chillingly 9410 +noncritical 9410 +lithograph 9410 +spongers 9410 +parenthood 9410 +posed 9410 +instruments 9410 +filial 9410 +fixedly 9410 +relives 9410 +Pandora 9410 +watering 9410 +ungrateful 9410 +secures 9410 +poison 9410 +dusted 9410 +encompasses 9410 +presentation 9410 +Kantian 9410 +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250502 250501 +250503 250501 +250504 250501 +250505 250501 +250501 250502 +250502 250502 +250503 250502 +250504 250502 +250505 250502 +250501 250503 +250502 250503 +250503 250503 +250504 250503 +250505 250503 +250501 250504 +250502 250504 +250503 250504 +250504 250504 +250505 250504 +250501 250505 +250502 250505 +250503 250505 +250504 250505 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where; Not exists +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where; Not exists +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +label +labeled +labeled +landslide +laterally +leaflet +lewdly +Lillian +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069 +explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087 +29 95 abut wetness 14473298 152350.5053 8368.5480 70032594.9026 +34 70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069 +select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +companynr count(price) sum(price) min(price) max(price) avg(price) +37 12543 309394878010 5987435 39654943 24666736.6667 +78 8362 414611089292 726498 98439034 49582766.0000 +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +0 +9 +4 +6 +7 +1 +3 +8 +5 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +0 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +companynr count sum diff func +37 12543 309394878010 0.0000 464091 +78 8362 414611089292 0.0000 652236 +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; +companynr fld3 sum(price) +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 Micronesia 786542 +512 Miles 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +explain select fld3 from t2 where fld1=fld1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +29 95 14473298 +34 70 17788966 +37 588 83602098 +41 52 12816335 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +29 +34 +37 +41 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +companynr companyname count(*) +68 company 10 12 +50 company 11 11 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 = t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int(11) NULL NO PRI NULL auto_increment # +fld1 int(6) unsigned zerofill NULL NO UNI 000000 # +companynr tinyint(2) unsigned zerofill NULL NO 00 # +fld3 char(30) latin1_swedish_ci NO MUL # +fld4 char(35) latin1_swedish_ci NO # +fld5 char(35) latin1_swedish_ci NO # +fld6 char(4) latin1_swedish_ci NO # +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 # +fld3 char(30) latin1_swedish_ci NO MUL # +fld4 char(35) latin1_swedish_ci NO # +fld5 char(35) latin1_swedish_ci NO # +fld6 char(4) latin1_swedish_ci NO # +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +drop table t4, t3, t2, t1; +DO 1; +DO benchmark(100,1+1),1,1; +do default; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +do foobar; +ERROR 42S22: Unknown column 'foobar' in 'field list' +CREATE TABLE t1 ( +id mediumint(8) unsigned NOT NULL auto_increment, +pseudo varchar(35) NOT NULL default '', +PRIMARY KEY (id), +UNIQUE KEY pseudo (pseudo) +); +INSERT INTO t1 (pseudo) VALUES ('test'); +INSERT INTO t1 (pseudo) VALUES ('test1'); +SELECT 1 as rnd1 from t1 where rand() > 2; +rnd1 +DROP TABLE t1; +CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL); +CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35); +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +gvid the_success the_fail the_size the_time +Warnings: +Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1 +Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1 +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +gvid the_success the_fail the_size the_time +DROP TABLE t1,t2; +create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0'); +INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093); +select wss_type from t1 where wss_type ='102935229216544106'; +wss_type +select wss_type from t1 where wss_type ='102935229216544105'; +wss_type +select wss_type from t1 where wss_type ='102935229216544104'; +wss_type +select wss_type from t1 where wss_type ='102935229216544093'; +wss_type +102935229216544093 +select wss_type from t1 where wss_type =102935229216544093; +wss_type +102935229216544093 +drop table t1; +select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; +select @a; +@a +3 +select @b; +@b +aaaa +select @c; +@c +6.260 +create table t1 (a int not null auto_increment primary key); +insert into t1 values (); +insert into t1 values (); +insert into t1 values (); +select * from (t1 as t2 left join t1 as t3 using (a)), t1; +a a +1 1 +2 1 +3 1 +1 2 +2 2 +3 2 +1 3 +2 3 +3 3 +select * from t1, (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +2 1 +3 1 +1 2 +2 2 +3 2 +1 3 +2 3 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1; +a a +1 1 +2 1 +3 1 +1 2 +2 2 +3 2 +1 3 +2 3 +3 3 +select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +2 1 +3 1 +1 2 +2 2 +3 2 +1 3 +2 3 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1; +a a +1 2 +2 2 +3 2 +1 3 +2 3 +3 3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +3 1 +2 2 +3 2 +2 3 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a ); +a +1 +2 +3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +1 NULL +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a ); +a +1 +2 +3 +select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; +a +1 +2 +3 +select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1; +a a +NULL 1 +1 2 +2 2 +3 2 +1 3 +2 3 +3 3 +select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +3 1 +2 2 +3 2 +2 3 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a ); +a +1 +2 +3 +select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1; +a +1 +2 +3 +select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from t1 natural join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1; +a +1 +2 +3 +drop table t1; +CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)) ENGINE=MyISAM; +INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522); +CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); +select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; +aa id t2_id id +2 8299 2517 2517 +3 8301 2518 2518 +4 8302 2519 2519 +5 8303 2520 2520 +6 8304 2521 2521 +drop table t1,t2; +create table t1 (id1 int NOT NULL); +create table t2 (id2 int NOT NULL); +create table t3 (id3 int NOT NULL); +create table t4 (id4 int NOT NULL, id44 int NOT NULL, KEY (id4)); +insert into t1 values (1); +insert into t1 values (2); +insert into t2 values (1); +insert into t4 values (1,1); +explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 system NULL NULL NULL NULL 0 const row not found +1 SIMPLE t4 const id4 NULL NULL NULL 1 +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where +select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id1 id2 id3 id4 id44 +1 1 NULL NULL NULL +drop table t1,t2,t3,t4; +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one '), ('two\t'); +select * from t1 where s = 'one'; +s +select * from t2 where s = 'one'; +s +select * from t3 where s = 'one'; +s +one +select * from t1,t2 where t1.s = t2.s; +s s +two two +select * from t2,t3 where t2.s = t3.s; +s s +two two +drop table t1, t2, t3; +create table t1 (a integer, b integer, index(a), index(b)); +create table t2 (c integer, d integer, index(c), index(d)); +insert into t1 values (1,2), (2,2), (3,2), (4,2); +insert into t2 values (1,3), (2,3), (3,4), (4,4); +explain select * from t1 left join t2 on a=c where d in (4); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref c,d d 5 const 2 Using where +1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where; Using join buffer +select * from t1 left join t2 on a=c where d in (4); +a b c d +3 2 3 4 +4 2 4 4 +explain select * from t1 left join t2 on a=c where d = 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref c,d d 5 const 2 Using where +1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where; Using join buffer +select * from t1 left join t2 on a=c where d = 4; +a b c d +3 2 3 4 +4 2 4 4 +drop table t1, t2; +CREATE TABLE t1 ( +i int(11) NOT NULL default '0', +c char(10) NOT NULL default '', +PRIMARY KEY (i), +UNIQUE KEY c (c) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (2,'b'); +INSERT INTO t1 VALUES (3,'c'); +EXPLAIN SELECT i FROM t1 WHERE i=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index +DROP TABLE t1; +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +1 SIMPLE t2 ref a a 23 test.t1.a 2 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +1 SIMPLE t2 ref a a 23 test.t1.a 2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( city char(30) ); +INSERT INTO t1 VALUES ('London'); +INSERT INTO t1 VALUES ('Paris'); +SELECT * FROM t1 WHERE city='London'; +city +London +SELECT * FROM t1 WHERE city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where +SELECT * FROM t1 WHERE city='London' AND city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where +SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +city +London +DROP TABLE t1; +create table t1 (a int(11) unsigned, b int(11) unsigned); +insert into t1 values (1,0), (1,1), (1,2); +select a-b from t1 order by 1; +a-b +0 +1 +18446744073709551615 +select a-b , (a-b < 0) from t1 order by 1; +a-b (a-b < 0) +0 0 +1 0 +18446744073709551615 0 +select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; +d (a-b >= 0) b +1 1 0 +0 1 1 +18446744073709551615 1 2 +select cast((a - b) as unsigned) from t1 order by 1; +cast((a - b) as unsigned) +0 +1 +18446744073709551615 +drop table t1; +create table t1 (a int(11)); +select all all * from t1; +a +select distinct distinct * from t1; +a +select all distinct * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +select distinct all * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +drop table t1; +CREATE TABLE t1 ( +kunde_intern_id int(10) unsigned NOT NULL default '0', +kunde_id int(10) unsigned NOT NULL default '0', +FK_firma_id int(10) unsigned NOT NULL default '0', +aktuell enum('Ja','Nein') NOT NULL default 'Ja', +vorname varchar(128) NOT NULL default '', +nachname varchar(128) NOT NULL default '', +geloescht enum('Ja','Nein') NOT NULL default 'Nein', +firma varchar(128) NOT NULL default '' +); +INSERT INTO t1 VALUES +(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'), +(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX'); +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1 +WHERE +( +( +( '' != '' AND firma LIKE CONCAT('%', '', '%')) +OR +(vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND +'Vorname1' != '' AND 'xxxx' != '') +) +AND +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, +geloescht FROM t1 +WHERE +( +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +AND +( +( '' != '' AND firma LIKE CONCAT('%', '', '%') ) +OR +( vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND +'xxxx' != '') +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT COUNT(*) FROM t1 WHERE +( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1)) +AND FK_firma_id = 2; +COUNT(*) +0 +drop table t1; +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +b +9223372036854775808 +DROP TABLE t1; +CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL); +CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL); +INSERT INTO `t2` VALUES (0,'READ'); +CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL); +INSERT INTO `t3` VALUES (1,'fs'); +select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0); +id name gid uid ident level +1 fs NULL NULL 0 READ +drop table t1,t2,t3; +CREATE TABLE t1 ( +acct_id int(11) NOT NULL default '0', +profile_id smallint(6) default NULL, +UNIQUE KEY t1$acct_id (acct_id), +KEY t1$profile_id (profile_id) +); +INSERT INTO t1 VALUES (132,17),(133,18); +CREATE TABLE t2 ( +profile_id smallint(6) default NULL, +queue_id int(11) default NULL, +seq int(11) default NULL, +KEY t2$queue_id (queue_id) +); +INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); +CREATE TABLE t3 ( +id int(11) NOT NULL default '0', +qtype int(11) default NULL, +seq int(11) default NULL, +warn_lvl int(11) default NULL, +crit_lvl int(11) default NULL, +rr1 tinyint(4) NOT NULL default '0', +rr2 int(11) default NULL, +default_queue tinyint(4) NOT NULL default '0', +KEY t3$qtype (qtype), +KEY t3$id (id) +); +INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), +(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); +SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q +WHERE +(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND +(pq.queue_id = q.id) AND (q.rr1 <> 1); +COUNT(*) +4 +drop table t1,t2,t3; +create table t1 (f1 int); +insert into t1 values (1),(NULL); +create table t2 (f2 int, f3 int, f4 int); +create index idx1 on t2 (f4); +insert into t2 values (1,2,3),(2,4,6); +select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) +from t2 C where A.f4 = C.f4) or A.f3 IS NULL; +f2 +1 +NULL +drop table t1,t2; +create table t2 (a tinyint unsigned); +create index t2i on t2(a); +insert into t2 values (0), (254), (255); +explain select * from t2 where a > -1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 index t2i t2i 2 NULL 3 Using where; Using index +select * from t2 where a > -1; +a +0 +254 +255 +drop table t2; +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +SELECT * FROM t1; +a b c +50 3 3 +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +select found_rows(); +found_rows() +0 +SELECT * FROM t1; +a b c +50 3 3 +select count(*) from t1; +count(*) +1 +select found_rows(); +found_rows() +1 +select count(*) from t1 limit 2,3; +count(*) +select found_rows(); +found_rows() +0 +select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; +count(*) +select found_rows(); +found_rows() +1 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +(SELECT a, b AS c FROM t1) ORDER BY c+1; +a c +(SELECT a, b AS c FROM t1) ORDER BY b+1; +a c +SELECT a, b AS c FROM t1 ORDER BY c+1; +a c +SELECT a, b AS c FROM t1 ORDER BY b+1; +a c +drop table t1; +create table t1(f1 int, f2 int); +create table t2(f3 int); +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL)); +f1 +insert into t1 values(1,1),(2,null); +insert into t2 values(2); +select * from t1,t2 where f1=f3 and (f1,f2) = (2,null); +f1 f2 f3 +select * from t1,t2 where f1=f3 and (f1,f2) <=> (2,null); +f1 f2 f3 +2 NULL 2 +drop table t1,t2; +create table t1 (f1 int not null auto_increment primary key, f2 varchar(10)); +create table t11 like t1; +insert into t1 values(1,""),(2,""); +show table status like 't1%'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Dynamic 2 20 X X X X X X X X latin1_swedish_ci NULL +t11 MyISAM 10 Dynamic 0 0 X X X X X X X X latin1_swedish_ci NULL +select 123 as a from t1 where f1 is null; +a +drop table t1,t11; +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) ); +INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4); +CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT ); +INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3); +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 2 1 1 +1 2 2 1 +1 2 3 1 +1 10 2 +1 11 2 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c; +a b c d +1 10 4 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c; +a b c d +1 2 1 1 +1 2 2 1 +1 2 3 1 +1 10 2 +1 11 2 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1 +WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 2 1 1 +1 2 2 1 +1 2 3 1 +DROP TABLE IF EXISTS t1, t2; +create table t1 (f1 int primary key, f2 int); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t1 values (1,1); +insert into t2 values (1,1),(1,2); +select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1; +count(f2) >0 +1 +drop table t1,t2; +create table t1 (f1 int,f2 int); +insert into t1 values(1,1); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t2 values(1,1); +select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2)); +f1 f2 +1 1 +drop table t1,t2; +CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c)); +insert into t1 values (1,0,0),(2,0,0); +CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a)); +insert into t2 values (1,'',''), (2,'',''); +CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b)); +insert into t3 values (1,1),(1,2); +explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2 +where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and +t2.b like '%%' order by t2.b limit 0,1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref b,c b 5 const 1 Using where; Using temporary; Using filesort +1 SIMPLE t3 index PRIMARY,a,b PRIMARY 8 NULL 2 Using index; Using join buffer +1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Range checked for each record (index map: 0x1) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, INDEX idx(a)); +INSERT INTO t1 VALUES (2), (3), (1); +EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +EXPLAIN SELECT * FROM t1 IGNORE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +EXPLAIN SELECT * FROM t1 FORCE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (4,10); +CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b)); +INSERT INTO t2 VALUES (1,NULL), (2,10); +ALTER TABLE t1 ENABLE KEYS; +EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 index b b 5 NULL 2 Using index +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer +SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 index b b 5 NULL 2 Using index +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer +SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (key1 float default NULL, UNIQUE KEY key1 (key1)); +CREATE TABLE t2 (key2 float default NULL, UNIQUE KEY key2 (key2)); +INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941); +INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941); +explain select max(key1) from t1 where key1 <= 0.6158; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +explain select max(key2) from t2 where key2 <= 1.6158; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +explain select min(key1) from t1 where key1 >= 0.3762; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +explain select min(key2) from t2 where key2 >= 1.3762; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +explain select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select max(key1) from t1 where key1 <= 0.6158; +max(key1) +0.615800023078918 +select max(key2) from t2 where key2 <= 1.6158; +max(key2) +1.61580002307892 +select min(key1) from t1 where key1 >= 0.3762; +min(key1) +0.376199990510941 +select min(key2) from t2 where key2 >= 1.3762; +min(key2) +1.37619996070862 +select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +max(key1) min(key2) +0.615800023078918 1.37619996070862 +select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +max(key1) +0.615800023078918 +select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +min(key1) +0.376199990510941 +DROP TABLE t1,t2; +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; +i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') +1 1 1 1 +DROP TABLE t1; +create table t1(a bigint unsigned, b bigint); +insert into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), +(0x10000000000000000, 0x10000000000000000), +(0x8fffffffffffffff, 0x8fffffffffffffff); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'b' at row 2 +Warning 1264 Out of range value for column 'b' at row 3 +select hex(a), hex(b) from t1; +hex(a) hex(b) +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +drop table t1; +CREATE TABLE t1 (c0 int); +CREATE TABLE t2 (c0 int); +INSERT INTO t1 VALUES(@@connect_timeout); +INSERT INTO t2 VALUES(@@connect_timeout); +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout); +c0 c0 +X X +DROP TABLE t1, t2; +End of 4.1 tests +CREATE TABLE t1 ( +K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', +K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', +F2I4 int(11) NOT NULL default '0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES +('W%RT', '0100', 1), +('W-RT', '0100', 1), +('WART', '0100', 1), +('WART', '0200', 1), +('WERT', '0100', 2), +('WORT','0200', 2), +('WT', '0100', 2), +('W_RT', '0100', 2), +('WaRT', '0100', 3), +('WART', '0300', 3), +('WRT' , '0400', 3), +('WURM', '0500', 3), +('W%T', '0600', 4), +('WA%T', '0700', 4), +('WA_T', '0800', 4); +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND +(F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); +K2C4 K4N4 F2I4 +WART 0200 1 +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); +K2C4 K4N4 F2I4 +WART 0100 1 +WART 0200 1 +WART 0300 3 +DROP TABLE t1; +create table t1 (a int, b int); +create table t2 like t1; +select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1; +a +select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1; +a +select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1; +a a a +drop table t1,t2; +create table t1 (s1 varchar(5)); +insert into t1 values ('Wall'); +select min(s1) from t1 group by s1 with rollup; +min(s1) +Wall +Wall +drop table t1; +create table t1 (s1 int) engine=myisam; +insert into t1 values (0); +select avg(distinct s1) from t1 group by s1 with rollup; +avg(distinct s1) +0.0000 +0.0000 +drop table t1; +create table t1 (s1 int); +insert into t1 values (null),(1); +select distinct avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 VALUES (2), (4), (6); +SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +a +2 +4 +EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer +EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer +DROP TABLE t1,t2; +select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; +x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 +16 16 2 2 +create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); +create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); +insert into t1 values (" 2", 2); +insert into t2 values (" 2", " one "),(" 2", " two "); +select * from t1 left join t2 on f1 = f3; +f1 f2 f3 f4 + 2 2 2 one + 2 2 2 two +drop table t1,t2; +create table t1 (empnum smallint, grp int); +create table t2 (empnum int, name char(5)); +insert into t1 values(1,1); +insert into t2 values(1,'bob'); +create view v1 as select * from t2 inner join t1 using (empnum); +select * from v1; +empnum name grp +1 bob 1 +drop table t1,t2; +drop view v1; +create table t1 (pk int primary key, b int); +create table t2 (pk int primary key, c int); +select pk from t1 inner join t2 using (pk); +pk +drop table t1,t2; +create table t1 (s1 int, s2 char(5), s3 decimal(10)); +create view v1 as select s1, s2, 'x' as s3 from t1; +select * from t1 natural join v1; +s1 s2 s3 +insert into t1 values (1,'x',5); +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +drop table t1; +drop view v1; +create table t1(a1 int); +create table t2(a2 int); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create view v2 (c) as select a1 from t1; +select * from t1 natural left join t2; +a1 a2 +1 1 +1 2 +2 1 +2 2 +select * from t1 natural right join t2; +a2 a1 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural left join t2; +c a2 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural right join t2; +a2 c +1 1 +1 2 +2 1 +2 2 +drop table t1, t2; +drop view v2; +create table t1 (a int(10), t1_val int(10)); +create table t2 (b int(10), t2_val int(10)); +create table t3 (a int(10), b int(10)); +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(3,1),(4,1); +select * from t1 natural join t2 natural join t3; +a b t1_val t2_val +1 1 1 1 +2 1 2 1 +select * from t1 natural join t3 natural join t2; +b a t1_val t2_val +1 1 1 1 +1 2 2 1 +drop table t1, t2, t3; +DO IFNULL(NULL, NULL); +SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL); +CAST(IFNULL(NULL, NULL) AS DECIMAL) +NULL +SELECT ABS(IFNULL(NULL, NULL)); +ABS(IFNULL(NULL, NULL)) +NULL +SELECT IFNULL(NULL, NULL); +IFNULL(NULL, NULL) +NULL +SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE=''; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode +CREATE TABLE BUG_12595(a varchar(100)); +INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an"); +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +a +hakan% +hakank +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE ''; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SET @@SQL_MODE='NO_BACKSLASH_ESCAPES'; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode NO_BACKSLASH_ESCAPES +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n'; +ERROR HY000: Incorrect arguments to ESCAPE +SET @@SQL_MODE=@OLD_SQL_MODE12595; +DROP TABLE BUG_12595; +create table t1 (a char(1)); +create table t2 (a char(1)); +insert into t1 values ('a'),('b'),('c'); +insert into t2 values ('b'),('c'),('d'); +select a from t1 natural join t2; +a +b +c +select * from t1 natural join t2 where a = 'b'; +a +b +drop table t1, t2; +CREATE TABLE t1 (`id` TINYINT); +CREATE TABLE t2 (`id` TINYINT); +CREATE TABLE t3 (`id` TINYINT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (3); +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.notacolumn=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +drop table t1, t2, t3; +create table t1 (a int(10),b int(10)); +create table t2 (a int(10),b int(10)); +insert into t1 values (1,10),(2,20),(3,30); +insert into t2 values (1,10); +select * from t1 inner join t2 using (A); +a b b +1 10 10 +select * from t1 inner join t2 using (a); +a b b +1 10 10 +drop table t1, t2; +create table t1 (a int, c int); +create table t2 (b int); +create table t3 (b int, a int); +create table t4 (c int); +insert into t1 values (1,1); +insert into t2 values (1); +insert into t3 values (1,1); +insert into t4 values (1); +select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +a c b b a +1 1 1 1 1 +select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +ERROR 42S22: Unknown column 't1.a' in 'on clause' +select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c); +a c b b a c +1 1 1 1 1 1 +select * from t1 join t2 join t4 using (c); +c a b +1 1 1 +drop table t1, t2, t3, t4; +create table t1(x int, y int); +create table t2(x int, y int); +create table t3(x int, primary key(x)); +insert into t1 values (1, 1), (2, 1), (3, 1), (4, 3), (5, 6), (6, 6); +insert into t2 values (1, 1), (2, 1), (3, 3), (4, 6), (5, 6); +insert into t3 values (1), (2), (3), (4), (5); +select t1.x, t3.x from t1, t2, t3 where t1.x = t2.x and t3.x >= t1.y and t3.x <= t2.y; +x x +1 1 +2 1 +3 1 +3 2 +3 3 +4 3 +4 4 +4 5 +drop table t1,t2,t3; +create table t1 (id char(16) not null default '', primary key (id)); +insert into t1 values ('100'),('101'),('102'); +create table t2 (id char(16) default null); +insert into t2 values (1); +create view v1 as select t1.id from t1; +create view v2 as select t2.id from t2; +create view v3 as select (t1.id+2) as id from t1 natural left join t2; +select t1.id from t1 left join v2 using (id); +id +100 +101 +102 +select t1.id from v2 right join t1 using (id); +id +100 +101 +102 +select t1.id from t1 left join v3 using (id); +id +100 +101 +102 +select * from t1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join t1 using (id); +id +100 +101 +102 +select * from t1 left join v3 using (id); +id +100 +101 +102 +select v1.id from v1 left join v2 using (id); +id +100 +101 +102 +select v1.id from v2 right join v1 using (id); +id +100 +101 +102 +select v1.id from v1 left join v3 using (id); +id +100 +101 +102 +select * from v1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join v1 using (id); +id +100 +101 +102 +select * from v1 left join v3 using (id); +id +100 +101 +102 +drop table t1, t2; +drop view v1, v2, v3; +create table t1 (id int(11) not null default '0'); +insert into t1 values (123),(191),(192); +create table t2 (id char(16) character set utf8 not null); +insert into t2 values ('58013'),('58014'),('58015'),('58016'); +create table t3 (a_id int(11) not null, b_id char(16) character set utf8); +insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013'); +select count(*) +from t1 inner join (t3 left join t2 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +select count(*) +from t1 inner join (t2 right join t3 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +drop table t1,t2,t3; +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); +select * from t1 join t2 join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 left join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 right join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 straight_join t3 on (t1.a=t3.c); +a b c +drop table t1, t2 ,t3; +create table t1(f1 int, f2 date); +insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'), +(4,'2005-10-01'),(5,'2005-12-30'); +select * from t1 where f2 >= 0 order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +select * from t1 where f2 >= '0000-00-00' order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +select * from t1 where f2 >= '2005-09-31' order by f2; +f1 f2 +4 2005-10-01 +5 2005-12-30 +select * from t1 where f2 >= '2005-09-3a' order by f2; +f1 f2 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +select * from t1 where f2 <= '2005-09-31' order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +3 2005-09-30 +select * from t1 where f2 <= '2005-09-3a' order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values (1, 30), (2, 20), (3, 10); +create algorithm=merge view v1 as select f1, f2 from t1; +create algorithm=merge view v2 (f2, f1) as select f1, f2 from t1; +create algorithm=merge view v3 as select t1.f1 as f2, t1.f2 as f1 from t1; +select t1.f1 as x1, f1 from t1 order by t1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v1.f1 as x1, f1 from v1 order by v1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v2.f1 as x1, f1 from v2 order by v2.f1; +x1 f1 +10 10 +20 20 +30 30 +select v3.f1 as x1, f1 from v3 order by v3.f1; +x1 f1 +10 10 +20 20 +30 30 +select f1, f2, v1.f1 as x1 from v1 order by v1.f1; +f1 f2 x1 +1 30 1 +2 20 2 +3 10 3 +select f1, f2, v2.f1 as x1 from v2 order by v2.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +select f1, f2, v3.f1 as x1 from v3 order by v3.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +drop table t1; +drop view v1, v2, v3; +CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a)); +CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a)); +CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32), +PRIMARY KEY(key_a,key_b)); +INSERT INTO t1 VALUES (0,''); +INSERT INTO t1 VALUES (1,'i'); +INSERT INTO t1 VALUES (2,'j'); +INSERT INTO t1 VALUES (3,'k'); +INSERT INTO t2 VALUES (1,'r'); +INSERT INTO t2 VALUES (2,'s'); +INSERT INTO t2 VALUES (3,'t'); +INSERT INTO t3 VALUES (1,5,'x'); +INSERT INTO t3 VALUES (1,6,'y'); +INSERT INTO t3 VALUES (2,5,'xx'); +INSERT INTO t3 VALUES (2,6,'yy'); +INSERT INTO t3 VALUES (2,7,'zz'); +INSERT INTO t3 VALUES (3,5,'xxx'); +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index +1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using index +1 SIMPLE t3 const PRIMARY PRIMARY 8 const,const 1 +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index +1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using index +1 SIMPLE t3 const PRIMARY PRIMARY 8 const,const 1 +DROP TABLE t1,t2,t3; +create table t1 (f1 int); +insert into t1 values(1),(2); +create table t2 (f2 int, f3 int, key(f2)); +insert into t2 values(1,1),(2,2); +create table t3 (f4 int not null); +insert into t3 values (2),(2),(2); +select f1,(select count(*) from t2,t3 where f2=f1 and f3=f4) as count from t1; +f1 count +1 0 +2 3 +drop table t1,t2,t3; +create table t1 (f1 int unique); +create table t2 (f2 int unique); +create table t3 (f3 int unique); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +insert into t3 values(1),(NULL); +select * from t3 where f3 is null; +f3 +NULL +select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1; +f2 +1 +drop table t1,t2,t3; +create table t1(f1 char, f2 char not null); +insert into t1 values(null,'a'); +create table t2 (f2 char not null); +insert into t2 values('b'); +select * from t1 left join t2 on f1=t2.f2 where t1.f2='a'; +f1 f2 f2 +NULL a NULL +drop table t1,t2; +select * from (select * left join t on f1=f2) tt; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on f1=f2) tt' at line 1 +CREATE TABLE t1 (sku int PRIMARY KEY, pr int); +CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255)); +INSERT INTO t1 VALUES +(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10); +INSERT INTO t2 VALUES +(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'), +(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh'); +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +sku sppr name sku pr +20 10 bbb 10 10 +20 10 bbb 20 10 +EXPLAIN +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where +DROP TABLE t1,t2; +CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL); +INSERT t1 SET i = 0; +UPDATE t1 SET i = -1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = CAST(i - 1 AS SIGNED); +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = i - 1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +255 +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, c int, e int, primary key(a,b,c)); +insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C; +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select 'In next EXPLAIN, B.rows must be exactly 10:' Z; +Z +In next EXPLAIN, B.rows must be exactly 10: +explain select * from t2 A, t2 B where A.a=5 and A.b=5 and A.C<5 +and B.a=5 and B.b=A.e and (B.b =1 or B.b = 3 or B.b=5); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE A range PRIMARY PRIMARY 12 NULL 4 Using where +1 SIMPLE B ref PRIMARY PRIMARY 8 const,test.A.e 10 +drop table t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b)); +INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2), +(3,1), (5,1), (8,9), (2,2), (0,9); +CREATE TABLE t2 (c int, d int, f int, INDEX(c,f)); +INSERT INTO t2 VALUES +(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1), +(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1), +(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1); +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using where +1 SIMPLE t2 ref c c 5 test.t1.a 2 Using where +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using where +1 SIMPLE t2 ref c c 5 test.t1.a 2 Using where +DROP TABLE t1, t2; +create table t1 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c bit not null +); +create table t2 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c int unsigned not null, +d varchar(50) +); +insert into t1 (b,c) values (0,1), (0,1); +insert into t2 (b,c) values (0,1); +select t1.a, t1.b + 0, t1.c + 0, t2.a, t2.b + 0, t2.c, t2.d +from t1 left outer join t2 on t1.a = t2.c and t2.b <> 1 +where t1.b <> 1 order by t1.a; +a t1.b + 0 t1.c + 0 a t2.b + 0 c d +1 0 1 1 0 1 NULL +2 0 1 NULL NULL NULL NULL +drop table t1,t2; +SELECT 0.9888889889 * 1.011111411911; +0.9888889889 * 1.011111411911 +0.9998769417899202067879 +prepare stmt from 'select 1 as " a "'; +Warnings: +Warning 1466 Leading spaces are removed from name ' a ' +execute stmt; +a +1 +CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +CREATE TABLE t2 (c int NOT NULL, INDEX idx(c)); +INSERT INTO t2 VALUES +(1), (1), (1), (1), (1), (1), (1), (1), +(2), (2), (2), (2), +(3), (3), +(4); +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 +1 SIMPLE t2 ref idx idx 4 const 7 Using index +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 +1 SIMPLE t2 ref idx idx 4 const 1 Using index +DROP TABLE t1, t2; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int); +INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2); +CREATE TABLE t2 (b int, c INT, INDEX idx1(b)); +INSERT INTO t2 VALUES (2,1), (3,2); +CREATE TABLE t3 (d int, e int, INDEX idx1(d)); +INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 +1 SIMPLE t2 const idx1 NULL NULL NULL 1 +1 SIMPLE t3 ref idx1 idx1 5 const 3 Using where +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id a b c d e +2 NULL NULL NULL 2 10 +2 NULL NULL NULL 2 20 +2 NULL NULL NULL 2 40 +2 NULL NULL NULL 2 50 +DROP TABLE t1,t2,t3; +create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int, +c7 int, c8 int, c9 int, fulltext key (`c1`)); +select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 +from t1 where c9=1 order by c2, c2; +match (`c1`) against ('z') c2 c3 c4 c5 c6 c7 c8 +drop table t1; +CREATE TABLE t1 (pk varchar(10) PRIMARY KEY, fk varchar(16)); +CREATE TABLE t2 (pk varchar(16) PRIMARY KEY, fk varchar(10)); +INSERT INTO t1 VALUES +('d','dddd'), ('i','iii'), ('a','aa'), ('b','bb'), ('g','gg'), +('e','eee'), ('c','cccc'), ('h','hhh'), ('j','jjj'), ('f','fff'); +INSERT INTO t2 VALUES +('jjj', 'j'), ('cc','c'), ('ccc','c'), ('aaa', 'a'), ('jjjj','j'), +('hhh','h'), ('gg','g'), ('fff','f'), ('ee','e'), ('ffff','f'), +('bbb','b'), ('ff','f'), ('cccc','c'), ('dddd','d'), ('jj','j'), +('aaaa','a'), ('bb','b'), ('eeee','e'), ('aa','a'), ('hh','h'); +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk < 'c' AND t2.pk=t1.fk; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 12 NULL 3 Using where +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 18 test.t1.fk 1 Using where +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk BETWEEN 'a' AND 'b' AND t2.pk=t1.fk; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 12 NULL 2 Using where +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 18 test.t1.fk 1 Using where +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk IN ('a','b') AND t2.pk=t1.fk; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 12 NULL 2 Using where +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 18 test.t1.fk 1 Using where +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b varchar(20) NOT NULL, PRIMARY KEY(a)); +CREATE TABLE t2 (a int, b varchar(20) NOT NULL, +PRIMARY KEY (a), UNIQUE KEY (b)); +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); +EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.b=t1.b WHERE t1.a=3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 +DROP TABLE t1,t2; +CREATE TABLE t1(id int PRIMARY KEY, b int, e int); +CREATE TABLE t2(i int, a int, INDEX si(i), INDEX ai(a)); +CREATE TABLE t3(a int PRIMARY KEY, c char(4), INDEX ci(c)); +INSERT INTO t1 VALUES +(1,10,19), (2,20,22), (4,41,42), (9,93,95), (7, 77,79), +(6,63,67), (5,55,58), (3,38,39), (8,81,89); +INSERT INTO t2 VALUES +(21,210), (41,410), (82,820), (83,830), (84,840), +(65,650), (51,510), (37,370), (94,940), (76,760), +(22,220), (33,330), (40,400), (95,950), (38,380), +(67,670), (88,880), (57,570), (96,960), (97,970); +INSERT INTO t3 VALUES +(210,'bb'), (950,'ii'), (400,'ab'), (500,'ee'), (220,'gg'), +(440,'gg'), (310,'eg'), (380,'ee'), (840,'bb'), (830,'ff'), +(230,'aa'), (960,'ii'), (410,'aa'), (510,'ee'), (290,'bb'), +(450,'gg'), (320,'dd'), (390,'hh'), (850,'jj'), (860,'ff'); +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 +1 SIMPLE t2 range si si 5 NULL 4 Using where +1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee') ; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 +1 SIMPLE t2 range si,ai si 5 NULL 4 Using where +1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 +1 SIMPLE t2 range si si 5 NULL 2 Using where +1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 +1 SIMPLE t2 range si,ai si 5 NULL 2 Using where +1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); +CREATE TABLE t2 ( f11 int PRIMARY KEY ); +INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0); +INSERT INTO t2 VALUES (62); +SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1; +f1 f2 f3 f4 f5 f6 checked_out f11 +1 1 1 0 0 0 0 NULL +DROP TABLE t1, t2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a int); +INSERT into t1 values (1), (2), (3); +SELECT * FROM t1 LIMIT 2, -1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1 +DROP TABLE t1; +CREATE TABLE t1 ( +ID_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID_with_null), +INDEX idx2 (ID_better) +); +INSERT INTO t1 VALUES (1,1), (2,1), (null,3), (null,3), (null,3), (null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +SELECT COUNT(*) FROM t1 WHERE ID_with_null IS NULL; +COUNT(*) +128 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID_with_null); +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where +DROP TABLE t1; +CREATE TABLE t1 ( +ID1_with_null int NULL, +ID2_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID1_with_null, ID2_with_null), +INDEX idx2 (ID_better) +); +INSERT INTO t1 VALUES (1,1,1), (2,2,1), (3,null,3), (null,3,3), (null,null,3), +(3,null,3), (null,3,3), (null,null,3), (3,null,3), (null,3,3), (null,null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null=3; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null=3 AND ID2_with_null IS NULL; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null IS NULL; +COUNT(*) +192 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND +(ID2_with_null=1 OR ID2_with_null=2); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where +DROP TABLE t1; +CREATE TABLE t1 (a INT, ts TIMESTAMP, KEY ts(ts)); +INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00"); +INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 +1 SIMPLE t1 range ts ts 4 NULL 1 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +a ts a dt1 dt2 +30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +DROP TABLE t1,t2; +create table t1 (a bigint unsigned); +insert into t1 values +(if(1, 9223372036854775808, 1)), +(case when 1 then 9223372036854775808 else 1 end), +(coalesce(9223372036854775808, 1)); +select * from t1; +a +9223372036854775808 +9223372036854775808 +9223372036854775808 +drop table t1; +create table t1 select +if(1, 9223372036854775808, 1) i, +case when 1 then 9223372036854775808 else 1 end c, +coalesce(9223372036854775808, 1) co; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` decimal(19,0) NOT NULL DEFAULT '0', + `c` decimal(19,0) NOT NULL DEFAULT '0', + `co` decimal(19,0) NOT NULL DEFAULT '0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select +if(1, cast(1111111111111111111 as unsigned), 1) i, +case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, +coalesce(cast(1111111111111111111 as unsigned), 1) co; +i c co +1111111111111111111 1111111111111111111 1111111111111111111 +CREATE TABLE t1 (name varchar(255)); +CREATE TABLE t2 (name varchar(255), n int, KEY (name(3))); +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc 4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc 4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc 4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref name name 6 const 3 Using where +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range name name 6 NULL 3 Using where +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc 4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range name name 6 NULL 3 Using where; Using filesort +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc 4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +1 SIMPLE t2 ref name name 6 test.t1.name 2 +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +ccc NULL NULL +bb bb 1 +bb bb 6 +cc cc 3 +cc cc 5 +cc cc 7 +aa aa 2 +aa aa 2 +DROP TABLE t1,t2; +CREATE TABLE t1 (name text); +CREATE TABLE t2 (name text, n int, KEY (name(3))); +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc 4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc 4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc 4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref name name 6 const 3 Using where +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range name name 6 NULL 3 Using where +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc 4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range name name 6 NULL 3 Using where; Using filesort +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc 4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +1 SIMPLE t2 ref name name 6 test.t1.name 2 +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +ccc NULL NULL +bb bb 1 +bb bb 6 +cc cc 3 +cc cc 5 +cc cc 7 +aa aa 2 +aa aa 2 +DROP TABLE t1,t2; +CREATE TABLE t1 ( +access_id int NOT NULL default '0', +name varchar(20) default NULL, +rank int NOT NULL default '0', +KEY idx (access_id) +); +CREATE TABLE t2 ( +faq_group_id int NOT NULL default '0', +faq_id int NOT NULL default '0', +access_id int default NULL, +UNIQUE KEY idx1 (faq_id), +KEY idx2 (faq_group_id,faq_id) +); +INSERT INTO t1 VALUES +(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4); +INSERT INTO t2 VALUES +(261,265,1),(490,494,1); +SELECT t2.faq_id +FROM t1 INNER JOIN t2 IGNORE INDEX (idx1) +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +SELECT t2.faq_id +FROM t1 INNER JOIN t2 +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, KEY inx (b,a)); +INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7); +EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 +ON ( f1.b=f2.b AND f1.a<f2.a ) +WHERE 1 AND f1.b NOT IN (100,2232,3343,51111); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index +1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using index +DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))))) > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +31 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +32 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0; +ERROR HY000: Too high level of nesting for select +DROP TABLE t1; +CREATE TABLE t1 ( +c1 int(11) NOT NULL AUTO_INCREMENT, +c2 varchar(1000) DEFAULT NULL, +c3 bigint(20) DEFAULT NULL, +c4 bigint(20) DEFAULT NULL, +PRIMARY KEY (c1) +); +EXPLAIN EXTENDED +SELECT join_2.c1 +FROM +t1 AS join_0, +t1 AS join_1, +t1 AS join_2, +t1 AS join_3, +t1 AS join_4, +t1 AS join_5, +t1 AS join_6, +t1 AS join_7 +WHERE +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +OR +join_0.c2 < '?' AND +join_1.c2 < '?' AND +join_2.c2 > '?' AND +join_2.c2 < '!' AND +join_3.c2 > '?' AND +join_4.c2 = '?' AND +join_5.c2 <> '?' AND +join_6.c2 <> '?' AND +join_7.c2 >= '?' AND +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +GROUP BY +join_3.c1, +join_2.c1, +join_7.c1, +join_1.c1, +join_0.c1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +Warnings: +Note 1003 select NULL AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where 0 group by NULL,NULL,NULL,NULL,NULL +SHOW WARNINGS; +Level Code Message +Note 1003 select NULL AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where 0 group by NULL,NULL,NULL,NULL,NULL +DROP TABLE t1; +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` x`; +x +1 +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +CREATE VIEW v1 AS SELECT 1 AS ``; +ERROR 42000: Incorrect column name '' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` x`; +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +SELECT `x` FROM v1; +x +1 +ALTER VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +DROP VIEW v1; +select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT'; +str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007/10/01 00:00:00 GMT' +Warning 1292 Truncated incorrect datetime value: '2007/10/20 00:00:00 GMT' +select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'; +str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6' +select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'; +str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/2000:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-01 x00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:x00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6' +select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56' +1 +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00' +0 +select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34' +select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34'; +str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34' +1 +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34' +1 +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00' +1 +set SQL_MODE=TRADITIONAL; +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34' +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34:00' +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20' +0 +Warnings: +Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/09/01' at row 1 +Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/10/20' at row 1 +set SQL_MODE=DEFAULT; +select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '' +select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'; +str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20' +0 +select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +0 +select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '' +select str_to_date('1','%Y-%m-%d') = '1'; +str_to_date('1','%Y-%m-%d') = '1' +0 +Warnings: +Warning 1292 Truncated incorrect date value: '1' +select str_to_date('1','%Y-%m-%d') = '1'; +str_to_date('1','%Y-%m-%d') = '1' +0 +Warnings: +Warning 1292 Truncated incorrect date value: '1' +select str_to_date('','%Y-%m-%d') = ''; +str_to_date('','%Y-%m-%d') = '' +0 +Warnings: +Warning 1292 Truncated incorrect date value: '' +select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL +0 +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00' +0 +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL +0 +CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, +c22 INT DEFAULT NULL, +KEY(c21, c22)); +CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, +c32 INT DEFAULT NULL, +c33 INT NOT NULL, +c34 INT UNSIGNED DEFAULT 0, +KEY (c33, c34, c32)); +INSERT INTO t1 values (),(),(),(),(); +INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b; +INSERT INTO t3 VALUES (1, 1, 1, 0), +(2, 2, 0, 0), +(3, 3, 1, 0), +(4, 4, 0, 0), +(5, 5, 1, 0); +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32; +c32 +1 +1 +3 +3 +5 +5 +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32 DESC; +c32 +5 +5 +3 +3 +1 +1 +DROP TABLE t1, t2, t3; + +# +# Bug#30736: Row Size Too Large Error Creating a Table and +# Inserting Data. +# +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1( +c1 DECIMAL(10, 2), +c2 FLOAT); + +INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5); + +CREATE TABLE t2( +c3 DECIMAL(10, 2)) +SELECT +c1 * c2 AS c3 +FROM t1; + +SELECT * FROM t1; +c1 c2 +0.00 1 +2.00 3 +4.00 5 + +SELECT * FROM t2; +c3 +0.00 +6.00 +20.00 + +DROP TABLE t1; +DROP TABLE t2; + +CREATE TABLE t1 (c1 BIGINT NOT NULL); +INSERT INTO t1 (c1) VALUES (1); +SELECT * FROM t1 WHERE c1 > NULL + 1; +c1 +DROP TABLE t1; + +CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY); +INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0'); +SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar'); +a +foo0 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, c INT, KEY(a)); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), +(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), +(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), +(4, 1), (4, 2), (4, 3), (4, 4), (4, 5); +FLUSH STATUS; +SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3; +b +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 6 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0', +f2 int(11) NOT NULL default '0', +f3 bigint(20) NOT NULL default '0', +f4 varchar(255) NOT NULL default '', +PRIMARY KEY (f1), +KEY key1 (f4), +KEY key2 (f2)); +CREATE TABLE t2 (f1 int(11) NOT NULL default '0', +f2 enum('A1','A2','A3') NOT NULL default 'A1', +f3 int(11) NOT NULL default '0', +PRIMARY KEY (f1), +KEY key1 (f3)); +CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0', +f2 datetime NOT NULL default '1980-01-01 00:00:00', +PRIMARY KEY (f1)); +insert into t1 values (1, 1, 1, 'abc'); +insert into t1 values (2, 1, 2, 'def'); +insert into t1 values (3, 1, 2, 'def'); +insert into t2 values (1, 'A1', 1); +insert into t3 values (1, '1980-01-01'); +SELECT a.f3, cr.f4, count(*) count +FROM t2 a +STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1 +LEFT JOIN +(t1 cr2 +JOIN t3 ae2 ON cr2.f3 = ae2.f1 +) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND +cr.f4 = cr2.f4 +GROUP BY a.f3, cr.f4; +f3 f4 count +1 abc 1 +1 def 2 +drop table t1, t2, t3; +CREATE TABLE t1 (a INT KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2 +EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2 +DROP TABLE t1; +# +# Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when +# forcing a spatial index +# +CREATE TABLE t1(a LINESTRING NOT NULL, SPATIAL KEY(a)); +INSERT INTO t1 VALUES +(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), +(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 +1 SIMPLE t2 ALL a NULL NULL NULL 2 +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +1 +1 +1 +1 +1 +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 +1 SIMPLE t2 ALL a NULL NULL NULL 2 +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +1 +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #48291 : crash with row() operator,select into @var, and +# subquery returning multiple rows +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (2),(3); +# Should not crash +SELECT 1 FROM t1 WHERE a <> 1 AND NOT +ROW(a,a) <=> ROW((SELECT 1 FROM t1 WHERE 1=2),(SELECT 1 FROM t1)) +INTO @var0; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #48458: simple query tries to allocate enormous amount of +# memory +# +CREATE TABLE t1(a INT NOT NULL, b YEAR); +INSERT INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +CREATE TABLE t2(c INT); +# Should not err out because of out-of-memory +SELECT 1 FROM t2 JOIN t1 ON 1=1 +WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a); +1 +DROP TABLE t1,t2; +# +# Bug #49199: Optimizer handles incorrectly: +# field='const1' AND field='const2' in some cases + +CREATE TABLE t1(a DATETIME NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select '2001-01-01 00:00:00' AS `a` from `test`.`t1` where 1 +DROP TABLE t1; +CREATE TABLE t1(a DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select '2001-01-01' AS `a` from `test`.`t1` where 1 +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select '2001-01-01 00:00:00' AS `a` from `test`.`t1` where 1 +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select '2001-01-01 00:00:00' AS `a`,'2001-01-01' AS `b` from `test`.`t1` where 1 +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b VARCHAR(20) NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +Warnings: +Note 1003 select '2001-01-01 00:00:00' AS `a`,'2001-01-01' AS `b` from `test`.`t1` where 0 +SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select '2001-01-01 00:00:00' AS `a`,'2001-01-01' AS `b` from `test`.`t1` where 1 +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +a a a +2001-01-01 00:00:00 2001-01-01 00:00:00 2001-01-01 00:00:00 +EXPLAIN EXTENDED SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x system NULL NULL NULL NULL 1 100.00 +1 SIMPLE y system NULL NULL NULL NULL 1 100.00 +1 SIMPLE z system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select '2001-01-01 00:00:00' AS `a`,'2001-01-01 00:00:00' AS `a`,'2001-01-01 00:00:00' AS `a` from `test`.`t1` `x` join `test`.`t1` `y` join `test`.`t1` `z` where 1 +DROP TABLE t1; +# +# Bug #49897: crash in ptr_compare when char(0) NOT NULL +# column is used for ORDER BY +# +SET @old_sort_buffer_size= @@session.sort_buffer_size; +SET @@sort_buffer_size= 40000; +CREATE TABLE t1(a CHAR(0) NOT NULL); +INSERT INTO t1 VALUES (0), (0), (0); +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +EXPLAIN SELECT a FROM t1 ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 24492 +SELECT a FROM t1 ORDER BY a; +DROP TABLE t1; +CREATE TABLE t1(a CHAR(0) NOT NULL, b CHAR(0) NOT NULL, c int); +INSERT INTO t1 VALUES (0, 0, 0), (0, 0, 2), (0, 0, 1); +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12; +EXPLAIN SELECT a FROM t1 ORDER BY a LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 24492 +SELECT a FROM t1 ORDER BY a LIMIT 5; +a + + + + + +EXPLAIN SELECT * FROM t1 ORDER BY a, b LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 24492 +SELECT * FROM t1 ORDER BY a, b LIMIT 5; +a b c + 0 + 2 + 1 + 0 + 2 +EXPLAIN SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 24492 Using filesort +SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +EXPLAIN SELECT * FROM t1 ORDER BY c, a LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 24492 Using filesort +SELECT * FROM t1 ORDER BY c, a LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +SET @@sort_buffer_size= @old_sort_buffer_size; +DROP TABLE t1; +End of 5.0 tests +create table t1(a INT, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SELECT a FROM t1 ORDER BY a LIMIT 2; +a +1 +2 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; +a +3 +4 +5 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; +a +3 +4 +5 +DROP TABLE t1; +CREATE TABLE A (date_key date); +CREATE TABLE C ( +pk int, +int_nokey int, +int_key int, +date_key date NOT NULL, +date_nokey date, +varchar_key varchar(1) +); +INSERT INTO C VALUES +(1,1,1,'0000-00-00',NULL,NULL), +(1,1,1,'0000-00-00',NULL,NULL); +SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C); +1 +SELECT COUNT(DISTINCT 1) FROM C +WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk; +COUNT(DISTINCT 1) +SELECT date_nokey FROM C +WHERE int_key IN (SELECT 1 FROM A) +HAVING date_nokey = '10:41:7' +ORDER BY date_key; +date_nokey +Warnings: +Warning 1292 Incorrect date value: '10:41:7' for column 'date_nokey' at row 1 +DROP TABLE A,C; +CREATE TABLE t1 (a INT NOT NULL, b INT); +INSERT INTO t1 VALUES (1, 1); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select '1' AS `a`,'1' AS `b` from `test`.`t1` where 1 +SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +a b +1 1 +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found +Warnings: +Note 1003 select NULL AS `a`,NULL AS `b`,NULL AS `c` from `test`.`t1` where 1 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found +Warnings: +Note 1003 select NULL AS `a`,NULL AS `b`,NULL AS `c` from `test`.`t1` where 1 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found +Warnings: +Note 1003 select NULL AS `a`,NULL AS `b`,NULL AS `c` from `test`.`t1` where 1 +DROP TABLE t1; +# +# Bug#45266: Uninitialized variable lead to an empty result. +# +drop table if exists A,AA,B,BB; +CREATE TABLE `A` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`datetime_key` datetime NOT NULL, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`) +); +CREATE TABLE `AA` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +KEY `time_key` (`time_key`), +PRIMARY KEY (`pk`) +); +CREATE TABLE `B` ( +`date_nokey` date NOT NULL, +`date_key` date NOT NULL, +`time_key` time NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(1) NOT NULL, +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +); +INSERT INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x'); +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`date_key` date NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +`date_nokey` date NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`) +); +INSERT INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18'); +SELECT table1 . `pk` AS field1 +FROM +(BB AS table1 INNER JOIN +(AA AS table2 STRAIGHT_JOIN A AS table3 +ON ( table3 . `date_key` = table2 . `pk` )) +ON ( table3 . `datetime_key` = table2 . `int_nokey` )) +WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`) +GROUP BY field1 ; +field1 +SELECT table3 .`date_key` field1 +FROM +B table1 LEFT JOIN B table3 JOIN +(BB table6 JOIN A table7 ON table6 .`varchar_nokey`) +ON table6 .`int_nokey` ON table6 .`date_key` + WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1; +field1 +NULL +SELECT table4 . `time_nokey` AS field1 FROM +(AA AS table1 CROSS JOIN +(AA AS table2 STRAIGHT_JOIN +(B AS table3 STRAIGHT_JOIN A AS table4 +ON ( table4 . `date_key` = table3 . `time_key` )) +ON ( table4 . `pk` = table3 . `date_nokey` )) +ON ( table4 . `time_key` = table3 . `datetime_nokey` )) +WHERE ( table4 . `time_key` < table1 . `time_key` AND +table1 . `int_nokey` != 'f') +GROUP BY field1 ORDER BY field1 , field1; +field1 +SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +field2 +00:05:48 +15:13:38 +drop table A,AA,B,BB; +#end of test for bug#45266 +# +# BUG#48052: Valgrind warning - uninitialized value in init_read_record() +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +i int(11) DEFAULT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (2,7,'m'); +INSERT INTO t1 VALUES (3,9,'m'); +SELECT v +FROM t1 +WHERE NOT pk > 0 +HAVING v <= 't' +ORDER BY pk; +v +DROP TABLE t1; +# +# Bug#49489 Uninitialized cache led to a wrong result. +# +CREATE TABLE t1(c1 DOUBLE(5,4)); +INSERT INTO t1 VALUES (9.1234); +SELECT * FROM t1 WHERE c1 < 9.12345; +c1 +9.1234 +DROP TABLE t1; +# End of test for bug#49489. +# +# Bug #49517: Inconsistent behavior while using +# NULLable BIGINT and INT columns in comparison +# +CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL); +INSERT INTO t1 VALUES(105, NULL, NULL); +SELECT * FROM t1 WHERE b < 102; +a b c +SELECT * FROM t1 WHERE c < 102; +a b c +SELECT * FROM t1 WHERE 102 < b; +a b c +SELECT * FROM t1 WHERE 102 < c; +a b c +DROP TABLE t1; +# +# Bug #54459: Assertion failed: param.sort_length, +# file .\filesort.cc, line 149 (part II) +# +CREATE TABLE t1(a ENUM('') NOT NULL); +INSERT INTO t1 VALUES (), (), (); +EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +1 +1 +1 +1 +DROP TABLE t1; +End of 5.1 tests diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 2180a23b91a..72079ee03a0 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -6940,9 +6940,8 @@ create procedure p() begin end; call p(); select @@sql_mode; @@sql_mode -REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,?,ONLY_FULL_GROUP_BY,NO_UNSIGNED_SUBTRACTION,NO_DIR_IN_CREATE,POSTGRESQL,ORACLE,MSSQL,DB2,MAXDB,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,MYSQL323,MYSQL40,ANSI,NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,HIGH_NOT_PRECEDENCE,NO_ENGINE_SUBSTITUTION,PAD_CHAR_TO_FULL_LENGTH +REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,IGNORE_BAD_TABLE_OPTIONS,ONLY_FULL_GROUP_BY,NO_UNSIGNED_SUBTRACTION,NO_DIR_IN_CREATE,POSTGRESQL,ORACLE,MSSQL,DB2,MAXDB,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,MYSQL323,MYSQL40,ANSI,NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,HIGH_NOT_PRECEDENCE,NO_ENGINE_SUBSTITUTION,PAD_CHAR_TO_FULL_LENGTH set @@sql_mode= @old_mode; -select replace(@full_mode, '?', 'NOT_USED') into @full_mode; select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode; select name from mysql.proc where name = 'p' and sql_mode = @full_mode; name diff --git a/mysql-test/r/sp_notembedded.result b/mysql-test/r/sp_notembedded.result index b21395d9623..880531f4b47 100644 --- a/mysql-test/r/sp_notembedded.result +++ b/mysql-test/r/sp_notembedded.result @@ -191,6 +191,8 @@ max_updates, max_connections, max_user_connections) VALUES('%', 'mysqltest_1', password(''), 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'N', '', '', '', '', '0', '0', '0', '0'); +Warnings: +Warning 1364 Field 'auth_string' doesn't have a default value FLUSH PRIVILEGES; CREATE PROCEDURE p1(i INT) BEGIN END; DROP PROCEDURE p1; diff --git a/mysql-test/r/status_user.result b/mysql-test/r/status_user.result new file mode 100644 index 00000000000..636eeabfffc --- /dev/null +++ b/mysql-test/r/status_user.result @@ -0,0 +1,186 @@ +DROP TABLE IF EXISTS t1; +select variable_value from information_schema.global_status where variable_name="handler_read_key" into @global_read_key; +show columns from information_schema.client_statistics; +Field Type Null Key Default Extra +CLIENT varchar(64) NO +TOTAL_CONNECTIONS bigint(21) NO 0 +CONCURRENT_CONNECTIONS bigint(21) NO 0 +CONNECTED_TIME bigint(21) NO 0 +BUSY_TIME double NO 0 +CPU_TIME double NO 0 +BYTES_RECEIVED bigint(21) NO 0 +BYTES_SENT bigint(21) NO 0 +BINLOG_BYTES_WRITTEN bigint(21) NO 0 +ROWS_READ bigint(21) NO 0 +ROWS_SENT bigint(21) NO 0 +ROWS_DELETED bigint(21) NO 0 +ROWS_INSERTED bigint(21) NO 0 +ROWS_UPDATED bigint(21) NO 0 +SELECT_COMMANDS bigint(21) NO 0 +UPDATE_COMMANDS bigint(21) NO 0 +OTHER_COMMANDS bigint(21) NO 0 +COMMIT_TRANSACTIONS bigint(21) NO 0 +ROLLBACK_TRANSACTIONS bigint(21) NO 0 +DENIED_CONNECTIONS bigint(21) NO 0 +LOST_CONNECTIONS bigint(21) NO 0 +ACCESS_DENIED bigint(21) NO 0 +EMPTY_QUERIES bigint(21) NO 0 +show columns from information_schema.user_statistics; +Field Type Null Key Default Extra +USER varchar(48) NO +TOTAL_CONNECTIONS int(11) NO 0 +CONCURRENT_CONNECTIONS int(11) NO 0 +CONNECTED_TIME int(11) NO 0 +BUSY_TIME double NO 0 +CPU_TIME double NO 0 +BYTES_RECEIVED bigint(21) NO 0 +BYTES_SENT bigint(21) NO 0 +BINLOG_BYTES_WRITTEN bigint(21) NO 0 +ROWS_READ bigint(21) NO 0 +ROWS_SENT bigint(21) NO 0 +ROWS_DELETED bigint(21) NO 0 +ROWS_INSERTED bigint(21) NO 0 +ROWS_UPDATED bigint(21) NO 0 +SELECT_COMMANDS bigint(21) NO 0 +UPDATE_COMMANDS bigint(21) NO 0 +OTHER_COMMANDS bigint(21) NO 0 +COMMIT_TRANSACTIONS bigint(21) NO 0 +ROLLBACK_TRANSACTIONS bigint(21) NO 0 +DENIED_CONNECTIONS bigint(21) NO 0 +LOST_CONNECTIONS bigint(21) NO 0 +ACCESS_DENIED bigint(21) NO 0 +EMPTY_QUERIES bigint(21) NO 0 +show columns from information_schema.index_statistics; +Field Type Null Key Default Extra +TABLE_SCHEMA varchar(192) NO +TABLE_NAME varchar(192) NO +INDEX_NAME varchar(192) NO +ROWS_READ bigint(21) NO 0 +show columns from information_schema.table_statistics; +Field Type Null Key Default Extra +TABLE_SCHEMA varchar(192) NO +TABLE_NAME varchar(192) NO +ROWS_READ bigint(21) NO 0 +ROWS_CHANGED bigint(21) NO 0 +ROWS_CHANGED_X_INDEXES bigint(21) NO 0 +set @save_general_log=@@global.general_log; +set @@global.general_log=0; +set @@global.userstat=1; +flush status; +create table t1 (a int, primary key (a), b int default 0) engine=innodb; +insert into t1 (a) values (1),(2),(3),(4); +update t1 set b=1; +update t1 set b=5 where a=2; +delete from t1 where a=3; +/* Empty query */ +select * from t1 where a=999; +a b +drop table t1; +create table t1 (a int, primary key (a), b int default 0) engine=innodb; +begin; +insert into t1 values(1,1); +commit; +begin; +insert into t1 values(2,2); +commit; +begin; +insert into t1 values(3,3); +rollback; +drop table t1; +select sleep(1); +sleep(1) +0 +show status like "rows%"; +Variable_name Value +Rows_read 6 +Rows_sent 1 +show status like "ha%"; +Variable_name Value +Handler_commit 19 +Handler_delete 1 +Handler_discover 0 +Handler_prepare 18 +Handler_read_first 0 +Handler_read_key 3 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 5 +Handler_rollback 2 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 5 +Handler_write 7 +select variable_value - @global_read_key as "handler_read_key" from information_schema.global_status where variable_name="handler_read_key"; +handler_read_key +3 +set @@global.userstat=0; +select * from information_schema.index_statistics; +TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ +test t1 PRIMARY 2 +select * from information_schema.table_statistics; +TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES +test t1 6 13 13 +show table_statistics; +Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes +test t1 6 13 13 +show index_statistics; +Table_schema Table_name Index_name Rows_read +test t1 PRIMARY 2 +select TOTAL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics;; +TOTAL_CONNECTIONS 1 +CONCURRENT_CONNECTIONS 0 +ROWS_READ 6 +ROWS_SENT 2 +ROWS_DELETED 1 +ROWS_INSERTED 8 +ROWS_UPDATED 5 +SELECT_COMMANDS 3 +UPDATE_COMMANDS 11 +OTHER_COMMANDS 7 +COMMIT_TRANSACTIONS 19 +ROLLBACK_TRANSACTIONS 2 +DENIED_CONNECTIONS 0 +LOST_CONNECTIONS 0 +ACCESS_DENIED 0 +EMPTY_QUERIES 1 +select TOTAL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics;; +TOTAL_CONNECTIONS 1 +CONCURRENT_CONNECTIONS 0 +ROWS_READ 6 +ROWS_SENT 2 +ROWS_DELETED 1 +ROWS_INSERTED 8 +ROWS_UPDATED 5 +SELECT_COMMANDS 3 +UPDATE_COMMANDS 11 +OTHER_COMMANDS 7 +COMMIT_TRANSACTIONS 19 +ROLLBACK_TRANSACTIONS 2 +DENIED_CONNECTIONS 0 +LOST_CONNECTIONS 0 +ACCESS_DENIED 0 +EMPTY_QUERIES 1 +flush table_statistics; +flush index_statistics; +select * from information_schema.index_statistics; +TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ +select * from information_schema.table_statistics; +TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES +show status like "%statistics%"; +Variable_name Value +Com_show_client_statistics 0 +Com_show_index_statistics 1 +Com_show_table_statistics 1 +Com_show_user_statistics 0 +select connected_time <> 0, busy_time <> 0, bytes_received <> 0, +bytes_sent <> 0, binlog_bytes_written <> 0 +from information_schema.user_statistics; +connected_time <> 0 busy_time <> 0 bytes_received <> 0 bytes_sent <> 0 binlog_bytes_written <> 0 +1 1 1 1 1 +select connected_time <> 0, busy_time <> 0, bytes_received <> 0, +bytes_sent <> 0, binlog_bytes_written <> 0 +from information_schema.client_statistics; +connected_time <> 0 busy_time <> 0 bytes_received <> 0 bytes_sent <> 0 binlog_bytes_written <> 0 +1 1 1 1 1 +set @@global.general_log=@save_general_log; diff --git a/mysql-test/r/system_mysql_db.result b/mysql-test/r/system_mysql_db.result index 17fd95ab1c8..aa407b25401 100644 --- a/mysql-test/r/system_mysql_db.result +++ b/mysql-test/r/system_mysql_db.result @@ -118,6 +118,8 @@ user CREATE TABLE `user` ( `max_updates` int(11) unsigned NOT NULL DEFAULT '0', `max_connections` int(11) unsigned NOT NULL DEFAULT '0', `max_user_connections` int(11) unsigned NOT NULL DEFAULT '0', + `plugin` char(60) CHARACTER SET latin1 NOT NULL DEFAULT '', + `auth_string` text COLLATE utf8_bin NOT NULL, PRIMARY KEY (`Host`,`User`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Users and global privileges' show create table func; @@ -200,7 +202,7 @@ proc CREATE TABLE `proc` ( `definer` char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', - `sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') NOT NULL DEFAULT '', + `sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') NOT NULL DEFAULT '', `comment` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `character_set_client` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `collation_connection` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, @@ -225,7 +227,7 @@ event CREATE TABLE `event` ( `ends` datetime DEFAULT NULL, `status` enum('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL DEFAULT 'ENABLED', `on_completion` enum('DROP','PRESERVE') NOT NULL DEFAULT 'DROP', - `sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') NOT NULL DEFAULT '', + `sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') NOT NULL DEFAULT '', `comment` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `originator` int(10) unsigned NOT NULL, `time_zone` char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', diff --git a/mysql-test/r/table_options.result b/mysql-test/r/table_options.result new file mode 100644 index 00000000000..ed6fe4fb3de --- /dev/null +++ b/mysql-test/r/table_options.result @@ -0,0 +1,182 @@ +drop table if exists t1; +SET @OLD_SQL_MODE=@@SQL_MODE; +SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS'; +create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1='1v1'; +Warnings: +Warning 1651 Unknown option 'fkey' +Warning 1651 Unknown option 'dff' +Warning 1651 Unknown option 'tkey1' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `fkey`=vvv, + KEY `akey` (`a`) `dff`=vvv +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey1`='1v1' +drop table t1; +#reassiginig options in the same line +create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1=1v1 TKEY1=DEFAULT tkey1=1v2 tkey2=2v1; +Warnings: +Warning 1651 Unknown option 'fkey' +Warning 1651 Unknown option 'dff' +Warning 1651 Unknown option 'tkey1' +Warning 1651 Unknown option 'tkey2' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `fkey`=vvv, + KEY `akey` (`a`) `dff`=vvv +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey1`=1v2 `tkey2`=2v1 +#add option +alter table t1 tkey4=4v1; +Warnings: +Warning 1651 Unknown option 'tkey4' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `fkey`=vvv, + KEY `akey` (`a`) `dff`=vvv +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey1`=1v2 `tkey2`=2v1 `tkey4`=4v1 +#remove options +alter table t1 tkey3=DEFAULT tkey4=DEFAULT; +Warnings: +Warning 1651 Unknown option 'tkey3' +Warning 1651 Unknown option 'tkey4' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `fkey`=vvv, + KEY `akey` (`a`) `dff`=vvv +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey1`=1v2 `tkey2`=2v1 +drop table t1; +create table t1 (a int fkey1=v1, key akey (a) kkey1=v1) tkey1=1v1 tkey1=1v2 TKEY1=DEFAULT tkey2=2v1 tkey3=3v1; +Warnings: +Warning 1651 Unknown option 'fkey1' +Warning 1651 Unknown option 'kkey1' +Warning 1651 Unknown option 'TKEY1' +Warning 1651 Unknown option 'tkey2' +Warning 1651 Unknown option 'tkey3' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `fkey1`=v1, + KEY `akey` (`a`) `kkey1`=v1 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey2`=2v1 `tkey3`=3v1 +#change field with option with the same value +alter table t1 change a a int `FKEY1`='v1'; +Warnings: +Warning 1651 Unknown option 'FKEY1' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `FKEY1`='v1', + KEY `akey` (`a`) `kkey1`=v1 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey2`=2v1 `tkey3`=3v1 +#change field with option with a different value +alter table t1 change a a int fkey1=v2; +Warnings: +Warning 1651 Unknown option 'fkey1' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `fkey1`=v2, + KEY `akey` (`a`) `kkey1`=v1 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey2`=2v1 `tkey3`=3v1 +#new column no options +alter table t1 add column b int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `fkey1`=v2, + `b` int(11) DEFAULT NULL, + KEY `akey` (`a`) `kkey1`=v1 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey2`=2v1 `tkey3`=3v1 +#new key with options +alter table t1 add key bkey (b) kkey2=v1; +Warnings: +Warning 1651 Unknown option 'kkey2' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `fkey1`=v2, + `b` int(11) DEFAULT NULL, + KEY `akey` (`a`) `kkey1`=v1, + KEY `bkey` (`b`) `kkey2`=v1 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey2`=2v1 `tkey3`=3v1 +#new column with options +alter table t1 add column c int fkey1=v1 fkey2=v2; +Warnings: +Warning 1651 Unknown option 'fkey1' +Warning 1651 Unknown option 'fkey2' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `fkey1`=v2, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL `fkey1`=v1 `fkey2`=v2, + KEY `akey` (`a`) `kkey1`=v1, + KEY `bkey` (`b`) `kkey2`=v1 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey2`=2v1 `tkey3`=3v1 +#new key no options +alter table t1 add key ckey (c); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `fkey1`=v2, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL `fkey1`=v1 `fkey2`=v2, + KEY `akey` (`a`) `kkey1`=v1, + KEY `bkey` (`b`) `kkey2`=v1, + KEY `ckey` (`c`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey2`=2v1 `tkey3`=3v1 +#drop column +alter table t1 drop b; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `fkey1`=v2, + `c` int(11) DEFAULT NULL `fkey1`=v1 `fkey2`=v2, + KEY `akey` (`a`) `kkey1`=v1, + KEY `ckey` (`c`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey2`=2v1 `tkey3`=3v1 +#add column with options after delete +alter table t1 add column b int fkey2=v1; +Warnings: +Warning 1651 Unknown option 'fkey2' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `fkey1`=v2, + `c` int(11) DEFAULT NULL `fkey1`=v1 `fkey2`=v2, + `b` int(11) DEFAULT NULL `fkey2`=v1, + KEY `akey` (`a`) `kkey1`=v1, + KEY `ckey` (`c`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey2`=2v1 `tkey3`=3v1 +#add key +alter table t1 add key bkey (b) kkey2=v2; +Warnings: +Warning 1651 Unknown option 'kkey2' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL `fkey1`=v2, + `c` int(11) DEFAULT NULL `fkey1`=v1 `fkey2`=v2, + `b` int(11) DEFAULT NULL `fkey2`=v1, + KEY `akey` (`a`) `kkey1`=v1, + KEY `ckey` (`c`), + KEY `bkey` (`b`) `kkey2`=v2 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey2`=2v1 `tkey3`=3v1 +drop table t1; +create table t1 (a int) tkey1=100; +Warnings: +Warning 1651 Unknown option 'tkey1' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `tkey1`=100 +drop table t1; +#error on unknown option +SET SQL_MODE=''; +create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1=1v1; +ERROR HY000: Unknown option 'fkey' +SET @@SQL_MODE=@OLD_SQL_MODE; diff --git a/mysql-test/std_data/loaddata7.dat b/mysql-test/std_data/loaddata7.dat new file mode 100644 index 00000000000..e86d1621bd4 --- /dev/null +++ b/mysql-test/std_data/loaddata7.dat @@ -0,0 +1,5 @@ +2,2
+3,3
+4,4
+5,5
+6,6
\ No newline at end of file diff --git a/mysql-test/suite/binlog/r/binlog_index.result b/mysql-test/suite/binlog/r/binlog_index.result index 01a41b55125..e2688a15899 100644 --- a/mysql-test/suite/binlog/r/binlog_index.result +++ b/mysql-test/suite/binlog/r/binlog_index.result @@ -13,6 +13,7 @@ master-bin.000001 # master-bin.000002 # master-bin.000003 # master-bin.000004 # +flush tables; purge binary logs TO 'master-bin.000004'; Warnings: Warning 1612 Being purged log master-bin.000001 was not found diff --git a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result new file mode 100644 index 00000000000..5a6fbc953b4 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result @@ -0,0 +1,416 @@ +DROP DATABASE IF EXISTS test1; +DROP DATABASE IF EXISTS test2; +DROP DATABASE IF EXISTS test3; +CREATE DATABASE test1; +CREATE DATABASE test2; +CREATE DATABASE test3; +SET timestamp=1000000000; +RESET MASTER; +USE test1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,2); +USE test2; +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1),(2); +DELETE FROM test1.t1 WHERE a=1; +USE test3; +CREATE TABLE t3 (a INT); +INSERT INTO t3 VALUES (1),(2); +INSERT INTO test1.t1 VALUES (3,3); +USE test1; +LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE t1 +FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n'; +DELETE FROM test3.t3 WHERE a=1; +flush logs; +# +# mysqlbinlog output +# --base64-output = decode-rows +# --rewrite-db = test1->new_test1 +# --rewrite-db = test3->new_test3 +# +/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; +DELIMITER /*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup +ROLLBACK/*!*/; +# at # +use new_test1/*!*/; +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +SET @@session.pseudo_thread_id=#/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.sql_mode=0/*!*/; +SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; +/*!\C latin1 *//*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.lc_time_names=0/*!*/; +SET @@session.collation_database=DEFAULT/*!*/; +CREATE TABLE t1 (a INT, b INT) +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `new_test1`.`t1` mapped to number # +#010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO new_test1.t1 +### SET +### @1=1 /* INT meta=0 nullable=1 is_null=0 */ +### @2=1 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO new_test1.t1 +### SET +### @1=2 /* INT meta=0 nullable=1 is_null=0 */ +### @2=2 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +use test2/*!*/; +SET TIMESTAMP=1000000000/*!*/; +CREATE TABLE t2 (a INT) +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `test2`.`t2` mapped to number # +#010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO test2.t2 +### SET +### @1=1 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO test2.t2 +### SET +### @1=2 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `new_test1`.`t1` mapped to number # +#010909 4:46:40 server id # end_log_pos # Delete_rows: table id # flags: STMT_END_F +### DELETE FROM new_test1.t1 +### WHERE +### @1=1 /* INT meta=0 nullable=1 is_null=0 */ +### @2=1 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +use new_test3/*!*/; +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +CREATE TABLE t3 (a INT) +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `new_test3`.`t3` mapped to number # +#010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO new_test3.t3 +### SET +### @1=1 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO new_test3.t3 +### SET +### @1=2 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `new_test1`.`t1` mapped to number # +#010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO new_test1.t1 +### SET +### @1=3 /* INT meta=0 nullable=1 is_null=0 */ +### @2=3 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +use new_test1/*!*/; +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `new_test1`.`t1` mapped to number # +#010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO new_test1.t1 +### SET +### @1=2 /* INT meta=0 nullable=1 is_null=0 */ +### @2=2 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO new_test1.t1 +### SET +### @1=3 /* INT meta=0 nullable=1 is_null=0 */ +### @2=3 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO new_test1.t1 +### SET +### @1=4 /* INT meta=0 nullable=1 is_null=0 */ +### @2=4 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO new_test1.t1 +### SET +### @1=5 /* INT meta=0 nullable=1 is_null=0 */ +### @2=5 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO new_test1.t1 +### SET +### @1=6 /* INT meta=0 nullable=1 is_null=0 */ +### @2=6 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `new_test3`.`t3` mapped to number # +#010909 4:46:40 server id # end_log_pos # Delete_rows: table id # flags: STMT_END_F +### DELETE FROM new_test3.t3 +### WHERE +### @1=1 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Rotate to master-bin.000002 pos: 4 +DELIMITER ; +# End of log file +ROLLBACK /* added by mysqlbinlog */; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; +# +# mysqlbinlog output +# --base64-output = decode-rows +# --rewrite-db = test1->new_test1 +# --rewrite-db = test3->new_test3 +# --read-from-remote-server +# +/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; +DELIMITER /*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup +ROLLBACK/*!*/; +# at # +use new_test1/*!*/; +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +SET @@session.pseudo_thread_id=#/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.sql_mode=0/*!*/; +SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; +/*!\C latin1 *//*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.lc_time_names=0/*!*/; +SET @@session.collation_database=DEFAULT/*!*/; +CREATE TABLE t1 (a INT, b INT) +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `new_test1`.`t1` mapped to number # +#010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO new_test1.t1 +### SET +### @1=1 /* INT meta=0 nullable=1 is_null=0 */ +### @2=1 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO new_test1.t1 +### SET +### @1=2 /* INT meta=0 nullable=1 is_null=0 */ +### @2=2 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +use test2/*!*/; +SET TIMESTAMP=1000000000/*!*/; +CREATE TABLE t2 (a INT) +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `test2`.`t2` mapped to number # +#010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO test2.t2 +### SET +### @1=1 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO test2.t2 +### SET +### @1=2 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `new_test1`.`t1` mapped to number # +#010909 4:46:40 server id # end_log_pos # Delete_rows: table id # flags: STMT_END_F +### DELETE FROM new_test1.t1 +### WHERE +### @1=1 /* INT meta=0 nullable=1 is_null=0 */ +### @2=1 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +use new_test3/*!*/; +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +CREATE TABLE t3 (a INT) +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `new_test3`.`t3` mapped to number # +#010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO new_test3.t3 +### SET +### @1=1 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO new_test3.t3 +### SET +### @1=2 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `new_test1`.`t1` mapped to number # +#010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO new_test1.t1 +### SET +### @1=3 /* INT meta=0 nullable=1 is_null=0 */ +### @2=3 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +use new_test1/*!*/; +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `new_test1`.`t1` mapped to number # +#010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO new_test1.t1 +### SET +### @1=2 /* INT meta=0 nullable=1 is_null=0 */ +### @2=2 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO new_test1.t1 +### SET +### @1=3 /* INT meta=0 nullable=1 is_null=0 */ +### @2=3 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO new_test1.t1 +### SET +### @1=4 /* INT meta=0 nullable=1 is_null=0 */ +### @2=4 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO new_test1.t1 +### SET +### @1=5 /* INT meta=0 nullable=1 is_null=0 */ +### @2=5 /* INT meta=0 nullable=1 is_null=0 */ +### INSERT INTO new_test1.t1 +### SET +### @1=6 /* INT meta=0 nullable=1 is_null=0 */ +### @2=6 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id # end_log_pos # Table_map: `new_test3`.`t3` mapped to number # +#010909 4:46:40 server id # end_log_pos # Delete_rows: table id # flags: STMT_END_F +### DELETE FROM new_test3.t3 +### WHERE +### @1=1 /* INT meta=0 nullable=1 is_null=0 */ +# at # +#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # Rotate to master-bin.000002 pos: 4 +DELIMITER ; +# End of log file +ROLLBACK /* added by mysqlbinlog */; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; +DROP DATABASE test1; +DROP DATABASE test2; +DROP DATABASE test3; diff --git a/mysql-test/suite/binlog/t/binlog_index.test b/mysql-test/suite/binlog/t/binlog_index.test index 94923275a5f..3847e40aeb2 100644 --- a/mysql-test/suite/binlog/t/binlog_index.test +++ b/mysql-test/suite/binlog/t/binlog_index.test @@ -28,6 +28,7 @@ flush logs; source include/show_binary_logs.inc; remove_file $MYSQLD_DATADIR/master-bin.000001; +flush tables; # there must be a warning with file names replace_regex /\.[\\\/]master/master/; diff --git a/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_options-master.opt b/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_options-master.opt new file mode 100644 index 00000000000..4d69f3359db --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_options-master.opt @@ -0,0 +1 @@ +--timezone=GMT-3 diff --git a/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_options.test b/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_options.test new file mode 100644 index 00000000000..c1756b22eab --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_options.test @@ -0,0 +1,78 @@ +--source include/have_log_bin.inc +--source include/have_binlog_format_row.inc + +# +# MWL36: Add a mysqlbinlog option to change the used database +# (Adding --rewrite-db option) +# +--disable_warnings +DROP DATABASE IF EXISTS test1; +DROP DATABASE IF EXISTS test2; +DROP DATABASE IF EXISTS test3; +--enable_warnings + +# For SBR --rewrite-db affects only default database and doesn't affect +# a query (specifically CREATE DATABASE) itself. Hence (for testing +# purpose) we start binary logging after all databases have been created. + +CREATE DATABASE test1; +CREATE DATABASE test2; +CREATE DATABASE test3; + +# Fix timestamp to avoid varying results. +SET timestamp=1000000000; + +# Delete all existing binary logs. +RESET MASTER; + +# Whe'll call mysqlbinlog with two rewrite rules: +# --rewrite-db="test1->new_test1" +# --rewrite-db="test3->new_test3" + +USE test1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,2); + +USE test2; +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1),(2); + +DELETE FROM test1.t1 WHERE a=1; + +USE test3; +CREATE TABLE t3 (a INT); +INSERT INTO t3 VALUES (1),(2); +INSERT INTO test1.t1 VALUES (3,3); + +USE test1; +LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE t1
+ FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
+DELETE FROM test3.t3 WHERE a=1; + +flush logs; + +--echo # +--echo # mysqlbinlog output +--echo # --base64-output = decode-rows +--echo # --rewrite-db = test1->new_test1 +--echo # --rewrite-db = test3->new_test3 +--echo # + +let $MYSQLD_DATADIR= `select @@datadir`; +--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ +--exec $MYSQL_BINLOG --base64-output=decode-rows --rewrite-db="test1->new_test1" --rewrite-db="test3->new_test3" -v -v $MYSQLD_DATADIR/master-bin.000001 + +--echo # +--echo # mysqlbinlog output +--echo # --base64-output = decode-rows +--echo # --rewrite-db = test1->new_test1 +--echo # --rewrite-db = test3->new_test3 +--echo # --read-from-remote-server +--echo # + +--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ +--exec $MYSQL_BINLOG --base64-output=decode-rows --rewrite-db="test1->new_test1" --rewrite-db="test3->new_test3" -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001 + +DROP DATABASE test1; +DROP DATABASE test2; +DROP DATABASE test3; diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index b1578b552bc..89c0d29016f 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -7,6 +7,29 @@ NULL information_schema CHARACTER_SETS CHARACTER_SET_NAME 1 NO varchar 32 96 NU NULL information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME 2 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select NULL information_schema CHARACTER_SETS DESCRIPTION 3 NO varchar 60 180 NULL NULL utf8 utf8_general_ci varchar(60) select NULL information_schema CHARACTER_SETS MAXLEN 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(3) select +NULL information_schema CLIENT_STATISTICS ACCESS_DENIED 22 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL double select +NULL information_schema CLIENT_STATISTICS BYTES_RECEIVED 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS BYTES_SENT 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS CLIENT 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select +NULL information_schema CLIENT_STATISTICS COMMIT_TRANSACTIONS 18 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS CONCURRENT_CONNECTIONS 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS CONNECTED_TIME 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS CPU_TIME 6 0 NO double NULL NULL 21 NULL NULL NULL double select +NULL information_schema CLIENT_STATISTICS DENIED_CONNECTIONS 20 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS EMPTY_QUERIES 23 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS LOST_CONNECTIONS 21 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS OTHER_COMMANDS 17 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS ROLLBACK_TRANSACTIONS 19 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS ROWS_DELETED 12 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS ROWS_INSERTED 13 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS ROWS_READ 10 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS ROWS_SENT 11 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS ROWS_UPDATED 14 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS SELECT_COMMANDS 15 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS TOTAL_CONNECTIONS 2 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema CLIENT_STATISTICS UPDATE_COMMANDS 16 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select NULL information_schema COLLATIONS CHARACTER_SET_NAME 2 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select NULL information_schema COLLATIONS COLLATION_NAME 1 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select NULL information_schema COLLATIONS ID 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(11) select @@ -113,6 +136,10 @@ NULL information_schema GLOBAL_STATUS VARIABLE_NAME 1 NO varchar 64 192 NULL NU NULL information_schema GLOBAL_STATUS VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select NULL information_schema GLOBAL_VARIABLES VARIABLE_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema GLOBAL_VARIABLES VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select +NULL information_schema INDEX_STATISTICS INDEX_NAME 3 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select +NULL information_schema INDEX_STATISTICS ROWS_READ 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema INDEX_STATISTICS TABLE_NAME 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select +NULL information_schema INDEX_STATISTICS TABLE_SCHEMA 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select NULL information_schema INNODB_BUFFER_POOL_PAGES fix_count 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_BUFFER_POOL_PAGES flush_type 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_BUFFER_POOL_PAGES lru_position 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select @@ -221,6 +248,18 @@ NULL information_schema INNODB_TRX trx_started 3 0000-00-00 00:00:00 NO datetime NULL information_schema INNODB_TRX trx_state 2 NO varchar 13 39 NULL NULL utf8 utf8_general_ci varchar(13) select NULL information_schema INNODB_TRX trx_wait_started 5 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select NULL information_schema INNODB_TRX trx_weight 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema KEY_CACHES BLOCK_SIZE 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema KEY_CACHES DIRTY_BLOCKS 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema KEY_CACHES FULL_SIZE 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema KEY_CACHES KEY_CACHE_NAME 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select +NULL information_schema KEY_CACHES READS 10 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema KEY_CACHES READ_REQUESTS 9 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema KEY_CACHES SEGMENTS 2 NULL YES int NULL NULL 10 0 NULL NULL int(3) unsigned select +NULL information_schema KEY_CACHES SEGMENT_NUMBER 3 NULL YES int NULL NULL 10 0 NULL NULL int(3) unsigned select +NULL information_schema KEY_CACHES UNUSED_BLOCKS 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema KEY_CACHES USED_BLOCKS 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema KEY_CACHES WRITES 12 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema KEY_CACHES WRITE_REQUESTS 11 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select NULL information_schema KEY_COLUMN_USAGE COLUMN_NAME 7 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select @@ -262,10 +301,12 @@ NULL information_schema PBXT_STATISTICS ID 1 0 NO int NULL NULL 10 0 NULL NULL i NULL information_schema PBXT_STATISTICS Name 2 NO varchar 40 120 NULL NULL utf8 utf8_general_ci varchar(40) select NULL information_schema PBXT_STATISTICS Value 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(8) select NULL information_schema PLUGINS PLUGIN_AUTHOR 8 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select +NULL information_schema PLUGINS PLUGIN_AUTH_VERSION 12 NULL YES varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema PLUGINS PLUGIN_DESCRIPTION 9 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema PLUGINS PLUGIN_LIBRARY 6 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema PLUGINS PLUGIN_LIBRARY_VERSION 7 NULL YES varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select NULL information_schema PLUGINS PLUGIN_LICENSE 10 NULL YES varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select +NULL information_schema PLUGINS PLUGIN_MATURITY 11 NULL YES varchar 12 36 NULL NULL utf8 utf8_general_ci varchar(12) select NULL information_schema PLUGINS PLUGIN_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema PLUGINS PLUGIN_STATUS 3 NO varchar 10 30 NULL NULL utf8 utf8_general_ci varchar(10) select NULL information_schema PLUGINS PLUGIN_TYPE 4 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select @@ -376,6 +417,11 @@ NULL information_schema TABLE_PRIVILEGES PRIVILEGE_TYPE 5 NO varchar 64 192 NUL NULL information_schema TABLE_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select NULL information_schema TABLE_PRIVILEGES TABLE_NAME 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema TABLE_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select +NULL information_schema TABLE_STATISTICS ROWS_CHANGED 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema TABLE_STATISTICS ROWS_CHANGED_X_INDEXES 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema TABLE_STATISTICS ROWS_READ 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema TABLE_STATISTICS TABLE_NAME 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select +NULL information_schema TABLE_STATISTICS TABLE_SCHEMA 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select NULL information_schema TRIGGERS ACTION_CONDITION 9 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema TRIGGERS ACTION_ORDER 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(4) select NULL information_schema TRIGGERS ACTION_ORIENTATION 11 NO varchar 9 27 NULL NULL utf8 utf8_general_ci varchar(9) select @@ -402,6 +448,29 @@ NULL information_schema USER_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL u NULL information_schema USER_PRIVILEGES IS_GRANTABLE 4 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select NULL information_schema USER_PRIVILEGES PRIVILEGE_TYPE 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema USER_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select +NULL information_schema USER_STATISTICS ACCESS_DENIED 22 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL double select +NULL information_schema USER_STATISTICS BYTES_RECEIVED 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS BYTES_SENT 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS COMMIT_TRANSACTIONS 18 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS CONCURRENT_CONNECTIONS 3 0 NO int NULL NULL 10 0 NULL NULL int(11) select +NULL information_schema USER_STATISTICS CONNECTED_TIME 4 0 NO int NULL NULL 10 0 NULL NULL int(11) select +NULL information_schema USER_STATISTICS CPU_TIME 6 0 NO double NULL NULL 21 NULL NULL NULL double select +NULL information_schema USER_STATISTICS DENIED_CONNECTIONS 20 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS EMPTY_QUERIES 23 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS LOST_CONNECTIONS 21 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS OTHER_COMMANDS 17 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS ROLLBACK_TRANSACTIONS 19 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS ROWS_DELETED 12 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS ROWS_INSERTED 13 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS ROWS_READ 10 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS ROWS_SENT 11 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS ROWS_UPDATED 14 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS SELECT_COMMANDS 15 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS TOTAL_CONNECTIONS 2 0 NO int NULL NULL 10 0 NULL NULL int(11) select +NULL information_schema USER_STATISTICS UPDATE_COMMANDS 16 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select +NULL information_schema USER_STATISTICS USER 1 NO varchar 48 144 NULL NULL utf8 utf8_general_ci varchar(48) select NULL information_schema VIEWS CHARACTER_SET_CLIENT 9 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select NULL information_schema VIEWS CHECK_OPTION 5 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8) select NULL information_schema VIEWS COLLATION_CONNECTION 10 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select @@ -458,6 +527,7 @@ COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME NULL bigint NULL NULL NULL datetime NULL NULL NULL decimal NULL NULL +NULL double NULL NULL NULL int NULL NULL --> CHAR(0) is allowed (see manual), and here both CHARACHTER_* values --> are 0, which is intended behavior, and the result of 0 / 0 IS NULL @@ -480,6 +550,29 @@ COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH C 3.0000 information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME varchar 32 96 utf8 utf8_general_ci varchar(32) 3.0000 information_schema CHARACTER_SETS DESCRIPTION varchar 60 180 utf8 utf8_general_ci varchar(60) NULL information_schema CHARACTER_SETS MAXLEN bigint NULL NULL NULL NULL bigint(3) +3.0000 information_schema CLIENT_STATISTICS CLIENT varchar 64 192 utf8 utf8_general_ci varchar(64) +NULL information_schema CLIENT_STATISTICS TOTAL_CONNECTIONS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS CONCURRENT_CONNECTIONS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS CONNECTED_TIME bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS BUSY_TIME double NULL NULL NULL NULL double +NULL information_schema CLIENT_STATISTICS CPU_TIME double NULL NULL NULL NULL double +NULL information_schema CLIENT_STATISTICS BYTES_RECEIVED bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS BYTES_SENT bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS BINLOG_BYTES_WRITTEN bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS ROWS_READ bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS ROWS_SENT bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS ROWS_DELETED bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS ROWS_INSERTED bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS ROWS_UPDATED bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS SELECT_COMMANDS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS UPDATE_COMMANDS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS OTHER_COMMANDS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS COMMIT_TRANSACTIONS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS ROLLBACK_TRANSACTIONS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS DENIED_CONNECTIONS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS LOST_CONNECTIONS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS ACCESS_DENIED bigint NULL NULL NULL NULL bigint(21) +NULL information_schema CLIENT_STATISTICS EMPTY_QUERIES bigint NULL NULL NULL NULL bigint(21) 3.0000 information_schema COLLATIONS COLLATION_NAME varchar 32 96 utf8 utf8_general_ci varchar(32) 3.0000 information_schema COLLATIONS CHARACTER_SET_NAME varchar 32 96 utf8 utf8_general_ci varchar(32) NULL information_schema COLLATIONS ID bigint NULL NULL NULL NULL bigint(11) @@ -586,6 +679,10 @@ NULL information_schema FILES CHECKSUM bigint NULL NULL NULL NULL bigint(21) uns 3.0000 information_schema GLOBAL_STATUS VARIABLE_VALUE varchar 1024 3072 utf8 utf8_general_ci varchar(1024) 3.0000 information_schema GLOBAL_VARIABLES VARIABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema GLOBAL_VARIABLES VARIABLE_VALUE varchar 1024 3072 utf8 utf8_general_ci varchar(1024) +3.0000 information_schema INDEX_STATISTICS TABLE_SCHEMA varchar 192 576 utf8 utf8_general_ci varchar(192) +3.0000 information_schema INDEX_STATISTICS TABLE_NAME varchar 192 576 utf8 utf8_general_ci varchar(192) +3.0000 information_schema INDEX_STATISTICS INDEX_NAME varchar 192 576 utf8 utf8_general_ci varchar(192) +NULL information_schema INDEX_STATISTICS ROWS_READ bigint NULL NULL NULL NULL bigint(21) 3.0000 information_schema INNODB_BUFFER_POOL_PAGES page_type varchar 64 192 utf8 utf8_general_ci varchar(64) NULL information_schema INNODB_BUFFER_POOL_PAGES space_id bigint NULL NULL NULL NULL bigint(21) unsigned NULL information_schema INNODB_BUFFER_POOL_PAGES page_no bigint NULL NULL NULL NULL bigint(21) unsigned @@ -694,6 +791,18 @@ NULL information_schema INNODB_TRX trx_wait_started datetime NULL NULL NULL NULL NULL information_schema INNODB_TRX trx_weight bigint NULL NULL NULL NULL bigint(21) unsigned NULL information_schema INNODB_TRX trx_mysql_thread_id bigint NULL NULL NULL NULL bigint(21) unsigned 3.0000 information_schema INNODB_TRX trx_query varchar 1024 3072 utf8 utf8_general_ci varchar(1024) +3.0000 information_schema KEY_CACHES KEY_CACHE_NAME varchar 192 576 utf8 utf8_general_ci varchar(192) +NULL information_schema KEY_CACHES SEGMENTS int NULL NULL NULL NULL int(3) unsigned +NULL information_schema KEY_CACHES SEGMENT_NUMBER int NULL NULL NULL NULL int(3) unsigned +NULL information_schema KEY_CACHES FULL_SIZE bigint NULL NULL NULL NULL bigint(21) unsigned +NULL information_schema KEY_CACHES BLOCK_SIZE bigint NULL NULL NULL NULL bigint(21) unsigned +NULL information_schema KEY_CACHES USED_BLOCKS bigint NULL NULL NULL NULL bigint(21) unsigned +NULL information_schema KEY_CACHES UNUSED_BLOCKS bigint NULL NULL NULL NULL bigint(21) unsigned +NULL information_schema KEY_CACHES DIRTY_BLOCKS bigint NULL NULL NULL NULL bigint(21) unsigned +NULL information_schema KEY_CACHES READ_REQUESTS bigint NULL NULL NULL NULL bigint(21) unsigned +NULL information_schema KEY_CACHES READS bigint NULL NULL NULL NULL bigint(21) unsigned +NULL information_schema KEY_CACHES WRITE_REQUESTS bigint NULL NULL NULL NULL bigint(21) unsigned +NULL information_schema KEY_CACHES WRITES bigint NULL NULL NULL NULL bigint(21) unsigned 3.0000 information_schema KEY_COLUMN_USAGE CONSTRAINT_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema KEY_COLUMN_USAGE CONSTRAINT_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema KEY_COLUMN_USAGE CONSTRAINT_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) @@ -744,6 +853,8 @@ NULL information_schema PBXT_STATISTICS Value bigint NULL NULL NULL NULL bigint( 3.0000 information_schema PLUGINS PLUGIN_AUTHOR varchar 64 192 utf8 utf8_general_ci varchar(64) 1.0000 information_schema PLUGINS PLUGIN_DESCRIPTION longtext 4294967295 4294967295 utf8 utf8_general_ci longtext 3.0000 information_schema PLUGINS PLUGIN_LICENSE varchar 80 240 utf8 utf8_general_ci varchar(80) +3.0000 information_schema PLUGINS PLUGIN_MATURITY varchar 12 36 utf8 utf8_general_ci varchar(12) +3.0000 information_schema PLUGINS PLUGIN_AUTH_VERSION varchar 80 240 utf8 utf8_general_ci varchar(80) NULL information_schema PROCESSLIST ID bigint NULL NULL NULL NULL bigint(4) 3.0000 information_schema PROCESSLIST USER varchar 16 48 utf8 utf8_general_ci varchar(16) 3.0000 information_schema PROCESSLIST HOST varchar 64 192 utf8 utf8_general_ci varchar(64) @@ -849,6 +960,11 @@ NULL information_schema TABLES CHECKSUM bigint NULL NULL NULL NULL bigint(21) un 3.0000 information_schema TABLE_PRIVILEGES TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema TABLE_PRIVILEGES PRIVILEGE_TYPE varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema TABLE_PRIVILEGES IS_GRANTABLE varchar 3 9 utf8 utf8_general_ci varchar(3) +3.0000 information_schema TABLE_STATISTICS TABLE_SCHEMA varchar 192 576 utf8 utf8_general_ci varchar(192) +3.0000 information_schema TABLE_STATISTICS TABLE_NAME varchar 192 576 utf8 utf8_general_ci varchar(192) +NULL information_schema TABLE_STATISTICS ROWS_READ bigint NULL NULL NULL NULL bigint(21) +NULL information_schema TABLE_STATISTICS ROWS_CHANGED bigint NULL NULL NULL NULL bigint(21) +NULL information_schema TABLE_STATISTICS ROWS_CHANGED_X_INDEXES bigint NULL NULL NULL NULL bigint(21) 3.0000 information_schema TRIGGERS TRIGGER_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema TRIGGERS TRIGGER_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema TRIGGERS TRIGGER_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) @@ -875,6 +991,29 @@ NULL information_schema TRIGGERS CREATED datetime NULL NULL NULL NULL datetime 3.0000 information_schema USER_PRIVILEGES TABLE_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema USER_PRIVILEGES PRIVILEGE_TYPE varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema USER_PRIVILEGES IS_GRANTABLE varchar 3 9 utf8 utf8_general_ci varchar(3) +3.0000 information_schema USER_STATISTICS USER varchar 48 144 utf8 utf8_general_ci varchar(48) +NULL information_schema USER_STATISTICS TOTAL_CONNECTIONS int NULL NULL NULL NULL int(11) +NULL information_schema USER_STATISTICS CONCURRENT_CONNECTIONS int NULL NULL NULL NULL int(11) +NULL information_schema USER_STATISTICS CONNECTED_TIME int NULL NULL NULL NULL int(11) +NULL information_schema USER_STATISTICS BUSY_TIME double NULL NULL NULL NULL double +NULL information_schema USER_STATISTICS CPU_TIME double NULL NULL NULL NULL double +NULL information_schema USER_STATISTICS BYTES_RECEIVED bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS BYTES_SENT bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS BINLOG_BYTES_WRITTEN bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ROWS_READ bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ROWS_SENT bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ROWS_DELETED bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ROWS_INSERTED bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ROWS_UPDATED bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS SELECT_COMMANDS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS UPDATE_COMMANDS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS OTHER_COMMANDS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS COMMIT_TRANSACTIONS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ROLLBACK_TRANSACTIONS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS DENIED_CONNECTIONS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS LOST_CONNECTIONS bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ACCESS_DENIED bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS EMPTY_QUERIES bigint NULL NULL NULL NULL bigint(21) 3.0000 information_schema VIEWS TABLE_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema VIEWS TABLE_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema VIEWS TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result index a61763976f4..a8713293c2a 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result @@ -7,6 +7,29 @@ NULL information_schema CHARACTER_SETS CHARACTER_SET_NAME 1 NO varchar 32 96 NU NULL information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME 2 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) NULL information_schema CHARACTER_SETS DESCRIPTION 3 NO varchar 60 180 NULL NULL utf8 utf8_general_ci varchar(60) NULL information_schema CHARACTER_SETS MAXLEN 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(3) +NULL information_schema CLIENT_STATISTICS ACCESS_DENIED 22 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL double +NULL information_schema CLIENT_STATISTICS BYTES_RECEIVED 7 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS BYTES_SENT 8 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS CLIENT 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) +NULL information_schema CLIENT_STATISTICS COMMIT_TRANSACTIONS 18 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS CONCURRENT_CONNECTIONS 3 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS CONNECTED_TIME 4 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS CPU_TIME 6 0 NO double NULL NULL 21 NULL NULL NULL double +NULL information_schema CLIENT_STATISTICS DENIED_CONNECTIONS 20 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS EMPTY_QUERIES 23 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS LOST_CONNECTIONS 21 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS OTHER_COMMANDS 17 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS ROLLBACK_TRANSACTIONS 19 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS ROWS_DELETED 12 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS ROWS_INSERTED 13 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS ROWS_READ 10 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS ROWS_SENT 11 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS ROWS_UPDATED 14 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS SELECT_COMMANDS 15 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS TOTAL_CONNECTIONS 2 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS UPDATE_COMMANDS 16 0 NO int NULL NULL 10 0 NULL NULL int(21) NULL information_schema COLLATIONS CHARACTER_SET_NAME 2 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) NULL information_schema COLLATIONS COLLATION_NAME 1 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) NULL information_schema COLLATIONS ID 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(11) @@ -113,6 +136,10 @@ NULL information_schema GLOBAL_STATUS VARIABLE_NAME 1 NO varchar 64 192 NULL NU NULL information_schema GLOBAL_STATUS VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) NULL information_schema GLOBAL_VARIABLES VARIABLE_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) NULL information_schema GLOBAL_VARIABLES VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) +NULL information_schema INDEX_STATISTICS INDEX_NAME 3 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) +NULL information_schema INDEX_STATISTICS ROWS_READ 4 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema INDEX_STATISTICS TABLE_NAME 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) +NULL information_schema INDEX_STATISTICS TABLE_SCHEMA 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) NULL information_schema INNODB_BUFFER_POOL_PAGES fix_count 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned NULL information_schema INNODB_BUFFER_POOL_PAGES flush_type 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned NULL information_schema INNODB_BUFFER_POOL_PAGES lru_position 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned @@ -355,6 +382,11 @@ NULL information_schema TABLE_PRIVILEGES PRIVILEGE_TYPE 5 NO varchar 64 192 NUL NULL information_schema TABLE_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) NULL information_schema TABLE_PRIVILEGES TABLE_NAME 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) NULL information_schema TABLE_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) +NULL information_schema TABLE_STATISTICS ROWS_CHANGED 4 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema TABLE_STATISTICS ROWS_CHANGED_X_INDEXES 5 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema TABLE_STATISTICS ROWS_READ 3 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema TABLE_STATISTICS TABLE_NAME 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) +NULL information_schema TABLE_STATISTICS TABLE_SCHEMA 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) NULL information_schema TRIGGERS ACTION_CONDITION 9 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext NULL information_schema TRIGGERS ACTION_ORDER 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(4) NULL information_schema TRIGGERS ACTION_ORIENTATION 11 NO varchar 9 27 NULL NULL utf8 utf8_general_ci varchar(9) @@ -381,6 +413,29 @@ NULL information_schema USER_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL u NULL information_schema USER_PRIVILEGES IS_GRANTABLE 4 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) NULL information_schema USER_PRIVILEGES PRIVILEGE_TYPE 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) NULL information_schema USER_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) +NULL information_schema USER_STATISTICS ACCESS_DENIED 22 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL double +NULL information_schema USER_STATISTICS BYTES_RECEIVED 7 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS BYTES_SENT 8 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS COMMIT_TRANSACTIONS 18 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS CONCURRENT_CONNECTIONS 3 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS CONNECTED_TIME 4 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS CPU_TIME 6 0 NO double NULL NULL 21 NULL NULL NULL double +NULL information_schema USER_STATISTICS DENIED_CONNECTIONS 20 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS EMPTY_QUERIES 23 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS LOST_CONNECTIONS 21 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS OTHER_COMMANDS 17 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS ROLLBACK_TRANSACTIONS 19 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS ROWS_DELETED 12 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS ROWS_INSERTED 13 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS ROWS_READ 10 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS ROWS_SENT 11 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS ROWS_UPDATED 14 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS SELECT_COMMANDS 15 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS TOTAL_CONNECTIONS 2 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS UPDATE_COMMANDS 16 0 NO int NULL NULL 10 0 NULL NULL int(21) +NULL information_schema USER_STATISTICS USER 1 NO varchar 48 144 NULL NULL utf8 utf8_general_ci varchar(48) NULL information_schema VIEWS CHARACTER_SET_CLIENT 9 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) NULL information_schema VIEWS CHECK_OPTION 5 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8) NULL information_schema VIEWS COLLATION_CONNECTION 10 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) @@ -436,6 +491,7 @@ COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME NULL bigint NULL NULL NULL datetime NULL NULL NULL decimal NULL NULL +NULL double NULL NULL NULL int NULL NULL --> CHAR(0) is allowed (see manual), and here both CHARACHTER_* values --> are 0, which is intended behavior, and the result of 0 / 0 IS NULL @@ -458,6 +514,29 @@ COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH C 3.0000 information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME varchar 32 96 utf8 utf8_general_ci varchar(32) 3.0000 information_schema CHARACTER_SETS DESCRIPTION varchar 60 180 utf8 utf8_general_ci varchar(60) NULL information_schema CHARACTER_SETS MAXLEN bigint NULL NULL NULL NULL bigint(3) +3.0000 information_schema CLIENT_STATISTICS CLIENT varchar 64 192 utf8 utf8_general_ci varchar(64) +NULL information_schema CLIENT_STATISTICS TOTAL_CONNECTIONS int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS CONCURRENT_CONNECTIONS int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS CONNECTED_TIME int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS BUSY_TIME double NULL NULL NULL NULL double +NULL information_schema CLIENT_STATISTICS CPU_TIME double NULL NULL NULL NULL double +NULL information_schema CLIENT_STATISTICS BYTES_RECEIVED int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS BYTES_SENT int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS BINLOG_BYTES_WRITTEN int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS ROWS_READ int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS ROWS_SENT int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS ROWS_DELETED int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS ROWS_INSERTED int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS ROWS_UPDATED int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS SELECT_COMMANDS int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS UPDATE_COMMANDS int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS OTHER_COMMANDS int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS COMMIT_TRANSACTIONS int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS ROLLBACK_TRANSACTIONS int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS DENIED_CONNECTIONS int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS LOST_CONNECTIONS int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS ACCESS_DENIED int NULL NULL NULL NULL int(21) +NULL information_schema CLIENT_STATISTICS EMPTY_QUERIES int NULL NULL NULL NULL int(21) 3.0000 information_schema COLLATIONS COLLATION_NAME varchar 32 96 utf8 utf8_general_ci varchar(32) 3.0000 information_schema COLLATIONS CHARACTER_SET_NAME varchar 32 96 utf8 utf8_general_ci varchar(32) NULL information_schema COLLATIONS ID bigint NULL NULL NULL NULL bigint(11) @@ -564,6 +643,10 @@ NULL information_schema FILES CHECKSUM bigint NULL NULL NULL NULL bigint(21) uns 3.0000 information_schema GLOBAL_STATUS VARIABLE_VALUE varchar 1024 3072 utf8 utf8_general_ci varchar(1024) 3.0000 information_schema GLOBAL_VARIABLES VARIABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema GLOBAL_VARIABLES VARIABLE_VALUE varchar 1024 3072 utf8 utf8_general_ci varchar(1024) +3.0000 information_schema INDEX_STATISTICS TABLE_SCHEMA varchar 192 576 utf8 utf8_general_ci varchar(192) +3.0000 information_schema INDEX_STATISTICS TABLE_NAME varchar 192 576 utf8 utf8_general_ci varchar(192) +3.0000 information_schema INDEX_STATISTICS INDEX_NAME varchar 192 576 utf8 utf8_general_ci varchar(192) +NULL information_schema INDEX_STATISTICS ROWS_READ int NULL NULL NULL NULL int(21) 3.0000 information_schema INNODB_BUFFER_POOL_PAGES page_type varchar 64 192 utf8 utf8_general_ci varchar(64) NULL information_schema INNODB_BUFFER_POOL_PAGES space_id bigint NULL NULL NULL NULL bigint(21) unsigned NULL information_schema INNODB_BUFFER_POOL_PAGES page_no bigint NULL NULL NULL NULL bigint(21) unsigned @@ -806,6 +889,11 @@ NULL information_schema TABLES CHECKSUM bigint NULL NULL NULL NULL bigint(21) un 3.0000 information_schema TABLE_PRIVILEGES TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema TABLE_PRIVILEGES PRIVILEGE_TYPE varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema TABLE_PRIVILEGES IS_GRANTABLE varchar 3 9 utf8 utf8_general_ci varchar(3) +3.0000 information_schema TABLE_STATISTICS TABLE_SCHEMA varchar 192 576 utf8 utf8_general_ci varchar(192) +3.0000 information_schema TABLE_STATISTICS TABLE_NAME varchar 192 576 utf8 utf8_general_ci varchar(192) +NULL information_schema TABLE_STATISTICS ROWS_READ int NULL NULL NULL NULL int(21) +NULL information_schema TABLE_STATISTICS ROWS_CHANGED int NULL NULL NULL NULL int(21) +NULL information_schema TABLE_STATISTICS ROWS_CHANGED_X_INDEXES int NULL NULL NULL NULL int(21) 3.0000 information_schema TRIGGERS TRIGGER_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema TRIGGERS TRIGGER_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema TRIGGERS TRIGGER_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) @@ -832,6 +920,29 @@ NULL information_schema TRIGGERS CREATED datetime NULL NULL NULL NULL datetime 3.0000 information_schema USER_PRIVILEGES TABLE_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema USER_PRIVILEGES PRIVILEGE_TYPE varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema USER_PRIVILEGES IS_GRANTABLE varchar 3 9 utf8 utf8_general_ci varchar(3) +3.0000 information_schema USER_STATISTICS USER varchar 48 144 utf8 utf8_general_ci varchar(48) +NULL information_schema USER_STATISTICS TOTAL_CONNECTIONS int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS CONCURRENT_CONNECTIONS int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS CONNECTED_TIME int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS BUSY_TIME double NULL NULL NULL NULL double +NULL information_schema USER_STATISTICS CPU_TIME double NULL NULL NULL NULL double +NULL information_schema USER_STATISTICS BYTES_RECEIVED int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS BYTES_SENT int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS BINLOG_BYTES_WRITTEN int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS ROWS_READ int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS ROWS_SENT int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS ROWS_DELETED int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS ROWS_INSERTED int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS ROWS_UPDATED int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS SELECT_COMMANDS int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS UPDATE_COMMANDS int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS OTHER_COMMANDS int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS COMMIT_TRANSACTIONS int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS ROLLBACK_TRANSACTIONS int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS DENIED_CONNECTIONS int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS LOST_CONNECTIONS int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS ACCESS_DENIED int NULL NULL NULL NULL int(21) +NULL information_schema USER_STATISTICS EMPTY_QUERIES int NULL NULL NULL NULL int(21) 3.0000 information_schema VIEWS TABLE_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema VIEWS TABLE_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema VIEWS TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql.result b/mysql-test/suite/funcs_1/r/is_columns_mysql.result index 98eeacdb74c..630baeee74f 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result +++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result @@ -49,7 +49,7 @@ NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL mysql event name 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references NULL mysql event on_completion 14 DROP NO enum 8 24 NULL NULL utf8 utf8_general_ci enum('DROP','PRESERVE') select,insert,update,references NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references -NULL mysql event sql_mode 15 NO set 478 1434 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') select,insert,update,references +NULL mysql event sql_mode 15 NO set 494 1482 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') select,insert,update,references NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event status 13 ENABLED NO enum 18 54 NULL NULL utf8 utf8_general_ci enum('ENABLED','DISABLED','SLAVESIDE_DISABLED') select,insert,update,references NULL mysql event time_zone 18 SYSTEM NO char 64 64 NULL NULL latin1 latin1_swedish_ci char(64) select,insert,update,references @@ -124,7 +124,7 @@ NULL mysql proc returns 10 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL mysql proc security_type 8 DEFINER NO enum 7 21 NULL NULL utf8 utf8_general_ci enum('INVOKER','DEFINER') select,insert,update,references NULL mysql proc specific_name 4 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql proc sql_data_access 6 CONTAINS_SQL NO enum 17 51 NULL NULL utf8 utf8_general_ci enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA') select,insert,update,references -NULL mysql proc sql_mode 15 NO set 478 1434 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') select,insert,update,references +NULL mysql proc sql_mode 15 NO set 494 1482 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') select,insert,update,references NULL mysql proc type 3 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('FUNCTION','PROCEDURE') PRI select,insert,update,references NULL mysql procs_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql procs_priv Grantor 6 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references @@ -178,6 +178,7 @@ NULL mysql time_zone_transition_type Time_zone_id 1 NULL NO int NULL NULL 10 0 N NULL mysql time_zone_transition_type Transition_type_id 2 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI select,insert,update,references NULL mysql user Alter_priv 17 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references NULL mysql user Alter_routine_priv 28 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references +NULL mysql user auth_string 41 NULL NO text 65535 65535 NULL NULL utf8 utf8_bin text select,insert,update,references NULL mysql user Create_priv 8 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references NULL mysql user Create_routine_priv 27 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references NULL mysql user Create_tmp_table_priv 20 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references @@ -198,6 +199,7 @@ NULL mysql user max_questions 36 0 NO int NULL NULL 10 0 NULL NULL int(11) unsig NULL mysql user max_updates 37 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned select,insert,update,references NULL mysql user max_user_connections 39 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned select,insert,update,references NULL mysql user Password 3 NO char 41 41 NULL NULL latin1 latin1_bin char(41) select,insert,update,references +NULL mysql user plugin 40 NO char 60 60 NULL NULL latin1 latin1_swedish_ci char(60) select,insert,update,references NULL mysql user Process_priv 12 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references NULL mysql user References_priv 15 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references NULL mysql user Reload_priv 10 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references @@ -233,6 +235,7 @@ COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME 1.0000 char latin1 latin1_bin 1.0000 char latin1 latin1_swedish_ci 1.0000 varchar latin1 latin1_swedish_ci +1.0000 text utf8 utf8_bin 1.0000 mediumtext utf8 utf8_general_ci 1.0000 text utf8 utf8_general_ci SELECT DISTINCT @@ -327,7 +330,7 @@ NULL mysql event starts datetime NULL NULL NULL NULL datetime NULL mysql event ends datetime NULL NULL NULL NULL datetime 3.0000 mysql event status enum 18 54 utf8 utf8_general_ci enum('ENABLED','DISABLED','SLAVESIDE_DISABLED') 3.0000 mysql event on_completion enum 8 24 utf8 utf8_general_ci enum('DROP','PRESERVE') -3.0000 mysql event sql_mode set 478 1434 utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') +3.0000 mysql event sql_mode set 494 1482 utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') 3.0000 mysql event comment char 64 192 utf8 utf8_bin char(64) NULL mysql event originator int NULL NULL NULL NULL int(10) unsigned 1.0000 mysql event time_zone char 64 64 latin1 latin1_swedish_ci char(64) @@ -402,7 +405,7 @@ NULL mysql ndb_binlog_index schemaops bigint NULL NULL NULL NULL bigint(20) unsi 3.0000 mysql proc definer char 77 231 utf8 utf8_bin char(77) NULL mysql proc created timestamp NULL NULL NULL NULL timestamp NULL mysql proc modified timestamp NULL NULL NULL NULL timestamp -3.0000 mysql proc sql_mode set 478 1434 utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') +3.0000 mysql proc sql_mode set 494 1482 utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') 3.0000 mysql proc comment char 64 192 utf8 utf8_bin char(64) 3.0000 mysql proc character_set_client char 32 96 utf8 utf8_bin char(32) 3.0000 mysql proc collation_connection char 32 96 utf8 utf8_bin char(32) @@ -497,3 +500,5 @@ NULL mysql user max_questions int NULL NULL NULL NULL int(11) unsigned NULL mysql user max_updates int NULL NULL NULL NULL int(11) unsigned NULL mysql user max_connections int NULL NULL NULL NULL int(11) unsigned NULL mysql user max_user_connections int NULL NULL NULL NULL int(11) unsigned +1.0000 mysql user plugin char 60 60 latin1 latin1_swedish_ci char(60) +1.0000 mysql user auth_string text 65535 65535 utf8 utf8_bin text diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result index 9c9d3cd26de..104960e4b79 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result @@ -49,7 +49,7 @@ NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL mysql event name 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI NULL mysql event on_completion 14 DROP NO enum 8 24 NULL NULL utf8 utf8_general_ci enum('DROP','PRESERVE') NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned -NULL mysql event sql_mode 15 NO set 478 1434 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') +NULL mysql event sql_mode 15 NO set 478 1434 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime NULL mysql event status 13 ENABLED NO enum 18 54 NULL NULL utf8 utf8_general_ci enum('ENABLED','DISABLED','SLAVESIDE_DISABLED') NULL mysql event time_zone 18 SYSTEM NO char 64 64 NULL NULL latin1 latin1_swedish_ci char(64) @@ -124,7 +124,7 @@ NULL mysql proc returns 10 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL mysql proc security_type 8 DEFINER NO enum 7 21 NULL NULL utf8 utf8_general_ci enum('INVOKER','DEFINER') NULL mysql proc specific_name 4 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) NULL mysql proc sql_data_access 6 CONTAINS_SQL NO enum 17 51 NULL NULL utf8 utf8_general_ci enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA') -NULL mysql proc sql_mode 15 NO set 478 1434 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') +NULL mysql proc sql_mode 15 NO set 478 1434 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') NULL mysql proc type 3 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('FUNCTION','PROCEDURE') PRI NULL mysql procs_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI NULL mysql procs_priv Grantor 6 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL @@ -327,7 +327,7 @@ NULL mysql event starts datetime NULL NULL NULL NULL datetime NULL mysql event ends datetime NULL NULL NULL NULL datetime 3.0000 mysql event status enum 18 54 utf8 utf8_general_ci enum('ENABLED','DISABLED','SLAVESIDE_DISABLED') 3.0000 mysql event on_completion enum 8 24 utf8 utf8_general_ci enum('DROP','PRESERVE') -3.0000 mysql event sql_mode set 478 1434 utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') +3.0000 mysql event sql_mode set 478 1434 utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') 3.0000 mysql event comment char 64 192 utf8 utf8_bin char(64) NULL mysql event originator int NULL NULL NULL NULL int(10) unsigned 1.0000 mysql event time_zone char 64 64 latin1 latin1_swedish_ci char(64) @@ -402,7 +402,7 @@ NULL mysql ndb_binlog_index schemaops bigint NULL NULL NULL NULL bigint(20) unsi 3.0000 mysql proc definer char 77 231 utf8 utf8_bin char(77) NULL mysql proc created timestamp NULL NULL NULL NULL timestamp NULL mysql proc modified timestamp NULL NULL NULL NULL timestamp -3.0000 mysql proc sql_mode set 478 1434 utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') +3.0000 mysql proc sql_mode set 478 1434 utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') 3.0000 mysql proc comment char 64 192 utf8 utf8_bin char(64) 3.0000 mysql proc character_set_client char 32 96 utf8 utf8_bin char(32) 3.0000 mysql proc collation_connection char 32 96 utf8 utf8_bin char(32) diff --git a/mysql-test/suite/funcs_1/r/is_tables_is.result b/mysql-test/suite/funcs_1/r/is_tables_is.result index bcfe138206e..8419bfb7ebb 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_is.result +++ b/mysql-test/suite/funcs_1/r/is_tables_is.result @@ -38,6 +38,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME CLIENT_STATISTICS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME COLLATIONS TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -245,6 +268,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME INDEX_STATISTICS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME INNODB_BUFFER_POOL_PAGES TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -590,6 +636,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME KEY_CACHES +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME KEY_COLUMN_USAGE TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -935,6 +1004,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME TABLE_STATISTICS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME TRIGGERS TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA @@ -981,6 +1073,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME USER_STATISTICS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME VIEWS TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA @@ -1090,6 +1205,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME CLIENT_STATISTICS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME COLLATIONS TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -1297,6 +1435,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME INDEX_STATISTICS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME INNODB_BUFFER_POOL_PAGES TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -1642,6 +1803,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME KEY_CACHES +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME KEY_COLUMN_USAGE TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -1987,6 +2171,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME TABLE_STATISTICS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME TRIGGERS TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA @@ -2033,6 +2240,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME USER_STATISTICS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME VIEWS TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA diff --git a/mysql-test/suite/funcs_1/r/is_user_privileges.result b/mysql-test/suite/funcs_1/r/is_user_privileges.result index 03865f59c2c..b9a19f98d65 100644 --- a/mysql-test/suite/funcs_1/r/is_user_privileges.result +++ b/mysql-test/suite/funcs_1/r/is_user_privileges.result @@ -76,10 +76,10 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'testuser3'@'localhost' NULL USAGE NO SELECT * FROM mysql.user WHERE user LIKE 'testuser%' ORDER BY host, user; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 # # Add GRANT OPTION db_datadict.* to testuser1; GRANT UPDATE ON db_datadict.* TO 'testuser1'@'localhost' WITH GRANT OPTION; @@ -93,10 +93,10 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'testuser3'@'localhost' NULL USAGE NO SELECT * FROM mysql.user WHERE user LIKE 'testuser%' ORDER BY host, user; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 # Establish connection testuser1 (user=testuser1) SELECT * FROM information_schema.user_privileges WHERE grantee LIKE '''testuser%''' @@ -105,10 +105,10 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'testuser1'@'localhost' NULL USAGE NO SELECT * FROM mysql.user WHERE user LIKE 'testuser%' ORDER BY host, user; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 SHOW GRANTS; Grants for testuser1@localhost GRANT USAGE ON *.* TO 'testuser1'@'localhost' @@ -130,10 +130,10 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'testuser3'@'localhost' NULL USAGE NO SELECT * FROM mysql.user WHERE user LIKE 'testuser%' ORDER BY host, user; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost testuser1 Y N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost testuser1 Y N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 GRANT SELECT ON *.* TO 'testuser1'@'localhost' WITH GRANT OPTION; # # Here <SELECT YES> is shown correctly for testuser1; @@ -147,10 +147,10 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'testuser3'@'localhost' NULL USAGE NO SELECT * FROM mysql.user WHERE user LIKE 'testuser%' ORDER BY host, user; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost testuser1 Y N N N N N N N N N Y N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost testuser1 Y N N N N N N N N N Y N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 # Switch to connection testuser1 SELECT * FROM information_schema.user_privileges WHERE grantee LIKE '''testuser%''' @@ -159,10 +159,10 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'testuser1'@'localhost' NULL SELECT YES SELECT * FROM mysql.user WHERE user LIKE 'testuser%' ORDER BY host, user; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost testuser1 Y N N N N N N N N N Y N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost testuser1 Y N N N N N N N N N Y N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 SHOW GRANTS; Grants for testuser1@localhost GRANT SELECT ON *.* TO 'testuser1'@'localhost' WITH GRANT OPTION @@ -207,10 +207,10 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'testuser3'@'localhost' NULL USAGE NO SELECT * FROM mysql.user WHERE user LIKE 'testuser%' ORDER BY host, user; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 # Switch to connection testuser1 SELECT * FROM information_schema.user_privileges WHERE grantee LIKE '''testuser%''' @@ -253,10 +253,10 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'testuser3'@'localhost' NULL USAGE NO SELECT * FROM mysql.user WHERE user LIKE 'testuser%' ORDER BY host, user; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 # Switch to connection testuser1 SELECT * FROM information_schema.user_privileges WHERE grantee LIKE '''testuser%''' @@ -265,10 +265,10 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'testuser1'@'localhost' NULL USAGE NO SELECT * FROM mysql.user WHERE user LIKE 'testuser%' ORDER BY host, user; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 SHOW GRANTS; Grants for testuser1@localhost GRANT USAGE ON *.* TO 'testuser1'@'localhost' @@ -284,10 +284,10 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'testuser1'@'localhost' NULL USAGE NO SELECT * FROM mysql.user WHERE user LIKE 'testuser%' ORDER BY host, user; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 SHOW GRANTS; Grants for testuser1@localhost GRANT USAGE ON *.* TO 'testuser1'@'localhost' @@ -309,10 +309,10 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'testuser3'@'localhost' NULL USAGE NO SELECT * FROM mysql.user WHERE user LIKE 'testuser%' ORDER BY host, user; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 -localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost testuser1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser2 N Y Y N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 +localhost testuser3 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 # Switch to connection testuser1 SELECT * FROM information_schema.user_privileges WHERE grantee LIKE '''testuser%''' diff --git a/mysql-test/suite/funcs_1/t/is_tables_is.test b/mysql-test/suite/funcs_1/t/is_tables_is.test index 90da2170281..20ed93ddd07 100644 --- a/mysql-test/suite/funcs_1/t/is_tables_is.test +++ b/mysql-test/suite/funcs_1/t/is_tables_is.test @@ -16,4 +16,3 @@ let $my_where = WHERE table_schema = 'information_schema' AND table_name <> 'profiling'; --source suite/funcs_1/datadict/tables1.inc - diff --git a/mysql-test/suite/maria/r/group_commit.result b/mysql-test/suite/maria/r/group_commit.result new file mode 100644 index 00000000000..75d7318340a --- /dev/null +++ b/mysql-test/suite/maria/r/group_commit.result @@ -0,0 +1,17 @@ +drop table if exists t1; +create table t1 (a int); +SET GLOBAL maria_group_commit="NONE"; +SET GLOBAL maria_group_commit_interval= 0; +SET GLOBAL maria_group_commit="NONE"; +SET GLOBAL maria_group_commit_interval= 100; +SET GLOBAL maria_group_commit="HARD"; +SET GLOBAL maria_group_commit_interval= 0; +SET GLOBAL maria_group_commit="HARD"; +SET GLOBAL maria_group_commit_interval= 100; +SET GLOBAL maria_group_commit="SOFT"; +SET GLOBAL maria_group_commit_interval= 0; +SET GLOBAL maria_group_commit="SOFT"; +SET GLOBAL maria_group_commit_interval= 100; +SET GLOBAL maria_group_commit="NONE"; +SET GLOBAL maria_group_commit_interval= 0; +drop table t1; diff --git a/mysql-test/suite/maria/r/maria.result b/mysql-test/suite/maria/r/maria.result index 46ae485b678..a56ae6ac401 100644 --- a/mysql-test/suite/maria/r/maria.result +++ b/mysql-test/suite/maria/r/maria.result @@ -2618,7 +2618,7 @@ f1 CHAR(255) BINARY , f2 CHAR(255) BINARY NOT NULL DEFAULT '0', f3 CHAR(255) BINARY NOT NULL , f4 CHAR(255) BINARY NOT NULL DEFAULT '0' , -v3 CHAR(255) BINARY NOT NULL DEFAULT '0' , +v3 CHAR(255) BINARY AS ( ( f1 NOT LIKE '%' ) ) PERSISTENT, KEY (v3) ) ENGINE=Maria; INSERT INTO t1 ( f1 , f2 , f3 , f4 ) SELECT f1 , f4 , f1 , f4 FROM t1; diff --git a/mysql-test/suite/maria/r/maria3.result b/mysql-test/suite/maria/r/maria3.result index e632363346d..4fb08ed192e 100644 --- a/mysql-test/suite/maria/r/maria3.result +++ b/mysql-test/suite/maria/r/maria3.result @@ -306,6 +306,8 @@ Variable_name Value maria_block_size 8192 maria_checkpoint_interval 30 maria_force_start_after_recovery_failures 0 +maria_group_commit none +maria_group_commit_interval 0 maria_log_file_size 4294959104 maria_log_purge_type immediate maria_max_sort_file_size 9223372036853727232 @@ -327,6 +329,7 @@ Maria_pagecache_read_requests # Maria_pagecache_reads # Maria_pagecache_write_requests # Maria_pagecache_writes # +Maria_transaction_log_syncs # create table t1 (b char(0)); insert into t1 values(NULL),(""); select length(b) from t1; diff --git a/mysql-test/suite/maria/t/group_commit.test b/mysql-test/suite/maria/t/group_commit.test new file mode 100644 index 00000000000..e2cace14036 --- /dev/null +++ b/mysql-test/suite/maria/t/group_commit.test @@ -0,0 +1,72 @@ +# Test different ways of syncing (mostly syntax) +--source include/have_maria.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 (a int); + +SET GLOBAL maria_group_commit="NONE"; +SET GLOBAL maria_group_commit_interval= 0; +--disable_query_log +let $num = 5000; +while ($num) +{ + insert into t1 values (1); + dec $num; +} +--enable_query_log +SET GLOBAL maria_group_commit="NONE"; +SET GLOBAL maria_group_commit_interval= 100; +--disable_query_log +let $num = 5000; +while ($num) +{ + insert into t1 values (1); + dec $num; +} +--enable_query_log +SET GLOBAL maria_group_commit="HARD"; +SET GLOBAL maria_group_commit_interval= 0; +--disable_query_log +let $num = 5000; +while ($num) +{ + insert into t1 values (1); + dec $num; +} +--enable_query_log +SET GLOBAL maria_group_commit="HARD"; +SET GLOBAL maria_group_commit_interval= 100; +--disable_query_log +let $num = 5000; +while ($num) +{ + insert into t1 values (1); + dec $num; +} +--enable_query_log +SET GLOBAL maria_group_commit="SOFT"; +SET GLOBAL maria_group_commit_interval= 0; +--disable_query_log +let $num = 5000; +while ($num) +{ + insert into t1 values (1); + dec $num; +} +--enable_query_log +SET GLOBAL maria_group_commit="SOFT"; +SET GLOBAL maria_group_commit_interval= 100; +--disable_query_log +let $num = 5000; +while ($num) +{ + insert into t1 values (1); + dec $num; +} +--enable_query_log +SET GLOBAL maria_group_commit="NONE"; +SET GLOBAL maria_group_commit_interval= 0; +drop table t1; diff --git a/mysql-test/suite/maria/t/maria.test b/mysql-test/suite/maria/t/maria.test index 4dde6364bb1..664bcb372ca 100644 --- a/mysql-test/suite/maria/t/maria.test +++ b/mysql-test/suite/maria/t/maria.test @@ -1903,7 +1903,7 @@ CREATE TABLE t1 ( f2 CHAR(255) BINARY NOT NULL DEFAULT '0', f3 CHAR(255) BINARY NOT NULL , f4 CHAR(255) BINARY NOT NULL DEFAULT '0' , - v3 CHAR(255) BINARY NOT NULL DEFAULT '0' , + v3 CHAR(255) BINARY AS ( ( f1 NOT LIKE '%' ) ) PERSISTENT, KEY (v3) ) ENGINE=Maria; INSERT INTO t1 ( f1 , f2 , f3 , f4 ) SELECT f1 , f4 , f1 , f4 FROM t1; diff --git a/mysql-test/suite/oqgraph/include/have_oqgraph_engine.inc b/mysql-test/suite/oqgraph/include/have_oqgraph_engine.inc new file mode 100644 index 00000000000..6fc3c6a0632 --- /dev/null +++ b/mysql-test/suite/oqgraph/include/have_oqgraph_engine.inc @@ -0,0 +1,4 @@ +disable_query_log; +--require r/true.require +select (PLUGIN_LIBRARY LIKE 'oqgraph_engine%') as `TRUE` from information_schema.plugins where PLUGIN_NAME='OQGRAPH'; +enable_query_log; diff --git a/mysql-test/suite/oqgraph/r/basic.result b/mysql-test/suite/oqgraph/r/basic.result new file mode 100644 index 00000000000..e90659c0986 --- /dev/null +++ b/mysql-test/suite/oqgraph/r/basic.result @@ -0,0 +1,63 @@ +drop table if exists graph; +Warnings: +Note 1051 Unknown table 'graph' +CREATE TABLE graph ( +latch SMALLINT UNSIGNED NULL, +origid BIGINT UNSIGNED NULL, +destid BIGINT UNSIGNED NULL, +weight DOUBLE NULL, +seq BIGINT UNSIGNED NULL, +linkid BIGINT UNSIGNED NULL, +KEY (latch, origid, destid) USING HASH, +KEY (latch, destid, origid) USING HASH +) ENGINE=OQGRAPH; +delete from graph; +insert into graph(origid, destid) values (1,2), (2,1); +insert into graph(origid, destid) values (1,3), (3,1); +insert into graph(origid, destid) values (3,4), (4,3); +insert into graph(origid, destid) values (3,5), (5,3); +insert into graph(origid, destid) values (5,6), (6,5); +select * from graph where latch = 2 and origid = 1 and weight = 1; +latch origid destid weight seq linkid +2 1 NULL 1 3 3 +2 1 NULL 1 2 2 +select * from graph where latch = 2 and origid = 1 and weight = 2; +latch origid destid weight seq linkid +2 1 NULL 2 5 5 +2 1 NULL 2 4 4 +select * from graph +where latch = 2 and origid = 1 and (weight = 1 or weight = 2); +latch origid destid weight seq linkid +2 1 NULL 2 5 5 +2 1 NULL 2 4 4 +2 1 NULL 1 3 3 +2 1 NULL 1 2 2 +select * from graph where latch=1 and origid=1 and destid=6; +latch origid destid weight seq linkid +1 1 6 NULL 0 1 +1 1 6 1 1 3 +1 1 6 1 2 5 +1 1 6 1 3 6 +select * from graph where latch=1 and origid=1 and destid=4; +latch origid destid weight seq linkid +1 1 4 NULL 0 1 +1 1 4 1 1 3 +1 1 4 1 2 4 +select * from graph where latch=1 and origid=4 and destid=1; +latch origid destid weight seq linkid +1 4 1 NULL 0 4 +1 4 1 1 1 3 +1 4 1 1 2 1 +insert into graph (origid,destid) values (4,6); +delete from graph where origid=5; +delete from graph where origid=3 and destid=5; +select * from graph where latch=1 and origid=1 and destid=6; +latch origid destid weight seq linkid +1 1 6 NULL 0 1 +1 1 6 1 1 3 +1 1 6 1 2 4 +1 1 6 1 3 6 +select * from graph where latch=1 and origid=6 and destid=1; +latch origid destid weight seq linkid +truncate table graph; +drop table graph; diff --git a/mysql-test/suite/oqgraph/r/binlog.result b/mysql-test/suite/oqgraph/r/binlog.result new file mode 100644 index 00000000000..ee0a8c081f4 --- /dev/null +++ b/mysql-test/suite/oqgraph/r/binlog.result @@ -0,0 +1,18 @@ +drop table if exists graph; +CREATE TABLE graph ( +latch SMALLINT UNSIGNED NULL, +origid BIGINT UNSIGNED NULL, +destid BIGINT UNSIGNED NULL, +weight DOUBLE NULL, +seq BIGINT UNSIGNED NULL, +linkid BIGINT UNSIGNED NULL, +KEY (latch, origid, destid) USING HASH, +KEY (latch, destid, origid) USING HASH +) ENGINE=OQGRAPH; +SET binlog_format = row; +insert into graph(origid, destid) values (1,3), (3,1); +SET binlog_format = statement; +insert into graph(origid, destid) values (3,4), (4,3); +SET binlog_format = mixed; +insert into graph(origid, destid) values (3,5), (5,3); +drop table graph; diff --git a/mysql-test/suite/oqgraph/t/basic.test b/mysql-test/suite/oqgraph/t/basic.test new file mode 100644 index 00000000000..b39341ba3d5 --- /dev/null +++ b/mysql-test/suite/oqgraph/t/basic.test @@ -0,0 +1,45 @@ +-- source suite/oqgraph/include/have_oqgraph_engine.inc + +drop table if exists graph; + +CREATE TABLE graph ( + latch SMALLINT UNSIGNED NULL, + origid BIGINT UNSIGNED NULL, + destid BIGINT UNSIGNED NULL, + weight DOUBLE NULL, + seq BIGINT UNSIGNED NULL, + linkid BIGINT UNSIGNED NULL, + KEY (latch, origid, destid) USING HASH, + KEY (latch, destid, origid) USING HASH + ) ENGINE=OQGRAPH; + +delete from graph; + +insert into graph(origid, destid) values (1,2), (2,1); +insert into graph(origid, destid) values (1,3), (3,1); +insert into graph(origid, destid) values (3,4), (4,3); +insert into graph(origid, destid) values (3,5), (5,3); +insert into graph(origid, destid) values (5,6), (6,5); + +select * from graph where latch = 2 and origid = 1 and weight = 1; + +select * from graph where latch = 2 and origid = 1 and weight = 2; + +select * from graph +where latch = 2 and origid = 1 and (weight = 1 or weight = 2); + +select * from graph where latch=1 and origid=1 and destid=6; +select * from graph where latch=1 and origid=1 and destid=4; +select * from graph where latch=1 and origid=4 and destid=1; + +insert into graph (origid,destid) values (4,6); + +delete from graph where origid=5; +delete from graph where origid=3 and destid=5; + +select * from graph where latch=1 and origid=1 and destid=6; +select * from graph where latch=1 and origid=6 and destid=1; + +truncate table graph; + +drop table graph; diff --git a/mysql-test/suite/oqgraph/t/binlog.test b/mysql-test/suite/oqgraph/t/binlog.test new file mode 100644 index 00000000000..ac7c8867533 --- /dev/null +++ b/mysql-test/suite/oqgraph/t/binlog.test @@ -0,0 +1,28 @@ +-- source suite/oqgraph/include/have_oqgraph_engine.inc +-- source include/have_log_bin.inc + +--disable_warnings +drop table if exists graph; +--enable_warnings + +CREATE TABLE graph ( + latch SMALLINT UNSIGNED NULL, + origid BIGINT UNSIGNED NULL, + destid BIGINT UNSIGNED NULL, + weight DOUBLE NULL, + seq BIGINT UNSIGNED NULL, + linkid BIGINT UNSIGNED NULL, + KEY (latch, origid, destid) USING HASH, + KEY (latch, destid, origid) USING HASH + ) ENGINE=OQGRAPH; + +# MBug#524625: OQGraph error with binary logging enabled +# Test that OQGraph works with different binlogging modes. +SET binlog_format = row; +insert into graph(origid, destid) values (1,3), (3,1); +SET binlog_format = statement; +insert into graph(origid, destid) values (3,4), (4,3); +SET binlog_format = mixed; +insert into graph(origid, destid) values (3,5), (5,3); + +drop table graph; diff --git a/mysql-test/suite/oqgraph/t/suite.opt b/mysql-test/suite/oqgraph/t/suite.opt new file mode 100644 index 00000000000..05985782664 --- /dev/null +++ b/mysql-test/suite/oqgraph/t/suite.opt @@ -0,0 +1 @@ +--plugin-load=$GRAPH_ENGINE_SO diff --git a/mysql-test/suite/parts/r/partition_debug_sync_innodb.result b/mysql-test/suite/parts/r/partition_debug_sync_innodb.result index 41c3d1af174..70939691565 100644 --- a/mysql-test/suite/parts/r/partition_debug_sync_innodb.result +++ b/mysql-test/suite/parts/r/partition_debug_sync_innodb.result @@ -35,7 +35,7 @@ ALTER TABLE t1 REORGANIZE PARTITION p0 INTO (PARTITION p0 VALUES LESS THAN (10), PARTITION p10 VALUES LESS THAN MAXVALUE); Warnings: -Warning 1639 debug sync point wait timed out +Warning 1649 debug sync point wait timed out TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME NULL test t1 p0 NULL 1 NULL RANGE NULL a NULL 10 1 16384 16384 NULL 0 0 NULL NULL NULL NULL default NULL NULL test t1 p10 NULL 2 NULL RANGE NULL a NULL MAXVALUE 3 5461 16384 NULL 0 0 NULL NULL NULL NULL default NULL diff --git a/mysql-test/suite/pbxt/r/grant.result b/mysql-test/suite/pbxt/r/grant.result index 74cac3ea4f0..68395661db3 100644 --- a/mysql-test/suite/pbxt/r/grant.result +++ b/mysql-test/suite/pbxt/r/grant.result @@ -11,8 +11,8 @@ GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3 GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost' grant delete on mysqltest.* to mysqltest_1@localhost; select * from mysql.user where user="mysqltest_1"; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED EDH-RSA-DES-CBC3-SHA 0 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED EDH-RSA-DES-CBC3-SHA 0 0 0 0 show grants for mysqltest_1@localhost; Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA' @@ -42,15 +42,15 @@ delete from mysql.user where user='mysqltest_1'; flush privileges; grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 10; select * from mysql.user where user="mysqltest_1"; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 10 0 0 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 10 0 0 0 show grants for mysqltest_1@localhost; Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_QUERIES_PER_HOUR 10 grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 20 max_connections_per_hour 30; select * from mysql.user where user="mysqltest_1"; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections -localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 10 20 30 0 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin auth_string +localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N 10 20 30 0 show grants for mysqltest_1@localhost; Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_QUERIES_PER_HOUR 10 MAX_UPDATES_PER_HOUR 20 MAX_CONNECTIONS_PER_HOUR 30 @@ -162,6 +162,7 @@ Warnings: Warning 1364 Field 'ssl_cipher' doesn't have a default value Warning 1364 Field 'x509_issuer' doesn't have a default value Warning 1364 Field 'x509_subject' doesn't have a default value +Warning 1364 Field 'auth_string' doesn't have a default value insert into mysql.db (host, db, user, select_priv) values ('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y'); alter table mysql.db order by db asc; diff --git a/mysql-test/suite/pbxt/r/group_min_max.result b/mysql-test/suite/pbxt/r/group_min_max.result index 0694a408f55..a591832bc0d 100644 --- a/mysql-test/suite/pbxt/r/group_min_max.result +++ b/mysql-test/suite/pbxt/r/group_min_max.result @@ -2199,7 +2199,7 @@ max(b) a SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 0 -Handler_read_next 0 +Handler_read_next 15 EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL a 10 NULL 15 Using index @@ -2208,7 +2208,7 @@ CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a; SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 0 -Handler_read_next 0 +Handler_read_next 15 FLUSH STATUS; SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b; max(b) a @@ -2219,7 +2219,7 @@ max(b) a SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 0 -Handler_read_next 0 +Handler_read_next 15 FLUSH STATUS; (SELECT max(b), a FROM t1 GROUP BY a) UNION (SELECT max(b), a FROM t1 GROUP BY a); @@ -2231,7 +2231,7 @@ max(b) a SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 0 -Handler_read_next 0 +Handler_read_next 30 EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION (SELECT max(b), a FROM t1 GROUP BY a); id select_type table type possible_keys key key_len ref rows Extra @@ -2282,7 +2282,7 @@ INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a; SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 0 -Handler_read_next 0 +Handler_read_next 15 DELETE FROM t3; FLUSH STATUS; INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) @@ -2290,13 +2290,13 @@ FROM t1 LIMIT 1; SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 0 -Handler_read_next 0 +Handler_read_next 15 FLUSH STATUS; DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000; SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 0 -Handler_read_next 0 +Handler_read_next 15 FLUSH STATUS; DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x FROM t1) > 10000; @@ -2304,7 +2304,7 @@ ERROR 21000: Subquery returns more than 1 row SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 0 -Handler_read_next 0 +Handler_read_next 16 DROP TABLE t1,t2,t3; CREATE TABLE t1 (a int, INDEX idx(a)); INSERT INTO t1 VALUES diff --git a/mysql-test/suite/pbxt/r/mysqlshow.result b/mysql-test/suite/pbxt/r/mysqlshow.result index 79394980270..8588b332b00 100644 --- a/mysql-test/suite/pbxt/r/mysqlshow.result +++ b/mysql-test/suite/pbxt/r/mysqlshow.result @@ -80,6 +80,7 @@ Database: information_schema | Tables | +---------------------------------------+ | CHARACTER_SETS | +| CLIENT_STATISTICS | | COLLATIONS | | COLLATION_CHARACTER_SET_APPLICABILITY | | COLUMNS | @@ -89,6 +90,8 @@ Database: information_schema | FILES | | GLOBAL_STATUS | | GLOBAL_VARIABLES | +| INDEX_STATISTICS | +| KEY_CACHES | | KEY_COLUMN_USAGE | | PARTITIONS | | PLUGINS | @@ -104,8 +107,10 @@ Database: information_schema | TABLES | | TABLE_CONSTRAINTS | | TABLE_PRIVILEGES | +| TABLE_STATISTICS | | TRIGGERS | | USER_PRIVILEGES | +| USER_STATISTICS | | VIEWS | | INNODB_BUFFER_POOL_PAGES | | PBXT_STATISTICS | @@ -131,6 +136,7 @@ Database: INFORMATION_SCHEMA | Tables | +---------------------------------------+ | CHARACTER_SETS | +| CLIENT_STATISTICS | | COLLATIONS | | COLLATION_CHARACTER_SET_APPLICABILITY | | COLUMNS | @@ -140,6 +146,8 @@ Database: INFORMATION_SCHEMA | FILES | | GLOBAL_STATUS | | GLOBAL_VARIABLES | +| INDEX_STATISTICS | +| KEY_CACHES | | KEY_COLUMN_USAGE | | PARTITIONS | | PLUGINS | @@ -155,8 +163,10 @@ Database: INFORMATION_SCHEMA | TABLES | | TABLE_CONSTRAINTS | | TABLE_PRIVILEGES | +| TABLE_STATISTICS | | TRIGGERS | | USER_PRIVILEGES | +| USER_STATISTICS | | VIEWS | | INNODB_BUFFER_POOL_PAGES | | PBXT_STATISTICS | diff --git a/mysql-test/suite/pbxt/r/null_key.result b/mysql-test/suite/pbxt/r/null_key.result index 753ebf31f1c..8a440284c53 100644 --- a/mysql-test/suite/pbxt/r/null_key.result +++ b/mysql-test/suite/pbxt/r/null_key.result @@ -423,9 +423,9 @@ FOUND_ROWS() SHOW STATUS LIKE "handler_read%"; Variable_name Value Handler_read_first 0 -Handler_read_key 0 -Handler_read_next 0 +Handler_read_key 6 +Handler_read_next 2 Handler_read_prev 0 Handler_read_rnd 0 -Handler_read_rnd_next 0 +Handler_read_rnd_next 5 DROP TABLE t1,t2,t3,t4; diff --git a/mysql-test/suite/pbxt/r/partition_pruning.result b/mysql-test/suite/pbxt/r/partition_pruning.result index 2f43fa6eb86..49fa43916aa 100644 --- a/mysql-test/suite/pbxt/r/partition_pruning.result +++ b/mysql-test/suite/pbxt/r/partition_pruning.result @@ -390,7 +390,7 @@ flush status; update t1 set a=100 where a+1=5+1; show status like 'Handler_read_rnd_next'; Variable_name Value -Handler_read_rnd_next 0 +Handler_read_rnd_next 10 flush status; delete from t1 where a=5; show status like 'Handler_read_rnd_next'; @@ -400,7 +400,7 @@ flush status; delete from t1 where a+1=5+1; show status like 'Handler_read_rnd_next'; Variable_name Value -Handler_read_rnd_next 0 +Handler_read_rnd_next 10 create table t2 like t1; insert into t2 select * from t2; flush status; @@ -468,7 +468,7 @@ flush status; update t2 set b = 100 where b = 6; show status like 'Handler_read_rnd_next'; Variable_name Value -Handler_read_rnd_next 0 +Handler_read_rnd_next 1015 flush status; update t2 set a = 1002 where a = 1001; show status like 'Handler_read_rnd_next'; @@ -478,17 +478,17 @@ flush status; update t2 set b = 6 where a = 600; show status like 'Handler_read_rnd_next'; Variable_name Value -Handler_read_rnd_next 0 +Handler_read_rnd_next 201 flush status; update t2 set b = 6 where a > 600 and a < 800; show status like 'Handler_read_rnd_next'; Variable_name Value -Handler_read_rnd_next 0 +Handler_read_rnd_next 201 flush status; delete from t2 where a > 600; show status like 'Handler_read_rnd_next'; Variable_name Value -Handler_read_rnd_next 0 +Handler_read_rnd_next 402 drop table t2; CREATE TABLE `t2` ( `a` int(11) default NULL, @@ -605,7 +605,7 @@ Variable_name Value Handler_read_rnd_next 0 show status like 'Handler_read_key'; Variable_name Value -Handler_read_key 0 +Handler_read_key 5 flush status; update t2 set a = 111 where b in (5,6); show status like 'Handler_read_rnd_next'; @@ -613,7 +613,7 @@ Variable_name Value Handler_read_rnd_next 0 show status like 'Handler_read_key'; Variable_name Value -Handler_read_key 0 +Handler_read_key 10 flush status; update t2 set a = 222 where b = 7; show status like 'Handler_read_rnd_next'; @@ -621,7 +621,7 @@ Variable_name Value Handler_read_rnd_next 0 show status like 'Handler_read_key'; Variable_name Value -Handler_read_key 0 +Handler_read_key 5 flush status; delete from t2 where b = 7; show status like 'Handler_read_rnd_next'; @@ -629,7 +629,7 @@ Variable_name Value Handler_read_rnd_next 0 show status like 'Handler_read_key'; Variable_name Value -Handler_read_key 0 +Handler_read_key 5 flush status; delete from t2 where b > 5; show status like 'Handler_read_rnd_next'; @@ -637,13 +637,13 @@ Variable_name Value Handler_read_rnd_next 0 show status like 'Handler_read_key'; Variable_name Value -Handler_read_key 0 +Handler_read_key 5 show status like 'Handler_read_prev'; Variable_name Value Handler_read_prev 0 show status like 'Handler_read_next'; Variable_name Value -Handler_read_next 0 +Handler_read_next 300 flush status; delete from t2 where b < 5 or b > 3; show status like 'Handler_read_rnd_next'; @@ -651,13 +651,13 @@ Variable_name Value Handler_read_rnd_next 0 show status like 'Handler_read_key'; Variable_name Value -Handler_read_key 0 +Handler_read_key 10 show status like 'Handler_read_prev'; Variable_name Value Handler_read_prev 0 show status like 'Handler_read_next'; Variable_name Value -Handler_read_next 0 +Handler_read_next 510 drop table t1, t2; create table t1 ( f_int1 mediumint, f_int2 integer) partition by list(mod(f_int1,4)) ( diff --git a/mysql-test/suite/pbxt/r/update.result b/mysql-test/suite/pbxt/r/update.result index 3a690709c28..9154583fa81 100644 --- a/mysql-test/suite/pbxt/r/update.result +++ b/mysql-test/suite/pbxt/r/update.result @@ -271,7 +271,7 @@ a 0 show status like 'handler_read%'; Variable_name Value -Handler_read_first 0 +Handler_read_first 1 Handler_read_key 0 Handler_read_next 0 Handler_read_prev 0 @@ -289,8 +289,8 @@ Handler_read_first 0 Handler_read_key 0 Handler_read_next 0 Handler_read_prev 0 -Handler_read_rnd 0 -Handler_read_rnd_next 0 +Handler_read_rnd 2 +Handler_read_rnd_next 18 flush status; delete from t1 order by a limit 1; show status like 'handler_read%'; @@ -299,8 +299,8 @@ Handler_read_first 0 Handler_read_key 0 Handler_read_next 0 Handler_read_prev 0 -Handler_read_rnd 0 -Handler_read_rnd_next 0 +Handler_read_rnd 1 +Handler_read_rnd_next 9 flush status; delete from t1 order by a desc limit 1; show status like 'handler_read%'; @@ -309,8 +309,8 @@ Handler_read_first 0 Handler_read_key 0 Handler_read_next 0 Handler_read_prev 0 -Handler_read_rnd 0 -Handler_read_rnd_next 0 +Handler_read_rnd 1 +Handler_read_rnd_next 8 alter table t1 disable keys; Warnings: Note 1031 Table storage engine for 't1' doesn't have this option @@ -322,8 +322,8 @@ Handler_read_first 0 Handler_read_key 0 Handler_read_next 0 Handler_read_prev 0 -Handler_read_rnd 0 -Handler_read_rnd_next 0 +Handler_read_rnd 1 +Handler_read_rnd_next 7 select * from t1; a b 0 0 @@ -372,10 +372,10 @@ update t2 set a=3 where a=2; show status like 'handler_read%'; Variable_name Value Handler_read_first 0 -Handler_read_key 0 -Handler_read_next 0 +Handler_read_key 1 +Handler_read_next 1 Handler_read_prev 0 -Handler_read_rnd 0 +Handler_read_rnd 1 Handler_read_rnd_next 0 drop table t1, t2; create table t1(f1 int, `*f2` int); diff --git a/mysql-test/suite/pbxt/t/multi_update.test b/mysql-test/suite/pbxt/t/multi_update.test index 12e91c79f22..1acd59ea626 100644 --- a/mysql-test/suite/pbxt/t/multi_update.test +++ b/mysql-test/suite/pbxt/t/multi_update.test @@ -20,6 +20,7 @@ create table t1(id1 int not null auto_increment primary key, t char(12)); create table t2(id2 int not null, t char(12)); create table t3(id3 int not null, t char(12), index(id3)); disable_query_log; +begin; let $1 = 100; while ($1) { @@ -38,6 +39,7 @@ while ($1) } dec $1; } +commit; enable_query_log; select count(*) from t1 where id1 > 95; @@ -75,6 +77,7 @@ drop table t1,t2,t3; create table t1(id1 int not null primary key, t varchar(100)) pack_keys = 1; create table t2(id2 int not null, t varchar(100), index(id2)) pack_keys = 1; disable_query_log; +begin; let $1 = 1000; while ($1) { @@ -87,6 +90,7 @@ while ($1) } dec $1; } +commit; enable_query_log; delete t1 from t1,t2 where t1.id1 = t2.id2 and t1.id1 > 500; drop table t1,t2; @@ -328,6 +332,7 @@ drop table t1,t2; create table t1 ( a int not null, b int not null) ; --disable_query_log +begin; insert into t1 values (1,1),(2,2),(3,3),(4,4); let $1=19; set @d=4; @@ -337,7 +342,7 @@ while ($1) eval set @d=@d*2; dec $1; } - +commit; --enable_query_log alter table t1 add index i1(a); delete from t1 where a > 2000000; diff --git a/mysql-test/suite/rpl/r/rpl_do_grant.result b/mysql-test/suite/rpl/r/rpl_do_grant.result index 0d51f771a90..45c5bcf7ba0 100644 --- a/mysql-test/suite/rpl/r/rpl_do_grant.result +++ b/mysql-test/suite/rpl/r/rpl_do_grant.result @@ -162,9 +162,9 @@ SELECT * FROM mysql.procs_priv; Host Db User Routine_name Routine_type Grantor Proc_priv Timestamp SELECT upgrade_alter_func(); ERROR HY000: The user specified as a definer ('create_rout_db'@'localhost') does not exist -USE bug42217_db; -DROP FUNCTION upgrade_del_func; -DROP FUNCTION upgrade_alter_func; +USE test; +DROP FUNCTION bug42217_db.upgrade_del_func; +DROP FUNCTION bug42217_db.upgrade_alter_func; DROP DATABASE bug42217_db; stop slave; DROP USER 'create_rout_db'@'localhost'; diff --git a/mysql-test/suite/rpl/r/rpl_ignore_table.result b/mysql-test/suite/rpl/r/rpl_ignore_table.result index e77be425270..d06dda66267 100644 --- a/mysql-test/suite/rpl/r/rpl_ignore_table.result +++ b/mysql-test/suite/rpl/r/rpl_ignore_table.result @@ -34,6 +34,7 @@ Warnings: Warning 1364 Field 'ssl_cipher' doesn't have a default value Warning 1364 Field 'x509_issuer' doesn't have a default value Warning 1364 Field 'x509_subject' doesn't have a default value +Warning 1364 Field 'auth_string' doesn't have a default value GRANT SELECT ON *.* TO mysqltest6@localhost; GRANT INSERT ON *.* TO mysqltest6@localhost; GRANT INSERT ON test.* TO mysqltest6@localhost; diff --git a/mysql-test/suite/rpl/r/rpl_stm_000001.result b/mysql-test/suite/rpl/r/rpl_stm_000001.result index c2a24cbaa82..2a5e4bdc99f 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_000001.result +++ b/mysql-test/suite/rpl/r/rpl_stm_000001.result @@ -66,6 +66,7 @@ Warnings: Warning 1364 Field 'ssl_cipher' doesn't have a default value Warning 1364 Field 'x509_issuer' doesn't have a default value Warning 1364 Field 'x509_subject' doesn't have a default value +Warning 1364 Field 'auth_string' doesn't have a default value select select_priv,user from mysql.user where user = _binary'blafasel2'; select_priv user N blafasel2 diff --git a/mysql-test/suite/rpl/r/rpl_table_options.result b/mysql-test/suite/rpl/r/rpl_table_options.result new file mode 100644 index 00000000000..9b0511f6494 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_table_options.result @@ -0,0 +1,25 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +install plugin example soname 'ha_example.so'; +set storage_engine=example; +create table t1 (a int not null) ull=12340; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL +) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `ull`=12340 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 `ull`=12340 +drop table t1; +set storage_engine=default; +select 1; +1 +1 +uninstall plugin example; diff --git a/mysql-test/suite/rpl/t/rpl_do_grant.test b/mysql-test/suite/rpl/t/rpl_do_grant.test index b0799b57f6a..457095f8fa6 100644 --- a/mysql-test/suite/rpl/t/rpl_do_grant.test +++ b/mysql-test/suite/rpl/t/rpl_do_grant.test @@ -208,9 +208,9 @@ SELECT upgrade_alter_func(); disconnect create_rout_db_master; disconnect create_rout_db_slave; connection master; -USE bug42217_db; -DROP FUNCTION upgrade_del_func; -DROP FUNCTION upgrade_alter_func; +USE test; +DROP FUNCTION bug42217_db.upgrade_del_func; +DROP FUNCTION bug42217_db.upgrade_alter_func; DROP DATABASE bug42217_db; -- sync_slave_with_master diff --git a/mysql-test/suite/rpl/t/rpl_table_options.test b/mysql-test/suite/rpl/t/rpl_table_options.test new file mode 100644 index 00000000000..b3d75bb0f95 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_table_options.test @@ -0,0 +1,31 @@ +--source include/not_windows_embedded.inc +--source include/have_example_plugin.inc +--source include/master-slave.inc + +--replace_regex /\.dll/.so/ +eval install plugin example soname '$HA_EXAMPLE_SO'; +set storage_engine=example; + +sync_slave_with_master; +connection master; + +# +# only master has example engine installed, +# the slave will have the table created in myisam, +# that does not have ULL table option. +# but because the table was created by the replication +# slave thread, the table will be created anyway, even if +# the option is unknown. +# +create table t1 (a int not null) ull=12340; +show create table t1; + +sync_slave_with_master; +connection slave; +show create table t1; + +connection master; +drop table t1; +set storage_engine=default; +select 1; +uninstall plugin example; diff --git a/mysql-test/suite/vcol/inc/vcol_blocked_sql_funcs_main.inc b/mysql-test/suite/vcol/inc/vcol_blocked_sql_funcs_main.inc new file mode 100644 index 00000000000..01f939337ed --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_blocked_sql_funcs_main.inc @@ -0,0 +1,344 @@ +################################################################################ +# inc/vcol_blocked_sql_funcs_main.inc # +# # +# Purpose: # +# Tests around sql functions # +# # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-08-31 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +# +# NOTE: All SQL functions should be rejected, otherwise BUG. +# + +--echo # RAND() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (b double as (rand())); + +--echo # LOAD_FILE() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(64), b varchar(1024) as (load_file(a))); + +--echo # CURDATE() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime as (curdate())); + +--echo # CURRENT_DATE(), CURRENT_DATE +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime as (current_date)); +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime as (current_date())); + +--echo # CURRENT_TIME(), CURRENT_TIME +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime as (current_time)); +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime as (current_time())); + +--echo # CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime as (current_timestamp())); +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime as (current_timestamp)); + +--echo # CURTIME() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime as (curtime())); + +--echo # LOCALTIME(), LOCALTIME +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime, b varchar(10) as (localtime())); +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime, b varchar(10) as (localtime)); + +--echo # LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6) +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime, b varchar(10) as (localtimestamp())); +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime, b varchar(10) as (localtimestamp)); + +--echo # NOW() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime, b varchar(10) as (now())); + +--echo # SYSDATE() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b varchar(10) as (sysdate())); + +--echo # UNIX_TIMESTAMP() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime, b datetime as (unix_timestamp())); + +--echo # UTC_DATE() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime, b datetime as (utc_date())); + +--echo # UTC_TIME() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime, b datetime as (utc_time())); + +--echo # UTC_TIMESTAMP() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a datetime, b datetime as (utc_timestamp())); + +--echo # MATCH() +if (!$skip_full_text_checks) +{ + -- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED + create table t1 (a varchar(32), b bool as (match a against ('sample text'))); +} + +--echo # BENCHMARK() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3))); + +--echo # CONNECTION_ID() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int as (connection_id())); + +--echo # CURRENT_USER(), CURRENT_USER +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(32) as (current_user())); +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(32) as (current_user)); + +--echo # DATABASE() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024), b varchar(1024) as (database())); + +--echo # FOUND_ROWS() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024), b varchar(1024) as (found_rows())); + +--echo # GET_LOCK() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10))); + +--echo # IS_FREE_LOCK() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a))); + +--echo # IS_USED_LOCK() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a))); + +--echo # LAST_INSERT_ID() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int as (last_insert_id())); + +--echo # MASTER_POS_WAIT() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(32), b int as (master_pos_wait(a,0,2))); + +--echo # NAME_CONST() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(32) as (name_const('test',1))); + +--echo # RELEASE_LOCK() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(32), b int as (release_lock(a))); + +--echo # ROW_COUNT() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int as (row_count())); + +--echo # SCHEMA() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(32) as (schema())); + +--echo # SESSION_USER() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(32) as (session_user())); + +--echo # SLEEP() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (sleep(a))); + +--echo # SYSTEM_USER() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(32) as (system_user())); + +--echo # USER() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024), b varchar(1024) as (user())); + +--echo # UUID_SHORT() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024) as (uuid_short())); + +--echo # UUID() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024) as (uuid())); + +--echo # VALUES() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024), b varchar(1024) as (values(a))); + +--echo # VERSION() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024), b varchar(1024) as (version())); + +--echo # ENCRYPT() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024), b varchar(1024) as (encrypt(a))); + +--echo # Stored procedures + +delimiter //; +create procedure p1() +begin + select current_user(); +end // + +create function f1() +returns int +begin + return 1; +end // + +delimiter ;// + +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int as (p1())); +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int as (f1())); + +drop procedure p1; +drop function f1; + +--echo # Unknown functions +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int as (f1())); + +--echo # +--echo # GROUP BY FUNCTIONS +--echo # + +--echo # AVG() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (avg(a))); + +--echo # BIT_AND() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (bit_and(a))); + +--echo # BIT_OR() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (bit_or(a))); + +--echo # BIT_XOR() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (bit_xor(a))); + +--echo # COUNT(DISTINCT) +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (count(distinct a))); + +--echo # COUNT() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (count(a))); + +--echo # GROUP_CONCAT() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(32), b int as (group_concat(a,''))); + +--echo # MAX() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (max(a))); + +--echo # MIN() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (min(a))); + +--echo # STD() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (std(a))); + +--echo # STDDEV_POP() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (stddev_pop(a))); + +--echo # STDDEV_SAMP() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (stddev_samp(a))); + +--echo # STDDEV() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (stddev(a))); + +--echo # SUM() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (sum(a))); + +--echo # VAR_POP() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (var_pop(a))); + +--echo # VAR_SAMP() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (var_samp(a))); + +--echo # VARIANCE() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (variance(a))); + +--echo # +--echo # XML FUNCTIONS +--echo # + +--echo # ExtractValue() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]'))); + +--echo # UpdateXML() +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>'))); + +--echo # +--echo # Sub-selects +--echo # + +create table t1 (a int); +-- error ER_PARSE_ERROR +create table t2 (a int, b int as (select count(*) from t1)); +drop table t1; + +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as ((select 1))); +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (a+(select 1))); + +--echo # +--echo # SP functions +--echo # + +--disable_warnings +drop function if exists sub1; +--enable_warnings +create function sub1(i int) returns int deterministic + return i+1; +select sub1(1); +-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int, b int as (a+sub3(1))); +drop function sub1; + +--echo # +--echo # Long expression + +let $tmp_long_string = `SELECT repeat('a',240)`; +eval create table t1 (a int, b varchar(300) as (concat(a,'$tmp_long_string'))); +drop table t1; +let $tmp_long_string = `SELECT repeat('a',243)`; +--error ER_WRONG_STRING_LENGTH +eval create table t1 (a int, b varchar(300) as (concat(a,'$tmp_long_string'))); + +--echo # +--echo # Constant expression +--error ER_CONST_EXPR_IN_VCOL +create table t1 (a int as (PI())); diff --git a/mysql-test/suite/vcol/inc/vcol_cleanup.inc b/mysql-test/suite/vcol/inc/vcol_cleanup.inc new file mode 100644 index 00000000000..f8adec03b07 --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_cleanup.inc @@ -0,0 +1,25 @@ +################################################################################ +# inc/vcol_cleanup.inc # +# # +# Purpose: # +# Removal of the objects created by the t/<test_name>.test # +# scripts. # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-08-31 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +--disable_warnings +--disable_query_log +DROP VIEW IF EXISTS v1,v2; +DROP TABLE IF EXISTS t1,t2,t3; +DROP PROCEDURE IF EXISTS p1; +DROP FUNCTION IF EXISTS f1; +DROP TRIGGER IF EXISTS trg1; +DROP TRIGGER IF EXISTS trg2; +--enable_query_log +--enable_warnings diff --git a/mysql-test/suite/vcol/inc/vcol_column_def_options.inc b/mysql-test/suite/vcol/inc/vcol_column_def_options.inc new file mode 100644 index 00000000000..2f28136ad63 --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_column_def_options.inc @@ -0,0 +1,113 @@ +################################################################################ +# inc/vcol_column_def_options.inc # +# # +# Purpose: # +# Testing different optional parameters specified when defining # +# a virtual column. # +# # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-02 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +--echo # +--echo # Section 1. Wrong column definition options +--echo # - NOT NULL +--echo # - NULL +--echo # - DEFAULT <value> +--echo # - AUTO_INCREMENT +--echo # - [PRIMARY] KEY + +--echo # NOT NULL +--error ER_PARSE_ERROR +create table t1 (a int, b int as (a+1) not null); +create table t1 (a int); +--error ER_PARSE_ERROR +alter table t1 add column b int as (a+1) not null; +drop table t1; + +--echo # NULL +--error ER_PARSE_ERROR +create table t1 (a int, b int as (a+1) null); +create table t1 (a int); +--error ER_PARSE_ERROR +alter table t1 add column b int as (a+1) null; +drop table t1; + +--echo # DEFAULT +--error ER_PARSE_ERROR +create table t1 (a int, b int as (a+1) default 0); +create table t1 (a int); +--error ER_PARSE_ERROR +alter table t1 add column b int as (a+1) default 0; +drop table t1; + +--echo # AUTO_INCREMENT +--error ER_PARSE_ERROR +create table t1 (a int, b int as (a+1) AUTO_INCREMENT); +create table t1 (a int); +--error ER_PARSE_ERROR +alter table t1 add column b int as (a+1) AUTO_INCREMENT; +drop table t1; + +--echo # [PRIMARY] KEY +--error ER_PARSE_ERROR +create table t1 (a int, b int as (a+1) key); +--error ER_PARSE_ERROR +create table t1 (a int, b int as (a+1) primary key); +create table t1 (a int); +--error ER_PARSE_ERROR +alter table t1 add column b int as (a+1) key; +--error ER_PARSE_ERROR +alter table t1 add column b int as (a+1) primary key; +drop table t1; + +--echo # Section 2. Other column definition options +--echo # - COMMENT +--echo # - REFERENCES (only syntax testing here) +--echo # - STORED (only systax testing here) +create table t1 (a int, b int as (a % 2) comment 'my comment'); +show create table t1; +describe t1; +drop table t1; +create table t1 (a int, b int as (a % 2)); +alter table t1 modify b int as (a % 2) comment 'my comment'; +show create table t1; +describe t1; +insert into t1 (a) values (1); +select * from t1; +insert into t1 values (2,default); +select a,b from t1; +create table t2 like t1; +show create table t2; +describe t2; +insert into t2 (a) values (1); +select * from t2; +insert into t2 values (2,default); +select a,b from t2; +drop table t2; +drop table t1; + +create table t1 (a int, b int as (a % 2) persistent); +show create table t1; +describe t1; +insert into t1 (a) values (1); +select * from t1; +insert into t1 values (2,default); +select a,b from t1; +drop table t1; + + +create table t2 (a int); +create table t1 (a int, b int as (a % 2) persistent references t2(a)); +show create table t1; +drop table t1; +create table t1 (a int, b int as (a % 2)); +--error ER_PARSE_ERROR +alter table t1 modify b int as (a % 2) persistent references t2(a); +show create table t1; +drop table t1; diff --git a/mysql-test/suite/vcol/inc/vcol_dependancies_on_vcol.inc b/mysql-test/suite/vcol/inc/vcol_dependancies_on_vcol.inc new file mode 100644 index 00000000000..91a55013699 --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_dependancies_on_vcol.inc @@ -0,0 +1,43 @@ +################################################################################ +# inc/vcol_dependencies_on_vcol.inc # +# # +# Purpose: # +# Testing scenarios when columns depend on virtual columns, i.e. such as # +# - a virtual column is based on a virtual column # +# - a "real" column on which a virtual one is renamed/dropped # +# - a virtual column involved in partitioning is renamed/dropped # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-02 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +--echo # Can't define a virtual column on another virtual column +--error ER_VCOL_BASED_ON_VCOL +create table t1 (a int, b int as (a+1), c int as (b+1)); +create table t1 (a int, b int as (a+1)); +--error ER_VCOL_BASED_ON_VCOL +alter table t1 add column c int as (b+1); +drop table t1; + +--echo # Can't rename or drop a column used in the function of a virtual column +create table t1 (a int, b int as (a+1)); +--echo # On renaming/dropping a column on which a virtual field is +--echo # defined the following error is displayed: +--echo # "Unknown column 'a' in 'virtual column function'" +--error ER_BAD_FIELD_ERROR +alter table t1 drop column a; +--error ER_BAD_FIELD_ERROR +alter table t1 change a c int; +drop table t1; + +--echo # Can't rename or drop a virtual column used by the paritition function +create table t1 (a int, b int as (a+1)) partition by hash(b); +--error ER_BAD_FIELD_ERROR +alter table t1 drop b; +--error ER_BAD_FIELD_ERROR +alter table t1 change b c int as (a+1); + diff --git a/mysql-test/suite/vcol/inc/vcol_handler.inc b/mysql-test/suite/vcol/inc/vcol_handler.inc new file mode 100644 index 00000000000..49e2ddc2973 --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_handler.inc @@ -0,0 +1,77 @@ +################################################################################ +# inc/vcol_handler.inc # +# # +# Purpose: # +# Testing HANDLER. # +# # +# # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +create table t1 (a int, + b int as (-a), + c int as (-a) persistent, + d char(1), + index (a), + index (c)); +insert into t1 (a,d) values (4,'a'), (2,'b'), (1,'c'), (3,'d'); +select * from t1; + +--echo # HANDLER tbl_name OPEN +handler t1 open; + +--echo # HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) +handler t1 read a > (2); + +--echo # HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE non-vcol_field=expr +handler t1 read a > (2) where d='c'; + +--echo # HANDLER tbl_name READ vcol_index_name = (value1,value2,...) +handler t1 read c = (-2); + +--echo # HANDLER tbl_name READ vcol_index_name = (value1,value2,...) WHERE non-vcol_field=expr +handler t1 read c = (-2) where d='c'; + +--echo # HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE vcol_field=expr +handler t1 read a > (2) where b=-3 && c=-3; + +--echo # HANDLER tbl_name READ vcol_index_name <= (value1,value2,...) +handler t1 read c <= (-2); + +--echo # HANDLER tbl_name READ vcol_index_name > (value1,value2,...) WHERE vcol_field=expr +handler t1 read c <= (-2) where b=-3; + +--echo # HANDLER tbl_name READ vcol_index_name FIRST +handler t1 read c first; + +--echo # HANDLER tbl_name READ vcol_index_name NEXT +handler t1 read c next; + +--echo # HANDLER tbl_name READ vcol_index_name PREV +handler t1 read c prev; + +--echo # HANDLER tbl_name READ vcol_index_name LAST +handler t1 read c last; + +--echo # HANDLER tbl_name READ FIRST where non-vcol=expr +handler t1 read FIRST where a >= 2; + +--echo # HANDLER tbl_name READ FIRST where vcol=expr +handler t1 read FIRST where b >= -2; + +--echo # HANDLER tbl_name READ NEXT where non-vcol=expr +handler t1 read NEXT where d='c'; + +--echo # HANDLER tbl_name READ NEXT where vcol=expr +handler t1 read NEXT where b<=-4; + +--echo # HANDLER tbl_name CLOSE +handler t1 close; + +drop table t1; diff --git a/mysql-test/suite/vcol/inc/vcol_init_vars.pre b/mysql-test/suite/vcol/inc/vcol_init_vars.pre new file mode 100644 index 00000000000..f3c55c22df8 --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_init_vars.pre @@ -0,0 +1,17 @@ +################################################################################ +# inc/vcol_init_vars.pre # +# # +# Purpose: # +# Initialize variables used in t/<name> test cases. # +# # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-08-31 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +let $skip_full_text_check = 0; +let $skip_spatial_index_check = 0; diff --git a/mysql-test/suite/vcol/inc/vcol_ins_upd.inc b/mysql-test/suite/vcol/inc/vcol_ins_upd.inc new file mode 100644 index 00000000000..8d0a51f42c0 --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_ins_upd.inc @@ -0,0 +1,289 @@ +################################################################################ +# inc/vcol_ins_upd.inc # +# # +# Purpose: # +# Testing DDL operations such as INSERT, UPDATE, REPLACE and DELETE. # +# # +# # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +let $create1 = create table t1 (a int, + b int as (-a), + c int as (-a) persistent); +let $create2 = create table t1 (a int unique, + b int as (-a), + c int as (-a) persistent); +let $create3 = create table t1 (a int, + b int as (-a), + c int as (-a) persistent unique); +let $create4 = create table t1 (a int, + b int as (-a), + c int as (-a) persistent unique, + d varchar(16)); +eval $create1; +set sql_warnings = 1; + +--echo # +--echo # *** INSERT *** +--echo # + +--echo # INSERT INTO tbl_name VALUES... DEFAULT is specified against vcols +insert into t1 values (1,default,default); +select * from t1; +delete from t1; +select * from t1; + +--echo # INSERT INTO tbl_name VALUES... NULL is specified against vcols +insert into t1 values (1,null,null); +select * from t1; +delete from t1; +select * from t1; + +--echo # INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols +insert into t1 values (1,2,3); +select * from t1; +delete from t1; +select * from t1; + +--echo # INSERT INTO tbl_name (<non_vcol_list>) VALUES... +insert into t1 (a) values (1), (2); +select * from t1; +delete from t1; +select * from t1; + +--echo # INSERT INTO tbl_name (<normal+vcols>) VALUES... DEFAULT is specified +--echo # against vcols +insert into t1 (a,b) values (1,default), (2,default); +select * from t1; +delete from t1; +select * from t1; + +--echo # INSERT INTO tbl_name (<normal+vcols>) VALUES... NULL is specified against vcols +insert into t1 (a,b) values (1,null), (2,null); +select * from t1; +delete from t1; +select * from t1; + +--echo # INSERT INTO tbl_name (<normal+vcols>) VALUES... a non-NULL value is specified +--echo # against vcols +insert into t1 (a,b) values (1,3), (2,4); +select * from t1; +delete from t1; +select * from t1; +drop table t1; + +--echo # Table with UNIQUE non-vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE +--echo # KEY UPDATE <non_vcol>=expr, <vcol>=expr +eval $create2; +insert into t1 values (1,default,default); +insert into t1 values (1,default,default) + on duplicate key update a=2, b=default; +select a,b,c from t1; +delete from t1 where b in (1,2); +select * from t1; +drop table t1; + +--echo # Table with UNIQUE vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE +--echo # KEY UPDATE <non_vcol>=expr, <vcol>=expr +eval $create3; +insert into t1 values (1,default,default); +insert into t1 values (1,default,default) + on duplicate key update a=2, b=default; +select a,b,c from t1; + +--echo # CREATE new_table ... LIKE old_table +--echo # INSERT INTO new_table SELECT * from old_table +create table t2 like t1; +insert into t2 select * from t1; +select * from t1; +drop table t2; + +--echo # CREATE new_table ... LIKE old_table INSERT INTO new_table (<non-vcols>, <vcols>) +--echo # SELECT <non-vcols>, <vcols> from old_table +insert into t1 values (1,default,default); +select * from t1; +create table t2 like t1; +insert into t2 (a,b) select a,b from t1; +select * from t2; +drop table t2; +drop table t1; + +--echo # +--echo # *** UPDATE *** +--echo # + +--echo # UPDATE tbl_name SET non-vcol=expr WHERE non-vcol=expr +eval $create1; +insert into t1 (a) values (1), (2); +select * from t1; +update t1 set a=3 where a=2; +select * from t1; +delete from t1; +select * from t1; + +--echo # UPDATE tbl_name SET vcol=expr WHERE non-vcol=expr +insert into t1 (a) values (1), (2); +select * from t1; +update t1 set c=3 where a=2; +select * from t1; +delete from t1; +select * from t1; + +--echo # UPDATE tbl_name SET non-vcol=expr WHERE vcol=expr +insert into t1 (a) values (1), (2); +select * from t1; +update t1 set a=3 where b=-2; +select * from t1; +delete from t1; +select * from t1; + +--echo # UPDATE tbl_name SET vcol=expr WHERE vcol=expr +insert into t1 (a) values (1), (2); +select * from t1; +update t1 set c=3 where b=-2; +select * from t1; +delete from t1; +select * from t1; +drop table t1; + +--echo # INDEX created on vcol +--echo # UPDATE tbl_name SET non-vcol=expr WHERE vcol=const +eval $create3; +insert into t1 (a) values (1), (2); +select * from t1; +update t1 set a=3 where c=-2; +select * from t1; +delete from t1; +select * from t1; + + +--echo # INDEX created on vcol +--echo # UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2 +insert into t1 (a) values (1), (2); +select * from t1; +update t1 set a=3 where c between -3 and -2; +select * from t1; +delete from t1; +select * from t1; + +--echo # No INDEX created on vcol +--echo # UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2 +insert into t1 (a) values (1), (2); +select * from t1; +update t1 set a=3 where b between -3 and -2; +select * from t1; +delete from t1; +select * from t1; + +--echo # INDEX created on vcol +--echo # UPDATE tbl_name SET non-vcol=expr +--echo # WHERE vcol=between const1 and const2 ORDER BY vcol +insert into t1 (a) values (1), (2), (3), (4), (5); +select * from t1; +update t1 set a=6 where c between -1 and 0 + order by c; +select * from t1; +delete from t1 where c between -6 and 0; +select * from t1; + +--echo # INDEX created on vcol +--echo # UPDATE tbl_name SET non-vcol=expr +--echo # WHERE vcol=between const1 and const2 ORDER BY vcol LIMIT 2 +insert into t1 (a) values (1), (2), (3), (4), (5); +select * from t1; +update t1 set a=6 where c between -1 and 0 + order by c limit 2; +select * from t1; +delete from t1 where c between -2 and 0 order by c; +select * from t1; +delete from t1; + +--echo # INDEX created on vcol +--echo # UPDATE tbl_name SET non-vcol=expr +--echo # WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3 +insert into t1 (a) values (1), (2), (3), (4), (5); +select * from t1; +update t1 set a=6 where (c between -2 and 0) and (b=-1); +select * from t1; +delete from t1; + +--echo # INDEX created on vcol +--echo # UPDATE tbl_name SET non-vcol=expr +--echo # WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3 +--echo # ORDER BY indexed vcol +insert into t1 (a) values (1), (2), (3), (4), (5); +select * from t1; +update t1 set a=6 where (c between -2 and 0) and (b=-1) order by c; +select * from t1; +delete from t1; +drop table t1; + +let $innodb_engine = `SELECT @@session.storage_engine='innodb'`; +if ($innodb_engine) +{ + --echo # + --echo # Verify ON UPDATE/DELETE actions of FOREIGN KEYs + create table t2 (a int primary key, name varchar(10)); + create table t1 (a int primary key, b int as (a % 10) persistent); + insert into t2 values (1, 'value1'), (2,'value2'), (3,'value3'); + insert into t1 (a) values (1),(2),(3); + select * from t1; + select * from t2; + select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a; + + --echo # - ON UPDATE RESTRICT + alter table t1 add foreign key (b) references t2(a) on update restrict; + --error ER_NO_REFERENCED_ROW_2 + insert into t1 (a) values (4); + --error ER_ROW_IS_REFERENCED_2 + update t2 set a=4 where a=3; + select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a; + alter table t1 drop foreign key t1_ibfk_1; + + --echo # - ON DELETE RESTRICT + alter table t1 add foreign key (b) references t2(a) on delete restrict; + --error ER_ROW_IS_REFERENCED_2 + delete from t2 where a=3; + select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a; + select t1.a, t1.b, t2.name from t1 left outer join t2 on (t1.b=t2.a); + alter table t1 drop foreign key t1_ibfk_1; + + --echo # - ON DELETE CASCADE + alter table t1 add foreign key (b) references t2(a) on delete cascade; + delete from t2 where a=3; + select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a; + select t1.a, t1.b, t2.name from t1 left outer join t2 on (t1.b=t2.a); + alter table t1 drop foreign key t1_ibfk_1; + + drop table t1; + drop table t2; +} + +--echo # +--echo # *** REPLACE *** +--echo # + +--echo # UNIQUE INDEX on vcol +--echo # REPLACE tbl_name (non-vcols) VALUES (non-vcols); +eval $create4; +insert into t1 (a,d) values (1,'a'), (2,'b'); +select * from t1; +replace t1 (a,d) values (1,'c'); +select * from t1; +delete from t1; +select * from t1; + + +# *** DELETE +# All required tests for DELETE are performed as part of the above testing +# for INSERT, UPDATE and REPLACE. + +set sql_warnings = 0; +drop table t1; diff --git a/mysql-test/suite/vcol/inc/vcol_keys.inc b/mysql-test/suite/vcol/inc/vcol_keys.inc new file mode 100644 index 00000000000..68a40afea92 --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_keys.inc @@ -0,0 +1,163 @@ +################################################################################ +# inc/vcol_keys.inc # +# # +# Purpose: # +# Testing keys, indexes defined upon virtual columns. # +# # +# # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-02 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + + +--echo # - UNIQUE KEY +--echo # - INDEX +--echo # - FULLTEXT INDEX +--echo # - SPATIAL INDEX (not supported) +--echo # - FOREIGN INDEX (partially supported) +--echo # - CHECK (allowed but not used) + +--echo # UNIQUE +--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN +create table t1 (a int, b int as (a*2) unique); +create table t1 (a int, b int as (a*2) persistent unique); +show create table t1; +describe t1; +drop table t1; + +--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN +create table t1 (a int, b int as (a*2), unique key (b)); +create table t1 (a int, b int as (a*2) persistent, unique (b)); +show create table t1; +describe t1; +drop table t1; + +create table t1 (a int, b int as (a*2)); +--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN +alter table t1 add unique key (b); +drop table t1; +create table t1 (a int, b int as (a*2) persistent); +alter table t1 add unique key (b); +drop table t1; + +--echo # Testing data manipulation operations involving UNIQUE keys +--echo # on virtual columns can be found in: +--echo # - vcol_ins_upd.inc +--echo # - vcol_select.inc + +--echo # +--echo # INDEX +--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN +create table t1 (a int, b int as (a*2), index (b)); +--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN +create table t1 (a int, b int as (a*2), index (a,b)); + +create table t1 (a int, b int as (a*2) persistent, index (b)); +show create table t1; +describe t1; +drop table t1; + +create table t1 (a int, b int as (a*2) persistent, index (a,b)); +show create table t1; +describe t1; +drop table t1; + +create table t1 (a int, b int as (a*2)); +--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN +alter table t1 add index (b); +--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN +alter table t1 add index (a,b); +drop table t1; + +create table t1 (a int, b int as (a*2) persistent); +alter table t1 add index (b); +drop table t1; + +create table t1 (a int, b int as (a*2) persistent); +alter table t1 add index (a,b); +create table t2 like t1; +drop table t2; +drop table t1; + +--echo # Testing data manipulation operations involving INDEX +--echo # on virtual columns can be found in: +--echo # - vcol_select.inc + +--echo # +--echo # TODO: FULLTEXT INDEX + +--echo # SPATIAL INDEX +if (!$skip_spatial_index_check) +{ + --echo # Error "All parts of a SPATIAL index must be NOT NULL" + --error ER_SPATIAL_CANT_HAVE_NULL + create table t1 (a int, b int as (a+1) persistent, spatial index (b)); + create table t1 (a int, b int as (a+1) persistent); + --error ER_SPATIAL_CANT_HAVE_NULL + alter table t1 add spatial index (b); + drop table t1; +} + +--echo # FOREIGN KEY + +--echo # Rejected FK options. +--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN +create table t1 (a int, b int as (a+1) persistent, + foreign key (b) references t2(a) on update set null); +--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN +create table t1 (a int, b int as (a+1) persistent, + foreign key (b) references t2(a) on update cascade); +--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN +create table t1 (a int, b int as (a+1) persistent, + foreign key (b) references t2(a) on delete set null); + +create table t1 (a int, b int as (a+1) persistent); +--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN +alter table t1 add foreign key (b) references t2(a) on update set null; +--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN +alter table t1 add foreign key (b) references t2(a) on update cascade; +--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN +alter table t1 add foreign key (b) references t2(a) on delete set null; +drop table t1; + +--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN +create table t1 (a int, b int as (a+1), + foreign key (b) references t2(a)); + +create table t1 (a int, b int as (a+1)); +--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN +alter table t1 add foreign key (b) references t2(a); +drop table t1; + +--echo # Allowed FK options. +create table t2 (a int primary key, b char(5)); +create table t1 (a int, b int as (a % 10) persistent, + foreign key (b) references t2(a) on update restrict); +drop table t1; +create table t1 (a int, b int as (a % 10) persistent, + foreign key (b) references t2(a) on update no action); +drop table t1; +create table t1 (a int, b int as (a % 10) persistent, + foreign key (b) references t2(a) on delete restrict); +drop table t1; +create table t1 (a int, b int as (a % 10) persistent, + foreign key (b) references t2(a) on delete cascade); +drop table t1; +create table t1 (a int, b int as (a % 10) persistent, + foreign key (b) references t2(a) on delete no action); +drop table t1; + +--echo +--echo # Testing data manipulation operations involving FOREIGN KEY +--echo # on virtual columns can be found in: +--echo # - vcol_ins_upd.inc +--echo # - vcol_select.inc + +--echo # +--echo # TODO: CHECK + diff --git a/mysql-test/suite/vcol/inc/vcol_non_stored_columns.inc b/mysql-test/suite/vcol/inc/vcol_non_stored_columns.inc new file mode 100644 index 00000000000..c586479618a --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_non_stored_columns.inc @@ -0,0 +1,162 @@ +################################################################################ +# inc/vcol_non_stored_columns.inc # +# # +# Purpose: # +# Ensure that MySQL behaviour is consistent irrelevant of # +# - the place of a non-stored column among other columns, # +# - the total number of non-stored fields. # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +--echo # Case 1. All non-stored columns. +--echo # This scenario is currently impossible due to the fact that virtual columns +--echo # with a constant expression are not allowed. + +--echo # Case 2. CREATE +--echo # - Column1: "real" +--echo # - Column 2: virtual non-stored +create table t1 (a int, b int as (-a)); +insert into t1 values (1,default); +select * from t1; +insert into t1 values (2,default); +select * from t1; +drop table t1; + +--echo # Case 3. CREATE +--echo # - Column1: "real" +--echo # - Column 2: virtual stored +create table t1 (a int, b int as (-a) persistent); +insert into t1 values (1,default); +select * from t1; +insert into t1 values (2,default); +select * from t1; +drop table t1; + +--echo # Case 4. CREATE +--echo # - Column1: virtual non-stored +--echo # - Column2: "real" +create table t1 (a int as (-b), b int); +insert into t1 values (default,1); +select * from t1; +insert into t1 values (default,2); +select * from t1; +drop table t1; + +--echo # Case 5. CREATE +--echo # - Column1: virtual stored +--echo # - Column2: "real" +create table t1 (a int as (-b) persistent, b int); +insert into t1 values (default,1); +select * from t1; +insert into t1 values (default,2); +select * from t1; +drop table t1; + +--echo # Case 6. CREATE +--echo # - Column1: "real" +--echo # - Column2: virtual non-stored +--echo # - Column3: virtual stored +create table t1 (a int, b int as (-a), c int as (-a) persistent); +insert into t1 values (1,default,default); +select * from t1; +insert into t1 values (2,default,default); +select * from t1; +drop table t1; + +--echo # Case 7. ALTER. Modify virtual stored -> virtual non-stored +create table t1 (a int, b int as (a % 2) persistent); +--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN +alter table t1 modify b int as (a % 2); +show create table t1; +drop table t1; + +--echo # Case 8. ALTER. Modify virtual non-stored -> virtual stored +create table t1 (a int, b int as (a % 2)); +--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN +alter table t1 modify b int as (a % 2) persistent; +show create table t1; +drop table t1; + +--echo # Case 9. CREATE LIKE +--echo # - Column1: "real" +--echo # - Column2: virtual non-stored +--echo # - Column3: virtual stored +create table t1 (a int, b int as (-a), c int as (-a) persistent); +create table t2 like t1; +insert into t2 values (1,default,default); +select * from t2; +insert into t2 values (2,default,default); +select * from t2; +drop table t2; +drop table t1; + +--echo # Case 10. ALTER. Dropping a virtual non-stored column. +--echo # - Column1: virtual non-stored +--echo # - Column2: "real" +create table t1 (a int as (-b), b int, c varchar(5)); +insert into t1 values (default,1,'v1'); +insert into t1 values (default,2,'v2'); +select * from t1; +alter table t1 drop column a; +select * from t1; +show create table t1; +drop table t1; + +--echo # Case 11. ALTER. Dropping a virtual stored column. +--echo # - Column1: virtual stored +--echo # - Column2: "real" +create table t1 (a int as (-b) persistent, b int, c char(5)); +insert into t1 values (default,1,'v1'); +insert into t1 values (default,2,'v2'); +select * from t1; +alter table t1 drop column a; +select * from t1; +show create table t1; +drop table t1; + +--echo # Case 12. ALTER. Adding a new virtual non-stored column. +create table t1 (a int, b datetime); +insert into t1 values (1,'2008-09-04'); +insert into t1 values (2,'2008-09-05'); +select * from t1; +alter table t1 add column c int as (dayofyear(b)) after a; +select * from t1; +show create table t1; +drop table t1; + +--echo # Case 13. ALTER. Adding a new virtual stored column. +create table t1 (a int, b datetime); +insert into t1 values (1,'2008-09-04'); +insert into t1 values (2,'2008-09-05'); +select * from t1; +alter table t1 add column c int as (dayofyear(b)) persistent after a; +select * from t1; +show create table t1; +drop table t1; + +--echo # Case 14. ALTER. Changing the expression of a virtual stored column. +create table t1 (a int, b datetime, c int as (week(b)) persistent); +insert into t1 values (1,'2008-09-04',default); +insert into t1 values (2,'2008-09-05',default); +select * from t1; +alter table t1 change column c c int as (week(b,1)) persistent; +select * from t1; +show create table t1; +drop table t1; + +--echo # Case 15. ALTER. Changing the expression of a virtual non-stored column. +create table t1 (a int, b datetime, c int as (week(b))); +insert into t1 values (1,'2008-09-04',default); +insert into t1 values (2,'2008-09-05',default); +select * from t1; +alter table t1 change column c c int as (week(b,1)); +select * from t1; +show create table t1; +drop table t1; + diff --git a/mysql-test/suite/vcol/inc/vcol_partition.inc b/mysql-test/suite/vcol/inc/vcol_partition.inc new file mode 100644 index 00000000000..c20dfaaa2a4 --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_partition.inc @@ -0,0 +1,127 @@ +################################################################################ +# inc/vcol_partition.inc # +# # +# Purpose: # +# Testing partitioning tables with virtual columns. # +# # +# # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +--source include/have_partition.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +--echo # Case 1. Partitioning by RANGE based on a non-stored virtual column. + +CREATE TABLE t1 ( + a DATE NOT NULL, + b int as (year(a)) +) +PARTITION BY RANGE( b ) ( + PARTITION p0 VALUES LESS THAN (2006), + PARTITION p2 VALUES LESS THAN (2008) +); + +insert into t1 values ('2006-01-01',default); +insert into t1 values ('2007-01-01',default); +insert into t1 values ('2005-01-01',default); +select * from t1; + +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; + +--echo # Modify the expression of virtual column b +ALTER TABLE t1 modify b int as (year(a)-1); + +select * from t1; + +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; + +drop table t1; + +--echo # Case 2. Partitioning by LIST based on a stored virtual column. + +CREATE TABLE t1 (a int, b int as (a % 3 ) persistent) +PARTITION BY LIST (a+1) +(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2)); + +insert into t1 values (1,default); +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; +select * from t1; + +# +# NOTE: The following tests are currently failing due to a +# [suspected] bug in the existing partition functionality. +# Here is what was observed when using mysqld compiled prior +# to adding the virtual column functionality. +# mysql> create table t1 (a int) partition by list (a) +# (partition p1 values in (1), partition p2 values in (2)); +# Query OK, 0 rows affected (0.00 sec) +# +# mysql> insert into t1 values (1), (1), (2); +# Query OK, 3 rows affected (0.00 sec) +# Records: 3 Duplicates: 0 Warnings: 0 +# +# mysql> select * from t1; +# +------+ +# | a | +# +------+ +# | 1 | +# | 1 | +# | 2 | +# +------+ +# 3 rows in set (0.00 sec) +# +# mysql> alter table t1 reorganize partition p1 into +# (partition p1 values in (3)); +# Query OK, 2 rows affected (3.90 sec) +# Records: 2 Duplicates: 2 Warnings: 0 +# +# mysql> select * from t1; +# +------+ +# | a | +# +------+ +# | 2 | <- Two row have been lost!!! +# +------+ +# 1 row in set (0.00 sec) + +# +#alter table t1 change b b int as ((a % 3)+1) persistent; +#--error ER_NO_PARTITION_FOR_GIVEN_VALUE +#alter table t1 change b b int as (a % 2) persistent; +#select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; + +select * from t1; + +drop table t1; + +--echo # Case 3. Partitioning by HASH based on a non-stored virtual column. + +CREATE TABLE t1 ( + a DATE NOT NULL, + b int as (year(a)) +) +PARTITION BY HASH( b % 3 ) PARTITIONS 3; + +insert into t1 values ('2005-01-01',default); +insert into t1 values ('2006-01-01',default); +select * from t1; + +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; + +--echo # Modify the expression of virtual column b +ALTER TABLE t1 modify b int as (year(a)-1); + +select * from t1; + +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; + +drop table t1; diff --git a/mysql-test/suite/vcol/inc/vcol_select.inc b/mysql-test/suite/vcol/inc/vcol_select.inc new file mode 100644 index 00000000000..28c3416a55a --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_select.inc @@ -0,0 +1,216 @@ +################################################################################ +# inc/vcol_select.inc # +# # +# Purpose: # +# Testing different SELECTs. # +# # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-18 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +# Table t1 is used below to test: +# - Join type of ALL (sequential scan of the entire table) +# - Join type of Index +# - Join type of Range +# - Join type of Ref_or_null +create table t1 (a int, + b int as (-a), + c int as (-a) persistent, + index (c)); +insert into t1 (a) values (2), (1), (1), (3), (NULL); + +# Table t2 is used below to test: +# - Join type of system and const +create table t2 like t1; +insert into t2 (a) values (1); + +# Table t3 is used below to test +# - Join type of Eq_ref with a unique virtual column +# - Join type of Const +create table t3 (a int primary key, + b int as (-a), + c int as (-a) persistent unique); +insert into t3 (a) values (2),(1),(3); + + +--echo # select_type=SIMPLE, type=system +let $s = select * from t2; +eval $s; +eval explain $s; + +let $s = select * from t2 where c=-1; +eval $s; +eval explain $s; + +--echo # select_type=SIMPLE, type=ALL +let $s = select * from t1 where b=-1; +eval $s; +eval explain $s; + +--echo # select_type=SIMPLE, type=const +let $s = select * from t3 where a=1; +eval $s; +eval explain $s; + +--echo # select_type=SIMPLE, type=range +let $s = select * from t3 where c>=-1; +eval $s; +eval explain $s; + +--echo # select_type=SIMPLE, type=ref +let $s = select * from t1,t3 where t1.c=t3.c and t3.c=-1; +eval $s; +eval explain $s; + +--echo # select_type=PRIMARY, type=index,ALL +let $s = select * from t1 where b in (select c from t3); +eval $s; +eval explain $s; + +--echo # select_type=PRIMARY, type=range,ref +let $s = select * from t1 where c in (select c from t3 where c between -2 and -1); +eval $s; +eval explain $s; + +--echo # select_type=UNION, type=system +--echo # select_type=UNION RESULT, type=<union1,2> +let $s = select * from t1 union select * from t2; +eval $s; +eval explain $s; + +--echo # select_type=DERIVED, type=system +let $s = select * from (select a,b,c from t1) as t11; +eval $s; +eval explain $s; + +--echo ### +--echo ### Using aggregate functions with/without DISTINCT +--echo ### +--echo # SELECT COUNT(*) FROM tbl_name +let $s = select count(*) from t1; +eval $s; +eval explain $s; + +--echo # SELECT COUNT(DISTINCT <non-vcol>) FROM tbl_name +let $s = select count(distinct a) from t1; +eval $s; +eval explain $s; + +--echo # SELECT COUNT(DISTINCT <non-stored vcol>) FROM tbl_name +let $s = select count(distinct b) from t1; +eval $s; +eval explain $s; + +--echo # SELECT COUNT(DISTINCT <stored vcol>) FROM tbl_name +let $s = select count(distinct c) from t1; +eval $s; +eval explain $s; + +--echo ### +--echo ### filesort & range-based utils +--echo ### +--echo # SELECT * FROM tbl_name WHERE <vcol expr> +let $s = select * from t3 where c >= -2; +eval $s; +eval explain $s; + +--echo # SELECT * FROM tbl_name WHERE <non-vcol expr> +let $s = select * from t3 where a between 1 and 2; +eval $s; +eval explain $s; + +--echo # SELECT * FROM tbl_name WHERE <non-indexed vcol expr> +let $s = select * from t3 where b between -2 and -1; +eval $s; +eval explain $s; + +--echo # SELECT * FROM tbl_name WHERE <indexed vcol expr> +let $s = select * from t3 where c between -2 and -1; +eval $s; +eval explain $s; + +#### Remove for MyISAM due to a bug +#### when all the three records are returned (a=1,2,3) +#### instead of just two (a=1,2). +#### This bug is presumably in base SQL routines as the same happens +#### with this table: +#### create table t4 (a int primary key, b int, c int unique); +let $myisam_engine = `SELECT @@session.storage_engine='myisam'`; +if (!$myisam_engine) +{ + --echo # SELECT * FROM tbl_name WHERE <non-vcol expr> ORDER BY <non-indexed vcol> + let $s = select * from t3 where a between 1 and 2 order by b; + eval $s; + eval explain $s; +} + +--echo # SELECT * FROM tbl_name WHERE <non-vcol expr> ORDER BY <indexed vcol> +let $s = select * from t3 where a between 1 and 2 order by c; +eval $s; +eval explain $s; + +--echo # SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-vcol> +let $s = select * from t3 where b between -2 and -1 order by a; +eval $s; +eval explain $s; + +#### Remove for MyISAM due to a bug +#### when all the three records are returned (a=1,2,3) +#### instead of just two (a=1,2). +#### This bug is presumably in base SQL routines as the same happens +#### with this table: +#### create table t4 (a int primary key, b int, c int unique); +let $innodb_engine = `SELECT @@session.storage_engine='innodb'`; +if (!$innodb_engine) +{ + --echo # SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-vcol> + let $s = select * from t3 where c between -2 and -1 order by a; + eval $s; + eval explain $s; +} + +--echo # SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-indexed vcol> +let $s = select * from t3 where b between -2 and -1 order by b; +eval $s; +eval explain $s; + +--echo # SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-indexed vcol> +let $s = select * from t3 where c between -2 and -1 order by b; +eval $s; +eval explain $s; + +--echo # SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <indexed vcol> +let $s = select * from t3 where b between -2 and -1 order by c; +eval $s; +eval explain $s; + +--echo # SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <indexed vcol> +let $s = select * from t3 where c between -2 and -1 order by c; +eval $s; +eval explain $s; + +--echo # SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol> +let $s = select sum(b) from t1 group by b; +eval $s; +eval explain $s; + +--echo # SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <indexed vcol> +let $s = select sum(c) from t1 group by c; +eval $s; +eval explain $s; + +--echo # SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <indexed vcol> +let $s = select sum(b) from t1 group by c; +eval $s; +eval explain $s; + +--echo # SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol> +let $s = select sum(c) from t1 group by b; +eval $s; +eval explain $s; + diff --git a/mysql-test/suite/vcol/inc/vcol_supported_sql_funcs.inc b/mysql-test/suite/vcol/inc/vcol_supported_sql_funcs.inc new file mode 100644 index 00000000000..f19bec04c7a --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_supported_sql_funcs.inc @@ -0,0 +1,42 @@ +################################################################################ +# inc/vcol_supported_sql_funcs.inc # +# # +# Purpose: # +# Tests frame for allowed sql functions # +# # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-08-31 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +--enable_warnings +set sql_warnings = 1; +eval create table t1 ($cols); +show create table t1; +if ($rows) +{ + eval insert into t1 values ($values1); + dec $rows; +} +if ($rows) +{ + eval insert into t1 values ($values2); + dec $rows; +} +if ($rows) +{ + eval insert into t1 values ($values3); + dec $rows; +} +if ($rows) +{ + eval insert into t1 values ($values4); + dec $rows; +} +select * from t1; +drop table t1; +set sql_warnings = 0; diff --git a/mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc b/mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc new file mode 100644 index 00000000000..daf59c38a7e --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc @@ -0,0 +1,1229 @@ +################################################################################ +# inc/vcol_supported_sql_funcs_main.inc # +# # +# Purpose: # +# Tests frame for allowed sql functions # +# # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-08-31 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +--echo # +--echo # NUMERIC FUNCTIONS +--echo # + +--echo # ABS() +let $cols = a int, b int as (abs(a)); +let $values1 = -1, default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # ACOS() +let $cols = a double, b double as (format(acos(a),6)); +let $values1 = 1, default; +let $values2 = 1.0001,default; +let $values3 = 0,default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # ASIN() +let $cols = a double, b double as (format(asin(a),6)); +let $values1 = 0.2, default; +let $values2 = 1.0001,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo #ATAN +let $cols = a double, b double, c double as (format(atan(a,b),6)); +let $values1 = -2,2,default; +let $values2 = format(PI(),6),0,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +let $cols = a double, c double as (format(atan(a),6)); +let $values1 = -2,default; +let $values2 = format(PI(),6),default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # ATAN2 +let $cols = a double, b double, c double as (format(atan2(a,b),6)); +let $values1 = -2,2,default; +let $values2 = format(PI(),6),0,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # CEIL() +let $cols = a double, b int as (ceil(a)); +let $values1 = 1.23,default; +let $values2 = -1.23,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # CONV() +let $cols = a varchar(10), b int, c int, d varchar(10) as (conv(a,b,c)); +let $values1 = 'a',16,2,default; +let $values2 = '6e',18,8,default; +let $values3 = -17,10,-18,default; +let $values4 = 10+'10'+'10'+0xa,10,10,default; +let $rows = 4; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # COS() +let $cols = a double, b double as (format(cos(a),6)); +let $values1 = format(PI(),6),default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # COT() +let $cols = a double, b double as (format(cot(a),6)); +let $values1 = 12,default; +let $values2 = 0,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # CRC32() +let $cols = a varchar(10), b long as (crc32(a)); +let $values1 = 'MySQL',default; +let $values2 = 'mysql',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # DEGREES() +let $cols = a double, b double as (format(degrees(a),6)); +let $values1 = format(PI(),6),default; +let $values2 = format(PI()/2,6),default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # / +let $cols = a double, b double as (a/2); +let $values1 = 2,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # EXP() +let $cols = a double, b double as (format(exp(a),6)); +let $values1 = 2,default; +let $values2 = -2,default; +let $values3 = 0,default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # FLOOR() +let $cols = a double, b long as (floor(a)); +let $values1 = 1.23,default; +let $values2 = -1.23,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # LN() +let $cols = a double, b double as (format(ln(a),6)); +let $values1 = 2,default; +let $values2 = -2,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # LOG() +let $cols = a double, b double, c double as (format(log(a,b),6)); +let $values1 = 2,65536,default; +let $values2 = 10,100,default; +let $values3 = 1,100,default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +let $cols = a double, b double as (format(log(a),6)); +let $values1 = 2,default; +let $values2 = -2,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # LOG2() +let $cols = a double, b double as (format(log2(a),6)); +let $values1 = 65536,default; +let $values2 = -100,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # LOG10() +let $cols = a double, b double as (format(log10(a),6)); +let $values1 = 2,default; +let $values2 = 100,default; +let $values3 = -100,default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # - +let $cols = a double, b double as (a-1); +let $values1 = 2,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # MOD() +let $cols = a int, b int as (mod(a,10)); +let $values1 = 1,default; +let $values2 = 11,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # % +let $cols = a int, b int as (a % 10); +let $values1 = 1,default; +let $values2 = 11,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # OCT() +let $cols = a double, b varchar(10) as (oct(a)); +let $values1 = 12,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # PI() +let $cols = a double, b double as (format(PI()*a*a,6)); +let $values1 = 1,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # + +let $cols = a int, b int as (a+1); +let $values1 = 1,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # POW, POWER +let $cols = a int, b int as (pow(a,2)), c int as (power(a,2)); +let $values1 = 1,default,default; +let $values2 = 2,default,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # RADIANS() +let $cols = a double, b double as (format(radians(a),6)); +let $values1 = 90,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # ROUND() +let $cols = a double, b int as (round(a)); +let $values1 = -1.23,default; +let $values2 = -1.58,default; +let $values3 = 1.58,default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +let $cols = a double, b double, c int as (round(a,b)); +let $values1 = 1.298,1,default; +let $values2 = 1.298,0,default; +let $values3 = 23.298,-1,default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SIGN() +let $cols = a double, b int as (sign(a)); +let $values1 = -32,default; +let $values2 = 0,default; +let $values3 = 234,default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SIN() +let $cols = a double, b double as (format(sin(a),6)); +let $values1 = format(PI()/2,6),default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SQRT() +let $cols = a double, b double as (format(sqrt(a),6)); +let $values1 = 4,default; +let $values2 = 20,default; +let $values3 = -16,default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # TAN() +let $cols = a double, b double as (format(tan(a),6)); +let $values1 = format(PI(),6),default; +let $values2 = format(PI()+1,6),default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # * +let $cols = a double, b double as (a*3); +let $values1 = 0,default; +let $values2 = 1,default; +let $values3 = 2,default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # TRUNCATE() +let $cols = a double, b double as (truncate(a,4)); +let $values1 = 1.223,default; +let $values2 = 1.999,default; +let $values3 = 1.999,default; +let $values4 = 122,default; +let $rows = 4; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # Unary - +let $cols = a double, b double as (-a); +let $values1 = 1,default; +let $values2 = -1,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # +--echo # STRING FUNCTIONS +--echo # + +--echo # ASCII() +let $cols = a char(2), b int as (ascii(a)); +let $values1 = '2',default; +let $values2 = 2,default; +let $values3 = 'dx',default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # BIN() +let $cols = a int, b varchar(10) as (bin(a)); +let $values1 = 12,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # BIT_LENGTH() +let $cols = a varchar(10), b long as (bit_length(a)); +let $values1 = 'text',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # CHAR_LENGTH() +let $cols = a varchar(10), b long as (char_length(a)); +let $values1 = 'text',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # CHAR() +let $cols = a int, b int, c varbinary(10) as (char(a,b)); +let $values1 = 77,121,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # CHARACTER_LENGTH() +let $cols = a varchar(10), b long as (character_length(a)); +let $values1 = 'text',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # CONCAT_WS() +let $cols = a varchar(10), b varchar(10), c varchar(20) as (concat_ws(',',a,b)); +let $values1 = 'value1','value2',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # CONCAT() +let $cols = a varchar(10), b varchar(10), c varchar(20) as (concat(a,',',b)); +let $values1 = 'value1','value2',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # ELT() +let $cols = a varchar(10), b varchar(10), c int, d varchar(10) as (elt(c,a,b)); +let $values1 = 'value1','value2',1,default; +let $values2 = 'value1','value2',2,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # EXPORT_SET() +let $cols = a int, b varchar(10) as (export_set(a,'1','0','',10)); +let $values1 = 6,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # FIELD() +let $cols = a varchar(10), b varchar(10), c int as (field('aa',a,b)); +let $values1 = 'aa','bb',default; +let $values2 = 'bb','aa',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # FIND_IN_SET() +let $cols = a varchar(10), b varchar(10), c int as (find_in_set(a,b)); +let $values1 = 'aa','aa,bb,cc',default; +let $values2 = 'aa','bb,aa,cc',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # FORMAT() +let $cols = a double, b varchar(20) as (format(a,2)); +let $values1 = 12332.123456,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # HEX() +let $cols = a int, b varchar(10) as (hex(a)); +let $values1 = 17,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +let $cols = a varchar(10), b varchar(10) as (hex(a)); +let $values1 = 'abc',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # INSERT() +let $cols = a varchar(10), b varchar(10), c varchar(20) as (insert(a,length(a),length(b),b)); +let $values1 = 'start,','end',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # INSTR() +let $cols = a varchar(10), b varchar(10), c int as (instr(a,b)); +let $values1 = 'foobarbar,','bar',default; +let $values2 = 'xbar,','foobar',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # LCASE() +let $cols = a varchar(10), b varchar(10) as (lcase(a)); +let $values1 = 'MySQL',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # LEFT() +let $cols = a varchar(10), b varchar(5) as (left(a,5)); +let $values1 = 'foobarbar',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # LENGTH() +let $cols = a varchar(10), b int as (length(a)); +let $values1 = 'text',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # LIKE +let $cols = a varchar(10), b bool as (a like 'H%o'); +let $values1 = 'Hello',default; +let $values2 = 'MySQL',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # LOCATE() +let $cols = a varchar(10), b varchar(10) as (locate('bar',a)); +let $values1 = 'foobarbar',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # LOWER() +let $cols = a varchar(10), b varchar(10) as (lower(a)); +let $values1 = 'MySQL',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # LPAD() +let $cols = a varchar(10), b varchar(10) as (lpad(a,4,' ')); +let $values1 = 'MySQL',default; +let $values2 = 'M',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # LTRIM() +let $cols = a varchar(10), b varchar(10) as (ltrim(a)); +let $values1 = ' MySQL',default; +let $values2 = 'MySQL',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # MAKE_SET() +let $cols = a varchar(10), b varchar(10), c int, d varchar(30) as (make_set(c,a,b)); +let $values1 = 'a','b',1,default; +let $values2 = 'a','b',3,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # MID() +let $cols = a varchar(10), b varchar(10) as (mid(a,1,2)); +let $values1 = 'foobarbar',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # NOT LIKE +let $cols = a varchar(10), b bool as (a not like 'H%o'); +let $values1 = 'Hello',default; +let $values2 = 'MySQL',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # NOT REGEXP +let $cols = a varchar(10), b bool as (a not regexp 'H.+o'); +let $values1 = 'Hello',default; +let $values2 = 'hello',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # OCTET_LENGTH() +let $cols = a varchar(10), b int as (octet_length(a)); +let $values1 = 'text',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # ORD() +let $cols = a varchar(10), b long as (ord(a)); +let $values1 = '2',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # POSITION() +let $cols = a varchar(10), b varchar(10) as (position('bar' in a)); +let $values1 = 'foobarbar',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # QUOTE() +let $cols = a varchar(10), b varchar(10) as (quote(a)); +let $values1 = 'Don\'t',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # REGEXP() +let $cols = a varchar(10), b bool as (a regexp 'H.+o'); +let $values1 = 'Hello',default; +let $values2 = 'hello',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # REPEAT() +let $cols = a varchar(10), b varchar(30) as (repeat(a,3)); +let $values1 = 'MySQL',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # REPLACE() +let $cols = a varchar(10), b varchar(30) as (replace(a,'aa','bb')); +let $values1 = 'maa',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # REVERSE() +let $cols = a varchar(10), b varchar(30) as (reverse(a)); +let $values1 = 'maa',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # RIGHT() +let $cols = a varchar(10), b varchar(10) as (right(a,4)); +let $values1 = 'foobarbar',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # RLIKE() +let $cols = a varchar(10), b bool as (a rlike 'H.+o'); +let $values1 = 'Hello',default; +let $values2 = 'MySQL',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # RPAD() +let $cols = a varchar(10), b varchar(10) as (rpad(a,4,'??')); +let $values1 = 'He',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # RTRIM(); +let $cols = a varchar(10), b varchar(10) as (rtrim(a)); +let $values1 = 'Hello ',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SOUNDEX() +let $cols = a varchar(10), b varchar(20) as (soundex(a)); +let $values1 = 'Hello',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SOUNDS LIKE +let $cols = a varchar(10), b varchar(10), c bool as (a sounds like b); +let $values1 = 'Hello','Hello',default; +let $values2 = 'Hello','MySQL',default; +let $values3 = 'Hello','hello',default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SPACE() +let $cols = a varchar(5), b varchar(10) as (concat(a,space(5))); +let $values1 = 'Hello', default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # STRCMP() +let $cols = a varchar(9), b varchar(9), c tinyint(1) as (strcmp(a,b)); +let $values1 = 'Hello','Hello', default; +let $values2 = 'Hello','Hello1', default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SUBSTR() +let $cols = a varchar(5), b varchar(10) as (substr(a,2)); +let $values1 = 'Hello',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SUBSTRING_INDEX() +let $cols = a varchar(15), b varchar(10) as (substring_index(a,'.',2)); +let $values1 = 'www.mysql.com',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SUBSTRING() +let $cols = a varchar(5), b varchar(10) as (substring(a from 2 for 2)); +let $values1 = 'Hello',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # TRIM() +let $cols = a varchar(15), b varchar(10) as (trim(a)); +let $values1 = ' aa ',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # UCASE() +let $cols = a varchar(5), b varchar(10) as (ucase(a)); +let $values1 = 'MySQL',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # UNHEX() +let $cols = a varchar(15), b varchar(10) as (unhex(a)); +let $values1 = '4D7953514C',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # UPPER() +let $cols = a varchar(5), b varchar(10) as (upper(a)); +let $values1 = 'MySQL',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # +--echo # CONTROL FLOW FUNCTIONS +--echo # + +--echo # CASE +let $cols = a varchar(10), b varchar(16) as (case a when NULL then 'asd' when 'b' then 'B' else a end); +let $values1 = NULL,default; +let $values2 = 'b',default; +let $values3 = 'c',default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # IF +let $cols = a int, b int, c int as (if(a=1,a,b)); +let $values1 = 1,2,default; +let $values2 = 3,4,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # IFNULL +let $cols = a varchar(10), b varchar(10), c varchar(10) as (ifnull(a,'DEFAULT')); +let $values1 = NULL,'adf',default; +let $values2 = 'a','adf',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # NULLIF +let $cols = a varchar(10), b varchar(10) as (nullif(a,'DEFAULT')); +let $values1 = 'DEFAULT',default; +let $values2 = 'a',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # +--echo # OPERATORS +--echo # + +--echo # AND, && +let $cols = a int, b bool as (a>0 && a<2); +let $values1 = -1,default; +let $values2 = 1,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # BETWEEN ... AND ... +let $cols = a int, b bool as (a between 0 and 2); +let $values1 = -1,default; +let $values2 = 1,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # BINARY +let $cols = a varchar(10), b varbinary(10) as (binary a); +let $values1 = '11',default; +let $values2 = 1,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # & +let $cols = a int, b int as (a & 5); +let $values1 = 1,default; +let $values2 = 0,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # ~ +let $cols = a int, b int as (~a); +let $values1 = 1,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # | +let $cols = a int, b int as (a | 5); +let $values1 = 1,default; +let $values2 = 0,default; +let $values3 = 2,default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # ^ +let $cols = a int, b int as (a ^ 5); +let $values1 = 1,default; +let $values2 = 0,default; +let $values3 = 2,default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # DIV +let $cols = a int, b int as (a div 5); +let $values1 = 1,default; +let $values2 = 7,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # <=> +let $cols = a int, b int, c bool as (a <=> b); +let $values1 = 1,1,default; +let $values2 = NULL,NULL,default; +let $values3 = 1,NULL,default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # = +let $cols = a varchar(10), b varchar(10), c bool as (a=b); +let $values1 = 'a','b',default; +let $values2 = 'a','a',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # >= +let $cols = a varchar(10), b varchar(10), c bool as (a >= b); +let $values1 = 'a','b',default; +let $values2 = 'a','a',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # > +let $cols = a varchar(10), b varchar(10), c bool as (a > b); +let $values1 = 'a','b',default; +let $values2 = 'a','a',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # IS NOT NULL +let $cols = a int, b bool as (a is not null); +let $values1 = 1,default; +let $values2 = NULL,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # IS NULL +let $cols = a int, b bool as (a is null); +let $values1 = 1,default; +let $values2 = NULL,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # << +let $cols = a int, b int as (a << 2); +let $values1 = 1,default; +let $values2 = 3,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # <= +let $cols = a varchar(10), b varchar(10), c bool as (a <= b); +let $values1 = 'b','a',default; +let $values2 = 'b','b',default; +let $values3 = 'b','c',default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # < +let $cols = a varchar(10), b varchar(10), c bool as (a < b); +let $values1 = 'b','a',default; +let $values2 = 'b','b',default; +let $values3 = 'b','c',default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # NOT BETWEEN ... AND ... +let $cols = a int, b bool as (a not between 0 and 2); +let $values1 = -1,default; +let $values2 = 1,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # <> +let $cols = a varchar(10), b varchar(10), c bool as (a <> b); +let $values1 = 'b','a',default; +let $values2 = 'b','b',default; +let $values3 = 'b','c',default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # != +let $cols = a varchar(10), b varchar(10), c bool as (a != b); +let $values1 = 'b','a',default; +let $values2 = 'b','b',default; +let $values3 = 'b','c',default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # ||, OR +let $cols = a int, b int as (a>5 || a<3); +let $values1 = 1,default; +let $values2 = 4,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # >> +let $cols = a int, b int as (a >> 2); +let $values1 = 8,default; +let $values2 = 3,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # XOR +let $cols = a int, b int as (a xor 5); +let $values1 = 0,default; +let $values2 = 1,default; +let $values3 = 2,default; +let $rows = 3; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # +--echo # DATE AND TIME FUNCTIONS +--echo # + +--echo # ADDDATE() +let $cols = a datetime, b datetime as (adddate(a,interval 1 month)); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # ADDTIME() +let $cols = a datetime, b datetime as (addtime(a,'02:00:00')); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # CONVERT_TZ() +let $cols = a datetime, b datetime as (convert_tz(a,'MET','UTC')); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # DATE_ADD() +let $cols = a datetime, b datetime as (date_add(a,interval 1 month)); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # DATE_FORMAT() +let $cols = a datetime, b varchar(64) as (date_format(a,'%W %M %D')); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # DATE_SUB() +let $cols = a datetime, b datetime as (date_sub(a,interval 1 month)); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # DATE() +let $cols = a datetime, b datetime as (date(a)); +let $values1 = '2008-08-31 02:00:00',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # DATEDIFF() +let $cols = a datetime, b long as (datediff(a,'2000-01-01')); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # DAY() +let $cols = a datetime, b int as (day(a)); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # DAYNAME() +let $cols = a datetime, b varchar(10) as (dayname(a)); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # DAYOFMONTH() +let $cols = a datetime, b int as (dayofmonth(a)); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # DAYOFWEEK() +let $cols = a datetime, b int as (dayofweek(a)); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # DAYOFYEAR() +let $cols = a datetime, b int as (dayofyear(a)); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # EXTRACT +let $cols = a datetime, b int as (extract(year from a)); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # FROM_DAYS() +let $cols = a long, b datetime as (from_days(a)); +let $values1 = 730669,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # FROM_UNIXTIME() +let $cols = a long, b datetime as (from_unixtime(a)); +let $values1 = 1196440219,default; +let $rows = 1; +set time_zone='UTC'; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # GET_FORMAT() +let $cols = a datetime, b varchar(32) as (date_format(a,get_format(DATE,'EUR'))); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # HOUR() +let $cols = a time, b long as (hour(a)); +let $values1 = '10:05:03',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # LAST_DAY() +let $cols = a datetime, b datetime as (last_day(a)); +let $values1 = '2003-02-05',default; +let $values2 = '2003-02-32',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # MAKEDATE() +let $cols = a int, b datetime as (makedate(a,1)); +let $values1 = 2001,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # MAKETIME() +let $cols = a int, b time as (maketime(a,1,3)); +let $values1 = 12,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # MICROSECOND() +let $cols = a datetime, b long as (microsecond(a)); +let $values1 = '2009-12-31 12:00:00.123456',default; +let $values2 = '2009-12-31 23:59:59.000010',default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # MINUTE() +let $cols = a datetime, b int as (minute(a)); +let $values1 = '2009-12-31 23:59:59.000010',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # MONTH() +let $cols = a datetime, b int as (month(a)); +let $values1 = '2009-12-31 23:59:59.000010',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # MONTHNAME() +let $cols = a datetime, b varchar(16) as (monthname(a)); +let $values1 = '2009-12-31 23:59:59.000010',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # PERIOD_ADD() +let $cols = a int, b int as (period_add(a,2)); +let $values1 = 200801,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # PERIOD_DIFF() +let $cols = a int, b int, c int as (period_diff(a,b)); +let $values1 = 200802,200703,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # QUARTER() +let $cols = a datetime, b int as (quarter(a)); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SEC_TO_TIME() +let $cols = a long, b time as (sec_to_time(a)); +let $values1 = 2378,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SECOND() +let $cols = a datetime, b int as (second(a)); +let $values1 = '10:05:03',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # STR_TO_DATE() +let $cols = a varchar(64), b datetime as (str_to_date(a,'%m/%d/%Y')); +let $values1 = '04/30/2004',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SUBDATE() +let $cols = a datetime, b datetime as (subdate(a,interval 1 month)); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SUBTIME() +let $cols = a datetime, b datetime as (subtime(a,'02:00:00')); +let $values1 = '2008-08-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # TIME_FORMAT() +let $cols = a datetime, b varchar(32) as (time_format(a,'%r')); +let $values1 = '2008-08-31 02:03:04',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # TIME_TO_SEC() +let $cols = a time, b long as (time_to_sec(a)); +let $values1 = '22:23:00',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # TIME() +let $cols = a datetime, b time as (time(a)); +let $values1 = '2008-08-31 02:03:04',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # TIMEDIFF() +let $cols = a datetime, b datetime, c long as (timediff(a,b)); +let $values1 = '2008-12-31 23:59:59.000001','2008-12-30 01:01:01.000002',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # TIMESTAMP() +let $cols = a datetime, b timestamp as (timestamp(a)); +let $values1 = '2008-12-31',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # TIMESTAMPADD() +let $cols = a datetime, b timestamp as (timestampadd(minute,1,a)); +let $values1 = '2003-01-02',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # TIMESTAMPDIFF() +let $cols = a timestamp, b timestamp, c long as (timestampdiff(MONTH, a,b)); +let $values1 = '2003-02-01','2003-05-01',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # TO_DAYS() +let $cols = a datetime, b long as (to_days(a)); +let $values1 = '2007-10-07',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # WEEK() +let $cols = a datetime, b int as (week(a)); +let $values1 = '2008-09-01',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # WEEKDAY() +let $cols = a datetime, b int as (weekday(a)); +let $values1 = '2008-09-01',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # WEEKOFYEAR() +let $cols = a datetime, b int as (weekofyear(a)); +let $values1 = '2008-09-01',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # YEAR() +let $cols = a datetime, b int as (year(a)); +let $values1 = '2008-09-01',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # YEARWEEK() +let $cols = a datetime, b int as (yearweek(a)); +let $values1 = '2008-09-01',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # +--echo # FULL TEXT SEARCH FUNCTIONS +--echo # +--echo # None. + +--echo # +--echo # CAST FUNCTIONS AND OPERATORS +--echo # + +--echo # CAST() +let $cols = a int, b long as (cast(a as unsigned)); +let $values1 = 1,default; +let $values2 = -1,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # Convert() +let $cols = a int, b long as (convert(a,unsigned)); +let $values1 = 1,default; +let $values2 = -1,default; +let $rows = 2; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # +--echo # XML FUNCTIONS +--echo # +--echo # None. + + +--echo # +--echo # OTHER FUNCTIONS +--echo # + +--echo # AES_DECRYPT(), AES_ENCRYPT() +let $cols = a varchar(1024), b varchar(1024) as (aes_encrypt(aes_decrypt(a,'adf'),'adf')); +let $values1 = 'MySQL',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # BIT_COUNT() +let $cols = a int, b int as (bit_count(a)); +let $values1 = 5,default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # CHARSET() +let $cols = a varchar(1024), b varchar(1024) as (charset(a)); +let $values1 = 'abc',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # COERCIBILITY() +let $cols = a varchar(1024), b int as (coercibility(a)); +let $values1 = 'abc',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # COLLATION() +let $cols = a varchar(1024), b varchar(1024) as (collation(a)); +let $values1 = 'abc',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # COMPRESS(), UNCOMPRESS() +let $cols = a varchar(1024), b varchar(1024) as (uncompress(compress(a))); +let $values1 = 'MySQL',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # ENCODE(), DECODE() +let $cols = a varchar(1024), b varchar(1024) as (decode(encode(a,'abc'),'abc')); +let $values1 = 'MySQL',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # DEFAULT() +let $cols = a varchar(1024) default 'aaa', b varchar(1024) as (ifnull(a,default(a))); +let $values1 = 'any value',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +#--echo # DES_ENCRYPT(), DES_DECRYPT() +#--source include/have_ssl.inc +#let $cols = a varchar(1024), b varchar(1024) as (des_encrypt(des_decrypt(a,'adf'),'adf')); +#let $values1 = 'MySQL',default; +#let $rows = 1; +#--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # INET_ATON(), INET_NTOA() +let $cols = a varchar(1024), b varchar(1024) as (inet_ntoa(inet_aton(a))); +let $values1 = '127.0.0.1',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # MD5() +let $cols = a varchar(1024), b varbinary(32) as (md5(a)); +let $values1 = 'testing',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # OLD_PASSWORD() +let $cols = a varchar(1024), b varchar(1024) as (old_password(a)); +let $values1 = 'badpwd',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # PASSWORD() +let $cols = a varchar(1024), b varchar(1024) as (password(a)); +let $values1 = 'badpwd',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SHA1() +let $cols = a varchar(1024), b varchar(1024) as (sha1(a)); +let $values1 = 'abc',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # SHA() +let $cols = a varchar(1024), b varchar(1024) as (sha(a)); +let $values1 = 'abc',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + +--echo # UNCOMPRESSED_LENGTH() +let $cols = a char, b varchar(1024) as (uncompressed_length(compress(repeat(a,30)))); +let $values1 = 'a',default; +let $rows = 1; +--source suite/vcol/inc/vcol_supported_sql_funcs.inc + diff --git a/mysql-test/suite/vcol/inc/vcol_trigger_sp.inc b/mysql-test/suite/vcol/inc/vcol_trigger_sp.inc new file mode 100644 index 00000000000..ddf13fef6a1 --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_trigger_sp.inc @@ -0,0 +1,110 @@ +################################################################################ +# inc/vcol_trigger_sp.inc # +# # +# Purpose: # +# Testing triggers, stored procedures and functions # +# defined on tables with virtual columns. # +# # +# # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +create table t1 (a int, + b int as (a/10), + c int as (a/10) persistent); + +create table t2 (a timestamp); + +delimiter |; + +create trigger trg1 before insert on t1 for each row +begin + if (new.b < 10) then + set new.a:= 100; + set new.b:= 9; + set new.c:= 9; + end if; + + if (new.c > 50) then + set new.a:= 500; + end if; +end| + +create trigger trg2 after insert on t1 for each row +begin + if (new.b >= 60) then + insert into t2 values (now()); + end if; +end| + +create function f1() +returns int +begin + declare sum1 int default '0'; + declare cur1 cursor for select sum(b) from t1; + open cur1; + fetch cur1 into sum1; + close cur1; + return sum1; +end| + +delimiter ;| + +set sql_warnings = 1; + +insert into t1 (a) values (200); +select * from t1; +select * from t2; + +insert into t1 (a) values (10); +select * from t1; +select * from t2; + +insert into t1 (a) values (600); +select * from t1; +--replace_column 1 <timestamp> +select * from t2; + +select f1(); + +set sql_warnings = 0; + +drop trigger trg1; +drop trigger trg2; +drop table t2; + +delimiter |; + +create procedure p1() +begin + declare i int default '0'; + create table t2 like t1; + insert into t2 (a) values (100), (200); + begin + declare cur1 cursor for select sum(c) from t2; + open cur1; + fetch cur1 into i; + close cur1; + if (i=30) then + insert into t1 values (300,default,default); + end if; + end; +end| + +delimiter ;| + +delete from t1; + +call p1(); + +select * from t2; +select * from t1; + +drop table t1,t2; +drop procedure p1; diff --git a/mysql-test/suite/vcol/inc/vcol_unsupported_storage_engines.inc b/mysql-test/suite/vcol/inc/vcol_unsupported_storage_engines.inc new file mode 100644 index 00000000000..681ed77fb3c --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_unsupported_storage_engines.inc @@ -0,0 +1,21 @@ +################################################################################ +# inc/vcol_unsupported_storage_engines.inc # +# # +# Purpose: # +# Ensure that defining a virtual column for an unsupported table type # +# results in a graceful error. # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-02 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN +create table t1 (a int, b int as (a+1)); +create table t1 (a int); +--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN +alter table t1 add column b int as (a+1); +drop table t1; diff --git a/mysql-test/suite/vcol/inc/vcol_view.inc b/mysql-test/suite/vcol/inc/vcol_view.inc new file mode 100644 index 00000000000..2bf413e2471 --- /dev/null +++ b/mysql-test/suite/vcol/inc/vcol_view.inc @@ -0,0 +1,201 @@ +################################################################################ +# inc/vcol_view.inc # +# # +# Purpose: # +# Testing views defined on tables with virtual columns. # +# # +# # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + + + +create table t1 (a int not null, + b int as (-a), + c int as (-a) persistent); +insert into t1 (a) values (1), (1), (2), (2), (3); + +# simple view +create view v1 (d,e) as select abs(b), abs(c) from t1; +select d,e from v1; +select is_updatable from information_schema.views where table_name='v1'; + +# view with different algorithms (explain output differs) +explain extended select d,e from v1; +create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1; +show create view v2; +select d,e from v2; +explain extended select d,e from v2; + +# VIEW on VIEW test +create view v3 (d,e) as select d*2, e*2 from v1; +select * from v3; +explain extended select * from v3; + +drop view v1,v2,v3; +drop table t1; + +# +# DISTINCT option for VIEW +# +create table t1 (a int not null, + b int as (-a), + c int as (-a) persistent); +insert into t1 (a) values (1), (2), (3), (1), (2), (3); +create view v1 as select distinct b from t1; +select * from v1; +explain select * from v1; +select * from t1; +drop view v1; +create view v1 as select distinct c from t1; +select * from v1; +explain select * from v1; +select * from t1; +drop view v1; +drop table t1; + +# +# LIMIT clause test +# +create table t1 (a int not null, + b int as (-a), + c int as (-a) persistent); +insert into t1 (a) values (1), (2), (3), (4); +create view v1 as select b+1 from t1 order by 1 desc limit 2; +select * from v1; +explain select * from v1; +drop view v1; +create view v1 as select c+1 from t1 order by 1 desc limit 2; +select * from v1; +explain select * from v1; +drop view v1; +drop table t1; + +# +# simple view + simple update, insert and delete +# +create table t1 (a int, + b int, + c int as (-a), + d int as (-a) persistent, + primary key(a)); +insert into t1 (a,b) values (10,2), (20,3), (30,4), (40,5), (50,10); +create view v1 (a,e,f,g) as select a, b+1,c+1,d+1 from t1; +# updatable field of updateable view +update v1 set a=a+e; +select * from v1; +select * from t1; +delete from v1; +select * from v1; +select * from t1; +--error ER_NON_INSERTABLE_TABLE +insert into v1 (a,e) values (60,15); +drop table t1; +drop view v1; + +# +# outer join based on VIEW with WHERE clause +# +create table t1 (a int, + b int as (-a), + c int as (-a) persistent, + primary key(a)); +insert into t1 (a) values (1), (2), (3); +create view v1 (x,y,z) as select a,b,c from t1 where b < -1; +select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.b= v1.y); +drop view v1; +create view v1 (x,y,z) as select a,b,c from t1 where c < -1; +select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.c= v1.z); +drop view v1; +drop table t1; + +# +# VIEW built over UNION +# +create table t1 (a1 int, + b1 int as (-a1), + c1 int as (-a1) persistent); +create table t2 (a2 int, + b2 int as (-a2), + c2 int as (-a2) persistent); +insert into t1 (a1) values (1), (2); +insert into t2 (a2) values (2), (3); +create view v1 as select * from t1,t2 union all select * from t1,t2; +select * from v1; +drop view v1; +drop table t1, t2; + +# +# Showing VIEW with VIEWs in subquery +# +create table t1 (a int, + b int as (-a), + c int as (-a) persistent); +create table t2 like t1; +create view v1 as select a,b,c from t1; +create view v2 as select a,b,c from t2 where b in (select b from v1); +show create view v2; +drop view v2, v1; +drop table t1, t2; + +# +# TODO: VIEW with full text +# +#CREATE TABLE t1 (c1 int not null auto_increment primary key, c2 varchar(20), fulltext(c2)); +#insert into t1 (c2) VALUES ('real Beer'),('Water'),('Kossu'),('Coca-Cola'),('Vodka'),('Wine'),('almost real Beer'); +#select * from t1 WHERE match (c2) against ('Beer'); +#CREATE VIEW v1 AS SELECT * from t1 WHERE match (c2) against ('Beer'); +#select * from v1; +#drop view v1; +#drop table t1; + +# +# distinct in temporary table with a VIEW +# +create table t1 (a int, + b int as (-a), + c int as (-a) persistent); +insert into t1 (a) values (1),(1),(2),(2),(3),(3); +create view v1 as select b from t1; +select distinct b from v1; +select distinct b from v1 limit 2; +select distinct b from t1 limit 2; +prepare stmt1 from "select distinct b from v1 limit 2"; +execute stmt1; +execute stmt1; +deallocate prepare stmt1; +drop view v1; +create view v1 as select c from t1; +select distinct c from v1; +select distinct c from v1 limit 2; +select distinct c from t1 limit 2; +prepare stmt1 from "select distinct c from v1 limit 2"; +execute stmt1; +execute stmt1; +deallocate prepare stmt1; +drop view v1; +drop table t1; + +# +# WITH CHECK OPTION insert/update test +# +create table t1 (a int, + b int as (-a), + c int as (-a) persistent); +create view v1 as select * from t1 where b > -2 && c >-2 with check option; +# simple insert +insert into v1 (a) values (1); +-- error 1369 +insert into v1 (a) values (3); +# simple insert with ignore +insert ignore into v1 (a) values (2),(3),(0); +select * from t1; +drop view v1; +drop table t1; + diff --git a/mysql-test/suite/vcol/r/rpl_vcol.result b/mysql-test/suite/vcol/r/rpl_vcol.result new file mode 100644 index 00000000000..f552d16d1c0 --- /dev/null +++ b/mysql-test/suite/vcol/r/rpl_vcol.result @@ -0,0 +1,25 @@ +SET @@session.storage_engine = 'InnoDB'; +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +create table t1 (a int, b int as (a+1)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a+1) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (2,default); +select * from t1; +a b +1 2 +2 3 +select * from t1; +a b +1 2 +2 3 +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_archive.result b/mysql-test/suite/vcol/r/vcol_archive.result new file mode 100644 index 00000000000..83fb78a5592 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_archive.result @@ -0,0 +1,7 @@ +SET @@session.storage_engine = 'archive'; +create table t1 (a int, b int as (a+1)); +ERROR HY000: 'Specified storage engine' is not yet supported for computed columns +create table t1 (a int); +alter table t1 add column b int as (a+1); +ERROR HY000: 'Specified storage engine' is not yet supported for computed columns +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_blackhole.result b/mysql-test/suite/vcol/r/vcol_blackhole.result new file mode 100644 index 00000000000..15e7505aebb --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_blackhole.result @@ -0,0 +1,7 @@ +SET @@session.storage_engine = 'blackhole'; +create table t1 (a int, b int as (a+1)); +ERROR HY000: 'Specified storage engine' is not yet supported for computed columns +create table t1 (a int); +alter table t1 add column b int as (a+1); +ERROR HY000: 'Specified storage engine' is not yet supported for computed columns +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs_innodb.result b/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs_innodb.result new file mode 100644 index 00000000000..a4099dff381 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs_innodb.result @@ -0,0 +1,243 @@ +SET @@session.storage_engine = 'InnoDB'; +# RAND() +create table t1 (b double as (rand())); +ERROR HY000: Function or expression is not allowed for column 'b' +# LOAD_FILE() +create table t1 (a varchar(64), b varchar(1024) as (load_file(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# CURDATE() +create table t1 (a datetime as (curdate())); +ERROR HY000: Function or expression is not allowed for column 'a' +# CURRENT_DATE(), CURRENT_DATE +create table t1 (a datetime as (current_date)); +ERROR HY000: Function or expression is not allowed for column 'a' +create table t1 (a datetime as (current_date())); +ERROR HY000: Function or expression is not allowed for column 'a' +# CURRENT_TIME(), CURRENT_TIME +create table t1 (a datetime as (current_time)); +ERROR HY000: Function or expression is not allowed for column 'a' +create table t1 (a datetime as (current_time())); +ERROR HY000: Function or expression is not allowed for column 'a' +# CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP +create table t1 (a datetime as (current_timestamp())); +ERROR HY000: Function or expression is not allowed for column 'a' +create table t1 (a datetime as (current_timestamp)); +ERROR HY000: Function or expression is not allowed for column 'a' +# CURTIME() +create table t1 (a datetime as (curtime())); +ERROR HY000: Function or expression is not allowed for column 'a' +# LOCALTIME(), LOCALTIME +create table t1 (a datetime, b varchar(10) as (localtime())); +ERROR HY000: Function or expression is not allowed for column 'b' +create table t1 (a datetime, b varchar(10) as (localtime)); +ERROR HY000: Function or expression is not allowed for column 'b' +# LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6) +create table t1 (a datetime, b varchar(10) as (localtimestamp())); +ERROR HY000: Function or expression is not allowed for column 'b' +create table t1 (a datetime, b varchar(10) as (localtimestamp)); +ERROR HY000: Function or expression is not allowed for column 'b' +# NOW() +create table t1 (a datetime, b varchar(10) as (now())); +ERROR HY000: Function or expression is not allowed for column 'b' +# SYSDATE() +create table t1 (a int, b varchar(10) as (sysdate())); +ERROR HY000: Function or expression is not allowed for column 'b' +# UNIX_TIMESTAMP() +create table t1 (a datetime, b datetime as (unix_timestamp())); +ERROR HY000: Function or expression is not allowed for column 'b' +# UTC_DATE() +create table t1 (a datetime, b datetime as (utc_date())); +ERROR HY000: Function or expression is not allowed for column 'b' +# UTC_TIME() +create table t1 (a datetime, b datetime as (utc_time())); +ERROR HY000: Function or expression is not allowed for column 'b' +# UTC_TIMESTAMP() +create table t1 (a datetime, b datetime as (utc_timestamp())); +ERROR HY000: Function or expression is not allowed for column 'b' +# MATCH() +# BENCHMARK() +create table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3))); +ERROR HY000: Function or expression is not allowed for column 'b' +# CONNECTION_ID() +create table t1 (a int as (connection_id())); +ERROR HY000: Function or expression is not allowed for column 'a' +# CURRENT_USER(), CURRENT_USER +create table t1 (a varchar(32) as (current_user())); +ERROR HY000: Function or expression is not allowed for column 'a' +create table t1 (a varchar(32) as (current_user)); +ERROR HY000: Function or expression is not allowed for column 'a' +# DATABASE() +create table t1 (a varchar(1024), b varchar(1024) as (database())); +ERROR HY000: Function or expression is not allowed for column 'b' +# FOUND_ROWS() +create table t1 (a varchar(1024), b varchar(1024) as (found_rows())); +ERROR HY000: Function or expression is not allowed for column 'b' +# GET_LOCK() +create table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10))); +ERROR HY000: Function or expression is not allowed for column 'b' +# IS_FREE_LOCK() +create table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# IS_USED_LOCK() +create table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# LAST_INSERT_ID() +create table t1 (a int as (last_insert_id())); +ERROR HY000: Function or expression is not allowed for column 'a' +# MASTER_POS_WAIT() +create table t1 (a varchar(32), b int as (master_pos_wait(a,0,2))); +ERROR HY000: Function or expression is not allowed for column 'b' +# NAME_CONST() +create table t1 (a varchar(32) as (name_const('test',1))); +ERROR HY000: Function or expression is not allowed for column 'a' +# RELEASE_LOCK() +create table t1 (a varchar(32), b int as (release_lock(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# ROW_COUNT() +create table t1 (a int as (row_count())); +ERROR HY000: Function or expression is not allowed for column 'a' +# SCHEMA() +create table t1 (a varchar(32) as (schema())); +ERROR HY000: Function or expression is not allowed for column 'a' +# SESSION_USER() +create table t1 (a varchar(32) as (session_user())); +ERROR HY000: Function or expression is not allowed for column 'a' +# SLEEP() +create table t1 (a int, b int as (sleep(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# SYSTEM_USER() +create table t1 (a varchar(32) as (system_user())); +ERROR HY000: Function or expression is not allowed for column 'a' +# USER() +create table t1 (a varchar(1024), b varchar(1024) as (user())); +ERROR HY000: Function or expression is not allowed for column 'b' +# UUID_SHORT() +create table t1 (a varchar(1024) as (uuid_short())); +ERROR HY000: Function or expression is not allowed for column 'a' +# UUID() +create table t1 (a varchar(1024) as (uuid())); +ERROR HY000: Function or expression is not allowed for column 'a' +# VALUES() +create table t1 (a varchar(1024), b varchar(1024) as (values(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# VERSION() +create table t1 (a varchar(1024), b varchar(1024) as (version())); +ERROR HY000: Function or expression is not allowed for column 'b' +# ENCRYPT() +create table t1 (a varchar(1024), b varchar(1024) as (encrypt(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# Stored procedures +create procedure p1() +begin +select current_user(); +end // +create function f1() +returns int +begin +return 1; +end // +create table t1 (a int as (p1())); +ERROR HY000: Function or expression is not allowed for column 'a' +create table t1 (a int as (f1())); +ERROR HY000: Function or expression is not allowed for column 'a' +drop procedure p1; +drop function f1; +# Unknown functions +create table t1 (a int as (f1())); +ERROR HY000: Function or expression is not allowed for column 'a' +# +# GROUP BY FUNCTIONS +# +# AVG() +create table t1 (a int, b int as (avg(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# BIT_AND() +create table t1 (a int, b int as (bit_and(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# BIT_OR() +create table t1 (a int, b int as (bit_or(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# BIT_XOR() +create table t1 (a int, b int as (bit_xor(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# COUNT(DISTINCT) +create table t1 (a int, b int as (count(distinct a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# COUNT() +create table t1 (a int, b int as (count(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# GROUP_CONCAT() +create table t1 (a varchar(32), b int as (group_concat(a,''))); +ERROR HY000: Function or expression is not allowed for column 'b' +# MAX() +create table t1 (a int, b int as (max(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# MIN() +create table t1 (a int, b int as (min(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# STD() +create table t1 (a int, b int as (std(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# STDDEV_POP() +create table t1 (a int, b int as (stddev_pop(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# STDDEV_SAMP() +create table t1 (a int, b int as (stddev_samp(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# STDDEV() +create table t1 (a int, b int as (stddev(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# SUM() +create table t1 (a int, b int as (sum(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# VAR_POP() +create table t1 (a int, b int as (var_pop(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# VAR_SAMP() +create table t1 (a int, b int as (var_samp(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# VARIANCE() +create table t1 (a int, b int as (variance(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# +# XML FUNCTIONS +# +# ExtractValue() +create table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]'))); +ERROR HY000: Function or expression is not allowed for column 'b' +# UpdateXML() +create table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>'))); +ERROR HY000: Function or expression is not allowed for column 'b' +# +# Sub-selects +# +create table t1 (a int); +create table t2 (a int, b int as (select count(*) from t1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from t1))' at line 1 +drop table t1; +create table t1 (a int, b int as ((select 1))); +ERROR HY000: Function or expression is not allowed for column 'b' +create table t1 (a int, b int as (a+(select 1))); +ERROR HY000: Function or expression is not allowed for column 'b' +# +# SP functions +# +drop function if exists sub1; +create function sub1(i int) returns int deterministic +return i+1; +select sub1(1); +sub1(1) +2 +create table t1 (a int, b int as (a+sub3(1))); +ERROR HY000: Function or expression is not allowed for column 'b' +drop function sub1; +# +# Long expression +create table t1 (a int, b varchar(300) as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'))); +drop table t1; +create table t1 (a int, b varchar(300) as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'))); +ERROR HY000: String 'concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long for VIRTUAL COLUMN EXPRESSION (should be no longer than 252) +# +# Constant expression +create table t1 (a int as (PI())); +ERROR HY000: Constant expression in computed column function is not allowed diff --git a/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs_myisam.result b/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs_myisam.result new file mode 100644 index 00000000000..dda222f5e8a --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs_myisam.result @@ -0,0 +1,245 @@ +SET @@session.storage_engine = 'MyISAM'; +# RAND() +create table t1 (b double as (rand())); +ERROR HY000: Function or expression is not allowed for column 'b' +# LOAD_FILE() +create table t1 (a varchar(64), b varchar(1024) as (load_file(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# CURDATE() +create table t1 (a datetime as (curdate())); +ERROR HY000: Function or expression is not allowed for column 'a' +# CURRENT_DATE(), CURRENT_DATE +create table t1 (a datetime as (current_date)); +ERROR HY000: Function or expression is not allowed for column 'a' +create table t1 (a datetime as (current_date())); +ERROR HY000: Function or expression is not allowed for column 'a' +# CURRENT_TIME(), CURRENT_TIME +create table t1 (a datetime as (current_time)); +ERROR HY000: Function or expression is not allowed for column 'a' +create table t1 (a datetime as (current_time())); +ERROR HY000: Function or expression is not allowed for column 'a' +# CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP +create table t1 (a datetime as (current_timestamp())); +ERROR HY000: Function or expression is not allowed for column 'a' +create table t1 (a datetime as (current_timestamp)); +ERROR HY000: Function or expression is not allowed for column 'a' +# CURTIME() +create table t1 (a datetime as (curtime())); +ERROR HY000: Function or expression is not allowed for column 'a' +# LOCALTIME(), LOCALTIME +create table t1 (a datetime, b varchar(10) as (localtime())); +ERROR HY000: Function or expression is not allowed for column 'b' +create table t1 (a datetime, b varchar(10) as (localtime)); +ERROR HY000: Function or expression is not allowed for column 'b' +# LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6) +create table t1 (a datetime, b varchar(10) as (localtimestamp())); +ERROR HY000: Function or expression is not allowed for column 'b' +create table t1 (a datetime, b varchar(10) as (localtimestamp)); +ERROR HY000: Function or expression is not allowed for column 'b' +# NOW() +create table t1 (a datetime, b varchar(10) as (now())); +ERROR HY000: Function or expression is not allowed for column 'b' +# SYSDATE() +create table t1 (a int, b varchar(10) as (sysdate())); +ERROR HY000: Function or expression is not allowed for column 'b' +# UNIX_TIMESTAMP() +create table t1 (a datetime, b datetime as (unix_timestamp())); +ERROR HY000: Function or expression is not allowed for column 'b' +# UTC_DATE() +create table t1 (a datetime, b datetime as (utc_date())); +ERROR HY000: Function or expression is not allowed for column 'b' +# UTC_TIME() +create table t1 (a datetime, b datetime as (utc_time())); +ERROR HY000: Function or expression is not allowed for column 'b' +# UTC_TIMESTAMP() +create table t1 (a datetime, b datetime as (utc_timestamp())); +ERROR HY000: Function or expression is not allowed for column 'b' +# MATCH() +create table t1 (a varchar(32), b bool as (match a against ('sample text'))); +ERROR HY000: Function or expression is not allowed for column 'b' +# BENCHMARK() +create table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3))); +ERROR HY000: Function or expression is not allowed for column 'b' +# CONNECTION_ID() +create table t1 (a int as (connection_id())); +ERROR HY000: Function or expression is not allowed for column 'a' +# CURRENT_USER(), CURRENT_USER +create table t1 (a varchar(32) as (current_user())); +ERROR HY000: Function or expression is not allowed for column 'a' +create table t1 (a varchar(32) as (current_user)); +ERROR HY000: Function or expression is not allowed for column 'a' +# DATABASE() +create table t1 (a varchar(1024), b varchar(1024) as (database())); +ERROR HY000: Function or expression is not allowed for column 'b' +# FOUND_ROWS() +create table t1 (a varchar(1024), b varchar(1024) as (found_rows())); +ERROR HY000: Function or expression is not allowed for column 'b' +# GET_LOCK() +create table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10))); +ERROR HY000: Function or expression is not allowed for column 'b' +# IS_FREE_LOCK() +create table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# IS_USED_LOCK() +create table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# LAST_INSERT_ID() +create table t1 (a int as (last_insert_id())); +ERROR HY000: Function or expression is not allowed for column 'a' +# MASTER_POS_WAIT() +create table t1 (a varchar(32), b int as (master_pos_wait(a,0,2))); +ERROR HY000: Function or expression is not allowed for column 'b' +# NAME_CONST() +create table t1 (a varchar(32) as (name_const('test',1))); +ERROR HY000: Function or expression is not allowed for column 'a' +# RELEASE_LOCK() +create table t1 (a varchar(32), b int as (release_lock(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# ROW_COUNT() +create table t1 (a int as (row_count())); +ERROR HY000: Function or expression is not allowed for column 'a' +# SCHEMA() +create table t1 (a varchar(32) as (schema())); +ERROR HY000: Function or expression is not allowed for column 'a' +# SESSION_USER() +create table t1 (a varchar(32) as (session_user())); +ERROR HY000: Function or expression is not allowed for column 'a' +# SLEEP() +create table t1 (a int, b int as (sleep(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# SYSTEM_USER() +create table t1 (a varchar(32) as (system_user())); +ERROR HY000: Function or expression is not allowed for column 'a' +# USER() +create table t1 (a varchar(1024), b varchar(1024) as (user())); +ERROR HY000: Function or expression is not allowed for column 'b' +# UUID_SHORT() +create table t1 (a varchar(1024) as (uuid_short())); +ERROR HY000: Function or expression is not allowed for column 'a' +# UUID() +create table t1 (a varchar(1024) as (uuid())); +ERROR HY000: Function or expression is not allowed for column 'a' +# VALUES() +create table t1 (a varchar(1024), b varchar(1024) as (values(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# VERSION() +create table t1 (a varchar(1024), b varchar(1024) as (version())); +ERROR HY000: Function or expression is not allowed for column 'b' +# ENCRYPT() +create table t1 (a varchar(1024), b varchar(1024) as (encrypt(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# Stored procedures +create procedure p1() +begin +select current_user(); +end // +create function f1() +returns int +begin +return 1; +end // +create table t1 (a int as (p1())); +ERROR HY000: Function or expression is not allowed for column 'a' +create table t1 (a int as (f1())); +ERROR HY000: Function or expression is not allowed for column 'a' +drop procedure p1; +drop function f1; +# Unknown functions +create table t1 (a int as (f1())); +ERROR HY000: Function or expression is not allowed for column 'a' +# +# GROUP BY FUNCTIONS +# +# AVG() +create table t1 (a int, b int as (avg(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# BIT_AND() +create table t1 (a int, b int as (bit_and(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# BIT_OR() +create table t1 (a int, b int as (bit_or(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# BIT_XOR() +create table t1 (a int, b int as (bit_xor(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# COUNT(DISTINCT) +create table t1 (a int, b int as (count(distinct a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# COUNT() +create table t1 (a int, b int as (count(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# GROUP_CONCAT() +create table t1 (a varchar(32), b int as (group_concat(a,''))); +ERROR HY000: Function or expression is not allowed for column 'b' +# MAX() +create table t1 (a int, b int as (max(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# MIN() +create table t1 (a int, b int as (min(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# STD() +create table t1 (a int, b int as (std(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# STDDEV_POP() +create table t1 (a int, b int as (stddev_pop(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# STDDEV_SAMP() +create table t1 (a int, b int as (stddev_samp(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# STDDEV() +create table t1 (a int, b int as (stddev(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# SUM() +create table t1 (a int, b int as (sum(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# VAR_POP() +create table t1 (a int, b int as (var_pop(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# VAR_SAMP() +create table t1 (a int, b int as (var_samp(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# VARIANCE() +create table t1 (a int, b int as (variance(a))); +ERROR HY000: Function or expression is not allowed for column 'b' +# +# XML FUNCTIONS +# +# ExtractValue() +create table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]'))); +ERROR HY000: Function or expression is not allowed for column 'b' +# UpdateXML() +create table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>'))); +ERROR HY000: Function or expression is not allowed for column 'b' +# +# Sub-selects +# +create table t1 (a int); +create table t2 (a int, b int as (select count(*) from t1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from t1))' at line 1 +drop table t1; +create table t1 (a int, b int as ((select 1))); +ERROR HY000: Function or expression is not allowed for column 'b' +create table t1 (a int, b int as (a+(select 1))); +ERROR HY000: Function or expression is not allowed for column 'b' +# +# SP functions +# +drop function if exists sub1; +create function sub1(i int) returns int deterministic +return i+1; +select sub1(1); +sub1(1) +2 +create table t1 (a int, b int as (a+sub3(1))); +ERROR HY000: Function or expression is not allowed for column 'b' +drop function sub1; +# +# Long expression +create table t1 (a int, b varchar(300) as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'))); +drop table t1; +create table t1 (a int, b varchar(300) as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'))); +ERROR HY000: String 'concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long for VIRTUAL COLUMN EXPRESSION (should be no longer than 252) +# +# Constant expression +create table t1 (a int as (PI())); +ERROR HY000: Constant expression in computed column function is not allowed diff --git a/mysql-test/suite/vcol/r/vcol_column_def_options_innodb.result b/mysql-test/suite/vcol/r/vcol_column_def_options_innodb.result new file mode 100644 index 00000000000..b1f96f8f4d9 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_column_def_options_innodb.result @@ -0,0 +1,146 @@ +SET @@session.storage_engine = 'InnoDB'; +# +# Section 1. Wrong column definition options +# - NOT NULL +# - NULL +# - DEFAULT <value> +# - AUTO_INCREMENT +# - [PRIMARY] KEY +# NOT NULL +create table t1 (a int, b int as (a+1) not null); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'not null)' at line 1 +create table t1 (a int); +alter table t1 add column b int as (a+1) not null; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'not null' at line 1 +drop table t1; +# NULL +create table t1 (a int, b int as (a+1) null); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null)' at line 1 +create table t1 (a int); +alter table t1 add column b int as (a+1) null; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null' at line 1 +drop table t1; +# DEFAULT +create table t1 (a int, b int as (a+1) default 0); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'default 0)' at line 1 +create table t1 (a int); +alter table t1 add column b int as (a+1) default 0; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'default 0' at line 1 +drop table t1; +# AUTO_INCREMENT +create table t1 (a int, b int as (a+1) AUTO_INCREMENT); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AUTO_INCREMENT)' at line 1 +create table t1 (a int); +alter table t1 add column b int as (a+1) AUTO_INCREMENT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AUTO_INCREMENT' at line 1 +drop table t1; +# [PRIMARY] KEY +create table t1 (a int, b int as (a+1) key); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key)' at line 1 +create table t1 (a int, b int as (a+1) primary key); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary key)' at line 1 +create table t1 (a int); +alter table t1 add column b int as (a+1) key; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key' at line 1 +alter table t1 add column b int as (a+1) primary key; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary key' at line 1 +drop table t1; +# Section 2. Other column definition options +# - COMMENT +# - REFERENCES (only syntax testing here) +# - STORED (only systax testing here) +create table t1 (a int, b int as (a % 2) comment 'my comment'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) VIRTUAL COMMENT 'my comment' +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES NULL VIRTUAL +drop table t1; +create table t1 (a int, b int as (a % 2)); +alter table t1 modify b int as (a % 2) comment 'my comment'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) VIRTUAL COMMENT 'my comment' +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES NULL VIRTUAL +insert into t1 (a) values (1); +select * from t1; +a b +1 1 +insert into t1 values (2,default); +select a,b from t1; +a b +1 1 +2 0 +create table t2 like t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) VIRTUAL COMMENT 'my comment' +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +describe t2; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES NULL VIRTUAL +insert into t2 (a) values (1); +select * from t2; +a b +1 1 +insert into t2 values (2,default); +select a,b from t2; +a b +1 1 +2 0 +drop table t2; +drop table t1; +create table t1 (a int, b int as (a % 2) persistent); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) PERSISTENT +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES NULL VIRTUAL +insert into t1 (a) values (1); +select * from t1; +a b +1 1 +insert into t1 values (2,default); +select a,b from t1; +a b +1 1 +2 0 +drop table t1; +create table t2 (a int); +create table t1 (a int, b int as (a % 2) persistent references t2(a)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) PERSISTENT +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a int, b int as (a % 2)); +alter table t1 modify b int as (a % 2) persistent references t2(a); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'references t2(a)' at line 1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_column_def_options_myisam.result b/mysql-test/suite/vcol/r/vcol_column_def_options_myisam.result new file mode 100644 index 00000000000..9fde339cb06 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_column_def_options_myisam.result @@ -0,0 +1,146 @@ +SET @@session.storage_engine = 'MyISAM'; +# +# Section 1. Wrong column definition options +# - NOT NULL +# - NULL +# - DEFAULT <value> +# - AUTO_INCREMENT +# - [PRIMARY] KEY +# NOT NULL +create table t1 (a int, b int as (a+1) not null); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'not null)' at line 1 +create table t1 (a int); +alter table t1 add column b int as (a+1) not null; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'not null' at line 1 +drop table t1; +# NULL +create table t1 (a int, b int as (a+1) null); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null)' at line 1 +create table t1 (a int); +alter table t1 add column b int as (a+1) null; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null' at line 1 +drop table t1; +# DEFAULT +create table t1 (a int, b int as (a+1) default 0); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'default 0)' at line 1 +create table t1 (a int); +alter table t1 add column b int as (a+1) default 0; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'default 0' at line 1 +drop table t1; +# AUTO_INCREMENT +create table t1 (a int, b int as (a+1) AUTO_INCREMENT); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AUTO_INCREMENT)' at line 1 +create table t1 (a int); +alter table t1 add column b int as (a+1) AUTO_INCREMENT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AUTO_INCREMENT' at line 1 +drop table t1; +# [PRIMARY] KEY +create table t1 (a int, b int as (a+1) key); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key)' at line 1 +create table t1 (a int, b int as (a+1) primary key); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary key)' at line 1 +create table t1 (a int); +alter table t1 add column b int as (a+1) key; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key' at line 1 +alter table t1 add column b int as (a+1) primary key; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary key' at line 1 +drop table t1; +# Section 2. Other column definition options +# - COMMENT +# - REFERENCES (only syntax testing here) +# - STORED (only systax testing here) +create table t1 (a int, b int as (a % 2) comment 'my comment'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) VIRTUAL COMMENT 'my comment' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES NULL VIRTUAL +drop table t1; +create table t1 (a int, b int as (a % 2)); +alter table t1 modify b int as (a % 2) comment 'my comment'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) VIRTUAL COMMENT 'my comment' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES NULL VIRTUAL +insert into t1 (a) values (1); +select * from t1; +a b +1 1 +insert into t1 values (2,default); +select a,b from t1; +a b +1 1 +2 0 +create table t2 like t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) VIRTUAL COMMENT 'my comment' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +describe t2; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES NULL VIRTUAL +insert into t2 (a) values (1); +select * from t2; +a b +1 1 +insert into t2 values (2,default); +select a,b from t2; +a b +1 1 +2 0 +drop table t2; +drop table t1; +create table t1 (a int, b int as (a % 2) persistent); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) PERSISTENT +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES NULL VIRTUAL +insert into t1 (a) values (1); +select * from t1; +a b +1 1 +insert into t1 values (2,default); +select a,b from t1; +a b +1 1 +2 0 +drop table t1; +create table t2 (a int); +create table t1 (a int, b int as (a % 2) persistent references t2(a)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) PERSISTENT +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a int, b int as (a % 2)); +alter table t1 modify b int as (a % 2) persistent references t2(a); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'references t2(a)' at line 1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_csv.result b/mysql-test/suite/vcol/r/vcol_csv.result new file mode 100644 index 00000000000..97977505696 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_csv.result @@ -0,0 +1,7 @@ +SET @@session.storage_engine = 'CSV'; +create table t1 (a int, b int as (a+1)); +ERROR HY000: 'Specified storage engine' is not yet supported for computed columns +create table t1 (a int not null); +alter table t1 add column b int as (a+1); +ERROR HY000: 'Specified storage engine' is not yet supported for computed columns +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_handler_innodb.result b/mysql-test/suite/vcol/r/vcol_handler_innodb.result new file mode 100644 index 00000000000..f7576299e9a --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_handler_innodb.result @@ -0,0 +1,76 @@ +SET @@session.storage_engine = 'InnoDB'; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent, +d char(1), +index (a), +index (c)); +insert into t1 (a,d) values (4,'a'), (2,'b'), (1,'c'), (3,'d'); +select * from t1; +a b c d +4 -4 -4 a +2 -2 -2 b +1 -1 -1 c +3 -3 -3 d +# HANDLER tbl_name OPEN +handler t1 open; +# HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) +handler t1 read a > (2); +a b c d +3 -3 -3 d +# HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE non-vcol_field=expr +handler t1 read a > (2) where d='c'; +a b c d +# HANDLER tbl_name READ vcol_index_name = (value1,value2,...) +handler t1 read c = (-2); +a b c d +2 -2 -2 b +# HANDLER tbl_name READ vcol_index_name = (value1,value2,...) WHERE non-vcol_field=expr +handler t1 read c = (-2) where d='c'; +a b c d +# HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE vcol_field=expr +handler t1 read a > (2) where b=-3 && c=-3; +a b c d +3 -3 -3 d +# HANDLER tbl_name READ vcol_index_name <= (value1,value2,...) +handler t1 read c <= (-2); +a b c d +2 -2 -2 b +# HANDLER tbl_name READ vcol_index_name > (value1,value2,...) WHERE vcol_field=expr +handler t1 read c <= (-2) where b=-3; +a b c d +3 -3 -3 d +# HANDLER tbl_name READ vcol_index_name FIRST +handler t1 read c first; +a b c d +4 -4 -4 a +# HANDLER tbl_name READ vcol_index_name NEXT +handler t1 read c next; +a b c d +3 -3 -3 d +# HANDLER tbl_name READ vcol_index_name PREV +handler t1 read c prev; +a b c d +4 -4 -4 a +# HANDLER tbl_name READ vcol_index_name LAST +handler t1 read c last; +a b c d +1 -1 -1 c +# HANDLER tbl_name READ FIRST where non-vcol=expr +handler t1 read FIRST where a >= 2; +a b c d +4 -4 -4 a +# HANDLER tbl_name READ FIRST where vcol=expr +handler t1 read FIRST where b >= -2; +a b c d +2 -2 -2 b +# HANDLER tbl_name READ NEXT where non-vcol=expr +handler t1 read NEXT where d='c'; +a b c d +1 -1 -1 c +# HANDLER tbl_name READ NEXT where vcol=expr +handler t1 read NEXT where b<=-4; +a b c d +# HANDLER tbl_name CLOSE +handler t1 close; +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_handler_maria.result b/mysql-test/suite/vcol/r/vcol_handler_maria.result new file mode 100644 index 00000000000..df36d0fbbf3 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_handler_maria.result @@ -0,0 +1,76 @@ +SET @@session.storage_engine = 'maria'; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent, +d char(1), +index (a), +index (c)); +insert into t1 (a,d) values (4,'a'), (2,'b'), (1,'c'), (3,'d'); +select * from t1; +a b c d +4 -4 -4 a +2 -2 -2 b +1 -1 -1 c +3 -3 -3 d +# HANDLER tbl_name OPEN +handler t1 open; +# HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) +handler t1 read a > (2); +a b c d +3 -3 -3 d +# HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE non-vcol_field=expr +handler t1 read a > (2) where d='c'; +a b c d +# HANDLER tbl_name READ vcol_index_name = (value1,value2,...) +handler t1 read c = (-2); +a b c d +2 -2 -2 b +# HANDLER tbl_name READ vcol_index_name = (value1,value2,...) WHERE non-vcol_field=expr +handler t1 read c = (-2) where d='c'; +a b c d +# HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE vcol_field=expr +handler t1 read a > (2) where b=-3 && c=-3; +a b c d +3 -3 -3 d +# HANDLER tbl_name READ vcol_index_name <= (value1,value2,...) +handler t1 read c <= (-2); +a b c d +2 -2 -2 b +# HANDLER tbl_name READ vcol_index_name > (value1,value2,...) WHERE vcol_field=expr +handler t1 read c <= (-2) where b=-3; +a b c d +3 -3 -3 d +# HANDLER tbl_name READ vcol_index_name FIRST +handler t1 read c first; +a b c d +4 -4 -4 a +# HANDLER tbl_name READ vcol_index_name NEXT +handler t1 read c next; +a b c d +3 -3 -3 d +# HANDLER tbl_name READ vcol_index_name PREV +handler t1 read c prev; +a b c d +4 -4 -4 a +# HANDLER tbl_name READ vcol_index_name LAST +handler t1 read c last; +a b c d +1 -1 -1 c +# HANDLER tbl_name READ FIRST where non-vcol=expr +handler t1 read FIRST where a >= 2; +a b c d +4 -4 -4 a +# HANDLER tbl_name READ FIRST where vcol=expr +handler t1 read FIRST where b >= -2; +a b c d +2 -2 -2 b +# HANDLER tbl_name READ NEXT where non-vcol=expr +handler t1 read NEXT where d='c'; +a b c d +1 -1 -1 c +# HANDLER tbl_name READ NEXT where vcol=expr +handler t1 read NEXT where b<=-4; +a b c d +# HANDLER tbl_name CLOSE +handler t1 close; +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_handler_myisam.result b/mysql-test/suite/vcol/r/vcol_handler_myisam.result new file mode 100644 index 00000000000..ff93756adc5 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_handler_myisam.result @@ -0,0 +1,76 @@ +SET @@session.storage_engine = 'MyISAM'; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent, +d char(1), +index (a), +index (c)); +insert into t1 (a,d) values (4,'a'), (2,'b'), (1,'c'), (3,'d'); +select * from t1; +a b c d +4 -4 -4 a +2 -2 -2 b +1 -1 -1 c +3 -3 -3 d +# HANDLER tbl_name OPEN +handler t1 open; +# HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) +handler t1 read a > (2); +a b c d +3 -3 -3 d +# HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE non-vcol_field=expr +handler t1 read a > (2) where d='c'; +a b c d +# HANDLER tbl_name READ vcol_index_name = (value1,value2,...) +handler t1 read c = (-2); +a b c d +2 -2 -2 b +# HANDLER tbl_name READ vcol_index_name = (value1,value2,...) WHERE non-vcol_field=expr +handler t1 read c = (-2) where d='c'; +a b c d +# HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE vcol_field=expr +handler t1 read a > (2) where b=-3 && c=-3; +a b c d +3 -3 -3 d +# HANDLER tbl_name READ vcol_index_name <= (value1,value2,...) +handler t1 read c <= (-2); +a b c d +2 -2 -2 b +# HANDLER tbl_name READ vcol_index_name > (value1,value2,...) WHERE vcol_field=expr +handler t1 read c <= (-2) where b=-3; +a b c d +3 -3 -3 d +# HANDLER tbl_name READ vcol_index_name FIRST +handler t1 read c first; +a b c d +4 -4 -4 a +# HANDLER tbl_name READ vcol_index_name NEXT +handler t1 read c next; +a b c d +3 -3 -3 d +# HANDLER tbl_name READ vcol_index_name PREV +handler t1 read c prev; +a b c d +4 -4 -4 a +# HANDLER tbl_name READ vcol_index_name LAST +handler t1 read c last; +a b c d +1 -1 -1 c +# HANDLER tbl_name READ FIRST where non-vcol=expr +handler t1 read FIRST where a >= 2; +a b c d +4 -4 -4 a +# HANDLER tbl_name READ FIRST where vcol=expr +handler t1 read FIRST where b >= -2; +a b c d +2 -2 -2 b +# HANDLER tbl_name READ NEXT where non-vcol=expr +handler t1 read NEXT where d='c'; +a b c d +1 -1 -1 c +# HANDLER tbl_name READ NEXT where vcol=expr +handler t1 read NEXT where b<=-4; +a b c d +# HANDLER tbl_name CLOSE +handler t1 close; +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result b/mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result new file mode 100644 index 00000000000..b996a0108e3 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result @@ -0,0 +1,427 @@ +SET @@session.storage_engine = 'InnoDB'; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent); +set sql_warnings = 1; +# +# *** INSERT *** +# +# INSERT INTO tbl_name VALUES... DEFAULT is specified against vcols +insert into t1 values (1,default,default); +select * from t1; +a b c +1 -1 -1 +delete from t1; +select * from t1; +a b c +# INSERT INTO tbl_name VALUES... NULL is specified against vcols +insert into t1 values (1,null,null); +select * from t1; +a b c +1 -1 -1 +delete from t1; +select * from t1; +a b c +# INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols +insert into t1 values (1,2,3); +Warnings: +Warning 1645 The value specified for computed column 'b' in table 't1' ignored +Warning 1645 The value specified for computed column 'c' in table 't1' ignored +select * from t1; +a b c +1 -1 -1 +delete from t1; +select * from t1; +a b c +# INSERT INTO tbl_name (<non_vcol_list>) VALUES... +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +delete from t1; +select * from t1; +a b c +# INSERT INTO tbl_name (<normal+vcols>) VALUES... DEFAULT is specified +# against vcols +insert into t1 (a,b) values (1,default), (2,default); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +delete from t1; +select * from t1; +a b c +# INSERT INTO tbl_name (<normal+vcols>) VALUES... NULL is specified against vcols +insert into t1 (a,b) values (1,null), (2,null); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +delete from t1; +select * from t1; +a b c +# INSERT INTO tbl_name (<normal+vcols>) VALUES... a non-NULL value is specified +# against vcols +insert into t1 (a,b) values (1,3), (2,4); +Warnings: +Warning 1645 The value specified for computed column 'b' in table 't1' ignored +Warning 1645 The value specified for computed column 'b' in table 't1' ignored +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +delete from t1; +select * from t1; +a b c +drop table t1; +# Table with UNIQUE non-vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE +# KEY UPDATE <non_vcol>=expr, <vcol>=expr +create table t1 (a int unique, +b int as (-a), +c int as (-a) persistent); +insert into t1 values (1,default,default); +insert into t1 values (1,default,default) +on duplicate key update a=2, b=default; +select a,b,c from t1; +a b c +2 -2 -2 +delete from t1 where b in (1,2); +select * from t1; +a b c +2 -2 -2 +drop table t1; +# Table with UNIQUE vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE +# KEY UPDATE <non_vcol>=expr, <vcol>=expr +create table t1 (a int, +b int as (-a), +c int as (-a) persistent unique); +insert into t1 values (1,default,default); +insert into t1 values (1,default,default) +on duplicate key update a=2, b=default; +select a,b,c from t1; +a b c +2 -2 -2 +# CREATE new_table ... LIKE old_table +# INSERT INTO new_table SELECT * from old_table +create table t2 like t1; +insert into t2 select * from t1; +Warnings: +Warning 1645 The value specified for computed column 'b' in table 't2' ignored +Warning 1645 The value specified for computed column 'c' in table 't2' ignored +select * from t1; +a b c +2 -2 -2 +drop table t2; +# CREATE new_table ... LIKE old_table INSERT INTO new_table (<non-vcols>, <vcols>) +# SELECT <non-vcols>, <vcols> from old_table +insert into t1 values (1,default,default); +select * from t1; +a b c +2 -2 -2 +1 -1 -1 +create table t2 like t1; +insert into t2 (a,b) select a,b from t1; +Warnings: +Warning 1645 The value specified for computed column 'b' in table 't2' ignored +Warning 1645 The value specified for computed column 'b' in table 't2' ignored +select * from t2; +a b c +2 -2 -2 +1 -1 -1 +drop table t2; +drop table t1; +# +# *** UPDATE *** +# +# UPDATE tbl_name SET non-vcol=expr WHERE non-vcol=expr +create table t1 (a int, +b int as (-a), +c int as (-a) persistent); +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set a=3 where a=2; +select * from t1; +a b c +1 -1 -1 +3 -3 -3 +delete from t1; +select * from t1; +a b c +# UPDATE tbl_name SET vcol=expr WHERE non-vcol=expr +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set c=3 where a=2; +Warnings: +Warning 1645 The value specified for computed column 'c' in table 't1' ignored +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +delete from t1; +select * from t1; +a b c +# UPDATE tbl_name SET non-vcol=expr WHERE vcol=expr +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set a=3 where b=-2; +select * from t1; +a b c +1 -1 -1 +3 -3 -3 +delete from t1; +select * from t1; +a b c +# UPDATE tbl_name SET vcol=expr WHERE vcol=expr +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set c=3 where b=-2; +Warnings: +Warning 1645 The value specified for computed column 'c' in table 't1' ignored +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +delete from t1; +select * from t1; +a b c +drop table t1; +# INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr WHERE vcol=const +create table t1 (a int, +b int as (-a), +c int as (-a) persistent unique); +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set a=3 where c=-2; +select * from t1; +a b c +1 -1 -1 +3 -3 -3 +delete from t1; +select * from t1; +a b c +# INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2 +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set a=3 where c between -3 and -2; +select * from t1; +a b c +1 -1 -1 +3 -3 -3 +delete from t1; +select * from t1; +a b c +# No INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2 +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set a=3 where b between -3 and -2; +select * from t1; +a b c +1 -1 -1 +3 -3 -3 +delete from t1; +select * from t1; +a b c +# INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr +# WHERE vcol=between const1 and const2 ORDER BY vcol +insert into t1 (a) values (1), (2), (3), (4), (5); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +update t1 set a=6 where c between -1 and 0 +order by c; +select * from t1; +a b c +6 -6 -6 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +delete from t1 where c between -6 and 0; +select * from t1; +a b c +# INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr +# WHERE vcol=between const1 and const2 ORDER BY vcol LIMIT 2 +insert into t1 (a) values (1), (2), (3), (4), (5); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +update t1 set a=6 where c between -1 and 0 +order by c limit 2; +select * from t1; +a b c +6 -6 -6 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +delete from t1 where c between -2 and 0 order by c; +select * from t1; +a b c +6 -6 -6 +3 -3 -3 +4 -4 -4 +5 -5 -5 +delete from t1; +# INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr +# WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3 +insert into t1 (a) values (1), (2), (3), (4), (5); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +update t1 set a=6 where (c between -2 and 0) and (b=-1); +select * from t1; +a b c +6 -6 -6 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +delete from t1; +# INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr +# WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3 +# ORDER BY indexed vcol +insert into t1 (a) values (1), (2), (3), (4), (5); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +update t1 set a=6 where (c between -2 and 0) and (b=-1) order by c; +select * from t1; +a b c +6 -6 -6 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +delete from t1; +drop table t1; +# +# Verify ON UPDATE/DELETE actions of FOREIGN KEYs +create table t2 (a int primary key, name varchar(10)); +create table t1 (a int primary key, b int as (a % 10) persistent); +insert into t2 values (1, 'value1'), (2,'value2'), (3,'value3'); +insert into t1 (a) values (1),(2),(3); +select * from t1; +a b +1 1 +2 2 +3 3 +select * from t2; +a name +1 value1 +2 value2 +3 value3 +select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a; +a b name +1 1 value1 +2 2 value2 +3 3 value3 +# - ON UPDATE RESTRICT +alter table t1 add foreign key (b) references t2(a) on update restrict; +insert into t1 (a) values (4); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t2` (`a`)) +update t2 set a=4 where a=3; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t2` (`a`)) +select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a; +a b name +1 1 value1 +2 2 value2 +3 3 value3 +alter table t1 drop foreign key t1_ibfk_1; +# - ON DELETE RESTRICT +alter table t1 add foreign key (b) references t2(a) on delete restrict; +delete from t2 where a=3; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t2` (`a`)) +select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a; +a b name +1 1 value1 +2 2 value2 +3 3 value3 +select t1.a, t1.b, t2.name from t1 left outer join t2 on (t1.b=t2.a); +a b name +1 1 value1 +2 2 value2 +3 3 value3 +alter table t1 drop foreign key t1_ibfk_1; +# - ON DELETE CASCADE +alter table t1 add foreign key (b) references t2(a) on delete cascade; +delete from t2 where a=3; +select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a; +a b name +1 1 value1 +2 2 value2 +select t1.a, t1.b, t2.name from t1 left outer join t2 on (t1.b=t2.a); +a b name +1 1 value1 +2 2 value2 +alter table t1 drop foreign key t1_ibfk_1; +drop table t1; +drop table t2; +# +# *** REPLACE *** +# +# UNIQUE INDEX on vcol +# REPLACE tbl_name (non-vcols) VALUES (non-vcols); +create table t1 (a int, +b int as (-a), +c int as (-a) persistent unique, +d varchar(16)); +insert into t1 (a,d) values (1,'a'), (2,'b'); +select * from t1; +a b c d +1 -1 -1 a +2 -2 -2 b +replace t1 (a,d) values (1,'c'); +select * from t1; +a b c d +1 -1 -1 c +2 -2 -2 b +delete from t1; +select * from t1; +a b c d +set sql_warnings = 0; +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_ins_upd_myisam.result b/mysql-test/suite/vcol/r/vcol_ins_upd_myisam.result new file mode 100644 index 00000000000..fa636597536 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_ins_upd_myisam.result @@ -0,0 +1,365 @@ +SET @@session.storage_engine = 'MyISAM'; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent); +set sql_warnings = 1; +# +# *** INSERT *** +# +# INSERT INTO tbl_name VALUES... DEFAULT is specified against vcols +insert into t1 values (1,default,default); +select * from t1; +a b c +1 -1 -1 +delete from t1; +select * from t1; +a b c +# INSERT INTO tbl_name VALUES... NULL is specified against vcols +insert into t1 values (1,null,null); +select * from t1; +a b c +1 -1 -1 +delete from t1; +select * from t1; +a b c +# INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols +insert into t1 values (1,2,3); +Warnings: +Warning 1645 The value specified for computed column 'b' in table 't1' ignored +Warning 1645 The value specified for computed column 'c' in table 't1' ignored +select * from t1; +a b c +1 -1 -1 +delete from t1; +select * from t1; +a b c +# INSERT INTO tbl_name (<non_vcol_list>) VALUES... +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +delete from t1; +select * from t1; +a b c +# INSERT INTO tbl_name (<normal+vcols>) VALUES... DEFAULT is specified +# against vcols +insert into t1 (a,b) values (1,default), (2,default); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +delete from t1; +select * from t1; +a b c +# INSERT INTO tbl_name (<normal+vcols>) VALUES... NULL is specified against vcols +insert into t1 (a,b) values (1,null), (2,null); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +delete from t1; +select * from t1; +a b c +# INSERT INTO tbl_name (<normal+vcols>) VALUES... a non-NULL value is specified +# against vcols +insert into t1 (a,b) values (1,3), (2,4); +Warnings: +Warning 1645 The value specified for computed column 'b' in table 't1' ignored +Warning 1645 The value specified for computed column 'b' in table 't1' ignored +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +delete from t1; +select * from t1; +a b c +drop table t1; +# Table with UNIQUE non-vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE +# KEY UPDATE <non_vcol>=expr, <vcol>=expr +create table t1 (a int unique, +b int as (-a), +c int as (-a) persistent); +insert into t1 values (1,default,default); +insert into t1 values (1,default,default) +on duplicate key update a=2, b=default; +select a,b,c from t1; +a b c +2 -2 -2 +delete from t1 where b in (1,2); +select * from t1; +a b c +2 -2 -2 +drop table t1; +# Table with UNIQUE vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE +# KEY UPDATE <non_vcol>=expr, <vcol>=expr +create table t1 (a int, +b int as (-a), +c int as (-a) persistent unique); +insert into t1 values (1,default,default); +insert into t1 values (1,default,default) +on duplicate key update a=2, b=default; +select a,b,c from t1; +a b c +2 -2 -2 +# CREATE new_table ... LIKE old_table +# INSERT INTO new_table SELECT * from old_table +create table t2 like t1; +insert into t2 select * from t1; +Warnings: +Warning 1645 The value specified for computed column 'b' in table 't2' ignored +Warning 1645 The value specified for computed column 'c' in table 't2' ignored +select * from t1; +a b c +2 -2 -2 +drop table t2; +# CREATE new_table ... LIKE old_table INSERT INTO new_table (<non-vcols>, <vcols>) +# SELECT <non-vcols>, <vcols> from old_table +insert into t1 values (1,default,default); +select * from t1; +a b c +2 -2 -2 +1 -1 -1 +create table t2 like t1; +insert into t2 (a,b) select a,b from t1; +Warnings: +Warning 1645 The value specified for computed column 'b' in table 't2' ignored +Warning 1645 The value specified for computed column 'b' in table 't2' ignored +select * from t2; +a b c +2 -2 -2 +1 -1 -1 +drop table t2; +drop table t1; +# +# *** UPDATE *** +# +# UPDATE tbl_name SET non-vcol=expr WHERE non-vcol=expr +create table t1 (a int, +b int as (-a), +c int as (-a) persistent); +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set a=3 where a=2; +select * from t1; +a b c +1 -1 -1 +3 -3 -3 +delete from t1; +select * from t1; +a b c +# UPDATE tbl_name SET vcol=expr WHERE non-vcol=expr +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set c=3 where a=2; +Warnings: +Warning 1645 The value specified for computed column 'c' in table 't1' ignored +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +delete from t1; +select * from t1; +a b c +# UPDATE tbl_name SET non-vcol=expr WHERE vcol=expr +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set a=3 where b=-2; +select * from t1; +a b c +1 -1 -1 +3 -3 -3 +delete from t1; +select * from t1; +a b c +# UPDATE tbl_name SET vcol=expr WHERE vcol=expr +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set c=3 where b=-2; +Warnings: +Warning 1645 The value specified for computed column 'c' in table 't1' ignored +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +delete from t1; +select * from t1; +a b c +drop table t1; +# INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr WHERE vcol=const +create table t1 (a int, +b int as (-a), +c int as (-a) persistent unique); +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set a=3 where c=-2; +select * from t1; +a b c +1 -1 -1 +3 -3 -3 +delete from t1; +select * from t1; +a b c +# INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2 +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set a=3 where c between -3 and -2; +select * from t1; +a b c +1 -1 -1 +3 -3 -3 +delete from t1; +select * from t1; +a b c +# No INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2 +insert into t1 (a) values (1), (2); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +update t1 set a=3 where b between -3 and -2; +select * from t1; +a b c +1 -1 -1 +3 -3 -3 +delete from t1; +select * from t1; +a b c +# INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr +# WHERE vcol=between const1 and const2 ORDER BY vcol +insert into t1 (a) values (1), (2), (3), (4), (5); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +update t1 set a=6 where c between -1 and 0 +order by c; +select * from t1; +a b c +6 -6 -6 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +delete from t1 where c between -6 and 0; +select * from t1; +a b c +# INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr +# WHERE vcol=between const1 and const2 ORDER BY vcol LIMIT 2 +insert into t1 (a) values (1), (2), (3), (4), (5); +select * from t1; +a b c +5 -5 -5 +4 -4 -4 +3 -3 -3 +2 -2 -2 +1 -1 -1 +update t1 set a=6 where c between -1 and 0 +order by c limit 2; +select * from t1; +a b c +5 -5 -5 +4 -4 -4 +3 -3 -3 +2 -2 -2 +6 -6 -6 +delete from t1 where c between -2 and 0 order by c; +select * from t1; +a b c +5 -5 -5 +4 -4 -4 +3 -3 -3 +6 -6 -6 +delete from t1; +# INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr +# WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3 +insert into t1 (a) values (1), (2), (3), (4), (5); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +update t1 set a=6 where (c between -2 and 0) and (b=-1); +select * from t1; +a b c +6 -6 -6 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +delete from t1; +# INDEX created on vcol +# UPDATE tbl_name SET non-vcol=expr +# WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3 +# ORDER BY indexed vcol +insert into t1 (a) values (1), (2), (3), (4), (5); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +update t1 set a=6 where (c between -2 and 0) and (b=-1) order by c; +select * from t1; +a b c +6 -6 -6 +2 -2 -2 +3 -3 -3 +4 -4 -4 +5 -5 -5 +delete from t1; +drop table t1; +# +# *** REPLACE *** +# +# UNIQUE INDEX on vcol +# REPLACE tbl_name (non-vcols) VALUES (non-vcols); +create table t1 (a int, +b int as (-a), +c int as (-a) persistent unique, +d varchar(16)); +insert into t1 (a,d) values (1,'a'), (2,'b'); +select * from t1; +a b c d +1 -1 -1 a +2 -2 -2 b +replace t1 (a,d) values (1,'c'); +select * from t1; +a b c d +1 -1 -1 c +2 -2 -2 b +delete from t1; +select * from t1; +a b c d +set sql_warnings = 0; +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_keys_innodb.result b/mysql-test/suite/vcol/r/vcol_keys_innodb.result new file mode 100644 index 00000000000..857dcb8423f --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_keys_innodb.result @@ -0,0 +1,151 @@ +SET @@session.storage_engine = 'InnoDB'; +# - UNIQUE KEY +# - INDEX +# - FULLTEXT INDEX +# - SPATIAL INDEX (not supported) +# - FOREIGN INDEX (partially supported) +# - CHECK (allowed but not used) +# UNIQUE +create table t1 (a int, b int as (a*2) unique); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +create table t1 (a int, b int as (a*2) persistent unique); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a*2) PERSISTENT, + UNIQUE KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES UNI NULL VIRTUAL +drop table t1; +create table t1 (a int, b int as (a*2), unique key (b)); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +create table t1 (a int, b int as (a*2) persistent, unique (b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a*2) PERSISTENT, + UNIQUE KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES UNI NULL VIRTUAL +drop table t1; +create table t1 (a int, b int as (a*2)); +alter table t1 add unique key (b); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +drop table t1; +create table t1 (a int, b int as (a*2) persistent); +alter table t1 add unique key (b); +drop table t1; +# Testing data manipulation operations involving UNIQUE keys +# on virtual columns can be found in: +# - vcol_ins_upd.inc +# - vcol_select.inc +# +# INDEX +create table t1 (a int, b int as (a*2), index (b)); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +create table t1 (a int, b int as (a*2), index (a,b)); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +create table t1 (a int, b int as (a*2) persistent, index (b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a*2) PERSISTENT, + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES MUL NULL VIRTUAL +drop table t1; +create table t1 (a int, b int as (a*2) persistent, index (a,b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a*2) PERSISTENT, + KEY `a` (`a`,`b`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES MUL NULL +b int(11) YES NULL VIRTUAL +drop table t1; +create table t1 (a int, b int as (a*2)); +alter table t1 add index (b); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +alter table t1 add index (a,b); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +drop table t1; +create table t1 (a int, b int as (a*2) persistent); +alter table t1 add index (b); +drop table t1; +create table t1 (a int, b int as (a*2) persistent); +alter table t1 add index (a,b); +create table t2 like t1; +drop table t2; +drop table t1; +# Testing data manipulation operations involving INDEX +# on virtual columns can be found in: +# - vcol_select.inc +# +# TODO: FULLTEXT INDEX +# SPATIAL INDEX +# FOREIGN KEY +# Rejected FK options. +create table t1 (a int, b int as (a+1) persistent, +foreign key (b) references t2(a) on update set null); +ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column +create table t1 (a int, b int as (a+1) persistent, +foreign key (b) references t2(a) on update cascade); +ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column +create table t1 (a int, b int as (a+1) persistent, +foreign key (b) references t2(a) on delete set null); +ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column +create table t1 (a int, b int as (a+1) persistent); +alter table t1 add foreign key (b) references t2(a) on update set null; +ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column +alter table t1 add foreign key (b) references t2(a) on update cascade; +ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column +alter table t1 add foreign key (b) references t2(a) on delete set null; +ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column +drop table t1; +create table t1 (a int, b int as (a+1), +foreign key (b) references t2(a)); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +create table t1 (a int, b int as (a+1)); +alter table t1 add foreign key (b) references t2(a); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +drop table t1; +# Allowed FK options. +create table t2 (a int primary key, b char(5)); +create table t1 (a int, b int as (a % 10) persistent, +foreign key (b) references t2(a) on update restrict); +drop table t1; +create table t1 (a int, b int as (a % 10) persistent, +foreign key (b) references t2(a) on update no action); +drop table t1; +create table t1 (a int, b int as (a % 10) persistent, +foreign key (b) references t2(a) on delete restrict); +drop table t1; +create table t1 (a int, b int as (a % 10) persistent, +foreign key (b) references t2(a) on delete cascade); +drop table t1; +create table t1 (a int, b int as (a % 10) persistent, +foreign key (b) references t2(a) on delete no action); +drop table t1; + +# Testing data manipulation operations involving FOREIGN KEY +# on virtual columns can be found in: +# - vcol_ins_upd.inc +# - vcol_select.inc +# +# TODO: CHECK diff --git a/mysql-test/suite/vcol/r/vcol_keys_myisam.result b/mysql-test/suite/vcol/r/vcol_keys_myisam.result new file mode 100644 index 00000000000..af0935affbc --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_keys_myisam.result @@ -0,0 +1,158 @@ +SET @@session.storage_engine = 'MyISAM'; +# - UNIQUE KEY +# - INDEX +# - FULLTEXT INDEX +# - SPATIAL INDEX (not supported) +# - FOREIGN INDEX (partially supported) +# - CHECK (allowed but not used) +# UNIQUE +create table t1 (a int, b int as (a*2) unique); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +create table t1 (a int, b int as (a*2) persistent unique); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a*2) PERSISTENT, + UNIQUE KEY `b` (`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES UNI NULL VIRTUAL +drop table t1; +create table t1 (a int, b int as (a*2), unique key (b)); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +create table t1 (a int, b int as (a*2) persistent, unique (b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a*2) PERSISTENT, + UNIQUE KEY `b` (`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES UNI NULL VIRTUAL +drop table t1; +create table t1 (a int, b int as (a*2)); +alter table t1 add unique key (b); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +drop table t1; +create table t1 (a int, b int as (a*2) persistent); +alter table t1 add unique key (b); +drop table t1; +# Testing data manipulation operations involving UNIQUE keys +# on virtual columns can be found in: +# - vcol_ins_upd.inc +# - vcol_select.inc +# +# INDEX +create table t1 (a int, b int as (a*2), index (b)); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +create table t1 (a int, b int as (a*2), index (a,b)); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +create table t1 (a int, b int as (a*2) persistent, index (b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a*2) PERSISTENT, + KEY `b` (`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES NULL +b int(11) YES MUL NULL VIRTUAL +drop table t1; +create table t1 (a int, b int as (a*2) persistent, index (a,b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a*2) PERSISTENT, + KEY `a` (`a`,`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +describe t1; +Field Type Null Key Default Extra +a int(11) YES MUL NULL +b int(11) YES NULL VIRTUAL +drop table t1; +create table t1 (a int, b int as (a*2)); +alter table t1 add index (b); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +alter table t1 add index (a,b); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +drop table t1; +create table t1 (a int, b int as (a*2) persistent); +alter table t1 add index (b); +drop table t1; +create table t1 (a int, b int as (a*2) persistent); +alter table t1 add index (a,b); +create table t2 like t1; +drop table t2; +drop table t1; +# Testing data manipulation operations involving INDEX +# on virtual columns can be found in: +# - vcol_select.inc +# +# TODO: FULLTEXT INDEX +# SPATIAL INDEX +# Error "All parts of a SPATIAL index must be NOT NULL" +create table t1 (a int, b int as (a+1) persistent, spatial index (b)); +ERROR 42000: All parts of a SPATIAL index must be NOT NULL +create table t1 (a int, b int as (a+1) persistent); +alter table t1 add spatial index (b); +ERROR 42000: All parts of a SPATIAL index must be NOT NULL +drop table t1; +# FOREIGN KEY +# Rejected FK options. +create table t1 (a int, b int as (a+1) persistent, +foreign key (b) references t2(a) on update set null); +ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column +create table t1 (a int, b int as (a+1) persistent, +foreign key (b) references t2(a) on update cascade); +ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column +create table t1 (a int, b int as (a+1) persistent, +foreign key (b) references t2(a) on delete set null); +ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column +create table t1 (a int, b int as (a+1) persistent); +alter table t1 add foreign key (b) references t2(a) on update set null; +ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column +alter table t1 add foreign key (b) references t2(a) on update cascade; +ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column +alter table t1 add foreign key (b) references t2(a) on delete set null; +ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column +drop table t1; +create table t1 (a int, b int as (a+1), +foreign key (b) references t2(a)); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +create table t1 (a int, b int as (a+1)); +alter table t1 add foreign key (b) references t2(a); +ERROR HY000: Key/Index cannot be defined on a non-stored computed column +drop table t1; +# Allowed FK options. +create table t2 (a int primary key, b char(5)); +create table t1 (a int, b int as (a % 10) persistent, +foreign key (b) references t2(a) on update restrict); +drop table t1; +create table t1 (a int, b int as (a % 10) persistent, +foreign key (b) references t2(a) on update no action); +drop table t1; +create table t1 (a int, b int as (a % 10) persistent, +foreign key (b) references t2(a) on delete restrict); +drop table t1; +create table t1 (a int, b int as (a % 10) persistent, +foreign key (b) references t2(a) on delete cascade); +drop table t1; +create table t1 (a int, b int as (a % 10) persistent, +foreign key (b) references t2(a) on delete no action); +drop table t1; + +# Testing data manipulation operations involving FOREIGN KEY +# on virtual columns can be found in: +# - vcol_ins_upd.inc +# - vcol_select.inc +# +# TODO: CHECK diff --git a/mysql-test/suite/vcol/r/vcol_memory.result b/mysql-test/suite/vcol/r/vcol_memory.result new file mode 100644 index 00000000000..30b6bd4a4bf --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_memory.result @@ -0,0 +1,7 @@ +SET @@session.storage_engine = 'memory'; +create table t1 (a int, b int as (a+1)); +ERROR HY000: 'Specified storage engine' is not yet supported for computed columns +create table t1 (a int); +alter table t1 add column b int as (a+1); +ERROR HY000: 'Specified storage engine' is not yet supported for computed columns +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_merge.result b/mysql-test/suite/vcol/r/vcol_merge.result new file mode 100644 index 00000000000..03a1e151c2e --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_merge.result @@ -0,0 +1,8 @@ +drop table if exists t1, t2, t3; +create table t1 (a int, b int as (a % 10)); +create table t2 (a int, b int as (a % 10)); +insert into t1 values (1,default); +insert into t2 values (2,default); +create table t3 (a int, b int as (a % 10)) engine=MERGE UNION=(t1,t2); +ERROR HY000: 'Specified storage engine' is not yet supported for computed columns +drop table t1,t2; diff --git a/mysql-test/suite/vcol/r/vcol_misc.result b/mysql-test/suite/vcol/r/vcol_misc.result new file mode 100644 index 00000000000..dee34cb4860 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_misc.result @@ -0,0 +1,135 @@ +drop table if exists t1,t2; +create table t1 (a int, b int, v int as (a+1), index idx(b)); +insert into t1(a, b) values +(4, 40), (3, 30), (5, 50), (7, 70), (8, 80), (2, 20), (1, 10); +select * from t1 order by b; +a b v +1 10 2 +2 20 3 +3 30 4 +4 40 5 +5 50 6 +7 70 8 +8 80 9 +delete from t1 where v > 6 order by b limit 1; +select * from t1 order by b; +a b v +1 10 2 +2 20 3 +3 30 4 +4 40 5 +5 50 6 +8 80 9 +update t1 set a=v order by b limit 1; +select * from t1 order by b; +a b v +2 10 3 +2 20 3 +3 30 4 +4 40 5 +5 50 6 +8 80 9 +drop table t1; +CREATE TABLE t1 ( +a int NOT NULL DEFAULT '0', +v double AS ((1, a)) VIRTUAL +); +ERROR HY000: Expression for computed column cannot return a row +CREATE TABLE t1 ( +a CHAR(255) BINARY NOT NULL DEFAULT 0, +b CHAR(255) BINARY NOT NULL DEFAULT 0, +v CHAR(255) BINARY AS (CONCAT(a,b)) VIRTUAL ); +INSERT INTO t1(a,b) VALUES ('4','7'), ('4','6'); +SELECT 1 AS C FROM t1 ORDER BY v; +C +1 +1 +DROP TABLE t1; +CREATE TABLE t1(a int, b int DEFAULT 0, v INT AS (b+10) PERSISTENT); +INSERT INTO t1(a) VALUES (1); +SELECT b, v FROM t1; +b v +0 10 +DROP TABLE t1; +CREATE TABLE t1(a int DEFAULT 100, v int AS (a+1) PERSISTENT); +INSERT INTO t1 () VALUES (); +CREATE TABLE t2(a int DEFAULT 100 , v int AS (a+1)); +INSERT INTO t2 () VALUES (); +SELECT a, v FROM t1; +a v +100 101 +SELECT a, v FROM t2; +a v +100 101 +DROP TABLE t1,t2; +CREATE TABLE t1 ( +a datetime NOT NULL DEFAULT '2000-01-01', +v boolean AS (a < '2001-01-01') +); +INSERT INTO t1(a) VALUES ('2002-02-15'); +INSERT INTO t1(a) VALUES ('2000-10-15'); +SELECT a, v FROM t1; +a v +2002-02-15 00:00:00 0 +2000-10-15 00:00:00 1 +SELECT a, v FROM t1; +a v +2002-02-15 00:00:00 0 +2000-10-15 00:00:00 1 +CREATE TABLE t2 ( +a datetime NOT NULL DEFAULT '2000-01-01', +v boolean AS (a < '2001-01-01') PERSISTENT +); +INSERT INTO t2(a) VALUES ('2002-02-15'); +INSERT INTO t2(a) VALUES ('2000-10-15'); +SELECT * FROM t2; +a v +2002-02-15 00:00:00 0 +2000-10-15 00:00:00 1 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +a char(255), b char(255), c char(255), d char(255), +v char(255) AS (CONCAT(c,d) ) VIRTUAL +); +INSERT INTO t1(a,b,c,d) VALUES ('w','x','y','z'), ('W','X','Y','Z'); +SELECT v FROM t1 ORDER BY CONCAT(a,b); +v +yz +YZ +DROP TABLE t1; +CREATE TABLE t1 (f1 INTEGER, v1 INTEGER AS (f1) VIRTUAL); +CREATE TABLE t2 AS SELECT v1 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `v1` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1,t2; +CREATE TABLE t1 (p int, a double NOT NULL, v double AS (ROUND(a,p)) VIRTUAL); +INSERT INTO t1 VALUES (0,1,0); +Warnings: +Warning 1645 The value specified for computed column 'v' in table 't1' ignored +INSERT INTO t1 VALUES (NULL,0,0); +Warnings: +Warning 1645 The value specified for computed column 'v' in table 't1' ignored +SELECT a, p, v, ROUND(a,p), ROUND(a,p+NULL) FROM t1; +a p v ROUND(a,p) ROUND(a,p+NULL) +1 0 1 1 NULL +0 NULL NULL NULL NULL +DROP TABLE t1; +CREATE TABLE t1 (p int, a double NOT NULL); +INSERT INTO t1(p,a) VALUES (0,1); +INSERT INTO t1(p,a) VALUES (NULL,0); +SELECT a, p, ROUND(a,p), ROUND(a,p+NULL) FROM t1; +a p ROUND(a,p) ROUND(a,p+NULL) +1 0 1 NULL +0 NULL NULL NULL +DROP TABLE t1; +CREATE TABLE t1 (a char(32), v char(32) CHARACTER SET ucs2 AS (a) VIRTUAL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(32) DEFAULT NULL, + `v` char(32) CHARACTER SET ucs2 AS (a) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/suite/vcol/r/vcol_non_stored_columns_innodb.result b/mysql-test/suite/vcol/r/vcol_non_stored_columns_innodb.result new file mode 100644 index 00000000000..c638ced4f41 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_non_stored_columns_innodb.result @@ -0,0 +1,242 @@ +SET @@session.storage_engine = 'InnoDB'; +# Case 1. All non-stored columns. +# This scenario is currently impossible due to the fact that virtual columns +# with a constant expression are not allowed. +# Case 2. CREATE +# - Column1: "real" +# - Column 2: virtual non-stored +create table t1 (a int, b int as (-a)); +insert into t1 values (1,default); +select * from t1; +a b +1 -1 +insert into t1 values (2,default); +select * from t1; +a b +1 -1 +2 -2 +drop table t1; +# Case 3. CREATE +# - Column1: "real" +# - Column 2: virtual stored +create table t1 (a int, b int as (-a) persistent); +insert into t1 values (1,default); +select * from t1; +a b +1 -1 +insert into t1 values (2,default); +select * from t1; +a b +1 -1 +2 -2 +drop table t1; +# Case 4. CREATE +# - Column1: virtual non-stored +# - Column2: "real" +create table t1 (a int as (-b), b int); +insert into t1 values (default,1); +select * from t1; +a b +-1 1 +insert into t1 values (default,2); +select * from t1; +a b +-1 1 +-2 2 +drop table t1; +# Case 5. CREATE +# - Column1: virtual stored +# - Column2: "real" +create table t1 (a int as (-b) persistent, b int); +insert into t1 values (default,1); +select * from t1; +a b +-1 1 +insert into t1 values (default,2); +select * from t1; +a b +-1 1 +-2 2 +drop table t1; +# Case 6. CREATE +# - Column1: "real" +# - Column2: virtual non-stored +# - Column3: virtual stored +create table t1 (a int, b int as (-a), c int as (-a) persistent); +insert into t1 values (1,default,default); +select * from t1; +a b c +1 -1 -1 +insert into t1 values (2,default,default); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +drop table t1; +# Case 7. ALTER. Modify virtual stored -> virtual non-stored +create table t1 (a int, b int as (a % 2) persistent); +alter table t1 modify b int as (a % 2); +ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) PERSISTENT +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; +# Case 8. ALTER. Modify virtual non-stored -> virtual stored +create table t1 (a int, b int as (a % 2)); +alter table t1 modify b int as (a % 2) persistent; +ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; +# Case 9. CREATE LIKE +# - Column1: "real" +# - Column2: virtual non-stored +# - Column3: virtual stored +create table t1 (a int, b int as (-a), c int as (-a) persistent); +create table t2 like t1; +insert into t2 values (1,default,default); +select * from t2; +a b c +1 -1 -1 +insert into t2 values (2,default,default); +select * from t2; +a b c +1 -1 -1 +2 -2 -2 +drop table t2; +drop table t1; +# Case 10. ALTER. Dropping a virtual non-stored column. +# - Column1: virtual non-stored +# - Column2: "real" +create table t1 (a int as (-b), b int, c varchar(5)); +insert into t1 values (default,1,'v1'); +insert into t1 values (default,2,'v2'); +select * from t1; +a b c +-1 1 v1 +-2 2 v2 +alter table t1 drop column a; +select * from t1; +b c +1 v1 +2 v2 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int(11) DEFAULT NULL, + `c` varchar(5) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; +# Case 11. ALTER. Dropping a virtual stored column. +# - Column1: virtual stored +# - Column2: "real" +create table t1 (a int as (-b) persistent, b int, c char(5)); +insert into t1 values (default,1,'v1'); +insert into t1 values (default,2,'v2'); +select * from t1; +a b c +-1 1 v1 +-2 2 v2 +alter table t1 drop column a; +select * from t1; +b c +1 v1 +2 v2 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int(11) DEFAULT NULL, + `c` char(5) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; +# Case 12. ALTER. Adding a new virtual non-stored column. +create table t1 (a int, b datetime); +insert into t1 values (1,'2008-09-04'); +insert into t1 values (2,'2008-09-05'); +select * from t1; +a b +1 2008-09-04 00:00:00 +2 2008-09-05 00:00:00 +alter table t1 add column c int as (dayofyear(b)) after a; +select * from t1; +a c b +1 248 2008-09-04 00:00:00 +2 249 2008-09-05 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `c` int(11) AS (dayofyear(b)) VIRTUAL, + `b` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; +# Case 13. ALTER. Adding a new virtual stored column. +create table t1 (a int, b datetime); +insert into t1 values (1,'2008-09-04'); +insert into t1 values (2,'2008-09-05'); +select * from t1; +a b +1 2008-09-04 00:00:00 +2 2008-09-05 00:00:00 +alter table t1 add column c int as (dayofyear(b)) persistent after a; +select * from t1; +a c b +1 248 2008-09-04 00:00:00 +2 249 2008-09-05 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `c` int(11) AS (dayofyear(b)) PERSISTENT, + `b` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; +# Case 14. ALTER. Changing the expression of a virtual stored column. +create table t1 (a int, b datetime, c int as (week(b)) persistent); +insert into t1 values (1,'2008-09-04',default); +insert into t1 values (2,'2008-09-05',default); +select * from t1; +a b c +1 2008-09-04 00:00:00 35 +2 2008-09-05 00:00:00 35 +alter table t1 change column c c int as (week(b,1)) persistent; +select * from t1; +a b c +1 2008-09-04 00:00:00 36 +2 2008-09-05 00:00:00 36 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` datetime DEFAULT NULL, + `c` int(11) AS (week(b,1)) PERSISTENT +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; +# Case 15. ALTER. Changing the expression of a virtual non-stored column. +create table t1 (a int, b datetime, c int as (week(b))); +insert into t1 values (1,'2008-09-04',default); +insert into t1 values (2,'2008-09-05',default); +select * from t1; +a b c +1 2008-09-04 00:00:00 35 +2 2008-09-05 00:00:00 35 +alter table t1 change column c c int as (week(b,1)); +select * from t1; +a b c +1 2008-09-04 00:00:00 36 +2 2008-09-05 00:00:00 36 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` datetime DEFAULT NULL, + `c` int(11) AS (week(b,1)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_non_stored_columns_myisam.result b/mysql-test/suite/vcol/r/vcol_non_stored_columns_myisam.result new file mode 100644 index 00000000000..be42b8b76c4 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_non_stored_columns_myisam.result @@ -0,0 +1,242 @@ +SET @@session.storage_engine = 'MyISAM'; +# Case 1. All non-stored columns. +# This scenario is currently impossible due to the fact that virtual columns +# with a constant expression are not allowed. +# Case 2. CREATE +# - Column1: "real" +# - Column 2: virtual non-stored +create table t1 (a int, b int as (-a)); +insert into t1 values (1,default); +select * from t1; +a b +1 -1 +insert into t1 values (2,default); +select * from t1; +a b +1 -1 +2 -2 +drop table t1; +# Case 3. CREATE +# - Column1: "real" +# - Column 2: virtual stored +create table t1 (a int, b int as (-a) persistent); +insert into t1 values (1,default); +select * from t1; +a b +1 -1 +insert into t1 values (2,default); +select * from t1; +a b +1 -1 +2 -2 +drop table t1; +# Case 4. CREATE +# - Column1: virtual non-stored +# - Column2: "real" +create table t1 (a int as (-b), b int); +insert into t1 values (default,1); +select * from t1; +a b +-1 1 +insert into t1 values (default,2); +select * from t1; +a b +-1 1 +-2 2 +drop table t1; +# Case 5. CREATE +# - Column1: virtual stored +# - Column2: "real" +create table t1 (a int as (-b) persistent, b int); +insert into t1 values (default,1); +select * from t1; +a b +-1 1 +insert into t1 values (default,2); +select * from t1; +a b +-1 1 +-2 2 +drop table t1; +# Case 6. CREATE +# - Column1: "real" +# - Column2: virtual non-stored +# - Column3: virtual stored +create table t1 (a int, b int as (-a), c int as (-a) persistent); +insert into t1 values (1,default,default); +select * from t1; +a b c +1 -1 -1 +insert into t1 values (2,default,default); +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +drop table t1; +# Case 7. ALTER. Modify virtual stored -> virtual non-stored +create table t1 (a int, b int as (a % 2) persistent); +alter table t1 modify b int as (a % 2); +ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) PERSISTENT +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +# Case 8. ALTER. Modify virtual non-stored -> virtual stored +create table t1 (a int, b int as (a % 2)); +alter table t1 modify b int as (a % 2) persistent; +ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 2) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +# Case 9. CREATE LIKE +# - Column1: "real" +# - Column2: virtual non-stored +# - Column3: virtual stored +create table t1 (a int, b int as (-a), c int as (-a) persistent); +create table t2 like t1; +insert into t2 values (1,default,default); +select * from t2; +a b c +1 -1 -1 +insert into t2 values (2,default,default); +select * from t2; +a b c +1 -1 -1 +2 -2 -2 +drop table t2; +drop table t1; +# Case 10. ALTER. Dropping a virtual non-stored column. +# - Column1: virtual non-stored +# - Column2: "real" +create table t1 (a int as (-b), b int, c varchar(5)); +insert into t1 values (default,1,'v1'); +insert into t1 values (default,2,'v2'); +select * from t1; +a b c +-1 1 v1 +-2 2 v2 +alter table t1 drop column a; +select * from t1; +b c +1 v1 +2 v2 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int(11) DEFAULT NULL, + `c` varchar(5) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +# Case 11. ALTER. Dropping a virtual stored column. +# - Column1: virtual stored +# - Column2: "real" +create table t1 (a int as (-b) persistent, b int, c char(5)); +insert into t1 values (default,1,'v1'); +insert into t1 values (default,2,'v2'); +select * from t1; +a b c +-1 1 v1 +-2 2 v2 +alter table t1 drop column a; +select * from t1; +b c +1 v1 +2 v2 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int(11) DEFAULT NULL, + `c` char(5) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +# Case 12. ALTER. Adding a new virtual non-stored column. +create table t1 (a int, b datetime); +insert into t1 values (1,'2008-09-04'); +insert into t1 values (2,'2008-09-05'); +select * from t1; +a b +1 2008-09-04 00:00:00 +2 2008-09-05 00:00:00 +alter table t1 add column c int as (dayofyear(b)) after a; +select * from t1; +a c b +1 248 2008-09-04 00:00:00 +2 249 2008-09-05 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `c` int(11) AS (dayofyear(b)) VIRTUAL, + `b` datetime DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +# Case 13. ALTER. Adding a new virtual stored column. +create table t1 (a int, b datetime); +insert into t1 values (1,'2008-09-04'); +insert into t1 values (2,'2008-09-05'); +select * from t1; +a b +1 2008-09-04 00:00:00 +2 2008-09-05 00:00:00 +alter table t1 add column c int as (dayofyear(b)) persistent after a; +select * from t1; +a c b +1 248 2008-09-04 00:00:00 +2 249 2008-09-05 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `c` int(11) AS (dayofyear(b)) PERSISTENT, + `b` datetime DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +# Case 14. ALTER. Changing the expression of a virtual stored column. +create table t1 (a int, b datetime, c int as (week(b)) persistent); +insert into t1 values (1,'2008-09-04',default); +insert into t1 values (2,'2008-09-05',default); +select * from t1; +a b c +1 2008-09-04 00:00:00 35 +2 2008-09-05 00:00:00 35 +alter table t1 change column c c int as (week(b,1)) persistent; +select * from t1; +a b c +1 2008-09-04 00:00:00 36 +2 2008-09-05 00:00:00 36 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` datetime DEFAULT NULL, + `c` int(11) AS (week(b,1)) PERSISTENT +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +# Case 15. ALTER. Changing the expression of a virtual non-stored column. +create table t1 (a int, b datetime, c int as (week(b))); +insert into t1 values (1,'2008-09-04',default); +insert into t1 values (2,'2008-09-05',default); +select * from t1; +a b c +1 2008-09-04 00:00:00 35 +2 2008-09-05 00:00:00 35 +alter table t1 change column c c int as (week(b,1)); +select * from t1; +a b c +1 2008-09-04 00:00:00 36 +2 2008-09-05 00:00:00 36 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` datetime DEFAULT NULL, + `c` int(11) AS (week(b,1)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_partition_innodb.result b/mysql-test/suite/vcol/r/vcol_partition_innodb.result new file mode 100644 index 00000000000..466c1851800 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_partition_innodb.result @@ -0,0 +1,80 @@ +SET @@session.storage_engine = 'InnoDB'; +drop table if exists t1; +# Case 1. Partitioning by RANGE based on a non-stored virtual column. +CREATE TABLE t1 ( +a DATE NOT NULL, +b int as (year(a)) +) +PARTITION BY RANGE( b ) ( +PARTITION p0 VALUES LESS THAN (2006), +PARTITION p2 VALUES LESS THAN (2008) +); +insert into t1 values ('2006-01-01',default); +insert into t1 values ('2007-01-01',default); +insert into t1 values ('2005-01-01',default); +select * from t1; +a b +2005-01-01 2005 +2006-01-01 2006 +2007-01-01 2007 +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; +partition_name table_rows data_length +p0 1 16384 +p2 2 16384 +# Modify the expression of virtual column b +ALTER TABLE t1 modify b int as (year(a)-1); +select * from t1; +a b +2005-01-01 2004 +2006-01-01 2005 +2007-01-01 2006 +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; +partition_name table_rows data_length +p0 2 16384 +p2 1 16384 +drop table t1; +# Case 2. Partitioning by LIST based on a stored virtual column. +CREATE TABLE t1 (a int, b int as (a % 3 ) persistent) +PARTITION BY LIST (a+1) +(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2)); +insert into t1 values (1,default); +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; +partition_name table_rows data_length +p1 0 16384 +p2 1 16384 +select * from t1; +a b +1 1 +select * from t1; +a b +1 1 +drop table t1; +# Case 3. Partitioning by HASH based on a non-stored virtual column. +CREATE TABLE t1 ( +a DATE NOT NULL, +b int as (year(a)) +) +PARTITION BY HASH( b % 3 ) PARTITIONS 3; +insert into t1 values ('2005-01-01',default); +insert into t1 values ('2006-01-01',default); +select * from t1; +a b +2005-01-01 2005 +2006-01-01 2006 +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; +partition_name table_rows data_length +p0 0 16384 +p1 1 16384 +p2 1 16384 +# Modify the expression of virtual column b +ALTER TABLE t1 modify b int as (year(a)-1); +select * from t1; +a b +2005-01-01 2004 +2006-01-01 2005 +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; +partition_name table_rows data_length +p0 1 16384 +p1 1 16384 +p2 0 16384 +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_partition_myisam.result b/mysql-test/suite/vcol/r/vcol_partition_myisam.result new file mode 100644 index 00000000000..9a92f308c45 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_partition_myisam.result @@ -0,0 +1,80 @@ +SET @@session.storage_engine = 'MyISAM'; +drop table if exists t1; +# Case 1. Partitioning by RANGE based on a non-stored virtual column. +CREATE TABLE t1 ( +a DATE NOT NULL, +b int as (year(a)) +) +PARTITION BY RANGE( b ) ( +PARTITION p0 VALUES LESS THAN (2006), +PARTITION p2 VALUES LESS THAN (2008) +); +insert into t1 values ('2006-01-01',default); +insert into t1 values ('2007-01-01',default); +insert into t1 values ('2005-01-01',default); +select * from t1; +a b +2005-01-01 2005 +2006-01-01 2006 +2007-01-01 2007 +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; +partition_name table_rows data_length +p0 1 7 +p2 2 14 +# Modify the expression of virtual column b +ALTER TABLE t1 modify b int as (year(a)-1); +select * from t1; +a b +2005-01-01 2004 +2006-01-01 2005 +2007-01-01 2006 +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; +partition_name table_rows data_length +p0 2 14 +p2 1 7 +drop table t1; +# Case 2. Partitioning by LIST based on a stored virtual column. +CREATE TABLE t1 (a int, b int as (a % 3 ) persistent) +PARTITION BY LIST (a+1) +(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2)); +insert into t1 values (1,default); +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; +partition_name table_rows data_length +p1 0 0 +p2 1 9 +select * from t1; +a b +1 1 +select * from t1; +a b +1 1 +drop table t1; +# Case 3. Partitioning by HASH based on a non-stored virtual column. +CREATE TABLE t1 ( +a DATE NOT NULL, +b int as (year(a)) +) +PARTITION BY HASH( b % 3 ) PARTITIONS 3; +insert into t1 values ('2005-01-01',default); +insert into t1 values ('2006-01-01',default); +select * from t1; +a b +2005-01-01 2005 +2006-01-01 2006 +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; +partition_name table_rows data_length +p0 0 0 +p1 1 7 +p2 1 7 +# Modify the expression of virtual column b +ALTER TABLE t1 modify b int as (year(a)-1); +select * from t1; +a b +2005-01-01 2004 +2006-01-01 2005 +select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1'; +partition_name table_rows data_length +p0 1 7 +p1 1 7 +p2 0 0 +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_select_innodb.result b/mysql-test/suite/vcol/r/vcol_select_innodb.result new file mode 100644 index 00000000000..f5b430fe233 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_select_innodb.result @@ -0,0 +1,264 @@ +SET @@session.storage_engine = 'InnoDB'; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent, +index (c)); +insert into t1 (a) values (2), (1), (1), (3), (NULL); +create table t2 like t1; +insert into t2 (a) values (1); +create table t3 (a int primary key, +b int as (-a), +c int as (-a) persistent unique); +insert into t3 (a) values (2),(1),(3); +# select_type=SIMPLE, type=system +select * from t2; +a b c +1 -1 -1 +explain select * from t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1 +select * from t2 where c=-1; +a b c +1 -1 -1 +explain select * from t2 where c=-1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref c c 5 const 1 Using where +# select_type=SIMPLE, type=ALL +select * from t1 where b=-1; +a b c +1 -1 -1 +1 -1 -1 +explain select * from t1 where b=-1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where +# select_type=SIMPLE, type=const +select * from t3 where a=1; +a b c +1 -1 -1 +explain select * from t3 where a=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 const PRIMARY PRIMARY 4 const 1 +# select_type=SIMPLE, type=range +select * from t3 where c>=-1; +a b c +1 -1 -1 +explain select * from t3 where c>=-1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c c 5 NULL 1 Using where +# select_type=SIMPLE, type=ref +select * from t1,t3 where t1.c=t3.c and t3.c=-1; +a b c a b c +1 -1 -1 1 -1 -1 +1 -1 -1 1 -1 -1 +explain select * from t1,t3 where t1.c=t3.c and t3.c=-1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 const c c 5 const 1 +1 SIMPLE t1 ref c c 5 const 2 Using where +# select_type=PRIMARY, type=index,ALL +select * from t1 where b in (select c from t3); +a b c +2 -2 -2 +1 -1 -1 +1 -1 -1 +3 -3 -3 +explain select * from t1 where b in (select c from t3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where +2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 1 Using index; Using where +# select_type=PRIMARY, type=range,ref +select * from t1 where c in (select c from t3 where c between -2 and -1); +a b c +2 -2 -2 +1 -1 -1 +1 -1 -1 +explain select * from t1 where c in (select c from t3 where c between -2 and -1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where +2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 1 Using index; Using where +# select_type=UNION, type=system +# select_type=UNION RESULT, type=<union1,2> +select * from t1 union select * from t2; +a b c +2 -2 -2 +1 -1 -1 +3 -3 -3 +NULL NULL NULL +explain select * from t1 union select * from t2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 +2 UNION t2 ALL NULL NULL NULL NULL 1 +NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL +# select_type=DERIVED, type=system +select * from (select a,b,c from t1) as t11; +a b c +2 -2 -2 +1 -1 -1 +1 -1 -1 +3 -3 -3 +NULL NULL NULL +explain select * from (select a,b,c from t1) as t11; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 +2 DERIVED t1 ALL NULL NULL NULL NULL 5 +### +### Using aggregate functions with/without DISTINCT +### +# SELECT COUNT(*) FROM tbl_name +select count(*) from t1; +count(*) +5 +explain select count(*) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL c 5 NULL 5 Using index +# SELECT COUNT(DISTINCT <non-vcol>) FROM tbl_name +select count(distinct a) from t1; +count(distinct a) +3 +explain select count(distinct a) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +# SELECT COUNT(DISTINCT <non-stored vcol>) FROM tbl_name +select count(distinct b) from t1; +count(distinct b) +3 +explain select count(distinct b) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +# SELECT COUNT(DISTINCT <stored vcol>) FROM tbl_name +select count(distinct c) from t1; +count(distinct c) +3 +explain select count(distinct c) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL c 5 NULL 5 Using index +### +### filesort & range-based utils +### +# SELECT * FROM tbl_name WHERE <vcol expr> +select * from t3 where c >= -2; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where c >= -2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c c 5 NULL 1 Using where +# SELECT * FROM tbl_name WHERE <non-vcol expr> +select * from t3 where a between 1 and 2; +a b c +1 -1 -1 +2 -2 -2 +explain select * from t3 where a between 1 and 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using where +# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> +select * from t3 where b between -2 and -1; +a b c +1 -1 -1 +2 -2 -2 +explain select * from t3 where b between -2 and -1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where +# SELECT * FROM tbl_name WHERE <indexed vcol expr> +select * from t3 where c between -2 and -1; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where c between -2 and -1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c c 5 NULL 1 Using where +# SELECT * FROM tbl_name WHERE <non-vcol expr> ORDER BY <non-indexed vcol> +select * from t3 where a between 1 and 2 order by b; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where a between 1 and 2 order by b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort +# SELECT * FROM tbl_name WHERE <non-vcol expr> ORDER BY <indexed vcol> +select * from t3 where a between 1 and 2 order by c; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where a between 1 and 2 order by c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort +# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-vcol> +select * from t3 where b between -2 and -1 order by a; +a b c +1 -1 -1 +2 -2 -2 +explain select * from t3 where b between -2 and -1 order by a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 index NULL PRIMARY 4 NULL 3 Using where +# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-indexed vcol> +select * from t3 where b between -2 and -1 order by b; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where b between -2 and -1 order by b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort +# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-indexed vcol> +select * from t3 where c between -2 and -1 order by b; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where c between -2 and -1 order by b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c c 5 NULL 1 Using where; Using filesort +# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <indexed vcol> +select * from t3 where b between -2 and -1 order by c; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where b between -2 and -1 order by c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort +# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <indexed vcol> +select * from t3 where c between -2 and -1 order by c; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where c between -2 and -1 order by c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c c 5 NULL 1 Using where +# SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol> +select sum(b) from t1 group by b; +sum(b) +NULL +-3 +-2 +-2 +explain select sum(b) from t1 group by b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort +# SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <indexed vcol> +select sum(c) from t1 group by c; +sum(c) +NULL +-3 +-2 +-2 +explain select sum(c) from t1 group by c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL c 5 NULL 5 Using index +# SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <indexed vcol> +select sum(b) from t1 group by c; +sum(b) +NULL +-3 +-2 +-2 +explain select sum(b) from t1 group by c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL c 5 NULL 5 +# SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol> +select sum(c) from t1 group by b; +sum(c) +NULL +-3 +-2 +-2 +explain select sum(c) from t1 group by b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort diff --git a/mysql-test/suite/vcol/r/vcol_select_myisam.result b/mysql-test/suite/vcol/r/vcol_select_myisam.result new file mode 100644 index 00000000000..45e4defd315 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_select_myisam.result @@ -0,0 +1,264 @@ +SET @@session.storage_engine = 'MyISAM'; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent, +index (c)); +insert into t1 (a) values (2), (1), (1), (3), (NULL); +create table t2 like t1; +insert into t2 (a) values (1); +create table t3 (a int primary key, +b int as (-a), +c int as (-a) persistent unique); +insert into t3 (a) values (2),(1),(3); +# select_type=SIMPLE, type=system +select * from t2; +a b c +1 -1 -1 +explain select * from t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 system NULL NULL NULL NULL 1 +select * from t2 where c=-1; +a b c +1 -1 -1 +explain select * from t2 where c=-1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 system c NULL NULL NULL 1 +# select_type=SIMPLE, type=ALL +select * from t1 where b=-1; +a b c +1 -1 -1 +1 -1 -1 +explain select * from t1 where b=-1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where +# select_type=SIMPLE, type=const +select * from t3 where a=1; +a b c +1 -1 -1 +explain select * from t3 where a=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 const PRIMARY PRIMARY 4 const 1 +# select_type=SIMPLE, type=range +select * from t3 where c>=-1; +a b c +1 -1 -1 +explain select * from t3 where c>=-1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c c 5 NULL 2 Using where +# select_type=SIMPLE, type=ref +select * from t1,t3 where t1.c=t3.c and t3.c=-1; +a b c a b c +1 -1 -1 1 -1 -1 +1 -1 -1 1 -1 -1 +explain select * from t1,t3 where t1.c=t3.c and t3.c=-1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 const c c 5 const 1 +1 SIMPLE t1 ref c c 5 const 2 Using where +# select_type=PRIMARY, type=index,ALL +select * from t1 where b in (select c from t3); +a b c +2 -2 -2 +1 -1 -1 +1 -1 -1 +3 -3 -3 +explain select * from t1 where b in (select c from t3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where +2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 2 Using index; Using where +# select_type=PRIMARY, type=range,ref +select * from t1 where c in (select c from t3 where c between -2 and -1); +a b c +2 -2 -2 +1 -1 -1 +1 -1 -1 +explain select * from t1 where c in (select c from t3 where c between -2 and -1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where +2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 2 Using index; Using where +# select_type=UNION, type=system +# select_type=UNION RESULT, type=<union1,2> +select * from t1 union select * from t2; +a b c +2 -2 -2 +1 -1 -1 +3 -3 -3 +NULL NULL NULL +explain select * from t1 union select * from t2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 +2 UNION t2 system NULL NULL NULL NULL 1 +NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL +# select_type=DERIVED, type=system +select * from (select a,b,c from t1) as t11; +a b c +2 -2 -2 +1 -1 -1 +1 -1 -1 +3 -3 -3 +NULL NULL NULL +explain select * from (select a,b,c from t1) as t11; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 +2 DERIVED t1 ALL NULL NULL NULL NULL 5 +### +### Using aggregate functions with/without DISTINCT +### +# SELECT COUNT(*) FROM tbl_name +select count(*) from t1; +count(*) +5 +explain select count(*) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +# SELECT COUNT(DISTINCT <non-vcol>) FROM tbl_name +select count(distinct a) from t1; +count(distinct a) +3 +explain select count(distinct a) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +# SELECT COUNT(DISTINCT <non-stored vcol>) FROM tbl_name +select count(distinct b) from t1; +count(distinct b) +3 +explain select count(distinct b) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +# SELECT COUNT(DISTINCT <stored vcol>) FROM tbl_name +select count(distinct c) from t1; +count(distinct c) +3 +explain select count(distinct c) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL c 5 NULL 5 Using index +### +### filesort & range-based utils +### +# SELECT * FROM tbl_name WHERE <vcol expr> +select * from t3 where c >= -2; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where c >= -2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c c 5 NULL 2 Using where +# SELECT * FROM tbl_name WHERE <non-vcol expr> +select * from t3 where a between 1 and 2; +a b c +1 -1 -1 +2 -2 -2 +explain select * from t3 where a between 1 and 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using where +# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> +select * from t3 where b between -2 and -1; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where b between -2 and -1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where +# SELECT * FROM tbl_name WHERE <indexed vcol expr> +select * from t3 where c between -2 and -1; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where c between -2 and -1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c c 5 NULL 1 Using where +# SELECT * FROM tbl_name WHERE <non-vcol expr> ORDER BY <indexed vcol> +select * from t3 where a between 1 and 2 order by c; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where a between 1 and 2 order by c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort +# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-vcol> +select * from t3 where b between -2 and -1 order by a; +a b c +1 -1 -1 +2 -2 -2 +explain select * from t3 where b between -2 and -1 order by a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort +# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-vcol> +select * from t3 where c between -2 and -1 order by a; +a b c +1 -1 -1 +2 -2 -2 +explain select * from t3 where c between -2 and -1 order by a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c c 5 NULL 1 Using where; Using filesort +# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-indexed vcol> +select * from t3 where b between -2 and -1 order by b; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where b between -2 and -1 order by b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort +# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-indexed vcol> +select * from t3 where c between -2 and -1 order by b; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where c between -2 and -1 order by b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c c 5 NULL 1 Using where; Using filesort +# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <indexed vcol> +select * from t3 where b between -2 and -1 order by c; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where b between -2 and -1 order by c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort +# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <indexed vcol> +select * from t3 where c between -2 and -1 order by c; +a b c +2 -2 -2 +1 -1 -1 +explain select * from t3 where c between -2 and -1 order by c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c c 5 NULL 1 Using where +# SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol> +select sum(b) from t1 group by b; +sum(b) +NULL +-3 +-2 +-2 +explain select sum(b) from t1 group by b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort +# SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <indexed vcol> +select sum(c) from t1 group by c; +sum(c) +NULL +-3 +-2 +-2 +explain select sum(c) from t1 group by c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL c 5 NULL 5 Using index +# SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <indexed vcol> +select sum(b) from t1 group by c; +sum(b) +NULL +-3 +-2 +-2 +explain select sum(b) from t1 group by c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort +# SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol> +select sum(c) from t1 group by b; +sum(c) +NULL +-3 +-2 +-2 +explain select sum(c) from t1 group by b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort diff --git a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result new file mode 100644 index 00000000000..2bc652a7da2 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result @@ -0,0 +1,2943 @@ +SET @@session.storage_engine = 'InnoDB'; +# +# NUMERIC FUNCTIONS +# +# ABS() +set sql_warnings = 1; +create table t1 (a int, b int as (abs(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (abs(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (-1, default); +select * from t1; +a b +-1 1 +drop table t1; +set sql_warnings = 0; +# ACOS() +set sql_warnings = 1; +create table t1 (a double, b double as (format(acos(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(acos(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1, default); +insert into t1 values (1.0001,default); +insert into t1 values (0,default); +select * from t1; +a b +1 0 +1.0001 NULL +0 1.570796 +drop table t1; +set sql_warnings = 0; +# ASIN() +set sql_warnings = 1; +create table t1 (a double, b double as (format(asin(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(asin(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (0.2, default); +insert into t1 values (1.0001,default); +select * from t1; +a b +0.2 0.201358 +1.0001 NULL +drop table t1; +set sql_warnings = 0; +#ATAN +set sql_warnings = 1; +create table t1 (a double, b double, c double as (format(atan(a,b),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double DEFAULT NULL, + `c` double AS (format(atan(a,b),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (-2,2,default); +insert into t1 values (format(PI(),6),0,default); +select * from t1; +a b c +-2 2 -0.785398 +3.141593 0 1.570796 +drop table t1; +set sql_warnings = 0; +set sql_warnings = 1; +create table t1 (a double, c double as (format(atan(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `c` double AS (format(atan(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (-2,default); +insert into t1 values (format(PI(),6),default); +select * from t1; +a c +-2 -1.107149 +3.141593 1.262627 +drop table t1; +set sql_warnings = 0; +# ATAN2 +set sql_warnings = 1; +create table t1 (a double, b double, c double as (format(atan2(a,b),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double DEFAULT NULL, + `c` double AS (format(atan2(a,b),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (-2,2,default); +insert into t1 values (format(PI(),6),0,default); +select * from t1; +a b c +-2 2 -0.785398 +3.141593 0 1.570796 +drop table t1; +set sql_warnings = 0; +# CEIL() +set sql_warnings = 1; +create table t1 (a double, b int as (ceil(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` int(11) AS (ceil(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1.23,default); +insert into t1 values (-1.23,default); +select * from t1; +a b +1.23 2 +-1.23 -1 +drop table t1; +set sql_warnings = 0; +# CONV() +set sql_warnings = 1; +create table t1 (a varchar(10), b int, c int, d varchar(10) as (conv(a,b,c))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `d` varchar(10) AS (conv(a,b,c)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('a',16,2,default); +insert into t1 values ('6e',18,8,default); +insert into t1 values (-17,10,-18,default); +insert into t1 values (10+'10'+'10'+0xa,10,10,default); +select * from t1; +a b c d +a 16 2 1010 +6e 18 8 172 +-17 10 -18 -H +40 10 10 40 +drop table t1; +set sql_warnings = 0; +# COS() +set sql_warnings = 1; +create table t1 (a double, b double as (format(cos(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(cos(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (format(PI(),6),default); +select * from t1; +a b +3.141593 -1 +drop table t1; +set sql_warnings = 0; +# COT() +set sql_warnings = 1; +create table t1 (a double, b double as (format(cot(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(cot(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (12,default); +insert into t1 values (0,default); +select * from t1; +a b +12 -1.572673 +0 NULL +drop table t1; +set sql_warnings = 0; +# CRC32() +set sql_warnings = 1; +create table t1 (a varchar(10), b long as (crc32(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` mediumtext AS (crc32(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +insert into t1 values ('mysql',default); +select * from t1; +a b +MySQL 3259397556 +mysql 2501908538 +drop table t1; +set sql_warnings = 0; +# DEGREES() +set sql_warnings = 1; +create table t1 (a double, b double as (format(degrees(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(degrees(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (format(PI(),6),default); +insert into t1 values (format(PI()/2,6),default); +select * from t1; +a b +3.141593 180.00002 +1.570796 89.999981 +drop table t1; +set sql_warnings = 0; +# / +set sql_warnings = 1; +create table t1 (a double, b double as (a/2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (a/2) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (2,default); +select * from t1; +a b +2 1 +drop table t1; +set sql_warnings = 0; +# EXP() +set sql_warnings = 1; +create table t1 (a double, b double as (format(exp(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(exp(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (2,default); +insert into t1 values (-2,default); +insert into t1 values (0,default); +select * from t1; +a b +2 7.389056 +-2 0.135335 +0 1 +drop table t1; +set sql_warnings = 0; +# FLOOR() +set sql_warnings = 1; +create table t1 (a double, b long as (floor(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` mediumtext AS (floor(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1.23,default); +insert into t1 values (-1.23,default); +select * from t1; +a b +1.23 1 +-1.23 -2 +drop table t1; +set sql_warnings = 0; +# LN() +set sql_warnings = 1; +create table t1 (a double, b double as (format(ln(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(ln(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (2,default); +insert into t1 values (-2,default); +select * from t1; +a b +2 0.693147 +-2 NULL +drop table t1; +set sql_warnings = 0; +# LOG() +set sql_warnings = 1; +create table t1 (a double, b double, c double as (format(log(a,b),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double DEFAULT NULL, + `c` double AS (format(log(a,b),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (2,65536,default); +insert into t1 values (10,100,default); +insert into t1 values (1,100,default); +select * from t1; +a b c +2 65536 16 +10 100 2 +1 100 NULL +drop table t1; +set sql_warnings = 0; +set sql_warnings = 1; +create table t1 (a double, b double as (format(log(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(log(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (2,default); +insert into t1 values (-2,default); +select * from t1; +a b +2 0.693147 +-2 NULL +drop table t1; +set sql_warnings = 0; +# LOG2() +set sql_warnings = 1; +create table t1 (a double, b double as (format(log2(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(log2(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (65536,default); +insert into t1 values (-100,default); +select * from t1; +a b +65536 16 +-100 NULL +drop table t1; +set sql_warnings = 0; +# LOG10() +set sql_warnings = 1; +create table t1 (a double, b double as (format(log10(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(log10(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (2,default); +insert into t1 values (100,default); +insert into t1 values (-100,default); +select * from t1; +a b +2 0.30103 +100 2 +-100 NULL +drop table t1; +set sql_warnings = 0; +# - +set sql_warnings = 1; +create table t1 (a double, b double as (a-1)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (a-1) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (2,default); +select * from t1; +a b +2 1 +drop table t1; +set sql_warnings = 0; +# MOD() +set sql_warnings = 1; +create table t1 (a int, b int as (mod(a,10))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (mod(a,10)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (11,default); +select * from t1; +a b +1 1 +11 1 +drop table t1; +set sql_warnings = 0; +# % +set sql_warnings = 1; +create table t1 (a int, b int as (a % 10)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 10) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (11,default); +select * from t1; +a b +1 1 +11 1 +drop table t1; +set sql_warnings = 0; +# OCT() +set sql_warnings = 1; +create table t1 (a double, b varchar(10) as (oct(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` varchar(10) AS (oct(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (12,default); +select * from t1; +a b +12 14 +drop table t1; +set sql_warnings = 0; +# PI() +set sql_warnings = 1; +create table t1 (a double, b double as (format(PI()*a*a,6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(PI()*a*a,6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +select * from t1; +a b +1 3.141593 +drop table t1; +set sql_warnings = 0; +# + +set sql_warnings = 1; +create table t1 (a int, b int as (a+1)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a+1) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +select * from t1; +a b +1 2 +drop table t1; +set sql_warnings = 0; +# POW, POWER +set sql_warnings = 1; +create table t1 (a int, b int as (pow(a,2)), c int as (power(a,2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (pow(a,2)) VIRTUAL, + `c` int(11) AS (power(a,2)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default,default); +insert into t1 values (2,default,default); +select * from t1; +a b c +1 1 1 +2 4 4 +drop table t1; +set sql_warnings = 0; +# RADIANS() +set sql_warnings = 1; +create table t1 (a double, b double as (format(radians(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(radians(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (90,default); +select * from t1; +a b +90 1.570796 +drop table t1; +set sql_warnings = 0; +# ROUND() +set sql_warnings = 1; +create table t1 (a double, b int as (round(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` int(11) AS (round(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (-1.23,default); +insert into t1 values (-1.58,default); +insert into t1 values (1.58,default); +select * from t1; +a b +-1.23 -1 +-1.58 -2 +1.58 2 +drop table t1; +set sql_warnings = 0; +set sql_warnings = 1; +create table t1 (a double, b double, c int as (round(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double DEFAULT NULL, + `c` int(11) AS (round(a,b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1.298,1,default); +insert into t1 values (1.298,0,default); +insert into t1 values (23.298,-1,default); +select * from t1; +a b c +1.298 1 1 +1.298 0 1 +23.298 -1 20 +drop table t1; +set sql_warnings = 0; +# SIGN() +set sql_warnings = 1; +create table t1 (a double, b int as (sign(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` int(11) AS (sign(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (-32,default); +insert into t1 values (0,default); +insert into t1 values (234,default); +select * from t1; +a b +-32 -1 +0 0 +234 1 +drop table t1; +set sql_warnings = 0; +# SIN() +set sql_warnings = 1; +create table t1 (a double, b double as (format(sin(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(sin(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (format(PI()/2,6),default); +select * from t1; +a b +1.570796 1 +drop table t1; +set sql_warnings = 0; +# SQRT() +set sql_warnings = 1; +create table t1 (a double, b double as (format(sqrt(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(sqrt(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (4,default); +insert into t1 values (20,default); +insert into t1 values (-16,default); +select * from t1; +a b +4 2 +20 4.472136 +-16 NULL +drop table t1; +set sql_warnings = 0; +# TAN() +set sql_warnings = 1; +create table t1 (a double, b double as (format(tan(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(tan(a),6)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (format(PI(),6),default); +insert into t1 values (format(PI()+1,6),default); +select * from t1; +a b +3.141593 0 +4.141593 1.557409 +drop table t1; +set sql_warnings = 0; +# * +set sql_warnings = 1; +create table t1 (a double, b double as (a*3)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (a*3) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (0,default); +insert into t1 values (1,default); +insert into t1 values (2,default); +select * from t1; +a b +0 0 +1 3 +2 6 +drop table t1; +set sql_warnings = 0; +# TRUNCATE() +set sql_warnings = 1; +create table t1 (a double, b double as (truncate(a,4))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (truncate(a,4)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1.223,default); +insert into t1 values (1.999,default); +insert into t1 values (1.999,default); +insert into t1 values (122,default); +select * from t1; +a b +1.223 1.223 +1.999 1.999 +1.999 1.999 +122 122 +drop table t1; +set sql_warnings = 0; +# Unary - +set sql_warnings = 1; +create table t1 (a double, b double as (-a)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (-a) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (-1,default); +select * from t1; +a b +1 -1 +-1 1 +drop table t1; +set sql_warnings = 0; +# +# STRING FUNCTIONS +# +# ASCII() +set sql_warnings = 1; +create table t1 (a char(2), b int as (ascii(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(2) DEFAULT NULL, + `b` int(11) AS (ascii(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2',default); +insert into t1 values (2,default); +insert into t1 values ('dx',default); +select * from t1; +a b +2 50 +2 50 +dx 100 +drop table t1; +set sql_warnings = 0; +# BIN() +set sql_warnings = 1; +create table t1 (a int, b varchar(10) as (bin(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(10) AS (bin(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (12,default); +select * from t1; +a b +12 1100 +drop table t1; +set sql_warnings = 0; +# BIT_LENGTH() +set sql_warnings = 1; +create table t1 (a varchar(10), b long as (bit_length(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` mediumtext AS (bit_length(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('text',default); +select * from t1; +a b +text 32 +drop table t1; +set sql_warnings = 0; +# CHAR_LENGTH() +set sql_warnings = 1; +create table t1 (a varchar(10), b long as (char_length(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` mediumtext AS (char_length(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('text',default); +select * from t1; +a b +text 4 +drop table t1; +set sql_warnings = 0; +# CHAR() +set sql_warnings = 1; +create table t1 (a int, b int, c varbinary(10) as (char(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` varbinary(10) AS (char(a,b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (77,121,default); +select * from t1; +a b c +77 121 My +drop table t1; +set sql_warnings = 0; +# CHARACTER_LENGTH() +set sql_warnings = 1; +create table t1 (a varchar(10), b long as (character_length(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` mediumtext AS (character_length(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('text',default); +select * from t1; +a b +text 4 +drop table t1; +set sql_warnings = 0; +# CONCAT_WS() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c varchar(20) as (concat_ws(',',a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` varchar(20) AS (concat_ws(',',a,b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('value1','value2',default); +select * from t1; +a b c +value1 value2 value1,value2 +drop table t1; +set sql_warnings = 0; +# CONCAT() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c varchar(20) as (concat(a,',',b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` varchar(20) AS (concat(a,',',b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('value1','value2',default); +select * from t1; +a b c +value1 value2 value1,value2 +drop table t1; +set sql_warnings = 0; +# ELT() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c int, d varchar(10) as (elt(c,a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `d` varchar(10) AS (elt(c,a,b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('value1','value2',1,default); +insert into t1 values ('value1','value2',2,default); +select * from t1; +a b c d +value1 value2 1 value1 +value1 value2 2 value2 +drop table t1; +set sql_warnings = 0; +# EXPORT_SET() +set sql_warnings = 1; +create table t1 (a int, b varchar(10) as (export_set(a,'1','0','',10))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(10) AS (export_set(a,'1','0','',10)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (6,default); +select * from t1; +a b +6 0110000000 +drop table t1; +set sql_warnings = 0; +# FIELD() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c int as (field('aa',a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` int(11) AS (field('aa',a,b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('aa','bb',default); +insert into t1 values ('bb','aa',default); +select * from t1; +a b c +aa bb 1 +bb aa 2 +drop table t1; +set sql_warnings = 0; +# FIND_IN_SET() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c int as (find_in_set(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` int(11) AS (find_in_set(a,b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('aa','aa,bb,cc',default); +insert into t1 values ('aa','bb,aa,cc',default); +select * from t1; +a b c +aa aa,bb,cc 1 +aa bb,aa,cc 2 +drop table t1; +set sql_warnings = 0; +# FORMAT() +set sql_warnings = 1; +create table t1 (a double, b varchar(20) as (format(a,2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` varchar(20) AS (format(a,2)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (12332.123456,default); +select * from t1; +a b +12332.123456 12,332.12 +drop table t1; +set sql_warnings = 0; +# HEX() +set sql_warnings = 1; +create table t1 (a int, b varchar(10) as (hex(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(10) AS (hex(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (17,default); +select * from t1; +a b +17 11 +drop table t1; +set sql_warnings = 0; +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (hex(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (hex(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('abc',default); +select * from t1; +a b +abc 616263 +drop table t1; +set sql_warnings = 0; +# INSERT() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c varchar(20) as (insert(a,length(a),length(b),b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` varchar(20) AS (insert(a,length(a),length(b),b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('start,','end',default); +select * from t1; +a b c +start, end startend +drop table t1; +set sql_warnings = 0; +# INSTR() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c int as (instr(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` int(11) AS (instr(a,b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('foobarbar,','bar',default); +insert into t1 values ('xbar,','foobar',default); +select * from t1; +a b c +foobarbar, bar 4 +xbar, foobar 0 +drop table t1; +set sql_warnings = 0; +# LCASE() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (lcase(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (lcase(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL mysql +drop table t1; +set sql_warnings = 0; +# LEFT() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(5) as (left(a,5))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(5) AS (left(a,5)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('foobarbar',default); +select * from t1; +a b +foobarbar fooba +drop table t1; +set sql_warnings = 0; +# LENGTH() +set sql_warnings = 1; +create table t1 (a varchar(10), b int as (length(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` int(11) AS (length(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('text',default); +select * from t1; +a b +text 4 +drop table t1; +set sql_warnings = 0; +# LIKE +set sql_warnings = 1; +create table t1 (a varchar(10), b bool as (a like 'H%o')); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` tinyint(1) AS (a like 'H%o') VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +insert into t1 values ('MySQL',default); +select * from t1; +a b +Hello 1 +MySQL 0 +drop table t1; +set sql_warnings = 0; +# LOCATE() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (locate('bar',a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (locate('bar',a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('foobarbar',default); +select * from t1; +a b +foobarbar 4 +drop table t1; +set sql_warnings = 0; +# LOWER() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (lower(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (lower(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL mysql +drop table t1; +set sql_warnings = 0; +# LPAD() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (lpad(a,4,' '))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (lpad(a,4,' ')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +insert into t1 values ('M',default); +select * from t1; +a b +MySQL MySQ +M M +drop table t1; +set sql_warnings = 0; +# LTRIM() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (ltrim(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (ltrim(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (' MySQL',default); +insert into t1 values ('MySQL',default); +select * from t1; +a b + MySQL MySQL +MySQL MySQL +drop table t1; +set sql_warnings = 0; +# MAKE_SET() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c int, d varchar(30) as (make_set(c,a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `d` varchar(30) AS (make_set(c,a,b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('a','b',1,default); +insert into t1 values ('a','b',3,default); +select * from t1; +a b c d +a b 1 a +a b 3 a,b +drop table t1; +set sql_warnings = 0; +# MID() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (mid(a,1,2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (mid(a,1,2)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('foobarbar',default); +select * from t1; +a b +foobarbar fo +drop table t1; +set sql_warnings = 0; +# NOT LIKE +set sql_warnings = 1; +create table t1 (a varchar(10), b bool as (a not like 'H%o')); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` tinyint(1) AS (a not like 'H%o') VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +insert into t1 values ('MySQL',default); +select * from t1; +a b +Hello 0 +MySQL 1 +drop table t1; +set sql_warnings = 0; +# NOT REGEXP +set sql_warnings = 1; +create table t1 (a varchar(10), b bool as (a not regexp 'H.+o')); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` tinyint(1) AS (a not regexp 'H.+o') VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +insert into t1 values ('hello',default); +select * from t1; +a b +Hello 0 +hello 0 +drop table t1; +set sql_warnings = 0; +# OCTET_LENGTH() +set sql_warnings = 1; +create table t1 (a varchar(10), b int as (octet_length(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` int(11) AS (octet_length(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('text',default); +select * from t1; +a b +text 4 +drop table t1; +set sql_warnings = 0; +# ORD() +set sql_warnings = 1; +create table t1 (a varchar(10), b long as (ord(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` mediumtext AS (ord(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2',default); +select * from t1; +a b +2 50 +drop table t1; +set sql_warnings = 0; +# POSITION() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (position('bar' in a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (position('bar' in a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('foobarbar',default); +select * from t1; +a b +foobarbar 4 +drop table t1; +set sql_warnings = 0; +# QUOTE() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (quote(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (quote(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('Don\'t',default); +select * from t1; +a b +Don't 'Don\'t' +drop table t1; +set sql_warnings = 0; +# REGEXP() +set sql_warnings = 1; +create table t1 (a varchar(10), b bool as (a regexp 'H.+o')); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` tinyint(1) AS (a regexp 'H.+o') VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +insert into t1 values ('hello',default); +select * from t1; +a b +Hello 1 +hello 1 +drop table t1; +set sql_warnings = 0; +# REPEAT() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(30) as (repeat(a,3))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(30) AS (repeat(a,3)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL MySQLMySQLMySQL +drop table t1; +set sql_warnings = 0; +# REPLACE() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(30) as (replace(a,'aa','bb'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(30) AS (replace(a,'aa','bb')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('maa',default); +select * from t1; +a b +maa mbb +drop table t1; +set sql_warnings = 0; +# REVERSE() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(30) as (reverse(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(30) AS (reverse(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('maa',default); +select * from t1; +a b +maa aam +drop table t1; +set sql_warnings = 0; +# RIGHT() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (right(a,4))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (right(a,4)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('foobarbar',default); +select * from t1; +a b +foobarbar rbar +drop table t1; +set sql_warnings = 0; +# RLIKE() +set sql_warnings = 1; +create table t1 (a varchar(10), b bool as (a rlike 'H.+o')); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` tinyint(1) AS (a rlike 'H.+o') VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +insert into t1 values ('MySQL',default); +select * from t1; +a b +Hello 1 +MySQL 0 +drop table t1; +set sql_warnings = 0; +# RPAD() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (rpad(a,4,'??'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (rpad(a,4,'??')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('He',default); +select * from t1; +a b +He He?? +drop table t1; +set sql_warnings = 0; +# RTRIM(); +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (rtrim(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (rtrim(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('Hello ',default); +select * from t1; +a b +Hello Hello +drop table t1; +set sql_warnings = 0; +# SOUNDEX() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(20) as (soundex(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(20) AS (soundex(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +select * from t1; +a b +Hello H400 +drop table t1; +set sql_warnings = 0; +# SOUNDS LIKE +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a sounds like b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a sounds like b) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('Hello','Hello',default); +insert into t1 values ('Hello','MySQL',default); +insert into t1 values ('Hello','hello',default); +select * from t1; +a b c +Hello Hello 1 +Hello MySQL 0 +Hello hello 1 +drop table t1; +set sql_warnings = 0; +# SPACE() +set sql_warnings = 1; +create table t1 (a varchar(5), b varchar(10) as (concat(a,space(5)))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) DEFAULT NULL, + `b` varchar(10) AS (concat(a,space(5))) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('Hello', default); +select * from t1; +a b +Hello Hello +drop table t1; +set sql_warnings = 0; +# STRCMP() +set sql_warnings = 1; +create table t1 (a varchar(9), b varchar(9), c tinyint(1) as (strcmp(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(9) DEFAULT NULL, + `b` varchar(9) DEFAULT NULL, + `c` tinyint(1) AS (strcmp(a,b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('Hello','Hello', default); +insert into t1 values ('Hello','Hello1', default); +select * from t1; +a b c +Hello Hello 0 +Hello Hello1 -1 +drop table t1; +set sql_warnings = 0; +# SUBSTR() +set sql_warnings = 1; +create table t1 (a varchar(5), b varchar(10) as (substr(a,2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) DEFAULT NULL, + `b` varchar(10) AS (substr(a,2)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +select * from t1; +a b +Hello ello +drop table t1; +set sql_warnings = 0; +# SUBSTRING_INDEX() +set sql_warnings = 1; +create table t1 (a varchar(15), b varchar(10) as (substring_index(a,'.',2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(15) DEFAULT NULL, + `b` varchar(10) AS (substring_index(a,'.',2)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('www.mysql.com',default); +select * from t1; +a b +www.mysql.com www.mysql +drop table t1; +set sql_warnings = 0; +# SUBSTRING() +set sql_warnings = 1; +create table t1 (a varchar(5), b varchar(10) as (substring(a from 2 for 2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) DEFAULT NULL, + `b` varchar(10) AS (substring(a from 2 for 2)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +select * from t1; +a b +Hello el +drop table t1; +set sql_warnings = 0; +# TRIM() +set sql_warnings = 1; +create table t1 (a varchar(15), b varchar(10) as (trim(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(15) DEFAULT NULL, + `b` varchar(10) AS (trim(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (' aa ',default); +select * from t1; +a b + aa aa +drop table t1; +set sql_warnings = 0; +# UCASE() +set sql_warnings = 1; +create table t1 (a varchar(5), b varchar(10) as (ucase(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) DEFAULT NULL, + `b` varchar(10) AS (ucase(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL MYSQL +drop table t1; +set sql_warnings = 0; +# UNHEX() +set sql_warnings = 1; +create table t1 (a varchar(15), b varchar(10) as (unhex(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(15) DEFAULT NULL, + `b` varchar(10) AS (unhex(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('4D7953514C',default); +select * from t1; +a b +4D7953514C MySQL +drop table t1; +set sql_warnings = 0; +# UPPER() +set sql_warnings = 1; +create table t1 (a varchar(5), b varchar(10) as (upper(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) DEFAULT NULL, + `b` varchar(10) AS (upper(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL MYSQL +drop table t1; +set sql_warnings = 0; +# +# CONTROL FLOW FUNCTIONS +# +# CASE +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(16) as (case a when NULL then 'asd' when 'b' then 'B' else a end)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(16) AS (case a when NULL then 'asd' when 'b' then 'B' else a end) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (NULL,default); +insert into t1 values ('b',default); +insert into t1 values ('c',default); +select * from t1; +a b +NULL NULL +b B +c c +drop table t1; +set sql_warnings = 0; +# IF +set sql_warnings = 1; +create table t1 (a int, b int, c int as (if(a=1,a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) AS (if(a=1,a,b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,2,default); +insert into t1 values (3,4,default); +select * from t1; +a b c +1 2 1 +3 4 4 +drop table t1; +set sql_warnings = 0; +# IFNULL +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c varchar(10) as (ifnull(a,'DEFAULT'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` varchar(10) AS (ifnull(a,'DEFAULT')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (NULL,'adf',default); +insert into t1 values ('a','adf',default); +select * from t1; +a b c +NULL adf DEFAULT +a adf a +drop table t1; +set sql_warnings = 0; +# NULLIF +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (nullif(a,'DEFAULT'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (nullif(a,'DEFAULT')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('DEFAULT',default); +insert into t1 values ('a',default); +select * from t1; +a b +DEFAULT NULL +a a +drop table t1; +set sql_warnings = 0; +# +# OPERATORS +# +# AND, && +set sql_warnings = 1; +create table t1 (a int, b bool as (a>0 && a<2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` tinyint(1) AS (a>0 && a<2) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (-1,default); +insert into t1 values (1,default); +select * from t1; +a b +-1 0 +1 1 +drop table t1; +set sql_warnings = 0; +# BETWEEN ... AND ... +set sql_warnings = 1; +create table t1 (a int, b bool as (a between 0 and 2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` tinyint(1) AS (a between 0 and 2) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (-1,default); +insert into t1 values (1,default); +select * from t1; +a b +-1 0 +1 1 +drop table t1; +set sql_warnings = 0; +# BINARY +set sql_warnings = 1; +create table t1 (a varchar(10), b varbinary(10) as (binary a)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varbinary(10) AS (binary a) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('11',default); +insert into t1 values (1,default); +select * from t1; +a b +11 11 +1 1 +drop table t1; +set sql_warnings = 0; +# & +set sql_warnings = 1; +create table t1 (a int, b int as (a & 5)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a & 5) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (0,default); +select * from t1; +a b +1 1 +0 0 +drop table t1; +set sql_warnings = 0; +# ~ +set sql_warnings = 1; +create table t1 (a int, b int as (~a)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (~a) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +Warnings: +Warning 1264 Out of range value for column 'b' at row 1 +select * from t1; +a b +1 2147483647 +drop table t1; +set sql_warnings = 0; +# | +set sql_warnings = 1; +create table t1 (a int, b int as (a | 5)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a | 5) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (0,default); +insert into t1 values (2,default); +select * from t1; +a b +1 5 +0 5 +2 7 +drop table t1; +set sql_warnings = 0; +# ^ +set sql_warnings = 1; +create table t1 (a int, b int as (a ^ 5)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a ^ 5) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (0,default); +insert into t1 values (2,default); +select * from t1; +a b +1 4 +0 5 +2 7 +drop table t1; +set sql_warnings = 0; +# DIV +set sql_warnings = 1; +create table t1 (a int, b int as (a div 5)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a div 5) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (7,default); +select * from t1; +a b +1 0 +7 1 +drop table t1; +set sql_warnings = 0; +# <=> +set sql_warnings = 1; +create table t1 (a int, b int, c bool as (a <=> b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` tinyint(1) AS (a <=> b) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,1,default); +insert into t1 values (NULL,NULL,default); +insert into t1 values (1,NULL,default); +select * from t1; +a b c +1 1 1 +NULL NULL 1 +1 NULL 0 +drop table t1; +set sql_warnings = 0; +# = +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a=b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a=b) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('a','b',default); +insert into t1 values ('a','a',default); +select * from t1; +a b c +a b 0 +a a 1 +drop table t1; +set sql_warnings = 0; +# >= +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a >= b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a >= b) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('a','b',default); +insert into t1 values ('a','a',default); +select * from t1; +a b c +a b 0 +a a 1 +drop table t1; +set sql_warnings = 0; +# > +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a > b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a > b) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('a','b',default); +insert into t1 values ('a','a',default); +select * from t1; +a b c +a b 0 +a a 0 +drop table t1; +set sql_warnings = 0; +# IS NOT NULL +set sql_warnings = 1; +create table t1 (a int, b bool as (a is not null)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` tinyint(1) AS (a is not null) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (NULL,default); +select * from t1; +a b +1 1 +NULL 0 +drop table t1; +set sql_warnings = 0; +# IS NULL +set sql_warnings = 1; +create table t1 (a int, b bool as (a is null)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` tinyint(1) AS (a is null) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (NULL,default); +select * from t1; +a b +1 0 +NULL 1 +drop table t1; +set sql_warnings = 0; +# << +set sql_warnings = 1; +create table t1 (a int, b int as (a << 2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a << 2) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (3,default); +select * from t1; +a b +1 4 +3 12 +drop table t1; +set sql_warnings = 0; +# <= +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a <= b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a <= b) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('b','a',default); +insert into t1 values ('b','b',default); +insert into t1 values ('b','c',default); +select * from t1; +a b c +b a 0 +b b 1 +b c 1 +drop table t1; +set sql_warnings = 0; +# < +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a < b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a < b) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('b','a',default); +insert into t1 values ('b','b',default); +insert into t1 values ('b','c',default); +select * from t1; +a b c +b a 0 +b b 0 +b c 1 +drop table t1; +set sql_warnings = 0; +# NOT BETWEEN ... AND ... +set sql_warnings = 1; +create table t1 (a int, b bool as (a not between 0 and 2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` tinyint(1) AS (a not between 0 and 2) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (-1,default); +insert into t1 values (1,default); +select * from t1; +a b +-1 1 +1 0 +drop table t1; +set sql_warnings = 0; +# <> +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a <> b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a <> b) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('b','a',default); +insert into t1 values ('b','b',default); +insert into t1 values ('b','c',default); +select * from t1; +a b c +b a 1 +b b 0 +b c 1 +drop table t1; +set sql_warnings = 0; +# != +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a != b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a != b) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('b','a',default); +insert into t1 values ('b','b',default); +insert into t1 values ('b','c',default); +select * from t1; +a b c +b a 1 +b b 0 +b c 1 +drop table t1; +set sql_warnings = 0; +# ||, OR +set sql_warnings = 1; +create table t1 (a int, b int as (a>5 || a<3)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a>5 || a<3) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (4,default); +select * from t1; +a b +1 1 +4 0 +drop table t1; +set sql_warnings = 0; +# >> +set sql_warnings = 1; +create table t1 (a int, b int as (a >> 2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a >> 2) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (8,default); +insert into t1 values (3,default); +select * from t1; +a b +8 2 +3 0 +drop table t1; +set sql_warnings = 0; +# XOR +set sql_warnings = 1; +create table t1 (a int, b int as (a xor 5)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a xor 5) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (0,default); +insert into t1 values (1,default); +insert into t1 values (2,default); +select * from t1; +a b +0 1 +1 0 +2 0 +drop table t1; +set sql_warnings = 0; +# +# DATE AND TIME FUNCTIONS +# +# ADDDATE() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (adddate(a,interval 1 month))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (adddate(a,interval 1 month)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-09-30 00:00:00 +drop table t1; +set sql_warnings = 0; +# ADDTIME() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (addtime(a,'02:00:00'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (addtime(a,'02:00:00')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-08-31 02:00:00 +drop table t1; +set sql_warnings = 0; +# CONVERT_TZ() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (convert_tz(a,'MET','UTC'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (convert_tz(a,'MET','UTC')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-08-30 22:00:00 +drop table t1; +set sql_warnings = 0; +# DATE_ADD() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (date_add(a,interval 1 month))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (date_add(a,interval 1 month)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-09-30 00:00:00 +drop table t1; +set sql_warnings = 0; +# DATE_FORMAT() +set sql_warnings = 1; +create table t1 (a datetime, b varchar(64) as (date_format(a,'%W %M %D'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` varchar(64) AS (date_format(a,'%W %M %D')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 Sunday August 31st +drop table t1; +set sql_warnings = 0; +# DATE_SUB() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (date_sub(a,interval 1 month))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (date_sub(a,interval 1 month)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-07-31 00:00:00 +drop table t1; +set sql_warnings = 0; +# DATE() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (date(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (date(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31 02:00:00',default); +select * from t1; +a b +2008-08-31 02:00:00 2008-08-31 00:00:00 +drop table t1; +set sql_warnings = 0; +# DATEDIFF() +set sql_warnings = 1; +create table t1 (a datetime, b long as (datediff(a,'2000-01-01'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` mediumtext AS (datediff(a,'2000-01-01')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 3165 +drop table t1; +set sql_warnings = 0; +# DAY() +set sql_warnings = 1; +create table t1 (a datetime, b int as (day(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (day(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 31 +drop table t1; +set sql_warnings = 0; +# DAYNAME() +set sql_warnings = 1; +create table t1 (a datetime, b varchar(10) as (dayname(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` varchar(10) AS (dayname(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 Sunday +drop table t1; +set sql_warnings = 0; +# DAYOFMONTH() +set sql_warnings = 1; +create table t1 (a datetime, b int as (dayofmonth(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (dayofmonth(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 31 +drop table t1; +set sql_warnings = 0; +# DAYOFWEEK() +set sql_warnings = 1; +create table t1 (a datetime, b int as (dayofweek(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (dayofweek(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 1 +drop table t1; +set sql_warnings = 0; +# DAYOFYEAR() +set sql_warnings = 1; +create table t1 (a datetime, b int as (dayofyear(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (dayofyear(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 244 +drop table t1; +set sql_warnings = 0; +# EXTRACT +set sql_warnings = 1; +create table t1 (a datetime, b int as (extract(year from a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (extract(year from a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008 +drop table t1; +set sql_warnings = 0; +# FROM_DAYS() +set sql_warnings = 1; +create table t1 (a long, b datetime as (from_days(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` mediumtext, + `b` datetime AS (from_days(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (730669,default); +select * from t1; +a b +730669 2000-07-03 00:00:00 +drop table t1; +set sql_warnings = 0; +# FROM_UNIXTIME() +set time_zone='UTC'; +set sql_warnings = 1; +create table t1 (a long, b datetime as (from_unixtime(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` mediumtext, + `b` datetime AS (from_unixtime(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1196440219,default); +select * from t1; +a b +1196440219 2007-11-30 16:30:19 +drop table t1; +set sql_warnings = 0; +# GET_FORMAT() +set sql_warnings = 1; +create table t1 (a datetime, b varchar(32) as (date_format(a,get_format(DATE,'EUR')))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` varchar(32) AS (date_format(a,get_format(DATE,'EUR'))) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 31.08.2008 +drop table t1; +set sql_warnings = 0; +# HOUR() +set sql_warnings = 1; +create table t1 (a time, b long as (hour(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` time DEFAULT NULL, + `b` mediumtext AS (hour(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('10:05:03',default); +select * from t1; +a b +10:05:03 10 +drop table t1; +set sql_warnings = 0; +# LAST_DAY() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (last_day(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (last_day(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2003-02-05',default); +insert into t1 values ('2003-02-32',default); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +select * from t1; +a b +2003-02-05 00:00:00 2003-02-28 00:00:00 +0000-00-00 00:00:00 NULL +drop table t1; +set sql_warnings = 0; +# MAKEDATE() +set sql_warnings = 1; +create table t1 (a int, b datetime as (makedate(a,1))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` datetime AS (makedate(a,1)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (2001,default); +select * from t1; +a b +2001 2001-01-01 00:00:00 +drop table t1; +set sql_warnings = 0; +# MAKETIME() +set sql_warnings = 1; +create table t1 (a int, b time as (maketime(a,1,3))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` time AS (maketime(a,1,3)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (12,default); +select * from t1; +a b +12 12:01:03 +drop table t1; +set sql_warnings = 0; +# MICROSECOND() +set sql_warnings = 1; +create table t1 (a datetime, b long as (microsecond(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` mediumtext AS (microsecond(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2009-12-31 12:00:00.123456',default); +insert into t1 values ('2009-12-31 23:59:59.000010',default); +select * from t1; +a b +2009-12-31 12:00:00 0 +2009-12-31 23:59:59 0 +drop table t1; +set sql_warnings = 0; +# MINUTE() +set sql_warnings = 1; +create table t1 (a datetime, b int as (minute(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (minute(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2009-12-31 23:59:59.000010',default); +select * from t1; +a b +2009-12-31 23:59:59 59 +drop table t1; +set sql_warnings = 0; +# MONTH() +set sql_warnings = 1; +create table t1 (a datetime, b int as (month(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (month(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2009-12-31 23:59:59.000010',default); +select * from t1; +a b +2009-12-31 23:59:59 12 +drop table t1; +set sql_warnings = 0; +# MONTHNAME() +set sql_warnings = 1; +create table t1 (a datetime, b varchar(16) as (monthname(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` varchar(16) AS (monthname(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2009-12-31 23:59:59.000010',default); +select * from t1; +a b +2009-12-31 23:59:59 December +drop table t1; +set sql_warnings = 0; +# PERIOD_ADD() +set sql_warnings = 1; +create table t1 (a int, b int as (period_add(a,2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (period_add(a,2)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (200801,default); +select * from t1; +a b +200801 200803 +drop table t1; +set sql_warnings = 0; +# PERIOD_DIFF() +set sql_warnings = 1; +create table t1 (a int, b int, c int as (period_diff(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) AS (period_diff(a,b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (200802,200703,default); +select * from t1; +a b c +200802 200703 11 +drop table t1; +set sql_warnings = 0; +# QUARTER() +set sql_warnings = 1; +create table t1 (a datetime, b int as (quarter(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (quarter(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 3 +drop table t1; +set sql_warnings = 0; +# SEC_TO_TIME() +set sql_warnings = 1; +create table t1 (a long, b time as (sec_to_time(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` mediumtext, + `b` time AS (sec_to_time(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (2378,default); +select * from t1; +a b +2378 00:39:38 +drop table t1; +set sql_warnings = 0; +# SECOND() +set sql_warnings = 1; +create table t1 (a datetime, b int as (second(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (second(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('10:05:03',default); +select * from t1; +a b +2010-05-03 00:00:00 0 +drop table t1; +set sql_warnings = 0; +# STR_TO_DATE() +set sql_warnings = 1; +create table t1 (a varchar(64), b datetime as (str_to_date(a,'%m/%d/%Y'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(64) DEFAULT NULL, + `b` datetime AS (str_to_date(a,'%m/%d/%Y')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('04/30/2004',default); +select * from t1; +a b +04/30/2004 2004-04-30 00:00:00 +drop table t1; +set sql_warnings = 0; +# SUBDATE() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (subdate(a,interval 1 month))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (subdate(a,interval 1 month)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-07-31 00:00:00 +drop table t1; +set sql_warnings = 0; +# SUBTIME() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (subtime(a,'02:00:00'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (subtime(a,'02:00:00')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-08-30 22:00:00 +drop table t1; +set sql_warnings = 0; +# TIME_FORMAT() +set sql_warnings = 1; +create table t1 (a datetime, b varchar(32) as (time_format(a,'%r'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` varchar(32) AS (time_format(a,'%r')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31 02:03:04',default); +select * from t1; +a b +2008-08-31 02:03:04 02:03:04 AM +drop table t1; +set sql_warnings = 0; +# TIME_TO_SEC() +set sql_warnings = 1; +create table t1 (a time, b long as (time_to_sec(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` time DEFAULT NULL, + `b` mediumtext AS (time_to_sec(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('22:23:00',default); +select * from t1; +a b +22:23:00 80580 +drop table t1; +set sql_warnings = 0; +# TIME() +set sql_warnings = 1; +create table t1 (a datetime, b time as (time(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` time AS (time(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31 02:03:04',default); +select * from t1; +a b +2008-08-31 02:03:04 02:03:04 +drop table t1; +set sql_warnings = 0; +# TIMEDIFF() +set sql_warnings = 1; +create table t1 (a datetime, b datetime, c long as (timediff(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime DEFAULT NULL, + `c` mediumtext AS (timediff(a,b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-12-31 23:59:59.000001','2008-12-30 01:01:01.000002',default); +select * from t1; +a b c +2008-12-31 23:59:59 2008-12-30 01:01:01 46:58:58 +drop table t1; +set sql_warnings = 0; +# TIMESTAMP() +set sql_warnings = 1; +create table t1 (a datetime, b timestamp as (timestamp(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` timestamp AS (timestamp(a)) VIRTUAL NULL ON UPDATE CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-12-31',default); +select * from t1; +a b +2008-12-31 00:00:00 2008-12-31 00:00:00 +drop table t1; +set sql_warnings = 0; +# TIMESTAMPADD() +set sql_warnings = 1; +create table t1 (a datetime, b timestamp as (timestampadd(minute,1,a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` timestamp AS (timestampadd(minute,1,a)) VIRTUAL NULL ON UPDATE CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2003-01-02',default); +select * from t1; +a b +2003-01-02 00:00:00 2003-01-02 00:01:00 +drop table t1; +set sql_warnings = 0; +# TIMESTAMPDIFF() +set sql_warnings = 1; +create table t1 (a timestamp, b timestamp, c long as (timestampdiff(MONTH, a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `b` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `c` mediumtext AS (timestampdiff(MONTH, a,b)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2003-02-01','2003-05-01',default); +select * from t1; +a b c +2003-02-01 00:00:00 2003-05-01 00:00:00 3 +drop table t1; +set sql_warnings = 0; +# TO_DAYS() +set sql_warnings = 1; +create table t1 (a datetime, b long as (to_days(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` mediumtext AS (to_days(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2007-10-07',default); +select * from t1; +a b +2007-10-07 00:00:00 733321 +drop table t1; +set sql_warnings = 0; +# WEEK() +set sql_warnings = 1; +create table t1 (a datetime, b int as (week(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (week(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-09-01',default); +select * from t1; +a b +2008-09-01 00:00:00 35 +drop table t1; +set sql_warnings = 0; +# WEEKDAY() +set sql_warnings = 1; +create table t1 (a datetime, b int as (weekday(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (weekday(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-09-01',default); +select * from t1; +a b +2008-09-01 00:00:00 0 +drop table t1; +set sql_warnings = 0; +# WEEKOFYEAR() +set sql_warnings = 1; +create table t1 (a datetime, b int as (weekofyear(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (weekofyear(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-09-01',default); +select * from t1; +a b +2008-09-01 00:00:00 36 +drop table t1; +set sql_warnings = 0; +# YEAR() +set sql_warnings = 1; +create table t1 (a datetime, b int as (year(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (year(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-09-01',default); +select * from t1; +a b +2008-09-01 00:00:00 2008 +drop table t1; +set sql_warnings = 0; +# YEARWEEK() +set sql_warnings = 1; +create table t1 (a datetime, b int as (yearweek(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (yearweek(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('2008-09-01',default); +select * from t1; +a b +2008-09-01 00:00:00 200835 +drop table t1; +set sql_warnings = 0; +# +# FULL TEXT SEARCH FUNCTIONS +# +# None. +# +# CAST FUNCTIONS AND OPERATORS +# +# CAST() +set sql_warnings = 1; +create table t1 (a int, b long as (cast(a as unsigned))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` mediumtext AS (cast(a as unsigned)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (-1,default); +select * from t1; +a b +1 1 +-1 18446744073709551615 +drop table t1; +set sql_warnings = 0; +# Convert() +set sql_warnings = 1; +create table t1 (a int, b long as (convert(a,unsigned))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` mediumtext AS (convert(a,unsigned)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (-1,default); +select * from t1; +a b +1 1 +-1 18446744073709551615 +drop table t1; +set sql_warnings = 0; +# +# XML FUNCTIONS +# +# None. +# +# OTHER FUNCTIONS +# +# AES_DECRYPT(), AES_ENCRYPT() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (aes_encrypt(aes_decrypt(a,'adf'),'adf'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (aes_encrypt(aes_decrypt(a,'adf'),'adf')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL NULL +drop table t1; +set sql_warnings = 0; +# BIT_COUNT() +set sql_warnings = 1; +create table t1 (a int, b int as (bit_count(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (bit_count(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values (5,default); +select * from t1; +a b +5 2 +drop table t1; +set sql_warnings = 0; +# CHARSET() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (charset(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (charset(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('abc',default); +select * from t1; +a b +abc latin1 +drop table t1; +set sql_warnings = 0; +# COERCIBILITY() +set sql_warnings = 1; +create table t1 (a varchar(1024), b int as (coercibility(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` int(11) AS (coercibility(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('abc',default); +select * from t1; +a b +abc 2 +drop table t1; +set sql_warnings = 0; +# COLLATION() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (collation(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (collation(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('abc',default); +select * from t1; +a b +abc latin1_swedish_ci +drop table t1; +set sql_warnings = 0; +# COMPRESS(), UNCOMPRESS() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (uncompress(compress(a)))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (uncompress(compress(a))) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL MySQL +drop table t1; +set sql_warnings = 0; +# ENCODE(), DECODE() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (decode(encode(a,'abc'),'abc'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (decode(encode(a,'abc'),'abc')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL MySQL +drop table t1; +set sql_warnings = 0; +# DEFAULT() +set sql_warnings = 1; +create table t1 (a varchar(1024) default 'aaa', b varchar(1024) as (ifnull(a,default(a)))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT 'aaa', + `b` varchar(1024) AS (ifnull(a,default(a))) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('any value',default); +select * from t1; +a b +any value any value +drop table t1; +set sql_warnings = 0; +# INET_ATON(), INET_NTOA() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (inet_ntoa(inet_aton(a)))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (inet_ntoa(inet_aton(a))) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('127.0.0.1',default); +select * from t1; +a b +127.0.0.1 127.0.0.1 +drop table t1; +set sql_warnings = 0; +# MD5() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varbinary(32) as (md5(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varbinary(32) AS (md5(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('testing',default); +select * from t1; +a b +testing ae2b1fca515949e5d54fb22b8ed95575 +drop table t1; +set sql_warnings = 0; +# OLD_PASSWORD() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (old_password(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (old_password(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('badpwd',default); +select * from t1; +a b +badpwd 7f84554057dd964b +drop table t1; +set sql_warnings = 0; +# PASSWORD() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (password(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (password(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('badpwd',default); +select * from t1; +a b +badpwd *AAB3E285149C0135D51A520E1940DD3263DC008C +drop table t1; +set sql_warnings = 0; +# SHA1() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (sha1(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (sha1(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('abc',default); +select * from t1; +a b +abc a9993e364706816aba3e25717850c26c9cd0d89d +drop table t1; +set sql_warnings = 0; +# SHA() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (sha(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (sha(a)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('abc',default); +select * from t1; +a b +abc a9993e364706816aba3e25717850c26c9cd0d89d +drop table t1; +set sql_warnings = 0; +# UNCOMPRESSED_LENGTH() +set sql_warnings = 1; +create table t1 (a char, b varchar(1024) as (uncompressed_length(compress(repeat(a,30))))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(1) DEFAULT NULL, + `b` varchar(1024) AS (uncompressed_length(compress(repeat(a,30)))) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +insert into t1 values ('a',default); +select * from t1; +a b +a 30 +drop table t1; +set sql_warnings = 0; diff --git a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result new file mode 100644 index 00000000000..a94e220180c --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result @@ -0,0 +1,2943 @@ +SET @@session.storage_engine = 'MyISAM'; +# +# NUMERIC FUNCTIONS +# +# ABS() +set sql_warnings = 1; +create table t1 (a int, b int as (abs(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (abs(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (-1, default); +select * from t1; +a b +-1 1 +drop table t1; +set sql_warnings = 0; +# ACOS() +set sql_warnings = 1; +create table t1 (a double, b double as (format(acos(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(acos(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1, default); +insert into t1 values (1.0001,default); +insert into t1 values (0,default); +select * from t1; +a b +1 0 +1.0001 NULL +0 1.570796 +drop table t1; +set sql_warnings = 0; +# ASIN() +set sql_warnings = 1; +create table t1 (a double, b double as (format(asin(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(asin(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (0.2, default); +insert into t1 values (1.0001,default); +select * from t1; +a b +0.2 0.201358 +1.0001 NULL +drop table t1; +set sql_warnings = 0; +#ATAN +set sql_warnings = 1; +create table t1 (a double, b double, c double as (format(atan(a,b),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double DEFAULT NULL, + `c` double AS (format(atan(a,b),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (-2,2,default); +insert into t1 values (format(PI(),6),0,default); +select * from t1; +a b c +-2 2 -0.785398 +3.141593 0 1.570796 +drop table t1; +set sql_warnings = 0; +set sql_warnings = 1; +create table t1 (a double, c double as (format(atan(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `c` double AS (format(atan(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (-2,default); +insert into t1 values (format(PI(),6),default); +select * from t1; +a c +-2 -1.107149 +3.141593 1.262627 +drop table t1; +set sql_warnings = 0; +# ATAN2 +set sql_warnings = 1; +create table t1 (a double, b double, c double as (format(atan2(a,b),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double DEFAULT NULL, + `c` double AS (format(atan2(a,b),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (-2,2,default); +insert into t1 values (format(PI(),6),0,default); +select * from t1; +a b c +-2 2 -0.785398 +3.141593 0 1.570796 +drop table t1; +set sql_warnings = 0; +# CEIL() +set sql_warnings = 1; +create table t1 (a double, b int as (ceil(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` int(11) AS (ceil(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1.23,default); +insert into t1 values (-1.23,default); +select * from t1; +a b +1.23 2 +-1.23 -1 +drop table t1; +set sql_warnings = 0; +# CONV() +set sql_warnings = 1; +create table t1 (a varchar(10), b int, c int, d varchar(10) as (conv(a,b,c))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `d` varchar(10) AS (conv(a,b,c)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('a',16,2,default); +insert into t1 values ('6e',18,8,default); +insert into t1 values (-17,10,-18,default); +insert into t1 values (10+'10'+'10'+0xa,10,10,default); +select * from t1; +a b c d +a 16 2 1010 +6e 18 8 172 +-17 10 -18 -H +40 10 10 40 +drop table t1; +set sql_warnings = 0; +# COS() +set sql_warnings = 1; +create table t1 (a double, b double as (format(cos(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(cos(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (format(PI(),6),default); +select * from t1; +a b +3.141593 -1 +drop table t1; +set sql_warnings = 0; +# COT() +set sql_warnings = 1; +create table t1 (a double, b double as (format(cot(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(cot(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (12,default); +insert into t1 values (0,default); +select * from t1; +a b +12 -1.572673 +0 NULL +drop table t1; +set sql_warnings = 0; +# CRC32() +set sql_warnings = 1; +create table t1 (a varchar(10), b long as (crc32(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` mediumtext AS (crc32(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +insert into t1 values ('mysql',default); +select * from t1; +a b +MySQL 3259397556 +mysql 2501908538 +drop table t1; +set sql_warnings = 0; +# DEGREES() +set sql_warnings = 1; +create table t1 (a double, b double as (format(degrees(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(degrees(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (format(PI(),6),default); +insert into t1 values (format(PI()/2,6),default); +select * from t1; +a b +3.141593 180.00002 +1.570796 89.999981 +drop table t1; +set sql_warnings = 0; +# / +set sql_warnings = 1; +create table t1 (a double, b double as (a/2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (a/2) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (2,default); +select * from t1; +a b +2 1 +drop table t1; +set sql_warnings = 0; +# EXP() +set sql_warnings = 1; +create table t1 (a double, b double as (format(exp(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(exp(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (2,default); +insert into t1 values (-2,default); +insert into t1 values (0,default); +select * from t1; +a b +2 7.389056 +-2 0.135335 +0 1 +drop table t1; +set sql_warnings = 0; +# FLOOR() +set sql_warnings = 1; +create table t1 (a double, b long as (floor(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` mediumtext AS (floor(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1.23,default); +insert into t1 values (-1.23,default); +select * from t1; +a b +1.23 1 +-1.23 -2 +drop table t1; +set sql_warnings = 0; +# LN() +set sql_warnings = 1; +create table t1 (a double, b double as (format(ln(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(ln(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (2,default); +insert into t1 values (-2,default); +select * from t1; +a b +2 0.693147 +-2 NULL +drop table t1; +set sql_warnings = 0; +# LOG() +set sql_warnings = 1; +create table t1 (a double, b double, c double as (format(log(a,b),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double DEFAULT NULL, + `c` double AS (format(log(a,b),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (2,65536,default); +insert into t1 values (10,100,default); +insert into t1 values (1,100,default); +select * from t1; +a b c +2 65536 16 +10 100 2 +1 100 NULL +drop table t1; +set sql_warnings = 0; +set sql_warnings = 1; +create table t1 (a double, b double as (format(log(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(log(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (2,default); +insert into t1 values (-2,default); +select * from t1; +a b +2 0.693147 +-2 NULL +drop table t1; +set sql_warnings = 0; +# LOG2() +set sql_warnings = 1; +create table t1 (a double, b double as (format(log2(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(log2(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (65536,default); +insert into t1 values (-100,default); +select * from t1; +a b +65536 16 +-100 NULL +drop table t1; +set sql_warnings = 0; +# LOG10() +set sql_warnings = 1; +create table t1 (a double, b double as (format(log10(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(log10(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (2,default); +insert into t1 values (100,default); +insert into t1 values (-100,default); +select * from t1; +a b +2 0.30103 +100 2 +-100 NULL +drop table t1; +set sql_warnings = 0; +# - +set sql_warnings = 1; +create table t1 (a double, b double as (a-1)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (a-1) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (2,default); +select * from t1; +a b +2 1 +drop table t1; +set sql_warnings = 0; +# MOD() +set sql_warnings = 1; +create table t1 (a int, b int as (mod(a,10))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (mod(a,10)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (11,default); +select * from t1; +a b +1 1 +11 1 +drop table t1; +set sql_warnings = 0; +# % +set sql_warnings = 1; +create table t1 (a int, b int as (a % 10)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a % 10) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (11,default); +select * from t1; +a b +1 1 +11 1 +drop table t1; +set sql_warnings = 0; +# OCT() +set sql_warnings = 1; +create table t1 (a double, b varchar(10) as (oct(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` varchar(10) AS (oct(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (12,default); +select * from t1; +a b +12 14 +drop table t1; +set sql_warnings = 0; +# PI() +set sql_warnings = 1; +create table t1 (a double, b double as (format(PI()*a*a,6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(PI()*a*a,6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +select * from t1; +a b +1 3.141593 +drop table t1; +set sql_warnings = 0; +# + +set sql_warnings = 1; +create table t1 (a int, b int as (a+1)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a+1) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +select * from t1; +a b +1 2 +drop table t1; +set sql_warnings = 0; +# POW, POWER +set sql_warnings = 1; +create table t1 (a int, b int as (pow(a,2)), c int as (power(a,2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (pow(a,2)) VIRTUAL, + `c` int(11) AS (power(a,2)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default,default); +insert into t1 values (2,default,default); +select * from t1; +a b c +1 1 1 +2 4 4 +drop table t1; +set sql_warnings = 0; +# RADIANS() +set sql_warnings = 1; +create table t1 (a double, b double as (format(radians(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(radians(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (90,default); +select * from t1; +a b +90 1.570796 +drop table t1; +set sql_warnings = 0; +# ROUND() +set sql_warnings = 1; +create table t1 (a double, b int as (round(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` int(11) AS (round(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (-1.23,default); +insert into t1 values (-1.58,default); +insert into t1 values (1.58,default); +select * from t1; +a b +-1.23 -1 +-1.58 -2 +1.58 2 +drop table t1; +set sql_warnings = 0; +set sql_warnings = 1; +create table t1 (a double, b double, c int as (round(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double DEFAULT NULL, + `c` int(11) AS (round(a,b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1.298,1,default); +insert into t1 values (1.298,0,default); +insert into t1 values (23.298,-1,default); +select * from t1; +a b c +1.298 1 1 +1.298 0 1 +23.298 -1 20 +drop table t1; +set sql_warnings = 0; +# SIGN() +set sql_warnings = 1; +create table t1 (a double, b int as (sign(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` int(11) AS (sign(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (-32,default); +insert into t1 values (0,default); +insert into t1 values (234,default); +select * from t1; +a b +-32 -1 +0 0 +234 1 +drop table t1; +set sql_warnings = 0; +# SIN() +set sql_warnings = 1; +create table t1 (a double, b double as (format(sin(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(sin(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (format(PI()/2,6),default); +select * from t1; +a b +1.570796 1 +drop table t1; +set sql_warnings = 0; +# SQRT() +set sql_warnings = 1; +create table t1 (a double, b double as (format(sqrt(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(sqrt(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (4,default); +insert into t1 values (20,default); +insert into t1 values (-16,default); +select * from t1; +a b +4 2 +20 4.472136 +-16 NULL +drop table t1; +set sql_warnings = 0; +# TAN() +set sql_warnings = 1; +create table t1 (a double, b double as (format(tan(a),6))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (format(tan(a),6)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (format(PI(),6),default); +insert into t1 values (format(PI()+1,6),default); +select * from t1; +a b +3.141593 0 +4.141593 1.557409 +drop table t1; +set sql_warnings = 0; +# * +set sql_warnings = 1; +create table t1 (a double, b double as (a*3)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (a*3) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (0,default); +insert into t1 values (1,default); +insert into t1 values (2,default); +select * from t1; +a b +0 0 +1 3 +2 6 +drop table t1; +set sql_warnings = 0; +# TRUNCATE() +set sql_warnings = 1; +create table t1 (a double, b double as (truncate(a,4))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (truncate(a,4)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1.223,default); +insert into t1 values (1.999,default); +insert into t1 values (1.999,default); +insert into t1 values (122,default); +select * from t1; +a b +1.223 1.223 +1.999 1.999 +1.999 1.999 +122 122 +drop table t1; +set sql_warnings = 0; +# Unary - +set sql_warnings = 1; +create table t1 (a double, b double as (-a)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` double AS (-a) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (-1,default); +select * from t1; +a b +1 -1 +-1 1 +drop table t1; +set sql_warnings = 0; +# +# STRING FUNCTIONS +# +# ASCII() +set sql_warnings = 1; +create table t1 (a char(2), b int as (ascii(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(2) DEFAULT NULL, + `b` int(11) AS (ascii(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2',default); +insert into t1 values (2,default); +insert into t1 values ('dx',default); +select * from t1; +a b +2 50 +2 50 +dx 100 +drop table t1; +set sql_warnings = 0; +# BIN() +set sql_warnings = 1; +create table t1 (a int, b varchar(10) as (bin(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(10) AS (bin(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (12,default); +select * from t1; +a b +12 1100 +drop table t1; +set sql_warnings = 0; +# BIT_LENGTH() +set sql_warnings = 1; +create table t1 (a varchar(10), b long as (bit_length(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` mediumtext AS (bit_length(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('text',default); +select * from t1; +a b +text 32 +drop table t1; +set sql_warnings = 0; +# CHAR_LENGTH() +set sql_warnings = 1; +create table t1 (a varchar(10), b long as (char_length(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` mediumtext AS (char_length(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('text',default); +select * from t1; +a b +text 4 +drop table t1; +set sql_warnings = 0; +# CHAR() +set sql_warnings = 1; +create table t1 (a int, b int, c varbinary(10) as (char(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` varbinary(10) AS (char(a,b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (77,121,default); +select * from t1; +a b c +77 121 My +drop table t1; +set sql_warnings = 0; +# CHARACTER_LENGTH() +set sql_warnings = 1; +create table t1 (a varchar(10), b long as (character_length(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` mediumtext AS (character_length(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('text',default); +select * from t1; +a b +text 4 +drop table t1; +set sql_warnings = 0; +# CONCAT_WS() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c varchar(20) as (concat_ws(',',a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` varchar(20) AS (concat_ws(',',a,b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('value1','value2',default); +select * from t1; +a b c +value1 value2 value1,value2 +drop table t1; +set sql_warnings = 0; +# CONCAT() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c varchar(20) as (concat(a,',',b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` varchar(20) AS (concat(a,',',b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('value1','value2',default); +select * from t1; +a b c +value1 value2 value1,value2 +drop table t1; +set sql_warnings = 0; +# ELT() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c int, d varchar(10) as (elt(c,a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `d` varchar(10) AS (elt(c,a,b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('value1','value2',1,default); +insert into t1 values ('value1','value2',2,default); +select * from t1; +a b c d +value1 value2 1 value1 +value1 value2 2 value2 +drop table t1; +set sql_warnings = 0; +# EXPORT_SET() +set sql_warnings = 1; +create table t1 (a int, b varchar(10) as (export_set(a,'1','0','',10))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(10) AS (export_set(a,'1','0','',10)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (6,default); +select * from t1; +a b +6 0110000000 +drop table t1; +set sql_warnings = 0; +# FIELD() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c int as (field('aa',a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` int(11) AS (field('aa',a,b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('aa','bb',default); +insert into t1 values ('bb','aa',default); +select * from t1; +a b c +aa bb 1 +bb aa 2 +drop table t1; +set sql_warnings = 0; +# FIND_IN_SET() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c int as (find_in_set(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` int(11) AS (find_in_set(a,b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('aa','aa,bb,cc',default); +insert into t1 values ('aa','bb,aa,cc',default); +select * from t1; +a b c +aa aa,bb,cc 1 +aa bb,aa,cc 2 +drop table t1; +set sql_warnings = 0; +# FORMAT() +set sql_warnings = 1; +create table t1 (a double, b varchar(20) as (format(a,2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double DEFAULT NULL, + `b` varchar(20) AS (format(a,2)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (12332.123456,default); +select * from t1; +a b +12332.123456 12,332.12 +drop table t1; +set sql_warnings = 0; +# HEX() +set sql_warnings = 1; +create table t1 (a int, b varchar(10) as (hex(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(10) AS (hex(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (17,default); +select * from t1; +a b +17 11 +drop table t1; +set sql_warnings = 0; +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (hex(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (hex(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('abc',default); +select * from t1; +a b +abc 616263 +drop table t1; +set sql_warnings = 0; +# INSERT() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c varchar(20) as (insert(a,length(a),length(b),b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` varchar(20) AS (insert(a,length(a),length(b),b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('start,','end',default); +select * from t1; +a b c +start, end startend +drop table t1; +set sql_warnings = 0; +# INSTR() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c int as (instr(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` int(11) AS (instr(a,b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('foobarbar,','bar',default); +insert into t1 values ('xbar,','foobar',default); +select * from t1; +a b c +foobarbar, bar 4 +xbar, foobar 0 +drop table t1; +set sql_warnings = 0; +# LCASE() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (lcase(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (lcase(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL mysql +drop table t1; +set sql_warnings = 0; +# LEFT() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(5) as (left(a,5))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(5) AS (left(a,5)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('foobarbar',default); +select * from t1; +a b +foobarbar fooba +drop table t1; +set sql_warnings = 0; +# LENGTH() +set sql_warnings = 1; +create table t1 (a varchar(10), b int as (length(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` int(11) AS (length(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('text',default); +select * from t1; +a b +text 4 +drop table t1; +set sql_warnings = 0; +# LIKE +set sql_warnings = 1; +create table t1 (a varchar(10), b bool as (a like 'H%o')); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` tinyint(1) AS (a like 'H%o') VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +insert into t1 values ('MySQL',default); +select * from t1; +a b +Hello 1 +MySQL 0 +drop table t1; +set sql_warnings = 0; +# LOCATE() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (locate('bar',a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (locate('bar',a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('foobarbar',default); +select * from t1; +a b +foobarbar 4 +drop table t1; +set sql_warnings = 0; +# LOWER() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (lower(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (lower(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL mysql +drop table t1; +set sql_warnings = 0; +# LPAD() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (lpad(a,4,' '))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (lpad(a,4,' ')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +insert into t1 values ('M',default); +select * from t1; +a b +MySQL MySQ +M M +drop table t1; +set sql_warnings = 0; +# LTRIM() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (ltrim(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (ltrim(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (' MySQL',default); +insert into t1 values ('MySQL',default); +select * from t1; +a b + MySQL MySQL +MySQL MySQL +drop table t1; +set sql_warnings = 0; +# MAKE_SET() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c int, d varchar(30) as (make_set(c,a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `d` varchar(30) AS (make_set(c,a,b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('a','b',1,default); +insert into t1 values ('a','b',3,default); +select * from t1; +a b c d +a b 1 a +a b 3 a,b +drop table t1; +set sql_warnings = 0; +# MID() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (mid(a,1,2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (mid(a,1,2)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('foobarbar',default); +select * from t1; +a b +foobarbar fo +drop table t1; +set sql_warnings = 0; +# NOT LIKE +set sql_warnings = 1; +create table t1 (a varchar(10), b bool as (a not like 'H%o')); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` tinyint(1) AS (a not like 'H%o') VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +insert into t1 values ('MySQL',default); +select * from t1; +a b +Hello 0 +MySQL 1 +drop table t1; +set sql_warnings = 0; +# NOT REGEXP +set sql_warnings = 1; +create table t1 (a varchar(10), b bool as (a not regexp 'H.+o')); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` tinyint(1) AS (a not regexp 'H.+o') VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +insert into t1 values ('hello',default); +select * from t1; +a b +Hello 0 +hello 0 +drop table t1; +set sql_warnings = 0; +# OCTET_LENGTH() +set sql_warnings = 1; +create table t1 (a varchar(10), b int as (octet_length(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` int(11) AS (octet_length(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('text',default); +select * from t1; +a b +text 4 +drop table t1; +set sql_warnings = 0; +# ORD() +set sql_warnings = 1; +create table t1 (a varchar(10), b long as (ord(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` mediumtext AS (ord(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2',default); +select * from t1; +a b +2 50 +drop table t1; +set sql_warnings = 0; +# POSITION() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (position('bar' in a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (position('bar' in a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('foobarbar',default); +select * from t1; +a b +foobarbar 4 +drop table t1; +set sql_warnings = 0; +# QUOTE() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (quote(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (quote(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('Don\'t',default); +select * from t1; +a b +Don't 'Don\'t' +drop table t1; +set sql_warnings = 0; +# REGEXP() +set sql_warnings = 1; +create table t1 (a varchar(10), b bool as (a regexp 'H.+o')); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` tinyint(1) AS (a regexp 'H.+o') VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +insert into t1 values ('hello',default); +select * from t1; +a b +Hello 1 +hello 1 +drop table t1; +set sql_warnings = 0; +# REPEAT() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(30) as (repeat(a,3))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(30) AS (repeat(a,3)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL MySQLMySQLMySQL +drop table t1; +set sql_warnings = 0; +# REPLACE() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(30) as (replace(a,'aa','bb'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(30) AS (replace(a,'aa','bb')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('maa',default); +select * from t1; +a b +maa mbb +drop table t1; +set sql_warnings = 0; +# REVERSE() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(30) as (reverse(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(30) AS (reverse(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('maa',default); +select * from t1; +a b +maa aam +drop table t1; +set sql_warnings = 0; +# RIGHT() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (right(a,4))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (right(a,4)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('foobarbar',default); +select * from t1; +a b +foobarbar rbar +drop table t1; +set sql_warnings = 0; +# RLIKE() +set sql_warnings = 1; +create table t1 (a varchar(10), b bool as (a rlike 'H.+o')); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` tinyint(1) AS (a rlike 'H.+o') VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +insert into t1 values ('MySQL',default); +select * from t1; +a b +Hello 1 +MySQL 0 +drop table t1; +set sql_warnings = 0; +# RPAD() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (rpad(a,4,'??'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (rpad(a,4,'??')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('He',default); +select * from t1; +a b +He He?? +drop table t1; +set sql_warnings = 0; +# RTRIM(); +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (rtrim(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (rtrim(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('Hello ',default); +select * from t1; +a b +Hello Hello +drop table t1; +set sql_warnings = 0; +# SOUNDEX() +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(20) as (soundex(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(20) AS (soundex(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +select * from t1; +a b +Hello H400 +drop table t1; +set sql_warnings = 0; +# SOUNDS LIKE +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a sounds like b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a sounds like b) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('Hello','Hello',default); +insert into t1 values ('Hello','MySQL',default); +insert into t1 values ('Hello','hello',default); +select * from t1; +a b c +Hello Hello 1 +Hello MySQL 0 +Hello hello 1 +drop table t1; +set sql_warnings = 0; +# SPACE() +set sql_warnings = 1; +create table t1 (a varchar(5), b varchar(10) as (concat(a,space(5)))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) DEFAULT NULL, + `b` varchar(10) AS (concat(a,space(5))) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('Hello', default); +select * from t1; +a b +Hello Hello +drop table t1; +set sql_warnings = 0; +# STRCMP() +set sql_warnings = 1; +create table t1 (a varchar(9), b varchar(9), c tinyint(1) as (strcmp(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(9) DEFAULT NULL, + `b` varchar(9) DEFAULT NULL, + `c` tinyint(1) AS (strcmp(a,b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('Hello','Hello', default); +insert into t1 values ('Hello','Hello1', default); +select * from t1; +a b c +Hello Hello 0 +Hello Hello1 -1 +drop table t1; +set sql_warnings = 0; +# SUBSTR() +set sql_warnings = 1; +create table t1 (a varchar(5), b varchar(10) as (substr(a,2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) DEFAULT NULL, + `b` varchar(10) AS (substr(a,2)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +select * from t1; +a b +Hello ello +drop table t1; +set sql_warnings = 0; +# SUBSTRING_INDEX() +set sql_warnings = 1; +create table t1 (a varchar(15), b varchar(10) as (substring_index(a,'.',2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(15) DEFAULT NULL, + `b` varchar(10) AS (substring_index(a,'.',2)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('www.mysql.com',default); +select * from t1; +a b +www.mysql.com www.mysql +drop table t1; +set sql_warnings = 0; +# SUBSTRING() +set sql_warnings = 1; +create table t1 (a varchar(5), b varchar(10) as (substring(a from 2 for 2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) DEFAULT NULL, + `b` varchar(10) AS (substring(a from 2 for 2)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('Hello',default); +select * from t1; +a b +Hello el +drop table t1; +set sql_warnings = 0; +# TRIM() +set sql_warnings = 1; +create table t1 (a varchar(15), b varchar(10) as (trim(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(15) DEFAULT NULL, + `b` varchar(10) AS (trim(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (' aa ',default); +select * from t1; +a b + aa aa +drop table t1; +set sql_warnings = 0; +# UCASE() +set sql_warnings = 1; +create table t1 (a varchar(5), b varchar(10) as (ucase(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) DEFAULT NULL, + `b` varchar(10) AS (ucase(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL MYSQL +drop table t1; +set sql_warnings = 0; +# UNHEX() +set sql_warnings = 1; +create table t1 (a varchar(15), b varchar(10) as (unhex(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(15) DEFAULT NULL, + `b` varchar(10) AS (unhex(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('4D7953514C',default); +select * from t1; +a b +4D7953514C MySQL +drop table t1; +set sql_warnings = 0; +# UPPER() +set sql_warnings = 1; +create table t1 (a varchar(5), b varchar(10) as (upper(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) DEFAULT NULL, + `b` varchar(10) AS (upper(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL MYSQL +drop table t1; +set sql_warnings = 0; +# +# CONTROL FLOW FUNCTIONS +# +# CASE +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(16) as (case a when NULL then 'asd' when 'b' then 'B' else a end)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(16) AS (case a when NULL then 'asd' when 'b' then 'B' else a end) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (NULL,default); +insert into t1 values ('b',default); +insert into t1 values ('c',default); +select * from t1; +a b +NULL NULL +b B +c c +drop table t1; +set sql_warnings = 0; +# IF +set sql_warnings = 1; +create table t1 (a int, b int, c int as (if(a=1,a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) AS (if(a=1,a,b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,2,default); +insert into t1 values (3,4,default); +select * from t1; +a b c +1 2 1 +3 4 4 +drop table t1; +set sql_warnings = 0; +# IFNULL +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c varchar(10) as (ifnull(a,'DEFAULT'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` varchar(10) AS (ifnull(a,'DEFAULT')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (NULL,'adf',default); +insert into t1 values ('a','adf',default); +select * from t1; +a b c +NULL adf DEFAULT +a adf a +drop table t1; +set sql_warnings = 0; +# NULLIF +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10) as (nullif(a,'DEFAULT'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) AS (nullif(a,'DEFAULT')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('DEFAULT',default); +insert into t1 values ('a',default); +select * from t1; +a b +DEFAULT NULL +a a +drop table t1; +set sql_warnings = 0; +# +# OPERATORS +# +# AND, && +set sql_warnings = 1; +create table t1 (a int, b bool as (a>0 && a<2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` tinyint(1) AS (a>0 && a<2) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (-1,default); +insert into t1 values (1,default); +select * from t1; +a b +-1 0 +1 1 +drop table t1; +set sql_warnings = 0; +# BETWEEN ... AND ... +set sql_warnings = 1; +create table t1 (a int, b bool as (a between 0 and 2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` tinyint(1) AS (a between 0 and 2) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (-1,default); +insert into t1 values (1,default); +select * from t1; +a b +-1 0 +1 1 +drop table t1; +set sql_warnings = 0; +# BINARY +set sql_warnings = 1; +create table t1 (a varchar(10), b varbinary(10) as (binary a)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varbinary(10) AS (binary a) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('11',default); +insert into t1 values (1,default); +select * from t1; +a b +11 11 +1 1 +drop table t1; +set sql_warnings = 0; +# & +set sql_warnings = 1; +create table t1 (a int, b int as (a & 5)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a & 5) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (0,default); +select * from t1; +a b +1 1 +0 0 +drop table t1; +set sql_warnings = 0; +# ~ +set sql_warnings = 1; +create table t1 (a int, b int as (~a)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (~a) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +Warnings: +Warning 1264 Out of range value for column 'b' at row 1 +select * from t1; +a b +1 2147483647 +drop table t1; +set sql_warnings = 0; +# | +set sql_warnings = 1; +create table t1 (a int, b int as (a | 5)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a | 5) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (0,default); +insert into t1 values (2,default); +select * from t1; +a b +1 5 +0 5 +2 7 +drop table t1; +set sql_warnings = 0; +# ^ +set sql_warnings = 1; +create table t1 (a int, b int as (a ^ 5)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a ^ 5) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (0,default); +insert into t1 values (2,default); +select * from t1; +a b +1 4 +0 5 +2 7 +drop table t1; +set sql_warnings = 0; +# DIV +set sql_warnings = 1; +create table t1 (a int, b int as (a div 5)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a div 5) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (7,default); +select * from t1; +a b +1 0 +7 1 +drop table t1; +set sql_warnings = 0; +# <=> +set sql_warnings = 1; +create table t1 (a int, b int, c bool as (a <=> b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` tinyint(1) AS (a <=> b) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,1,default); +insert into t1 values (NULL,NULL,default); +insert into t1 values (1,NULL,default); +select * from t1; +a b c +1 1 1 +NULL NULL 1 +1 NULL 0 +drop table t1; +set sql_warnings = 0; +# = +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a=b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a=b) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('a','b',default); +insert into t1 values ('a','a',default); +select * from t1; +a b c +a b 0 +a a 1 +drop table t1; +set sql_warnings = 0; +# >= +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a >= b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a >= b) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('a','b',default); +insert into t1 values ('a','a',default); +select * from t1; +a b c +a b 0 +a a 1 +drop table t1; +set sql_warnings = 0; +# > +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a > b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a > b) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('a','b',default); +insert into t1 values ('a','a',default); +select * from t1; +a b c +a b 0 +a a 0 +drop table t1; +set sql_warnings = 0; +# IS NOT NULL +set sql_warnings = 1; +create table t1 (a int, b bool as (a is not null)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` tinyint(1) AS (a is not null) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (NULL,default); +select * from t1; +a b +1 1 +NULL 0 +drop table t1; +set sql_warnings = 0; +# IS NULL +set sql_warnings = 1; +create table t1 (a int, b bool as (a is null)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` tinyint(1) AS (a is null) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (NULL,default); +select * from t1; +a b +1 0 +NULL 1 +drop table t1; +set sql_warnings = 0; +# << +set sql_warnings = 1; +create table t1 (a int, b int as (a << 2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a << 2) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (3,default); +select * from t1; +a b +1 4 +3 12 +drop table t1; +set sql_warnings = 0; +# <= +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a <= b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a <= b) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('b','a',default); +insert into t1 values ('b','b',default); +insert into t1 values ('b','c',default); +select * from t1; +a b c +b a 0 +b b 1 +b c 1 +drop table t1; +set sql_warnings = 0; +# < +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a < b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a < b) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('b','a',default); +insert into t1 values ('b','b',default); +insert into t1 values ('b','c',default); +select * from t1; +a b c +b a 0 +b b 0 +b c 1 +drop table t1; +set sql_warnings = 0; +# NOT BETWEEN ... AND ... +set sql_warnings = 1; +create table t1 (a int, b bool as (a not between 0 and 2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` tinyint(1) AS (a not between 0 and 2) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (-1,default); +insert into t1 values (1,default); +select * from t1; +a b +-1 1 +1 0 +drop table t1; +set sql_warnings = 0; +# <> +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a <> b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a <> b) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('b','a',default); +insert into t1 values ('b','b',default); +insert into t1 values ('b','c',default); +select * from t1; +a b c +b a 1 +b b 0 +b c 1 +drop table t1; +set sql_warnings = 0; +# != +set sql_warnings = 1; +create table t1 (a varchar(10), b varchar(10), c bool as (a != b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) DEFAULT NULL, + `b` varchar(10) DEFAULT NULL, + `c` tinyint(1) AS (a != b) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('b','a',default); +insert into t1 values ('b','b',default); +insert into t1 values ('b','c',default); +select * from t1; +a b c +b a 1 +b b 0 +b c 1 +drop table t1; +set sql_warnings = 0; +# ||, OR +set sql_warnings = 1; +create table t1 (a int, b int as (a>5 || a<3)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a>5 || a<3) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (4,default); +select * from t1; +a b +1 1 +4 0 +drop table t1; +set sql_warnings = 0; +# >> +set sql_warnings = 1; +create table t1 (a int, b int as (a >> 2)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a >> 2) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (8,default); +insert into t1 values (3,default); +select * from t1; +a b +8 2 +3 0 +drop table t1; +set sql_warnings = 0; +# XOR +set sql_warnings = 1; +create table t1 (a int, b int as (a xor 5)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a xor 5) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (0,default); +insert into t1 values (1,default); +insert into t1 values (2,default); +select * from t1; +a b +0 1 +1 0 +2 0 +drop table t1; +set sql_warnings = 0; +# +# DATE AND TIME FUNCTIONS +# +# ADDDATE() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (adddate(a,interval 1 month))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (adddate(a,interval 1 month)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-09-30 00:00:00 +drop table t1; +set sql_warnings = 0; +# ADDTIME() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (addtime(a,'02:00:00'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (addtime(a,'02:00:00')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-08-31 02:00:00 +drop table t1; +set sql_warnings = 0; +# CONVERT_TZ() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (convert_tz(a,'MET','UTC'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (convert_tz(a,'MET','UTC')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-08-30 22:00:00 +drop table t1; +set sql_warnings = 0; +# DATE_ADD() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (date_add(a,interval 1 month))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (date_add(a,interval 1 month)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-09-30 00:00:00 +drop table t1; +set sql_warnings = 0; +# DATE_FORMAT() +set sql_warnings = 1; +create table t1 (a datetime, b varchar(64) as (date_format(a,'%W %M %D'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` varchar(64) AS (date_format(a,'%W %M %D')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 Sunday August 31st +drop table t1; +set sql_warnings = 0; +# DATE_SUB() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (date_sub(a,interval 1 month))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (date_sub(a,interval 1 month)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-07-31 00:00:00 +drop table t1; +set sql_warnings = 0; +# DATE() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (date(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (date(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31 02:00:00',default); +select * from t1; +a b +2008-08-31 02:00:00 2008-08-31 00:00:00 +drop table t1; +set sql_warnings = 0; +# DATEDIFF() +set sql_warnings = 1; +create table t1 (a datetime, b long as (datediff(a,'2000-01-01'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` mediumtext AS (datediff(a,'2000-01-01')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 3165 +drop table t1; +set sql_warnings = 0; +# DAY() +set sql_warnings = 1; +create table t1 (a datetime, b int as (day(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (day(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 31 +drop table t1; +set sql_warnings = 0; +# DAYNAME() +set sql_warnings = 1; +create table t1 (a datetime, b varchar(10) as (dayname(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` varchar(10) AS (dayname(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 Sunday +drop table t1; +set sql_warnings = 0; +# DAYOFMONTH() +set sql_warnings = 1; +create table t1 (a datetime, b int as (dayofmonth(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (dayofmonth(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 31 +drop table t1; +set sql_warnings = 0; +# DAYOFWEEK() +set sql_warnings = 1; +create table t1 (a datetime, b int as (dayofweek(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (dayofweek(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 1 +drop table t1; +set sql_warnings = 0; +# DAYOFYEAR() +set sql_warnings = 1; +create table t1 (a datetime, b int as (dayofyear(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (dayofyear(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 244 +drop table t1; +set sql_warnings = 0; +# EXTRACT +set sql_warnings = 1; +create table t1 (a datetime, b int as (extract(year from a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (extract(year from a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008 +drop table t1; +set sql_warnings = 0; +# FROM_DAYS() +set sql_warnings = 1; +create table t1 (a long, b datetime as (from_days(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` mediumtext, + `b` datetime AS (from_days(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (730669,default); +select * from t1; +a b +730669 2000-07-03 00:00:00 +drop table t1; +set sql_warnings = 0; +# FROM_UNIXTIME() +set time_zone='UTC'; +set sql_warnings = 1; +create table t1 (a long, b datetime as (from_unixtime(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` mediumtext, + `b` datetime AS (from_unixtime(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1196440219,default); +select * from t1; +a b +1196440219 2007-11-30 16:30:19 +drop table t1; +set sql_warnings = 0; +# GET_FORMAT() +set sql_warnings = 1; +create table t1 (a datetime, b varchar(32) as (date_format(a,get_format(DATE,'EUR')))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` varchar(32) AS (date_format(a,get_format(DATE,'EUR'))) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 31.08.2008 +drop table t1; +set sql_warnings = 0; +# HOUR() +set sql_warnings = 1; +create table t1 (a time, b long as (hour(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` time DEFAULT NULL, + `b` mediumtext AS (hour(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('10:05:03',default); +select * from t1; +a b +10:05:03 10 +drop table t1; +set sql_warnings = 0; +# LAST_DAY() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (last_day(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (last_day(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2003-02-05',default); +insert into t1 values ('2003-02-32',default); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +select * from t1; +a b +2003-02-05 00:00:00 2003-02-28 00:00:00 +0000-00-00 00:00:00 NULL +drop table t1; +set sql_warnings = 0; +# MAKEDATE() +set sql_warnings = 1; +create table t1 (a int, b datetime as (makedate(a,1))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` datetime AS (makedate(a,1)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (2001,default); +select * from t1; +a b +2001 2001-01-01 00:00:00 +drop table t1; +set sql_warnings = 0; +# MAKETIME() +set sql_warnings = 1; +create table t1 (a int, b time as (maketime(a,1,3))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` time AS (maketime(a,1,3)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (12,default); +select * from t1; +a b +12 12:01:03 +drop table t1; +set sql_warnings = 0; +# MICROSECOND() +set sql_warnings = 1; +create table t1 (a datetime, b long as (microsecond(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` mediumtext AS (microsecond(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2009-12-31 12:00:00.123456',default); +insert into t1 values ('2009-12-31 23:59:59.000010',default); +select * from t1; +a b +2009-12-31 12:00:00 0 +2009-12-31 23:59:59 0 +drop table t1; +set sql_warnings = 0; +# MINUTE() +set sql_warnings = 1; +create table t1 (a datetime, b int as (minute(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (minute(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2009-12-31 23:59:59.000010',default); +select * from t1; +a b +2009-12-31 23:59:59 59 +drop table t1; +set sql_warnings = 0; +# MONTH() +set sql_warnings = 1; +create table t1 (a datetime, b int as (month(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (month(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2009-12-31 23:59:59.000010',default); +select * from t1; +a b +2009-12-31 23:59:59 12 +drop table t1; +set sql_warnings = 0; +# MONTHNAME() +set sql_warnings = 1; +create table t1 (a datetime, b varchar(16) as (monthname(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` varchar(16) AS (monthname(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2009-12-31 23:59:59.000010',default); +select * from t1; +a b +2009-12-31 23:59:59 December +drop table t1; +set sql_warnings = 0; +# PERIOD_ADD() +set sql_warnings = 1; +create table t1 (a int, b int as (period_add(a,2))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (period_add(a,2)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (200801,default); +select * from t1; +a b +200801 200803 +drop table t1; +set sql_warnings = 0; +# PERIOD_DIFF() +set sql_warnings = 1; +create table t1 (a int, b int, c int as (period_diff(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) AS (period_diff(a,b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (200802,200703,default); +select * from t1; +a b c +200802 200703 11 +drop table t1; +set sql_warnings = 0; +# QUARTER() +set sql_warnings = 1; +create table t1 (a datetime, b int as (quarter(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (quarter(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 3 +drop table t1; +set sql_warnings = 0; +# SEC_TO_TIME() +set sql_warnings = 1; +create table t1 (a long, b time as (sec_to_time(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` mediumtext, + `b` time AS (sec_to_time(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (2378,default); +select * from t1; +a b +2378 00:39:38 +drop table t1; +set sql_warnings = 0; +# SECOND() +set sql_warnings = 1; +create table t1 (a datetime, b int as (second(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (second(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('10:05:03',default); +select * from t1; +a b +2010-05-03 00:00:00 0 +drop table t1; +set sql_warnings = 0; +# STR_TO_DATE() +set sql_warnings = 1; +create table t1 (a varchar(64), b datetime as (str_to_date(a,'%m/%d/%Y'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(64) DEFAULT NULL, + `b` datetime AS (str_to_date(a,'%m/%d/%Y')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('04/30/2004',default); +select * from t1; +a b +04/30/2004 2004-04-30 00:00:00 +drop table t1; +set sql_warnings = 0; +# SUBDATE() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (subdate(a,interval 1 month))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (subdate(a,interval 1 month)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-07-31 00:00:00 +drop table t1; +set sql_warnings = 0; +# SUBTIME() +set sql_warnings = 1; +create table t1 (a datetime, b datetime as (subtime(a,'02:00:00'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime AS (subtime(a,'02:00:00')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31',default); +select * from t1; +a b +2008-08-31 00:00:00 2008-08-30 22:00:00 +drop table t1; +set sql_warnings = 0; +# TIME_FORMAT() +set sql_warnings = 1; +create table t1 (a datetime, b varchar(32) as (time_format(a,'%r'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` varchar(32) AS (time_format(a,'%r')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31 02:03:04',default); +select * from t1; +a b +2008-08-31 02:03:04 02:03:04 AM +drop table t1; +set sql_warnings = 0; +# TIME_TO_SEC() +set sql_warnings = 1; +create table t1 (a time, b long as (time_to_sec(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` time DEFAULT NULL, + `b` mediumtext AS (time_to_sec(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('22:23:00',default); +select * from t1; +a b +22:23:00 80580 +drop table t1; +set sql_warnings = 0; +# TIME() +set sql_warnings = 1; +create table t1 (a datetime, b time as (time(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` time AS (time(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-08-31 02:03:04',default); +select * from t1; +a b +2008-08-31 02:03:04 02:03:04 +drop table t1; +set sql_warnings = 0; +# TIMEDIFF() +set sql_warnings = 1; +create table t1 (a datetime, b datetime, c long as (timediff(a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` datetime DEFAULT NULL, + `c` mediumtext AS (timediff(a,b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-12-31 23:59:59.000001','2008-12-30 01:01:01.000002',default); +select * from t1; +a b c +2008-12-31 23:59:59 2008-12-30 01:01:01 46:58:58 +drop table t1; +set sql_warnings = 0; +# TIMESTAMP() +set sql_warnings = 1; +create table t1 (a datetime, b timestamp as (timestamp(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` timestamp AS (timestamp(a)) VIRTUAL NULL ON UPDATE CURRENT_TIMESTAMP +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-12-31',default); +select * from t1; +a b +2008-12-31 00:00:00 2008-12-31 00:00:00 +drop table t1; +set sql_warnings = 0; +# TIMESTAMPADD() +set sql_warnings = 1; +create table t1 (a datetime, b timestamp as (timestampadd(minute,1,a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` timestamp AS (timestampadd(minute,1,a)) VIRTUAL NULL ON UPDATE CURRENT_TIMESTAMP +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2003-01-02',default); +select * from t1; +a b +2003-01-02 00:00:00 2003-01-02 00:01:00 +drop table t1; +set sql_warnings = 0; +# TIMESTAMPDIFF() +set sql_warnings = 1; +create table t1 (a timestamp, b timestamp, c long as (timestampdiff(MONTH, a,b))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `b` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `c` mediumtext AS (timestampdiff(MONTH, a,b)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2003-02-01','2003-05-01',default); +select * from t1; +a b c +2003-02-01 00:00:00 2003-05-01 00:00:00 3 +drop table t1; +set sql_warnings = 0; +# TO_DAYS() +set sql_warnings = 1; +create table t1 (a datetime, b long as (to_days(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` mediumtext AS (to_days(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2007-10-07',default); +select * from t1; +a b +2007-10-07 00:00:00 733321 +drop table t1; +set sql_warnings = 0; +# WEEK() +set sql_warnings = 1; +create table t1 (a datetime, b int as (week(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (week(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-09-01',default); +select * from t1; +a b +2008-09-01 00:00:00 35 +drop table t1; +set sql_warnings = 0; +# WEEKDAY() +set sql_warnings = 1; +create table t1 (a datetime, b int as (weekday(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (weekday(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-09-01',default); +select * from t1; +a b +2008-09-01 00:00:00 0 +drop table t1; +set sql_warnings = 0; +# WEEKOFYEAR() +set sql_warnings = 1; +create table t1 (a datetime, b int as (weekofyear(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (weekofyear(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-09-01',default); +select * from t1; +a b +2008-09-01 00:00:00 36 +drop table t1; +set sql_warnings = 0; +# YEAR() +set sql_warnings = 1; +create table t1 (a datetime, b int as (year(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (year(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-09-01',default); +select * from t1; +a b +2008-09-01 00:00:00 2008 +drop table t1; +set sql_warnings = 0; +# YEARWEEK() +set sql_warnings = 1; +create table t1 (a datetime, b int as (yearweek(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime DEFAULT NULL, + `b` int(11) AS (yearweek(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('2008-09-01',default); +select * from t1; +a b +2008-09-01 00:00:00 200835 +drop table t1; +set sql_warnings = 0; +# +# FULL TEXT SEARCH FUNCTIONS +# +# None. +# +# CAST FUNCTIONS AND OPERATORS +# +# CAST() +set sql_warnings = 1; +create table t1 (a int, b long as (cast(a as unsigned))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` mediumtext AS (cast(a as unsigned)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (-1,default); +select * from t1; +a b +1 1 +-1 18446744073709551615 +drop table t1; +set sql_warnings = 0; +# Convert() +set sql_warnings = 1; +create table t1 (a int, b long as (convert(a,unsigned))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` mediumtext AS (convert(a,unsigned)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (1,default); +insert into t1 values (-1,default); +select * from t1; +a b +1 1 +-1 18446744073709551615 +drop table t1; +set sql_warnings = 0; +# +# XML FUNCTIONS +# +# None. +# +# OTHER FUNCTIONS +# +# AES_DECRYPT(), AES_ENCRYPT() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (aes_encrypt(aes_decrypt(a,'adf'),'adf'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (aes_encrypt(aes_decrypt(a,'adf'),'adf')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL NULL +drop table t1; +set sql_warnings = 0; +# BIT_COUNT() +set sql_warnings = 1; +create table t1 (a int, b int as (bit_count(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (bit_count(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (5,default); +select * from t1; +a b +5 2 +drop table t1; +set sql_warnings = 0; +# CHARSET() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (charset(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (charset(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('abc',default); +select * from t1; +a b +abc latin1 +drop table t1; +set sql_warnings = 0; +# COERCIBILITY() +set sql_warnings = 1; +create table t1 (a varchar(1024), b int as (coercibility(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` int(11) AS (coercibility(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('abc',default); +select * from t1; +a b +abc 2 +drop table t1; +set sql_warnings = 0; +# COLLATION() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (collation(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (collation(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('abc',default); +select * from t1; +a b +abc latin1_swedish_ci +drop table t1; +set sql_warnings = 0; +# COMPRESS(), UNCOMPRESS() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (uncompress(compress(a)))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (uncompress(compress(a))) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL MySQL +drop table t1; +set sql_warnings = 0; +# ENCODE(), DECODE() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (decode(encode(a,'abc'),'abc'))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (decode(encode(a,'abc'),'abc')) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('MySQL',default); +select * from t1; +a b +MySQL MySQL +drop table t1; +set sql_warnings = 0; +# DEFAULT() +set sql_warnings = 1; +create table t1 (a varchar(1024) default 'aaa', b varchar(1024) as (ifnull(a,default(a)))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT 'aaa', + `b` varchar(1024) AS (ifnull(a,default(a))) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('any value',default); +select * from t1; +a b +any value any value +drop table t1; +set sql_warnings = 0; +# INET_ATON(), INET_NTOA() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (inet_ntoa(inet_aton(a)))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (inet_ntoa(inet_aton(a))) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('127.0.0.1',default); +select * from t1; +a b +127.0.0.1 127.0.0.1 +drop table t1; +set sql_warnings = 0; +# MD5() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varbinary(32) as (md5(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varbinary(32) AS (md5(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('testing',default); +select * from t1; +a b +testing ae2b1fca515949e5d54fb22b8ed95575 +drop table t1; +set sql_warnings = 0; +# OLD_PASSWORD() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (old_password(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (old_password(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('badpwd',default); +select * from t1; +a b +badpwd 7f84554057dd964b +drop table t1; +set sql_warnings = 0; +# PASSWORD() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (password(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (password(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('badpwd',default); +select * from t1; +a b +badpwd *AAB3E285149C0135D51A520E1940DD3263DC008C +drop table t1; +set sql_warnings = 0; +# SHA1() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (sha1(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (sha1(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('abc',default); +select * from t1; +a b +abc a9993e364706816aba3e25717850c26c9cd0d89d +drop table t1; +set sql_warnings = 0; +# SHA() +set sql_warnings = 1; +create table t1 (a varchar(1024), b varchar(1024) as (sha(a))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1024) DEFAULT NULL, + `b` varchar(1024) AS (sha(a)) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('abc',default); +select * from t1; +a b +abc a9993e364706816aba3e25717850c26c9cd0d89d +drop table t1; +set sql_warnings = 0; +# UNCOMPRESSED_LENGTH() +set sql_warnings = 1; +create table t1 (a char, b varchar(1024) as (uncompressed_length(compress(repeat(a,30))))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(1) DEFAULT NULL, + `b` varchar(1024) AS (uncompressed_length(compress(repeat(a,30)))) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('a',default); +select * from t1; +a b +a 30 +drop table t1; +set sql_warnings = 0; diff --git a/mysql-test/suite/vcol/r/vcol_syntax.result b/mysql-test/suite/vcol/r/vcol_syntax.result new file mode 100644 index 00000000000..8515d790359 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_syntax.result @@ -0,0 +1,52 @@ +drop table if exists t1; +set @OLD_SQL_MODE=@@SESSION.SQL_MODE; +create table t1 (a int, b int generated always as (a+1)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a+1) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a int, b int as (a+1) virtual); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a+1) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a int, b int generated always as (a+1) persistent); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) AS (a+1) PERSISTENT +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set session sql_mode='ORACLE'; +create table t1 (a int, b int as (a+1)); +show create table t1; +Table Create Table +t1 CREATE TABLE "t1" ( + "a" int(11) DEFAULT NULL, + "b" int(11) AS (a+1) VIRTUAL +) +drop table t1; +create table t1 (a int, b int generated always as (a+1) virtual); +show create table t1; +Table Create Table +t1 CREATE TABLE "t1" ( + "a" int(11) DEFAULT NULL, + "b" int(11) AS (a+1) VIRTUAL +) +drop table t1; +create table t1 (a int, b int as (a+1) persistent); +show create table t1; +Table Create Table +t1 CREATE TABLE "t1" ( + "a" int(11) DEFAULT NULL, + "b" int(11) AS (a+1) PERSISTENT +) +drop table t1; +set session sql_mode=@OLD_SQL_MODE; diff --git a/mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result b/mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result new file mode 100644 index 00000000000..e903bc4eafd --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result @@ -0,0 +1,87 @@ +SET @@session.storage_engine = 'InnoDB'; +create table t1 (a int, +b int as (a/10), +c int as (a/10) persistent); +create table t2 (a timestamp); +create trigger trg1 before insert on t1 for each row +begin +if (new.b < 10) then +set new.a:= 100; +set new.b:= 9; +set new.c:= 9; +end if; +if (new.c > 50) then +set new.a:= 500; +end if; +end| +create trigger trg2 after insert on t1 for each row +begin +if (new.b >= 60) then +insert into t2 values (now()); +end if; +end| +create function f1() +returns int +begin +declare sum1 int default '0'; +declare cur1 cursor for select sum(b) from t1; +open cur1; +fetch cur1 into sum1; +close cur1; +return sum1; +end| +set sql_warnings = 1; +insert into t1 (a) values (200); +select * from t1; +a b c +200 20 20 +select * from t2; +a +insert into t1 (a) values (10); +select * from t1; +a b c +200 20 20 +100 10 10 +select * from t2; +a +insert into t1 (a) values (600); +select * from t1; +a b c +200 20 20 +100 10 10 +500 50 50 +select * from t2; +a +select f1(); +f1() +80 +set sql_warnings = 0; +drop trigger trg1; +drop trigger trg2; +drop table t2; +create procedure p1() +begin +declare i int default '0'; +create table t2 like t1; +insert into t2 (a) values (100), (200); +begin +declare cur1 cursor for select sum(c) from t2; +open cur1; +fetch cur1 into i; +close cur1; +if (i=30) then +insert into t1 values (300,default,default); +end if; +end; +end| +delete from t1; +call p1(); +select * from t2; +a b c +100 10 10 +200 20 20 +select * from t1; +a b c +300 30 30 +drop table t1,t2; +drop procedure p1; diff --git a/mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result b/mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result new file mode 100644 index 00000000000..c2a66d656b5 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result @@ -0,0 +1,87 @@ +SET @@session.storage_engine = 'MyISAM'; +create table t1 (a int, +b int as (a/10), +c int as (a/10) persistent); +create table t2 (a timestamp); +create trigger trg1 before insert on t1 for each row +begin +if (new.b < 10) then +set new.a:= 100; +set new.b:= 9; +set new.c:= 9; +end if; +if (new.c > 50) then +set new.a:= 500; +end if; +end| +create trigger trg2 after insert on t1 for each row +begin +if (new.b >= 60) then +insert into t2 values (now()); +end if; +end| +create function f1() +returns int +begin +declare sum1 int default '0'; +declare cur1 cursor for select sum(b) from t1; +open cur1; +fetch cur1 into sum1; +close cur1; +return sum1; +end| +set sql_warnings = 1; +insert into t1 (a) values (200); +select * from t1; +a b c +200 20 20 +select * from t2; +a +insert into t1 (a) values (10); +select * from t1; +a b c +200 20 20 +100 10 10 +select * from t2; +a +insert into t1 (a) values (600); +select * from t1; +a b c +200 20 20 +100 10 10 +500 50 50 +select * from t2; +a +select f1(); +f1() +80 +set sql_warnings = 0; +drop trigger trg1; +drop trigger trg2; +drop table t2; +create procedure p1() +begin +declare i int default '0'; +create table t2 like t1; +insert into t2 (a) values (100), (200); +begin +declare cur1 cursor for select sum(c) from t2; +open cur1; +fetch cur1 into i; +close cur1; +if (i=30) then +insert into t1 values (300,default,default); +end if; +end; +end| +delete from t1; +call p1(); +select * from t2; +a b c +100 10 10 +200 20 20 +select * from t1; +a b c +300 30 30 +drop table t1,t2; +drop procedure p1; diff --git a/mysql-test/suite/vcol/r/vcol_view_innodb.result b/mysql-test/suite/vcol/r/vcol_view_innodb.result new file mode 100644 index 00000000000..ae834722606 --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_view_innodb.result @@ -0,0 +1,276 @@ +SET @@session.storage_engine = 'InnoDB'; +create table t1 (a int not null, +b int as (-a), +c int as (-a) persistent); +insert into t1 (a) values (1), (1), (2), (2), (3); +create view v1 (d,e) as select abs(b), abs(c) from t1; +select d,e from v1; +d e +1 1 +1 1 +2 2 +2 2 +3 3 +select is_updatable from information_schema.views where table_name='v1'; +is_updatable +NO +explain extended select d,e from v1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 +Warnings: +Note 1003 select abs(`test`.`t1`.`b`) AS `d`,abs(`test`.`t1`.`c`) AS `e` from `test`.`t1` +create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1; +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select abs(`t1`.`b`) AS `d`,abs(`t1`.`c`) AS `e` from `t1` latin1 latin1_swedish_ci +select d,e from v2; +d e +1 1 +1 1 +2 2 +2 2 +3 3 +explain extended select d,e from v2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 100.00 +2 DERIVED t1 ALL NULL NULL NULL NULL 5 100.00 +Warnings: +Note 1003 select `v2`.`d` AS `d`,`v2`.`e` AS `e` from `test`.`v2` +create view v3 (d,e) as select d*2, e*2 from v1; +select * from v3; +d e +2 2 +2 2 +4 4 +4 4 +6 6 +explain extended select * from v3; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 +Warnings: +Note 1003 select (abs(`test`.`t1`.`b`) * 2) AS `d`,(abs(`test`.`t1`.`c`) * 2) AS `e` from `test`.`t1` +drop view v1,v2,v3; +drop table t1; +create table t1 (a int not null, +b int as (-a), +c int as (-a) persistent); +insert into t1 (a) values (1), (2), (3), (1), (2), (3); +create view v1 as select distinct b from t1; +select * from v1; +b +-1 +-2 +-3 +explain select * from v1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 +2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +3 -3 -3 +1 -1 -1 +2 -2 -2 +3 -3 -3 +drop view v1; +create view v1 as select distinct c from t1; +select * from v1; +c +-1 +-2 +-3 +explain select * from v1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 +2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +3 -3 -3 +1 -1 -1 +2 -2 -2 +3 -3 -3 +drop view v1; +drop table t1; +create table t1 (a int not null, +b int as (-a), +c int as (-a) persistent); +insert into t1 (a) values (1), (2), (3), (4); +create view v1 as select b+1 from t1 order by 1 desc limit 2; +select * from v1; +b+1 +0 +-1 +explain select * from v1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort +drop view v1; +create view v1 as select c+1 from t1 order by 1 desc limit 2; +select * from v1; +c+1 +0 +-1 +explain select * from v1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort +drop view v1; +drop table t1; +create table t1 (a int, +b int, +c int as (-a), +d int as (-a) persistent, +primary key(a)); +insert into t1 (a,b) values (10,2), (20,3), (30,4), (40,5), (50,10); +create view v1 (a,e,f,g) as select a, b+1,c+1,d+1 from t1; +update v1 set a=a+e; +select * from v1; +a e f g +13 3 -12 -12 +24 4 -23 -23 +35 5 -34 -34 +46 6 -45 -45 +61 11 -60 -60 +select * from t1; +a b c d +13 2 -13 -13 +24 3 -24 -24 +35 4 -35 -35 +46 5 -46 -46 +61 10 -61 -61 +delete from v1; +select * from v1; +a e f g +select * from t1; +a b c d +insert into v1 (a,e) values (60,15); +ERROR HY000: The target table v1 of the INSERT is not insertable-into +drop table t1; +drop view v1; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent, +primary key(a)); +insert into t1 (a) values (1), (2), (3); +create view v1 (x,y,z) as select a,b,c from t1 where b < -1; +select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.b= v1.y); +a x y z +1 NULL NULL NULL +2 2 -2 -2 +3 3 -3 -3 +drop view v1; +create view v1 (x,y,z) as select a,b,c from t1 where c < -1; +select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.c= v1.z); +a x y z +1 NULL NULL NULL +2 2 -2 -2 +3 3 -3 -3 +drop view v1; +drop table t1; +create table t1 (a1 int, +b1 int as (-a1), +c1 int as (-a1) persistent); +create table t2 (a2 int, +b2 int as (-a2), +c2 int as (-a2) persistent); +insert into t1 (a1) values (1), (2); +insert into t2 (a2) values (2), (3); +create view v1 as select * from t1,t2 union all select * from t1,t2; +select * from v1; +a1 b1 c1 a2 b2 c2 +1 -1 -1 2 -2 -2 +2 -2 -2 2 -2 -2 +1 -1 -1 3 -3 -3 +2 -2 -2 3 -3 -3 +1 -1 -1 2 -2 -2 +2 -2 -2 2 -2 -2 +1 -1 -1 3 -3 -3 +2 -2 -2 3 -3 -3 +drop view v1; +drop table t1, t2; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent); +create table t2 like t1; +create view v1 as select a,b,c from t1; +create view v2 as select a,b,c from t2 where b in (select b from v1); +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a`,`t2`.`b` AS `b`,`t2`.`c` AS `c` from `t2` where `t2`.`b` in (select `v1`.`b` from `v1`) latin1 latin1_swedish_ci +drop view v2, v1; +drop table t1, t2; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent); +insert into t1 (a) values (1),(1),(2),(2),(3),(3); +create view v1 as select b from t1; +select distinct b from v1; +b +-1 +-2 +-3 +select distinct b from v1 limit 2; +b +-1 +-2 +select distinct b from t1 limit 2; +b +-1 +-2 +prepare stmt1 from "select distinct b from v1 limit 2"; +execute stmt1; +b +-1 +-2 +execute stmt1; +b +-1 +-2 +deallocate prepare stmt1; +drop view v1; +create view v1 as select c from t1; +select distinct c from v1; +c +-1 +-2 +-3 +select distinct c from v1 limit 2; +c +-1 +-2 +select distinct c from t1 limit 2; +c +-1 +-2 +prepare stmt1 from "select distinct c from v1 limit 2"; +execute stmt1; +c +-1 +-2 +execute stmt1; +c +-1 +-2 +deallocate prepare stmt1; +drop view v1; +drop table t1; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent); +create view v1 as select * from t1 where b > -2 && c >-2 with check option; +insert into v1 (a) values (1); +insert into v1 (a) values (3); +ERROR HY000: CHECK OPTION failed 'test.v1' +insert ignore into v1 (a) values (2),(3),(0); +Warnings: +Error 1369 CHECK OPTION failed 'test.v1' +Error 1369 CHECK OPTION failed 'test.v1' +select * from t1; +a b c +1 -1 -1 +0 0 0 +drop view v1; +drop table t1; diff --git a/mysql-test/suite/vcol/r/vcol_view_myisam.result b/mysql-test/suite/vcol/r/vcol_view_myisam.result new file mode 100644 index 00000000000..bd5999792ff --- /dev/null +++ b/mysql-test/suite/vcol/r/vcol_view_myisam.result @@ -0,0 +1,276 @@ +SET @@session.storage_engine = 'MyISAM'; +create table t1 (a int not null, +b int as (-a), +c int as (-a) persistent); +insert into t1 (a) values (1), (1), (2), (2), (3); +create view v1 (d,e) as select abs(b), abs(c) from t1; +select d,e from v1; +d e +1 1 +1 1 +2 2 +2 2 +3 3 +select is_updatable from information_schema.views where table_name='v1'; +is_updatable +NO +explain extended select d,e from v1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 +Warnings: +Note 1003 select abs(`test`.`t1`.`b`) AS `d`,abs(`test`.`t1`.`c`) AS `e` from `test`.`t1` +create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1; +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select abs(`t1`.`b`) AS `d`,abs(`t1`.`c`) AS `e` from `t1` latin1 latin1_swedish_ci +select d,e from v2; +d e +1 1 +1 1 +2 2 +2 2 +3 3 +explain extended select d,e from v2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 100.00 +2 DERIVED t1 ALL NULL NULL NULL NULL 5 100.00 +Warnings: +Note 1003 select `v2`.`d` AS `d`,`v2`.`e` AS `e` from `test`.`v2` +create view v3 (d,e) as select d*2, e*2 from v1; +select * from v3; +d e +2 2 +2 2 +4 4 +4 4 +6 6 +explain extended select * from v3; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 +Warnings: +Note 1003 select (abs(`test`.`t1`.`b`) * 2) AS `d`,(abs(`test`.`t1`.`c`) * 2) AS `e` from `test`.`t1` +drop view v1,v2,v3; +drop table t1; +create table t1 (a int not null, +b int as (-a), +c int as (-a) persistent); +insert into t1 (a) values (1), (2), (3), (1), (2), (3); +create view v1 as select distinct b from t1; +select * from v1; +b +-1 +-2 +-3 +explain select * from v1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 +2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +3 -3 -3 +1 -1 -1 +2 -2 -2 +3 -3 -3 +drop view v1; +create view v1 as select distinct c from t1; +select * from v1; +c +-1 +-2 +-3 +explain select * from v1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 +2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary +select * from t1; +a b c +1 -1 -1 +2 -2 -2 +3 -3 -3 +1 -1 -1 +2 -2 -2 +3 -3 -3 +drop view v1; +drop table t1; +create table t1 (a int not null, +b int as (-a), +c int as (-a) persistent); +insert into t1 (a) values (1), (2), (3), (4); +create view v1 as select b+1 from t1 order by 1 desc limit 2; +select * from v1; +b+1 +0 +-1 +explain select * from v1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort +drop view v1; +create view v1 as select c+1 from t1 order by 1 desc limit 2; +select * from v1; +c+1 +0 +-1 +explain select * from v1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort +drop view v1; +drop table t1; +create table t1 (a int, +b int, +c int as (-a), +d int as (-a) persistent, +primary key(a)); +insert into t1 (a,b) values (10,2), (20,3), (30,4), (40,5), (50,10); +create view v1 (a,e,f,g) as select a, b+1,c+1,d+1 from t1; +update v1 set a=a+e; +select * from v1; +a e f g +13 3 -12 -12 +24 4 -23 -23 +35 5 -34 -34 +46 6 -45 -45 +61 11 -60 -60 +select * from t1; +a b c d +13 2 -13 -13 +24 3 -24 -24 +35 4 -35 -35 +46 5 -46 -46 +61 10 -61 -61 +delete from v1; +select * from v1; +a e f g +select * from t1; +a b c d +insert into v1 (a,e) values (60,15); +ERROR HY000: The target table v1 of the INSERT is not insertable-into +drop table t1; +drop view v1; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent, +primary key(a)); +insert into t1 (a) values (1), (2), (3); +create view v1 (x,y,z) as select a,b,c from t1 where b < -1; +select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.b= v1.y); +a x y z +1 NULL NULL NULL +2 2 -2 -2 +3 3 -3 -3 +drop view v1; +create view v1 (x,y,z) as select a,b,c from t1 where c < -1; +select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.c= v1.z); +a x y z +1 NULL NULL NULL +2 2 -2 -2 +3 3 -3 -3 +drop view v1; +drop table t1; +create table t1 (a1 int, +b1 int as (-a1), +c1 int as (-a1) persistent); +create table t2 (a2 int, +b2 int as (-a2), +c2 int as (-a2) persistent); +insert into t1 (a1) values (1), (2); +insert into t2 (a2) values (2), (3); +create view v1 as select * from t1,t2 union all select * from t1,t2; +select * from v1; +a1 b1 c1 a2 b2 c2 +1 -1 -1 2 -2 -2 +2 -2 -2 2 -2 -2 +1 -1 -1 3 -3 -3 +2 -2 -2 3 -3 -3 +1 -1 -1 2 -2 -2 +2 -2 -2 2 -2 -2 +1 -1 -1 3 -3 -3 +2 -2 -2 3 -3 -3 +drop view v1; +drop table t1, t2; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent); +create table t2 like t1; +create view v1 as select a,b,c from t1; +create view v2 as select a,b,c from t2 where b in (select b from v1); +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a`,`t2`.`b` AS `b`,`t2`.`c` AS `c` from `t2` where `t2`.`b` in (select `v1`.`b` from `v1`) latin1 latin1_swedish_ci +drop view v2, v1; +drop table t1, t2; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent); +insert into t1 (a) values (1),(1),(2),(2),(3),(3); +create view v1 as select b from t1; +select distinct b from v1; +b +-1 +-2 +-3 +select distinct b from v1 limit 2; +b +-1 +-2 +select distinct b from t1 limit 2; +b +-1 +-2 +prepare stmt1 from "select distinct b from v1 limit 2"; +execute stmt1; +b +-1 +-2 +execute stmt1; +b +-1 +-2 +deallocate prepare stmt1; +drop view v1; +create view v1 as select c from t1; +select distinct c from v1; +c +-1 +-2 +-3 +select distinct c from v1 limit 2; +c +-1 +-2 +select distinct c from t1 limit 2; +c +-1 +-2 +prepare stmt1 from "select distinct c from v1 limit 2"; +execute stmt1; +c +-1 +-2 +execute stmt1; +c +-1 +-2 +deallocate prepare stmt1; +drop view v1; +drop table t1; +create table t1 (a int, +b int as (-a), +c int as (-a) persistent); +create view v1 as select * from t1 where b > -2 && c >-2 with check option; +insert into v1 (a) values (1); +insert into v1 (a) values (3); +ERROR HY000: CHECK OPTION failed 'test.v1' +insert ignore into v1 (a) values (2),(3),(0); +Warnings: +Error 1369 CHECK OPTION failed 'test.v1' +Error 1369 CHECK OPTION failed 'test.v1' +select * from t1; +a b c +1 -1 -1 +0 0 0 +drop view v1; +drop table t1; diff --git a/mysql-test/suite/vcol/t/rpl_vcol.test b/mysql-test/suite/vcol/t/rpl_vcol.test new file mode 100644 index 00000000000..2ac31f5ba35 --- /dev/null +++ b/mysql-test/suite/vcol/t/rpl_vcol.test @@ -0,0 +1,69 @@ +################################################################################ +# t/vcol_rpl.test # +# # +# Purpose: # +# Test replication of tables with virtual columns. # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_innodb.inc +SET @@session.storage_engine = 'InnoDB'; + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source include/master-slave.inc + +connection master; +create table t1 (a int, b int as (a+1)); +show create table t1; +insert into t1 values (1,default); +insert into t1 values (2,default); +select * from t1; +save_master_pos; + +connection slave; +sync_with_master; +select * from t1; + +connection master; +drop table t1; +save_master_pos; + +connection slave; +sync_with_master; + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_archive.test b/mysql-test/suite/vcol/t/vcol_archive.test new file mode 100644 index 00000000000..c0c9ecc445d --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_archive.test @@ -0,0 +1,49 @@ +################################################################################ +# t/vcol_archive.test # +# # +# Purpose: # +# ARCHIVE branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-02 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_archive.inc +SET @@session.storage_engine = 'archive'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests +--source suite/vcol/inc/vcol_unsupported_storage_engines.inc + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_blackhole.test b/mysql-test/suite/vcol/t/vcol_blackhole.test new file mode 100644 index 00000000000..eac074d9595 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_blackhole.test @@ -0,0 +1,49 @@ +################################################################################ +# t/vcol_blackhole.test # +# # +# Purpose: # +# BLACKHOLE branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-02 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_blackhole.inc +SET @@session.storage_engine = 'blackhole'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests +--source suite/vcol/inc/vcol_unsupported_storage_engines.inc + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_innodb.test b/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_innodb.test new file mode 100644 index 00000000000..516e121a2aa --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_innodb.test @@ -0,0 +1,52 @@ +################################################################################ +# t/vcol_supported_sql_funcs.test # +# # +# Purpose: # +# Test SQL functions not allowed for virtual columns # +# InnoDB branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-08-31 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_innodb.inc +eval SET @@session.storage_engine = 'InnoDB'; + +let $skip_full_text_checks = 1; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_blocked_sql_funcs_main.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_myisam.test b/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_myisam.test new file mode 100644 index 00000000000..d8eddb4ef15 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_myisam.test @@ -0,0 +1,49 @@ +################################################################################ +# t/vcol_supported_sql_funcs.test # +# # +# Purpose: # +# Test SQL functions not allowed for virtual columns # +# MyISAM branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-08-31 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +eval SET @@session.storage_engine = 'MyISAM'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_blocked_sql_funcs_main.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test b/mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test new file mode 100644 index 00000000000..38baa2b3024 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test @@ -0,0 +1,51 @@ +################################################################################ +# t/vcol_column_def_options_innodb.test # +# # +# Purpose: # +# Testing different optional parameters of virtual columns. # +# # +# InnoDB branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-02 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_innodb.inc +eval SET @@session.storage_engine = 'InnoDB'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_column_def_options.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_column_def_options_myisam.test b/mysql-test/suite/vcol/t/vcol_column_def_options_myisam.test new file mode 100644 index 00000000000..5c3a4619834 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_column_def_options_myisam.test @@ -0,0 +1,50 @@ +################################################################################ +# t/vcol_column_def_options_myisam.test # +# # +# Purpose: # +# Testing different optional parameters of virtual columns. # +# # +# MyISAM branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-02 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +eval SET @@session.storage_engine = 'MyISAM'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_column_def_options.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_csv.test b/mysql-test/suite/vcol/t/vcol_csv.test new file mode 100644 index 00000000000..b8342e24e07 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_csv.test @@ -0,0 +1,54 @@ +################################################################################ +# t/vcol_csv.test # +# # +# Purpose: # +# CSV branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-02 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_csv.inc +SET @@session.storage_engine = 'CSV'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests +--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN +create table t1 (a int, b int as (a+1)); +create table t1 (a int not null); +--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN +alter table t1 add column b int as (a+1); +drop table t1; + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_handler_innodb.test b/mysql-test/suite/vcol/t/vcol_handler_innodb.test new file mode 100644 index 00000000000..bf443c6bbd3 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_handler_innodb.test @@ -0,0 +1,51 @@ +################################################################################ +# t/vcol_handler_innodb.test # +# # +# Purpose: # +# Testing HANDLER. +# # +# InnoDB branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_innodb.inc +eval SET @@session.storage_engine = 'InnoDB'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_handler.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_handler_maria.test b/mysql-test/suite/vcol/t/vcol_handler_maria.test new file mode 100644 index 00000000000..9b69e600767 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_handler_maria.test @@ -0,0 +1,52 @@ +################################################################################ +# t/vcol_handler_maria.test # +# # +# Purpose: # +# Testing HANDLER. +# # +# Maria branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +--source include/have_maria.inc + +# +# NOTE: PLEASE DO NOT ADD NOT MARIA SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +eval SET @@session.storage_engine = 'maria'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_handler.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_handler_myisam.test b/mysql-test/suite/vcol/t/vcol_handler_myisam.test new file mode 100644 index 00000000000..5aa16da180a --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_handler_myisam.test @@ -0,0 +1,50 @@ +################################################################################ +# t/vcol_handler_myisam.test # +# # +# Purpose: # +# Testing HANDLER. +# # +# MyISAM branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +eval SET @@session.storage_engine = 'MyISAM'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_handler.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test b/mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test new file mode 100644 index 00000000000..5d9ac12e930 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test @@ -0,0 +1,51 @@ +################################################################################ +# t/vcol_ins_upd_innodb.test # +# # +# Purpose: # +# Testing DDL operations such as INSERT, UPDATE, REPLACE and DELETE. # +# # +# InnoDB branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_innodb.inc +eval SET @@session.storage_engine = 'InnoDB'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_ins_upd.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_ins_upd_myisam.test b/mysql-test/suite/vcol/t/vcol_ins_upd_myisam.test new file mode 100644 index 00000000000..7840c191194 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_ins_upd_myisam.test @@ -0,0 +1,50 @@ +################################################################################ +# t/vcol_ins_upd_myisam.test # +# # +# Purpose: # +# Testing DDL operations such as INSERT, UPDATE, REPLACE and DELETE. # +# # +# MyISAM branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +eval SET @@session.storage_engine = 'MyISAM'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_ins_upd.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_keys_innodb.test b/mysql-test/suite/vcol/t/vcol_keys_innodb.test new file mode 100644 index 00000000000..e408672ac07 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_keys_innodb.test @@ -0,0 +1,52 @@ +################################################################################ +# t/vcol_keys_innodb.test # +# # +# Purpose: # +# Testing keys, indexes defined upon virtual columns. # +# # +# InnoDB branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_innodb.inc +eval SET @@session.storage_engine = 'InnoDB'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +let $skip_spatial_index_check = 1; +--source suite/vcol/inc/vcol_keys.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_keys_myisam.test b/mysql-test/suite/vcol/t/vcol_keys_myisam.test new file mode 100644 index 00000000000..87d7b79aa1c --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_keys_myisam.test @@ -0,0 +1,50 @@ +################################################################################ +# t/vcol_keys_myisam.test # +# # +# Purpose: # +# Testing keys, indexes defined upon virtual columns. # +# # +# MyISAM branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +eval SET @@session.storage_engine = 'MyISAM'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_keys.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_memory.test b/mysql-test/suite/vcol/t/vcol_memory.test new file mode 100644 index 00000000000..f481427fa93 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_memory.test @@ -0,0 +1,48 @@ +################################################################################ +# t/vcol_memory.test # +# # +# Purpose: # +# MEMORY branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-02 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +SET @@session.storage_engine = 'memory'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests +--source suite/vcol/inc/vcol_unsupported_storage_engines.inc + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_merge.test b/mysql-test/suite/vcol/t/vcol_merge.test new file mode 100644 index 00000000000..7ba72441bf5 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_merge.test @@ -0,0 +1,57 @@ +################################################################################ +# t/vcol_merge.test # +# # +# Purpose: # +# MERGE branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-03 # +# Change Author: Oleksandr Byelkin (Monty program Ab) +# Date: 2009-03-24 +# Change: Syntax changed +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests +--disable_warnings +drop table if exists t1, t2, t3; +--enable_warnings + +create table t1 (a int, b int as (a % 10)); +create table t2 (a int, b int as (a % 10)); +insert into t1 values (1,default); +insert into t2 values (2,default); +--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN +create table t3 (a int, b int as (a % 10)) engine=MERGE UNION=(t1,t2); +drop table t1,t2; + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_misc.test b/mysql-test/suite/vcol/t/vcol_misc.test new file mode 100644 index 00000000000..2a8d9a576b4 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_misc.test @@ -0,0 +1,142 @@ +--source include/have_ucs2.inc + +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +# +# Bug#601164: DELETE/UPDATE with ORDER BY index and LIMIT +# + +create table t1 (a int, b int, v int as (a+1), index idx(b)); +insert into t1(a, b) values + (4, 40), (3, 30), (5, 50), (7, 70), (8, 80), (2, 20), (1, 10); + +select * from t1 order by b; + +delete from t1 where v > 6 order by b limit 1; +select * from t1 order by b; + +update t1 set a=v order by b limit 1; +select * from t1 order by b; + +drop table t1; + +# +# Bug#604549: Expression for virtual column returns row +# + +-- error ER_ROW_EXPR_FOR_VCOL +CREATE TABLE t1 ( + a int NOT NULL DEFAULT '0', + v double AS ((1, a)) VIRTUAL +); + +# +# Bug#603654: Virtual column in ORDER BY, no other references of table columns +# + +CREATE TABLE t1 ( + a CHAR(255) BINARY NOT NULL DEFAULT 0, + b CHAR(255) BINARY NOT NULL DEFAULT 0, + v CHAR(255) BINARY AS (CONCAT(a,b)) VIRTUAL ); +INSERT INTO t1(a,b) VALUES ('4','7'), ('4','6'); +SELECT 1 AS C FROM t1 ORDER BY v; + +DROP TABLE t1; + +# +# Bug#603186: Insert into a table with stored vurtual columns +# + +CREATE TABLE t1(a int, b int DEFAULT 0, v INT AS (b+10) PERSISTENT); +INSERT INTO t1(a) VALUES (1); +SELECT b, v FROM t1; + +DROP TABLE t1; + +CREATE TABLE t1(a int DEFAULT 100, v int AS (a+1) PERSISTENT); +INSERT INTO t1 () VALUES (); +CREATE TABLE t2(a int DEFAULT 100 , v int AS (a+1)); +INSERT INTO t2 () VALUES (); + +SELECT a, v FROM t1; +SELECT a, v FROM t2; + +DROP TABLE t1,t2; + +# +# Bug#604503: Virtual column expression with datetime comparison +# + +CREATE TABLE t1 ( + a datetime NOT NULL DEFAULT '2000-01-01', + v boolean AS (a < '2001-01-01') +); +INSERT INTO t1(a) VALUES ('2002-02-15'); +INSERT INTO t1(a) VALUES ('2000-10-15'); + +SELECT a, v FROM t1; +SELECT a, v FROM t1; + +CREATE TABLE t2 ( + a datetime NOT NULL DEFAULT '2000-01-01', + v boolean AS (a < '2001-01-01') PERSISTENT +); +INSERT INTO t2(a) VALUES ('2002-02-15'); +INSERT INTO t2(a) VALUES ('2000-10-15'); + +SELECT * FROM t2; + +DROP TABLE t1, t2; + +# +# Bug#607566: Virtual column in the select list of SELECT with ORDER BY +# + +CREATE TABLE t1 ( + a char(255), b char(255), c char(255), d char(255), + v char(255) AS (CONCAT(c,d) ) VIRTUAL +); + +INSERT INTO t1(a,b,c,d) VALUES ('w','x','y','z'), ('W','X','Y','Z'); + +SELECT v FROM t1 ORDER BY CONCAT(a,b); + +DROP TABLE t1; + +# +# Bug#607168: CREATE TABLE AS SELECT that returns virtual columns +# + +CREATE TABLE t1 (f1 INTEGER, v1 INTEGER AS (f1) VIRTUAL); +CREATE TABLE t2 AS SELECT v1 FROM t1; +SHOW CREATE TABLE t2; + +DROP TABLE t1,t2; + +# +# Bug#607177: ROUND function in the expression for a virtual function +# + +CREATE TABLE t1 (p int, a double NOT NULL, v double AS (ROUND(a,p)) VIRTUAL); +INSERT INTO t1 VALUES (0,1,0); +INSERT INTO t1 VALUES (NULL,0,0); +SELECT a, p, v, ROUND(a,p), ROUND(a,p+NULL) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (p int, a double NOT NULL); +INSERT INTO t1(p,a) VALUES (0,1); +INSERT INTO t1(p,a) VALUES (NULL,0); +SELECT a, p, ROUND(a,p), ROUND(a,p+NULL) FROM t1; +DROP TABLE t1; + +# +# Bug#610890: SHOW CREATE TABLE with a virtual column +# + +CREATE TABLE t1 (a char(32), v char(32) CHARACTER SET ucs2 AS (a) VIRTUAL); + +SHOW CREATE TABLE t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test b/mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test new file mode 100644 index 00000000000..88ed6157294 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test @@ -0,0 +1,53 @@ +################################################################################ +# t/vcol_non_stored_columns_innodb.test # +# # +# Purpose: # +# Ensure that MySQL behaviour is consistent irrelevant of # +# - the place of a non-stored column among other columns, # +# - the total number of non-stored fields. # +# # +# InnoDB branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_innodb.inc +eval SET @@session.storage_engine = 'InnoDB'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_non_stored_columns.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_non_stored_columns_myisam.test b/mysql-test/suite/vcol/t/vcol_non_stored_columns_myisam.test new file mode 100644 index 00000000000..32481e792ec --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_non_stored_columns_myisam.test @@ -0,0 +1,52 @@ +################################################################################ +# t/vcol_non_stored_columns_myisam.test # +# # +# Purpose: # +# Ensure that MySQL behaviour is consistent irrelevant of # +# - the place of a non-stored column among other columns, # +# - the total number of non-stored fields. # +# # +# MyISAM branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +eval SET @@session.storage_engine = 'MyISAM'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_non_stored_columns.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_partition_innodb.test b/mysql-test/suite/vcol/t/vcol_partition_innodb.test new file mode 100644 index 00000000000..01230120ef9 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_partition_innodb.test @@ -0,0 +1,52 @@ +################################################################################ +# t/vcol_partition_innodb.test # +# # +# Purpose: # +# Testing partitioning tables with virtual columns. # +# # +# InnoDB branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ +--source include/have_partition.inc + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_innodb.inc +eval SET @@session.storage_engine = 'InnoDB'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_partition.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_partition_myisam.test b/mysql-test/suite/vcol/t/vcol_partition_myisam.test new file mode 100644 index 00000000000..25f0d42c300 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_partition_myisam.test @@ -0,0 +1,51 @@ +################################################################################ +# t/vcol_partition_myisam.test # +# # +# Purpose: # +# Testing partitioning tables with virtual columns. # +# # +# MyISAM branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ +--source include/have_partition.inc + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +eval SET @@session.storage_engine = 'MyISAM'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_partition.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_select_innodb.test b/mysql-test/suite/vcol/t/vcol_select_innodb.test new file mode 100644 index 00000000000..314aecb75b9 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_select_innodb.test @@ -0,0 +1,51 @@ +################################################################################ +# t/vcol_select_innodb.test # +# # +# Purpose: # +# Testing different SELECTs. # +# # +# InnoDB branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-18 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_innodb.inc +eval SET @@session.storage_engine = 'InnoDB'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_select.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_select_myisam.test b/mysql-test/suite/vcol/t/vcol_select_myisam.test new file mode 100644 index 00000000000..855e02ac113 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_select_myisam.test @@ -0,0 +1,50 @@ +################################################################################ +# t/vcol_select.test # +# # +# Purpose: # +# Testing different SELECTs. # +# # +# MyISAM branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-18 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +eval SET @@session.storage_engine = 'MyISAM'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_select.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_supported_sql_funcs_innodb.test b/mysql-test/suite/vcol/t/vcol_supported_sql_funcs_innodb.test new file mode 100644 index 00000000000..53826a460a7 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_supported_sql_funcs_innodb.test @@ -0,0 +1,50 @@ +################################################################################ +# t/vcol_supported_sql_funcs.test # +# # +# Purpose: # +# Test SQL functions allowed for virtual columns # +# InnoDB branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-08-31 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_innodb.inc +SET @@session.storage_engine = 'InnoDB'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_supported_sql_funcs_main.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_supported_sql_funcs_myisam.test b/mysql-test/suite/vcol/t/vcol_supported_sql_funcs_myisam.test new file mode 100644 index 00000000000..aa5833451c6 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_supported_sql_funcs_myisam.test @@ -0,0 +1,49 @@ +################################################################################ +# t/vcol_supported_sql_funcs.test # +# # +# Purpose: # +# Test SQL functions allowed for virtual columns # +# MyISAM branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-08-31 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +eval SET @@session.storage_engine = 'MyISAM'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_supported_sql_funcs_main.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_syntax.test b/mysql-test/suite/vcol/t/vcol_syntax.test new file mode 100644 index 00000000000..6dc3cf43317 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_syntax.test @@ -0,0 +1,30 @@ +# +# test syntax +# +--disable_warnings +drop table if exists t1; +--enable_warnings + +set @OLD_SQL_MODE=@@SESSION.SQL_MODE; +create table t1 (a int, b int generated always as (a+1)); +show create table t1; +drop table t1; +create table t1 (a int, b int as (a+1) virtual); +show create table t1; +drop table t1; +create table t1 (a int, b int generated always as (a+1) persistent); +show create table t1; +drop table t1; + +set session sql_mode='ORACLE'; +create table t1 (a int, b int as (a+1)); +show create table t1; +drop table t1; +create table t1 (a int, b int generated always as (a+1) virtual); +show create table t1; +drop table t1; +create table t1 (a int, b int as (a+1) persistent); +show create table t1; +drop table t1; +set session sql_mode=@OLD_SQL_MODE; + diff --git a/mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test b/mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test new file mode 100644 index 00000000000..5a36fb1c06d --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test @@ -0,0 +1,52 @@ +################################################################################ +# t/vcol_trigger_sp_innodb.test # +# # +# Purpose: # +# Testing triggers, stored procedures and functions # +# defined on tables with virtual columns. # +# # +# InnoDB branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_innodb.inc +eval SET @@session.storage_engine = 'InnoDB'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_trigger_sp.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_trigger_sp_myisam.test b/mysql-test/suite/vcol/t/vcol_trigger_sp_myisam.test new file mode 100644 index 00000000000..c475a31eaa6 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_trigger_sp_myisam.test @@ -0,0 +1,51 @@ +################################################################################ +# t/vcol_trigger_sp_myisam.test # +# # +# Purpose: # +# Testing triggers, stored procedures and functions # +# defined on tables with virtual columns. # +# # +# MyISAM branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +eval SET @@session.storage_engine = 'MyISAM'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_trigger_sp.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_view_innodb.test b/mysql-test/suite/vcol/t/vcol_view_innodb.test new file mode 100644 index 00000000000..01fced8e4c3 --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_view_innodb.test @@ -0,0 +1,51 @@ +################################################################################ +# t/vcol_view_innodb.test # +# # +# Purpose: # +# Testing views defined on tables with virtual columns. # +# # +# InnoDB branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +--source include/have_innodb.inc +eval SET @@session.storage_engine = 'InnoDB'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_view.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/suite/vcol/t/vcol_view_myisam.test b/mysql-test/suite/vcol/t/vcol_view_myisam.test new file mode 100644 index 00000000000..2ebd36431bc --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_view_myisam.test @@ -0,0 +1,50 @@ +################################################################################ +# t/vcol_view_myisam.test # +# # +# Purpose: # +# Testing views defined on tables with virtual columns. # +# # +# MyISAM branch # +# # +#------------------------------------------------------------------------------# +# Original Author: Andrey Zhakov # +# Original Date: 2008-09-04 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +#------------------------------------------------------------------------------# +# General not engine specific settings and requirements +--source suite/vcol/inc/vcol_init_vars.pre + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +# Set the session storage engine +eval SET @@session.storage_engine = 'MyISAM'; + +##### Workarounds for known open engine specific bugs +# none + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/vcol/inc/vcol_view.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +#------------------------------------------------------------------------------# +# Cleanup +--source suite/vcol/inc/vcol_cleanup.inc diff --git a/mysql-test/t/change_user.test b/mysql-test/t/change_user.test index 46bf1d2a92c..5639e013de8 100644 --- a/mysql-test/t/change_user.test +++ b/mysql-test/t/change_user.test @@ -1,4 +1,61 @@ # +# functional change user tests +# + +grant select on test.* to test_nopw; +grant select on test.* to test_oldpw identified by password "09301740536db389"; +grant select on test.* to test_newpw identified by "newpw"; + +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); + +# +# massaging the data for tests to pass in the embedded server, +# that has authentication completely disabled or, if enabled, can +# only do new auth (20-byte scramble). +# + +change_user test_nopw; +--replace_result <@> <test_nopw@%> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); + +# +# embedded with enabled privilege control cannot do plugin negotiation. +# that is, it cannot try to authenticate with a new scramble, receive a request +# to switch to an old scramble, and retry with an old scramble. +# As a result, it cannot change to a user that has old scramble and +# and it stays logged as a previous user - test_nopw in this test file. +# For the embedded with auth we replace nopw with oldpw in the results. +# +let $repl = `select if(version() like '%embedded%' and user() like '%nopw%', 'nopw', 'oldpw')`; + +change_user test_oldpw, oldpw; +--replace_result <@> <test_oldpw@%> @> @localhost> $repl oldpw +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +change_user test_newpw, newpw; +--replace_result <@> <test_newpw@%> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +change_user root; +--replace_result <@> <root@localhost> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); + +change_user test_nopw,,test; +--replace_result <@> <test_nopw@%> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +change_user test_oldpw,oldpw,test; +--replace_result <@> <test_oldpw@%> @> @localhost> $repl oldpw +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +change_user test_newpw,newpw,test; +--replace_result <@> <test_newpw@%> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +change_user root,,test; +--replace_result <@> <root@localhost> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); + +drop user test_nopw; +drop user test_oldpw; +drop user test_newpw; + +# # Bug#20023 mysql_change_user() resets the value of SQL_BIG_SELECTS # The replace's are here to fix things for 32 bit systems # diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test index 255a4634bca..a8c8b659c3c 100644 --- a/mysql-test/t/connect.test +++ b/mysql-test/t/connect.test @@ -328,6 +328,34 @@ if ($error) --disconnect extracon2 --connection default +# +# A couple of plugin tests - for builtin plugins only +# +CREATE USER mysqltest_up1 IDENTIFIED VIA mysql_native_password using '*E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB'; +CREATE USER mysqltest_up2 IDENTIFIED VIA mysql_old_password using '09301740536db389'; + +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +--error ER_ACCESS_DENIED_ERROR +connect(pcon1,localhost,mysqltest_up1,foo,,$MASTER_MYPORT,); +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +connect(pcon2,localhost,mysqltest_up1,bar,,$MASTER_MYPORT,); +connection pcon2; +select user(), current_user(); +disconnect pcon2; + +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +--error ER_ACCESS_DENIED_ERROR +connect(pcon3,localhost,mysqltest_up2,newpw,,$MASTER_MYPORT,); +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +connect(pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,); +connection pcon4; +select user(), current_user(); +disconnect pcon4; + +connection default; +DROP USER mysqltest_up1@'%'; +DROP USER mysqltest_up2@'%'; + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index 81397b333f9..f2a82f40cff 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.test @@ -1204,7 +1204,6 @@ create event e1 on schedule every 1 day do select 1; select @@sql_mode; set @@sql_mode= @old_mode; # Rename SQL modes that differ in name between the server and the table definition. -select replace(@full_mode, '?', 'NOT_USED') into @full_mode; select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode; select name from mysql.event where name = 'p' and sql_mode = @full_mode; drop event e1; diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test index 4c14dc96aaa..d77ce243e32 100644 --- a/mysql-test/t/key_cache.test +++ b/mysql-test/t/key_cache.test @@ -1,11 +1,13 @@ # -# Test of multiple key caches +# Test of multiple key caches, simple and segmented # --disable_warnings drop table if exists t1, t2, t3; --enable_warnings -SET @save_key_buffer=@@key_buffer_size; +SET @save_key_buffer_size=@@key_buffer_size; +SET @save_key_cache_block_size=@@key_cache_block_size; +SET @save_key_cache_segments=@@key_cache_segments; SELECT @@key_buffer_size, @@small.key_buffer_size; @@ -33,7 +35,7 @@ SELECT @@`default`.key_buffer_size; SELECT @@small.key_buffer_size; SELECT @@medium.key_buffer_size; -SET @@global.key_buffer_size=@save_key_buffer; +SET @@global.key_buffer_size=@save_key_buffer_size; # # Errors @@ -247,3 +249,272 @@ SET GLOBAL key_cache_block_size= @bug28478_key_cache_block_size; DROP TABLE t1; # End of 4.1 tests + +# End of 5.1 tests + +# +# Test cases for segmented key caches +# + +# Test usage of the KEY_CACHE table from information schema +# for a simple key cache + +set global key_buffer_size=@save_key_buffer_size; +set global key_cache_block_size=@save_key_cache_block_size; +select @@key_buffer_size; +select @@key_cache_block_size; +select @@key_cache_segments; + +create table t1 ( + p int not null auto_increment primary key, + a char(10)); +create table t2 ( + p int not null auto_increment primary key, + i int, a char(10), key k1(i), key k2(a)); + +select @@key_cache_segments; +--replace_column 7 # +select * from information_schema.key_caches where segment_number is null; + +insert into t1 values (1, 'qqqq'), (2, 'yyyy'); +insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'), + (3, 1, 'yyyy'), (4, 3, 'zzzz'); +select * from t1; +select * from t2; +update t1 set p=3 where p=1; +update t2 set i=2 where i=1; + +--replace_result 1808 KEY_BLOCKS_UNUSED 1670 KEY_BLOCKS_UNUSED 1789 KEY_BLOCKS_UNUSED +show status like 'key_%'; +--replace_column 7 # +select * from information_schema.key_caches where segment_number is null; + +delete from t2 where a='zzzz'; +--replace_column 7 # +select * from information_schema.key_caches where segment_number is null; + +delete from t1; +delete from t2; +--replace_column 7 # +select * from information_schema.key_caches where segment_number is null; + +# For the key cache with 2 segments execute the same sequence of +# statements as for the simple cache above. +# The statistical information on the number of i/o requests and +# the number of is expected to be the same. + +set global key_cache_segments=2; +select @@key_cache_segments; +--replace_column 7 # +select * from information_schema.key_caches where segment_number is null; + +insert into t1 values (1, 'qqqq'), (2, 'yyyy'); +insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'), + (3, 1, 'yyyy'), (4, 3, 'zzzz'); +select * from t1; +select * from t2; +update t1 set p=3 where p=1; +update t2 set i=2 where i=1; + +--replace_result 1808 KEY_BLOCKS_UNUSED 1670 KEY_BLOCKS_UNUSED 1788 KEY_BLOCKS_UNUSED +show status like 'key_%'; +--replace_column 7 # +select * from information_schema.key_caches where segment_number is null; + +delete from t1; +delete from t2; +--replace_column 7 # +select * from information_schema.key_caches where segment_number is null; + +# Check that we can work with one segment with the same results + +set global key_cache_segments=1; +select @@key_cache_segments; +--replace_column 7 # +select * from information_schema.key_caches where segment_number is null; + +insert into t1 values (1, 'qqqq'), (2, 'yyyy'); +insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'), + (3, 1, 'yyyy'), (4, 3, 'zzzz'); +select * from t1; +select * from t2; +update t1 set p=3 where p=1; +update t2 set i=2 where i=1; + +--replace_result 1808 KEY_BLOCKS_UNUSED 1670 KEY_BLOCKS_UNUSED 1789 KEY_BLOCKS_UNUSED +show status like 'key_%'; +--replace_column 7 # +select * from information_schema.key_caches where segment_number is null; + +delete from t1; +delete from t2; +--replace_column 7 # +select * from information_schema.key_caches where segment_number is null; + +flush tables; flush status; +--replace_column 7 # +select * from information_schema.key_caches where segment_number is null; + +# Switch back to 2 segments + +set global key_buffer_size=32*1024; +select @@key_buffer_size; +set global key_cache_segments=2; +select @@key_cache_segments; +--replace_column 7 # +select * from information_schema.key_caches where segment_number is null; + +insert into t1 values (1, 'qqqq'), (2, 'yyyy'); +insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'), + (3, 1, 'yyyy'), (4, 3, 'zzzz'); +select * from t1; +select * from t2; +update t1 set p=3 where p=1; +update t2 set i=2 where i=1; + +--replace_column 7 # +select * from information_schema.key_caches where segment_number is null; + +# Add more rows to tables t1 and t2 + +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; +insert into t1(a) select a from t1; + +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; +insert into t2(i,a) select i,a from t2; + +--replace_column 6 # 7 # 10 # +select * from information_schema.key_caches where segment_number is null; + +select * from t1 where p between 1010 and 1020 ; +select * from t2 where p between 1010 and 1020 ; +--replace_column 6 # 7 # 10 # +select * from information_schema.key_caches where segment_number is null; + +flush tables; flush status; +update t1 set a='zzzz' where a='qqqq'; +update t2 set i=1 where i=2; +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; + +# Now test how we can work with 7 segments + +set global keycache1.key_buffer_size=256*1024; +select @@keycache1.key_buffer_size; +set global keycache1.key_cache_segments=7; +select @@keycache1.key_cache_segments; + +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; +--replace_column 7 # +select * from information_schema.key_caches where key_cache_name like "key%" + and segment_number is null; + +cache index t1 key (`primary`) in keycache1; + +explain select p from t1 where p between 1010 and 1020; +select p from t1 where p between 1010 and 1020; +explain select i from t2 where p between 1010 and 1020; +select i from t2 where p between 1010 and 1020; +explain select count(*) from t1, t2 where t1.p = t2.i; +select count(*) from t1, t2 where t1.p = t2.i; + +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; +--replace_column 7 # +select * from information_schema.key_caches where key_cache_name like "key%" + and segment_number is null; + +cache index t2 in keycache1; +update t2 set p=p+3000, i=2 where a='qqqq'; +--replace_column 7 # +select * from information_schema.key_caches where key_cache_name like "key%" + and segment_number is null; + +set global keycache2.key_buffer_size=1024*1024; +cache index t2 in keycache2; +insert into t2 values (2000, 3, 'yyyy'); +--replace_column 7 # +select * from information_schema.key_caches where key_cache_name like "keycache2" + and segment_number is null; +--replace_column 7 # +select * from information_schema.key_caches where key_cache_name like "key%" + and segment_number is null; + +cache index t2 in keycache1; +update t2 set p=p+5000 where a='zzzz'; +select * from t2 where p between 1010 and 1020; +explain select p from t2 where p between 1010 and 1020; +select p from t2 where p between 1010 and 1020; +explain select i from t2 where a='yyyy' and i=3; +select i from t2 where a='yyyy' and i=3; +explain select a from t2 where a='yyyy' and i=3; +select a from t2 where a='yyyy' and i=3 ; +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; + +set global keycache1.key_cache_block_size=2*1024; +insert into t2 values (7000, 3, 'yyyy'); +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; + +set global keycache1.key_cache_block_size=8*1024; +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; +insert into t2 values (8000, 3, 'yyyy'); +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; + +set global keycache1.key_buffer_size=64*1024; +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; + +set global keycache1.key_cache_block_size=2*1024; +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; + +set global keycache1.key_cache_block_size=8*1024; +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; + +set global keycache1.key_buffer_size=0; +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; + +set global keycache1.key_cache_block_size=8*1024; +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; + +set global keycache1.key_buffer_size=0; +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; + +set global keycache1.key_buffer_size=128*1024; +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; + +set global keycache1.key_cache_block_size=1024; +--replace_column 6 # 7 # +select * from information_schema.key_caches where segment_number is null; + +drop table t1,t2; + +set global keycache1.key_buffer_size=0; +set global keycache2.key_buffer_size=0; + +set global key_buffer_size=@save_key_buffer_size; +set global key_cache_segments=@save_key_cache_segments; + +# End of 5.2 tests diff --git a/mysql-test/t/log_slow.test b/mysql-test/t/log_slow.test index 303d5bf8deb..d624e9f2520 100644 --- a/mysql-test/t/log_slow.test +++ b/mysql-test/t/log_slow.test @@ -36,6 +36,12 @@ select @@log_slow_verbosity; show fields from mysql.slow_log; +# +# Check flush command +# + +flush slow query logs; + # Reset used variables set @@log_slow_filter=default; diff --git a/mysql-test/t/partition_example.test b/mysql-test/t/partition_example.test new file mode 100644 index 00000000000..8c1b92b2e33 --- /dev/null +++ b/mysql-test/t/partition_example.test @@ -0,0 +1,23 @@ +--source include/not_windows_embedded.inc +--source include/have_example_plugin.inc +--source include/have_partition.inc + +--replace_regex /\.dll/.so/ +eval install plugin example soname '$HA_EXAMPLE_SO'; + +create table t1 (a int not null) +engine=example +partition by list (a) +(partition p0 values in (1), partition p1 values in (2)); +show create table t1; +drop table t1; + +create table t1 (a int not null) +engine=example ull=12340 +partition by list (a) +(partition p0 values in (1), partition p1 values in (2)); +show create table t1; +drop table t1; + +select 1; +uninstall plugin example; diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test index 9a1a750378c..55250b73ae5 100644 --- a/mysql-test/t/plugin.test +++ b/mysql-test/t/plugin.test @@ -22,6 +22,12 @@ SELECT * FROM t1; DROP TABLE t1; +# a couple of tests for variables +set global example_ulong_var=500; +set global example_enum_var= e1; +show status like 'example%'; +show variables like 'example%'; + UNINSTALL PLUGIN example; --error 1305 UNINSTALL PLUGIN EXAMPLE; @@ -78,4 +84,55 @@ set session sql_mode=@old_sql_mode; --error ER_INCORRECT_GLOBAL_LOCAL_VAR set session old=bla; +############################################################### +# engine-specific clauses in the CREATE TABLE: + +--echo #legal values +CREATE TABLE t1 ( a int complex='c,f,f,f' ) ENGINE=example ULL=10000 STR='dskj' one_or_two='one' YESNO=0; +show create table t1; +drop table t1; + +SET @OLD_SQL_MODE=@@SQL_MODE; +SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS'; + +--echo #illegal value fixed +CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS; +show create table t1; + +--echo #alter table +alter table t1 ULL=10000000; +show create table t1; +alter table t1 change a a int complex='c,c,c'; +show create table t1; +drop table t1; + +--echo #illegal value error +SET SQL_MODE=''; +--error ER_BAD_OPTION_VALUE +CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS; + +--error ER_PARSE_ERROR +CREATE TABLE t1 (a int) ENGINE=example ULL=10.00; + +--error ER_PARSE_ERROR +CREATE TABLE t1 (a int) ENGINE=example ULL=1e2; + +CREATE TABLE t1 (a int) ENGINE=example ULL=0x1234; +SHOW CREATE TABLE t1; + +ALTER TABLE t1 ULL=DEFAULT; +SHOW CREATE TABLE t1; + +DROP TABLE t1; + +SET @@SQL_MODE=@OLD_SQL_MODE; + +# +# The only preparable statement above was CREATE TABLE. +# We need to prepare another statement here to force the +# previous one to be deallocated (mysqltest reuses the same handle) +# and to unlock all thread-local plugin locks. Otherwise the plugin won't +# uninstall. +# +select 1; UNINSTALL PLUGIN example; diff --git a/mysql-test/t/plugin_maturity-master.opt b/mysql-test/t/plugin_maturity-master.opt new file mode 100644 index 00000000000..70ba6280117 --- /dev/null +++ b/mysql-test/t/plugin_maturity-master.opt @@ -0,0 +1 @@ +--plugin-maturity=stable diff --git a/mysql-test/t/plugin_maturity.test b/mysql-test/t/plugin_maturity.test new file mode 100644 index 00000000000..fe95f19b803 --- /dev/null +++ b/mysql-test/t/plugin_maturity.test @@ -0,0 +1,6 @@ +--source include/have_example_plugin.inc + +# test for --plugin_maturity +--replace_regex /\.dll/.so/ +--error 1126 +eval INSTALL PLUGIN example SONAME '$HA_EXAMPLE_SO'; diff --git a/mysql-test/t/select_pkeycache-master.opt b/mysql-test/t/select_pkeycache-master.opt new file mode 100644 index 00000000000..a6c0f247334 --- /dev/null +++ b/mysql-test/t/select_pkeycache-master.opt @@ -0,0 +1 @@ +--key_cache_segments=7 diff --git a/mysql-test/t/select_pkeycache.test b/mysql-test/t/select_pkeycache.test new file mode 100644 index 00000000000..e0ee96e937a --- /dev/null +++ b/mysql-test/t/select_pkeycache.test @@ -0,0 +1,8 @@ + +# +# Run select.test with the segmented default key cache (with 7 segments) +# (see setting the number of segments in select_pkecache-master.opt) +# The result is expected the same as for select.test +# + +--source t/select.test diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 5cf050146dd..db8077bbbef 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -8210,7 +8210,6 @@ call p(); select @@sql_mode; set @@sql_mode= @old_mode; # Rename SQL modes that differ in name between the server and the table definition. -select replace(@full_mode, '?', 'NOT_USED') into @full_mode; select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode; select name from mysql.proc where name = 'p' and sql_mode = @full_mode; drop procedure p; diff --git a/mysql-test/t/status_user-master.opt b/mysql-test/t/status_user-master.opt new file mode 100644 index 00000000000..cef79bc8585 --- /dev/null +++ b/mysql-test/t/status_user-master.opt @@ -0,0 +1 @@ +--force-restart diff --git a/mysql-test/t/status_user.test b/mysql-test/t/status_user.test new file mode 100644 index 00000000000..d42f81b20e5 --- /dev/null +++ b/mysql-test/t/status_user.test @@ -0,0 +1,89 @@ +# +# Testing of user status (the userstat variable). +# Note that this test requires a fresh restart to not problems with +# old status + +-- source include/have_innodb.inc +-- source include/have_log_bin.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +select variable_value from information_schema.global_status where variable_name="handler_read_key" into @global_read_key; +show columns from information_schema.client_statistics; +show columns from information_schema.user_statistics; +show columns from information_schema.index_statistics; +show columns from information_schema.table_statistics; + +# Disable logging to get right number of writes into the tables. +set @save_general_log=@@global.general_log; +set @@global.general_log=0; +set @@global.userstat=1; +flush status; + +create table t1 (a int, primary key (a), b int default 0) engine=innodb; +insert into t1 (a) values (1),(2),(3),(4); +update t1 set b=1; +update t1 set b=5 where a=2; +delete from t1 where a=3; + +/* Empty query */ +select * from t1 where a=999; + +drop table t1; + +# +# Test the commit and rollback are counted +# + +create table t1 (a int, primary key (a), b int default 0) engine=innodb; +begin; +insert into t1 values(1,1); +commit; +begin; +insert into t1 values(2,2); +commit; +begin; +insert into t1 values(3,3); +rollback; +drop table t1; + +select sleep(1); + +show status like "rows%"; +show status like "ha%"; +select variable_value - @global_read_key as "handler_read_key" from information_schema.global_status where variable_name="handler_read_key"; + +# Ensure that the following commands doesn't change statistics + +set @@global.userstat=0; + +# +# Check that we got right statistics +# +select * from information_schema.index_statistics; +select * from information_schema.table_statistics; +show table_statistics; +show index_statistics; +--query_vertical select TOTAL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics; +--query_vertical select TOTAL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics; +flush table_statistics; +flush index_statistics; +select * from information_schema.index_statistics; +select * from information_schema.table_statistics; +show status like "%statistics%"; + +# +# Test that some variables are not 0 +# + +select connected_time <> 0, busy_time <> 0, bytes_received <> 0, + bytes_sent <> 0, binlog_bytes_written <> 0 + from information_schema.user_statistics; +select connected_time <> 0, busy_time <> 0, bytes_received <> 0, + bytes_sent <> 0, binlog_bytes_written <> 0 + from information_schema.client_statistics; + +# Cleanup +set @@global.general_log=@save_general_log; diff --git a/mysql-test/t/table_options.test b/mysql-test/t/table_options.test new file mode 100644 index 00000000000..533e6829c00 --- /dev/null +++ b/mysql-test/t/table_options.test @@ -0,0 +1,68 @@ +--disable_warnings +drop table if exists t1; +--enable_warnings + +SET @OLD_SQL_MODE=@@SQL_MODE; +SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS'; + +create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1='1v1'; +show create table t1; +drop table t1; + +--echo #reassiginig options in the same line +create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1=1v1 TKEY1=DEFAULT tkey1=1v2 tkey2=2v1; +show create table t1; + +-- echo #add option +alter table t1 tkey4=4v1; +show create table t1; + +--echo #remove options +alter table t1 tkey3=DEFAULT tkey4=DEFAULT; +show create table t1; + +drop table t1; + +create table t1 (a int fkey1=v1, key akey (a) kkey1=v1) tkey1=1v1 tkey1=1v2 TKEY1=DEFAULT tkey2=2v1 tkey3=3v1; +show create table t1; + +--echo #change field with option with the same value +alter table t1 change a a int `FKEY1`='v1'; +show create table t1; +--echo #change field with option with a different value +alter table t1 change a a int fkey1=v2; +show create table t1; +--echo #new column no options +alter table t1 add column b int; +show create table t1; +--echo #new key with options +alter table t1 add key bkey (b) kkey2=v1; +show create table t1; +--echo #new column with options +alter table t1 add column c int fkey1=v1 fkey2=v2; +show create table t1; +--echo #new key no options +alter table t1 add key ckey (c); +show create table t1; +--echo #drop column +alter table t1 drop b; +show create table t1; +--echo #add column with options after delete +alter table t1 add column b int fkey2=v1; +show create table t1; +--echo #add key +alter table t1 add key bkey (b) kkey2=v2; +show create table t1; +drop table t1; + +#numeric (unquoted) value +create table t1 (a int) tkey1=100; +show create table t1; +drop table t1; + +--echo #error on unknown option +SET SQL_MODE=''; +--error ER_UNKNOWN_OPTION +create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1=1v1; + +SET @@SQL_MODE=@OLD_SQL_MODE; diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp index 67179571953..1919b79461d 100644 --- a/mysql-test/valgrind.supp +++ b/mysql-test/valgrind.supp @@ -539,6 +539,13 @@ fun:_Unwind_ForcedUnwind } +{ + dlsym memory loss from plugin + Memcheck:Leak + fun:malloc + fun:_dl_signal_error +} + # # Reading wrong addresses on SuSe Linux 10.3 32 bit # @@ -1000,6 +1007,27 @@ fun:nptl_pthread_exit_hack_handler } +{ + Invalid read within nptl_pthread_exit_hack_handler + Memcheck:Addr8 + obj:*/ld-*.so + obj:*/ld-*.so + obj:*/ld-*.so + obj:*/ld-*.so + obj:*/ld-*.so + obj:*/ld-*.so + obj:*/ld-*.so + obj:*/libc-*.so + obj:*/ld-*.so + obj:*/libc-*.so + fun:__libc_dlopen_mode + fun:pthread_cancel_init + fun:_Unwind_ForcedUnwind + fun:__pthread_unwind + fun:pthread_exit + fun:nptl_pthread_exit_hack_handler +} + # # Pthread doesn't free all thread specific memory before program exists # |