mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Merge with Trunk
This commit is contained in:
@@ -506,6 +506,9 @@ int DbugParse(CODE_STATE *cs, const char *control)
|
||||
rel= control[0] == '+' || control[0] == '-';
|
||||
if ((!rel || (!stack->out_file && !stack->next)))
|
||||
{
|
||||
/* If overwriting previous state, be sure to free old to avoid leak. */
|
||||
if (stack->out_file)
|
||||
FreeState(cs, stack, 0);
|
||||
stack->flags= 0;
|
||||
stack->delay= 0;
|
||||
stack->maxdepth= 0;
|
||||
@@ -1648,10 +1651,12 @@ static void FreeState(CODE_STATE *cs, struct settings *state, int free_state)
|
||||
FreeList(state->processes);
|
||||
if (!is_shared(state, p_functions))
|
||||
FreeList(state->p_functions);
|
||||
if (!is_shared(state, out_file))
|
||||
if (!is_shared(state, out_file) &&
|
||||
state->out_file != stderr && state->out_file != stdout)
|
||||
DBUGCloseFile(cs, state->out_file);
|
||||
(void) fflush(cs->stack->out_file);
|
||||
if (state->prof_file)
|
||||
if (state->prof_file &&
|
||||
state->prof_file != stderr && state->prof_file != stdout)
|
||||
DBUGCloseFile(cs, state->prof_file);
|
||||
if (free_state)
|
||||
free((void*) state);
|
||||
|
||||
@@ -569,6 +569,12 @@ int __void__;
|
||||
#define PURIFY_OR_LINT_INIT(var)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_purify
|
||||
#define IF_PURIFY(A,B) (A)
|
||||
#else
|
||||
#define IF_PURIFY(A,B) (B)
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_UINT)
|
||||
#undef HAVE_UINT
|
||||
#define HAVE_UINT
|
||||
|
||||
@@ -34,7 +34,7 @@ connection master;
|
||||
drop table t1;
|
||||
|
||||
set @@session.auto_increment_increment=100, @@session.auto_increment_offset=10;
|
||||
show variables like "%auto_inc%";
|
||||
show variables like "auto_inc%";
|
||||
|
||||
eval create table t1 (a int not null auto_increment, primary key (a)) engine=$engine_type2;
|
||||
# Insert with 2 insert statements to get better testing of logging
|
||||
|
||||
4
mysql-test/include/have_pbxt.inc
Normal file
4
mysql-test/include/have_pbxt.inc
Normal file
@@ -0,0 +1,4 @@
|
||||
disable_query_log;
|
||||
--require r/true.require
|
||||
select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'pbxt';
|
||||
enable_query_log;
|
||||
@@ -187,8 +187,10 @@ sub mtr_report_test ($) {
|
||||
}
|
||||
|
||||
|
||||
sub mtr_report_stats ($) {
|
||||
sub mtr_report_stats ($$$) {
|
||||
my $fail= shift;
|
||||
my $tests= shift;
|
||||
my $extra_warnings= shift;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Find out how we where doing
|
||||
@@ -325,10 +327,27 @@ sub mtr_report_stats ($) {
|
||||
print "All $tot_tests tests were successful.\n\n";
|
||||
}
|
||||
|
||||
if (@$extra_warnings)
|
||||
{
|
||||
print <<MSG;
|
||||
Errors/warnings were found in logfiles during server shutdown after running the
|
||||
following sequence(s) of tests:
|
||||
MSG
|
||||
print " $_\n" for @$extra_warnings;
|
||||
}
|
||||
|
||||
if ( $tot_failed != 0 || $found_problems)
|
||||
{
|
||||
mtr_error("there were failing test cases");
|
||||
}
|
||||
elsif (@$extra_warnings)
|
||||
{
|
||||
mtr_error("There were errors/warnings in server logs after running test cases.");
|
||||
}
|
||||
elsif ($fail)
|
||||
{
|
||||
mtr_error("Test suite failure, see messages above for possible cause(s).");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -62,13 +62,14 @@ sub mtr_get_unique_id($$) {
|
||||
die 'lock file is a symbolic link';
|
||||
}
|
||||
|
||||
chmod 0777, "$file.sem";
|
||||
open SEM, ">", "$file.sem" or die "can't write to $file.sem";
|
||||
chmod 0777, "$file.sem";
|
||||
flock SEM, LOCK_EX or die "can't lock $file.sem";
|
||||
if(! -e $file) {
|
||||
open FILE, ">", $file or die "can't create $file";
|
||||
close FILE;
|
||||
}
|
||||
chmod 0777, $file;
|
||||
|
||||
msg("HAVE THE LOCK");
|
||||
|
||||
@@ -76,7 +77,6 @@ sub mtr_get_unique_id($$) {
|
||||
die 'lock file is a symbolic link';
|
||||
}
|
||||
|
||||
chmod 0777, $file;
|
||||
open FILE, "+<", $file or die "can't open $file";
|
||||
#select undef,undef,undef,0.2;
|
||||
seek FILE, 0, 0;
|
||||
@@ -136,6 +136,7 @@ sub mtr_release_unique_id($) {
|
||||
}
|
||||
|
||||
open SEM, ">", "$file.sem" or die "can't write to $file.sem";
|
||||
chmod 0777, "$file.sem";
|
||||
flock SEM, LOCK_EX or die "can't lock $file.sem";
|
||||
|
||||
msg("HAVE THE LOCK");
|
||||
@@ -148,6 +149,7 @@ sub mtr_release_unique_id($) {
|
||||
open FILE, ">", $file or die "can't create $file";
|
||||
close FILE;
|
||||
}
|
||||
chmod 0777, "$file.sem";
|
||||
open FILE, "+<", $file or die "can't open $file";
|
||||
#select undef,undef,undef,0.2;
|
||||
seek FILE, 0, 0;
|
||||
|
||||
@@ -357,7 +357,8 @@ sub main {
|
||||
mtr_print_thick_line();
|
||||
mtr_print_header();
|
||||
|
||||
my ($completed, $fail)= run_test_server($server, $tests, $opt_parallel);
|
||||
my ($fail, $completed, $extra_warnings)=
|
||||
run_test_server($server, $tests, $opt_parallel);
|
||||
|
||||
# Send Ctrl-C to any children still running
|
||||
kill("INT", keys(%children));
|
||||
@@ -393,10 +394,6 @@ sub main {
|
||||
mtr_error("Not all tests completed");
|
||||
}
|
||||
|
||||
if ($fail) {
|
||||
mtr_error("Test suite failure.");
|
||||
}
|
||||
|
||||
mtr_print_line();
|
||||
|
||||
if ( $opt_gcov ) {
|
||||
@@ -404,7 +401,7 @@ sub main {
|
||||
$opt_gcov_msg, $opt_gcov_err);
|
||||
}
|
||||
|
||||
mtr_report_stats($completed);
|
||||
mtr_report_stats($fail, $completed, $extra_warnings);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
@@ -416,7 +413,8 @@ sub run_test_server ($$$) {
|
||||
my $num_saved_cores= 0; # Number of core files saved in vardir/log/ so far.
|
||||
my $num_saved_datadir= 0; # Number of datadirs saved in vardir/log/ so far.
|
||||
my $num_failed_test= 0; # Number of tests failed so far
|
||||
my $test_failure= 0;
|
||||
my $test_failure= 0; # Set true if test suite failed
|
||||
my $extra_warnings= []; # Warnings found during server shutdowns
|
||||
|
||||
# Scheduler variables
|
||||
my $max_ndb= $childs / 2;
|
||||
@@ -450,7 +448,7 @@ sub run_test_server ($$$) {
|
||||
$s->remove($sock);
|
||||
if (--$childs == 0){
|
||||
$suite_timeout_proc->kill();
|
||||
return ($completed, $test_failure);
|
||||
return ($test_failure, $completed, $extra_warnings);
|
||||
}
|
||||
next;
|
||||
}
|
||||
@@ -519,14 +517,14 @@ sub run_test_server ($$$) {
|
||||
# Test has failed, force is off
|
||||
$suite_timeout_proc->kill();
|
||||
push(@$completed, $result);
|
||||
return ($completed, 1);
|
||||
return (1, $completed, $extra_warnings);
|
||||
}
|
||||
elsif ($opt_max_test_fail > 0 and
|
||||
$num_failed_test >= $opt_max_test_fail) {
|
||||
$suite_timeout_proc->kill();
|
||||
mtr_report("Too many tests($num_failed_test) failed!",
|
||||
"Terminating...");
|
||||
return (undef, 1);
|
||||
return (1, $completed, $extra_warnings);
|
||||
}
|
||||
$num_failed_test++;
|
||||
}
|
||||
@@ -580,13 +578,14 @@ sub run_test_server ($$$) {
|
||||
elsif ($line eq 'WARNINGS'){
|
||||
my $fake_test= My::Test::read_test($sock);
|
||||
my $test_list= join (" ", @{$fake_test->{testnames}});
|
||||
push @$extra_warnings, $test_list;
|
||||
mtr_report("***Warnings generated in error logs during shutdown ".
|
||||
"after running tests: $test_list");
|
||||
$test_failure= 1;
|
||||
if ( !$opt_force ) {
|
||||
# Test failure due to warnings, force is off
|
||||
$suite_timeout_proc->kill();
|
||||
return ($completed, 1);
|
||||
return (1, $completed, $extra_warnings);
|
||||
}
|
||||
} else {
|
||||
mtr_error("Unknown response: '$line' from client");
|
||||
@@ -666,7 +665,7 @@ sub run_test_server ($$$) {
|
||||
if ( ! $suite_timeout_proc->wait_one(0) )
|
||||
{
|
||||
mtr_report("Test suite timeout! Terminating...");
|
||||
return (undef, 1);
|
||||
return (1, $completed, $extra_warnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -758,7 +757,9 @@ sub run_worker ($) {
|
||||
}
|
||||
}
|
||||
|
||||
die "Internal error: should not reach this place.";
|
||||
stop_all_servers();
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@ create view v1 (c) as
|
||||
SELECT table_name 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';
|
||||
table_name<>'ndb_apply_status' AND
|
||||
NOT (table_schema = 'INFORMATION_SCHEMA' AND table_name LIKE 'PBXT_%');
|
||||
select * from v1;
|
||||
c
|
||||
CHARACTER_SETS
|
||||
@@ -850,10 +851,6 @@ VIEWS TABLE_NAME select
|
||||
delete from mysql.user where user='mysqltest_4';
|
||||
delete from mysql.db where user='mysqltest_4';
|
||||
flush privileges;
|
||||
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 28
|
||||
mysql 22
|
||||
create table t1 (i int, j int);
|
||||
create trigger trg1 before insert on t1 for each row
|
||||
begin
|
||||
@@ -1224,92 +1221,6 @@ f1()
|
||||
DROP FUNCTION f1;
|
||||
DROP PROCEDURE p1;
|
||||
DROP USER mysql_bug20230@localhost;
|
||||
SELECT t.table_name, c1.column_name
|
||||
FROM information_schema.tables t
|
||||
INNER JOIN
|
||||
information_schema.columns c1
|
||||
ON t.table_schema = c1.table_schema AND
|
||||
t.table_name = c1.table_name
|
||||
WHERE t.table_schema = 'information_schema' AND
|
||||
c1.ordinal_position =
|
||||
( SELECT COALESCE(MIN(c2.ordinal_position),1)
|
||||
FROM information_schema.columns c2
|
||||
WHERE c2.table_schema = t.table_schema AND
|
||||
c2.table_name = t.table_name AND
|
||||
c2.column_name LIKE '%SCHEMA%'
|
||||
);
|
||||
table_name column_name
|
||||
CHARACTER_SETS CHARACTER_SET_NAME
|
||||
COLLATIONS COLLATION_NAME
|
||||
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
|
||||
COLUMNS TABLE_SCHEMA
|
||||
COLUMN_PRIVILEGES TABLE_SCHEMA
|
||||
ENGINES ENGINE
|
||||
EVENTS EVENT_SCHEMA
|
||||
FILES TABLE_SCHEMA
|
||||
GLOBAL_STATUS VARIABLE_NAME
|
||||
GLOBAL_VARIABLES VARIABLE_NAME
|
||||
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
|
||||
PARTITIONS TABLE_SCHEMA
|
||||
PLUGINS PLUGIN_NAME
|
||||
PROCESSLIST ID
|
||||
PROFILING QUERY_ID
|
||||
REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
|
||||
ROUTINES ROUTINE_SCHEMA
|
||||
SCHEMATA SCHEMA_NAME
|
||||
SCHEMA_PRIVILEGES TABLE_SCHEMA
|
||||
SESSION_STATUS VARIABLE_NAME
|
||||
SESSION_VARIABLES VARIABLE_NAME
|
||||
STATISTICS TABLE_SCHEMA
|
||||
TABLES TABLE_SCHEMA
|
||||
TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
|
||||
TABLE_PRIVILEGES TABLE_SCHEMA
|
||||
TRIGGERS TRIGGER_SCHEMA
|
||||
USER_PRIVILEGES GRANTEE
|
||||
VIEWS TABLE_SCHEMA
|
||||
SELECT t.table_name, c1.column_name
|
||||
FROM information_schema.tables t
|
||||
INNER JOIN
|
||||
information_schema.columns c1
|
||||
ON t.table_schema = c1.table_schema AND
|
||||
t.table_name = c1.table_name
|
||||
WHERE t.table_schema = 'information_schema' AND
|
||||
c1.ordinal_position =
|
||||
( SELECT COALESCE(MIN(c2.ordinal_position),1)
|
||||
FROM information_schema.columns c2
|
||||
WHERE c2.table_schema = 'information_schema' AND
|
||||
c2.table_name = t.table_name AND
|
||||
c2.column_name LIKE '%SCHEMA%'
|
||||
);
|
||||
table_name column_name
|
||||
CHARACTER_SETS CHARACTER_SET_NAME
|
||||
COLLATIONS COLLATION_NAME
|
||||
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
|
||||
COLUMNS TABLE_SCHEMA
|
||||
COLUMN_PRIVILEGES TABLE_SCHEMA
|
||||
ENGINES ENGINE
|
||||
EVENTS EVENT_SCHEMA
|
||||
FILES TABLE_SCHEMA
|
||||
GLOBAL_STATUS VARIABLE_NAME
|
||||
GLOBAL_VARIABLES VARIABLE_NAME
|
||||
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
|
||||
PARTITIONS TABLE_SCHEMA
|
||||
PLUGINS PLUGIN_NAME
|
||||
PROCESSLIST ID
|
||||
PROFILING QUERY_ID
|
||||
REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
|
||||
ROUTINES ROUTINE_SCHEMA
|
||||
SCHEMATA SCHEMA_NAME
|
||||
SCHEMA_PRIVILEGES TABLE_SCHEMA
|
||||
SESSION_STATUS VARIABLE_NAME
|
||||
SESSION_VARIABLES VARIABLE_NAME
|
||||
STATISTICS TABLE_SCHEMA
|
||||
TABLES TABLE_SCHEMA
|
||||
TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
|
||||
TABLE_PRIVILEGES TABLE_SCHEMA
|
||||
TRIGGERS TRIGGER_SCHEMA
|
||||
USER_PRIVILEGES GRANTEE
|
||||
VIEWS TABLE_SCHEMA
|
||||
SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test');
|
||||
MAX(table_name)
|
||||
VIEWS
|
||||
@@ -1355,55 +1266,6 @@ table_name
|
||||
t1
|
||||
t2
|
||||
drop table t1,t2;
|
||||
select 1 as f1 from information_schema.tables where "CHARACTER_SETS"=
|
||||
(select cast(table_name as char) from information_schema.tables
|
||||
order by table_name limit 1) limit 1;
|
||||
f1
|
||||
1
|
||||
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
|
||||
count(*) as num1
|
||||
from information_schema.tables t
|
||||
inner join information_schema.columns c1
|
||||
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
|
||||
where t.table_schema = 'information_schema' and
|
||||
c1.ordinal_position =
|
||||
(select isnull(c2.column_type) -
|
||||
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
|
||||
count(*) as num
|
||||
from information_schema.columns c2 where
|
||||
c2.table_schema='information_schema' and
|
||||
(c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)')
|
||||
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
|
||||
COLLATIONS information_schema.COLLATIONS 1
|
||||
COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
|
||||
COLUMNS information_schema.COLUMNS 1
|
||||
COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
|
||||
ENGINES information_schema.ENGINES 1
|
||||
EVENTS information_schema.EVENTS 1
|
||||
FILES information_schema.FILES 1
|
||||
GLOBAL_STATUS information_schema.GLOBAL_STATUS 1
|
||||
GLOBAL_VARIABLES information_schema.GLOBAL_VARIABLES 1
|
||||
KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
|
||||
PARTITIONS information_schema.PARTITIONS 1
|
||||
PLUGINS information_schema.PLUGINS 1
|
||||
PROCESSLIST information_schema.PROCESSLIST 1
|
||||
PROFILING information_schema.PROFILING 1
|
||||
REFERENTIAL_CONSTRAINTS information_schema.REFERENTIAL_CONSTRAINTS 1
|
||||
ROUTINES information_schema.ROUTINES 1
|
||||
SCHEMATA information_schema.SCHEMATA 1
|
||||
SCHEMA_PRIVILEGES information_schema.SCHEMA_PRIVILEGES 1
|
||||
SESSION_STATUS information_schema.SESSION_STATUS 1
|
||||
SESSION_VARIABLES information_schema.SESSION_VARIABLES 1
|
||||
STATISTICS information_schema.STATISTICS 1
|
||||
TABLES information_schema.TABLES 1
|
||||
TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
|
||||
TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
|
||||
TRIGGERS information_schema.TRIGGERS 1
|
||||
USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
|
||||
VIEWS information_schema.VIEWS 1
|
||||
create table t1(f1 int);
|
||||
create view v1 as select f1+1 as a from t1;
|
||||
create table t2 (f1 int, f2 int);
|
||||
|
||||
248
mysql-test/r/information_schema_all_engines.result
Normal file
248
mysql-test/r/information_schema_all_engines.result
Normal file
@@ -0,0 +1,248 @@
|
||||
use INFORMATION_SCHEMA;
|
||||
show tables;
|
||||
Tables_in_information_schema
|
||||
CHARACTER_SETS
|
||||
COLLATIONS
|
||||
COLLATION_CHARACTER_SET_APPLICABILITY
|
||||
COLUMNS
|
||||
COLUMN_PRIVILEGES
|
||||
ENGINES
|
||||
EVENTS
|
||||
FILES
|
||||
GLOBAL_STATUS
|
||||
GLOBAL_VARIABLES
|
||||
KEY_COLUMN_USAGE
|
||||
PARTITIONS
|
||||
PLUGINS
|
||||
PROCESSLIST
|
||||
PROFILING
|
||||
REFERENTIAL_CONSTRAINTS
|
||||
ROUTINES
|
||||
SCHEMATA
|
||||
SCHEMA_PRIVILEGES
|
||||
SESSION_STATUS
|
||||
SESSION_VARIABLES
|
||||
STATISTICS
|
||||
TABLES
|
||||
TABLE_CONSTRAINTS
|
||||
TABLE_PRIVILEGES
|
||||
TRIGGERS
|
||||
USER_PRIVILEGES
|
||||
VIEWS
|
||||
PBXT_STATISTICS
|
||||
SELECT t.table_name, c1.column_name
|
||||
FROM information_schema.tables t
|
||||
INNER JOIN
|
||||
information_schema.columns c1
|
||||
ON t.table_schema = c1.table_schema AND
|
||||
t.table_name = c1.table_name
|
||||
WHERE t.table_schema = 'information_schema' AND
|
||||
c1.ordinal_position =
|
||||
( SELECT COALESCE(MIN(c2.ordinal_position),1)
|
||||
FROM information_schema.columns c2
|
||||
WHERE c2.table_schema = t.table_schema AND
|
||||
c2.table_name = t.table_name AND
|
||||
c2.column_name LIKE '%SCHEMA%'
|
||||
);
|
||||
table_name column_name
|
||||
CHARACTER_SETS CHARACTER_SET_NAME
|
||||
COLLATIONS COLLATION_NAME
|
||||
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
|
||||
COLUMNS TABLE_SCHEMA
|
||||
COLUMN_PRIVILEGES TABLE_SCHEMA
|
||||
ENGINES ENGINE
|
||||
EVENTS EVENT_SCHEMA
|
||||
FILES TABLE_SCHEMA
|
||||
GLOBAL_STATUS VARIABLE_NAME
|
||||
GLOBAL_VARIABLES VARIABLE_NAME
|
||||
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
|
||||
PARTITIONS TABLE_SCHEMA
|
||||
PLUGINS PLUGIN_NAME
|
||||
PROCESSLIST ID
|
||||
PROFILING QUERY_ID
|
||||
REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
|
||||
ROUTINES ROUTINE_SCHEMA
|
||||
SCHEMATA SCHEMA_NAME
|
||||
SCHEMA_PRIVILEGES TABLE_SCHEMA
|
||||
SESSION_STATUS VARIABLE_NAME
|
||||
SESSION_VARIABLES VARIABLE_NAME
|
||||
STATISTICS TABLE_SCHEMA
|
||||
TABLES TABLE_SCHEMA
|
||||
TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
|
||||
TABLE_PRIVILEGES TABLE_SCHEMA
|
||||
TRIGGERS TRIGGER_SCHEMA
|
||||
USER_PRIVILEGES GRANTEE
|
||||
VIEWS TABLE_SCHEMA
|
||||
PBXT_STATISTICS ID
|
||||
SELECT t.table_name, c1.column_name
|
||||
FROM information_schema.tables t
|
||||
INNER JOIN
|
||||
information_schema.columns c1
|
||||
ON t.table_schema = c1.table_schema AND
|
||||
t.table_name = c1.table_name
|
||||
WHERE t.table_schema = 'information_schema' AND
|
||||
c1.ordinal_position =
|
||||
( SELECT COALESCE(MIN(c2.ordinal_position),1)
|
||||
FROM information_schema.columns c2
|
||||
WHERE c2.table_schema = 'information_schema' AND
|
||||
c2.table_name = t.table_name AND
|
||||
c2.column_name LIKE '%SCHEMA%'
|
||||
);
|
||||
table_name column_name
|
||||
CHARACTER_SETS CHARACTER_SET_NAME
|
||||
COLLATIONS COLLATION_NAME
|
||||
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
|
||||
COLUMNS TABLE_SCHEMA
|
||||
COLUMN_PRIVILEGES TABLE_SCHEMA
|
||||
ENGINES ENGINE
|
||||
EVENTS EVENT_SCHEMA
|
||||
FILES TABLE_SCHEMA
|
||||
GLOBAL_STATUS VARIABLE_NAME
|
||||
GLOBAL_VARIABLES VARIABLE_NAME
|
||||
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
|
||||
PARTITIONS TABLE_SCHEMA
|
||||
PLUGINS PLUGIN_NAME
|
||||
PROCESSLIST ID
|
||||
PROFILING QUERY_ID
|
||||
REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
|
||||
ROUTINES ROUTINE_SCHEMA
|
||||
SCHEMATA SCHEMA_NAME
|
||||
SCHEMA_PRIVILEGES TABLE_SCHEMA
|
||||
SESSION_STATUS VARIABLE_NAME
|
||||
SESSION_VARIABLES VARIABLE_NAME
|
||||
STATISTICS TABLE_SCHEMA
|
||||
TABLES TABLE_SCHEMA
|
||||
TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
|
||||
TABLE_PRIVILEGES TABLE_SCHEMA
|
||||
TRIGGERS TRIGGER_SCHEMA
|
||||
USER_PRIVILEGES GRANTEE
|
||||
VIEWS TABLE_SCHEMA
|
||||
PBXT_STATISTICS ID
|
||||
select 1 as f1 from information_schema.tables where "CHARACTER_SETS"=
|
||||
(select cast(table_name as char) from information_schema.tables
|
||||
order by table_name limit 1) limit 1;
|
||||
f1
|
||||
1
|
||||
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
|
||||
count(*) as num1
|
||||
from information_schema.tables t
|
||||
inner join information_schema.columns c1
|
||||
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
|
||||
where t.table_schema = 'information_schema' and
|
||||
c1.ordinal_position =
|
||||
(select isnull(c2.column_type) -
|
||||
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
|
||||
count(*) as num
|
||||
from information_schema.columns c2 where
|
||||
c2.table_schema='information_schema' and
|
||||
(c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)')
|
||||
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
|
||||
COLLATIONS information_schema.COLLATIONS 1
|
||||
COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
|
||||
COLUMNS information_schema.COLUMNS 1
|
||||
COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
|
||||
ENGINES information_schema.ENGINES 1
|
||||
EVENTS information_schema.EVENTS 1
|
||||
FILES information_schema.FILES 1
|
||||
GLOBAL_STATUS information_schema.GLOBAL_STATUS 1
|
||||
GLOBAL_VARIABLES information_schema.GLOBAL_VARIABLES 1
|
||||
KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
|
||||
PARTITIONS information_schema.PARTITIONS 1
|
||||
PBXT_STATISTICS information_schema.PBXT_STATISTICS 1
|
||||
PLUGINS information_schema.PLUGINS 1
|
||||
PROCESSLIST information_schema.PROCESSLIST 1
|
||||
PROFILING information_schema.PROFILING 1
|
||||
REFERENTIAL_CONSTRAINTS information_schema.REFERENTIAL_CONSTRAINTS 1
|
||||
ROUTINES information_schema.ROUTINES 1
|
||||
SCHEMATA information_schema.SCHEMATA 1
|
||||
SCHEMA_PRIVILEGES information_schema.SCHEMA_PRIVILEGES 1
|
||||
SESSION_STATUS information_schema.SESSION_STATUS 1
|
||||
SESSION_VARIABLES information_schema.SESSION_VARIABLES 1
|
||||
STATISTICS information_schema.STATISTICS 1
|
||||
TABLES information_schema.TABLES 1
|
||||
TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
|
||||
TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
|
||||
TRIGGERS information_schema.TRIGGERS 1
|
||||
USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
|
||||
VIEWS information_schema.VIEWS 1
|
||||
Database: information_schema
|
||||
+---------------------------------------+
|
||||
| Tables |
|
||||
+---------------------------------------+
|
||||
| CHARACTER_SETS |
|
||||
| COLLATIONS |
|
||||
| COLLATION_CHARACTER_SET_APPLICABILITY |
|
||||
| COLUMNS |
|
||||
| COLUMN_PRIVILEGES |
|
||||
| ENGINES |
|
||||
| EVENTS |
|
||||
| FILES |
|
||||
| GLOBAL_STATUS |
|
||||
| GLOBAL_VARIABLES |
|
||||
| KEY_COLUMN_USAGE |
|
||||
| PARTITIONS |
|
||||
| PLUGINS |
|
||||
| PROCESSLIST |
|
||||
| PROFILING |
|
||||
| REFERENTIAL_CONSTRAINTS |
|
||||
| ROUTINES |
|
||||
| SCHEMATA |
|
||||
| SCHEMA_PRIVILEGES |
|
||||
| SESSION_STATUS |
|
||||
| SESSION_VARIABLES |
|
||||
| STATISTICS |
|
||||
| TABLES |
|
||||
| TABLE_CONSTRAINTS |
|
||||
| TABLE_PRIVILEGES |
|
||||
| TRIGGERS |
|
||||
| USER_PRIVILEGES |
|
||||
| VIEWS |
|
||||
| PBXT_STATISTICS |
|
||||
+---------------------------------------+
|
||||
Database: INFORMATION_SCHEMA
|
||||
+---------------------------------------+
|
||||
| Tables |
|
||||
+---------------------------------------+
|
||||
| CHARACTER_SETS |
|
||||
| COLLATIONS |
|
||||
| COLLATION_CHARACTER_SET_APPLICABILITY |
|
||||
| COLUMNS |
|
||||
| COLUMN_PRIVILEGES |
|
||||
| ENGINES |
|
||||
| EVENTS |
|
||||
| FILES |
|
||||
| GLOBAL_STATUS |
|
||||
| GLOBAL_VARIABLES |
|
||||
| KEY_COLUMN_USAGE |
|
||||
| PARTITIONS |
|
||||
| PLUGINS |
|
||||
| PROCESSLIST |
|
||||
| PROFILING |
|
||||
| REFERENTIAL_CONSTRAINTS |
|
||||
| ROUTINES |
|
||||
| SCHEMATA |
|
||||
| SCHEMA_PRIVILEGES |
|
||||
| SESSION_STATUS |
|
||||
| SESSION_VARIABLES |
|
||||
| STATISTICS |
|
||||
| TABLES |
|
||||
| TABLE_CONSTRAINTS |
|
||||
| TABLE_PRIVILEGES |
|
||||
| TRIGGERS |
|
||||
| USER_PRIVILEGES |
|
||||
| VIEWS |
|
||||
| PBXT_STATISTICS |
|
||||
+---------------------------------------+
|
||||
Wildcard: inf_rmation_schema
|
||||
+--------------------+
|
||||
| Databases |
|
||||
+--------------------+
|
||||
| information_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 29
|
||||
mysql 22
|
||||
@@ -2,37 +2,6 @@ drop table if exists t1,t2;
|
||||
drop view if exists v1,v2;
|
||||
drop function if exists f1;
|
||||
drop function if exists f2;
|
||||
use INFORMATION_SCHEMA;
|
||||
show tables;
|
||||
Tables_in_information_schema
|
||||
CHARACTER_SETS
|
||||
COLLATIONS
|
||||
COLLATION_CHARACTER_SET_APPLICABILITY
|
||||
COLUMNS
|
||||
COLUMN_PRIVILEGES
|
||||
ENGINES
|
||||
EVENTS
|
||||
FILES
|
||||
GLOBAL_STATUS
|
||||
GLOBAL_VARIABLES
|
||||
KEY_COLUMN_USAGE
|
||||
PARTITIONS
|
||||
PLUGINS
|
||||
PROCESSLIST
|
||||
PROFILING
|
||||
REFERENTIAL_CONSTRAINTS
|
||||
ROUTINES
|
||||
SCHEMATA
|
||||
SCHEMA_PRIVILEGES
|
||||
SESSION_STATUS
|
||||
SESSION_VARIABLES
|
||||
STATISTICS
|
||||
TABLES
|
||||
TABLE_CONSTRAINTS
|
||||
TABLE_PRIVILEGES
|
||||
TRIGGERS
|
||||
USER_PRIVILEGES
|
||||
VIEWS
|
||||
show tables from INFORMATION_SCHEMA like 'T%';
|
||||
Tables_in_information_schema (T%)
|
||||
TABLES
|
||||
|
||||
@@ -197,7 +197,7 @@ c1 c2
|
||||
5 9
|
||||
DROP TABLE t1;
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 100
|
||||
auto_increment_offset 10
|
||||
@@ -230,7 +230,7 @@ c1
|
||||
DROP TABLE t1;
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||
SET @@INSERT_ID=1;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 1
|
||||
auto_increment_offset 1
|
||||
@@ -269,7 +269,7 @@ c1
|
||||
DROP TABLE t1;
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||
SET @@INSERT_ID=1;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 1
|
||||
auto_increment_offset 1
|
||||
@@ -282,7 +282,7 @@ SELECT * FROM t1;
|
||||
c1
|
||||
-1
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 100
|
||||
auto_increment_offset 10
|
||||
@@ -315,7 +315,7 @@ c1
|
||||
DROP TABLE t1;
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||
SET @@INSERT_ID=1;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 1
|
||||
auto_increment_offset 1
|
||||
@@ -330,7 +330,7 @@ SELECT * FROM t1;
|
||||
c1
|
||||
1
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 100
|
||||
auto_increment_offset 10
|
||||
@@ -370,7 +370,7 @@ c1
|
||||
DROP TABLE t1;
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||
SET @@INSERT_ID=1;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 1
|
||||
auto_increment_offset 1
|
||||
@@ -385,7 +385,7 @@ SELECT * FROM t1;
|
||||
c1
|
||||
1
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 100
|
||||
auto_increment_offset 10
|
||||
@@ -419,7 +419,7 @@ c1
|
||||
DROP TABLE t1;
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||
SET @@INSERT_ID=1;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 1
|
||||
auto_increment_offset 1
|
||||
@@ -434,7 +434,7 @@ c1
|
||||
1
|
||||
9223372036854775794
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 2
|
||||
auto_increment_offset 10
|
||||
@@ -452,7 +452,7 @@ c1
|
||||
DROP TABLE t1;
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||
SET @@INSERT_ID=1;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 1
|
||||
auto_increment_offset 1
|
||||
@@ -467,7 +467,7 @@ c1
|
||||
1
|
||||
18446744073709551603
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 2
|
||||
auto_increment_offset 10
|
||||
@@ -485,7 +485,7 @@ c1
|
||||
DROP TABLE t1;
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||
SET @@INSERT_ID=1;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 1
|
||||
auto_increment_offset 1
|
||||
@@ -500,7 +500,7 @@ c1
|
||||
1
|
||||
18446744073709551603
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=5, @@SESSION.AUTO_INCREMENT_OFFSET=7;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 5
|
||||
auto_increment_offset 7
|
||||
@@ -514,7 +514,7 @@ c1
|
||||
DROP TABLE t1;
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||
SET @@INSERT_ID=1;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 1
|
||||
auto_increment_offset 1
|
||||
@@ -533,7 +533,7 @@ c1
|
||||
-9223372036854775806
|
||||
1
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=3, @@SESSION.AUTO_INCREMENT_OFFSET=3;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 3
|
||||
auto_increment_offset 3
|
||||
@@ -550,7 +550,7 @@ c1
|
||||
DROP TABLE t1;
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||
SET @@INSERT_ID=1;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 1
|
||||
auto_increment_offset 1
|
||||
@@ -568,7 +568,7 @@ SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCRE
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect auto_increment_increment value: '1152921504606846976'
|
||||
Warning 1292 Truncated incorrect auto_increment_offset value: '1152921504606846976'
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
SHOW VARIABLES LIKE "auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 65535
|
||||
auto_increment_offset 65535
|
||||
|
||||
@@ -75,76 +75,4 @@ Database: test
|
||||
2 rows in set.
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
Database: information_schema
|
||||
+---------------------------------------+
|
||||
| Tables |
|
||||
+---------------------------------------+
|
||||
| CHARACTER_SETS |
|
||||
| COLLATIONS |
|
||||
| COLLATION_CHARACTER_SET_APPLICABILITY |
|
||||
| COLUMNS |
|
||||
| COLUMN_PRIVILEGES |
|
||||
| ENGINES |
|
||||
| EVENTS |
|
||||
| FILES |
|
||||
| GLOBAL_STATUS |
|
||||
| GLOBAL_VARIABLES |
|
||||
| KEY_COLUMN_USAGE |
|
||||
| PARTITIONS |
|
||||
| PLUGINS |
|
||||
| PROCESSLIST |
|
||||
| PROFILING |
|
||||
| REFERENTIAL_CONSTRAINTS |
|
||||
| ROUTINES |
|
||||
| SCHEMATA |
|
||||
| SCHEMA_PRIVILEGES |
|
||||
| SESSION_STATUS |
|
||||
| SESSION_VARIABLES |
|
||||
| STATISTICS |
|
||||
| TABLES |
|
||||
| TABLE_CONSTRAINTS |
|
||||
| TABLE_PRIVILEGES |
|
||||
| TRIGGERS |
|
||||
| USER_PRIVILEGES |
|
||||
| VIEWS |
|
||||
+---------------------------------------+
|
||||
Database: INFORMATION_SCHEMA
|
||||
+---------------------------------------+
|
||||
| Tables |
|
||||
+---------------------------------------+
|
||||
| CHARACTER_SETS |
|
||||
| COLLATIONS |
|
||||
| COLLATION_CHARACTER_SET_APPLICABILITY |
|
||||
| COLUMNS |
|
||||
| COLUMN_PRIVILEGES |
|
||||
| ENGINES |
|
||||
| EVENTS |
|
||||
| FILES |
|
||||
| GLOBAL_STATUS |
|
||||
| GLOBAL_VARIABLES |
|
||||
| KEY_COLUMN_USAGE |
|
||||
| PARTITIONS |
|
||||
| PLUGINS |
|
||||
| PROCESSLIST |
|
||||
| PROFILING |
|
||||
| REFERENTIAL_CONSTRAINTS |
|
||||
| ROUTINES |
|
||||
| SCHEMATA |
|
||||
| SCHEMA_PRIVILEGES |
|
||||
| SESSION_STATUS |
|
||||
| SESSION_VARIABLES |
|
||||
| STATISTICS |
|
||||
| TABLES |
|
||||
| TABLE_CONSTRAINTS |
|
||||
| TABLE_PRIVILEGES |
|
||||
| TRIGGERS |
|
||||
| USER_PRIVILEGES |
|
||||
| VIEWS |
|
||||
+---------------------------------------+
|
||||
Wildcard: inf_rmation_schema
|
||||
+--------------------+
|
||||
| Databases |
|
||||
+--------------------+
|
||||
| information_schema |
|
||||
+--------------------+
|
||||
End of 5.0 tests
|
||||
|
||||
75
mysql-test/suite/pbxt/r/alias.result
Normal file
75
mysql-test/suite/pbxt/r/alias.result
Normal file
@@ -0,0 +1,75 @@
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (
|
||||
cont_nr int(11) NOT NULL auto_increment,
|
||||
ver_nr int(11) NOT NULL default '0',
|
||||
aufnr int(11) NOT NULL default '0',
|
||||
username varchar(50) NOT NULL default '',
|
||||
hdl_nr int(11) NOT NULL default '0',
|
||||
eintrag date NOT NULL default '0000-00-00',
|
||||
st_klasse varchar(40) NOT NULL default '',
|
||||
st_wert varchar(40) NOT NULL default '',
|
||||
st_zusatz varchar(40) NOT NULL default '',
|
||||
st_bemerkung varchar(255) NOT NULL default '',
|
||||
kunden_art varchar(40) NOT NULL default '',
|
||||
mcbs_knr int(11) default NULL,
|
||||
mcbs_aufnr int(11) NOT NULL default '0',
|
||||
schufa_status char(1) default '?',
|
||||
bemerkung text,
|
||||
wirknetz text,
|
||||
wf_igz int(11) NOT NULL default '0',
|
||||
tarifcode varchar(80) default NULL,
|
||||
recycle char(1) default NULL,
|
||||
sim varchar(30) default NULL,
|
||||
mcbs_tpl varchar(30) default NULL,
|
||||
emp_nr int(11) NOT NULL default '0',
|
||||
laufzeit int(11) default NULL,
|
||||
hdl_name varchar(30) default NULL,
|
||||
prov_hdl_nr int(11) NOT NULL default '0',
|
||||
auto_wirknetz varchar(50) default NULL,
|
||||
auto_billing varchar(50) default NULL,
|
||||
touch timestamp NOT NULL,
|
||||
kategorie varchar(50) default NULL,
|
||||
kundentyp varchar(20) NOT NULL default '',
|
||||
sammel_rech_msisdn varchar(30) NOT NULL default '',
|
||||
p_nr varchar(9) NOT NULL default '',
|
||||
suffix char(3) NOT NULL default '',
|
||||
PRIMARY KEY (cont_nr),
|
||||
KEY idx_aufnr(aufnr),
|
||||
KEY idx_hdl_nr(hdl_nr),
|
||||
KEY idx_st_klasse(st_klasse),
|
||||
KEY ver_nr(ver_nr),
|
||||
KEY eintrag_idx(eintrag),
|
||||
KEY emp_nr_idx(emp_nr),
|
||||
KEY wf_igz(wf_igz),
|
||||
KEY touch(touch),
|
||||
KEY hdl_tag(eintrag,hdl_nr),
|
||||
KEY prov_hdl_nr(prov_hdl_nr),
|
||||
KEY mcbs_aufnr(mcbs_aufnr),
|
||||
KEY kundentyp(kundentyp),
|
||||
KEY p_nr(p_nr,suffix)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (3359356,405,3359356,'Mustermann Musterfrau',52500,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und gepr<70>ft','','privat',1485525,2122316,'+','','N',1909160,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',3,24,'MobilCom Shop Koeln',52500,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
|
||||
INSERT INTO t1 VALUES (3359357,468,3359357,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und gepr<70>ft','','privat',1503580,2139699,'+','','P',1909171,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
|
||||
INSERT INTO t1 VALUES (3359358,407,3359358,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und gepr<70>ft','','privat',1501358,2137473,'N','','N',1909159,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
|
||||
INSERT INTO t1 VALUES (3359359,468,3359359,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und gepr<70>ft','','privat',1507831,2143894,'+','','P',1909162,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
|
||||
INSERT INTO t1 VALUES (3359360,0,0,'Mustermann Musterfrau',29674907,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und gepr<70>ft','','privat',1900169997,2414578,'+',NULL,'N',1909148,'',NULL,NULL,'RV99066_2',20,NULL,'POS',29674907,NULL,NULL,20010202105916,'Mobilfunk','','','97317481','007');
|
||||
INSERT INTO t1 VALUES (3359361,406,3359361,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag storniert','','(7001-84):Storno, Kd. m<>chte nicht mehr','privat',NULL,0,'+','','P',1909150,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
|
||||
INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und gepr<70>ft','','privat',1509984,2145874,'+','','P',1909154,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
|
||||
SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie;
|
||||
Kundentyp kategorie
|
||||
Privat (Private Nutzung) Mobilfunk
|
||||
Warnings:
|
||||
Warning 1052 Column 'kundentyp' in group statement is ambiguous
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
AUFNR varchar(12) NOT NULL default '',
|
||||
PLNFL varchar(6) NOT NULL default '',
|
||||
VORNR varchar(4) NOT NULL default '',
|
||||
xstatus_vor smallint(5) unsigned NOT NULL default '0'
|
||||
);
|
||||
INSERT INTO t1 VALUES ('40004712','000001','0010',9);
|
||||
INSERT INTO t1 VALUES ('40004712','000001','0020',0);
|
||||
UPDATE t1 SET t1.xstatus_vor = Greatest(t1.xstatus_vor,1) WHERE t1.aufnr =
|
||||
"40004712" AND t1.plnfl = "000001" AND t1.vornr > "0010" ORDER BY t1.vornr
|
||||
ASC LIMIT 1;
|
||||
drop table t1;
|
||||
913
mysql-test/suite/pbxt/r/alter_table.result
Normal file
913
mysql-test/suite/pbxt/r/alter_table.result
Normal file
@@ -0,0 +1,913 @@
|
||||
drop table if exists t1,t2;
|
||||
drop database if exists mysqltest;
|
||||
create table t1 (
|
||||
col1 int not null auto_increment primary key,
|
||||
col2 varchar(30) not null,
|
||||
col3 varchar (20) not null,
|
||||
col4 varchar(4) not null,
|
||||
col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
|
||||
col6 int not null, to_be_deleted int);
|
||||
insert into t1 values (2,4,3,5,"PENDING",1,7);
|
||||
alter table t1
|
||||
add column col4_5 varchar(20) not null after col4,
|
||||
add column col7 varchar(30) not null after col5,
|
||||
add column col8 datetime not null, drop column to_be_deleted,
|
||||
change column col2 fourth varchar(30) not null after col3,
|
||||
modify column col6 int not null first;
|
||||
select * from t1;
|
||||
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
|
||||
1 2 3 4 5 PENDING 0000-00-00 00:00:00
|
||||
drop table t1;
|
||||
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
|
||||
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
|
||||
alter table t1 add column new_col int, order by payoutid,bandid;
|
||||
select * from t1;
|
||||
bandID payoutID new_col
|
||||
6 1 NULL
|
||||
3 4 NULL
|
||||
1 6 NULL
|
||||
2 6 NULL
|
||||
4 9 NULL
|
||||
5 10 NULL
|
||||
7 12 NULL
|
||||
8 12 NULL
|
||||
alter table t1 order by bandid,payoutid;
|
||||
select * from t1;
|
||||
bandID payoutID new_col
|
||||
1 6 NULL
|
||||
2 6 NULL
|
||||
3 4 NULL
|
||||
4 9 NULL
|
||||
5 10 NULL
|
||||
6 1 NULL
|
||||
7 12 NULL
|
||||
8 12 NULL
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
GROUP_ID int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
LANG_ID smallint(5) unsigned DEFAULT '0' NOT NULL,
|
||||
NAME varchar(80) DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (GROUP_ID,LANG_ID),
|
||||
KEY NAME (NAME));
|
||||
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
|
||||
SHOW FULL COLUMNS FROM t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
GROUP_ID int(10) unsigned NULL NO PRI 0 #
|
||||
LANG_ID smallint(5) unsigned NULL NO PRI 0 #
|
||||
NAME char(80) latin1_swedish_ci NO MUL NULL #
|
||||
DROP TABLE t1;
|
||||
create table t1 (n int);
|
||||
insert into t1 values(9),(3),(12),(10);
|
||||
alter table t1 order by n;
|
||||
select * from t1;
|
||||
n
|
||||
3
|
||||
9
|
||||
10
|
||||
12
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
id int(11) unsigned NOT NULL default '0',
|
||||
category_id tinyint(4) unsigned NOT NULL default '0',
|
||||
type_id tinyint(4) unsigned NOT NULL default '0',
|
||||
body text NOT NULL,
|
||||
user_id int(11) unsigned NOT NULL default '0',
|
||||
status enum('new','old') NOT NULL default 'new',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=MyISAM;
|
||||
ALTER TABLE t1 ORDER BY t1.id, t1.status, t1.type_id, t1.user_id, t1.body;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (AnamneseId int(10) unsigned NOT NULL auto_increment,B BLOB,PRIMARY KEY (AnamneseId)) engine=myisam;
|
||||
insert into t1 values (null,"hello");
|
||||
LOCK TABLES t1 WRITE;
|
||||
ALTER TABLE t1 ADD Column new_col int not null;
|
||||
UNLOCK TABLES;
|
||||
OPTIMIZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize status OK
|
||||
DROP TABLE t1;
|
||||
create table t1 (i int unsigned not null auto_increment primary key);
|
||||
insert into t1 values (null),(null),(null),(null);
|
||||
alter table t1 drop i,add i int unsigned not null auto_increment, drop primary key, add primary key (i);
|
||||
select * from t1;
|
||||
i
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
drop table t1;
|
||||
create table t1 (name char(15));
|
||||
insert into t1 (name) values ("current");
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (name char(15));
|
||||
insert into mysqltest.t1 (name) values ("mysqltest");
|
||||
select * from t1;
|
||||
name
|
||||
current
|
||||
select * from mysqltest.t1;
|
||||
name
|
||||
mysqltest
|
||||
alter table t1 rename mysqltest.t1;
|
||||
ERROR 42S01: Table 't1' already exists
|
||||
select * from t1;
|
||||
name
|
||||
current
|
||||
select * from mysqltest.t1;
|
||||
name
|
||||
mysqltest
|
||||
drop table t1;
|
||||
drop database mysqltest;
|
||||
create table t1 (n1 int not null, n2 int, n3 int, n4 float,
|
||||
unique(n1),
|
||||
key (n1, n2, n3, n4),
|
||||
key (n2, n3, n4, n1),
|
||||
key (n3, n4, n1, n2),
|
||||
key (n4, n1, n2, n3) );
|
||||
alter table t1 disable keys;
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 n1 1 n1 NULL 0 NULL NULL BTREE
|
||||
t1 1 n1_2 1 n1 NULL NULL NULL NULL BTREE
|
||||
t1 1 n1_2 2 n2 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n1_2 3 n3 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n1_2 4 n4 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n2 1 n2 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n2 2 n3 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n2 3 n4 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n2 4 n1 NULL NULL NULL NULL BTREE
|
||||
t1 1 n3 1 n3 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n3 2 n4 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n3 3 n1 NULL NULL NULL NULL BTREE
|
||||
t1 1 n3 4 n2 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n4 1 n4 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n4 2 n1 NULL NULL NULL NULL BTREE
|
||||
t1 1 n4 3 n2 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n4 4 n3 NULL NULL NULL NULL YES BTREE
|
||||
insert into t1 values(10,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(9,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(8,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(7,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(6,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(5,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(4,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(3,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(2,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(1,RAND()*1000,RAND()*1000,RAND());
|
||||
alter table t1 enable keys;
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 n1 1 n1 NULL 10 NULL NULL BTREE
|
||||
t1 1 n1_2 1 n1 NULL NULL NULL NULL BTREE
|
||||
t1 1 n1_2 2 n2 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n1_2 3 n3 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n1_2 4 n4 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n2 1 n2 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n2 2 n3 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n2 3 n4 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n2 4 n1 NULL NULL NULL NULL BTREE
|
||||
t1 1 n3 1 n3 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n3 2 n4 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n3 3 n1 NULL NULL NULL NULL BTREE
|
||||
t1 1 n3 4 n2 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n4 1 n4 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n4 2 n1 NULL NULL NULL NULL BTREE
|
||||
t1 1 n4 3 n2 NULL NULL NULL NULL YES BTREE
|
||||
t1 1 n4 4 n3 NULL NULL NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
create table t1 (i int unsigned not null auto_increment primary key);
|
||||
alter table t1 rename t2;
|
||||
alter table t2 rename t1, add c char(10) comment "no comment";
|
||||
show columns from t1;
|
||||
Field Type Null Key Default Extra
|
||||
i int(10) unsigned NO PRI NULL auto_increment
|
||||
c char(10) YES NULL
|
||||
drop table t1;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values(1,100), (2,100), (3, 100);
|
||||
insert into t1 values(1,99), (2,99), (3, 99);
|
||||
insert into t1 values(1,98), (2,98), (3, 98);
|
||||
insert into t1 values(1,97), (2,97), (3, 97);
|
||||
insert into t1 values(1,96), (2,96), (3, 96);
|
||||
insert into t1 values(1,95), (2,95), (3, 95);
|
||||
insert into t1 values(1,94), (2,94), (3, 94);
|
||||
insert into t1 values(1,93), (2,93), (3, 93);
|
||||
insert into t1 values(1,92), (2,92), (3, 92);
|
||||
insert into t1 values(1,91), (2,91), (3, 91);
|
||||
insert into t1 values(1,90), (2,90), (3, 90);
|
||||
insert into t1 values(1,89), (2,89), (3, 89);
|
||||
insert into t1 values(1,88), (2,88), (3, 88);
|
||||
insert into t1 values(1,87), (2,87), (3, 87);
|
||||
insert into t1 values(1,86), (2,86), (3, 86);
|
||||
insert into t1 values(1,85), (2,85), (3, 85);
|
||||
insert into t1 values(1,84), (2,84), (3, 84);
|
||||
insert into t1 values(1,83), (2,83), (3, 83);
|
||||
insert into t1 values(1,82), (2,82), (3, 82);
|
||||
insert into t1 values(1,81), (2,81), (3, 81);
|
||||
insert into t1 values(1,80), (2,80), (3, 80);
|
||||
insert into t1 values(1,79), (2,79), (3, 79);
|
||||
insert into t1 values(1,78), (2,78), (3, 78);
|
||||
insert into t1 values(1,77), (2,77), (3, 77);
|
||||
insert into t1 values(1,76), (2,76), (3, 76);
|
||||
insert into t1 values(1,75), (2,75), (3, 75);
|
||||
insert into t1 values(1,74), (2,74), (3, 74);
|
||||
insert into t1 values(1,73), (2,73), (3, 73);
|
||||
insert into t1 values(1,72), (2,72), (3, 72);
|
||||
insert into t1 values(1,71), (2,71), (3, 71);
|
||||
insert into t1 values(1,70), (2,70), (3, 70);
|
||||
insert into t1 values(1,69), (2,69), (3, 69);
|
||||
insert into t1 values(1,68), (2,68), (3, 68);
|
||||
insert into t1 values(1,67), (2,67), (3, 67);
|
||||
insert into t1 values(1,66), (2,66), (3, 66);
|
||||
insert into t1 values(1,65), (2,65), (3, 65);
|
||||
insert into t1 values(1,64), (2,64), (3, 64);
|
||||
insert into t1 values(1,63), (2,63), (3, 63);
|
||||
insert into t1 values(1,62), (2,62), (3, 62);
|
||||
insert into t1 values(1,61), (2,61), (3, 61);
|
||||
insert into t1 values(1,60), (2,60), (3, 60);
|
||||
insert into t1 values(1,59), (2,59), (3, 59);
|
||||
insert into t1 values(1,58), (2,58), (3, 58);
|
||||
insert into t1 values(1,57), (2,57), (3, 57);
|
||||
insert into t1 values(1,56), (2,56), (3, 56);
|
||||
insert into t1 values(1,55), (2,55), (3, 55);
|
||||
insert into t1 values(1,54), (2,54), (3, 54);
|
||||
insert into t1 values(1,53), (2,53), (3, 53);
|
||||
insert into t1 values(1,52), (2,52), (3, 52);
|
||||
insert into t1 values(1,51), (2,51), (3, 51);
|
||||
insert into t1 values(1,50), (2,50), (3, 50);
|
||||
insert into t1 values(1,49), (2,49), (3, 49);
|
||||
insert into t1 values(1,48), (2,48), (3, 48);
|
||||
insert into t1 values(1,47), (2,47), (3, 47);
|
||||
insert into t1 values(1,46), (2,46), (3, 46);
|
||||
insert into t1 values(1,45), (2,45), (3, 45);
|
||||
insert into t1 values(1,44), (2,44), (3, 44);
|
||||
insert into t1 values(1,43), (2,43), (3, 43);
|
||||
insert into t1 values(1,42), (2,42), (3, 42);
|
||||
insert into t1 values(1,41), (2,41), (3, 41);
|
||||
insert into t1 values(1,40), (2,40), (3, 40);
|
||||
insert into t1 values(1,39), (2,39), (3, 39);
|
||||
insert into t1 values(1,38), (2,38), (3, 38);
|
||||
insert into t1 values(1,37), (2,37), (3, 37);
|
||||
insert into t1 values(1,36), (2,36), (3, 36);
|
||||
insert into t1 values(1,35), (2,35), (3, 35);
|
||||
insert into t1 values(1,34), (2,34), (3, 34);
|
||||
insert into t1 values(1,33), (2,33), (3, 33);
|
||||
insert into t1 values(1,32), (2,32), (3, 32);
|
||||
insert into t1 values(1,31), (2,31), (3, 31);
|
||||
insert into t1 values(1,30), (2,30), (3, 30);
|
||||
insert into t1 values(1,29), (2,29), (3, 29);
|
||||
insert into t1 values(1,28), (2,28), (3, 28);
|
||||
insert into t1 values(1,27), (2,27), (3, 27);
|
||||
insert into t1 values(1,26), (2,26), (3, 26);
|
||||
insert into t1 values(1,25), (2,25), (3, 25);
|
||||
insert into t1 values(1,24), (2,24), (3, 24);
|
||||
insert into t1 values(1,23), (2,23), (3, 23);
|
||||
insert into t1 values(1,22), (2,22), (3, 22);
|
||||
insert into t1 values(1,21), (2,21), (3, 21);
|
||||
insert into t1 values(1,20), (2,20), (3, 20);
|
||||
insert into t1 values(1,19), (2,19), (3, 19);
|
||||
insert into t1 values(1,18), (2,18), (3, 18);
|
||||
insert into t1 values(1,17), (2,17), (3, 17);
|
||||
insert into t1 values(1,16), (2,16), (3, 16);
|
||||
insert into t1 values(1,15), (2,15), (3, 15);
|
||||
insert into t1 values(1,14), (2,14), (3, 14);
|
||||
insert into t1 values(1,13), (2,13), (3, 13);
|
||||
insert into t1 values(1,12), (2,12), (3, 12);
|
||||
insert into t1 values(1,11), (2,11), (3, 11);
|
||||
insert into t1 values(1,10), (2,10), (3, 10);
|
||||
insert into t1 values(1,9), (2,9), (3, 9);
|
||||
insert into t1 values(1,8), (2,8), (3, 8);
|
||||
insert into t1 values(1,7), (2,7), (3, 7);
|
||||
insert into t1 values(1,6), (2,6), (3, 6);
|
||||
insert into t1 values(1,5), (2,5), (3, 5);
|
||||
insert into t1 values(1,4), (2,4), (3, 4);
|
||||
insert into t1 values(1,3), (2,3), (3, 3);
|
||||
insert into t1 values(1,2), (2,2), (3, 2);
|
||||
insert into t1 values(1,1), (2,1), (3, 1);
|
||||
alter table t1 add unique (a,b), add key (b);
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A NULL NULL NULL YES BTREE
|
||||
t1 0 a 2 b A NULL NULL NULL YES BTREE
|
||||
t1 1 b 1 b A NULL NULL NULL YES BTREE
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A NULL NULL NULL YES BTREE
|
||||
t1 0 a 2 b A NULL NULL NULL YES BTREE
|
||||
t1 1 b 1 b A NULL NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (i int(10), index(i) );
|
||||
ALTER TABLE t1 DISABLE KEYS;
|
||||
INSERT INTO t1 VALUES(1),(2),(3);
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
Host varchar(16) binary NOT NULL default '',
|
||||
User varchar(16) binary NOT NULL default '',
|
||||
PRIMARY KEY (Host,User)
|
||||
) ENGINE=MyISAM;
|
||||
ALTER TABLE t1 DISABLE KEYS;
|
||||
LOCK TABLES t1 WRITE;
|
||||
INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty');
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
UNLOCK TABLES;
|
||||
CHECK TABLES t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
Host varchar(16) binary NOT NULL default '',
|
||||
User varchar(16) binary NOT NULL default '',
|
||||
PRIMARY KEY (Host,User),
|
||||
KEY (Host)
|
||||
) ENGINE=MyISAM;
|
||||
ALTER TABLE t1 DISABLE KEYS;
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
|
||||
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
|
||||
LOCK TABLES t1 WRITE;
|
||||
INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
|
||||
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
|
||||
t1 1 Host 1 Host A 1 NULL NULL BTREE
|
||||
UNLOCK TABLES;
|
||||
CHECK TABLES t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
LOCK TABLES t1 WRITE;
|
||||
ALTER TABLE t1 RENAME t2;
|
||||
UNLOCK TABLES;
|
||||
select * from t2;
|
||||
Host User
|
||||
localhost
|
||||
localhost root
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t1 (
|
||||
Host varchar(16) binary NOT NULL default '',
|
||||
User varchar(16) binary NOT NULL default '',
|
||||
PRIMARY KEY (Host,User),
|
||||
KEY (Host)
|
||||
) ENGINE=MyISAM;
|
||||
LOCK TABLES t1 WRITE;
|
||||
ALTER TABLE t1 DISABLE KEYS;
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
|
||||
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int);
|
||||
alter table t1 rename to ``;
|
||||
ERROR 42000: Incorrect table name ''
|
||||
rename table t1 to ``;
|
||||
ERROR 42000: Incorrect table name ''
|
||||
drop table t1;
|
||||
drop table if exists t1, t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
Note 1051 Unknown table 't2'
|
||||
create table t1 ( a varchar(10) not null primary key ) engine=myisam;
|
||||
create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1);
|
||||
flush tables;
|
||||
alter table t1 modify a varchar(10);
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` varchar(10) NOT NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`)
|
||||
flush tables;
|
||||
alter table t1 modify a varchar(10) not null;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` varchar(10) NOT NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`)
|
||||
drop table if exists t1, t2;
|
||||
create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
|
||||
insert into t1 (a) values(1);
|
||||
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 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL
|
||||
alter table t1 modify a int;
|
||||
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 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null, g int not null, h int not null,i int not null, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
|
||||
insert into t1 (a) values(1);
|
||||
Warnings:
|
||||
Warning 1364 Field 'b' doesn't have a default value
|
||||
Warning 1364 Field 'c' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'e' doesn't have a default value
|
||||
Warning 1364 Field 'f' doesn't have a default value
|
||||
Warning 1364 Field 'g' doesn't have a default value
|
||||
Warning 1364 Field 'h' doesn't have a default value
|
||||
Warning 1364 Field 'i' doesn't have a default value
|
||||
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 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL
|
||||
drop table t1;
|
||||
set names koi8r;
|
||||
create table t1 (a char(10) character set koi8r);
|
||||
insert into t1 values ('<27><><EFBFBD><EFBFBD>');
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> D4C5D3D4
|
||||
alter table t1 change a a char(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a binary(4);
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a char(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> D4C5D3D4
|
||||
alter table t1 change a a varchar(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> D4C5D3D4
|
||||
alter table t1 change a a text character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> D4C5D3D4
|
||||
delete from t1;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(10) CHARACTER SET koi8r DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
alter table t1 DEFAULT CHARACTER SET latin1;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(10) CHARACTER SET koi8r DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
alter table t1 CONVERT TO CHARACTER SET latin1;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(10) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
alter table t1 DEFAULT CHARACTER SET cp1251;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(10) CHARACTER SET latin1 DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=cp1251
|
||||
drop table t1;
|
||||
create table t1 (myblob longblob,mytext longtext)
|
||||
default charset latin1 collate latin1_general_cs;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`myblob` longblob,
|
||||
`mytext` longtext COLLATE latin1_general_cs
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs
|
||||
alter table t1 character set latin2;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`myblob` longblob,
|
||||
`mytext` longtext CHARACTER SET latin1 COLLATE latin1_general_cs
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin2
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE);
|
||||
ALTER TABLE t1 DROP PRIMARY KEY;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
UNIQUE KEY `b` (`b`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
ALTER TABLE t1 DROP PRIMARY KEY;
|
||||
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int, b int, key(a));
|
||||
insert into t1 values (1,1), (2,2);
|
||||
alter table t1 drop key no_such_key;
|
||||
ERROR 42000: Can't DROP 'no_such_key'; check that column/key exists
|
||||
alter table t1 drop key a;
|
||||
drop table t1;
|
||||
CREATE TABLE T12207(a int) ENGINE=MYISAM;
|
||||
ALTER TABLE T12207 DISCARD TABLESPACE;
|
||||
ERROR HY000: Table storage engine for 'T12207' doesn't have this option
|
||||
DROP TABLE T12207;
|
||||
create table t1 (a text) character set koi8r;
|
||||
insert into t1 values (_koi8r'<27><><EFBFBD><EFBFBD>');
|
||||
select hex(a) from t1;
|
||||
hex(a)
|
||||
D4C5D3D4
|
||||
alter table t1 convert to character set cp1251;
|
||||
select hex(a) from t1;
|
||||
hex(a)
|
||||
F2E5F1F2
|
||||
drop table t1;
|
||||
create table t1 ( a timestamp );
|
||||
alter table t1 add unique ( a(1) );
|
||||
ERROR HY000: Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys
|
||||
drop table t1;
|
||||
drop table if exists t1;
|
||||
create table t1 (a int, key(a));
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 a 1 a A NULL NULL NULL YES BTREE
|
||||
"this used not to disable the index"
|
||||
alter table t1 modify a int, disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 a 1 a A NULL NULL NULL YES BTREE
|
||||
alter table t1 enable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 a 1 a NULL NULL NULL NULL YES BTREE
|
||||
alter table t1 modify a bigint, disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 a 1 a A NULL NULL NULL YES BTREE
|
||||
alter table t1 enable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 a 1 a NULL NULL NULL NULL YES BTREE
|
||||
alter table t1 add b char(10), disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 a 1 a A NULL NULL NULL YES BTREE
|
||||
alter table t1 add c decimal(10,2), enable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 a 1 a A NULL NULL NULL YES BTREE
|
||||
"this however did"
|
||||
alter table t1 disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 a 1 a NULL NULL NULL NULL YES BTREE
|
||||
desc t1;
|
||||
Field Type Null Key Default Extra
|
||||
a bigint(20) YES MUL NULL
|
||||
b char(10) YES NULL
|
||||
c decimal(10,2) YES NULL
|
||||
alter table t1 add d decimal(15,5);
|
||||
"The key should still be disabled"
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 a 1 a A NULL NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
"Now will test with one unique index"
|
||||
create table t1(a int, b char(10), unique(a));
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
alter table t1 disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a NULL 0 NULL NULL YES BTREE
|
||||
alter table t1 enable keys;
|
||||
"If no copy on noop change, this won't touch the data file"
|
||||
"Unique index, no change"
|
||||
alter table t1 modify a int, disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
"Change the type implying data copy"
|
||||
"Unique index, no change"
|
||||
alter table t1 modify a bigint, disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
alter table t1 modify a bigint;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
alter table t1 modify a int;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
"Now will test with one unique and one non-unique index"
|
||||
create table t1(a int, b char(10), unique(a), key(b));
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A NULL NULL NULL YES BTREE
|
||||
alter table t1 disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a NULL 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b NULL NULL NULL NULL YES BTREE
|
||||
alter table t1 enable keys;
|
||||
"If no copy on noop change, this won't touch the data file"
|
||||
"The non-unique index will be disabled"
|
||||
alter table t1 modify a int, disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A NULL NULL NULL YES BTREE
|
||||
alter table t1 enable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a NULL 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b NULL NULL NULL NULL YES BTREE
|
||||
"Change the type implying data copy"
|
||||
"The non-unique index will be disabled"
|
||||
alter table t1 modify a bigint, disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A NULL NULL NULL YES BTREE
|
||||
"Change again the type, but leave the indexes as_is"
|
||||
alter table t1 modify a int;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A NULL NULL NULL YES BTREE
|
||||
"Try the same. When data is no copied on similar tables, this is noop"
|
||||
alter table t1 modify a int;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A NULL NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
create database mysqltest;
|
||||
create table t1 (c1 int);
|
||||
alter table t1 rename mysqltest.t1;
|
||||
drop table t1;
|
||||
ERROR 42S02: Unknown table 't1'
|
||||
alter table mysqltest.t1 rename t1;
|
||||
drop table t1;
|
||||
create table t1 (c1 int);
|
||||
use mysqltest;
|
||||
drop database mysqltest;
|
||||
alter table test.t1 rename t1;
|
||||
ERROR 3D000: No database selected
|
||||
alter table test.t1 rename test.t1;
|
||||
use test;
|
||||
drop table t1;
|
||||
CREATE TABLE t1(a INT) ROW_FORMAT=FIXED;
|
||||
CREATE INDEX i1 ON t1(a);
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
KEY `i1` (`a`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
|
||||
DROP INDEX i1 ON t1;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
|
||||
DROP TABLE t1;
|
||||
DROP TABLE IF EXISTS bug24219;
|
||||
DROP TABLE IF EXISTS bug24219_2;
|
||||
CREATE TABLE bug24219 (a INT, INDEX(a));
|
||||
SHOW INDEX FROM bug24219;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
bug24219 1 a 1 a A NULL NULL NULL YES BTREE
|
||||
ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
|
||||
SHOW INDEX FROM bug24219_2;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
bug24219_2 1 a 1 a A NULL NULL NULL YES BTREE
|
||||
DROP TABLE bug24219_2;
|
||||
create table t1 (mycol int(10) not null);
|
||||
alter table t1 alter column mycol set default 0;
|
||||
desc t1;
|
||||
Field Type Null Key Default Extra
|
||||
mycol int(10) NO 0
|
||||
drop table t1;
|
||||
create table t1 (v varchar(32));
|
||||
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
|
||||
select * from t1;
|
||||
v
|
||||
def
|
||||
abc
|
||||
hij
|
||||
3r4f
|
||||
alter table t1 change v v2 varchar(32);
|
||||
select * from t1;
|
||||
v2
|
||||
def
|
||||
abc
|
||||
hij
|
||||
3r4f
|
||||
alter table t1 change v2 v varchar(64);
|
||||
select * from t1;
|
||||
v
|
||||
def
|
||||
abc
|
||||
hij
|
||||
3r4f
|
||||
update t1 set v = 'lmn' where v = 'hij';
|
||||
select * from t1;
|
||||
v
|
||||
def
|
||||
abc
|
||||
3r4f
|
||||
lmn
|
||||
alter table t1 add i int auto_increment not null primary key first;
|
||||
select * from t1;
|
||||
i v
|
||||
1 def
|
||||
2 abc
|
||||
3 3r4f
|
||||
4 lmn
|
||||
update t1 set i=5 where i=3;
|
||||
select * from t1;
|
||||
i v
|
||||
1 def
|
||||
2 abc
|
||||
4 lmn
|
||||
5 3r4f
|
||||
alter table t1 change i i bigint;
|
||||
select * from t1;
|
||||
i v
|
||||
1 def
|
||||
2 abc
|
||||
4 lmn
|
||||
5 3r4f
|
||||
alter table t1 add unique key (i, v);
|
||||
select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
|
||||
i v
|
||||
4 lmn
|
||||
drop table t1;
|
||||
create table t1 (t varchar(255) default null, key t (t(80)))
|
||||
engine=myisam default charset=latin1;
|
||||
alter table t1 change t t text;
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (s CHAR(8) BINARY);
|
||||
INSERT INTO t1 VALUES ('test');
|
||||
SELECT LENGTH(s) FROM t1;
|
||||
LENGTH(s)
|
||||
4
|
||||
ALTER TABLE t1 MODIFY s CHAR(10) BINARY;
|
||||
SELECT LENGTH(s) FROM t1;
|
||||
LENGTH(s)
|
||||
4
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (s BINARY(8));
|
||||
INSERT INTO t1 VALUES ('test');
|
||||
SELECT LENGTH(s) FROM t1;
|
||||
LENGTH(s)
|
||||
8
|
||||
SELECT HEX(s) FROM t1;
|
||||
HEX(s)
|
||||
7465737400000000
|
||||
ALTER TABLE t1 MODIFY s BINARY(10);
|
||||
SELECT HEX(s) FROM t1;
|
||||
HEX(s)
|
||||
74657374000000000000
|
||||
SELECT LENGTH(s) FROM t1;
|
||||
LENGTH(s)
|
||||
10
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (v VARCHAR(3), b INT);
|
||||
INSERT INTO t1 VALUES ('abc', 5);
|
||||
SELECT * FROM t1;
|
||||
v b
|
||||
abc 5
|
||||
ALTER TABLE t1 MODIFY COLUMN v VARCHAR(4);
|
||||
SELECT * FROM t1;
|
||||
v b
|
||||
abc 5
|
||||
DROP TABLE t1;
|
||||
DROP TABLE IF EXISTS `t+1`, `t+2`;
|
||||
CREATE TABLE `t+1` (c1 INT);
|
||||
ALTER TABLE `t+1` RENAME `t+2`;
|
||||
CREATE TABLE `t+1` (c1 INT);
|
||||
ALTER TABLE `t+1` RENAME `t+2`;
|
||||
ERROR 42S01: Table 't+2' already exists
|
||||
DROP TABLE `t+1`, `t+2`;
|
||||
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
|
||||
ALTER TABLE `tt+1` RENAME `tt+2`;
|
||||
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
|
||||
ALTER TABLE `tt+1` RENAME `tt+2`;
|
||||
ERROR 42S01: Table 'tt+2' already exists
|
||||
SHOW CREATE TABLE `tt+1`;
|
||||
Table Create Table
|
||||
tt+1 CREATE TEMPORARY TABLE `tt+1` (
|
||||
`c1` int(11) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
SHOW CREATE TABLE `tt+2`;
|
||||
Table Create Table
|
||||
tt+2 CREATE TEMPORARY TABLE `tt+2` (
|
||||
`c1` int(11) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
DROP TABLE `tt+1`, `tt+2`;
|
||||
CREATE TABLE `#sql1` (c1 INT);
|
||||
CREATE TABLE `@0023sql2` (c1 INT);
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
#sql1
|
||||
@0023sql2
|
||||
RENAME TABLE `#sql1` TO `@0023sql1`;
|
||||
RENAME TABLE `@0023sql2` TO `#sql2`;
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
#sql2
|
||||
@0023sql1
|
||||
ALTER TABLE `@0023sql1` RENAME `#sql-1`;
|
||||
ALTER TABLE `#sql2` RENAME `@0023sql-2`;
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
#sql-1
|
||||
@0023sql-2
|
||||
INSERT INTO `#sql-1` VALUES (1);
|
||||
INSERT INTO `@0023sql-2` VALUES (2);
|
||||
DROP TABLE `#sql-1`, `@0023sql-2`;
|
||||
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
|
||||
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
ALTER TABLE `#sql1` RENAME `@0023sql1`;
|
||||
ALTER TABLE `@0023sql2` RENAME `#sql2`;
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
INSERT INTO `#sql2` VALUES (1);
|
||||
INSERT INTO `@0023sql1` VALUES (2);
|
||||
SHOW CREATE TABLE `#sql2`;
|
||||
Table Create Table
|
||||
#sql2 CREATE TEMPORARY TABLE `#sql2` (
|
||||
`c1` int(11) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
SHOW CREATE TABLE `@0023sql1`;
|
||||
Table Create Table
|
||||
@0023sql1 CREATE TEMPORARY TABLE `@0023sql1` (
|
||||
`c1` int(11) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
DROP TABLE `#sql2`, `@0023sql1`;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
DROP TABLE IF EXISTS t2;
|
||||
CREATE TABLE t1 (
|
||||
int_field INTEGER UNSIGNED NOT NULL,
|
||||
char_field CHAR(10),
|
||||
INDEX(`int_field`)
|
||||
);
|
||||
DESCRIBE t1;
|
||||
Field Type Null Key Default Extra
|
||||
int_field int(10) unsigned NO MUL NULL
|
||||
char_field char(10) YES NULL
|
||||
SHOW INDEXES FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 int_field 1 int_field A NULL NULL NULL BTREE
|
||||
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
|
||||
"Non-copy data change - new frm, but old data and index files"
|
||||
ALTER TABLE t1
|
||||
CHANGE int_field unsigned_int_field INTEGER UNSIGNED NOT NULL,
|
||||
RENAME t2;
|
||||
SELECT * FROM t1 ORDER BY int_field;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
SELECT * FROM t2 ORDER BY unsigned_int_field;
|
||||
unsigned_int_field char_field
|
||||
1 edno
|
||||
1 edno
|
||||
2 dve
|
||||
3 tri
|
||||
5 pet
|
||||
DESCRIBE t2;
|
||||
Field Type Null Key Default Extra
|
||||
unsigned_int_field int(10) unsigned NO MUL NULL
|
||||
char_field char(10) YES NULL
|
||||
DESCRIBE t2;
|
||||
Field Type Null Key Default Extra
|
||||
unsigned_int_field int(10) unsigned NO MUL NULL
|
||||
char_field char(10) YES NULL
|
||||
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT UNSIGNED NOT NULL;
|
||||
DESCRIBE t2;
|
||||
Field Type Null Key Default Extra
|
||||
unsigned_int_field bigint(20) unsigned NO MUL NULL
|
||||
char_field char(10) YES NULL
|
||||
DROP TABLE t2;
|
||||
156
mysql-test/suite/pbxt/r/analyse.result
Normal file
156
mysql-test/suite/pbxt/r/analyse.result
Normal file
@@ -0,0 +1,156 @@
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (i int, j int, empty_string char(10), bool char(1), d date);
|
||||
insert into t1 values (1,2,"","Y","2002-03-03"), (3,4,"","N","2002-03-04"), (5,6,"","Y","2002-03-04"), (7,8,"","N","2002-03-05");
|
||||
select count(*) from t1 procedure analyse();
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
count(*) 4 4 1 1 0 0 4.0000 0.0000 ENUM('4') NOT NULL
|
||||
select * from t1 procedure analyse();
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
|
||||
test.t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
|
||||
test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
||||
test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
||||
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
||||
select * from t1 procedure analyse(2);
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.i 1 7 1 1 0 0 4.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
|
||||
test.t1.j 2 8 1 1 0 0 5.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
|
||||
test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
||||
test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
||||
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
||||
create table t2 select * from t1 procedure analyse();
|
||||
select * from t2;
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
|
||||
test.t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
|
||||
test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
||||
test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
||||
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
||||
drop table t1,t2;
|
||||
EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE();
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
create table t1 (a int not null);
|
||||
create table t2 select * from t1 where 0=1 procedure analyse();
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`Field_name` varbinary(255) NOT NULL DEFAULT '',
|
||||
`Min_value` varbinary(255) DEFAULT NULL,
|
||||
`Max_value` varbinary(255) DEFAULT NULL,
|
||||
`Min_length` bigint(11) NOT NULL DEFAULT '0',
|
||||
`Max_length` bigint(11) NOT NULL DEFAULT '0',
|
||||
`Empties_or_zeros` bigint(11) NOT NULL DEFAULT '0',
|
||||
`Nulls` bigint(11) NOT NULL DEFAULT '0',
|
||||
`Avg_value_or_avg_length` varbinary(255) NOT NULL DEFAULT '',
|
||||
`Std` varbinary(255) DEFAULT NULL,
|
||||
`Optimal_fieldtype` varbinary(64) NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
select * from t1 where 0=1 procedure analyse();
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
insert into t1 values(1);
|
||||
drop table t2;
|
||||
create table t2 select * from t1 where 0=1 procedure analyse();
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`Field_name` varbinary(255) NOT NULL DEFAULT '',
|
||||
`Min_value` varbinary(255) DEFAULT NULL,
|
||||
`Max_value` varbinary(255) DEFAULT NULL,
|
||||
`Min_length` bigint(11) NOT NULL DEFAULT '0',
|
||||
`Max_length` bigint(11) NOT NULL DEFAULT '0',
|
||||
`Empties_or_zeros` bigint(11) NOT NULL DEFAULT '0',
|
||||
`Nulls` bigint(11) NOT NULL DEFAULT '0',
|
||||
`Avg_value_or_avg_length` varbinary(255) NOT NULL DEFAULT '',
|
||||
`Std` varbinary(255) DEFAULT NULL,
|
||||
`Optimal_fieldtype` varbinary(64) NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
select * from t2;
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
insert into t2 select * from t1 procedure analyse();
|
||||
select * from t2;
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.a 1 1 1 1 0 0 1.0000 0.0000 ENUM('1') NOT NULL
|
||||
insert into t1 values(2);
|
||||
drop table t2;
|
||||
create table t2 select * from t1 where 0=1 procedure analyse();
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`Field_name` varbinary(255) NOT NULL DEFAULT '',
|
||||
`Min_value` varbinary(255) DEFAULT NULL,
|
||||
`Max_value` varbinary(255) DEFAULT NULL,
|
||||
`Min_length` bigint(11) NOT NULL DEFAULT '0',
|
||||
`Max_length` bigint(11) NOT NULL DEFAULT '0',
|
||||
`Empties_or_zeros` bigint(11) NOT NULL DEFAULT '0',
|
||||
`Nulls` bigint(11) NOT NULL DEFAULT '0',
|
||||
`Avg_value_or_avg_length` varbinary(255) NOT NULL DEFAULT '',
|
||||
`Std` varbinary(255) DEFAULT NULL,
|
||||
`Optimal_fieldtype` varbinary(64) NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
select * from t2;
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
insert into t2 select * from t1 procedure analyse();
|
||||
select * from t2;
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.a 1 2 1 1 0 0 1.5000 0.5000 ENUM('1','2') NOT NULL
|
||||
drop table t1,t2;
|
||||
create table t1 (v varchar(128));
|
||||
insert into t1 values ('abc'),('abc\'def\\hij\"klm\0opq'),('\''),('\"'),('\\'),('a\0'),('b\''),('c\"'),('d\\'),('\'b'),('\"c'),('\\d'),('a\0\0\0b'),('a\'\'\'\'b'),('a\"\"\"\"b'),('a\\\\\\\\b'),('\'\0\\\"'),('\'\''),('\"\"'),('\\\\'),('The\ZEnd');
|
||||
select * from t1 procedure analyse();
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.v " \\ 1 19 0 0 3.7619 NULL ENUM('"','""','"c','\'\0\\"','\'','\'\'','\'b','a\0\0\0b','a\0','a""""b','a\'\'\'\'b','abc','abc\'def\\hij"klm\0opq','a\\\\\\\\b','b\'','c"','d\\','The\ZEnd','\\','\\d','\\\\') NOT NULL
|
||||
drop table t1;
|
||||
create table t1 (df decimal(5,1));
|
||||
insert into t1 values(1.1);
|
||||
insert into t1 values(2.2);
|
||||
select * from t1 procedure analyse();
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.df 1.1 2.2 13 13 0 0 1.65000 0.55000 ENUM('1.1','2.2') NOT NULL
|
||||
drop table t1;
|
||||
create table t1 (d double);
|
||||
insert into t1 values (100000);
|
||||
select * from t1 procedure analyse (1,1);
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.d 100000 100000 6 6 0 0 100000 0 MEDIUMINT(6) UNSIGNED NOT NULL
|
||||
drop table t1;
|
||||
create table t1 (product varchar(32), country_id int not null, year int,
|
||||
profit int);
|
||||
insert into t1 values ( 'Computer', 2,2000, 1200),
|
||||
( 'TV', 1, 1999, 150),
|
||||
( 'Calculator', 1, 1999,50),
|
||||
( 'Computer', 1, 1999,1500),
|
||||
( 'Computer', 1, 2000,1500),
|
||||
( 'TV', 1, 2000, 150),
|
||||
( 'TV', 2, 2000, 100),
|
||||
( 'TV', 2, 2000, 100),
|
||||
( 'Calculator', 1, 2000,75),
|
||||
( 'Calculator', 2, 2000,75),
|
||||
( 'TV', 1, 1999, 100),
|
||||
( 'Computer', 1, 1999,1200),
|
||||
( 'Computer', 2, 2000,1500),
|
||||
( 'Calculator', 2, 2000,75),
|
||||
( 'Phone', 3, 2003,10)
|
||||
;
|
||||
create table t2 (country_id int primary key, country char(20) not null);
|
||||
insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland');
|
||||
select product, sum(profit),avg(profit) from t1 group by product with rollup procedure analyse();
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.product Computer TV 2 8 0 0 4.2500 NULL ENUM('Computer','Phone','TV') NOT NULL
|
||||
sum(profit) 10 6900 11 11 0 0 1946.2500 2867.6719 ENUM('10','275','600','6900') NOT NULL
|
||||
avg(profit) 10.0000 1380.0000 16 16 0 0 394.68750000 570.20033144 ENUM('10.0000','68.7500','120.0000','1380.0000') NOT NULL
|
||||
drop table t1,t2;
|
||||
create table t1 (f1 double(10,5), f2 char(10), f3 double(10,5));
|
||||
insert into t1 values (5.999, "5.9999", 5.99999), (9.555, "9.5555", 9.55555);
|
||||
select f1 from t1 procedure analyse(1, 1);
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.f1 5.99900 9.55500 7 7 0 0 7.77700 1.77800 FLOAT(4,3) NOT NULL
|
||||
select f2 from t1 procedure analyse(1, 1);
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.f2 5.9999 9.5555 6 6 0 0 6.0000 NULL FLOAT(5,4) UNSIGNED NOT NULL
|
||||
select f3 from t1 procedure analyse(1, 1);
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.f3 5.99999 9.55555 7 7 0 0 7.77777 1.77778 FLOAT(6,5) NOT NULL
|
||||
drop table t1;
|
||||
End of 4.1 tests
|
||||
60
mysql-test/suite/pbxt/r/analyze.result
Normal file
60
mysql-test/suite/pbxt/r/analyze.result
Normal file
@@ -0,0 +1,60 @@
|
||||
create table t1 (a bigint);
|
||||
lock tables t1 write;
|
||||
insert into t1 values(0);
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
unlock tables;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values(0);
|
||||
lock tables t1 write;
|
||||
delete from t1;
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
unlock tables;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values(0);
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
create table t1 (a mediumtext, fulltext key key1(a)) charset utf8 collate utf8_general_ci engine myisam;
|
||||
insert into t1 values ('hello');
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Table is already up to date
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int);
|
||||
prepare stmt1 from "SELECT * FROM t1 PROCEDURE ANALYSE()";
|
||||
execute stmt1;
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.a NULL NULL 0 0 0 0 0.0 0.0 CHAR(0) NOT NULL
|
||||
execute stmt1;
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.a NULL NULL 0 0 0 0 0.0 0.0 CHAR(0) NOT NULL
|
||||
deallocate prepare stmt1;
|
||||
drop table t1;
|
||||
create temporary table t1(a int, index(a));
|
||||
insert into t1 values('1'),('2'),('3'),('4'),('5');
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
show index from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 a 1 a A NULL NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
48
mysql-test/suite/pbxt/r/ansi.result
Normal file
48
mysql-test/suite/pbxt/r/ansi.result
Normal file
@@ -0,0 +1,48 @@
|
||||
drop table if exists t1;
|
||||
set sql_mode="MySQL40";
|
||||
select @@sql_mode;
|
||||
@@sql_mode
|
||||
MYSQL40,HIGH_NOT_PRECEDENCE
|
||||
set @@sql_mode="ANSI";
|
||||
select @@sql_mode;
|
||||
@@sql_mode
|
||||
REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI
|
||||
SELECT 'A' || 'B';
|
||||
'A' || 'B'
|
||||
AB
|
||||
CREATE TABLE t1 (id INT, id2 int);
|
||||
SELECT id,NULL,1,1.1,'a' FROM t1 GROUP BY id;
|
||||
id NULL 1 1.1 a
|
||||
SELECT id FROM t1 GROUP BY id2;
|
||||
id
|
||||
drop table t1;
|
||||
SET @@SQL_MODE="";
|
||||
CREATE TABLE t1 (i int auto_increment NOT NULL, PRIMARY KEY (i));
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`i`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
SET @@SQL_MODE="MYSQL323";
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`i`)
|
||||
) TYPE=PBXT
|
||||
SET @@SQL_MODE="MYSQL40";
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`i`)
|
||||
) TYPE=PBXT
|
||||
SET @@SQL_MODE="NO_FIELD_OPTIONS";
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) NOT NULL,
|
||||
PRIMARY KEY (`i`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
454
mysql-test/suite/pbxt/r/auto_increment.result
Normal file
454
mysql-test/suite/pbxt/r/auto_increment.result
Normal file
@@ -0,0 +1,454 @@
|
||||
drop table if exists t1;
|
||||
drop table if exists t2;
|
||||
SET SQL_WARNINGS=1;
|
||||
create table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam auto_increment=3;
|
||||
insert into t1 values (1,1),(NULL,3),(NULL,4);
|
||||
delete from t1 where a=4;
|
||||
insert into t1 values (NULL,5),(NULL,6);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
3 3
|
||||
5 5
|
||||
6 6
|
||||
delete from t1 where a=6;
|
||||
replace t1 values (3,1);
|
||||
ALTER TABLE t1 add c int;
|
||||
replace t1 values (3,3,3);
|
||||
insert into t1 values (NULL,7,7);
|
||||
update t1 set a=8,b=b+1,c=c+1 where a=7;
|
||||
insert into t1 values (NULL,9,9);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 1 NULL
|
||||
3 3 3
|
||||
5 5 NULL
|
||||
8 8 8
|
||||
9 9 9
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
|
||||
sval char(20)
|
||||
);
|
||||
insert into t1 values (NULL, "hello");
|
||||
insert into t1 values (NULL, "hey");
|
||||
select * from t1;
|
||||
skey sval
|
||||
1 hello
|
||||
2 hey
|
||||
select _rowid,t1._rowid,skey,sval from t1;
|
||||
_rowid _rowid skey sval
|
||||
1 1 1 hello
|
||||
2 2 2 hey
|
||||
drop table t1;
|
||||
create table t1 (a char(10) not null, b int not null auto_increment, primary key(a,b));
|
||||
insert into t1 values ("a",1),("b",2),("a",2),("c",1);
|
||||
insert into t1 values ("a",NULL),("b",NULL),("c",NULL),("e",NULL);
|
||||
insert into t1 (a) values ("a"),("b"),("c"),("d");
|
||||
insert into t1 (a) values ('k'),('d');
|
||||
insert into t1 (a) values ("a");
|
||||
insert into t1 values ("d",last_insert_id());
|
||||
select * from t1;
|
||||
a b
|
||||
a 1
|
||||
a 2
|
||||
a 3
|
||||
a 7
|
||||
a 13
|
||||
b 2
|
||||
b 4
|
||||
b 8
|
||||
c 1
|
||||
c 5
|
||||
c 9
|
||||
d 10
|
||||
d 12
|
||||
d 13
|
||||
e 6
|
||||
k 11
|
||||
drop table t1;
|
||||
create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ordid), index(ord,ordid));
|
||||
insert into t1 (ordid,ord) values (NULL,'sdj'),(NULL,'sdj');
|
||||
select * from t1;
|
||||
ordid ord
|
||||
1 sdj
|
||||
2 sdj
|
||||
drop table t1;
|
||||
create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid));
|
||||
insert into t1 values (NULL,'sdj'),(NULL,'sdj'),(NULL,"abc"),(NULL,'abc'),(NULL,'zzz'),(NULL,'sdj'),(NULL,'abc');
|
||||
select * from t1;
|
||||
ordid ord
|
||||
3 abc
|
||||
4 abc
|
||||
7 abc
|
||||
1 sdj
|
||||
2 sdj
|
||||
6 sdj
|
||||
5 zzz
|
||||
drop table t1;
|
||||
create table t1 (sid char(5), id int(2) NOT NULL auto_increment, key(sid, id));
|
||||
create table t2 (sid char(20), id int(2));
|
||||
insert into t2 values ('skr',NULL),('skr',NULL),('test',NULL);
|
||||
insert into t1 select * from t2;
|
||||
select * from t1;
|
||||
sid id
|
||||
skr 1
|
||||
skr 2
|
||||
test 3
|
||||
drop table t1,t2;
|
||||
create table t1 (a int not null primary key auto_increment);
|
||||
insert into t1 values (0);
|
||||
update t1 set a=0;
|
||||
select * from t1;
|
||||
a
|
||||
0
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
create table t1 (a int not null auto_increment primary key);
|
||||
insert into t1 values (NULL);
|
||||
insert into t1 values (-1);
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
1
|
||||
insert into t1 values (NULL);
|
||||
select * from t1;
|
||||
a
|
||||
-1
|
||||
1
|
||||
2
|
||||
drop table t1;
|
||||
create table t1 (a int not null auto_increment primary key) /*!40102 engine=heap */;
|
||||
insert into t1 values (NULL);
|
||||
insert into t1 values (-1);
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
1
|
||||
insert into t1 values (NULL);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
-1
|
||||
2
|
||||
drop table t1;
|
||||
create table t1 (i tinyint unsigned not null auto_increment primary key);
|
||||
insert into t1 set i = 254;
|
||||
insert into t1 set i = null;
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
255
|
||||
explain extended select last_insert_id();
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select last_insert_id() AS `last_insert_id()`
|
||||
insert into t1 set i = 254;
|
||||
ERROR 23000: Duplicate entry '254' for key 'PRIMARY'
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
255
|
||||
insert into t1 set i = null;
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
255
|
||||
drop table t1;
|
||||
create table t1 (i tinyint unsigned not null auto_increment, key (i));
|
||||
insert into t1 set i = 254;
|
||||
insert into t1 set i = null;
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
255
|
||||
insert into t1 set i = null;
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
255
|
||||
drop table t1;
|
||||
create table t1 (i tinyint unsigned not null auto_increment primary key, b int, unique (b));
|
||||
insert into t1 values (NULL, 10);
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
1
|
||||
insert into t1 values (NULL, 15);
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
2
|
||||
insert into t1 values (NULL, 10);
|
||||
ERROR 23000: Duplicate entry '10' for key 'b'
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
2
|
||||
drop table t1;
|
||||
create table t1(a int auto_increment,b int null,primary key(a));
|
||||
SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
|
||||
insert into t1(a,b)values(NULL,1);
|
||||
insert into t1(a,b)values(200,2);
|
||||
insert into t1(a,b)values(0,3);
|
||||
insert into t1(b)values(4);
|
||||
insert into t1(b)values(5);
|
||||
insert into t1(b)values(6);
|
||||
insert into t1(b)values(7);
|
||||
select * from t1 order by b;
|
||||
a b
|
||||
1 1
|
||||
200 2
|
||||
0 3
|
||||
201 4
|
||||
202 5
|
||||
203 6
|
||||
204 7
|
||||
alter table t1 modify b mediumint;
|
||||
select * from t1 order by b;
|
||||
a b
|
||||
1 1
|
||||
200 2
|
||||
0 3
|
||||
201 4
|
||||
202 5
|
||||
203 6
|
||||
204 7
|
||||
create table t2 (a int);
|
||||
insert t2 values (1),(2);
|
||||
alter table t2 add b int auto_increment primary key;
|
||||
select * from t2;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
drop table t2;
|
||||
delete from t1 where a=0;
|
||||
update t1 set a=0 where b=5;
|
||||
select * from t1 order by b;
|
||||
a b
|
||||
1 1
|
||||
200 2
|
||||
201 4
|
||||
0 5
|
||||
203 6
|
||||
204 7
|
||||
delete from t1 where a=0;
|
||||
update t1 set a=NULL where b=6;
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
update t1 set a=300 where b=7;
|
||||
SET SQL_MODE='';
|
||||
insert into t1(a,b)values(NULL,8);
|
||||
insert into t1(a,b)values(400,9);
|
||||
insert into t1(a,b)values(0,10);
|
||||
insert into t1(b)values(11);
|
||||
insert into t1(b)values(12);
|
||||
insert into t1(b)values(13);
|
||||
insert into t1(b)values(14);
|
||||
select * from t1 order by b;
|
||||
a b
|
||||
1 1
|
||||
200 2
|
||||
201 4
|
||||
203 6
|
||||
300 7
|
||||
301 8
|
||||
400 9
|
||||
401 10
|
||||
402 11
|
||||
403 12
|
||||
404 13
|
||||
405 14
|
||||
delete from t1 where a=0;
|
||||
update t1 set a=0 where b=12;
|
||||
select * from t1 order by b;
|
||||
a b
|
||||
1 1
|
||||
200 2
|
||||
201 4
|
||||
203 6
|
||||
300 7
|
||||
301 8
|
||||
400 9
|
||||
401 10
|
||||
402 11
|
||||
0 12
|
||||
404 13
|
||||
405 14
|
||||
delete from t1 where a=0;
|
||||
update t1 set a=NULL where b=13;
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
update t1 set a=500 where b=14;
|
||||
select * from t1 order by b;
|
||||
a b
|
||||
1 1
|
||||
200 2
|
||||
201 4
|
||||
203 6
|
||||
300 7
|
||||
301 8
|
||||
400 9
|
||||
401 10
|
||||
402 11
|
||||
404 13
|
||||
500 14
|
||||
drop table t1;
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values (1), (2), (3), (NULL), (NULL);
|
||||
alter table t1 modify a bigint not null auto_increment primary key;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
drop table t1;
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values (1), (2), (3), (0), (0);
|
||||
alter table t1 modify a bigint not null auto_increment primary key;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
drop table t1;
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values (0), (1), (2), (3);
|
||||
set sql_mode=NO_AUTO_VALUE_ON_ZERO;
|
||||
alter table t1 modify a bigint not null auto_increment primary key;
|
||||
set sql_mode= '';
|
||||
select * from t1;
|
||||
a
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
drop table t1;
|
||||
create table t1 (a int auto_increment primary key , b int null);
|
||||
set sql_mode=NO_AUTO_VALUE_ON_ZERO;
|
||||
insert into t1 values (0,1),(1,2),(2,3);
|
||||
select * from t1;
|
||||
a b
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
set sql_mode= '';
|
||||
alter table t1 modify b varchar(255);
|
||||
insert into t1 values (0,4);
|
||||
select * from t1;
|
||||
a b
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10)));
|
||||
INSERT INTO t1 (b) VALUES ('aaaa');
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
INSERT INTO t1 (b) VALUES ('');
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
INSERT INTO t1 (b) VALUES ('bbbb');
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE `t1` (
|
||||
t1_name VARCHAR(255) DEFAULT NULL,
|
||||
t1_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
KEY (t1_name),
|
||||
PRIMARY KEY (t1_id)
|
||||
) AUTO_INCREMENT = 1000;
|
||||
INSERT INTO t1 (t1_name) VALUES('MySQL');
|
||||
INSERT INTO t1 (t1_name) VALUES('MySQL');
|
||||
INSERT INTO t1 (t1_name) VALUES('MySQL');
|
||||
SELECT * from t1;
|
||||
t1_name t1_id
|
||||
MySQL 1000
|
||||
MySQL 1001
|
||||
MySQL 1002
|
||||
SHOW CREATE TABLE `t1`;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`t1_name` varchar(255) DEFAULT NULL,
|
||||
`t1_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`t1_id`),
|
||||
KEY `t1_name` (`t1_name`)
|
||||
) ENGINE=PBXT AUTO_INCREMENT=1000 DEFAULT CHARSET=latin1
|
||||
DROP TABLE `t1`;
|
||||
create table t1(a int not null auto_increment primary key);
|
||||
create table t2(a int not null auto_increment primary key, t1a int);
|
||||
insert into t1 values(NULL);
|
||||
insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
|
||||
insert into t1 values (NULL);
|
||||
insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
|
||||
(NULL, LAST_INSERT_ID());
|
||||
insert into t1 values (NULL);
|
||||
insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
|
||||
(NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
|
||||
select * from t2;
|
||||
a t1a
|
||||
1 1
|
||||
2 1
|
||||
3 2
|
||||
4 2
|
||||
5 2
|
||||
6 3
|
||||
7 3
|
||||
8 3
|
||||
9 3
|
||||
drop table t1, t2;
|
||||
End of 4.1 tests
|
||||
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`));
|
||||
insert into t1 (b) values (1);
|
||||
replace into t1 (b) values (2), (1), (3);
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 1
|
||||
4 3
|
||||
truncate table t1;
|
||||
insert into t1 (b) values (1);
|
||||
replace into t1 (b) values (2);
|
||||
replace into t1 (b) values (1);
|
||||
replace into t1 (b) values (3);
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
2 2
|
||||
3 1
|
||||
4 3
|
||||
drop table t1;
|
||||
create table t1 (rowid int not null auto_increment, val int not null,primary
|
||||
key (rowid), unique(val));
|
||||
replace into t1 (val) values ('1'),('2');
|
||||
replace into t1 (val) values ('1'),('2');
|
||||
insert into t1 (val) values ('1'),('2');
|
||||
ERROR 23000: Duplicate entry '1' for key 'val'
|
||||
select * from t1;
|
||||
rowid val
|
||||
3 1
|
||||
4 2
|
||||
drop table t1;
|
||||
create table t1 (a int not null auto_increment primary key, val int);
|
||||
insert into t1 (val) values (1);
|
||||
update t1 set a=2 where a=1;
|
||||
insert into t1 (val) values (1);
|
||||
select * from t1 order by a;
|
||||
a val
|
||||
2 1
|
||||
3 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (t1 INT(10) PRIMARY KEY, t2 INT(10));
|
||||
INSERT INTO t1 VALUES(0, 0);
|
||||
INSERT INTO t1 VALUES(1, 1);
|
||||
ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
|
||||
ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY'
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c));
|
||||
insert into t1 values(null,1,1,now());
|
||||
insert into t1 values(null,0,0,null);
|
||||
replace into t1 values(null,1,0,null);
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
3
|
||||
drop table t1;
|
||||
11
mysql-test/suite/pbxt/r/bench_count_distinct.result
Normal file
11
mysql-test/suite/pbxt/r/bench_count_distinct.result
Normal file
@@ -0,0 +1,11 @@
|
||||
drop table if exists t1;
|
||||
create table t1(n int not null, key(n)) delay_key_write = 1;
|
||||
select count(distinct n) from t1;
|
||||
count(distinct n)
|
||||
100
|
||||
explain extended select count(distinct n) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 index NULL n 4 NULL 200 100.00 Using index
|
||||
Warnings:
|
||||
Note 1003 select count(distinct `test`.`t1`.`n`) AS `count(distinct n)` from `test`.`t1`
|
||||
drop table t1;
|
||||
354
mysql-test/suite/pbxt/r/bigint.result
Normal file
354
mysql-test/suite/pbxt/r/bigint.result
Normal file
@@ -0,0 +1,354 @@
|
||||
drop table if exists t1, t2;
|
||||
select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296;
|
||||
0 256 00000000000000065536 2147483647 -2147483648 2147483648 4294967296
|
||||
0 256 65536 2147483647 -2147483648 2147483648 4294967296
|
||||
select 9223372036854775807,-009223372036854775808;
|
||||
9223372036854775807 -009223372036854775808
|
||||
9223372036854775807 -9223372036854775808
|
||||
select +9999999999999999999,-9999999999999999999;
|
||||
9999999999999999999 -9999999999999999999
|
||||
9999999999999999999 -9999999999999999999
|
||||
select cast(9223372036854775808 as unsigned)+1;
|
||||
cast(9223372036854775808 as unsigned)+1
|
||||
9223372036854775809
|
||||
select 9223372036854775808+1;
|
||||
9223372036854775808+1
|
||||
9223372036854775809
|
||||
select -(0-3),round(-(0-3)), round(9999999999999999999);
|
||||
-(0-3) round(-(0-3)) round(9999999999999999999)
|
||||
3 3 9999999999999999999
|
||||
select 1,11,101,1001,10001,100001,1000001,10000001,100000001,1000000001,10000000001,100000000001,1000000000001,10000000000001,100000000000001,1000000000000001,10000000000000001,100000000000000001,1000000000000000001,10000000000000000001;
|
||||
1 11 101 1001 10001 100001 1000001 10000001 100000001 1000000001 10000000001 100000000001 1000000000001 10000000000001 100000000000001 1000000000000001 10000000000000001 100000000000000001 1000000000000000001 10000000000000000001
|
||||
1 11 101 1001 10001 100001 1000001 10000001 100000001 1000000001 10000000001 100000000001 1000000000001 10000000000001 100000000000001 1000000000000001 10000000000000001 100000000000000001 1000000000000000001 10000000000000000001
|
||||
select -1,-11,-101,-1001,-10001,-100001,-1000001,-10000001,-100000001,-1000000001,-10000000001,-100000000001,-1000000000001,-10000000000001,-100000000000001,-1000000000000001,-10000000000000001,-100000000000000001,-1000000000000000001,-10000000000000000001;
|
||||
-1 -11 -101 -1001 -10001 -100001 -1000001 -10000001 -100000001 -1000000001 -10000000001 -100000000001 -1000000000001 -10000000000001 -100000000000001 -1000000000000001 -10000000000000001 -100000000000000001 -1000000000000000001 -10000000000000000001
|
||||
-1 -11 -101 -1001 -10001 -100001 -1000001 -10000001 -100000001 -1000000001 -10000000001 -100000000001 -1000000000001 -10000000000001 -100000000000001 -1000000000000001 -10000000000000001 -100000000000000001 -1000000000000000001 -10000000000000000001
|
||||
select conv(1,10,16),conv((1<<2)-1,10,16),conv((1<<10)-2,10,16),conv((1<<16)-3,10,16),conv((1<<25)-4,10,16),conv((1<<31)-5,10,16),conv((1<<36)-6,10,16),conv((1<<47)-7,10,16),conv((1<<48)-8,10,16),conv((1<<55)-9,10,16),conv((1<<56)-10,10,16),conv((1<<63)-11,10,16);
|
||||
conv(1,10,16) conv((1<<2)-1,10,16) conv((1<<10)-2,10,16) conv((1<<16)-3,10,16) conv((1<<25)-4,10,16) conv((1<<31)-5,10,16) conv((1<<36)-6,10,16) conv((1<<47)-7,10,16) conv((1<<48)-8,10,16) conv((1<<55)-9,10,16) conv((1<<56)-10,10,16) conv((1<<63)-11,10,16)
|
||||
1 3 3FE FFFD 1FFFFFC 7FFFFFFB FFFFFFFFA 7FFFFFFFFFF9 FFFFFFFFFFF8 7FFFFFFFFFFFF7 FFFFFFFFFFFFF6 7FFFFFFFFFFFFFF5
|
||||
create table t1 (a bigint unsigned not null, primary key(a));
|
||||
insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612);
|
||||
select * from t1;
|
||||
a
|
||||
18446744073709551612
|
||||
18446744073709551613
|
||||
18446744073709551614
|
||||
18446744073709551615
|
||||
select * from t1 where a=18446744073709551615;
|
||||
a
|
||||
18446744073709551615
|
||||
delete from t1 where a=18446744073709551615;
|
||||
select * from t1;
|
||||
a
|
||||
18446744073709551612
|
||||
18446744073709551613
|
||||
18446744073709551614
|
||||
drop table t1;
|
||||
create table t1 ( a int not null default 1, big bigint );
|
||||
insert into t1 (big) values (-1),(12345678901234567),(9223372036854775807),(18446744073709551615);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'big' at row 4
|
||||
select * from t1;
|
||||
a big
|
||||
1 -1
|
||||
1 12345678901234567
|
||||
1 9223372036854775807
|
||||
1 9223372036854775807
|
||||
select min(big),max(big),max(big)-1 from t1;
|
||||
min(big) max(big) max(big)-1
|
||||
-1 9223372036854775807 9223372036854775806
|
||||
select min(big),max(big),max(big)-1 from t1 group by a;
|
||||
min(big) max(big) max(big)-1
|
||||
-1 9223372036854775807 9223372036854775806
|
||||
alter table t1 modify big bigint unsigned not null;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'big' at row 1
|
||||
select min(big),max(big),max(big)-1 from t1;
|
||||
min(big) max(big) max(big)-1
|
||||
0 9223372036854775807 9223372036854775806
|
||||
select min(big),max(big),max(big)-1 from t1 group by a;
|
||||
min(big) max(big) max(big)-1
|
||||
0 9223372036854775807 9223372036854775806
|
||||
insert into t1 (big) values (18446744073709551615);
|
||||
select * from t1;
|
||||
a big
|
||||
1 0
|
||||
1 12345678901234567
|
||||
1 9223372036854775807
|
||||
1 9223372036854775807
|
||||
1 18446744073709551615
|
||||
select min(big),max(big),max(big)-1 from t1;
|
||||
min(big) max(big) max(big)-1
|
||||
0 18446744073709551615 18446744073709551614
|
||||
select min(big),max(big),max(big)-1 from t1 group by a;
|
||||
min(big) max(big) max(big)-1
|
||||
0 18446744073709551615 18446744073709551614
|
||||
alter table t1 add key (big);
|
||||
select min(big),max(big),max(big)-1 from t1;
|
||||
min(big) max(big) max(big)-1
|
||||
0 18446744073709551615 18446744073709551614
|
||||
select min(big),max(big),max(big)-1 from t1 group by a;
|
||||
min(big) max(big) max(big)-1
|
||||
0 18446744073709551615 18446744073709551614
|
||||
alter table t1 modify big bigint not null;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'big' at row 5
|
||||
select * from t1;
|
||||
a big
|
||||
1 0
|
||||
1 12345678901234567
|
||||
1 9223372036854775807
|
||||
1 9223372036854775807
|
||||
1 9223372036854775807
|
||||
select min(big),max(big),max(big)-1 from t1;
|
||||
min(big) max(big) max(big)-1
|
||||
0 9223372036854775807 9223372036854775806
|
||||
select min(big),max(big),max(big)-1 from t1 group by a;
|
||||
min(big) max(big) max(big)-1
|
||||
0 9223372036854775807 9223372036854775806
|
||||
drop table t1;
|
||||
create table t1 (id bigint auto_increment primary key, a int) auto_increment=9999999999;
|
||||
insert into t1 values (null,1);
|
||||
select * from t1;
|
||||
id a
|
||||
9999999999 1
|
||||
select * from t1 limit 9999999999;
|
||||
id a
|
||||
9999999999 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( quantity decimal(60,0));
|
||||
insert into t1 values (10000000000000000000);
|
||||
insert into t1 values (10000000000000000000.0);
|
||||
insert into t1 values ('10000000000000000000');
|
||||
select * from t1;
|
||||
quantity
|
||||
10000000000000000000
|
||||
10000000000000000000
|
||||
10000000000000000000
|
||||
drop table t1;
|
||||
SELECT '0x8000000000000001'+0;
|
||||
'0x8000000000000001'+0
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '0x8000000000000001'
|
||||
create table t1 (
|
||||
value64 bigint unsigned not null,
|
||||
value32 integer not null,
|
||||
primary key(value64, value32)
|
||||
);
|
||||
create table t2 (
|
||||
value64 bigint unsigned not null,
|
||||
value32 integer not null,
|
||||
primary key(value64, value32)
|
||||
);
|
||||
insert into t1 values(17156792991891826145, 1);
|
||||
insert into t1 values( 9223372036854775807, 2);
|
||||
insert into t2 values(17156792991891826145, 3);
|
||||
insert into t2 values( 9223372036854775807, 4);
|
||||
select * from t1;
|
||||
value64 value32
|
||||
9223372036854775807 2
|
||||
17156792991891826145 1
|
||||
select * from t2;
|
||||
value64 value32
|
||||
9223372036854775807 4
|
||||
17156792991891826145 3
|
||||
select * from t1, t2 where t1.value64=17156792991891826145 and
|
||||
t2.value64=17156792991891826145;
|
||||
value64 value32 value64 value32
|
||||
17156792991891826145 1 17156792991891826145 3
|
||||
select * from t1, t2 where t1.value64=17156792991891826145 and
|
||||
t2.value64=t1.value64;
|
||||
value64 value32 value64 value32
|
||||
17156792991891826145 1 17156792991891826145 3
|
||||
select * from t1, t2 where t1.value64= 9223372036854775807 and
|
||||
t2.value64=9223372036854775807;
|
||||
value64 value32 value64 value32
|
||||
9223372036854775807 2 9223372036854775807 4
|
||||
select * from t1, t2 where t1.value64= 9223372036854775807 and
|
||||
t2.value64=t1.value64;
|
||||
value64 value32 value64 value32
|
||||
9223372036854775807 2 9223372036854775807 4
|
||||
drop table t1, t2;
|
||||
create table t1 select 1 as 'a';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(1) NOT NULL DEFAULT '0'
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 select 9223372036854775809 as 'a';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` bigint(19) unsigned NOT NULL DEFAULT '0'
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
select * from t1;
|
||||
a
|
||||
9223372036854775809
|
||||
drop table t1;
|
||||
DROP DATABASE IF EXISTS `scott`;
|
||||
Warnings:
|
||||
Note 1008 Can't drop database 'scott'; database doesn't exist
|
||||
create table t1 (a char(100), b varchar(100), c text, d blob);
|
||||
insert into t1 values(
|
||||
18446744073709551615,18446744073709551615,
|
||||
18446744073709551615, 18446744073709551615
|
||||
);
|
||||
insert into t1 values (-1 | 0,-1 | 0,-1 | 0 ,-1 | 0);
|
||||
select * from t1;
|
||||
a b c d
|
||||
18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
|
||||
18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
|
||||
drop table t1;
|
||||
create table t1 ( quantity decimal(2) unsigned);
|
||||
insert into t1 values (500), (-500), (~0), (-1);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'quantity' at row 1
|
||||
Warning 1264 Out of range value for column 'quantity' at row 2
|
||||
Warning 1264 Out of range value for column 'quantity' at row 3
|
||||
Warning 1264 Out of range value for column 'quantity' at row 4
|
||||
select * from t1;
|
||||
quantity
|
||||
99
|
||||
0
|
||||
99
|
||||
0
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
`col1` INT(1) NULL,
|
||||
`col2` INT(2) NULL,
|
||||
`col3` INT(3) NULL,
|
||||
`col4` INT(4) NULL,
|
||||
`col5` INT(5) NULL,
|
||||
`col6` INT(6) NULL,
|
||||
`col7` INT(7) NULL,
|
||||
`col8` INT(8) NULL,
|
||||
`col9` INT(9) NULL,
|
||||
`col10` BIGINT(10) NULL,
|
||||
`col11` BIGINT(11) NULL,
|
||||
`col12` BIGINT(12) NULL,
|
||||
`col13` BIGINT(13) NULL,
|
||||
`col14` BIGINT(14) NULL,
|
||||
`col15` BIGINT(15) NULL,
|
||||
`col16` BIGINT(16) NULL,
|
||||
`col17` BIGINT(17) NULL,
|
||||
`col18` BIGINT(18) NULL,
|
||||
`col19` DECIMAL(19, 0) NULL,
|
||||
`col20` DECIMAL(20, 0) NULL,
|
||||
`col21` DECIMAL(21, 0) NULL,
|
||||
`col22` DECIMAL(22, 0) NULL,
|
||||
`col23` DECIMAL(23, 0) NULL,
|
||||
`col24` DECIMAL(24, 0) NULL,
|
||||
`col25` DECIMAL(25, 0) NULL,
|
||||
`col26` DECIMAL(26, 0) NULL,
|
||||
`col27` DECIMAL(27, 0) NULL,
|
||||
`col28` DECIMAL(28, 0) NULL,
|
||||
`col29` DECIMAL(29, 0) NULL,
|
||||
`col30` DECIMAL(30, 0) NULL,
|
||||
`col31` DECIMAL(31, 0) NULL,
|
||||
`col32` DECIMAL(32, 0) NULL,
|
||||
`col33` DECIMAL(33, 0) NULL,
|
||||
`col34` DECIMAL(34, 0) NULL,
|
||||
`col35` DECIMAL(35, 0) NULL,
|
||||
`col36` DECIMAL(36, 0) NULL,
|
||||
`col37` DECIMAL(37, 0) NULL,
|
||||
`col38` DECIMAL(38, 0) NULL,
|
||||
`fix1` DECIMAL(38, 1) NULL,
|
||||
`fix2` DECIMAL(38, 2) NULL,
|
||||
`fix3` DECIMAL(38, 3) NULL,
|
||||
`fix4` DECIMAL(38, 4) NULL,
|
||||
`fix5` DECIMAL(38, 5) NULL,
|
||||
`fix6` DECIMAL(38, 6) NULL,
|
||||
`fix7` DECIMAL(38, 7) NULL,
|
||||
`fix8` DECIMAL(38, 8) NULL,
|
||||
`fix9` DECIMAL(38, 9) NULL,
|
||||
`fix10` DECIMAL(38, 10) NULL,
|
||||
`fix11` DECIMAL(38, 11) NULL,
|
||||
`fix12` DECIMAL(38, 12) NULL,
|
||||
`fix13` DECIMAL(38, 13) NULL,
|
||||
`fix14` DECIMAL(38, 14) NULL,
|
||||
`fix15` DECIMAL(38, 15) NULL,
|
||||
`fix16` DECIMAL(38, 16) NULL,
|
||||
`fix17` DECIMAL(38, 17) NULL,
|
||||
`fix18` DECIMAL(38, 18) NULL,
|
||||
`fix19` DECIMAL(38, 19) NULL,
|
||||
`fix20` DECIMAL(38, 20) NULL,
|
||||
`fix21` DECIMAL(38, 21) NULL,
|
||||
`fix22` DECIMAL(38, 22) NULL,
|
||||
`fix23` DECIMAL(38, 23) NULL,
|
||||
`fix24` DECIMAL(38, 24) NULL,
|
||||
`fix25` DECIMAL(38, 25) NULL,
|
||||
`fix26` DECIMAL(38, 26) NULL,
|
||||
`fix27` DECIMAL(38, 27) NULL,
|
||||
`fix28` DECIMAL(38, 28) NULL,
|
||||
`fix29` DECIMAL(38, 29) NULL,
|
||||
`fix30` DECIMAL(38, 30) NULL
|
||||
);
|
||||
INSERT INTO t1(`col1`, `col2`, `col3`, `col4`, `col5`, `col6`, `col7`, `col8`, `col9`, `col10`, `col11`, `col12`, `col13`, `col14`, `col15`, `col16`, `col17`, `col18`, `col19`, `col20`, `col21`, `col22`, `col23`, `col24`, `col25`, `col26`, `col27`, `col28`, `col29`, `col30`, `col31`, `col32`, `col33`, `col34`, `col35`, `col36`, `col37`, `col38`, `fix1`, `fix2`, `fix3`, `fix4`, `fix5`, `fix6`, `fix7`, `fix8`, `fix9`, `fix10`, `fix11`, `fix12`, `fix13`, `fix14`, `fix15`, `fix16`, `fix17`, `fix18`, `fix19`, `fix20`, `fix21`, `fix22`, `fix23`, `fix24`, `fix25`, `fix26`, `fix27`, `fix28`, `fix29`, `fix30`)
|
||||
VALUES (9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999,
|
||||
9999999999, 99999999999, 999999999999, 9999999999999, 99999999999999,
|
||||
999999999999999, 9999999999999999, 99999999999999999, 999999999999999999,
|
||||
9999999999999999999, 99999999999999999999, 999999999999999999999,
|
||||
9999999999999999999999, 99999999999999999999999, 999999999999999999999999,
|
||||
9999999999999999999999999, 99999999999999999999999999,
|
||||
999999999999999999999999999, 9999999999999999999999999999,
|
||||
99999999999999999999999999999, 999999999999999999999999999999,
|
||||
9999999999999999999999999999999, 99999999999999999999999999999999,
|
||||
999999999999999999999999999999999, 9999999999999999999999999999999999,
|
||||
99999999999999999999999999999999999, 999999999999999999999999999999999999,
|
||||
9999999999999999999999999999999999999, 99999999999999999999999999999999999999,
|
||||
9999999999999999999999999999999999999.9,
|
||||
999999999999999999999999999999999999.99,
|
||||
99999999999999999999999999999999999.999,
|
||||
9999999999999999999999999999999999.9999,
|
||||
999999999999999999999999999999999.99999,
|
||||
99999999999999999999999999999999.999999,
|
||||
9999999999999999999999999999999.9999999,
|
||||
999999999999999999999999999999.99999999,
|
||||
99999999999999999999999999999.999999999,
|
||||
9999999999999999999999999999.9999999999,
|
||||
999999999999999999999999999.99999999999,
|
||||
99999999999999999999999999.999999999999,
|
||||
9999999999999999999999999.9999999999999,
|
||||
999999999999999999999999.99999999999999,
|
||||
99999999999999999999999.999999999999999,
|
||||
9999999999999999999999.9999999999999999,
|
||||
999999999999999999999.99999999999999999,
|
||||
99999999999999999999.999999999999999999,
|
||||
9999999999999999999.9999999999999999999,
|
||||
999999999999999999.99999999999999999999,
|
||||
99999999999999999.999999999999999999999,
|
||||
9999999999999999.9999999999999999999999,
|
||||
999999999999999.99999999999999999999999,
|
||||
99999999999999.999999999999999999999999,
|
||||
9999999999999.9999999999999999999999999,
|
||||
999999999999.99999999999999999999999999,
|
||||
99999999999.999999999999999999999999999,
|
||||
9999999999.9999999999999999999999999999,
|
||||
999999999.99999999999999999999999999999,
|
||||
99999999.999999999999999999999999999999);
|
||||
SELECT * FROM t1;
|
||||
col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col11 col12 col13 col14 col15 col16 col17 col18 col19 col20 col21 col22 col23 col24 col25 col26 col27 col28 col29 col30 col31 col32 col33 col34 col35 col36 col37 col38 fix1 fix2 fix3 fix4 fix5 fix6 fix7 fix8 fix9 fix10 fix11 fix12 fix13 fix14 fix15 fix16 fix17 fix18 fix19 fix20 fix21 fix22 fix23 fix24 fix25 fix26 fix27 fix28 fix29 fix30
|
||||
9 99 999 9999 99999 999999 9999999 99999999 999999999 9999999999 99999999999 999999999999 9999999999999 99999999999999 999999999999999 9999999999999999 99999999999999999 999999999999999999 9999999999999999999 99999999999999999999 999999999999999999999 9999999999999999999999 99999999999999999999999 999999999999999999999999 9999999999999999999999999 99999999999999999999999999 999999999999999999999999999 9999999999999999999999999999 99999999999999999999999999999 999999999999999999999999999999 9999999999999999999999999999999 99999999999999999999999999999999 999999999999999999999999999999999 9999999999999999999999999999999999 99999999999999999999999999999999999 999999999999999999999999999999999999 9999999999999999999999999999999999999 99999999999999999999999999999999999999 9999999999999999999999999999999999999.9 999999999999999999999999999999999999.99 99999999999999999999999999999999999.999 9999999999999999999999999999999999.9999 999999999999999999999999999999999.99999 99999999999999999999999999999999.999999 9999999999999999999999999999999.9999999 999999999999999999999999999999.99999999 99999999999999999999999999999.999999999 9999999999999999999999999999.9999999999 999999999999999999999999999.99999999999 99999999999999999999999999.999999999999 9999999999999999999999999.9999999999999 999999999999999999999999.99999999999999 99999999999999999999999.999999999999999 9999999999999999999999.9999999999999999 999999999999999999999.99999999999999999 99999999999999999999.999999999999999999 9999999999999999999.9999999999999999999 999999999999999999.99999999999999999999 99999999999999999.999999999999999999999 9999999999999999.9999999999999999999999 999999999999999.99999999999999999999999 99999999999999.999999999999999999999999 9999999999999.9999999999999999999999999 999999999999.99999999999999999999999999 99999999999.999999999999999999999999999 9999999999.9999999999999999999999999999 999999999.99999999999999999999999999999 99999999.999999999999999999999999999999
|
||||
DROP TABLE t1;
|
||||
create table t1 (bigint_col bigint unsigned);
|
||||
insert into t1 values (17666000000000000000);
|
||||
select * from t1 where bigint_col=17666000000000000000;
|
||||
bigint_col
|
||||
17666000000000000000
|
||||
select * from t1 where bigint_col='17666000000000000000';
|
||||
bigint_col
|
||||
17666000000000000000
|
||||
drop table t1;
|
||||
|
||||
bug 19955 -- mod is signed with bigint
|
||||
select cast(10000002383263201056 as unsigned) mod 50 as result;
|
||||
result
|
||||
6
|
||||
create table t1 (c1 bigint unsigned);
|
||||
insert into t1 values (10000002383263201056);
|
||||
select c1 mod 50 as result from t1;
|
||||
result
|
||||
6
|
||||
drop table t1;
|
||||
162
mysql-test/suite/pbxt/r/binary.result
Normal file
162
mysql-test/suite/pbxt/r/binary.result
Normal file
@@ -0,0 +1,162 @@
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (name char(20) not null, primary key (name));
|
||||
create table t2 (name char(20) binary not null, primary key (name));
|
||||
insert into t1 values ("<22>");
|
||||
insert into t1 values ("<22>");
|
||||
insert into t1 values ("<22>");
|
||||
insert into t2 select * from t1;
|
||||
select * from t1 order by name;
|
||||
name
|
||||
<EFBFBD>
|
||||
<EFBFBD>
|
||||
<EFBFBD>
|
||||
select concat("*",name,"*") from t1 order by 1;
|
||||
concat("*",name,"*")
|
||||
*<2A>*
|
||||
*<2A>*
|
||||
*<2A>*
|
||||
select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t1;
|
||||
min(name) min(concat("*",name,"*")) max(name) max(concat("*",name,"*"))
|
||||
<EFBFBD> *<2A>* <09> *<2A>*
|
||||
select * from t2 order by name;
|
||||
name
|
||||
<EFBFBD>
|
||||
<EFBFBD>
|
||||
<EFBFBD>
|
||||
select concat("*",name,"*") from t2 order by 1;
|
||||
concat("*",name,"*")
|
||||
*<2A>*
|
||||
*<2A>*
|
||||
*<2A>*
|
||||
select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t2;
|
||||
min(name) min(concat("*",name,"*")) max(name) max(concat("*",name,"*"))
|
||||
<EFBFBD> *<2A>* <09> *<2A>*
|
||||
select name from t1 where name between '<27>' and '<27>';
|
||||
name
|
||||
<EFBFBD>
|
||||
<EFBFBD>
|
||||
select name from t2 where name between '<27>' and '<27>';
|
||||
name
|
||||
<EFBFBD>
|
||||
<EFBFBD>
|
||||
<EFBFBD>
|
||||
select name from t2 where name between '<27>' and '<27>';
|
||||
name
|
||||
drop table t1,t2;
|
||||
create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b));
|
||||
insert into t1 values ("hello ","hello "),("hello2 ","hello2 ");
|
||||
select concat("-",a,"-",b,"-") from t1 where a="hello";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
select concat("-",a,"-",b,"-") from t1 where a="hello ";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello ";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
select concat("-",a,"-",b,"-") from t1 where b="hello";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
select concat("-",a,"-",b,"-") from t1 where b="hello ";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
alter table t1 modify b tinytext not null, drop key b, add key (b(100));
|
||||
select concat("-",a,"-",b,"-") from t1;
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
-hello2-hello2-
|
||||
select concat("-",a,"-",b,"-") from t1 where b="hello ";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
drop table t1;
|
||||
create table t1 (b char(8));
|
||||
insert into t1 values(NULL);
|
||||
select b from t1 where binary b like '';
|
||||
b
|
||||
select b from t1 group by binary b like '';
|
||||
b
|
||||
NULL
|
||||
select b from t1 having binary b like '';
|
||||
b
|
||||
drop table t1;
|
||||
create table t1 (a char(3) binary, b binary(3));
|
||||
insert into t1 values ('aaa','bbb'),('AAA','BBB');
|
||||
select upper(a),upper(b) from t1;
|
||||
upper(a) upper(b)
|
||||
AAA bbb
|
||||
AAA BBB
|
||||
select lower(a),lower(b) from t1;
|
||||
lower(a) lower(b)
|
||||
aaa bbb
|
||||
aaa BBB
|
||||
select * from t1 where upper(a)='AAA';
|
||||
a b
|
||||
aaa bbb
|
||||
AAA BBB
|
||||
select * from t1 where lower(a)='aaa';
|
||||
a b
|
||||
aaa bbb
|
||||
AAA BBB
|
||||
select * from t1 where upper(b)='BBB';
|
||||
a b
|
||||
AAA BBB
|
||||
select * from t1 where lower(b)='bbb';
|
||||
a b
|
||||
aaa bbb
|
||||
select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1;
|
||||
charset(a) charset(b) charset(binary 'ccc')
|
||||
latin1 binary binary
|
||||
select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1;
|
||||
collation(a) collation(b) collation(binary 'ccc')
|
||||
latin1_bin binary binary
|
||||
drop table t1;
|
||||
create table t1( firstname char(20), lastname char(20));
|
||||
insert into t1 values ("john","doe"),("John","Doe");
|
||||
select * from t1 where firstname='john' and firstname like binary 'john';
|
||||
firstname lastname
|
||||
john doe
|
||||
select * from t1 where firstname='john' and binary 'john' = firstname;
|
||||
firstname lastname
|
||||
john doe
|
||||
select * from t1 where firstname='john' and firstname = binary 'john';
|
||||
firstname lastname
|
||||
john doe
|
||||
select * from t1 where firstname='John' and firstname like binary 'john';
|
||||
firstname lastname
|
||||
john doe
|
||||
select * from t1 where firstname='john' and firstname like binary 'John';
|
||||
firstname lastname
|
||||
John Doe
|
||||
drop table t1;
|
||||
create table t1 (a binary);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` binary(1) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (col1 binary(4));
|
||||
insert into t1 values ('a'),('a ');
|
||||
select hex(col1) from t1;
|
||||
hex(col1)
|
||||
61000000
|
||||
61200000
|
||||
alter table t1 modify col1 binary(10);
|
||||
select hex(col1) from t1;
|
||||
hex(col1)
|
||||
61000000000000000000
|
||||
61200000000000000000
|
||||
insert into t1 values ('b'),('b ');
|
||||
select hex(col1) from t1;
|
||||
hex(col1)
|
||||
61000000000000000000
|
||||
61200000000000000000
|
||||
62000000000000000000
|
||||
62200000000000000000
|
||||
drop table t1;
|
||||
88
mysql-test/suite/pbxt/r/bool.result
Normal file
88
mysql-test/suite/pbxt/r/bool.result
Normal file
@@ -0,0 +1,88 @@
|
||||
DROP TABLE IF EXISTS t1;
|
||||
SELECT IF(NULL AND 1, 1, 2), IF(1 AND NULL, 1, 2);
|
||||
IF(NULL AND 1, 1, 2) IF(1 AND NULL, 1, 2)
|
||||
2 2
|
||||
SELECT NULL AND 1, 1 AND NULL, 0 AND NULL, NULL and 0;
|
||||
NULL AND 1 1 AND NULL 0 AND NULL NULL and 0
|
||||
NULL NULL 0 0
|
||||
create table t1 (a int);
|
||||
insert into t1 values (0),(1),(NULL);
|
||||
SELECT * FROM t1 WHERE IF(a AND 1, 0, 1);
|
||||
a
|
||||
0
|
||||
NULL
|
||||
SELECT * FROM t1 WHERE IF(1 AND a, 0, 1);
|
||||
a
|
||||
0
|
||||
NULL
|
||||
SELECT * FROM t1 where NOT(a AND 1);
|
||||
a
|
||||
0
|
||||
SELECT * FROM t1 where NOT(1 AND a);
|
||||
a
|
||||
0
|
||||
SELECT * FROM t1 where (a AND 1)=0;
|
||||
a
|
||||
0
|
||||
SELECT * FROM t1 where (1 AND a)=0;
|
||||
a
|
||||
0
|
||||
SELECT * FROM t1 where (1 AND a)=1;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t1 where (1 AND a) IS NULL;
|
||||
a
|
||||
NULL
|
||||
set sql_mode='high_not_precedence';
|
||||
select * from t1 where not a between 2 and 3;
|
||||
a
|
||||
set sql_mode=default;
|
||||
select * from t1 where not a between 2 and 3;
|
||||
a
|
||||
0
|
||||
1
|
||||
select a, a is false, a is true, a is unknown from t1;
|
||||
a a is false a is true a is unknown
|
||||
0 1 0 0
|
||||
1 0 1 0
|
||||
NULL 0 0 1
|
||||
select a, a is not false, a is not true, a is not unknown from t1;
|
||||
a a is not false a is not true a is not unknown
|
||||
0 0 1 1
|
||||
1 1 0 1
|
||||
NULL 1 1 0
|
||||
SET @a=0, @b=0;
|
||||
SELECT * FROM t1 WHERE NULL AND (@a:=@a+1);
|
||||
a
|
||||
SELECT * FROM t1 WHERE NOT(a>=0 AND NULL AND (@b:=@b+1));
|
||||
a
|
||||
SELECT * FROM t1 WHERE a=2 OR (NULL AND (@a:=@a+1));
|
||||
a
|
||||
SELECT * FROM t1 WHERE NOT(a=2 OR (NULL AND (@b:=@b+1)));
|
||||
a
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
|
||||
select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1;
|
||||
A B nA nB AB n(AB) nAonB AoB n(AoB) nAnB
|
||||
N N N N N N N N N N
|
||||
0 N 1 N 0 1 1 N N N
|
||||
1 N 0 N N N N 1 0 0
|
||||
N 0 N 1 0 1 1 N N N
|
||||
N 1 N 0 N N N 1 0 0
|
||||
0 0 1 1 0 1 1 0 1 1
|
||||
0 1 1 0 0 1 1 1 0 0
|
||||
1 0 0 1 0 1 1 1 0 0
|
||||
1 1 0 0 1 0 0 1 0 0
|
||||
select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t1;
|
||||
A B nA nB AB n(AB) nAonB AoB n(AoB) nAnB
|
||||
N N N N N N N N N N
|
||||
0 N 1 N 0 1 1 N N N
|
||||
1 N 0 N N N N 1 0 0
|
||||
N 0 N 1 0 1 1 N N N
|
||||
N 1 N 0 N N N 1 0 0
|
||||
0 0 1 1 0 1 1 0 1 1
|
||||
0 1 1 0 0 1 1 1 0 0
|
||||
1 0 0 1 0 1 1 1 0 0
|
||||
1 1 0 0 1 0 0 1 0 0
|
||||
drop table t1;
|
||||
11
mysql-test/suite/pbxt/r/bulk_replace.result
Normal file
11
mysql-test/suite/pbxt/r/bulk_replace.result
Normal file
@@ -0,0 +1,11 @@
|
||||
drop table if exists t1;
|
||||
CREATE TABLE t1 (a int, unique (a), b int not null, unique(b), c int not null, index(c));
|
||||
replace into t1 values (1,1,1),(2,2,2),(3,1,3);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
2 2 2
|
||||
3 1 3
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
202
mysql-test/suite/pbxt/r/case.result
Normal file
202
mysql-test/suite/pbxt/r/case.result
Normal file
@@ -0,0 +1,202 @@
|
||||
drop table if exists t1,t2;
|
||||
select CASE "b" when "a" then 1 when "b" then 2 END;
|
||||
CASE "b" when "a" then 1 when "b" then 2 END
|
||||
2
|
||||
select CASE "c" when "a" then 1 when "b" then 2 END;
|
||||
CASE "c" when "a" then 1 when "b" then 2 END
|
||||
NULL
|
||||
select CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END;
|
||||
CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END
|
||||
3
|
||||
select CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END;
|
||||
CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END
|
||||
ok
|
||||
select CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END;
|
||||
CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END
|
||||
ok
|
||||
select CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end;
|
||||
CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end
|
||||
a
|
||||
select CASE when 1=0 then "true" else "false" END;
|
||||
CASE when 1=0 then "true" else "false" END
|
||||
false
|
||||
select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
|
||||
CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END
|
||||
one
|
||||
explain extended select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select (case 1 when 1 then 'one' when 2 then 'two' else 'more' end) AS `CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END`
|
||||
select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END;
|
||||
CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END
|
||||
two
|
||||
select (CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0;
|
||||
(CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0
|
||||
2
|
||||
select (CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0;
|
||||
(CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0
|
||||
2.00
|
||||
select case 1/0 when "a" then "true" else "false" END;
|
||||
case 1/0 when "a" then "true" else "false" END
|
||||
false
|
||||
select case 1/0 when "a" then "true" END;
|
||||
case 1/0 when "a" then "true" END
|
||||
NULL
|
||||
select (case 1/0 when "a" then "true" END) | 0;
|
||||
(case 1/0 when "a" then "true" END) | 0
|
||||
NULL
|
||||
select (case 1/0 when "a" then "true" END) + 0.0;
|
||||
(case 1/0 when "a" then "true" END) + 0.0
|
||||
NULL
|
||||
select case when 1>0 then "TRUE" else "FALSE" END;
|
||||
case when 1>0 then "TRUE" else "FALSE" END
|
||||
TRUE
|
||||
select case when 1<0 then "TRUE" else "FALSE" END;
|
||||
case when 1<0 then "TRUE" else "FALSE" END
|
||||
FALSE
|
||||
create table t1 (a int);
|
||||
insert into t1 values(1),(2),(3),(4);
|
||||
select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase;
|
||||
fcase count(*)
|
||||
0 2
|
||||
2 1
|
||||
3 1
|
||||
explain extended select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select (case `test`.`t1`.`a` when 1 then 2 when 2 then 3 else 0 end) AS `fcase`,count(0) AS `count(*)` from `test`.`t1` group by (case `test`.`t1`.`a` when 1 then 2 when 2 then 3 else 0 end)
|
||||
select case a when 1 then "one" when 2 then "two" else "nothing" end as fcase, count(*) from t1 group by fcase;
|
||||
fcase count(*)
|
||||
nothing 2
|
||||
one 1
|
||||
two 1
|
||||
drop table t1;
|
||||
create table t1 (row int not null, col int not null, val varchar(255) not null);
|
||||
insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small');
|
||||
select max(case col when 1 then val else null end) as color from t1 group by row;
|
||||
color
|
||||
orange
|
||||
yellow
|
||||
green
|
||||
drop table t1;
|
||||
SET NAMES latin1;
|
||||
CREATE TABLE t1 SELECT
|
||||
CASE WHEN 1 THEN _latin1'a' COLLATE latin1_danish_ci ELSE _latin1'a' END AS c1,
|
||||
CASE WHEN 1 THEN _latin1'a' ELSE _latin1'a' COLLATE latin1_danish_ci END AS c2,
|
||||
CASE WHEN 1 THEN 'a' ELSE 1 END AS c3,
|
||||
CASE WHEN 1 THEN 1 ELSE 'a' END AS c4,
|
||||
CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5,
|
||||
CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6,
|
||||
CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7,
|
||||
CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8,
|
||||
CASE WHEN 1 THEN 1.0 END AS c9,
|
||||
CASE WHEN 1 THEN 0.1e1 else 0.1 END AS c10,
|
||||
CASE WHEN 1 THEN 0.1e1 else 1 END AS c11,
|
||||
CASE WHEN 1 THEN 0.1e1 else '1' END AS c12
|
||||
;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '',
|
||||
`c2` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '',
|
||||
`c3` varbinary(1) NOT NULL DEFAULT '',
|
||||
`c4` varbinary(1) NOT NULL DEFAULT '',
|
||||
`c5` varbinary(4) NOT NULL DEFAULT '',
|
||||
`c6` varbinary(4) NOT NULL DEFAULT '',
|
||||
`c7` decimal(2,1) NOT NULL DEFAULT '0.0',
|
||||
`c8` decimal(2,1) NOT NULL DEFAULT '0.0',
|
||||
`c9` decimal(2,1) DEFAULT NULL,
|
||||
`c10` double NOT NULL DEFAULT '0',
|
||||
`c11` double NOT NULL DEFAULT '0',
|
||||
`c12` varbinary(5) NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
SELECT CASE
|
||||
WHEN 1
|
||||
THEN _latin1'a' COLLATE latin1_danish_ci
|
||||
ELSE _latin1'a' COLLATE latin1_swedish_ci
|
||||
END;
|
||||
ERROR HY000: Illegal mix of collations (latin1_danish_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'case'
|
||||
SELECT CASE _latin1'a' COLLATE latin1_general_ci
|
||||
WHEN _latin1'a' COLLATE latin1_danish_ci THEN 1
|
||||
WHEN _latin1'a' COLLATE latin1_swedish_ci THEN 2
|
||||
END;
|
||||
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_danish_ci,EXPLICIT), (latin1_swedish_ci,EXPLICIT) for operation 'case'
|
||||
SELECT
|
||||
CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END,
|
||||
CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END,
|
||||
CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END,
|
||||
CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END
|
||||
;
|
||||
CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END
|
||||
1 2 1 2
|
||||
CREATE TABLE t1 SELECT COALESCE(_latin1'a',_latin2'a');
|
||||
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'coalesce'
|
||||
CREATE TABLE t1 SELECT COALESCE('a' COLLATE latin1_swedish_ci,'b' COLLATE latin1_bin);
|
||||
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce'
|
||||
CREATE TABLE t1 SELECT
|
||||
COALESCE(1), COALESCE(1.0),COALESCE('a'),
|
||||
COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'),
|
||||
COALESCE('a' COLLATE latin1_bin,'b');
|
||||
explain extended SELECT
|
||||
COALESCE(1), COALESCE(1.0),COALESCE('a'),
|
||||
COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'),
|
||||
COALESCE('a' COLLATE latin1_bin,'b');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select coalesce(1) AS `COALESCE(1)`,coalesce(1.0) AS `COALESCE(1.0)`,coalesce('a') AS `COALESCE('a')`,coalesce(1,1.0) AS `COALESCE(1,1.0)`,coalesce(1,'1') AS `COALESCE(1,'1')`,coalesce(1.1,'1') AS `COALESCE(1.1,'1')`,coalesce(('a' collate latin1_bin),'b') AS `COALESCE('a' COLLATE latin1_bin,'b')`
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`COALESCE(1)` int(1) NOT NULL DEFAULT '0',
|
||||
`COALESCE(1.0)` decimal(2,1) NOT NULL DEFAULT '0.0',
|
||||
`COALESCE('a')` varchar(1) NOT NULL DEFAULT '',
|
||||
`COALESCE(1,1.0)` decimal(2,1) NOT NULL DEFAULT '0.0',
|
||||
`COALESCE(1,'1')` varbinary(1) NOT NULL DEFAULT '',
|
||||
`COALESCE(1.1,'1')` varbinary(4) NOT NULL DEFAULT '',
|
||||
`COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
SELECT 'case+union+test'
|
||||
UNION
|
||||
SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
|
||||
case+union+test
|
||||
case+union+test
|
||||
nobug
|
||||
SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
|
||||
CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END
|
||||
nobug
|
||||
SELECT 'case+union+test'
|
||||
UNION
|
||||
SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END;
|
||||
case+union+test
|
||||
case+union+test
|
||||
nobug
|
||||
create table t1(a float, b int default 3);
|
||||
insert into t1 (a) values (2), (11), (8);
|
||||
select min(a), min(case when 1=1 then a else NULL end),
|
||||
min(case when 1!=1 then NULL else a end)
|
||||
from t1 where b=3 group by b;
|
||||
min(a) min(case when 1=1 then a else NULL end) min(case when 1!=1 then NULL else a end)
|
||||
2 2 2
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (EMPNUM INT);
|
||||
INSERT INTO t1 VALUES (0), (2);
|
||||
CREATE TABLE t2 (EMPNUM DECIMAL (4, 2));
|
||||
INSERT INTO t2 VALUES (0.0), (9.0);
|
||||
SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
|
||||
t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
|
||||
FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
|
||||
CEMPNUM EMPMUM1 EMPNUM2
|
||||
0.00 0 0.00
|
||||
2.00 2 NULL
|
||||
SELECT IFNULL(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
|
||||
t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
|
||||
FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
|
||||
CEMPNUM EMPMUM1 EMPNUM2
|
||||
0.00 0 0.00
|
||||
2.00 2 NULL
|
||||
DROP TABLE t1,t2;
|
||||
396
mysql-test/suite/pbxt/r/cast.result
Normal file
396
mysql-test/suite/pbxt/r/cast.result
Normal file
@@ -0,0 +1,396 @@
|
||||
select CAST(1-2 AS UNSIGNED);
|
||||
CAST(1-2 AS UNSIGNED)
|
||||
18446744073709551615
|
||||
select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
|
||||
CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER)
|
||||
-1
|
||||
select CAST('10 ' as unsigned integer);
|
||||
CAST('10 ' as unsigned integer)
|
||||
10
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '10 '
|
||||
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
|
||||
cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1
|
||||
18446744073709551611 18446744073709551611
|
||||
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
|
||||
cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1
|
||||
18446744073709551610 18446744073709551612
|
||||
select ~5, cast(~5 as signed);
|
||||
~5 cast(~5 as signed)
|
||||
18446744073709551610 -6
|
||||
explain extended select ~5, cast(~5 as signed);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select ~(5) AS `~5`,cast(~(5) as signed) AS `cast(~5 as signed)`
|
||||
select cast(5 as unsigned) -6.0;
|
||||
cast(5 as unsigned) -6.0
|
||||
-1.0
|
||||
select cast(NULL as signed), cast(1/0 as signed);
|
||||
cast(NULL as signed) cast(1/0 as signed)
|
||||
NULL NULL
|
||||
select cast(NULL as unsigned), cast(1/0 as unsigned);
|
||||
cast(NULL as unsigned) cast(1/0 as unsigned)
|
||||
NULL NULL
|
||||
select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
|
||||
cast("A" as binary) = "a" cast(BINARY "a" as CHAR) = "A"
|
||||
0 1
|
||||
select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
|
||||
cast("2001-1-1" as DATE) cast("2001-1-1" as DATETIME)
|
||||
2001-01-01 2001-01-01 00:00:00
|
||||
select cast("1:2:3" as TIME);
|
||||
cast("1:2:3" as TIME)
|
||||
01:02:03
|
||||
select CONVERT("2004-01-22 21:45:33",DATE);
|
||||
CONVERT("2004-01-22 21:45:33",DATE)
|
||||
2004-01-22
|
||||
select 10+'10';
|
||||
10+'10'
|
||||
20
|
||||
select 10.0+'10';
|
||||
10.0+'10'
|
||||
20
|
||||
select 10E+0+'10';
|
||||
10E+0+'10'
|
||||
20
|
||||
select CONVERT(DATE "2004-01-22 21:45:33" USING latin1);
|
||||
CONVERT(DATE "2004-01-22 21:45:33" USING latin1)
|
||||
2004-01-22 21:45:33
|
||||
select CONVERT(DATE "2004-01-22 21:45:33",CHAR);
|
||||
CONVERT(DATE "2004-01-22 21:45:33",CHAR)
|
||||
2004-01-22 21:45:33
|
||||
select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4));
|
||||
CONVERT(DATE "2004-01-22 21:45:33",CHAR(4))
|
||||
2004
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33'
|
||||
select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4));
|
||||
CONVERT(DATE "2004-01-22 21:45:33",BINARY(4))
|
||||
2004
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33'
|
||||
select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4));
|
||||
CAST(DATE "2004-01-22 21:45:33" AS BINARY(4))
|
||||
2004
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33'
|
||||
select CAST(0xb3 as signed);
|
||||
CAST(0xb3 as signed)
|
||||
179
|
||||
select CAST(0x8fffffffffffffff as signed);
|
||||
CAST(0x8fffffffffffffff as signed)
|
||||
-8070450532247928833
|
||||
select CAST(0xffffffffffffffff as unsigned);
|
||||
CAST(0xffffffffffffffff as unsigned)
|
||||
18446744073709551615
|
||||
select CAST(0xfffffffffffffffe as signed);
|
||||
CAST(0xfffffffffffffffe as signed)
|
||||
-2
|
||||
select cast('-10a' as signed integer);
|
||||
cast('-10a' as signed integer)
|
||||
-10
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-10a'
|
||||
select cast('a10' as unsigned integer);
|
||||
cast('a10' as unsigned integer)
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: 'a10'
|
||||
select 10+'a';
|
||||
10+'a'
|
||||
10
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
select 10.0+cast('a' as decimal);
|
||||
10.0+cast('a' as decimal)
|
||||
10.0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DECIMAL value: 'a'
|
||||
select 10E+0+'a';
|
||||
10E+0+'a'
|
||||
10
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
select cast('18446744073709551616' as unsigned);
|
||||
cast('18446744073709551616' as unsigned)
|
||||
18446744073709551615
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '18446744073709551616'
|
||||
select cast('18446744073709551616' as signed);
|
||||
cast('18446744073709551616' as signed)
|
||||
-1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '18446744073709551616'
|
||||
select cast('9223372036854775809' as signed);
|
||||
cast('9223372036854775809' as signed)
|
||||
-9223372036854775807
|
||||
Warnings:
|
||||
Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement
|
||||
select cast('-1' as unsigned);
|
||||
cast('-1' as unsigned)
|
||||
18446744073709551615
|
||||
Warnings:
|
||||
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
|
||||
select cast('abc' as signed);
|
||||
cast('abc' as signed)
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: 'abc'
|
||||
select cast('1a' as signed);
|
||||
cast('1a' as signed)
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1a'
|
||||
select cast('' as signed);
|
||||
cast('' as signed)
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: ''
|
||||
set names binary;
|
||||
select cast(_latin1'test' as char character set latin2);
|
||||
cast(_latin1'test' as char character set latin2)
|
||||
test
|
||||
select cast(_koi8r'<27><><EFBFBD><EFBFBD>' as char character set cp1251);
|
||||
cast(_koi8r'<27><><EFBFBD><EFBFBD>' as char character set cp1251)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
create table t1 select cast(_koi8r'<27><><EFBFBD><EFBFBD>' as char character set cp1251) as t;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`t` varchar(4) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
select
|
||||
cast(_latin1'ab' AS char) as c1,
|
||||
cast(_latin1'a ' AS char) as c2,
|
||||
cast(_latin1'abc' AS char(2)) as c3,
|
||||
cast(_latin1'a ' AS char(2)) as c4,
|
||||
hex(cast(_latin1'a' AS char(2))) as c5;
|
||||
c1 c2 c3 c4 c5
|
||||
ab a ab a 6100
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'abc'
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'a '
|
||||
select cast(1000 as CHAR(3));
|
||||
cast(1000 as CHAR(3))
|
||||
100
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(3) value: '1000'
|
||||
create table t1 select
|
||||
cast(_latin1'ab' AS char) as c1,
|
||||
cast(_latin1'a ' AS char) as c2,
|
||||
cast(_latin1'abc' AS char(2)) as c3,
|
||||
cast(_latin1'a ' AS char(2)) as c4,
|
||||
cast(_latin1'a' AS char(2)) as c5;
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'abc'
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'a '
|
||||
select c1,c2,c3,c4,hex(c5) from t1;
|
||||
c1 c2 c3 c4 hex(c5)
|
||||
ab a ab a 6100
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` varbinary(2) NOT NULL DEFAULT '',
|
||||
`c2` varbinary(2) NOT NULL DEFAULT '',
|
||||
`c3` varbinary(2) NOT NULL DEFAULT '',
|
||||
`c4` varbinary(2) NOT NULL DEFAULT '',
|
||||
`c5` varbinary(2) NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
select
|
||||
cast(_koi8r'<27><>' AS nchar) as c1,
|
||||
cast(_koi8r'<27> ' AS nchar) as c2,
|
||||
cast(_koi8r'<27><><EFBFBD>' AS nchar(2)) as c3,
|
||||
cast(_koi8r'<27> ' AS nchar(2)) as c4,
|
||||
cast(_koi8r'<27>' AS nchar(2)) as c5;
|
||||
c1 c2 c3 c4 c5
|
||||
фг ф фг ф ф
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect CHAR(4) value: 'фгх'
|
||||
Warning 1292 Truncated incorrect CHAR(3) value: 'ф '
|
||||
create table t1 select
|
||||
cast(_koi8r'<27><>' AS nchar) as c1,
|
||||
cast(_koi8r'<27> ' AS nchar) as c2,
|
||||
cast(_koi8r'<27><><EFBFBD>' AS nchar(2)) as c3,
|
||||
cast(_koi8r'<27> ' AS nchar(2)) as c4,
|
||||
cast(_koi8r'<27>' AS nchar(2)) as c5;
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect CHAR(4) value: 'фгх'
|
||||
Warning 1292 Truncated incorrect CHAR(3) value: 'ф '
|
||||
select * from t1;
|
||||
c1 c2 c3 c4 c5
|
||||
фг ф фг ф ф
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`c2` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`c3` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`c4` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`c5` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (a binary(4), b char(4) character set koi8r);
|
||||
insert into t1 values (_binary'<27><><EFBFBD><EFBFBD>',_binary'<27><><EFBFBD><EFBFBD>');
|
||||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||||
a b cast(a as char character set cp1251) cast(b as binary)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD>
|
||||
set names koi8r;
|
||||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||||
a b cast(a as char character set cp1251) cast(b as binary)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD>
|
||||
set names cp1251;
|
||||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||||
a b cast(a as char character set cp1251) cast(b as binary)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD>
|
||||
drop table t1;
|
||||
set names binary;
|
||||
select cast("2001-1-1" as date) = "2001-01-01";
|
||||
cast("2001-1-1" as date) = "2001-01-01"
|
||||
1
|
||||
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
|
||||
cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
|
||||
1
|
||||
select cast("1:2:3" as TIME) = "1:02:03";
|
||||
cast("1:2:3" as TIME) = "1:02:03"
|
||||
0
|
||||
select cast(NULL as DATE);
|
||||
cast(NULL as DATE)
|
||||
NULL
|
||||
select cast(NULL as BINARY);
|
||||
cast(NULL as BINARY)
|
||||
NULL
|
||||
CREATE TABLE t1 (a enum ('aac','aab','aaa') not null);
|
||||
INSERT INTO t1 VALUES ('aaa'),('aab'),('aac');
|
||||
SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ;
|
||||
a CAST(a AS CHAR)
|
||||
aac aac
|
||||
aab aab
|
||||
aaa aaa
|
||||
SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a;
|
||||
a CAST(a AS CHAR(3))
|
||||
aac aac
|
||||
aab aab
|
||||
aaa aaa
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'aaa'
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'aab'
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'aac'
|
||||
SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ;
|
||||
a CAST(a AS UNSIGNED)
|
||||
aaa 3
|
||||
aab 2
|
||||
aac 1
|
||||
SELECT a, CAST(a AS CHAR(2)) FROM t1 ORDER BY CAST(a AS CHAR(3)), a;
|
||||
a CAST(a AS CHAR(2))
|
||||
aaa aa
|
||||
aab aa
|
||||
aac aa
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'aaa'
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'aab'
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'aac'
|
||||
DROP TABLE t1;
|
||||
select date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour);
|
||||
date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour)
|
||||
2004-12-30 00:00:00
|
||||
select timediff(cast('2004-12-30 12:00:00' as time), '12:00:00');
|
||||
timediff(cast('2004-12-30 12:00:00' as time), '12:00:00')
|
||||
00:00:00
|
||||
select timediff(cast('1 12:00:00' as time), '12:00:00');
|
||||
timediff(cast('1 12:00:00' as time), '12:00:00')
|
||||
24:00:00
|
||||
select cast(18446744073709551615 as unsigned);
|
||||
cast(18446744073709551615 as unsigned)
|
||||
18446744073709551615
|
||||
select cast(18446744073709551615 as signed);
|
||||
cast(18446744073709551615 as signed)
|
||||
-1
|
||||
select cast('18446744073709551615' as unsigned);
|
||||
cast('18446744073709551615' as unsigned)
|
||||
18446744073709551615
|
||||
select cast('18446744073709551615' as signed);
|
||||
cast('18446744073709551615' as signed)
|
||||
-1
|
||||
Warnings:
|
||||
Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement
|
||||
select cast('9223372036854775807' as signed);
|
||||
cast('9223372036854775807' as signed)
|
||||
9223372036854775807
|
||||
select cast(concat('184467440','73709551615') as unsigned);
|
||||
cast(concat('184467440','73709551615') as unsigned)
|
||||
18446744073709551615
|
||||
select cast(concat('184467440','73709551615') as signed);
|
||||
cast(concat('184467440','73709551615') as signed)
|
||||
-1
|
||||
Warnings:
|
||||
Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement
|
||||
select cast(repeat('1',20) as unsigned);
|
||||
cast(repeat('1',20) as unsigned)
|
||||
11111111111111111111
|
||||
select cast(repeat('1',20) as signed);
|
||||
cast(repeat('1',20) as signed)
|
||||
-7335632962598440505
|
||||
Warnings:
|
||||
Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement
|
||||
select cast(1.0e+300 as signed int);
|
||||
cast(1.0e+300 as signed int)
|
||||
9223372036854775807
|
||||
CREATE TABLE t1 (f1 double);
|
||||
INSERT INTO t1 SET f1 = -1.0e+30 ;
|
||||
INSERT INTO t1 SET f1 = +1.0e+30 ;
|
||||
SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1;
|
||||
double_val cast_val
|
||||
-1e+30 -9223372036854775808
|
||||
1e+30 9223372036854775807
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1e+30'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1e+30'
|
||||
DROP TABLE t1;
|
||||
select cast('1.2' as decimal(3,2));
|
||||
cast('1.2' as decimal(3,2))
|
||||
1.20
|
||||
select 1e18 * cast('1.2' as decimal(3,2));
|
||||
1e18 * cast('1.2' as decimal(3,2))
|
||||
1.2e+18
|
||||
select cast(cast('1.2' as decimal(3,2)) as signed);
|
||||
cast(cast('1.2' as decimal(3,2)) as signed)
|
||||
1
|
||||
set @v1=1e18;
|
||||
select cast(@v1 as decimal(22, 2));
|
||||
cast(@v1 as decimal(22, 2))
|
||||
1000000000000000000.00
|
||||
select cast(-1e18 as decimal(22,2));
|
||||
cast(-1e18 as decimal(22,2))
|
||||
-1000000000000000000.00
|
||||
create table t1(s1 time);
|
||||
insert into t1 values ('11:11:11');
|
||||
select cast(s1 as decimal(7,2)) from t1;
|
||||
cast(s1 as decimal(7,2))
|
||||
99999.99
|
||||
Warnings:
|
||||
Error 1264 Out of range value for column 'cast(s1 as decimal(7,2))' at row 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (v varchar(10), tt tinytext, t text,
|
||||
mt mediumtext, lt longtext);
|
||||
INSERT INTO t1 VALUES ('1.01', '2.02', '3.03', '4.04', '5.05');
|
||||
SELECT CAST(v AS DECIMAL), CAST(tt AS DECIMAL), CAST(t AS DECIMAL),
|
||||
CAST(mt AS DECIMAL), CAST(lt AS DECIMAL) from t1;
|
||||
CAST(v AS DECIMAL) CAST(tt AS DECIMAL) CAST(t AS DECIMAL) CAST(mt AS DECIMAL) CAST(lt AS DECIMAL)
|
||||
1 2 3 4 5
|
||||
DROP TABLE t1;
|
||||
select cast(NULL as decimal(6)) as t1;
|
||||
t1
|
||||
NULL
|
||||
set names latin1;
|
||||
select hex(cast('a' as char(2) binary));
|
||||
hex(cast('a' as char(2) binary))
|
||||
61
|
||||
select hex(cast('a' as binary(2)));
|
||||
hex(cast('a' as binary(2)))
|
||||
6100
|
||||
select hex(cast('a' as char(2) binary));
|
||||
hex(cast('a' as char(2) binary))
|
||||
61
|
||||
End of 5.0 tests
|
||||
16
mysql-test/suite/pbxt/r/check.result
Normal file
16
mysql-test/suite/pbxt/r/check.result
Normal file
@@ -0,0 +1,16 @@
|
||||
drop table if exists t1;
|
||||
create table t1(n int not null, key(n), key(n), key(n), key(n));
|
||||
check table t1 extended;
|
||||
insert into t1 values (200000);
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
Create table t1(f1 int);
|
||||
Create table t2(f1 int);
|
||||
Create view v1 as Select * from t1;
|
||||
Check Table v1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.v1 check status OK
|
||||
test.t2 check status OK
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
74
mysql-test/suite/pbxt/r/client_xml.result
Normal file
74
mysql-test/suite/pbxt/r/client_xml.result
Normal file
@@ -0,0 +1,74 @@
|
||||
create table t1 (
|
||||
`a&b` int,
|
||||
`a<b` int,
|
||||
`a>b` text
|
||||
);
|
||||
insert into t1 values (1, 2, 'a&b a<b a>b');
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="select * from t1
|
||||
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="a&b">1</field>
|
||||
<field name="a<b">2</field>
|
||||
<field name="a>b">a&b a<b a>b</field>
|
||||
</row>
|
||||
</resultset>
|
||||
<?xml version="1.0"?>
|
||||
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<database name="test">
|
||||
<table_structure name="t1">
|
||||
<field Field="a&b" Type="int(11)" Null="YES" Key="" Extra="" />
|
||||
<field Field="a<b" Type="int(11)" Null="YES" Key="" Extra="" />
|
||||
<field Field="a>b" Type="text" Null="YES" Key="" Extra="" />
|
||||
</table_structure>
|
||||
<table_data name="t1">
|
||||
<row>
|
||||
<field name="a&b">1</field>
|
||||
<field name="a<b">2</field>
|
||||
<field name="a>b">a&b a<b a>b</field>
|
||||
</row>
|
||||
</table_data>
|
||||
</database>
|
||||
</mysqldump>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="select count(*) from t1
|
||||
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="count(*)">1</field>
|
||||
</row>
|
||||
</resultset>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="select 1 < 2 from dual
|
||||
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="1 < 2">1</field>
|
||||
</row>
|
||||
</resultset>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="select 1 > 2 from dual
|
||||
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="1 > 2">0</field>
|
||||
</row>
|
||||
</resultset>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="select 1 & 3 from dual
|
||||
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="1 & 3">1</field>
|
||||
</row>
|
||||
</resultset>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="select null from dual
|
||||
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="NULL" xsi:nil="true" />
|
||||
</row>
|
||||
</resultset>
|
||||
drop table t1;
|
||||
28
mysql-test/suite/pbxt/r/comments.result
Normal file
28
mysql-test/suite/pbxt/r/comments.result
Normal file
@@ -0,0 +1,28 @@
|
||||
select 1+2/*hello*/+3;
|
||||
1+2/*hello*/+3
|
||||
6
|
||||
select 1 /* long
|
||||
multi line comment */;
|
||||
1
|
||||
1
|
||||
;
|
||||
ERROR 42000: Query was empty
|
||||
select 1 /*!32301 +1 */;
|
||||
1 +1
|
||||
2
|
||||
select 1 /*!52301 +1 */;
|
||||
1
|
||||
1
|
||||
select 1--1;
|
||||
1--1
|
||||
2
|
||||
select 1 --2
|
||||
+1;
|
||||
1 --2
|
||||
+1
|
||||
4
|
||||
select 1 # The rest of the row will be ignored
|
||||
;
|
||||
1
|
||||
1
|
||||
/* line with only comment */;
|
||||
55
mysql-test/suite/pbxt/r/compare.result
Normal file
55
mysql-test/suite/pbxt/r/compare.result
Normal file
@@ -0,0 +1,55 @@
|
||||
drop table if exists t1;
|
||||
CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
|
||||
insert into t1 values ('000000000001'),('000000000002');
|
||||
explain select * from t1 where id=000000000001;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 12 NULL 2 Using where; Using index
|
||||
select * from t1 where id=000000000001;
|
||||
id
|
||||
000000000001
|
||||
delete from t1 where id=000000000002;
|
||||
select * from t1;
|
||||
id
|
||||
000000000001
|
||||
drop table t1;
|
||||
SELECT 'a' = 'a ';
|
||||
'a' = 'a '
|
||||
1
|
||||
SELECT 'a\0' < 'a';
|
||||
'a\0' < 'a'
|
||||
1
|
||||
SELECT 'a\0' < 'a ';
|
||||
'a\0' < 'a '
|
||||
1
|
||||
SELECT 'a\t' < 'a';
|
||||
'a\t' < 'a'
|
||||
1
|
||||
SELECT 'a\t' < 'a ';
|
||||
'a\t' < 'a '
|
||||
1
|
||||
CREATE TABLE t1 (a char(10) not null);
|
||||
INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a ');
|
||||
SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1;
|
||||
hex(a) STRCMP(a,'a') STRCMP(a,'a ')
|
||||
61 0 0
|
||||
6100 -1 -1
|
||||
6109 -1 -1
|
||||
61 0 0
|
||||
DROP TABLE t1;
|
||||
SELECT CHAR(31) = '', '' = CHAR(31);
|
||||
CHAR(31) = '' '' = CHAR(31)
|
||||
0 0
|
||||
SELECT CHAR(30) = '', '' = CHAR(30);
|
||||
CHAR(30) = '' '' = CHAR(30)
|
||||
0 0
|
||||
create table t1 (a tinyint(1),b binary(1));
|
||||
insert into t1 values (0x01,0x01);
|
||||
select * from t1 where a=b;
|
||||
a b
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: ''
|
||||
select * from t1 where a=b and b=0x01;
|
||||
a b
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: ''
|
||||
drop table if exists t1;
|
||||
117
mysql-test/suite/pbxt/r/connect.result
Normal file
117
mysql-test/suite/pbxt/r/connect.result
Normal file
@@ -0,0 +1,117 @@
|
||||
drop table if exists t1,t2;
|
||||
show tables;
|
||||
Tables_in_mysql
|
||||
columns_priv
|
||||
db
|
||||
event
|
||||
func
|
||||
general_log
|
||||
help_category
|
||||
help_keyword
|
||||
help_relation
|
||||
help_topic
|
||||
host
|
||||
ndb_binlog_index
|
||||
plugin
|
||||
proc
|
||||
procs_priv
|
||||
servers
|
||||
slow_log
|
||||
tables_priv
|
||||
time_zone
|
||||
time_zone_leap_second
|
||||
time_zone_name
|
||||
time_zone_transition
|
||||
time_zone_transition_type
|
||||
user
|
||||
show tables;
|
||||
Tables_in_test
|
||||
connect(localhost,root,z,test2,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
|
||||
connect(localhost,root,z,test,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
|
||||
grant ALL on *.* to test@localhost identified by "gambling";
|
||||
grant ALL on *.* to test@127.0.0.1 identified by "gambling";
|
||||
show tables;
|
||||
Tables_in_mysql
|
||||
columns_priv
|
||||
db
|
||||
event
|
||||
func
|
||||
general_log
|
||||
help_category
|
||||
help_keyword
|
||||
help_relation
|
||||
help_topic
|
||||
host
|
||||
ndb_binlog_index
|
||||
plugin
|
||||
proc
|
||||
procs_priv
|
||||
servers
|
||||
slow_log
|
||||
tables_priv
|
||||
time_zone
|
||||
time_zone_leap_second
|
||||
time_zone_name
|
||||
time_zone_transition
|
||||
time_zone_transition_type
|
||||
user
|
||||
show tables;
|
||||
Tables_in_test
|
||||
connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
|
||||
connect(localhost,test,,"",MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
|
||||
connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
|
||||
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
|
||||
update mysql.user set password=old_password("gambling2") where user=_binary"test";
|
||||
flush privileges;
|
||||
set password="";
|
||||
set password='gambling3';
|
||||
ERROR HY000: Password hash should be a 41-digit hexadecimal number
|
||||
set password=old_password('gambling3');
|
||||
show tables;
|
||||
Tables_in_mysql
|
||||
columns_priv
|
||||
db
|
||||
event
|
||||
func
|
||||
general_log
|
||||
help_category
|
||||
help_keyword
|
||||
help_relation
|
||||
help_topic
|
||||
host
|
||||
ndb_binlog_index
|
||||
plugin
|
||||
proc
|
||||
procs_priv
|
||||
servers
|
||||
slow_log
|
||||
tables_priv
|
||||
time_zone
|
||||
time_zone_leap_second
|
||||
time_zone_name
|
||||
time_zone_transition
|
||||
time_zone_transition_type
|
||||
user
|
||||
show tables;
|
||||
Tables_in_test
|
||||
connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
|
||||
connect(localhost,test,,test,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
|
||||
connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
|
||||
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
|
||||
delete from mysql.user where user=_binary"test";
|
||||
flush privileges;
|
||||
create table t1 (id integer not null auto_increment primary key);
|
||||
create temporary table t2(id integer not null auto_increment primary key);
|
||||
set @id := 1;
|
||||
delete from t1 where id like @id;
|
||||
drop table t1;
|
||||
15
mysql-test/suite/pbxt/r/consistent_snapshot.result
Normal file
15
mysql-test/suite/pbxt/r/consistent_snapshot.result
Normal file
@@ -0,0 +1,15 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (a int) engine=innodb;
|
||||
start transaction with consistent snapshot;
|
||||
insert into t1 values(1);
|
||||
select * from t1;
|
||||
a
|
||||
commit;
|
||||
delete from t1;
|
||||
start transaction;
|
||||
insert into t1 values(1);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
commit;
|
||||
drop table t1;
|
||||
29
mysql-test/suite/pbxt/r/constraints.result
Normal file
29
mysql-test/suite/pbxt/r/constraints.result
Normal file
@@ -0,0 +1,29 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (a int check (a>0));
|
||||
insert into t1 values (1);
|
||||
insert into t1 values (0);
|
||||
drop table t1;
|
||||
create table t1 (a int ,b int, check a>b);
|
||||
insert into t1 values (1,0);
|
||||
insert into t1 values (0,1);
|
||||
drop table t1;
|
||||
create table t1 (a int ,b int, constraint abc check (a>b));
|
||||
insert into t1 values (1,0);
|
||||
insert into t1 values (0,1);
|
||||
drop table t1;
|
||||
create table t1 (a int null);
|
||||
insert into t1 values (1),(NULL);
|
||||
drop table t1;
|
||||
create table t1 (a int null);
|
||||
alter table t1 add constraint constraint_1 unique (a);
|
||||
alter table t1 add constraint unique key_1(a);
|
||||
alter table t1 add constraint constraint_2 unique key_2(a);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
UNIQUE KEY `constraint_1` (`a`),
|
||||
UNIQUE KEY `key_1` (`a`),
|
||||
UNIQUE KEY `key_2` (`a`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
5
mysql-test/suite/pbxt/r/contributors.result
Normal file
5
mysql-test/suite/pbxt/r/contributors.result
Normal file
@@ -0,0 +1,5 @@
|
||||
SHOW CONTRIBUTORS;
|
||||
Name Location Comment
|
||||
Ronald Bradford Brisbane, Australia EFF contribution for UC2006 Auction
|
||||
Sheeri Kritzer Boston, Mass. USA EFF contribution for UC2006 Auction
|
||||
Mark Shuttleworth London, UK. EFF contribution for UC2006 Auction
|
||||
68
mysql-test/suite/pbxt/r/count_distinct.result
Normal file
68
mysql-test/suite/pbxt/r/count_distinct.result
Normal file
@@ -0,0 +1,68 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
create table t1 (libname varchar(21) not null, city text, primary key (libname));
|
||||
create table t2 (isbn varchar(21) not null, author text, title text, primary key (isbn));
|
||||
create table t3 (isbn varchar(21) not null, libname varchar(21) not null, quantity int ,primary key (isbn,libname));
|
||||
insert into t2 values ('001','Daffy','A duck''s life');
|
||||
insert into t2 values ('002','Bugs','A rabbit\'s life');
|
||||
insert into t2 values ('003','Cowboy','Life on the range');
|
||||
insert into t2 values ('000','Anonymous','Wanna buy this book?');
|
||||
insert into t2 values ('004','Best Seller','One Heckuva book');
|
||||
insert into t2 values ('005','EveryoneBuys','This very book');
|
||||
insert into t2 values ('006','San Fran','It is a san fran lifestyle');
|
||||
insert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');
|
||||
insert into t3 values('000','New York Public Libra','1');
|
||||
insert into t3 values('001','New York Public Libra','2');
|
||||
insert into t3 values('002','New York Public Libra','3');
|
||||
insert into t3 values('003','New York Public Libra','4');
|
||||
insert into t3 values('004','New York Public Libra','5');
|
||||
insert into t3 values('005','New York Public Libra','6');
|
||||
insert into t3 values('006','San Fransisco Public','5');
|
||||
insert into t3 values('007','Berkeley Public1','3');
|
||||
insert into t3 values('007','Berkeley Public2','3');
|
||||
insert into t3 values('001','NYC Lib','8');
|
||||
insert into t1 values ('New York Public Libra','New York');
|
||||
insert into t1 values ('San Fransisco Public','San Fran');
|
||||
insert into t1 values ('Berkeley Public1','Berkeley');
|
||||
insert into t1 values ('Berkeley Public2','Berkeley');
|
||||
insert into t1 values ('NYC Lib','New York');
|
||||
select t2.isbn,city,t1.libname,count(t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city,t1.libname;
|
||||
isbn city libname a
|
||||
007 Berkeley Berkeley Public1 1
|
||||
007 Berkeley Berkeley Public2 1
|
||||
000 New York New York Public Libra 6
|
||||
001 New York NYC Lib 1
|
||||
006 San Fran San Fransisco Public 1
|
||||
select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city having count(distinct t1.libname) > 1;
|
||||
isbn city libname a
|
||||
007 Berkeley Berkeley Public1 2
|
||||
000 New York New York Public Libra 2
|
||||
select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city having count(distinct concat(t1.libname,'a')) > 1;
|
||||
isbn city libname a
|
||||
007 Berkeley Berkeley Public1 2
|
||||
000 New York New York Public Libra 2
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (f1 int);
|
||||
insert into t1 values (1);
|
||||
create table t2 (f1 int,f2 int);
|
||||
select t1.f1,count(distinct t2.f2),count(distinct 1,NULL) from t1 left join t2 on t1.f1=t2.f1 group by t1.f1;
|
||||
f1 count(distinct t2.f2) count(distinct 1,NULL)
|
||||
1 0 0
|
||||
drop table t1,t2;
|
||||
create table t1 (f int);
|
||||
select count(distinct f) from t1;
|
||||
count(distinct f)
|
||||
0
|
||||
drop table t1;
|
||||
create table t1 (a char(3), b char(20), primary key (a, b));
|
||||
insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English');
|
||||
select count(distinct a) from t1 group by b;
|
||||
count(distinct a)
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (f1 int, f2 int);
|
||||
insert into t1 values (0,1),(1,2);
|
||||
select count(distinct if(f1,3,f2)) from t1;
|
||||
count(distinct if(f1,3,f2))
|
||||
2
|
||||
drop table t1;
|
||||
129
mysql-test/suite/pbxt/r/count_distinct2.result
Normal file
129
mysql-test/suite/pbxt/r/count_distinct2.result
Normal file
@@ -0,0 +1,129 @@
|
||||
drop table if exists t1;
|
||||
create table t1(n1 int, n2 int, s char(20), vs varchar(20), t text);
|
||||
insert into t1 values (1,11, 'one','eleven', 'eleven'),
|
||||
(1,11, 'one','eleven', 'eleven'),
|
||||
(2,11, 'two','eleven', 'eleven'),
|
||||
(2,12, 'two','twevle', 'twelve'),
|
||||
(2,13, 'two','thirteen', 'foo'),
|
||||
(2,13, 'two','thirteen', 'foo'),
|
||||
(2,13, 'two','thirteen', 'bar'),
|
||||
(NULL,13, 'two','thirteen', 'bar'),
|
||||
(2,NULL, 'two','thirteen', 'bar'),
|
||||
(2,13, NULL,'thirteen', 'bar'),
|
||||
(2,13, 'two',NULL, 'bar'),
|
||||
(2,13, 'two','thirteen', NULL);
|
||||
select distinct n1 from t1;
|
||||
n1
|
||||
1
|
||||
2
|
||||
NULL
|
||||
select count(distinct n1) from t1;
|
||||
count(distinct n1)
|
||||
2
|
||||
select distinct n2 from t1;
|
||||
n2
|
||||
11
|
||||
12
|
||||
13
|
||||
NULL
|
||||
select count(distinct n2) from t1;
|
||||
count(distinct n2)
|
||||
3
|
||||
select distinct s from t1;
|
||||
s
|
||||
one
|
||||
two
|
||||
NULL
|
||||
select count(distinct s) from t1;
|
||||
count(distinct s)
|
||||
2
|
||||
select distinct vs from t1;
|
||||
vs
|
||||
eleven
|
||||
twevle
|
||||
thirteen
|
||||
NULL
|
||||
select count(distinct vs) from t1;
|
||||
count(distinct vs)
|
||||
3
|
||||
select distinct t from t1;
|
||||
t
|
||||
eleven
|
||||
twelve
|
||||
foo
|
||||
bar
|
||||
NULL
|
||||
select count(distinct t) from t1;
|
||||
count(distinct t)
|
||||
4
|
||||
select distinct n1,n2 from t1;
|
||||
n1 n2
|
||||
1 11
|
||||
2 11
|
||||
2 12
|
||||
2 13
|
||||
NULL 13
|
||||
2 NULL
|
||||
select count(distinct n1,n2) from t1;
|
||||
count(distinct n1,n2)
|
||||
4
|
||||
select distinct n1,s from t1;
|
||||
n1 s
|
||||
1 one
|
||||
2 two
|
||||
NULL two
|
||||
2 NULL
|
||||
select count(distinct n1,s) from t1;
|
||||
count(distinct n1,s)
|
||||
2
|
||||
select distinct s,n1,vs from t1;
|
||||
s n1 vs
|
||||
one 1 eleven
|
||||
two 2 eleven
|
||||
two 2 twevle
|
||||
two 2 thirteen
|
||||
two NULL thirteen
|
||||
NULL 2 thirteen
|
||||
two 2 NULL
|
||||
select count(distinct s,n1,vs) from t1;
|
||||
count(distinct s,n1,vs)
|
||||
4
|
||||
select distinct s,t from t1;
|
||||
s t
|
||||
one eleven
|
||||
two eleven
|
||||
two twelve
|
||||
two foo
|
||||
two bar
|
||||
NULL bar
|
||||
two NULL
|
||||
select count(distinct s,t) from t1;
|
||||
count(distinct s,t)
|
||||
5
|
||||
select count(distinct n1), count(distinct n2) from t1;
|
||||
count(distinct n1) count(distinct n2)
|
||||
2 3
|
||||
select count(distinct n2), n1 from t1 group by n1;
|
||||
count(distinct n2) n1
|
||||
1 NULL
|
||||
1 1
|
||||
3 2
|
||||
drop table t1;
|
||||
create table t1 (n int default NULL);
|
||||
flush status;
|
||||
select count(distinct n) from t1;
|
||||
count(distinct n)
|
||||
5000
|
||||
show status like 'Created_tmp_disk_tables';
|
||||
Variable_name Value
|
||||
Created_tmp_disk_tables 0
|
||||
drop table t1;
|
||||
create table t1 (s text);
|
||||
flush status;
|
||||
select count(distinct s) from t1;
|
||||
count(distinct s)
|
||||
5000
|
||||
show status like 'Created_tmp_disk_tables';
|
||||
Variable_name Value
|
||||
Created_tmp_disk_tables 1
|
||||
drop table t1;
|
||||
8
mysql-test/suite/pbxt/r/count_distinct3.result
Normal file
8
mysql-test/suite/pbxt/r/count_distinct3.result
Normal file
@@ -0,0 +1,8 @@
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER);
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
4181000
|
||||
SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp;
|
||||
DROP TABLE t1;
|
||||
set @@read_buffer_size=default;
|
||||
837
mysql-test/suite/pbxt/r/create.result
Normal file
837
mysql-test/suite/pbxt/r/create.result
Normal file
@@ -0,0 +1,837 @@
|
||||
drop table if exists t1,t2,t3,t4,t5;
|
||||
drop database if exists mysqltest;
|
||||
create table t1 (b char(0));
|
||||
insert into t1 values (""),(null);
|
||||
select * from t1;
|
||||
b
|
||||
|
||||
NULL
|
||||
drop table if exists t1;
|
||||
create table t1 (b char(0) not null);
|
||||
create table if not exists t1 (b char(0) not null);
|
||||
Warnings:
|
||||
Note 1050 Table 't1' already exists
|
||||
insert into t1 values (""),(null);
|
||||
Warnings:
|
||||
Warning 1048 Column 'b' cannot be null
|
||||
select * from t1;
|
||||
b
|
||||
|
||||
|
||||
drop table t1;
|
||||
create table t1 (a int not null auto_increment,primary key (a)) engine=heap;
|
||||
drop table t1;
|
||||
create table t2 engine=heap select * from t1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
create table t2 select auto+1 from t1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
drop table if exists t1,t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
Note 1051 Unknown table 't2'
|
||||
create table t1 (b char(0) not null, index(b));
|
||||
ERROR 42000: The used storage engine can't index column 'b'
|
||||
create table t1 (a int not null,b text) engine=heap;
|
||||
ERROR 42000: The used table type doesn't support BLOB/TEXT columns
|
||||
drop table if exists t1;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) engine=heap;
|
||||
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
|
||||
create table not_existing_database.test (a int);
|
||||
ERROR 42000: Unknown database 'not_existing_database'
|
||||
create table `a/a` (a int);
|
||||
show create table `a/a`;
|
||||
Table Create Table
|
||||
a/a CREATE TABLE `a/a` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
create table t1 like `a/a`;
|
||||
drop table `a/a`;
|
||||
drop table `t1`;
|
||||
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int);
|
||||
ERROR 42000: Incorrect table name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
|
||||
create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int);
|
||||
ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long
|
||||
create table t1 (a datetime default now());
|
||||
ERROR 42000: Invalid default value for 'a'
|
||||
create table t1 (a datetime on update now());
|
||||
ERROR HY000: Invalid ON UPDATE clause for 'a' column
|
||||
create table t1 (a int default 100 auto_increment);
|
||||
ERROR 42000: Invalid default value for 'a'
|
||||
create table t1 (a tinyint default 1000);
|
||||
ERROR 42000: Invalid default value for 'a'
|
||||
create table t1 (a varchar(5) default 'abcdef');
|
||||
ERROR 42000: Invalid default value for 'a'
|
||||
create table t1 (a varchar(5) default 'abcde');
|
||||
insert into t1 values();
|
||||
select * from t1;
|
||||
a
|
||||
abcde
|
||||
alter table t1 alter column a set default 'abcdef';
|
||||
ERROR 42000: Invalid default value for 'a'
|
||||
drop table t1;
|
||||
create table 1ea10 (1a20 int,1e int);
|
||||
insert into 1ea10 values(1,1);
|
||||
select 1ea10.1a20,1e+ 1e+10 from 1ea10;
|
||||
1a20 1e+ 1e+10
|
||||
1 10000000001
|
||||
drop table 1ea10;
|
||||
create table t1 (t1.index int);
|
||||
drop table t1;
|
||||
drop database if exists mysqltest;
|
||||
Warnings:
|
||||
Note 1008 Can't drop database 'mysqltest'; database doesn't exist
|
||||
create database mysqltest;
|
||||
create table mysqltest.$test1 (a$1 int, $b int, c$ int);
|
||||
insert into mysqltest.$test1 values (1,2,3);
|
||||
select a$1, $b, c$ from mysqltest.$test1;
|
||||
a$1 $b c$
|
||||
1 2 3
|
||||
create table mysqltest.test2$ (a int);
|
||||
drop table mysqltest.test2$;
|
||||
drop database mysqltest;
|
||||
create table `` (a int);
|
||||
ERROR 42000: Incorrect table name ''
|
||||
drop table if exists ``;
|
||||
ERROR 42000: Incorrect table name ''
|
||||
create table t1 (`` int);
|
||||
ERROR 42000: Incorrect column name ''
|
||||
create table t1 (i int, index `` (i));
|
||||
ERROR 42000: Incorrect index name ''
|
||||
create table t1 (a int auto_increment not null primary key, B CHAR(20));
|
||||
insert into t1 (b) values ("hello"),("my"),("world");
|
||||
create table t2 (key (b)) select * from t1;
|
||||
explain select * from t2 where b="world";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref B B 21 const 1 Using where
|
||||
select * from t2 where b="world";
|
||||
a B
|
||||
3 world
|
||||
drop table t1,t2;
|
||||
create table t1(x varchar(50) );
|
||||
create table t2 select x from t1 where 1=2;
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
x varchar(50) YES NULL
|
||||
describe t2;
|
||||
Field Type Null Key Default Extra
|
||||
x varchar(50) YES NULL
|
||||
drop table t2;
|
||||
create table t2 select now() as a , curtime() as b, curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f;
|
||||
describe t2;
|
||||
Field Type Null Key Default Extra
|
||||
a datetime NO 0000-00-00 00:00:00
|
||||
b time NO 00:00:00
|
||||
c date NO 0000-00-00
|
||||
d int(3) NO 0
|
||||
e decimal(3,1) NO 0.0
|
||||
f bigint(19) NO 0
|
||||
drop table t2;
|
||||
create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("20:45:11" AS TIME) as t, CAST("2001-12-29 20:45:11" AS DATETIME) as dt;
|
||||
describe t2;
|
||||
Field Type Null Key Default Extra
|
||||
d date YES NULL
|
||||
t time YES NULL
|
||||
dt datetime YES NULL
|
||||
drop table t1,t2;
|
||||
create table t1 (a tinyint);
|
||||
create table t2 (a int) select * from t1;
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a tinyint(4) YES NULL
|
||||
describe t2;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
drop table if exists t2;
|
||||
create table t2 (a int, a float) select * from t1;
|
||||
ERROR 42S21: Duplicate column name 'a'
|
||||
drop table if exists t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't2'
|
||||
create table t2 (a int) select a as b, a+1 as b from t1;
|
||||
ERROR 42S21: Duplicate column name 'b'
|
||||
drop table if exists t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't2'
|
||||
create table t2 (b int) select a as b, a+1 as b from t1;
|
||||
ERROR 42S21: Duplicate column name 'b'
|
||||
drop table if exists t1,t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't2'
|
||||
CREATE TABLE t1 (a int not null);
|
||||
INSERT INTO t1 values (1),(2),(1);
|
||||
CREATE TABLE t2 (primary key(a)) SELECT * FROM t1;
|
||||
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
||||
SELECT * from t2;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
DROP TABLE t1;
|
||||
DROP TABLE IF EXISTS t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't2'
|
||||
create table t1 (a int not null, b int, primary key(a), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`a`),
|
||||
KEY `b` (`b`),
|
||||
KEY `b_2` (`b`),
|
||||
KEY `b_3` (`b`),
|
||||
KEY `b_4` (`b`),
|
||||
KEY `b_5` (`b`),
|
||||
KEY `b_6` (`b`),
|
||||
KEY `b_7` (`b`),
|
||||
KEY `b_8` (`b`),
|
||||
KEY `b_9` (`b`),
|
||||
KEY `b_10` (`b`),
|
||||
KEY `b_11` (`b`),
|
||||
KEY `b_12` (`b`),
|
||||
KEY `b_13` (`b`),
|
||||
KEY `b_14` (`b`),
|
||||
KEY `b_15` (`b`),
|
||||
KEY `b_16` (`b`),
|
||||
KEY `b_17` (`b`),
|
||||
KEY `b_18` (`b`),
|
||||
KEY `b_19` (`b`),
|
||||
KEY `b_20` (`b`),
|
||||
KEY `b_21` (`b`),
|
||||
KEY `b_22` (`b`),
|
||||
KEY `b_23` (`b`),
|
||||
KEY `b_24` (`b`),
|
||||
KEY `b_25` (`b`),
|
||||
KEY `b_26` (`b`),
|
||||
KEY `b_27` (`b`),
|
||||
KEY `b_28` (`b`),
|
||||
KEY `b_29` (`b`),
|
||||
KEY `b_30` (`b`),
|
||||
KEY `b_31` (`b`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 select if(1,'1','0'), month("2002-08-02");
|
||||
drop table t1;
|
||||
create table t1 select if('2002'='2002','Y','N');
|
||||
select * from t1;
|
||||
if('2002'='2002','Y','N')
|
||||
Y
|
||||
drop table if exists t1;
|
||||
SET SESSION storage_engine="heap";
|
||||
SELECT @@storage_engine;
|
||||
@@storage_engine
|
||||
MEMORY
|
||||
CREATE TABLE t1 (a int not null);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
SET SESSION storage_engine="gemini";
|
||||
ERROR 42000: Unknown table engine 'gemini'
|
||||
SELECT @@storage_engine;
|
||||
@@storage_engine
|
||||
MEMORY
|
||||
CREATE TABLE t1 (a int not null);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
SET SESSION storage_engine=default;
|
||||
drop table t1;
|
||||
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));
|
||||
insert into t1 values ("a", 1), ("b", 2);
|
||||
insert into t1 values ("c", NULL);
|
||||
ERROR 23000: Column 'k2' cannot be null
|
||||
insert into t1 values (NULL, 3);
|
||||
ERROR 23000: Column 'k1' cannot be null
|
||||
insert into t1 values (NULL, NULL);
|
||||
ERROR 23000: Column 'k1' cannot be null
|
||||
drop table t1;
|
||||
create table t1 select x'4132';
|
||||
drop table t1;
|
||||
create table t1 select 1,2,3;
|
||||
create table if not exists t1 select 1,2;
|
||||
Warnings:
|
||||
Note 1050 Table 't1' already exists
|
||||
create table if not exists t1 select 1,2,3,4;
|
||||
ERROR 21S01: Column count doesn't match value count at row 1
|
||||
create table if not exists t1 select 1;
|
||||
Warnings:
|
||||
Note 1050 Table 't1' already exists
|
||||
select * from t1;
|
||||
1 2 3
|
||||
1 2 3
|
||||
0 1 2
|
||||
0 0 1
|
||||
drop table t1;
|
||||
flush status;
|
||||
create table t1 (a int not null, b int, primary key (a));
|
||||
insert into t1 values (1,1);
|
||||
create table if not exists t1 select 2;
|
||||
Warnings:
|
||||
Note 1050 Table 't1' already exists
|
||||
Warning 1364 Field 'a' doesn't have a default value
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
0 2
|
||||
create table if not exists t1 select 3 as 'a',4 as 'b';
|
||||
Warnings:
|
||||
Note 1050 Table 't1' already exists
|
||||
create table if not exists t1 select 3 as 'a',3 as 'b';
|
||||
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Note 1050 Table 't1' already exists
|
||||
Error 1062 Duplicate entry '3' for key 'PRIMARY'
|
||||
show status like "Opened_tables";
|
||||
Variable_name Value
|
||||
Opened_tables 3
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
0 2
|
||||
3 4
|
||||
drop table t1;
|
||||
create table `t1 `(a int);
|
||||
ERROR 42000: Incorrect table name 't1 '
|
||||
create database `db1 `;
|
||||
ERROR 42000: Incorrect database name 'db1 '
|
||||
create table t1(`a ` int);
|
||||
ERROR 42000: Incorrect column name 'a '
|
||||
create table t1 (a int,);
|
||||
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
|
||||
create table t1 (a int,,b int);
|
||||
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 'b int)' at line 1
|
||||
create table t1 (,b int);
|
||||
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 'b int)' at line 1
|
||||
create table t1 (a int, key(a));
|
||||
create table t2 (b int, foreign key(b) references t1(a), key(b));
|
||||
drop table if exists t2,t1;
|
||||
create table t1(id int not null, name char(20));
|
||||
insert into t1 values(10,'mysql'),(20,'monty- the creator');
|
||||
create table t2(id int not null);
|
||||
insert into t2 values(10),(20);
|
||||
create table t3 like t1;
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`id` int(11) NOT NULL,
|
||||
`name` char(20) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
select * from t3;
|
||||
id name
|
||||
create table if not exists t3 like t1;
|
||||
Warnings:
|
||||
Note 1050 Table 't3' already exists
|
||||
select @@warning_count;
|
||||
@@warning_count
|
||||
1
|
||||
create temporary table t3 like t2;
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TEMPORARY TABLE `t3` (
|
||||
`id` int(11) NOT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
select * from t3;
|
||||
id
|
||||
drop table t3;
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`id` int(11) NOT NULL,
|
||||
`name` char(20) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
select * from t3;
|
||||
id name
|
||||
drop table t2, t3;
|
||||
create database mysqltest;
|
||||
alter table t1;
|
||||
create table mysqltest.t3 like t1;
|
||||
create temporary table t3 like mysqltest.t3;
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TEMPORARY TABLE `t3` (
|
||||
`id` int(11) NOT NULL,
|
||||
`name` char(20) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
create table t2 like t3;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`id` int(11) NOT NULL,
|
||||
`name` char(20) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
select * from t2;
|
||||
id name
|
||||
create table t3 like t1;
|
||||
create table t3 like mysqltest.t3;
|
||||
ERROR 42S01: Table 't3' already exists
|
||||
create table non_existing_database.t1 like t1;
|
||||
ERROR 42000: Unknown database 'non_existing_database'
|
||||
create table t3 like non_existing_table;
|
||||
ERROR 42S02: Table 'test.non_existing_table' doesn't exist
|
||||
create temporary table t3 like t1;
|
||||
ERROR 42S01: Table 't3' already exists
|
||||
drop table t1, t2, t3;
|
||||
drop table t3;
|
||||
drop database mysqltest;
|
||||
SET SESSION storage_engine="heap";
|
||||
SELECT @@storage_engine;
|
||||
@@storage_engine
|
||||
MEMORY
|
||||
CREATE TABLE t1 (a int not null);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
SET SESSION storage_engine="gemini";
|
||||
ERROR 42000: Unknown table engine 'gemini'
|
||||
SELECT @@storage_engine;
|
||||
@@storage_engine
|
||||
MEMORY
|
||||
CREATE TABLE t1 (a int not null);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
SET SESSION storage_engine=default;
|
||||
drop table t1;
|
||||
create table t1(a int,b int,c int unsigned,d date,e char,f datetime,g time,h blob);
|
||||
insert into t1(a)values(1);
|
||||
insert into t1(a,b,c,d,e,f,g,h)
|
||||
values(2,-2,2,'1825-12-14','a','2003-1-1 3:2:1','4:3:2','binary data');
|
||||
select * from t1;
|
||||
a b c d e f g h
|
||||
1 NULL NULL NULL NULL NULL NULL NULL
|
||||
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data
|
||||
select a,
|
||||
ifnull(b,cast(-7 as signed)) as b,
|
||||
ifnull(c,cast(7 as unsigned)) as c,
|
||||
ifnull(d,cast('2000-01-01' as date)) as d,
|
||||
ifnull(e,cast('b' as char)) as e,
|
||||
ifnull(f,cast('2000-01-01' as datetime)) as f,
|
||||
ifnull(g,cast('5:4:3' as time)) as g,
|
||||
ifnull(h,cast('yet another binary data' as binary)) as h,
|
||||
addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd
|
||||
from t1;
|
||||
a b c d e f g h dd
|
||||
1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00
|
||||
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00
|
||||
create table t2
|
||||
select
|
||||
a,
|
||||
ifnull(b,cast(-7 as signed)) as b,
|
||||
ifnull(c,cast(7 as unsigned)) as c,
|
||||
ifnull(d,cast('2000-01-01' as date)) as d,
|
||||
ifnull(e,cast('b' as char)) as e,
|
||||
ifnull(f,cast('2000-01-01' as datetime)) as f,
|
||||
ifnull(g,cast('5:4:3' as time)) as g,
|
||||
ifnull(h,cast('yet another binary data' as binary)) as h,
|
||||
addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd
|
||||
from t1;
|
||||
explain t2;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b bigint(11) NO 0
|
||||
c bigint(11) unsigned NO 0
|
||||
d date YES NULL
|
||||
e varchar(1) NO
|
||||
f datetime YES NULL
|
||||
g time YES NULL
|
||||
h longblob NO NULL
|
||||
dd time YES NULL
|
||||
select * from t2;
|
||||
a b c d e f g h dd
|
||||
1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00
|
||||
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00
|
||||
drop table t1, t2;
|
||||
create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp, l datetime, m enum('a','b'), n set('a','b'), o char(10));
|
||||
create table t2 select ifnull(a,a), ifnull(b,b), ifnull(c,c), ifnull(d,d), ifnull(e,e), ifnull(f,f), ifnull(g,g), ifnull(h,h), ifnull(i,i), ifnull(j,j), ifnull(k,k), ifnull(l,l), ifnull(m,m), ifnull(n,n), ifnull(o,o) from t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`ifnull(a,a)` tinyint(4) DEFAULT NULL,
|
||||
`ifnull(b,b)` smallint(6) DEFAULT NULL,
|
||||
`ifnull(c,c)` mediumint(8) DEFAULT NULL,
|
||||
`ifnull(d,d)` int(11) DEFAULT NULL,
|
||||
`ifnull(e,e)` bigint(20) DEFAULT NULL,
|
||||
`ifnull(f,f)` float(3,2) DEFAULT NULL,
|
||||
`ifnull(g,g)` double(4,3) DEFAULT NULL,
|
||||
`ifnull(h,h)` decimal(5,4) DEFAULT NULL,
|
||||
`ifnull(i,i)` year(4) DEFAULT NULL,
|
||||
`ifnull(j,j)` date DEFAULT NULL,
|
||||
`ifnull(k,k)` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`ifnull(l,l)` datetime DEFAULT NULL,
|
||||
`ifnull(m,m)` varchar(1) DEFAULT NULL,
|
||||
`ifnull(n,n)` varchar(3) DEFAULT NULL,
|
||||
`ifnull(o,o)` varchar(10) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1,t2;
|
||||
create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14');
|
||||
insert into t1 values ('','',0,0.0);
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
str varchar(10) YES def
|
||||
strnull varchar(10) YES NULL
|
||||
intg int(11) YES 10
|
||||
rel double YES 3.14
|
||||
create table t2 select default(str) as str, default(strnull) as strnull, default(intg) as intg, default(rel) as rel from t1;
|
||||
describe t2;
|
||||
Field Type Null Key Default Extra
|
||||
str varchar(10) YES NULL
|
||||
strnull varchar(10) YES NULL
|
||||
intg int(11) YES NULL
|
||||
rel double YES NULL
|
||||
drop table t1, t2;
|
||||
create table t1(name varchar(10), age smallint default -1);
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
name varchar(10) YES NULL
|
||||
age smallint(6) YES -1
|
||||
create table t2(name varchar(10), age smallint default - 1);
|
||||
describe t2;
|
||||
Field Type Null Key Default Extra
|
||||
name varchar(10) YES NULL
|
||||
age smallint(6) YES -1
|
||||
drop table t1, t2;
|
||||
create table t1(cenum enum('a'), cset set('b'));
|
||||
create table t2(cenum enum('a','a'), cset set('b','b'));
|
||||
Warnings:
|
||||
Note 1291 Column 'cenum' has duplicated value 'a' in ENUM
|
||||
Note 1291 Column 'cset' has duplicated value 'b' in SET
|
||||
create table t3(cenum enum('a','A','a','c','c'), cset set('b','B','b','d','d'));
|
||||
Warnings:
|
||||
Note 1291 Column 'cenum' has duplicated value 'a' in ENUM
|
||||
Note 1291 Column 'cenum' has duplicated value 'A' in ENUM
|
||||
Note 1291 Column 'cenum' has duplicated value 'c' in ENUM
|
||||
Note 1291 Column 'cset' has duplicated value 'b' in SET
|
||||
Note 1291 Column 'cset' has duplicated value 'B' in SET
|
||||
Note 1291 Column 'cset' has duplicated value 'd' in SET
|
||||
drop table t1, t2, t3;
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
select database();
|
||||
database()
|
||||
mysqltest
|
||||
drop database mysqltest;
|
||||
select database();
|
||||
database()
|
||||
NULL
|
||||
create user mysqltest_1;
|
||||
select database(), user();
|
||||
database() user()
|
||||
NULL mysqltest_1@localhost
|
||||
drop user mysqltest_1;
|
||||
use test;
|
||||
create table t1 (a int, index `primary` (a));
|
||||
ERROR 42000: Incorrect index name 'primary'
|
||||
create table t1 (a int, index `PRIMARY` (a));
|
||||
ERROR 42000: Incorrect index name 'PRIMARY'
|
||||
create table t1 (`primary` int, index(`primary`));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`primary` int(11) DEFAULT NULL,
|
||||
KEY `primary_2` (`primary`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
create table t2 (`PRIMARY` int, index(`PRIMARY`));
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`PRIMARY` int(11) DEFAULT NULL,
|
||||
KEY `PRIMARY_2` (`PRIMARY`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
create table t3 (a int);
|
||||
alter table t3 add index `primary` (a);
|
||||
ERROR 42000: Incorrect index name 'primary'
|
||||
alter table t3 add index `PRIMARY` (a);
|
||||
ERROR 42000: Incorrect index name 'PRIMARY'
|
||||
create table t4 (`primary` int);
|
||||
alter table t4 add index(`primary`);
|
||||
show create table t4;
|
||||
Table Create Table
|
||||
t4 CREATE TABLE `t4` (
|
||||
`primary` int(11) DEFAULT NULL,
|
||||
KEY `primary_2` (`primary`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
create table t5 (`PRIMARY` int);
|
||||
alter table t5 add index(`PRIMARY`);
|
||||
show create table t5;
|
||||
Table Create Table
|
||||
t5 CREATE TABLE `t5` (
|
||||
`PRIMARY` int(11) DEFAULT NULL,
|
||||
KEY `PRIMARY_2` (`PRIMARY`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1, t2, t3, t4, t5;
|
||||
CREATE TABLE t1(id varchar(10) NOT NULL PRIMARY KEY, dsc longtext);
|
||||
INSERT INTO t1 VALUES ('5000000001', NULL),('5000000003', 'Test'),('5000000004', NULL);
|
||||
CREATE TABLE t2(id varchar(15) NOT NULL, proc varchar(100) NOT NULL, runID varchar(16) NOT NULL, start datetime NOT NULL, PRIMARY KEY (id,proc,runID,start));
|
||||
INSERT INTO t2 VALUES ('5000000001', 'proc01', '20031029090650', '2003-10-29 13:38:40'),('5000000001', 'proc02', '20031029090650', '2003-10-29 13:38:51'),('5000000001', 'proc03', '20031029090650', '2003-10-29 13:38:11'),('5000000002', 'proc09', '20031024013310', '2003-10-24 01:33:11'),('5000000002', 'proc09', '20031024153537', '2003-10-24 15:36:04'),('5000000004', 'proc01', '20031024013641', '2003-10-24 01:37:29'),('5000000004', 'proc02', '20031024013641', '2003-10-24 01:37:39');
|
||||
CREATE TABLE t3 SELECT t1.dsc,COUNT(DISTINCT t2.id) AS countOfRuns FROM t1 LEFT JOIN t2 ON (t1.id=t2.id) GROUP BY t1.id;
|
||||
SELECT * FROM t3;
|
||||
dsc countOfRuns
|
||||
NULL 1
|
||||
Test 0
|
||||
NULL 1
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (b bool not null default false);
|
||||
create table t2 (b bool not null default true);
|
||||
insert into t1 values ();
|
||||
insert into t2 values ();
|
||||
select * from t1;
|
||||
b
|
||||
0
|
||||
select * from t2;
|
||||
b
|
||||
1
|
||||
drop table t1,t2;
|
||||
create table t1 (a int);
|
||||
create table t1 select * from t1;
|
||||
ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
||||
create table t2 union = (t1) select * from t1;
|
||||
ERROR HY000: 'test.t2' is not BASE TABLE
|
||||
flush tables with read lock;
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
create table t1(column.name int);
|
||||
ERROR 42000: Incorrect table name 'column'
|
||||
create table t1(test.column.name int);
|
||||
ERROR 42000: Incorrect table name 'column'
|
||||
create table t1(xyz.t1.name int);
|
||||
ERROR 42000: Incorrect database name 'xyz'
|
||||
create table t1(t1.name int);
|
||||
create table t2(test.t2.name int);
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (f1 VARCHAR(255) CHARACTER SET utf8);
|
||||
CREATE TABLE t2 AS SELECT LEFT(f1,171) AS f2 FROM t1 UNION SELECT LEFT(f1,171) AS f2 FROM t1;
|
||||
DESC t2;
|
||||
Field Type Null Key Default Extra
|
||||
f2 varchar(171) YES NULL
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t12913 (f1 ENUM ('a','b')) AS SELECT 'a' AS f1;
|
||||
SELECT * FROM t12913;
|
||||
f1
|
||||
a
|
||||
DROP TABLE t12913;
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
drop database mysqltest;
|
||||
create table test.t1 like x;
|
||||
ERROR 3D000: No database selected
|
||||
drop table if exists test.t1;
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
create view v1 as select 'foo' from dual;
|
||||
create table t1 like v1;
|
||||
ERROR HY000: 'mysqltest.v1' is not BASE TABLE
|
||||
drop view v1;
|
||||
drop database mysqltest;
|
||||
create database mysqltest;
|
||||
create database if not exists mysqltest character set latin2;
|
||||
Warnings:
|
||||
Note 1007 Can't create database 'mysqltest'; database exists
|
||||
show create database mysqltest;
|
||||
Database Create Database
|
||||
mysqltest CREATE DATABASE `mysqltest` /*!40100 DEFAULT CHARACTER SET latin1 */
|
||||
drop database mysqltest;
|
||||
use test;
|
||||
create table t1 (a int);
|
||||
create table if not exists t1 (a int);
|
||||
Warnings:
|
||||
Note 1050 Table 't1' already exists
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a varchar(112) charset utf8 collate utf8_bin not null,
|
||||
primary key (a)
|
||||
) select 'test' as a ;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varchar(112) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
CREATE TABLE t2 (
|
||||
a int(11) default NULL
|
||||
);
|
||||
insert into t2 values(111);
|
||||
create table t1 (
|
||||
a varchar(12) charset utf8 collate utf8_bin not null,
|
||||
b int not null, primary key (a)
|
||||
) select a, 1 as b from t2 ;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
|
||||
`b` int(11) NOT NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a varchar(12) charset utf8 collate utf8_bin not null,
|
||||
b int not null, primary key (a)
|
||||
) select a, 1 as c from t2 ;
|
||||
Warnings:
|
||||
Warning 1364 Field 'b' doesn't have a default value
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`b` int(11) NOT NULL,
|
||||
`a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
|
||||
`c` int(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a varchar(12) charset utf8 collate utf8_bin not null,
|
||||
b int null, primary key (a)
|
||||
) select a, 1 as c from t2 ;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
|
||||
`c` int(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a varchar(12) charset utf8 collate utf8_bin not null,
|
||||
b int not null, primary key (a)
|
||||
) select 'a' as a , 1 as b from t2 ;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
|
||||
`b` int(11) NOT NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a varchar(12) charset utf8 collate utf8_bin,
|
||||
b int not null, primary key (a)
|
||||
) select 'a' as a , 1 as b from t2 ;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||
`b` int(11) NOT NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1, t2;
|
||||
create table t1 (
|
||||
a1 int not null,
|
||||
a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
|
||||
);
|
||||
insert into t1 values (1,1,1, 1,1,1, 1,1,1);
|
||||
create table t2 (
|
||||
a1 varchar(12) charset utf8 collate utf8_bin not null,
|
||||
a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
|
||||
primary key (a1)
|
||||
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
|
||||
drop table t2;
|
||||
create table t2 (
|
||||
a1 varchar(12) charset utf8 collate utf8_bin,
|
||||
a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
|
||||
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1;
|
||||
drop table t1, t2;
|
||||
create table t1 (
|
||||
a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
|
||||
);
|
||||
insert into t1 values (1,1,1, 1,1,1, 1,1,1);
|
||||
create table t2 (
|
||||
a1 varchar(12) charset utf8 collate utf8_bin not null,
|
||||
a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
|
||||
primary key (a1)
|
||||
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
|
||||
drop table t2;
|
||||
create table t2 ( a int default 3, b int default 3)
|
||||
select a1,a2 from t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` int(11) DEFAULT '3',
|
||||
`b` int(11) DEFAULT '3',
|
||||
`a1` int(11) DEFAULT NULL,
|
||||
`a2` int(11) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1, t2;
|
||||
create table t1(a set("a,b","c,d") not null);
|
||||
ERROR 22007: Illegal set 'a,b' value found during parsing
|
||||
create table t1 (i int) engine=myisam max_rows=100000000000;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 MAX_ROWS=4294967295
|
||||
alter table t1 max_rows=100;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 MAX_ROWS=100
|
||||
alter table t1 max_rows=100000000000;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 MAX_ROWS=4294967295
|
||||
drop table t1;
|
||||
create table t1 (upgrade int);
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
insert into t1 values (1,1),(1,2);
|
||||
CREATE TABLE t2 (primary key (a)) select * from t1;
|
||||
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
||||
drop table if exists t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't2'
|
||||
CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1;
|
||||
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
||||
drop table if exists t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't2'
|
||||
CREATE TABLE t2 (a int, b int, primary key (a));
|
||||
CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
|
||||
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
||||
SELECT * from t2;
|
||||
a b
|
||||
TRUNCATE table t2;
|
||||
INSERT INTO t2 select * from t1;
|
||||
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
||||
SELECT * from t2;
|
||||
a b
|
||||
drop table t2;
|
||||
CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a));
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
|
||||
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
||||
SELECT * from t2;
|
||||
a b
|
||||
TRUNCATE table t2;
|
||||
INSERT INTO t2 select * from t1;
|
||||
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
||||
SELECT * from t2;
|
||||
a b
|
||||
drop table t1,t2;
|
||||
CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
|
||||
DROP DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
|
||||
RENAME DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa TO 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 'DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' at line 1
|
||||
RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
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 'DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' at line 1
|
||||
create database mysqltest;
|
||||
RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
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 'DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' at line 1
|
||||
drop database mysqltest;
|
||||
USE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
|
||||
SHOW CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
|
||||
584
mysql-test/suite/pbxt/r/date_formats.result
Normal file
584
mysql-test/suite/pbxt/r/date_formats.result
Normal file
@@ -0,0 +1,584 @@
|
||||
drop table if exists t1;
|
||||
SHOW GLOBAL VARIABLES LIKE "%_format%";
|
||||
Variable_name Value
|
||||
binlog_format <format>
|
||||
date_format %Y-%m-%d
|
||||
datetime_format %Y-%m-%d %H:%i:%s
|
||||
default_week_format 0
|
||||
time_format %H:%i:%s
|
||||
SHOW SESSION VARIABLES LIKE "%_format%";
|
||||
Variable_name Value
|
||||
binlog_format <format>
|
||||
date_format %Y-%m-%d
|
||||
datetime_format %Y-%m-%d %H:%i:%s
|
||||
default_week_format 0
|
||||
time_format %H:%i:%s
|
||||
SET time_format='%H%i%s';
|
||||
SET time_format='%H:%i:%s.%f';
|
||||
SET time_format='%h-%i-%s.%f%p';
|
||||
SET time_format='%h:%i:%s.%f %p';
|
||||
SET time_format='%h:%i:%s%p';
|
||||
SET date_format='%Y%m%d';
|
||||
SET date_format='%Y.%m.%d';
|
||||
SET date_format='%d.%m.%Y';
|
||||
SET date_format='%m-%d-%Y';
|
||||
set datetime_format= '%Y%m%d%H%i%s';
|
||||
set datetime_format= '%Y-%m-%d %H:%i:%s';
|
||||
set datetime_format= '%m-%d-%y %H:%i:%s.%f';
|
||||
set datetime_format= '%d-%m-%Y %h:%i:%s%p';
|
||||
set datetime_format= '%H:%i:%s %Y-%m-%d';
|
||||
set datetime_format= '%H:%i:%s.%f %m-%d-%Y';
|
||||
set datetime_format= '%h:%i:%s %p %Y-%m-%d';
|
||||
set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d';
|
||||
SHOW SESSION VARIABLES LIKE "%format";
|
||||
Variable_name Value
|
||||
binlog_format <format>
|
||||
date_format %m-%d-%Y
|
||||
datetime_format %h:%i:%s.%f %p %Y-%m-%d
|
||||
default_week_format 0
|
||||
time_format %h:%i:%s%p
|
||||
SET time_format='%h:%i:%s';
|
||||
ERROR 42000: Variable 'time_format' can't be set to the value of '%h:%i:%s'
|
||||
SET time_format='%H %i:%s';
|
||||
ERROR 42000: Variable 'time_format' can't be set to the value of '%H %i:%s'
|
||||
SET time_format='%H::%i:%s';
|
||||
ERROR 42000: Variable 'time_format' can't be set to the value of '%H::%i:%s'
|
||||
SET time_format='%H:%i:%s%f';
|
||||
ERROR 42000: Variable 'time_format' can't be set to the value of '%H:%i:%s%f'
|
||||
SET time_format='%H:%i.%f:%s';
|
||||
ERROR 42000: Variable 'time_format' can't be set to the value of '%H:%i.%f:%s'
|
||||
SET time_format='%H:%i:%s%p';
|
||||
ERROR 42000: Variable 'time_format' can't be set to the value of '%H:%i:%s%p'
|
||||
SET time_format='%h:%i:%s.%f %p %Y-%m-%d';
|
||||
ERROR 42000: Variable 'time_format' can't be set to the value of '%h:%i:%s.%f %p %Y-%m-%d'
|
||||
SET time_format='%H%i%s.%f';
|
||||
ERROR 42000: Variable 'time_format' can't be set to the value of '%H%i%s.%f'
|
||||
SET time_format='%H:%i-%s.%f';
|
||||
ERROR 42000: Variable 'time_format' can't be set to the value of '%H:%i-%s.%f'
|
||||
SET date_format='%d.%m.%d';
|
||||
ERROR 42000: Variable 'date_format' can't be set to the value of '%d.%m.%d'
|
||||
SET datetime_format='%h.%m.%y %d.%i.%s';
|
||||
ERROR 42000: Variable 'datetime_format' can't be set to the value of '%h.%m.%y %d.%i.%s'
|
||||
set datetime_format= '%H:%i:%s.%f %p %Y-%m-%d';
|
||||
ERROR 42000: Variable 'datetime_format' can't be set to the value of '%H:%i:%s.%f %p %Y-%m-%d'
|
||||
set GLOBAL datetime_format= '%H:%i:%s %Y-%m-%d';
|
||||
SET SESSION datetime_format=default;
|
||||
select @@global.datetime_format, @@session.datetime_format;
|
||||
@@global.datetime_format @@session.datetime_format
|
||||
%H:%i:%s %Y-%m-%d %H:%i:%s %Y-%m-%d
|
||||
SET GLOBAL datetime_format=default;
|
||||
SET SESSION datetime_format=default;
|
||||
select @@global.datetime_format, @@session.datetime_format;
|
||||
@@global.datetime_format @@session.datetime_format
|
||||
%Y-%m-%d %H:%i:%s %Y-%m-%d %H:%i:%s
|
||||
SET GLOBAL date_format=default;
|
||||
SET GLOBAL time_format=default;
|
||||
SET GLOBAL datetime_format=default;
|
||||
SET time_format=default;
|
||||
SET date_format=default;
|
||||
SET datetime_format=default;
|
||||
select str_to_date(concat('15-01-2001',' 2:59:58.999'),
|
||||
concat('%d-%m-%Y',' ','%H:%i:%s.%f'));
|
||||
str_to_date(concat('15-01-2001',' 2:59:58.999'),
|
||||
concat('%d-%m-%Y',' ','%H:%i:%s.%f'))
|
||||
2001-01-15 02:59:58.999000
|
||||
select STR_TO_DATE('2004.12.12 22.30.61','%Y.%m.%d %T');
|
||||
STR_TO_DATE('2004.12.12 22.30.61','%Y.%m.%d %T')
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1411 Incorrect time value: '22.30.61' for function str_to_date
|
||||
create table t1 (date char(30), format char(30) not null);
|
||||
insert into t1 values
|
||||
('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
|
||||
('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'),
|
||||
('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'),
|
||||
('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'),
|
||||
('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'),
|
||||
('2003-01-02 12:11:12.12345 am', '%Y-%m-%d %h:%i:%S.%f%p'),
|
||||
('2003-01-02 11:11:12Pm', '%Y-%m-%d %h:%i:%S%p'),
|
||||
('10:20:10', '%H:%i:%s'),
|
||||
('10:20:10', '%h:%i:%s.%f'),
|
||||
('10:20:10', '%T'),
|
||||
('10:20:10AM', '%h:%i:%s%p'),
|
||||
('10:20:10AM', '%r'),
|
||||
('10:20:10.44AM', '%h:%i:%s.%f%p'),
|
||||
('15-01-2001 12:59:58', '%d-%m-%Y %H:%i:%S'),
|
||||
('15 September 2001', '%d %M %Y'),
|
||||
('15 SEPTEMB 2001', '%d %M %Y'),
|
||||
('15 MAY 2001', '%d %b %Y'),
|
||||
('15th May 2001', '%D %b %Y'),
|
||||
('Sunday 15 MAY 2001', '%W %d %b %Y'),
|
||||
('Sund 15 MAY 2001', '%W %d %b %Y'),
|
||||
('Tuesday 00 2002', '%W %U %Y'),
|
||||
('Thursday 53 1998', '%W %u %Y'),
|
||||
('Sunday 01 2001', '%W %v %x'),
|
||||
('Tuesday 52 2001', '%W %V %X'),
|
||||
('060 2004', '%j %Y'),
|
||||
('4 53 1998', '%w %u %Y'),
|
||||
('15-01-2001', '%d-%m-%Y %H:%i:%S'),
|
||||
('15-01-20', '%d-%m-%y'),
|
||||
('15-2001-1', '%d-%Y-%c');
|
||||
select date,format,str_to_date(date, format) as str_to_date from t1;
|
||||
date format str_to_date
|
||||
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
|
||||
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
||||
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450
|
||||
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450
|
||||
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450
|
||||
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
|
||||
10:20:10 %H:%i:%s 0000-00-00 10:20:10
|
||||
10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
|
||||
10:20:10 %T 0000-00-00 10:20:10
|
||||
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
|
||||
10:20:10AM %r 0000-00-00 10:20:10
|
||||
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000
|
||||
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
|
||||
15 September 2001 %d %M %Y 2001-09-15 00:00:00
|
||||
15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
|
||||
15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
|
||||
15th May 2001 %D %b %Y 2001-05-15 00:00:00
|
||||
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
||||
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
||||
Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00
|
||||
Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00
|
||||
Sunday 01 2001 %W %v %x 2001-01-07 00:00:00
|
||||
Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00
|
||||
060 2004 %j %Y 2004-02-29 00:00:00
|
||||
4 53 1998 %w %u %Y 1998-12-31 00:00:00
|
||||
15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00
|
||||
15-01-20 %d-%m-%y 2020-01-15 00:00:00
|
||||
15-2001-1 %d-%Y-%c 2001-01-15 00:00:00
|
||||
select date,format,concat('',str_to_date(date, format)) as con from t1;
|
||||
date format con
|
||||
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
|
||||
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
||||
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450
|
||||
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450
|
||||
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450
|
||||
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
|
||||
10:20:10 %H:%i:%s 0000-00-00 10:20:10
|
||||
10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
|
||||
10:20:10 %T 0000-00-00 10:20:10
|
||||
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
|
||||
10:20:10AM %r 0000-00-00 10:20:10
|
||||
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000
|
||||
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
|
||||
15 September 2001 %d %M %Y 2001-09-15 00:00:00
|
||||
15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
|
||||
15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
|
||||
15th May 2001 %D %b %Y 2001-05-15 00:00:00
|
||||
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
||||
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
||||
Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00
|
||||
Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00
|
||||
Sunday 01 2001 %W %v %x 2001-01-07 00:00:00
|
||||
Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00
|
||||
060 2004 %j %Y 2004-02-29 00:00:00
|
||||
4 53 1998 %w %u %Y 1998-12-31 00:00:00
|
||||
15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00
|
||||
15-01-20 %d-%m-%y 2020-01-15 00:00:00
|
||||
15-2001-1 %d-%Y-%c 2001-01-15 00:00:00
|
||||
select date,format,cast(str_to_date(date, format) as datetime) as datetime from t1;
|
||||
date format datetime
|
||||
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
|
||||
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
||||
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450
|
||||
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450
|
||||
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450
|
||||
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
|
||||
10:20:10 %H:%i:%s 0000-00-00 10:20:10
|
||||
10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
|
||||
10:20:10 %T 0000-00-00 10:20:10
|
||||
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
|
||||
10:20:10AM %r 0000-00-00 10:20:10
|
||||
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000
|
||||
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
|
||||
15 September 2001 %d %M %Y 2001-09-15 00:00:00
|
||||
15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
|
||||
15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
|
||||
15th May 2001 %D %b %Y 2001-05-15 00:00:00
|
||||
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
||||
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
||||
Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00
|
||||
Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00
|
||||
Sunday 01 2001 %W %v %x 2001-01-07 00:00:00
|
||||
Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00
|
||||
060 2004 %j %Y 2004-02-29 00:00:00
|
||||
4 53 1998 %w %u %Y 1998-12-31 00:00:00
|
||||
15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00
|
||||
15-01-20 %d-%m-%y 2020-01-15 00:00:00
|
||||
15-2001-1 %d-%Y-%c 2001-01-15 00:00:00
|
||||
select date,format,DATE(str_to_date(date, format)) as date2 from t1;
|
||||
date format date2
|
||||
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02
|
||||
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02
|
||||
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02
|
||||
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02
|
||||
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02
|
||||
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02
|
||||
10:20:10 %H:%i:%s 0000-00-00
|
||||
10:20:10 %h:%i:%s.%f 0000-00-00
|
||||
10:20:10 %T 0000-00-00
|
||||
10:20:10AM %h:%i:%s%p 0000-00-00
|
||||
10:20:10AM %r 0000-00-00
|
||||
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00
|
||||
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15
|
||||
15 September 2001 %d %M %Y 2001-09-15
|
||||
15 SEPTEMB 2001 %d %M %Y 2001-09-15
|
||||
15 MAY 2001 %d %b %Y 2001-05-15
|
||||
15th May 2001 %D %b %Y 2001-05-15
|
||||
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15
|
||||
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15
|
||||
Tuesday 00 2002 %W %U %Y 2002-01-01
|
||||
Thursday 53 1998 %W %u %Y 1998-12-31
|
||||
Sunday 01 2001 %W %v %x 2001-01-07
|
||||
Tuesday 52 2001 %W %V %X 2002-01-01
|
||||
060 2004 %j %Y 2004-02-29
|
||||
4 53 1998 %w %u %Y 1998-12-31
|
||||
15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15
|
||||
15-01-20 %d-%m-%y 2020-01-15
|
||||
15-2001-1 %d-%Y-%c 2001-01-15
|
||||
select date,format,TIME(str_to_date(date, format)) as time from t1;
|
||||
date format time
|
||||
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
|
||||
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
|
||||
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450
|
||||
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450
|
||||
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450
|
||||
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12
|
||||
10:20:10 %H:%i:%s 10:20:10
|
||||
10:20:10 %h:%i:%s.%f 10:20:10
|
||||
10:20:10 %T 10:20:10
|
||||
10:20:10AM %h:%i:%s%p 10:20:10
|
||||
10:20:10AM %r 10:20:10
|
||||
10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000
|
||||
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58
|
||||
15 September 2001 %d %M %Y 00:00:00
|
||||
15 SEPTEMB 2001 %d %M %Y 00:00:00
|
||||
15 MAY 2001 %d %b %Y 00:00:00
|
||||
15th May 2001 %D %b %Y 00:00:00
|
||||
Sunday 15 MAY 2001 %W %d %b %Y 00:00:00
|
||||
Sund 15 MAY 2001 %W %d %b %Y 00:00:00
|
||||
Tuesday 00 2002 %W %U %Y 00:00:00
|
||||
Thursday 53 1998 %W %u %Y 00:00:00
|
||||
Sunday 01 2001 %W %v %x 00:00:00
|
||||
Tuesday 52 2001 %W %V %X 00:00:00
|
||||
060 2004 %j %Y 00:00:00
|
||||
4 53 1998 %w %u %Y 00:00:00
|
||||
15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00
|
||||
15-01-20 %d-%m-%y 00:00:00
|
||||
15-2001-1 %d-%Y-%c 00:00:00
|
||||
select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1;
|
||||
date format time2
|
||||
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
|
||||
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
|
||||
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450
|
||||
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450
|
||||
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450
|
||||
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12
|
||||
10:20:10 %H:%i:%s 10:20:10
|
||||
10:20:10 %h:%i:%s.%f 10:20:10
|
||||
10:20:10 %T 10:20:10
|
||||
10:20:10AM %h:%i:%s%p 10:20:10
|
||||
10:20:10AM %r 10:20:10
|
||||
10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000
|
||||
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58
|
||||
15 September 2001 %d %M %Y 00:00:00
|
||||
15 SEPTEMB 2001 %d %M %Y 00:00:00
|
||||
15 MAY 2001 %d %b %Y 00:00:00
|
||||
15th May 2001 %D %b %Y 00:00:00
|
||||
Sunday 15 MAY 2001 %W %d %b %Y 00:00:00
|
||||
Sund 15 MAY 2001 %W %d %b %Y 00:00:00
|
||||
Tuesday 00 2002 %W %U %Y 00:00:00
|
||||
Thursday 53 1998 %W %u %Y 00:00:00
|
||||
Sunday 01 2001 %W %v %x 00:00:00
|
||||
Tuesday 52 2001 %W %V %X 00:00:00
|
||||
060 2004 %j %Y 00:00:00
|
||||
4 53 1998 %w %u %Y 00:00:00
|
||||
15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00
|
||||
15-01-20 %d-%m-%y 00:00:00
|
||||
15-2001-1 %d-%Y-%c 00:00:00
|
||||
select concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d'));
|
||||
concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d'))
|
||||
2003-01-02 08:11:02.123456
|
||||
truncate table t1;
|
||||
insert into t1 values
|
||||
('2003-01-02 10:11:12 PM', '%Y-%m-%d %H:%i:%S %p'),
|
||||
('2003-01-02 10:11:12.123456', '%Y-%m-%d %h:%i:%S %p'),
|
||||
('2003-01-02 10:11:12AM', '%Y-%m-%d %h:%i:%S.%f %p'),
|
||||
('2003-01-02 10:11:12AN', '%Y-%m-%d %h:%i:%S%p'),
|
||||
('2003-01-02 10:11:12 PM', '%y-%m-%d %H:%i:%S %p'),
|
||||
('10:20:10AM', '%H:%i:%s%p'),
|
||||
('15 Septembei 2001', '%d %M %Y'),
|
||||
('15 Ju 2001', '%d %M %Y'),
|
||||
('Sund 15 MA', '%W %d %b %Y'),
|
||||
('Thursdai 12 1998', '%W %u %Y'),
|
||||
('Sunday 01 2001', '%W %v %X'),
|
||||
('Tuesday 52 2001', '%W %V %x'),
|
||||
('Tuesday 52 2001', '%W %V %Y'),
|
||||
('Tuesday 52 2001', '%W %u %x'),
|
||||
('7 53 1998', '%w %u %Y'),
|
||||
(NULL, get_format(DATE,'USA'));
|
||||
select date,format,str_to_date(date, format) as str_to_date from t1;
|
||||
date format str_to_date
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %H:%i:%S %p NULL
|
||||
2003-01-02 10:11:12.123456 %Y-%m-%d %h:%i:%S %p NULL
|
||||
2003-01-02 10:11:12AM %Y-%m-%d %h:%i:%S.%f %p NULL
|
||||
2003-01-02 10:11:12AN %Y-%m-%d %h:%i:%S%p NULL
|
||||
2003-01-02 10:11:12 PM %y-%m-%d %H:%i:%S %p NULL
|
||||
10:20:10AM %H:%i:%s%p NULL
|
||||
15 Septembei 2001 %d %M %Y NULL
|
||||
15 Ju 2001 %d %M %Y NULL
|
||||
Sund 15 MA %W %d %b %Y NULL
|
||||
Thursdai 12 1998 %W %u %Y NULL
|
||||
Sunday 01 2001 %W %v %X NULL
|
||||
Tuesday 52 2001 %W %V %x NULL
|
||||
Tuesday 52 2001 %W %V %Y NULL
|
||||
Tuesday 52 2001 %W %u %x NULL
|
||||
7 53 1998 %w %u %Y NULL
|
||||
NULL %m.%d.%Y NULL
|
||||
Warnings:
|
||||
Error 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '2003-01-02 10:11:12.123456' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '2003-01-02 10:11:12AM' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '2003-01-02 10:11:12AN' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '10:20:10AM' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '15 Septembei 2001' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '15 Ju 2001' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: 'Sund 15 MA' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: 'Thursdai 12 1998' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: 'Sunday 01 2001' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '7 53 1998' for function str_to_date
|
||||
select date,format,concat(str_to_date(date, format),'') as con from t1;
|
||||
date format con
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %H:%i:%S %p NULL
|
||||
2003-01-02 10:11:12.123456 %Y-%m-%d %h:%i:%S %p NULL
|
||||
2003-01-02 10:11:12AM %Y-%m-%d %h:%i:%S.%f %p NULL
|
||||
2003-01-02 10:11:12AN %Y-%m-%d %h:%i:%S%p NULL
|
||||
2003-01-02 10:11:12 PM %y-%m-%d %H:%i:%S %p NULL
|
||||
10:20:10AM %H:%i:%s%p NULL
|
||||
15 Septembei 2001 %d %M %Y NULL
|
||||
15 Ju 2001 %d %M %Y NULL
|
||||
Sund 15 MA %W %d %b %Y NULL
|
||||
Thursdai 12 1998 %W %u %Y NULL
|
||||
Sunday 01 2001 %W %v %X NULL
|
||||
Tuesday 52 2001 %W %V %x NULL
|
||||
Tuesday 52 2001 %W %V %Y NULL
|
||||
Tuesday 52 2001 %W %u %x NULL
|
||||
7 53 1998 %w %u %Y NULL
|
||||
NULL %m.%d.%Y NULL
|
||||
Warnings:
|
||||
Error 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '2003-01-02 10:11:12.123456' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '2003-01-02 10:11:12AM' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '2003-01-02 10:11:12AN' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '10:20:10AM' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '15 Septembei 2001' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '15 Ju 2001' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: 'Sund 15 MA' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: 'Thursdai 12 1998' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: 'Sunday 01 2001' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '7 53 1998' for function str_to_date
|
||||
truncate table t1;
|
||||
insert into t1 values
|
||||
('10:20:10AM', '%h:%i:%s'),
|
||||
('2003-01-02 10:11:12', '%Y-%m-%d %h:%i:%S'),
|
||||
('03-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p');
|
||||
select date,format,str_to_date(date, format) as str_to_date from t1;
|
||||
date format str_to_date
|
||||
10:20:10AM %h:%i:%s 0000-00-00 10:20:10
|
||||
2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
|
||||
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '10:20:10AM'
|
||||
select date,format,concat(str_to_date(date, format),'') as con from t1;
|
||||
date format con
|
||||
10:20:10AM %h:%i:%s 0000-00-00 10:20:10
|
||||
2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
|
||||
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '10:20:10AM'
|
||||
drop table t1;
|
||||
select get_format(DATE, 'USA') as a;
|
||||
a
|
||||
%m.%d.%Y
|
||||
select get_format(TIME, 'internal') as a;
|
||||
a
|
||||
%H%i%s
|
||||
select get_format(DATETIME, 'eur') as a;
|
||||
a
|
||||
%Y-%m-%d %H.%i.%s
|
||||
select get_format(TIMESTAMP, 'eur') as a;
|
||||
a
|
||||
%Y-%m-%d %H.%i.%s
|
||||
select get_format(DATE, 'TEST') as a;
|
||||
a
|
||||
NULL
|
||||
select str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA'));
|
||||
str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA'))
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1411 Incorrect datetime value: '15-01-2001 12:59:59' for function str_to_date
|
||||
explain extended select makedate(1997,1), addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM"),cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME), maketime(23,11,12),microsecond("1997-12-31 23:59:59.000001");
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select makedate(1997,1) AS `makedate(1997,1)`,addtime('31.12.97 11.59.59.999999 PM','1 1.1.1.000002') AS `addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,subtime('31.12.97 11.59.59.999999 PM','1 1.1.1.000002') AS `subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,timediff('01.01.97 11:59:59.000001 PM','31.12.95 11:59:59.000002 PM') AS `timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM")`,cast(str_to_date('15-01-2001 12:59:59','%d-%m-%Y %H:%i:%S') as time) AS `cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME)`,maketime(23,11,12) AS `maketime(23,11,12)`,microsecond('1997-12-31 23:59:59.000001') AS `microsecond("1997-12-31 23:59:59.000001")`
|
||||
create table t1 (d date);
|
||||
insert into t1 values ('2004-07-14'),('2005-07-14');
|
||||
select date_format(d,"%d") from t1 order by 1;
|
||||
date_format(d,"%d")
|
||||
14
|
||||
14
|
||||
drop table t1;
|
||||
select str_to_date("2003-....01ABCD-02 10:11:12.0012", "%Y-%.%m%@-%d %H:%i:%S.%f") as a;
|
||||
a
|
||||
2003-01-02 10:11:12.001200
|
||||
create table t1 select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1,
|
||||
str_to_date("10:11:12.0012", "%H:%i:%S.%f") as f2,
|
||||
str_to_date("2003-01-02", "%Y-%m-%d") as f3,
|
||||
str_to_date("02", "%d") as f4, str_to_date("02 10", "%d %H") as f5;
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
f1 datetime YES NULL
|
||||
f2 time YES NULL
|
||||
f3 date YES NULL
|
||||
f4 date YES NULL
|
||||
f5 time YES NULL
|
||||
select * from t1;
|
||||
f1 f2 f3 f4 f5
|
||||
2003-01-02 10:11:12 10:11:12 2003-01-02 0000-00-02 58:00:00
|
||||
drop table t1;
|
||||
create table t1 select "02 10" as a, "%d %H" as b;
|
||||
select str_to_date(a,b) from t1;
|
||||
str_to_date(a,b)
|
||||
0000-00-02 10:00:00
|
||||
create table t2 select str_to_date(a,b) from t1;
|
||||
describe t2;
|
||||
Field Type Null Key Default Extra
|
||||
str_to_date(a,b) datetime YES NULL
|
||||
select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1,
|
||||
str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S") as f2,
|
||||
str_to_date("2003-01-02", "%Y-%m-%d") as f3,
|
||||
str_to_date("02 10:11:12", "%d %H:%i:%S.%f") as f4,
|
||||
str_to_date("02 10:11:12", "%d %H:%i:%S") as f5,
|
||||
str_to_date("02 10", "%d %f") as f6;
|
||||
f1 f2 f3 f4 f5 f6
|
||||
2003-01-02 10:11:12.001200 2003-01-02 10:11:12 2003-01-02 58:11:12 58:11:12 48:00:00.100000
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect datetime value: '2003-01-02 10:11:12.0012'
|
||||
drop table t1, t2;
|
||||
select str_to_date("2003-01-02 10:11:12.0012ABCD", "%Y-%m-%d %H:%i:%S.%f") as f1,
|
||||
addtime("-01:01:01.01 GGG", "-23:59:59.1") as f2,
|
||||
microsecond("1997-12-31 23:59:59.01XXXX") as f3;
|
||||
f1 f2 f3
|
||||
2003-01-02 10:11:12.001200 -25:01:00.110000 10000
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect datetime value: '2003-01-02 10:11:12.0012ABCD'
|
||||
Warning 1292 Truncated incorrect time value: '-01:01:01.01 GGG'
|
||||
Warning 1292 Truncated incorrect time value: '1997-12-31 23:59:59.01XXXX'
|
||||
select str_to_date("2003-04-05 g", "%Y-%m-%d") as f1,
|
||||
str_to_date("2003-04-05 10:11:12.101010234567", "%Y-%m-%d %H:%i:%S.%f") as f2;
|
||||
f1 f2
|
||||
2003-04-05 2003-04-05 10:11:12.101010
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect date value: '2003-04-05 g'
|
||||
Warning 1292 Truncated incorrect datetime value: '2003-04-05 10:11:12.101010234567'
|
||||
set names latin1;
|
||||
select date_format('2004-01-01','%W (%a), %e %M (%b) %Y');
|
||||
date_format('2004-01-01','%W (%a), %e %M (%b) %Y')
|
||||
Thursday (Thu), 1 January (Jan) 2004
|
||||
set lc_time_names=ru_RU;
|
||||
set names koi8r;
|
||||
select date_format('2004-01-01','%W (%a), %e %M (%b) %Y');
|
||||
date_format('2004-01-01','%W (%a), %e %M (%b) %Y')
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD>), 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD>) 2004
|
||||
set lc_time_names=de_DE;
|
||||
set names latin1;
|
||||
select date_format('2004-01-01','%W (%a), %e %M (%b) %Y');
|
||||
date_format('2004-01-01','%W (%a), %e %M (%b) %Y')
|
||||
Donnerstag (Do), 1 Januar (Jan) 2004
|
||||
set names latin1;
|
||||
set lc_time_names=en_US;
|
||||
create table t1 (f1 datetime);
|
||||
insert into t1 (f1) values ("2005-01-01");
|
||||
insert into t1 (f1) values ("2005-02-01");
|
||||
select date_format(f1, "%m") as d1, date_format(f1, "%M") as d2 from t1 order by date_format(f1, "%M");
|
||||
d1 d2
|
||||
02 February
|
||||
01 January
|
||||
drop table t1;
|
||||
select str_to_date( 1, NULL );
|
||||
str_to_date( 1, NULL )
|
||||
NULL
|
||||
select str_to_date( NULL, 1 );
|
||||
str_to_date( NULL, 1 )
|
||||
NULL
|
||||
select str_to_date( 1, IF(1=1,NULL,NULL) );
|
||||
str_to_date( 1, IF(1=1,NULL,NULL) )
|
||||
NULL
|
||||
SELECT TIME_FORMAT("24:00:00", '%r');
|
||||
TIME_FORMAT("24:00:00", '%r')
|
||||
12:00:00 AM
|
||||
SELECT TIME_FORMAT("00:00:00", '%r');
|
||||
TIME_FORMAT("00:00:00", '%r')
|
||||
12:00:00 AM
|
||||
SELECT TIME_FORMAT("12:00:00", '%r');
|
||||
TIME_FORMAT("12:00:00", '%r')
|
||||
12:00:00 PM
|
||||
SELECT TIME_FORMAT("15:00:00", '%r');
|
||||
TIME_FORMAT("15:00:00", '%r')
|
||||
03:00:00 PM
|
||||
SELECT TIME_FORMAT("01:00:00", '%r');
|
||||
TIME_FORMAT("01:00:00", '%r')
|
||||
01:00:00 AM
|
||||
SELECT TIME_FORMAT("25:00:00", '%r');
|
||||
TIME_FORMAT("25:00:00", '%r')
|
||||
01:00:00 AM
|
||||
SELECT TIME_FORMAT("00:00:00", '%l %p');
|
||||
TIME_FORMAT("00:00:00", '%l %p')
|
||||
12 AM
|
||||
SELECT TIME_FORMAT("01:00:00", '%l %p');
|
||||
TIME_FORMAT("01:00:00", '%l %p')
|
||||
1 AM
|
||||
SELECT TIME_FORMAT("12:00:00", '%l %p');
|
||||
TIME_FORMAT("12:00:00", '%l %p')
|
||||
12 PM
|
||||
SELECT TIME_FORMAT("23:00:00", '%l %p');
|
||||
TIME_FORMAT("23:00:00", '%l %p')
|
||||
11 PM
|
||||
SELECT TIME_FORMAT("24:00:00", '%l %p');
|
||||
TIME_FORMAT("24:00:00", '%l %p')
|
||||
12 AM
|
||||
SELECT TIME_FORMAT("25:00:00", '%l %p');
|
||||
TIME_FORMAT("25:00:00", '%l %p')
|
||||
1 AM
|
||||
SELECT DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896);
|
||||
DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '%Y-%m-%d %H:%i:%s'
|
||||
select str_to_date('04 /30/2004', '%m /%d/%Y');
|
||||
str_to_date('04 /30/2004', '%m /%d/%Y')
|
||||
2004-04-30
|
||||
select str_to_date('04/30 /2004', '%m /%d /%Y');
|
||||
str_to_date('04/30 /2004', '%m /%d /%Y')
|
||||
2004-04-30
|
||||
select str_to_date('04/30/2004 ', '%m/%d/%Y ');
|
||||
str_to_date('04/30/2004 ', '%m/%d/%Y ')
|
||||
2004-04-30
|
||||
"End of 4.1 tests"
|
||||
198
mysql-test/suite/pbxt/r/default.result
Normal file
198
mysql-test/suite/pbxt/r/default.result
Normal file
@@ -0,0 +1,198 @@
|
||||
drop table if exists t1,t2,t3,t4,t5,t6;
|
||||
drop database if exists mysqltest;
|
||||
CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
b varchar(1) binary NOT NULL DEFAULT ' ',
|
||||
c varchar(4) binary NOT NULL DEFAULT '0000',
|
||||
d tinyblob NULL,
|
||||
e tinyblob NULL,
|
||||
f tinyblob NULL,
|
||||
g tinyblob NULL,
|
||||
h tinyblob NULL,
|
||||
i tinyblob NULL,
|
||||
j tinyblob NULL,
|
||||
k tinyblob NULL,
|
||||
l tinyblob NULL,
|
||||
m tinyblob NULL,
|
||||
n tinyblob NULL,
|
||||
o tinyblob NULL,
|
||||
p tinyblob NULL,
|
||||
q varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
r varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
s tinyblob NULL,
|
||||
t varchar(4) binary NOT NULL DEFAULT ' ',
|
||||
u varchar(1) binary NOT NULL DEFAULT ' ',
|
||||
v varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
w varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
x tinyblob NULL,
|
||||
y varchar(5) binary NOT NULL DEFAULT ' ',
|
||||
z varchar(20) binary NOT NULL DEFAULT ' ',
|
||||
a1 varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
b1 tinyblob NULL)
|
||||
ENGINE=InnoDB DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
|
||||
INSERT into t1 (b) values ('1');
|
||||
SHOW WARNINGS;
|
||||
Level Code Message
|
||||
SELECT * from t1;
|
||||
a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1
|
||||
1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
|
||||
CREATE TABLE t2 (a varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
b varchar(1) binary NOT NULL DEFAULT ' ',
|
||||
c varchar(4) binary NOT NULL DEFAULT '0000',
|
||||
d tinyblob NULL,
|
||||
e tinyblob NULL,
|
||||
f tinyblob NULL,
|
||||
g tinyblob NULL,
|
||||
h tinyblob NULL,
|
||||
i tinyblob NULL,
|
||||
j tinyblob NULL,
|
||||
k tinyblob NULL,
|
||||
l tinyblob NULL,
|
||||
m tinyblob NULL,
|
||||
n tinyblob NULL,
|
||||
o tinyblob NULL,
|
||||
p tinyblob NULL,
|
||||
q varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
r varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
s tinyblob NULL,
|
||||
t varchar(4) binary NOT NULL DEFAULT ' ',
|
||||
u varchar(1) binary NOT NULL DEFAULT ' ',
|
||||
v varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
w varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
x tinyblob NULL,
|
||||
y varchar(5) binary NOT NULL DEFAULT ' ',
|
||||
z varchar(20) binary NOT NULL DEFAULT ' ',
|
||||
a1 varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
b1 tinyblob NULL)
|
||||
ENGINE=MyISAM DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`b` varchar(1) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`c` varchar(4) COLLATE latin1_bin NOT NULL DEFAULT '0000',
|
||||
`d` tinyblob,
|
||||
`e` tinyblob,
|
||||
`f` tinyblob,
|
||||
`g` tinyblob,
|
||||
`h` tinyblob,
|
||||
`i` tinyblob,
|
||||
`j` tinyblob,
|
||||
`k` tinyblob,
|
||||
`l` tinyblob,
|
||||
`m` tinyblob,
|
||||
`n` tinyblob,
|
||||
`o` tinyblob,
|
||||
`p` tinyblob,
|
||||
`q` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`r` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`s` tinyblob,
|
||||
`t` varchar(4) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`u` varchar(1) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`v` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`w` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`x` tinyblob,
|
||||
`y` varchar(5) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`z` varchar(20) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`a1` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`b1` tinyblob
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin
|
||||
INSERT into t2 (b) values ('1');
|
||||
SHOW WARNINGS;
|
||||
Level Code Message
|
||||
SELECT * from t2;
|
||||
a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1
|
||||
1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
create table bug20691 (i int, d datetime NOT NULL, dn datetime not null default '0000-00-00 00:00:00');
|
||||
insert into bug20691 values (1, DEFAULT, DEFAULT), (1, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (1, DEFAULT, DEFAULT);
|
||||
Warnings:
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
insert into bug20691 (i) values (2);
|
||||
Warnings:
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
desc bug20691;
|
||||
Field Type Null Key Default Extra
|
||||
i int(11) YES NULL
|
||||
d datetime NO NULL
|
||||
dn datetime NO 0000-00-00 00:00:00
|
||||
insert into bug20691 values (3, DEFAULT, DEFAULT), (3, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (3, DEFAULT, DEFAULT);
|
||||
Warnings:
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
insert into bug20691 (i) values (4);
|
||||
Warnings:
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
insert into bug20691 values (5, DEFAULT, DEFAULT), (5, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (5, DEFAULT, DEFAULT);
|
||||
Warnings:
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
SET sql_mode = 'ALLOW_INVALID_DATES';
|
||||
insert into bug20691 values (6, DEFAULT, DEFAULT), (6, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (6, DEFAULT, DEFAULT);
|
||||
Warnings:
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
SET sql_mode = 'STRICT_ALL_TABLES';
|
||||
insert into bug20691 values (7, DEFAULT, DEFAULT), (7, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (7, DEFAULT, DEFAULT);
|
||||
ERROR HY000: Field 'd' doesn't have a default value
|
||||
select * from bug20691 order by i asc;
|
||||
i d dn
|
||||
1 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
1 1975-07-10 07:10:03 1978-01-13 14:08:51
|
||||
1 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
2 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
3 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
3 1975-07-10 07:10:03 1978-01-13 14:08:51
|
||||
3 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
4 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
5 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
5 1975-07-10 07:10:03 1978-01-13 14:08:51
|
||||
5 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
6 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
6 1975-07-10 07:10:03 1978-01-13 14:08:51
|
||||
6 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
drop table bug20691;
|
||||
SET sql_mode = '';
|
||||
create table bug20691 (
|
||||
a set('one', 'two', 'three') not null,
|
||||
b enum('small', 'medium', 'large', 'enormous', 'ellisonego') not null,
|
||||
c time not null,
|
||||
d date not null,
|
||||
e int not null,
|
||||
f long not null,
|
||||
g blob not null,
|
||||
h datetime not null,
|
||||
i decimal not null,
|
||||
x int);
|
||||
insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 1);
|
||||
insert into bug20691 (x) values (2);
|
||||
Warnings:
|
||||
Warning 1364 Field 'a' doesn't have a default value
|
||||
Warning 1364 Field 'c' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'e' doesn't have a default value
|
||||
Warning 1364 Field 'f' doesn't have a default value
|
||||
Warning 1364 Field 'g' doesn't have a default value
|
||||
Warning 1364 Field 'h' doesn't have a default value
|
||||
Warning 1364 Field 'i' doesn't have a default value
|
||||
insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 3);
|
||||
insert into bug20691 values (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, 4);
|
||||
Warnings:
|
||||
Warning 1364 Field 'a' doesn't have a default value
|
||||
Warning 1364 Field 'b' doesn't have a default value
|
||||
Warning 1364 Field 'c' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'e' doesn't have a default value
|
||||
Warning 1364 Field 'f' doesn't have a default value
|
||||
Warning 1364 Field 'g' doesn't have a default value
|
||||
Warning 1364 Field 'h' doesn't have a default value
|
||||
Warning 1364 Field 'i' doesn't have a default value
|
||||
select * from bug20691 order by x asc;
|
||||
a b c d e f g h i x
|
||||
two large 00:00:05 0007-01-01 11 13 17 0019-01-01 00:00:00 23 1
|
||||
small 00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 2
|
||||
two large 00:00:05 0007-01-01 11 13 17 0019-01-01 00:00:00 23 3
|
||||
00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 4
|
||||
drop table bug20691;
|
||||
End of 5.0 tests.
|
||||
208
mysql-test/suite/pbxt/r/delete.result
Normal file
208
mysql-test/suite/pbxt/r/delete.result
Normal file
@@ -0,0 +1,208 @@
|
||||
drop table if exists t1,t2,t3,t11,t12;
|
||||
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
|
||||
INSERT INTO t1 VALUES (1,1);
|
||||
INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
|
||||
INSERT INTO t1 VALUES (1,3);
|
||||
DELETE from t1 where a=1 limit 1;
|
||||
DELETE LOW_PRIORITY from t1 where a=1;
|
||||
INSERT INTO t1 VALUES (1,1);
|
||||
DELETE from t1;
|
||||
LOCK TABLE t1 write;
|
||||
INSERT INTO t1 VALUES (1,2);
|
||||
DELETE from t1;
|
||||
UNLOCK TABLES;
|
||||
INSERT INTO t1 VALUES (1,2);
|
||||
SET AUTOCOMMIT=0;
|
||||
DELETE from t1;
|
||||
SET AUTOCOMMIT=1;
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a bigint not null,
|
||||
b bigint not null default 0,
|
||||
c bigint not null default 0,
|
||||
d bigint not null default 0,
|
||||
e bigint not null default 0,
|
||||
f bigint not null default 0,
|
||||
g bigint not null default 0,
|
||||
h bigint not null default 0,
|
||||
i bigint not null default 0,
|
||||
j bigint not null default 0,
|
||||
primary key (a,b,c,d,e,f,g,h,i,j));
|
||||
insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23);
|
||||
delete from t1 where a=26;
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a bigint not null,
|
||||
b bigint not null default 0,
|
||||
c bigint not null default 0,
|
||||
d bigint not null default 0,
|
||||
e bigint not null default 0,
|
||||
f bigint not null default 0,
|
||||
g bigint not null default 0,
|
||||
h bigint not null default 0,
|
||||
i bigint not null default 0,
|
||||
j bigint not null default 0,
|
||||
primary key (a,b,c,d,e,f,g,h,i,j));
|
||||
insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27);
|
||||
delete from t1 where a=27;
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`i` int(10) NOT NULL default '0',
|
||||
`i2` int(10) NOT NULL default '0',
|
||||
PRIMARY KEY (`i`)
|
||||
);
|
||||
DELETE FROM t1 USING t1 WHERE post='1';
|
||||
ERROR 42S22: Unknown column 'post' in 'where clause'
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
bool char(0) default NULL,
|
||||
not_null varchar(20) binary NOT NULL default '',
|
||||
misc integer not null,
|
||||
PRIMARY KEY (not_null)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (NULL,'a',4), (NULL,'b',5), (NULL,'c',6), (NULL,'d',7);
|
||||
select * from t1 where misc > 5 and bool is null;
|
||||
bool not_null misc
|
||||
NULL c 6
|
||||
NULL d 7
|
||||
delete from t1 where misc > 5 and bool is null;
|
||||
select * from t1 where misc > 5 and bool is null;
|
||||
bool not_null misc
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
2
|
||||
delete from t1 where 1 > 2;
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
2
|
||||
delete from t1 where 3 > 2;
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
0
|
||||
drop table t1;
|
||||
create table t1 (a int not null auto_increment primary key, b char(32));
|
||||
insert into t1 (b) values ('apple'), ('apple');
|
||||
select * from t1;
|
||||
a b
|
||||
1 apple
|
||||
2 apple
|
||||
delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a;
|
||||
select * from t1;
|
||||
a b
|
||||
1 apple
|
||||
drop table t1;
|
||||
create table t11 (a int NOT NULL, b int, primary key (a));
|
||||
create table t12 (a int NOT NULL, b int, primary key (a));
|
||||
create table t2 (a int NOT NULL, b int, primary key (a));
|
||||
insert into t11 values (0, 10),(1, 11),(2, 12);
|
||||
insert into t12 values (33, 10),(0, 11),(2, 12);
|
||||
insert into t2 values (1, 21),(2, 12),(3, 23);
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
2 12
|
||||
select * from t12;
|
||||
a b
|
||||
33 10
|
||||
0 11
|
||||
2 12
|
||||
select * from t2;
|
||||
a b
|
||||
1 21
|
||||
2 12
|
||||
3 23
|
||||
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
2 12
|
||||
select * from t12;
|
||||
a b
|
||||
33 10
|
||||
0 11
|
||||
2 12
|
||||
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
Warnings:
|
||||
Error 1242 Subquery returns more than 1 row
|
||||
Error 1242 Subquery returns more than 1 row
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
select * from t12;
|
||||
a b
|
||||
33 10
|
||||
0 11
|
||||
insert into t11 values (2, 12);
|
||||
delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
2 12
|
||||
delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
Warnings:
|
||||
Error 1242 Subquery returns more than 1 row
|
||||
Error 1242 Subquery returns more than 1 row
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
drop table t11, t12, t2;
|
||||
create table t1 (a int, b int, unique key (a), key (b));
|
||||
insert into t1 values (3, 3), (7, 7);
|
||||
delete t1 from t1 where a = 3;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
select * from t1;
|
||||
a b
|
||||
7 7
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( a int PRIMARY KEY );
|
||||
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;
|
||||
INSERT INTO t1 VALUES (0),(1),(2);
|
||||
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1;
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
0
|
||||
2
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int);
|
||||
delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5;
|
||||
delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5;
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int not null,b int not null);
|
||||
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b));
|
||||
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b));
|
||||
insert into t1 values (1,1),(2,1),(1,3);
|
||||
insert into t2 values (1,1),(2,2),(3,3);
|
||||
insert into t3 values (1,1),(2,1),(1,3);
|
||||
select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
|
||||
a b a b a b
|
||||
1 1 1 1 1 1
|
||||
2 1 2 2 2 1
|
||||
1 3 1 1 1 3
|
||||
explain select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 8 test.t2.b,test.t1.b 1 Using index
|
||||
delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
|
||||
select * from t3;
|
||||
a b
|
||||
drop table t1,t2,t3;
|
||||
create table t1(a date not null);
|
||||
insert into t1 values (0);
|
||||
select * from t1 where a is null;
|
||||
a
|
||||
0000-00-00
|
||||
delete from t1 where a is null;
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
0
|
||||
drop table t1;
|
||||
391
mysql-test/suite/pbxt/r/derived.result
Normal file
391
mysql-test/suite/pbxt/r/derived.result
Normal file
@@ -0,0 +1,391 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
select * from (select 2 from DUAL) b;
|
||||
2
|
||||
2
|
||||
SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
CREATE TABLE t1 (a int not null, b char (10) not null);
|
||||
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
|
||||
CREATE TABLE t2 (a int not null, b char (10) not null);
|
||||
insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e');
|
||||
select t1.a,t3.y from t1,(select a as y from t2 where b='c') as t3 where t1.a = t3.y;
|
||||
a y
|
||||
3 3
|
||||
3 3
|
||||
select t1.a,t3.a from t1,(select * from t2 where b='c') as t3 where t1.a = t3.a;
|
||||
a a
|
||||
3 3
|
||||
3 3
|
||||
CREATE TABLE t3 (a int not null, b char (10) not null);
|
||||
insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c');
|
||||
select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5 where t2.b=t5.b) as t4 where t1.a = t4.y;
|
||||
a y
|
||||
3 3
|
||||
3 3
|
||||
SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b;
|
||||
ERROR 42S22: Unknown column 'a' in 'having clause'
|
||||
SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1;
|
||||
ERROR 23000: Column 'a' in having clause is ambiguous
|
||||
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2;
|
||||
a a
|
||||
1 2
|
||||
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1;
|
||||
a a
|
||||
SELECT 1 FROM (SELECT 1) a WHERE a=2;
|
||||
ERROR 42S22: Unknown column 'a' in 'where clause'
|
||||
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a;
|
||||
ERROR 42S22: Unknown column 'a' in 'having clause'
|
||||
select * from t1 as x1, (select * from t1) as x2;
|
||||
a b a b
|
||||
1 a 1 a
|
||||
2 b 1 a
|
||||
3 c 1 a
|
||||
3 c 1 a
|
||||
1 a 2 b
|
||||
2 b 2 b
|
||||
3 c 2 b
|
||||
3 c 2 b
|
||||
1 a 3 c
|
||||
2 b 3 c
|
||||
3 c 3 c
|
||||
3 c 3 c
|
||||
1 a 3 c
|
||||
2 b 3 c
|
||||
3 c 3 c
|
||||
3 c 3 c
|
||||
explain select * from t1 as x1, (select * from t1) as x2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY x1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 Using join buffer
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4
|
||||
drop table if exists t2,t3;
|
||||
select * from (select 1) as a;
|
||||
1
|
||||
1
|
||||
select a from (select 1 as a) as b;
|
||||
a
|
||||
1
|
||||
select 1 from (select 1) as a;
|
||||
1
|
||||
1
|
||||
select * from (select * from t1 union select * from t1) a;
|
||||
a b
|
||||
1 a
|
||||
2 b
|
||||
3 c
|
||||
select * from (select * from t1 union all select * from t1) a;
|
||||
a b
|
||||
1 a
|
||||
2 b
|
||||
3 c
|
||||
3 c
|
||||
1 a
|
||||
2 b
|
||||
3 c
|
||||
3 c
|
||||
select * from (select * from t1 union all select * from t1 limit 2) a;
|
||||
a b
|
||||
1 a
|
||||
2 b
|
||||
explain select * from (select * from t1 union select * from t1) a;
|
||||
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 4
|
||||
3 UNION t1 ALL NULL NULL NULL NULL 4
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
explain select * from (select * from t1 union all select * from t1) a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 8
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4
|
||||
3 UNION t1 ALL NULL NULL NULL NULL 4
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
CREATE TABLE t2 (a int not null);
|
||||
insert into t2 values(1);
|
||||
select * from (select * from t1 where t1.a=(select a from t2 where t2.a=t1.a)) a;
|
||||
a b
|
||||
1 a
|
||||
select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) union select t1.a, t1.b from t1) a;
|
||||
a b
|
||||
1 a
|
||||
2 b
|
||||
3 c
|
||||
explain select * from (select t1.*, t2.a as t2a from t1,t2 where t1.a=t2.a) t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
|
||||
2 DERIVED t2 ALL NULL NULL NULL NULL 1
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer
|
||||
drop table t1, t2;
|
||||
create table t1(a int not null, t char(8), index(a));
|
||||
SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20;
|
||||
a t
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
5 5
|
||||
6 6
|
||||
7 7
|
||||
8 8
|
||||
9 9
|
||||
10 10
|
||||
11 11
|
||||
12 12
|
||||
13 13
|
||||
14 14
|
||||
15 15
|
||||
16 16
|
||||
17 17
|
||||
18 18
|
||||
19 19
|
||||
20 20
|
||||
explain select count(*) from t1 as tt1, (select * from t1) as tt2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY tt1 index NULL a 4 NULL 10000 Using index
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 10000 Using join buffer
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 10000
|
||||
drop table t1;
|
||||
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
|
||||
(SELECT * FROM (SELECT 1 as a) as a )
|
||||
1
|
||||
select * from (select 1 as a) b left join (select 2 as a) c using(a);
|
||||
a
|
||||
1
|
||||
SELECT * FROM (SELECT 1 UNION SELECT a) b;
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
select 1 from (select 2) a order by 0;
|
||||
ERROR 42S22: Unknown column '0' in 'order clause'
|
||||
create table t1 (id int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
describe select * from (select * from t1 group by id) bar;
|
||||
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 3 Using temporary; Using filesort
|
||||
drop table t1;
|
||||
create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL);
|
||||
create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL);
|
||||
insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9);
|
||||
insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
|
||||
SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
|
||||
pla_id mat_id
|
||||
100 1
|
||||
101 1
|
||||
102 1
|
||||
103 2
|
||||
104 2
|
||||
105 3
|
||||
SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
|
||||
pla_id test
|
||||
100 1
|
||||
101 1
|
||||
102 1
|
||||
103 2
|
||||
104 2
|
||||
105 3
|
||||
explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY m2 ALL NULL NULL NULL NULL 9
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1
|
||||
explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY m2 ALL NULL NULL NULL NULL 9
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1
|
||||
drop table t1,t2;
|
||||
SELECT a.x FROM (SELECT 1 AS x) AS a HAVING a.x = 1;
|
||||
x
|
||||
1
|
||||
create user mysqltest_1;
|
||||
create table t1 select 1 as a;
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
select 2 as a from (select * from t1) b;
|
||||
ERROR 3D000: No database selected
|
||||
use test;
|
||||
select 2 as a from (select * from t1) b;
|
||||
a
|
||||
2
|
||||
drop table t1;
|
||||
select mail_id, if(folder.f_description!='', folder.f_description, folder.f_name) as folder_name, date, address_id, phrase, address, subject from folder, (select mail.mail_id as mail_id, date_format(mail.h_date, '%b %e, %Y %h:%i') as date, mail.folder_id, sender.address_id as address_id, sender.phrase as phrase, sender.address as address, mail.h_subject as subject from mail left join mxa as mxa_sender on mail.mail_id=mxa_sender.mail_id and mxa_sender.type='from' left join address as sender on mxa_sender.address_id=sender.address_id mxa as mxa_recipient, address as recipient, where 1 and mail.mail_id=mxa_recipient.mail_id and mxa_recipient.address_id=recipient.address_id and mxa_recipient.type='to' and match(sender.phrase, sender.address, sender.comment) against ('jeremy' in boolean mode) and match(recipient.phrase, recipient.address, recipient.comment) against ('monty' in boolean mode) order by mail.h_date desc limit 0, 25 ) as query where query.folder_id=folder.folder_id;
|
||||
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 'mxa as mxa_recipient, address as recipient, where 1 and mail.mail_id=mxa_r' at line 1
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
update (select * from t1) as t1 set a = 5;
|
||||
ERROR HY000: The target table t1 of the UPDATE is not updatable
|
||||
delete from (select * 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 * from t1)' at line 1
|
||||
insert into (select * from t1) values (5);
|
||||
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 * from t1) values (5)' at line 1
|
||||
drop table t1;
|
||||
create table t1 (E1 INTEGER UNSIGNED NOT NULL, E2 INTEGER UNSIGNED NOT NULL, E3 INTEGER UNSIGNED NOT NULL, PRIMARY KEY(E1)
|
||||
);
|
||||
insert into t1 VALUES(1,1,1), (2,2,1);
|
||||
select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
|
||||
count(*)
|
||||
2
|
||||
explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 THEMAX.E2 1 Using where
|
||||
2 DERIVED A ALL NULL NULL NULL NULL 2 Using where
|
||||
3 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 2 Using where
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2);
|
||||
select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b;
|
||||
a a
|
||||
1 1
|
||||
2 1
|
||||
1 2
|
||||
2 2
|
||||
explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY <derived4> ALL NULL NULL NULL NULL 2 Using join buffer
|
||||
4 DERIVED t1 ALL NULL NULL NULL NULL 2
|
||||
5 UNION t1 ALL NULL NULL NULL NULL 2
|
||||
NULL UNION RESULT <union4,5> ALL NULL NULL NULL NULL NULL
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 2
|
||||
3 UNION t1 ALL NULL NULL NULL NULL 2
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`N` int(11) unsigned NOT NULL default '0',
|
||||
`M` tinyint(1) default '0'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
INSERT INTO `t1` (N, M) VALUES (1, 0),(1, 0),(1, 0),(2, 0),(2, 0),(3, 0);
|
||||
UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2;
|
||||
select * from t1;
|
||||
N M
|
||||
1 2
|
||||
1 2
|
||||
1 2
|
||||
2 2
|
||||
2 2
|
||||
3 0
|
||||
UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2, P2.N = 2;
|
||||
ERROR HY000: The target table P2 of the UPDATE is not updatable
|
||||
UPDATE `t1` AS P1 INNER JOIN (SELECT aaaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2;
|
||||
ERROR 42S22: Unknown column 'aaaa' in 'field list'
|
||||
delete P1.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
|
||||
select * from t1;
|
||||
N M
|
||||
3 0
|
||||
delete P1.*,p2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS p2 ON P1.N = p2.N;
|
||||
ERROR 42S02: Unknown table 'p2' in MULTI DELETE
|
||||
delete P1.* from `t1` AS P1 INNER JOIN (SELECT aaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
|
||||
ERROR 42S22: Unknown column 'aaa' in 'field list'
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
OBJECTID int(11) NOT NULL default '0',
|
||||
SORTORDER int(11) NOT NULL auto_increment,
|
||||
KEY t1_SortIndex (SORTORDER),
|
||||
KEY t1_IdIndex (OBJECTID)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
CREATE TABLE t2 (
|
||||
ID int(11) default NULL,
|
||||
PARID int(11) default NULL,
|
||||
UNIQUE KEY t2_ID_IDX (ID),
|
||||
KEY t2_PARID_IDX (PARID)
|
||||
) engine=MyISAM DEFAULT CHARSET=latin1;
|
||||
INSERT INTO t2 VALUES (1000,0),(1001,0),(1002,0),(1003,0),(1008,1),(1009,1),(1010,1),(1011,1),(1016,2);
|
||||
CREATE TABLE t3 (
|
||||
ID int(11) default NULL,
|
||||
DATA decimal(10,2) default NULL,
|
||||
UNIQUE KEY t3_ID_IDX (ID)
|
||||
) engine=MyISAM DEFAULT CHARSET=latin1;
|
||||
INSERT INTO t3 VALUES (1000,0.00),(1001,0.25),(1002,0.50),(1003,0.75),(1008,1.00),(1009,1.25),(1010,1.50),(1011,1.75);
|
||||
select 497, TMP.ID, NULL from (select 497 as ID, MAX(t3.DATA) as DATA from t1 join t2 on (t1.ObjectID = t2.ID) join t3 on (t1.ObjectID = t3.ID) group by t2.ParID order by DATA DESC) as TMP;
|
||||
497 ID NULL
|
||||
drop table t1, t2, t3;
|
||||
CREATE TABLE t1 (name char(1) default NULL, val int(5) default NULL);
|
||||
INSERT INTO t1 VALUES ('a',1), ('a',2), ('a',2), ('a',2), ('a',3), ('a',6), ('a',7), ('a',11), ('a',11), ('a',12), ('a',13), ('a',13), ('a',20), ('b',2), ('b',3), ('b',4), ('b',5);
|
||||
SELECT s.name, AVG(s.val) AS median FROM (SELECT x.name, x.val FROM t1 x, t1 y WHERE x.name=y.name GROUP BY x.name, x.val HAVING SUM(y.val <= x.val) >= COUNT(*)/2 AND SUM(y.val >= x.val) >= COUNT(*)/2) AS s GROUP BY s.name;
|
||||
name median
|
||||
a 7.0000
|
||||
b 3.5000
|
||||
explain SELECT s.name, AVG(s.val) AS median FROM (SELECT x.name, x.val FROM t1 x, t1 y WHERE x.name=y.name GROUP BY x.name, x.val HAVING SUM(y.val <= x.val) >= COUNT(*)/2 AND SUM(y.val >= x.val) >= COUNT(*)/2) AS s GROUP BY s.name;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
|
||||
2 DERIVED x ALL NULL NULL NULL NULL 17 Using temporary; Using filesort
|
||||
2 DERIVED y ALL NULL NULL NULL NULL 17 Using where; Using join buffer
|
||||
drop table t1;
|
||||
create table t2 (a int, b int, primary key (a));
|
||||
insert into t2 values (1,7),(2,7);
|
||||
explain select a from t2 where a>1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
|
||||
explain select a from (select a from t2 where a>1) tt;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
|
||||
2 DERIVED t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
|
||||
drop table t2;
|
||||
CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`));
|
||||
insert into t1 values (128, 'rozn', 2, now(), 10),(128, 'rozn', 1, now(), 10);
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'date_' at row 1
|
||||
Note 1265 Data truncated for column 'date_' at row 2
|
||||
SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices;
|
||||
min max avg
|
||||
10.00 10.00 10
|
||||
DROP TABLE t1;
|
||||
create table t1 (a integer, b integer);
|
||||
insert into t1 values (1,4), (2,2),(2,2), (4,1),(4,1),(4,1),(4,1);
|
||||
select distinct sum(b) from t1 group by a;
|
||||
sum(b)
|
||||
4
|
||||
select distinct sum(b) from (select a,b from t1) y group by a;
|
||||
sum(b)
|
||||
4
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a char(10), b char(10));
|
||||
INSERT INTO t1 VALUES ('root','localhost'), ('root','%');
|
||||
SELECT * FROM (SELECT (SELECT a.a FROM t1 AS a WHERE a.a = b.a) FROM t1 AS b) AS c;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
DROP TABLE t1;
|
||||
create table t1(a int);
|
||||
create table t2(a int);
|
||||
create table t3(a int);
|
||||
insert into t1 values(1),(1);
|
||||
insert into t2 values(2),(2);
|
||||
insert into t3 values(3),(3);
|
||||
select * from t1 union distinct select * from t2 union all select * from t3;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
3
|
||||
select * from (select * from t1 union distinct select * from t2 union all select * from t3) X;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
3
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
select * from (select * from t1,t2) foo;
|
||||
ERROR 42S21: Duplicate column name 'a'
|
||||
drop table t1,t2;
|
||||
create table t1 (ID int unsigned not null auto_increment,
|
||||
DATA varchar(5) not null, primary key (ID));
|
||||
create table t2 (ID int unsigned not null auto_increment,
|
||||
DATA varchar(5) not null, FID int unsigned not null,
|
||||
primary key (ID));
|
||||
select A.* from (t1 inner join (select * from t2) as A on t1.ID = A.FID);
|
||||
ID DATA FID
|
||||
select t2.* from ((select * from t1) as A inner join t2 on A.ID = t2.FID);
|
||||
ID DATA FID
|
||||
select t2.* from (select * from t1) as A inner join t2 on A.ID = t2.FID;
|
||||
ID DATA FID
|
||||
drop table t1, t2;
|
||||
drop user mysqltest_1;
|
||||
9
mysql-test/suite/pbxt/r/dirty_close.result
Normal file
9
mysql-test/suite/pbxt/r/dirty_close.result
Normal file
@@ -0,0 +1,9 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (n int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
select * from t1;
|
||||
n
|
||||
1
|
||||
2
|
||||
3
|
||||
drop table t1;
|
||||
646
mysql-test/suite/pbxt/r/distinct.result
Normal file
646
mysql-test/suite/pbxt/r/distinct.result
Normal file
@@ -0,0 +1,646 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
CREATE TABLE t1 (id int,facility char(20));
|
||||
CREATE TABLE t2 (facility char(20));
|
||||
INSERT INTO t1 VALUES (NULL,NULL);
|
||||
INSERT INTO t1 VALUES (-1,'');
|
||||
INSERT INTO t1 VALUES (0,'');
|
||||
INSERT INTO t1 VALUES (1,'/L');
|
||||
INSERT INTO t1 VALUES (2,'A01');
|
||||
INSERT INTO t1 VALUES (3,'ANC');
|
||||
INSERT INTO t1 VALUES (4,'F01');
|
||||
INSERT INTO t1 VALUES (5,'FBX');
|
||||
INSERT INTO t1 VALUES (6,'MT');
|
||||
INSERT INTO t1 VALUES (7,'P');
|
||||
INSERT INTO t1 VALUES (8,'RV');
|
||||
INSERT INTO t1 VALUES (9,'SRV');
|
||||
INSERT INTO t1 VALUES (10,'VMT');
|
||||
INSERT INTO t2 SELECT DISTINCT FACILITY FROM t1;
|
||||
select id from t1 group by id;
|
||||
id
|
||||
NULL
|
||||
-1
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
select * from t1 order by id;
|
||||
id facility
|
||||
NULL NULL
|
||||
-1
|
||||
0
|
||||
1 /L
|
||||
2 A01
|
||||
3 ANC
|
||||
4 F01
|
||||
5 FBX
|
||||
6 MT
|
||||
7 P
|
||||
8 RV
|
||||
9 SRV
|
||||
10 VMT
|
||||
select id-5,facility from t1 order by "id-5";
|
||||
id-5 facility
|
||||
NULL NULL
|
||||
-6
|
||||
-5
|
||||
-4 /L
|
||||
-3 A01
|
||||
-2 ANC
|
||||
-1 F01
|
||||
0 FBX
|
||||
1 MT
|
||||
2 P
|
||||
3 RV
|
||||
4 SRV
|
||||
5 VMT
|
||||
select id,concat(facility) from t1 group by id ;
|
||||
id concat(facility)
|
||||
NULL NULL
|
||||
-1
|
||||
0
|
||||
1 /L
|
||||
2 A01
|
||||
3 ANC
|
||||
4 F01
|
||||
5 FBX
|
||||
6 MT
|
||||
7 P
|
||||
8 RV
|
||||
9 SRV
|
||||
10 VMT
|
||||
select id+0 as a,max(id),concat(facility) as b from t1 group by a order by b desc,a;
|
||||
a max(id) b
|
||||
10 10 VMT
|
||||
9 9 SRV
|
||||
8 8 RV
|
||||
7 7 P
|
||||
6 6 MT
|
||||
5 5 FBX
|
||||
4 4 F01
|
||||
3 3 ANC
|
||||
2 2 A01
|
||||
1 1 /L
|
||||
-1 -1
|
||||
0 0
|
||||
NULL NULL NULL
|
||||
select id >= 0 and id <= 5 as grp,count(*) from t1 group by grp;
|
||||
grp count(*)
|
||||
NULL 1
|
||||
0 6
|
||||
1 6
|
||||
SELECT DISTINCT FACILITY FROM t1;
|
||||
FACILITY
|
||||
NULL
|
||||
|
||||
/L
|
||||
A01
|
||||
ANC
|
||||
F01
|
||||
FBX
|
||||
MT
|
||||
P
|
||||
RV
|
||||
SRV
|
||||
VMT
|
||||
SELECT FACILITY FROM t2;
|
||||
FACILITY
|
||||
NULL
|
||||
|
||||
/L
|
||||
A01
|
||||
ANC
|
||||
F01
|
||||
FBX
|
||||
MT
|
||||
P
|
||||
RV
|
||||
SRV
|
||||
VMT
|
||||
SELECT count(*) from t1,t2 where t1.facility=t2.facility;
|
||||
count(*)
|
||||
12
|
||||
select count(facility) from t1;
|
||||
count(facility)
|
||||
12
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
13
|
||||
select count(*) from t1 where facility IS NULL;
|
||||
count(*)
|
||||
1
|
||||
select count(*) from t1 where facility = NULL;
|
||||
count(*)
|
||||
0
|
||||
select count(*) from t1 where facility IS NOT NULL;
|
||||
count(*)
|
||||
12
|
||||
select count(*) from t1 where id IS NULL;
|
||||
count(*)
|
||||
1
|
||||
select count(*) from t1 where id IS NOT NULL;
|
||||
count(*)
|
||||
12
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (UserId int(11) DEFAULT '0' NOT NULL);
|
||||
INSERT INTO t1 VALUES (20);
|
||||
INSERT INTO t1 VALUES (27);
|
||||
SELECT UserId FROM t1 WHERE Userid=22;
|
||||
UserId
|
||||
SELECT UserId FROM t1 WHERE UserId=22 group by Userid;
|
||||
UserId
|
||||
SELECT DISTINCT UserId FROM t1 WHERE UserId=22 group by Userid;
|
||||
UserId
|
||||
SELECT DISTINCT UserId FROM t1 WHERE UserId=22;
|
||||
UserId
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int(10) unsigned not null primary key,b int(10) unsigned);
|
||||
INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1);
|
||||
CREATE TABLE t2 (a int(10) unsigned not null, key (A));
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
CREATE TABLE t3 (a int(10) unsigned, key(A), b text);
|
||||
INSERT INTO t3 VALUES (1,'1'),(2,'2');
|
||||
SELECT DISTINCT t3.b FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
|
||||
b
|
||||
1
|
||||
INSERT INTO t2 values (1),(2),(3);
|
||||
INSERT INTO t3 VALUES (1,'1'),(2,'2'),(1,'1'),(2,'2');
|
||||
explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using temporary
|
||||
1 SIMPLE t3 ref a a 5 test.t1.b 2 Using where; Using index
|
||||
1 SIMPLE t2 index a a 4 NULL 5 Using where; Using index; Distinct; Using join buffer
|
||||
SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
|
||||
a
|
||||
1
|
||||
create temporary table t4 select * from t3;
|
||||
insert into t3 select * from t4;
|
||||
insert into t4 select * from t3;
|
||||
insert into t3 select * from t4;
|
||||
insert into t4 select * from t3;
|
||||
insert into t3 select * from t4;
|
||||
insert into t4 select * from t3;
|
||||
insert into t3 select * from t4;
|
||||
explain select distinct t1.a from t1,t3 where t1.a=t3.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 4 Using index; Using temporary
|
||||
1 SIMPLE t3 ref a a 5 test.t1.a 11 Using where; Using index; Distinct
|
||||
select distinct t1.a from t1,t3 where t1.a=t3.a;
|
||||
a
|
||||
1
|
||||
2
|
||||
select distinct 1 from t1,t3 where t1.a=t3.a;
|
||||
1
|
||||
1
|
||||
explain SELECT distinct t1.a from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
|
||||
explain SELECT distinct t1.a from t1 order by a desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
|
||||
explain SELECT t1.a from t1 group by a order by a desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
|
||||
explain SELECT distinct t1.a from t1 order by a desc limit 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 1 Using index
|
||||
explain SELECT distinct a from t3 order by a desc limit 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 index NULL a 5 NULL 40 Using index
|
||||
explain SELECT distinct a,b from t3 order by a+1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
|
||||
explain SELECT distinct a,b from t3 order by a limit 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
|
||||
explain SELECT a,b from t3 group by a,b order by a+1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
|
||||
drop table t1,t2,t3,t4;
|
||||
CREATE TABLE t1 (name varchar(255));
|
||||
INSERT INTO t1 VALUES ('aa'),('ab'),('ac'),('ad'),('ae');
|
||||
SELECT DISTINCT * FROM t1 LIMIT 2;
|
||||
name
|
||||
aa
|
||||
ab
|
||||
SELECT DISTINCT name FROM t1 LIMIT 2;
|
||||
name
|
||||
aa
|
||||
ab
|
||||
SELECT DISTINCT 1 FROM t1 LIMIT 2;
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
NAME varchar(75) DEFAULT '' NOT NULL,
|
||||
LINK_ID int(11) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
KEY NAME (NAME),
|
||||
KEY LINK_ID (LINK_ID)
|
||||
);
|
||||
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0),(2,'Jack',0),(3,'Bill',0);
|
||||
CREATE TABLE t2 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
NAME varchar(150) DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
KEY NAME (NAME)
|
||||
);
|
||||
SELECT DISTINCT
|
||||
t2.id AS key_link_id,
|
||||
t2.name AS link
|
||||
FROM t1
|
||||
LEFT JOIN t2 ON t1.link_id=t2.id
|
||||
GROUP BY t1.id
|
||||
ORDER BY link;
|
||||
key_link_id link
|
||||
NULL NULL
|
||||
drop table t1,t2;
|
||||
create table t1 (
|
||||
id int not null,
|
||||
name tinytext not null,
|
||||
unique (id)
|
||||
);
|
||||
create table t2 (
|
||||
id int not null,
|
||||
idx int not null,
|
||||
unique (id, idx)
|
||||
);
|
||||
create table t3 (
|
||||
id int not null,
|
||||
idx int not null,
|
||||
unique (id, idx)
|
||||
);
|
||||
insert into t1 values (1,'yes'), (2,'no');
|
||||
insert into t2 values (1,1);
|
||||
insert into t3 values (1,1);
|
||||
EXPLAIN
|
||||
SELECT DISTINCT
|
||||
t1.id
|
||||
from
|
||||
t1
|
||||
straight_join
|
||||
t2
|
||||
straight_join
|
||||
t3
|
||||
straight_join
|
||||
t1 as j_lj_t2 left join t2 as t2_lj
|
||||
on j_lj_t2.id=t2_lj.id
|
||||
straight_join
|
||||
t1 as j_lj_t3 left join t3 as t3_lj
|
||||
on j_lj_t3.id=t3_lj.id
|
||||
WHERE
|
||||
((t1.id=j_lj_t2.id AND t2_lj.id IS NULL) OR (t1.id=t2.id AND t2.idx=2))
|
||||
AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index id id 4 NULL 2 Using index; Using temporary
|
||||
1 SIMPLE t2 index id id 8 NULL 1 Using index; Distinct; Using join buffer
|
||||
1 SIMPLE t3 index id id 8 NULL 1 Using index; Distinct; Using join buffer
|
||||
1 SIMPLE j_lj_t2 index id id 4 NULL 2 Using where; Using index; Distinct; Using join buffer
|
||||
1 SIMPLE t2_lj ref id id 4 test.j_lj_t2.id 1 Using where; Using index; Distinct
|
||||
1 SIMPLE j_lj_t3 index id id 4 NULL 2 Using where; Using index; Distinct; Using join buffer
|
||||
1 SIMPLE t3_lj ref id id 4 test.j_lj_t3.id 1 Using where; Using index; Distinct
|
||||
SELECT DISTINCT
|
||||
t1.id
|
||||
from
|
||||
t1
|
||||
straight_join
|
||||
t2
|
||||
straight_join
|
||||
t3
|
||||
straight_join
|
||||
t1 as j_lj_t2 left join t2 as t2_lj
|
||||
on j_lj_t2.id=t2_lj.id
|
||||
straight_join
|
||||
t1 as j_lj_t3 left join t3 as t3_lj
|
||||
on j_lj_t3.id=t3_lj.id
|
||||
WHERE
|
||||
((t1.id=j_lj_t2.id AND t2_lj.id IS NULL) OR (t1.id=t2.id AND t2.idx=2))
|
||||
AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2));
|
||||
id
|
||||
2
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (a int not null, b int not null, t time);
|
||||
insert into t1 values (1,1,"00:06:15"),(1,2,"00:06:15"),(1,2,"00:30:15"),(1,3,"00:06:15"),(1,3,"00:30:15");
|
||||
select a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b;
|
||||
a sec_to_time(sum(time_to_sec(t)))
|
||||
1 00:06:15
|
||||
1 00:36:30
|
||||
1 00:36:30
|
||||
select distinct a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b;
|
||||
a sec_to_time(sum(time_to_sec(t)))
|
||||
1 00:06:15
|
||||
1 00:36:30
|
||||
create table t2 (a int not null primary key, b int);
|
||||
insert into t2 values (1,1),(2,2),(3,3);
|
||||
select t1.a,sec_to_time(sum(time_to_sec(t))) from t1 left join t2 on (t1.b=t2.a) group by t1.a,t2.b;
|
||||
a sec_to_time(sum(time_to_sec(t)))
|
||||
1 00:06:15
|
||||
1 00:36:30
|
||||
1 00:36:30
|
||||
select distinct t1.a,sec_to_time(sum(time_to_sec(t))) from t1 left join t2 on (t1.b=t2.a) group by t1.a,t2.b;
|
||||
a sec_to_time(sum(time_to_sec(t)))
|
||||
1 00:06:15
|
||||
1 00:36:30
|
||||
drop table t1,t2;
|
||||
create table t1 (a int not null,b char(5), c text);
|
||||
insert into t1 (a) values (1),(2),(3),(4),(1),(2),(3),(4);
|
||||
select distinct a from t1 group by b,a having a > 2 order by a desc;
|
||||
a
|
||||
4
|
||||
3
|
||||
select distinct a,c from t1 group by b,c,a having a > 2 order by a desc;
|
||||
a c
|
||||
4 NULL
|
||||
3 NULL
|
||||
drop table t1;
|
||||
create table t1 (a char(1), key(a)) engine=myisam;
|
||||
insert into t1 values('1'),('1');
|
||||
select * from t1 where a >= '1';
|
||||
a
|
||||
1
|
||||
1
|
||||
select distinct a from t1 order by a desc;
|
||||
a
|
||||
1
|
||||
select distinct a from t1 where a >= '1' order by a desc;
|
||||
a
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (email varchar(50), infoID BIGINT, dateentered DATETIME);
|
||||
CREATE TABLE t2 (infoID BIGINT, shipcode varchar(10));
|
||||
INSERT INTO t1 (email, infoID, dateentered) VALUES
|
||||
('test1@testdomain.com', 1, '2002-07-30 22:56:38'),
|
||||
('test1@testdomain.com', 1, '2002-07-27 22:58:16'),
|
||||
('test2@testdomain.com', 1, '2002-06-19 15:22:19'),
|
||||
('test2@testdomain.com', 2, '2002-06-18 14:23:47'),
|
||||
('test3@testdomain.com', 1, '2002-05-19 22:17:32');
|
||||
INSERT INTO t2(infoID, shipcode) VALUES
|
||||
(1, 'Z001'),
|
||||
(2, 'R002');
|
||||
SELECT DISTINCTROW email, shipcode FROM t1, t2 WHERE t1.infoID=t2.infoID;
|
||||
email shipcode
|
||||
test1@testdomain.com Z001
|
||||
test2@testdomain.com Z001
|
||||
test2@testdomain.com R002
|
||||
test3@testdomain.com Z001
|
||||
SELECT DISTINCTROW email FROM t1 ORDER BY dateentered DESC;
|
||||
email
|
||||
test1@testdomain.com
|
||||
test2@testdomain.com
|
||||
test3@testdomain.com
|
||||
SELECT DISTINCTROW email, shipcode FROM t1, t2 WHERE t1.infoID=t2.infoID ORDER BY dateentered DESC;
|
||||
email shipcode
|
||||
test1@testdomain.com Z001
|
||||
test2@testdomain.com Z001
|
||||
test2@testdomain.com R002
|
||||
test3@testdomain.com Z001
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (privatemessageid int(10) unsigned NOT NULL auto_increment, folderid smallint(6) NOT NULL default '0', userid int(10) unsigned NOT NULL default '0', touserid int(10) unsigned NOT NULL default '0', fromuserid int(10) unsigned NOT NULL default '0', title varchar(250) NOT NULL default '', message mediumtext NOT NULL, dateline int(10) unsigned NOT NULL default '0', showsignature smallint(6) NOT NULL default '0', iconid smallint(5) unsigned NOT NULL default '0', messageread smallint(6) NOT NULL default '0', readtime int(10) unsigned NOT NULL default '0', receipt smallint(6) unsigned NOT NULL default '0', deleteprompt smallint(6) unsigned NOT NULL default '0', multiplerecipients smallint(6) unsigned NOT NULL default '0', PRIMARY KEY (privatemessageid), KEY userid (userid)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (128,0,33,33,8,':D','',996121863,1,0,2,996122850,2,0,0);
|
||||
CREATE TABLE t2 (userid int(10) unsigned NOT NULL auto_increment, usergroupid smallint(5) unsigned NOT NULL default '0', username varchar(50) NOT NULL default '', password varchar(50) NOT NULL default '', email varchar(50) NOT NULL default '', styleid smallint(5) unsigned NOT NULL default '0', parentemail varchar(50) NOT NULL default '', coppauser smallint(6) NOT NULL default '0', homepage varchar(100) NOT NULL default '', icq varchar(20) NOT NULL default '', aim varchar(20) NOT NULL default '', yahoo varchar(20) NOT NULL default '', signature mediumtext NOT NULL, adminemail smallint(6) NOT NULL default '0', showemail smallint(6) NOT NULL default '0', invisible smallint(6) NOT NULL default '0', usertitle varchar(250) NOT NULL default '', customtitle smallint(6) NOT NULL default '0', joindate int(10) unsigned NOT NULL default '0', cookieuser smallint(6) NOT NULL default '0', daysprune smallint(6) NOT NULL default '0', lastvisit int(10) unsigned NOT NULL default '0', lastactivity int(10) unsigned NOT NULL default '0', lastpost int(10) unsigned NOT NULL default '0', posts smallint(5) unsigned NOT NULL default '0', timezoneoffset varchar(4) NOT NULL default '', emailnotification smallint(6) NOT NULL default '0', buddylist mediumtext NOT NULL, ignorelist mediumtext NOT NULL, pmfolders mediumtext NOT NULL, receivepm smallint(6) NOT NULL default '0', emailonpm smallint(6) NOT NULL default '0', pmpopup smallint(6) NOT NULL default '0', avatarid smallint(6) NOT NULL default '0', avatarrevision int(6) unsigned NOT NULL default '0', options smallint(6) NOT NULL default '15', birthday date NOT NULL default '0000-00-00', maxposts smallint(6) NOT NULL default '-1', startofweek smallint(6) NOT NULL default '1', ipaddress varchar(20) NOT NULL default '', referrerid int(10) unsigned NOT NULL default '0', nosessionhash smallint(6) NOT NULL default '0', autorefresh smallint(6) NOT NULL default '-1', messagepopup tinyint(2) NOT NULL default '0', inforum smallint(5) unsigned NOT NULL default '0', ratenum smallint(5) unsigned NOT NULL default '0', ratetotal smallint(5) unsigned NOT NULL default '0', allowrate smallint(5) unsigned NOT NULL default '1', PRIMARY KEY (userid), KEY usergroupid (usergroupid), KEY username (username), KEY inforum (inforum)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (33,6,'Kevin','0','kevin@stileproject.com',1,'',0,'http://www.stileproject.com','','','','',1,1,0,'Administrator',0,996120694,1,-1,1030996168,1031027028,1030599436,36,'-6',0,'','','',1,0,1,0,0,15,'0000-00-00',-1,1,'64.0.0.0',0,1,-1,0,0,4,19,1);
|
||||
SELECT DISTINCT t1.*, t2.* FROM t1 LEFT JOIN t2 ON (t2.userid = t1.touserid);
|
||||
privatemessageid folderid userid touserid fromuserid title message dateline showsignature iconid messageread readtime receipt deleteprompt multiplerecipients userid usergroupid username password email styleid parentemail coppauser homepage icq aim yahoo signature adminemail showemail invisible usertitle customtitle joindate cookieuser daysprune lastvisit lastactivity lastpost posts timezoneoffset emailnotification buddylist ignorelist pmfolders receivepm emailonpm pmpopup avatarid avatarrevision options birthday maxposts startofweek ipaddress referrerid nosessionhash autorefresh messagepopup inforum ratenum ratetotal allowrate
|
||||
128 0 33 33 8 :D 996121863 1 0 2 996122850 2 0 0 33 6 Kevin 0 kevin@stileproject.com 1 0 http://www.stileproject.com 1 1 0 Administrator 0 996120694 1 -1 1030996168 1031027028 1030599436 36 -6 0 1 0 1 0 0 15 0000-00-00 -1 1 64.0.0.0 0 1 -1 0 0 4 19 1
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a int primary key, b int, c int);
|
||||
INSERT t1 VALUES (1,2,3);
|
||||
CREATE TABLE t2 (a int primary key, b int, c int);
|
||||
INSERT t2 VALUES (3,4,5);
|
||||
SELECT DISTINCT t1.a, t2.b FROM t1, t2 WHERE t1.a=1 ORDER BY t2.c;
|
||||
a b
|
||||
1 4
|
||||
DROP TABLE t1,t2;
|
||||
CREATE table t1 ( `id` int(11) NOT NULL auto_increment, `name` varchar(50) NOT NULL default '', PRIMARY KEY (`id`)) ENGINE=MyISAM AUTO_INCREMENT=3 ;
|
||||
INSERT INTO t1 VALUES (1, 'aaaaa');
|
||||
INSERT INTO t1 VALUES (3, 'aaaaa');
|
||||
INSERT INTO t1 VALUES (2, 'eeeeeee');
|
||||
select distinct left(name,1) as name from t1;
|
||||
name
|
||||
a
|
||||
e
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
NAME varchar(75) DEFAULT '' NOT NULL,
|
||||
LINK_ID int(11) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
KEY NAME (NAME),
|
||||
KEY LINK_ID (LINK_ID)
|
||||
);
|
||||
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0);
|
||||
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0);
|
||||
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0);
|
||||
CREATE TABLE t2 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
NAME varchar(150) DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
KEY NAME (NAME)
|
||||
);
|
||||
SELECT DISTINCT
|
||||
t2.id AS key_link_id,
|
||||
t2.name AS link
|
||||
FROM t1
|
||||
LEFT JOIN t2 ON t1.link_id=t2.id
|
||||
GROUP BY t1.id
|
||||
ORDER BY link;
|
||||
key_link_id link
|
||||
NULL NULL
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (
|
||||
html varchar(5) default NULL,
|
||||
rin int(11) default '0',
|
||||
rout int(11) default '0'
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('1',1,0);
|
||||
SELECT DISTINCT html,SUM(rout)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
|
||||
html prod
|
||||
1 0.0000
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
|
||||
SELECT DISTINCT a, 1 FROM t1;
|
||||
a 1
|
||||
1 1
|
||||
2 1
|
||||
3 1
|
||||
4 1
|
||||
5 1
|
||||
SELECT DISTINCT 1, a FROM t1;
|
||||
1 a
|
||||
1 1
|
||||
1 2
|
||||
1 3
|
||||
1 4
|
||||
1 5
|
||||
CREATE TABLE t2 (a int, b int);
|
||||
INSERT INTO t2 VALUES (1,1),(2,2),(2,3),(2,4),(3,5);
|
||||
SELECT DISTINCT a, b, 2 FROM t2;
|
||||
a b 2
|
||||
1 1 2
|
||||
2 2 2
|
||||
2 3 2
|
||||
2 4 2
|
||||
3 5 2
|
||||
SELECT DISTINCT 2, a, b FROM t2;
|
||||
2 a b
|
||||
2 1 1
|
||||
2 2 2
|
||||
2 2 3
|
||||
2 2 4
|
||||
2 3 5
|
||||
SELECT DISTINCT a, 2, b FROM t2;
|
||||
a 2 b
|
||||
1 2 1
|
||||
2 2 2
|
||||
2 2 3
|
||||
2 2 4
|
||||
3 2 5
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1(a INT PRIMARY KEY, b INT);
|
||||
INSERT INTO t1 VALUES (1,1), (2,1), (3,1);
|
||||
EXPLAIN SELECT DISTINCT a FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
|
||||
EXPLAIN SELECT DISTINCT a,b FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
EXPLAIN SELECT DISTINCT t1_1.a, t1_1.b FROM t1 t1_1, t1 t1_2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1_1 ALL NULL NULL NULL NULL 3 Using temporary
|
||||
1 SIMPLE t1_2 index NULL PRIMARY 4 NULL 3 Using index; Distinct; Using join buffer
|
||||
EXPLAIN SELECT DISTINCT t1_1.a, t1_1.b FROM t1 t1_1, t1 t1_2
|
||||
WHERE t1_1.a = t1_2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1_1 ALL PRIMARY NULL NULL NULL 3 Using temporary
|
||||
1 SIMPLE t1_2 eq_ref PRIMARY PRIMARY 4 test.t1_1.a 1 Using index; Distinct
|
||||
EXPLAIN SELECT a FROM t1 GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
|
||||
EXPLAIN SELECT a,b FROM t1 GROUP BY a,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
EXPLAIN SELECT DISTINCT a,b FROM t1 GROUP BY a,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
CREATE TABLE t2(a INT, b INT, c INT, d INT, PRIMARY KEY (a,b));
|
||||
INSERT INTO t2 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
|
||||
EXPLAIN SELECT DISTINCT a FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index
|
||||
EXPLAIN SELECT DISTINCT a,a FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index
|
||||
EXPLAIN SELECT DISTINCT b,a FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index
|
||||
EXPLAIN SELECT DISTINCT a,c FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using temporary
|
||||
EXPLAIN SELECT DISTINCT c,a,b FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
|
||||
EXPLAIN SELECT DISTINCT a,b,d FROM t2 GROUP BY c,b,d;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
|
||||
CREATE UNIQUE INDEX c_b_unq ON t2 (c,b);
|
||||
EXPLAIN SELECT DISTINCT a,b,d FROM t2 GROUP BY c,b,d;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
|
||||
DROP TABLE t1,t2;
|
||||
create table t1 (id int, dsc varchar(50));
|
||||
insert into t1 values (1, "line number one"), (2, "line number two"), (3, "line number three");
|
||||
select distinct id, IFNULL(dsc, '-') from t1;
|
||||
id IFNULL(dsc, '-')
|
||||
1 line number one
|
||||
2 line number two
|
||||
3 line number three
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int primary key, b int);
|
||||
INSERT INTO t1 (a,b) values (1,1), (2,3), (3,2);
|
||||
explain SELECT DISTINCT a, b FROM t1 ORDER BY b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
SELECT DISTINCT a, b FROM t1 ORDER BY b;
|
||||
a b
|
||||
1 1
|
||||
3 2
|
||||
2 3
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
x varchar(20) default NULL,
|
||||
y decimal(10,0) default NULL,
|
||||
PRIMARY KEY (ID),
|
||||
KEY (y)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES
|
||||
(1,'ba','-1'),
|
||||
(2,'ba','1150'),
|
||||
(306,'ba','-1'),
|
||||
(307,'ba','1150'),
|
||||
(611,'ba','-1'),
|
||||
(612,'ba','1150');
|
||||
select count(distinct x,y) from t1;
|
||||
count(distinct x,y)
|
||||
2
|
||||
select count(distinct concat(x,y)) from t1;
|
||||
count(distinct concat(x,y))
|
||||
2
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b));
|
||||
INSERT INTO t1 VALUES (1, 101);
|
||||
INSERT INTO t1 SELECT a + 1, a + 101 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 2, a + 102 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 4, a + 104 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 8, a + 108 FROM t1;
|
||||
EXPLAIN SELECT DISTINCT a,a FROM t1 WHERE b < 12 ORDER BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 8 NULL 16 Using where; Using index
|
||||
SELECT DISTINCT a,a FROM t1 WHERE b < 12 ORDER BY a;
|
||||
a a
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a CHAR(1));
|
||||
INSERT INTO t1 VALUES('A'), (0);
|
||||
SELECT a FROM t1 WHERE a=0;
|
||||
a
|
||||
A
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'A'
|
||||
SELECT DISTINCT a FROM t1 WHERE a=0;
|
||||
a
|
||||
A
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'A'
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a DATE);
|
||||
INSERT INTO t1 VALUES ('1972-07-29'), ('1972-02-06');
|
||||
EXPLAIN SELECT (SELECT DISTINCT a FROM t1 WHERE a = '2002-08-03');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
EXPLAIN SELECT (SELECT DISTINCT ADDDATE(a,1) FROM t1
|
||||
WHERE ADDDATE(a,1) = '2002-08-03');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
CREATE TABLE t2 (a CHAR(5) CHARACTER SET latin1 COLLATE latin1_general_ci);
|
||||
INSERT INTO t2 VALUES (0xf6);
|
||||
INSERT INTO t2 VALUES ('oe');
|
||||
SELECT COUNT(*) FROM (SELECT DISTINCT a FROM t2) dt;
|
||||
COUNT(*)
|
||||
2
|
||||
SELECT COUNT(*) FROM
|
||||
(SELECT DISTINCT a FROM t2 WHERE a='oe' COLLATE latin1_german2_ci) dt;
|
||||
COUNT(*)
|
||||
2
|
||||
DROP TABLE t1, t2;
|
||||
91
mysql-test/suite/pbxt/r/drop.result
Normal file
91
mysql-test/suite/pbxt/r/drop.result
Normal file
@@ -0,0 +1,91 @@
|
||||
drop table if exists t1;
|
||||
drop database if exists mysqltest;
|
||||
drop database if exists client_test_db;
|
||||
drop table t1;
|
||||
ERROR 42S02: Unknown table 't1'
|
||||
create table t1(n int);
|
||||
insert into t1 values(1);
|
||||
create temporary table t1( n int);
|
||||
insert into t1 values(2);
|
||||
create table t1(n int);
|
||||
ERROR 42S01: Table 't1' already exists
|
||||
drop table t1;
|
||||
select * from t1;
|
||||
n
|
||||
1
|
||||
create database mysqltest;
|
||||
drop database if exists mysqltest;
|
||||
create database mysqltest;
|
||||
create table mysqltest.mysqltest (n int);
|
||||
insert into mysqltest.mysqltest values (4);
|
||||
select * from mysqltest.mysqltest;
|
||||
n
|
||||
4
|
||||
drop database if exists mysqltest;
|
||||
affected rows: 1
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
drop table table1, table2, table3, table4, table5, table6,
|
||||
table7, table8, table9, table10, table11, table12, table13,
|
||||
table14, table15, table16, table17, table18, table19, table20,
|
||||
table21, table22, table23, table24, table25, table26, table27,
|
||||
table28;
|
||||
ERROR 42S02: Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table'
|
||||
drop table table1, table2, table3, table4, table5, table6,
|
||||
table7, table8, table9, table10, table11, table12, table13,
|
||||
table14, table15, table16, table17, table18, table19, table20,
|
||||
table21, table22, table23, table24, table25, table26, table27,
|
||||
table28, table29, table30;
|
||||
ERROR 42S02: Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table'
|
||||
use test;
|
||||
drop database mysqltest;
|
||||
flush tables with read lock;
|
||||
create database mysqltest;
|
||||
Got one of the listed errors
|
||||
unlock tables;
|
||||
create database mysqltest;
|
||||
show databases;
|
||||
Database
|
||||
information_schema
|
||||
mtr
|
||||
mysql
|
||||
mysqltest
|
||||
pbxt
|
||||
test
|
||||
flush tables with read lock;
|
||||
drop database mysqltest;
|
||||
Got one of the listed errors
|
||||
unlock tables;
|
||||
drop database mysqltest;
|
||||
show databases;
|
||||
Database
|
||||
information_schema
|
||||
mtr
|
||||
mysql
|
||||
pbxt
|
||||
test
|
||||
drop database mysqltest;
|
||||
ERROR HY000: Can't drop database 'mysqltest'; database doesn't exist
|
||||
drop table t1;
|
||||
flush tables with read lock;
|
||||
create table t1(n int);
|
||||
ERROR HY000: Can't execute the query because you have a conflicting read lock
|
||||
unlock tables;
|
||||
create table t1(n int);
|
||||
show tables;
|
||||
Tables_in_test
|
||||
t1
|
||||
drop table t1;
|
||||
drop database if exists mysqltest;
|
||||
drop table if exists t1;
|
||||
create table t1 (i int);
|
||||
lock tables t1 read;
|
||||
create database mysqltest;
|
||||
drop table t1;
|
||||
show open tables;
|
||||
drop database mysqltest;
|
||||
select 1;
|
||||
1
|
||||
1
|
||||
unlock tables;
|
||||
End of 5.0 tests
|
||||
10
mysql-test/suite/pbxt/r/empty_table.result
Normal file
10
mysql-test/suite/pbxt/r/empty_table.result
Normal file
@@ -0,0 +1,10 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
0
|
||||
select * from t1;
|
||||
nr b str
|
||||
select * from t1 limit 0;
|
||||
nr b str
|
||||
drop table t1;
|
||||
217
mysql-test/suite/pbxt/r/endspace.result
Normal file
217
mysql-test/suite/pbxt/r/endspace.result
Normal file
@@ -0,0 +1,217 @@
|
||||
drop table if exists t1;
|
||||
select 'a' = 'a', 'a' = 'a ', 'a ' = 'a';
|
||||
'a' = 'a' 'a' = 'a ' 'a ' = 'a'
|
||||
1 1 1
|
||||
select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a';
|
||||
'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a'
|
||||
0 1 0
|
||||
select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0';
|
||||
'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0'
|
||||
0 0 1
|
||||
select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a ';
|
||||
'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a '
|
||||
0 1 0
|
||||
select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0';
|
||||
'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0'
|
||||
0 0 1
|
||||
select 'a a' > 'a', 'a \0' < 'a';
|
||||
'a a' > 'a' 'a \0' < 'a'
|
||||
1 1
|
||||
select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a';
|
||||
binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a'
|
||||
1 1 1
|
||||
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1));
|
||||
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
select * from t1 ignore key (key1) where text1='teststring' or text1 like 'teststring_%';
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select * from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select * from t1 where text1='teststring' or text1 > 'teststring\t';
|
||||
text1
|
||||
teststring
|
||||
select * from t1 order by text1;
|
||||
text1
|
||||
nothing
|
||||
teststring
|
||||
teststring
|
||||
explain select * from t1 order by text1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL key1 34 NULL 3 Using index
|
||||
alter table t1 modify text1 char(32) binary not null;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
select * from t1 ignore key (key1) where text1='teststring' or text1 like 'teststring_%';
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
concat('|', text1, '|')
|
||||
|teststring |
|
||||
|teststring|
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t';
|
||||
concat('|', text1, '|')
|
||||
|teststring|
|
||||
select text1, length(text1) from t1 order by text1;
|
||||
text1 length(text1)
|
||||
nothing 7
|
||||
teststring 11
|
||||
teststring 10
|
||||
select text1, length(text1) from t1 order by binary text1;
|
||||
text1 length(text1)
|
||||
nothing 7
|
||||
teststring 10
|
||||
teststring 11
|
||||
alter table t1 modify text1 blob not null, drop key key1, add key key1 (text1(20));
|
||||
insert into t1 values ('teststring ');
|
||||
select concat('|', text1, '|') from t1 order by text1;
|
||||
concat('|', text1, '|')
|
||||
|nothing|
|
||||
|teststring|
|
||||
|teststring |
|
||||
|teststring |
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t';
|
||||
concat('|', text1, '|')
|
||||
|teststring|
|
||||
|teststring |
|
||||
select concat('|', text1, '|') from t1 where text1='teststring';
|
||||
concat('|', text1, '|')
|
||||
|teststring|
|
||||
select concat('|', text1, '|') from t1 where text1='teststring ';
|
||||
concat('|', text1, '|')
|
||||
|teststring |
|
||||
alter table t1 modify text1 text not null, pack_keys=1;
|
||||
select concat('|', text1, '|') from t1 where text1='teststring';
|
||||
concat('|', text1, '|')
|
||||
|teststring|
|
||||
|teststring |
|
||||
select concat('|', text1, '|') from t1 where text1='teststring ';
|
||||
concat('|', text1, '|')
|
||||
|teststring|
|
||||
|teststring |
|
||||
explain select concat('|', text1, '|') from t1 where text1='teststring ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref key1 key1 22 const 1 Using where
|
||||
select concat('|', text1, '|') from t1 where text1 like 'teststring_%';
|
||||
concat('|', text1, '|')
|
||||
|teststring |
|
||||
|teststring |
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
concat('|', text1, '|')
|
||||
|teststring |
|
||||
|teststring|
|
||||
|teststring |
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t';
|
||||
concat('|', text1, '|')
|
||||
|teststring|
|
||||
|teststring |
|
||||
select concat('|', text1, '|') from t1 order by text1;
|
||||
concat('|', text1, '|')
|
||||
|nothing|
|
||||
|teststring |
|
||||
|teststring|
|
||||
|teststring |
|
||||
drop table t1;
|
||||
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) pack_keys=0;
|
||||
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
concat('|', text1, '|')
|
||||
|teststring |
|
||||
|teststring|
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 >= 'teststring\t';
|
||||
concat('|', text1, '|')
|
||||
|teststring |
|
||||
|teststring|
|
||||
drop table t1;
|
||||
create table t1 (text1 varchar(32) not NULL, KEY key1 using BTREE (text1)) engine=heap;
|
||||
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
|
||||
select * from t1 ignore key (key1) where text1='teststring' or text1 like 'teststring_%';
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select * from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select * from t1 where text1='teststring' or text1 >= 'teststring\t';
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select * from t1 order by text1;
|
||||
text1
|
||||
nothing
|
||||
teststring
|
||||
teststring
|
||||
explain select * from t1 order by text1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
alter table t1 modify text1 char(32) binary not null;
|
||||
select * from t1 order by text1;
|
||||
text1
|
||||
nothing
|
||||
teststring
|
||||
teststring
|
||||
drop table t1;
|
||||
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) engine=innodb;
|
||||
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
select * from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select * from t1 where text1='teststring' or text1 > 'teststring\t';
|
||||
text1
|
||||
teststring
|
||||
select * from t1 order by text1;
|
||||
text1
|
||||
nothing
|
||||
teststring
|
||||
teststring
|
||||
explain select * from t1 order by text1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL key1 34 NULL 3 Using index
|
||||
alter table t1 modify text1 char(32) binary not null;
|
||||
select * from t1 order by text1;
|
||||
text1
|
||||
nothing
|
||||
teststring
|
||||
teststring
|
||||
alter table t1 modify text1 blob not null, drop key key1, add key key1 (text1(20));
|
||||
insert into t1 values ('teststring ');
|
||||
select concat('|', text1, '|') from t1 order by text1;
|
||||
concat('|', text1, '|')
|
||||
|nothing|
|
||||
|teststring|
|
||||
|teststring |
|
||||
|teststring |
|
||||
alter table t1 modify text1 text not null, pack_keys=1;
|
||||
select * from t1 where text1 like 'teststring_%';
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select text1, length(text1) from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
text1 length(text1)
|
||||
teststring 11
|
||||
teststring 10
|
||||
teststring 11
|
||||
select text1, length(text1) from t1 where text1='teststring' or text1 >= 'teststring\t';
|
||||
text1 length(text1)
|
||||
teststring 11
|
||||
teststring 10
|
||||
teststring 11
|
||||
select concat('|', text1, '|') from t1 order by text1;
|
||||
concat('|', text1, '|')
|
||||
|nothing|
|
||||
|teststring |
|
||||
|teststring|
|
||||
|teststring |
|
||||
drop table t1;
|
||||
30
mysql-test/suite/pbxt/r/errors.result
Normal file
30
mysql-test/suite/pbxt/r/errors.result
Normal file
@@ -0,0 +1,30 @@
|
||||
drop table if exists t1;
|
||||
insert into t1 values(1);
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
delete from t1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
update t1 set a=1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
create table t1 (a int);
|
||||
select count(test.t1.b) from t1;
|
||||
ERROR 42S22: Unknown column 'test.t1.b' in 'field list'
|
||||
select count(not_existing_database.t1) from t1;
|
||||
ERROR 42S22: Unknown column 'not_existing_database.t1' in 'field list'
|
||||
select count(not_existing_database.t1.a) from t1;
|
||||
ERROR 42S22: Unknown column 'not_existing_database.t1.a' in 'field list'
|
||||
select count(not_existing_database.t1.a) from not_existing_database.t1;
|
||||
Got one of the listed errors
|
||||
select 1 from t1 order by 2;
|
||||
ERROR 42S22: Unknown column '2' in 'order clause'
|
||||
select 1 from t1 group by 2;
|
||||
ERROR 42S22: Unknown column '2' in 'group statement'
|
||||
select 1 from t1 order by t1.b;
|
||||
ERROR 42S22: Unknown column 't1.b' in 'order clause'
|
||||
select count(*),b from t1;
|
||||
ERROR 42S22: Unknown column 'b' in 'field list'
|
||||
drop table t1;
|
||||
create table t1 (a int(256));
|
||||
ERROR 42000: Display width out of range for column 'a' (max = 255)
|
||||
set sql_mode='traditional';
|
||||
create table t1 (a varchar(66000));
|
||||
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
|
||||
59
mysql-test/suite/pbxt/r/explain.result
Normal file
59
mysql-test/suite/pbxt/r/explain.result
Normal file
@@ -0,0 +1,59 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (id int not null, str char(10), unique(str));
|
||||
explain select * from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 0
|
||||
insert into t1 values (1, null),(2, null),(3, "foo"),(4, "bar");
|
||||
select * from t1 where str is null;
|
||||
id str
|
||||
1 NULL
|
||||
2 NULL
|
||||
select * from t1 where str="foo";
|
||||
id str
|
||||
3 foo
|
||||
explain select * from t1 where str is null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref str str 11 const 1 Using where
|
||||
explain select * from t1 where str="foo";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const str str 11 const 1
|
||||
explain select * from t1 ignore key (str) where str="foo";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
explain select * from t1 use key (str,str) where str="foo";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const str str 11 const 1
|
||||
explain select * from t1 use key (str,str,foo) where str="foo";
|
||||
ERROR 42000: Key 'foo' doesn't exist in table 't1'
|
||||
explain select * from t1 ignore key (str,str,foo) where str="foo";
|
||||
ERROR 42000: Key 'foo' doesn't exist in table 't1'
|
||||
drop table t1;
|
||||
explain select 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
create table t1 (a int not null);
|
||||
explain select count(*) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 0
|
||||
insert into t1 values(1);
|
||||
explain select count(*) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1
|
||||
insert into t1 values(1);
|
||||
explain select count(*) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
|
||||
drop table t1;
|
||||
set names koi8r;
|
||||
create table <20><><EFBFBD> (<28><><EFBFBD>0 int, <20><><EFBFBD>1 int, key <20><><EFBFBD>0 (<28><><EFBFBD>0), key <20><><EFBFBD>01 (<28><><EFBFBD>0,<2C><><EFBFBD>1));
|
||||
insert into <20><><EFBFBD> (<28><><EFBFBD>0) values (1);
|
||||
insert into <20><><EFBFBD> (<28><><EFBFBD>0) values (2);
|
||||
explain select <20><><EFBFBD>0 from <20><><EFBFBD> where <20><><EFBFBD>0=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE <09><><EFBFBD> ref <09><><EFBFBD>0,<2C><><EFBFBD>01 <09><><EFBFBD>0 5 const 1 Using where; Using index
|
||||
drop table <20><><EFBFBD>;
|
||||
set names latin1;
|
||||
select 3 into @v1;
|
||||
explain select 3 into @v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
57
mysql-test/suite/pbxt/r/flush.result
Normal file
57
mysql-test/suite/pbxt/r/flush.result
Normal file
@@ -0,0 +1,57 @@
|
||||
drop table if exists t1,t2;
|
||||
drop database if exists mysqltest;
|
||||
create temporary table t1(n int not null primary key);
|
||||
create table t2(n int);
|
||||
insert into t2 values(3);
|
||||
select * from t1;
|
||||
n
|
||||
3
|
||||
flush tables with read lock;
|
||||
drop table t2;
|
||||
ERROR HY000: Can't execute the query because you have a conflicting read lock
|
||||
drop table t2;
|
||||
unlock tables;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1(n int);
|
||||
insert into mysqltest.t1 values (23);
|
||||
flush tables with read lock;
|
||||
drop database mysqltest;
|
||||
select * from mysqltest.t1;
|
||||
n
|
||||
23
|
||||
unlock tables;
|
||||
create table t1 (n int);
|
||||
flush tables with read lock;
|
||||
insert into t1 values (345);
|
||||
select * from t1;
|
||||
n
|
||||
345
|
||||
drop table t1;
|
||||
create table t1 (c1 int);
|
||||
lock table t1 write;
|
||||
flush tables with read lock;
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
lock table t1 read;
|
||||
flush tables with read lock;
|
||||
lock table t1 write;
|
||||
ERROR HY000: Can't execute the query because you have a conflicting read lock
|
||||
lock table t1 read;
|
||||
lock table t1 write;
|
||||
ERROR HY000: Can't execute the query because you have a conflicting read lock
|
||||
unlock tables;
|
||||
create table t2 (c1 int);
|
||||
create table t3 (c1 int);
|
||||
lock table t1 read, t2 read, t3 write;
|
||||
flush tables with read lock;
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
lock table t1 read, t2 read, t3 read;
|
||||
flush tables with read lock;
|
||||
unlock tables;
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (c1 int);
|
||||
create table t2 (c1 int);
|
||||
lock table t1 write;
|
||||
flush tables with read lock;
|
||||
insert into t2 values(1);
|
||||
unlock tables;
|
||||
drop table t1, t2;
|
||||
12
mysql-test/suite/pbxt/r/flush_read_lock_kill.result
Normal file
12
mysql-test/suite/pbxt/r/flush_read_lock_kill.result
Normal file
@@ -0,0 +1,12 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (kill_id int);
|
||||
insert into t1 values(connection_id());
|
||||
select kill_id-kill_id from t1;
|
||||
kill_id-kill_id
|
||||
0
|
||||
flush tables with read lock;
|
||||
select ((@id := kill_id) - kill_id) from t1;
|
||||
((@id := kill_id) - kill_id)
|
||||
0
|
||||
kill connection @id;
|
||||
drop table t1;
|
||||
137
mysql-test/suite/pbxt/r/flush_table.result
Normal file
137
mysql-test/suite/pbxt/r/flush_table.result
Normal file
@@ -0,0 +1,137 @@
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (a int not null auto_increment primary key);
|
||||
insert into t1 values(0);
|
||||
lock table t1 read;
|
||||
flush table t1;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
unlock tables;
|
||||
lock table t1 read;
|
||||
lock table t1 read;
|
||||
flush table t1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
unlock tables;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
unlock tables;
|
||||
lock table t1 write;
|
||||
lock table t1 read;
|
||||
flush table t1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
unlock tables;
|
||||
unlock tables;
|
||||
lock table t1 read;
|
||||
lock table t1 write;
|
||||
flush table t1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
unlock tables;
|
||||
unlock tables;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
drop table t1;
|
||||
create table t1(table_id char(20) primary key);
|
||||
create table t2(table_id char(20) primary key);
|
||||
insert into t1 values ('test.t1');
|
||||
insert into t1 values ('');
|
||||
insert into t2 values ('test.t2');
|
||||
insert into t2 values ('');
|
||||
handler t1 open as a1;
|
||||
handler t1 open as a2;
|
||||
handler t2 open;
|
||||
handler a1 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler a2 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler t2 read first limit 9;
|
||||
table_id
|
||||
test.t2
|
||||
|
||||
flush tables;
|
||||
handler a1 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler a2 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler t2 read first limit 9;
|
||||
table_id
|
||||
test.t2
|
||||
|
||||
handler t1 open as a1;
|
||||
ERROR 42000: Not unique table/alias: 'a1'
|
||||
handler t1 open as a2;
|
||||
ERROR 42000: Not unique table/alias: 'a2'
|
||||
handler t2 open;
|
||||
ERROR 42000: Not unique table/alias: 't2'
|
||||
handler a1 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler a2 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler t2 read first limit 9;
|
||||
table_id
|
||||
test.t2
|
||||
|
||||
flush table t1;
|
||||
handler a1 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler a2 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler t2 read first limit 9;
|
||||
table_id
|
||||
test.t2
|
||||
|
||||
flush table t2;
|
||||
handler t2 close;
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
create table t1(table_id char(20) primary key);
|
||||
insert into t1 values ('Record-01');
|
||||
insert into t1 values ('Record-02');
|
||||
insert into t1 values ('Record-03');
|
||||
insert into t1 values ('Record-04');
|
||||
insert into t1 values ('Record-05');
|
||||
handler t1 open;
|
||||
handler t1 read first limit 1;
|
||||
table_id
|
||||
Record-01
|
||||
handler t1 read next limit 1;
|
||||
table_id
|
||||
Record-02
|
||||
handler t1 read next limit 1;
|
||||
table_id
|
||||
Record-03
|
||||
flush table t1;
|
||||
handler t1 read next limit 1;
|
||||
table_id
|
||||
Record-01
|
||||
handler t1 read next limit 1;
|
||||
table_id
|
||||
Record-02
|
||||
handler t1 close;
|
||||
drop table t1;
|
||||
FLUSH TABLES WITH READ LOCK ;
|
||||
FLUSH TABLES WITH READ LOCK ;
|
||||
UNLOCK TABLES;
|
||||
18
mysql-test/suite/pbxt/r/foreign_key.result
Normal file
18
mysql-test/suite/pbxt/r/foreign_key.result
Normal file
@@ -0,0 +1,18 @@
|
||||
drop table if exists t1;
|
||||
set foreign_key_checks = 0;
|
||||
create table t1 (
|
||||
a int not null references t2,
|
||||
b int not null references t2 (c),
|
||||
c int,
|
||||
primary key (a,b),
|
||||
foreign key (a) references t3 match full,
|
||||
foreign key (a) references t3 match partial,
|
||||
foreign key (a,b) references t3 (c,d) on delete no action
|
||||
on update no action,
|
||||
foreign key (a,b) references t3 (c,d) on update cascade,
|
||||
foreign key (a,b) references t3 (c,d) on delete set default,
|
||||
foreign key (c) references t3 (e) on update set null);
|
||||
create index a on t1 (a);
|
||||
create unique index b on t1 (a,b);
|
||||
drop table t1;
|
||||
set foreign_key_checks = 1;
|
||||
84
mysql-test/suite/pbxt/r/func_concat.result
Normal file
84
mysql-test/suite/pbxt/r/func_concat.result
Normal file
@@ -0,0 +1,84 @@
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 ( number INT NOT NULL, alpha CHAR(6) NOT NULL );
|
||||
INSERT INTO t1 VALUES (1413006,'idlfmv'),
|
||||
(1413065,'smpsfz'),(1413127,'sljrhx'),(1413304,'qerfnd');
|
||||
SELECT number, alpha, CONCAT_WS('<---->',number,alpha) AS new
|
||||
FROM t1 GROUP BY number;
|
||||
number alpha new
|
||||
1413006 idlfmv 1413006<---->idlfmv
|
||||
1413065 smpsfz 1413065<---->smpsfz
|
||||
1413127 sljrhx 1413127<---->sljrhx
|
||||
1413304 qerfnd 1413304<---->qerfnd
|
||||
SELECT CONCAT_WS('<---->',number,alpha) AS new
|
||||
FROM t1 GROUP BY new LIMIT 1;
|
||||
new
|
||||
1413006<---->idlfmv
|
||||
SELECT number, alpha, CONCAT_WS('<->',number,alpha) AS new
|
||||
FROM t1 GROUP BY new LIMIT 1;
|
||||
number alpha new
|
||||
1413006 idlfmv 1413006<->idlfmv
|
||||
SELECT number, alpha, CONCAT_WS('-',number,alpha,alpha,alpha,alpha,alpha,alpha,alpha) AS new
|
||||
FROM t1 GROUP BY new LIMIT 1;
|
||||
number alpha new
|
||||
1413006 idlfmv 1413006-idlfmv-idlfmv-idlfmv-idlfmv-idlfmv-idlfmv-idlfmv
|
||||
SELECT number, alpha, CONCAT_WS('<------------------>',number,alpha) AS new
|
||||
FROM t1 GROUP BY new LIMIT 1;
|
||||
number alpha new
|
||||
1413006 idlfmv 1413006<------------------>idlfmv
|
||||
drop table t1;
|
||||
create table t1 (a char(4), b double, c date, d tinyint(4));
|
||||
insert into t1 values ('AAAA', 105, '2003-03-01', 1);
|
||||
select * from t1 where concat(A,C,B,D) = 'AAAA2003-03-011051';
|
||||
a b c d
|
||||
AAAA 105 2003-03-01 1
|
||||
drop table t1;
|
||||
select 'a' union select concat('a', -4);
|
||||
a
|
||||
a
|
||||
a-4
|
||||
select 'a' union select concat('a', -4.5);
|
||||
a
|
||||
a
|
||||
a-4.5
|
||||
select 'a' union select concat('a', -(4 + 1));
|
||||
a
|
||||
a
|
||||
a-5
|
||||
select 'a' union select concat('a', 4 - 5);
|
||||
a
|
||||
a
|
||||
a-1
|
||||
select 'a' union select concat('a', -'3');
|
||||
a
|
||||
a
|
||||
a-3
|
||||
select 'a' union select concat('a', -concat('3',4));
|
||||
a
|
||||
a
|
||||
a-34
|
||||
select 'a' union select concat('a', -0);
|
||||
a
|
||||
a
|
||||
a0
|
||||
select 'a' union select concat('a', -0.0);
|
||||
a
|
||||
a
|
||||
a0.0
|
||||
select 'a' union select concat('a', -0.0000);
|
||||
a
|
||||
a
|
||||
a0.0000
|
||||
select concat((select x from (select 'a' as x) as t1 ),
|
||||
(select y from (select 'b' as y) as t2 )) from (select 1 union select 2 )
|
||||
as t3;
|
||||
concat((select x from (select 'a' as x) as t1 ),
|
||||
(select y from (select 'b' as y) as t2 ))
|
||||
ab
|
||||
ab
|
||||
create table t1(f1 varchar(6)) charset=utf8;
|
||||
insert into t1 values ("123456");
|
||||
select concat(f1, 2) a from t1 union select 'x' a from t1;
|
||||
a
|
||||
1234562
|
||||
x
|
||||
drop table t1;
|
||||
97
mysql-test/suite/pbxt/r/func_crypt.result
Normal file
97
mysql-test/suite/pbxt/r/func_crypt.result
Normal file
@@ -0,0 +1,97 @@
|
||||
drop table if exists t1;
|
||||
select length(encrypt('foo', 'ff')) <> 0;
|
||||
length(encrypt('foo', 'ff')) <> 0
|
||||
1
|
||||
create table t1 (name varchar(50), pw varchar(64));
|
||||
insert into t1 values ('tom', password('my_pass'));
|
||||
set @pass='my_pass';
|
||||
select name from t1 where name='tom' and pw=password(@pass);
|
||||
name
|
||||
tom
|
||||
select name from t1 where name='tom' and pw=password(@undefined);
|
||||
name
|
||||
drop table t1;
|
||||
select password('abc');
|
||||
password('abc')
|
||||
*0D3CED9BEC10A777AEC23CCC353A8C08A633045E
|
||||
select password('');
|
||||
password('')
|
||||
|
||||
select old_password('abc');
|
||||
old_password('abc')
|
||||
7cd2b5942be28759
|
||||
select old_password('');
|
||||
old_password('')
|
||||
|
||||
select password('gabbagabbahey');
|
||||
password('gabbagabbahey')
|
||||
*B0F99D2963660DD7E16B751EC9EE2F17B6A68FA6
|
||||
select old_password('idkfa');
|
||||
old_password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
select length(password('1'));
|
||||
length(password('1'))
|
||||
41
|
||||
select length(encrypt('test'));
|
||||
length(encrypt('test'))
|
||||
13
|
||||
select encrypt('test','aa');
|
||||
encrypt('test','aa')
|
||||
aaqPiZY5xR5l.
|
||||
select old_password(NULL);
|
||||
old_password(NULL)
|
||||
NULL
|
||||
select password(NULL);
|
||||
password(NULL)
|
||||
NULL
|
||||
set global old_passwords=on;
|
||||
select password('');
|
||||
password('')
|
||||
|
||||
select old_password('');
|
||||
old_password('')
|
||||
|
||||
select password('idkfa');
|
||||
password('idkfa')
|
||||
*B669C9DAC3AA6F2254B03CDEF8DFDD6B2D1054BA
|
||||
select old_password('idkfa');
|
||||
old_password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
set old_passwords=on;
|
||||
select password('idkfa');
|
||||
password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
select old_password('idkfa');
|
||||
old_password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
set global old_passwords=off;
|
||||
select password('idkfa');
|
||||
password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
select old_password('idkfa');
|
||||
old_password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
set old_passwords=off;
|
||||
select password('idkfa ');
|
||||
password('idkfa ')
|
||||
*2DC31D90647B4C1ABC9231563D2236E96C9A2DB2
|
||||
select password('idkfa');
|
||||
password('idkfa')
|
||||
*B669C9DAC3AA6F2254B03CDEF8DFDD6B2D1054BA
|
||||
select password(' idkfa');
|
||||
password(' idkfa')
|
||||
*12B099E56BB7FE8D43C78FD834A9D1D11178D045
|
||||
select old_password('idkfa');
|
||||
old_password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
select old_password(' i d k f a ');
|
||||
old_password(' i d k f a ')
|
||||
5c078dc54ca0fcca
|
||||
explain extended select password('idkfa '), old_password('idkfa');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select password('idkfa ') AS `password('idkfa ')`,old_password('idkfa') AS `old_password('idkfa')`
|
||||
select encrypt('1234','_.');
|
||||
encrypt('1234','_.')
|
||||
#
|
||||
87
mysql-test/suite/pbxt/r/func_date_add.result
Normal file
87
mysql-test/suite/pbxt/r/func_date_add.result
Normal file
@@ -0,0 +1,87 @@
|
||||
drop table if exists t1;
|
||||
CREATE TABLE t1 (
|
||||
visitor_id int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
group_id int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
hits int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
sessions int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
ts timestamp,
|
||||
PRIMARY KEY (visitor_id,group_id)
|
||||
)/*! engine=MyISAM */;
|
||||
INSERT INTO t1 VALUES (465931136,7,2,2,20000318160952);
|
||||
INSERT INTO t1 VALUES (173865424,2,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,8,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,39,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,7,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,3,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,6,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,60,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,1502,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (48985536,2,2,2,20000319013932);
|
||||
INSERT INTO t1 VALUES (48985536,8,2,2,20000319013932);
|
||||
INSERT INTO t1 VALUES (48985536,39,2,2,20000319013932);
|
||||
INSERT INTO t1 VALUES (48985536,7,2,2,20000319013932);
|
||||
INSERT INTO t1 VALUES (465931136,3,2,2,20000318160951);
|
||||
INSERT INTO t1 VALUES (465931136,119,1,1,20000318160953);
|
||||
INSERT INTO t1 VALUES (465931136,2,1,1,20000318160950);
|
||||
INSERT INTO t1 VALUES (465931136,8,1,1,20000318160950);
|
||||
INSERT INTO t1 VALUES (465931136,39,1,1,20000318160950);
|
||||
INSERT INTO t1 VALUES (1092858576,14,1,1,20000319013445);
|
||||
INSERT INTO t1 VALUES (357917728,3,2,2,20000319145026);
|
||||
INSERT INTO t1 VALUES (357917728,7,2,2,20000319145027);
|
||||
select visitor_id,max(ts) as mts from t1 group by visitor_id
|
||||
having mts < DATE_SUB(NOW(),INTERVAL 3 MONTH);
|
||||
visitor_id mts
|
||||
48985536 2000-03-19 01:39:32
|
||||
173865424 2000-03-18 23:36:15
|
||||
357917728 2000-03-19 14:50:27
|
||||
465931136 2000-03-18 16:09:53
|
||||
1092858576 2000-03-19 01:34:45
|
||||
select visitor_id,max(ts) as mts from t1 group by visitor_id
|
||||
having DATE_ADD(mts,INTERVAL 3 MONTH) < NOW();
|
||||
visitor_id mts
|
||||
48985536 2000-03-19 01:39:32
|
||||
173865424 2000-03-18 23:36:15
|
||||
357917728 2000-03-19 14:50:27
|
||||
465931136 2000-03-18 16:09:53
|
||||
1092858576 2000-03-19 01:34:45
|
||||
drop table t1;
|
||||
set sql_mode='traditional';
|
||||
create table t1 (d date);
|
||||
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
|
||||
ERROR 22008: Datetime function: datetime field overflow
|
||||
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
|
||||
ERROR 22008: Datetime function: datetime field overflow
|
||||
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
|
||||
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
|
||||
set sql_mode='';
|
||||
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
|
||||
Warnings:
|
||||
Warning 1441 Datetime function: datetime field overflow
|
||||
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
|
||||
Warnings:
|
||||
Warning 1441 Datetime function: datetime field overflow
|
||||
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
|
||||
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
|
||||
select * from t1;
|
||||
d
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
drop table t1;
|
||||
End of 4.1 tests
|
||||
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 DAY;
|
||||
CAST('2006-09-26' AS DATE) + INTERVAL 1 DAY
|
||||
2006-09-27
|
||||
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 MONTH;
|
||||
CAST('2006-09-26' AS DATE) + INTERVAL 1 MONTH
|
||||
2006-10-26
|
||||
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 YEAR;
|
||||
CAST('2006-09-26' AS DATE) + INTERVAL 1 YEAR
|
||||
2007-09-26
|
||||
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 WEEK;
|
||||
CAST('2006-09-26' AS DATE) + INTERVAL 1 WEEK
|
||||
2006-10-03
|
||||
End of 5.0 tests
|
||||
23
mysql-test/suite/pbxt/r/func_default.result
Normal file
23
mysql-test/suite/pbxt/r/func_default.result
Normal file
@@ -0,0 +1,23 @@
|
||||
drop table if exists t1,t2;
|
||||
create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14');
|
||||
insert into t1 values ('','',0,0.0);
|
||||
select default(str), default(strnull), default(intg), default(rel) from t1;
|
||||
default(str) default(strnull) default(intg) default(rel)
|
||||
def NULL 10 3.14
|
||||
explain extended select default(str), default(strnull), default(intg), default(rel) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select default(`test`.`t1`.`str`) AS `default(str)`,default(`test`.`t1`.`strnull`) AS `default(strnull)`,default(`test`.`t1`.`intg`) AS `default(intg)`,default(`test`.`t1`.`rel`) AS `default(rel)` from `test`.`t1`
|
||||
select * from t1 where str <> default(str);
|
||||
str strnull intg rel
|
||||
0 0
|
||||
explain select * from t1 where str <> default(str);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (id int(11), s varchar(20));
|
||||
INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three');
|
||||
SELECT s, 32 AS mi FROM t1 GROUP BY s HAVING DEFAULT(mi) IS NULL;
|
||||
ERROR HY000: Field 'mi' doesn't have a default value
|
||||
DROP TABLE t1;
|
||||
44
mysql-test/suite/pbxt/r/func_equal.result
Normal file
44
mysql-test/suite/pbxt/r/func_equal.result
Normal file
@@ -0,0 +1,44 @@
|
||||
drop table if exists t1,t2;
|
||||
select 0<=>0,0.0<=>0.0,0E0=0E0,"A"<=>"A",NULL<=>NULL;
|
||||
0<=>0 0.0<=>0.0 0E0=0E0 "A"<=>"A" NULL<=>NULL
|
||||
1 1 1 1 1
|
||||
select 1<=>0,0<=>NULL,NULL<=>0;
|
||||
1<=>0 0<=>NULL NULL<=>0
|
||||
0 0 0
|
||||
select 1.0<=>0.0,0.0<=>NULL,NULL<=>0.0;
|
||||
1.0<=>0.0 0.0<=>NULL NULL<=>0.0
|
||||
0 0 0
|
||||
select "A"<=>"B","A"<=>NULL,NULL<=>"A";
|
||||
"A"<=>"B" "A"<=>NULL NULL<=>"A"
|
||||
0 0 0
|
||||
select 0<=>0.0, 0.0<=>0E0, 0E0<=>"0", 10.0<=>1E1, 10<=>10.0, 10<=>1E1;
|
||||
0<=>0.0 0.0<=>0E0 0E0<=>"0" 10.0<=>1E1 10<=>10.0 10<=>1E1
|
||||
1 1 1 1 1 1
|
||||
select 1.0<=>0E1,10<=>NULL,NULL<=>0.0, NULL<=>0E0;
|
||||
1.0<=>0E1 10<=>NULL NULL<=>0.0 NULL<=>0E0
|
||||
0 0 0 0
|
||||
create table t1 (id int, value int);
|
||||
create table t2 (id int, value int);
|
||||
insert into t1 values (1,null);
|
||||
insert into t2 values (1,null);
|
||||
select t1.*, t2.*, t1.value<=>t2.value from t1, t2 where t1.id=t2.id and t1.id=1;
|
||||
id value id value t1.value<=>t2.value
|
||||
1 NULL 1 NULL 1
|
||||
select * from t1 where id <=>id;
|
||||
id value
|
||||
1 NULL
|
||||
select * from t1 where value <=> value;
|
||||
id value
|
||||
1 NULL
|
||||
select * from t1 where id <=> value or value<=>id;
|
||||
id value
|
||||
drop table t1,t2;
|
||||
create table t1 (a bigint unsigned);
|
||||
insert into t1 values (4828532208463511553);
|
||||
select * from t1 where a = '4828532208463511553';
|
||||
a
|
||||
4828532208463511553
|
||||
select * from t1 where a in ('4828532208463511553');
|
||||
a
|
||||
4828532208463511553
|
||||
drop table t1;
|
||||
736
mysql-test/suite/pbxt/r/func_gconcat.result
Normal file
736
mysql-test/suite/pbxt/r/func_gconcat.result
Normal file
@@ -0,0 +1,736 @@
|
||||
drop table if exists t1, t2;
|
||||
create table t1 (grp int, a bigint unsigned, c char(10) not null, d char(10) not null);
|
||||
insert into t1 values (1,1,"a","a");
|
||||
insert into t1 values (2,2,"b","a");
|
||||
insert into t1 values (2,3,"c","b");
|
||||
insert into t1 values (3,4,"E","a");
|
||||
insert into t1 values (3,5,"C","b");
|
||||
insert into t1 values (3,6,"D","b");
|
||||
insert into t1 values (3,7,"d","d");
|
||||
insert into t1 values (3,8,"d","d");
|
||||
insert into t1 values (3,9,"D","c");
|
||||
select grp,group_concat(c) from t1 group by grp;
|
||||
grp group_concat(c)
|
||||
1 a
|
||||
2 b,c
|
||||
3 E,C,D,d,d,D
|
||||
explain extended select grp,group_concat(c) from t1 group by grp;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 100.00 Using filesort
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`grp` AS `grp`,group_concat(`test`.`t1`.`c` separator ',') AS `group_concat(c)` from `test`.`t1` group by `test`.`t1`.`grp`
|
||||
select grp,group_concat(a,c) from t1 group by grp;
|
||||
grp group_concat(a,c)
|
||||
1 1a
|
||||
2 2b,3c
|
||||
3 4E,5C,6D,7d,8d,9D
|
||||
select grp,group_concat("(",a,":",c,")") from t1 group by grp;
|
||||
grp group_concat("(",a,":",c,")")
|
||||
1 (1:a)
|
||||
2 (2:b),(3:c)
|
||||
3 (4:E),(5:C),(6:D),(7:d),(8:d),(9:D)
|
||||
select grp,group_concat(c separator ",") from t1 group by grp;
|
||||
grp group_concat(c separator ",")
|
||||
1 a
|
||||
2 b,c
|
||||
3 E,C,D,d,d,D
|
||||
select grp,group_concat(c separator "---->") from t1 group by grp;
|
||||
grp group_concat(c separator "---->")
|
||||
1 a
|
||||
2 b---->c
|
||||
3 E---->C---->D---->d---->d---->D
|
||||
select grp,group_concat(c order by c) from t1 group by grp;
|
||||
grp group_concat(c order by c)
|
||||
1 a
|
||||
2 b,c
|
||||
3 C,D,d,d,D,E
|
||||
select grp,group_concat(c order by c desc) from t1 group by grp;
|
||||
grp group_concat(c order by c desc)
|
||||
1 a
|
||||
2 c,b
|
||||
3 E,D,d,d,D,C
|
||||
select grp,group_concat(d order by a) from t1 group by grp;
|
||||
grp group_concat(d order by a)
|
||||
1 a
|
||||
2 a,b
|
||||
3 a,b,b,d,d,c
|
||||
select grp,group_concat(d order by a desc) from t1 group by grp;
|
||||
grp group_concat(d order by a desc)
|
||||
1 a
|
||||
2 b,a
|
||||
3 c,d,d,b,b,a
|
||||
select grp,group_concat(a order by a,d+c-ascii(c)-a) from t1 group by grp;
|
||||
grp group_concat(a order by a,d+c-ascii(c)-a)
|
||||
1 1
|
||||
2 2,3
|
||||
3 4,5,6,7,8,9
|
||||
select grp,group_concat(a order by d+c-ascii(c),a) from t1 group by grp;
|
||||
grp group_concat(a order by d+c-ascii(c),a)
|
||||
1 1
|
||||
2 3,2
|
||||
3 7,8,4,6,9,5
|
||||
select grp,group_concat(c order by 1) from t1 group by grp;
|
||||
grp group_concat(c order by 1)
|
||||
1 a
|
||||
2 b,c
|
||||
3 C,D,d,d,D,E
|
||||
select grp,group_concat(distinct c order by c) from t1 group by grp;
|
||||
grp group_concat(distinct c order by c)
|
||||
1 a
|
||||
2 b,c
|
||||
3 C,D,E
|
||||
select grp,group_concat(distinct c order by c desc) from t1 group by grp;
|
||||
grp group_concat(distinct c order by c desc)
|
||||
1 a
|
||||
2 c,b
|
||||
3 E,D,C
|
||||
explain extended select grp,group_concat(distinct c order by c desc) from t1 group by grp;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 100.00 Using filesort
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`grp` AS `grp`,group_concat(distinct `test`.`t1`.`c` order by `test`.`t1`.`c` DESC separator ',') AS `group_concat(distinct c order by c desc)` from `test`.`t1` group by `test`.`t1`.`grp`
|
||||
select grp,group_concat(c order by c separator ",") from t1 group by grp;
|
||||
grp group_concat(c order by c separator ",")
|
||||
1 a
|
||||
2 b,c
|
||||
3 C,D,d,d,D,E
|
||||
select grp,group_concat(c order by c desc separator ",") from t1 group by grp;
|
||||
grp group_concat(c order by c desc separator ",")
|
||||
1 a
|
||||
2 c,b
|
||||
3 E,D,d,d,D,C
|
||||
select grp,group_concat(distinct c order by c separator ",") from t1 group by grp;
|
||||
grp group_concat(distinct c order by c separator ",")
|
||||
1 a
|
||||
2 b,c
|
||||
3 C,D,E
|
||||
explain extended select grp,group_concat(distinct c order by c separator ",") from t1 group by grp;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 100.00 Using filesort
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`grp` AS `grp`,group_concat(distinct `test`.`t1`.`c` order by `test`.`t1`.`c` ASC separator ',') AS `group_concat(distinct c order by c separator ",")` from `test`.`t1` group by `test`.`t1`.`grp`
|
||||
select grp,group_concat(distinct c order by c desc separator ",") from t1 group by grp;
|
||||
grp group_concat(distinct c order by c desc separator ",")
|
||||
1 a
|
||||
2 c,b
|
||||
3 E,D,C
|
||||
select grp,group_concat(c order by grp desc) from t1 group by grp order by grp;
|
||||
grp group_concat(c order by grp desc)
|
||||
1 a
|
||||
2 c,b
|
||||
3 D,d,d,D,C,E
|
||||
select grp, group_concat(a separator "")+0 from t1 group by grp;
|
||||
grp group_concat(a separator "")+0
|
||||
1 1
|
||||
2 23
|
||||
3 456789
|
||||
select grp, group_concat(a separator "")+0.0 from t1 group by grp;
|
||||
grp group_concat(a separator "")+0.0
|
||||
1 1.0
|
||||
2 23.0
|
||||
3 456789.0
|
||||
select grp, ROUND(group_concat(a separator "")) from t1 group by grp;
|
||||
grp ROUND(group_concat(a separator ""))
|
||||
1 1
|
||||
2 23
|
||||
3 456789
|
||||
drop table t1;
|
||||
create table t1 (grp int, c char(10));
|
||||
insert into t1 values (1,NULL),(2,"b"),(2,NULL),(3,"E"),(3,NULL),(3,"D"),(3,NULL),(3,NULL),(3,"D"),(4,""),(5,NULL);
|
||||
select grp,group_concat(c order by c) from t1 group by grp;
|
||||
grp group_concat(c order by c)
|
||||
1 NULL
|
||||
2 b
|
||||
3 D,D,E
|
||||
4
|
||||
5 NULL
|
||||
set group_concat_max_len = 4;
|
||||
select grp,group_concat(c) from t1 group by grp;
|
||||
grp group_concat(c)
|
||||
1 NULL
|
||||
2 b
|
||||
3 E,D,
|
||||
4
|
||||
5 NULL
|
||||
Warnings:
|
||||
Warning 1260 1 line(s) were cut by GROUP_CONCAT()
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 1260 1 line(s) were cut by GROUP_CONCAT()
|
||||
set group_concat_max_len = 1024;
|
||||
select group_concat(sum(c)) from t1 group by grp;
|
||||
ERROR HY000: Invalid use of group function
|
||||
select grp,group_concat(c order by 2) from t1 group by grp;
|
||||
ERROR 42S22: Unknown column '2' in 'order clause'
|
||||
drop table t1;
|
||||
create table t1 ( URL_ID int(11), URL varchar(80));
|
||||
create table t2 ( REQ_ID int(11), URL_ID int(11));
|
||||
insert into t1 values (4,'www.host.com'), (5,'www.google.com'),(5,'www.help.com');
|
||||
insert into t2 values (1,4), (5,4), (5,5);
|
||||
select REQ_ID, Group_Concat(URL) as URL from t1, t2 where
|
||||
t2.URL_ID = t1.URL_ID group by REQ_ID;
|
||||
REQ_ID URL
|
||||
1 X
|
||||
5 X,X,X
|
||||
select REQ_ID, Group_Concat(URL) as URL, Min(t1.URL_ID) urll,
|
||||
Max(t1.URL_ID) urlg from t1, t2 where t2.URL_ID = t1.URL_ID group by REQ_ID;
|
||||
REQ_ID URL urll urlg
|
||||
1 X 4 4
|
||||
5 X,X,X 4 5
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
create table t1 (id int, name varchar(16));
|
||||
insert into t1 values (1,'longername'),(1,'evenlongername');
|
||||
select ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'without distinct: how it should be' from t1;
|
||||
without distinct: how it should be
|
||||
1:longername,1:evenlongername
|
||||
select distinct ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'with distinct: cutoff at length of shortname' from t1;
|
||||
with distinct: cutoff at length of shortname
|
||||
1:longername,1:evenlongername
|
||||
drop table t1;
|
||||
create table t1(id int);
|
||||
create table t2(id int);
|
||||
insert into t1 values(0),(1);
|
||||
select group_concat(t1.id) FROM t1,t2;
|
||||
group_concat(t1.id)
|
||||
NULL
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
create table t1 (bar varchar(32));
|
||||
insert into t1 values('test1'),('test2');
|
||||
select group_concat(bar order by concat(bar,bar)) from t1;
|
||||
group_concat(bar order by concat(bar,bar))
|
||||
test1,test2
|
||||
select group_concat(bar order by concat(bar,bar) desc) from t1;
|
||||
group_concat(bar order by concat(bar,bar) desc)
|
||||
test2,test1
|
||||
select bar from t1 having group_concat(bar)='';
|
||||
bar
|
||||
select bar from t1 having instr(group_concat(bar), "test") > 0;
|
||||
bar
|
||||
test1
|
||||
select bar from t1 having instr(group_concat(bar order by concat(bar,bar) desc), "test2,test1") > 0;
|
||||
bar
|
||||
test1
|
||||
drop table t1;
|
||||
create table t1 (a int, a1 varchar(10));
|
||||
create table t2 (a0 int);
|
||||
insert into t1 values (0,"a"),(0,"b"),(1,"c");
|
||||
insert into t2 values (1),(2),(3);
|
||||
select group_concat(a1 order by (t1.a IN (select a0 from t2))) from t1;
|
||||
group_concat(a1 order by (t1.a IN (select a0 from t2)))
|
||||
b,a,c
|
||||
select group_concat(a1 order by (t1.a)) from t1;
|
||||
group_concat(a1 order by (t1.a))
|
||||
b,a,c
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1 (id1 tinyint(4) NOT NULL, id2 tinyint(4) NOT NULL);
|
||||
INSERT INTO t1 VALUES (1, 1),(1, 2),(1, 3),(1, 4),(1, 5),(2, 1),(2, 2),(2, 3);
|
||||
CREATE TABLE t2 (id1 tinyint(4) NOT NULL);
|
||||
INSERT INTO t2 VALUES (1),(2),(3),(4),(5);
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2 ORDER BY t1.id2 ASC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 AND t1.id1=1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 1,2,3,4,5
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2 ORDER BY t1.id2 ASC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 1,2,3,4,5
|
||||
2 1,2,3
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2 ORDER BY t1.id2 DESC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 5,4,3,2,1
|
||||
2 3,2,1
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2 ORDER BY 6-t1.id2 ASC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 5,4,3,2,1
|
||||
2 3,2,1
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2,6-t1.id2 ORDER BY 6-t1.id2 ASC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 51,42,33,24,15
|
||||
2 33,24,15
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2,6-t1.id2 ORDER BY 6-t1.id2 ASC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 51,42,33,24,15
|
||||
2 33,24,15
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2,"/",6-t1.id2 ORDER BY 1+0,6-t1.id2,t1.id2 ASC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 5/1,4/2,3/3,2/4,1/5
|
||||
2 3/3,2/4,1/5
|
||||
drop table t1,t2;
|
||||
create table t1 (s1 char(10), s2 int not null);
|
||||
insert into t1 values ('a',2),('b',2),('c',1),('a',3),('b',4),('c',4);
|
||||
select distinct s1 from t1 order by s2,s1;
|
||||
s1
|
||||
c
|
||||
a
|
||||
b
|
||||
select group_concat(distinct s1) from t1;
|
||||
group_concat(distinct s1)
|
||||
a,b,c
|
||||
select group_concat(distinct s1 order by s2) from t1 where s2 < 4;
|
||||
group_concat(distinct s1 order by s2)
|
||||
c,b,a
|
||||
select group_concat(distinct s1 order by s2) from t1;
|
||||
group_concat(distinct s1 order by s2)
|
||||
c,b,a
|
||||
drop table t1;
|
||||
create table t1 (a int, c int);
|
||||
insert into t1 values (1, 2), (2, 3), (2, 4), (3, 5);
|
||||
create table t2 (a int, c int);
|
||||
insert into t2 values (1, 5), (2, 4), (3, 3), (3,3);
|
||||
select group_concat(c) from t1;
|
||||
group_concat(c)
|
||||
2,3,4,5
|
||||
select group_concat(c order by (select c from t2 where t2.a=t1.a limit 1)) as grp from t1;
|
||||
grp
|
||||
5,4,3,2
|
||||
select group_concat(c order by (select mid(group_concat(c order by a),1,5) from t2 where t2.a=t1.a)) as grp from t1;
|
||||
grp
|
||||
5,4,3,2
|
||||
select group_concat(c order by (select mid(group_concat(c order by a),1,5) from t2 where t2.a=t1.a) desc) as grp from t1;
|
||||
grp
|
||||
2,4,3,5
|
||||
select t1.a, group_concat(c order by (select c from t2 where t2.a=t1.a limit 1)) as grp from t1 group by 1;
|
||||
a grp
|
||||
1 2
|
||||
2 4,3
|
||||
3 5
|
||||
select t1.a, group_concat(c order by (select mid(group_concat(c order by a),1,5) from t2 where t2.a=t1.a)) as grp from t1 group by 1;
|
||||
a grp
|
||||
1 2
|
||||
2 4,3
|
||||
3 5
|
||||
select t1.a, group_concat(c order by (select mid(group_concat(c order by a),1,5) from t2 where t2.a=t1.a) desc) as grp from t1 group by 1;
|
||||
a grp
|
||||
1 2
|
||||
2 4,3
|
||||
3 5
|
||||
select group_concat(c order by (select concat(5-t1.c,group_concat(c order by a)) from t2 where t2.a=t1.a)) as grp from t1;
|
||||
grp
|
||||
5,4,3,2
|
||||
select group_concat(c order by (select concat(t1.c,group_concat(c)) from t2 where a=t1.a)) as grp from t1;
|
||||
grp
|
||||
2,3,4,5
|
||||
select a,c,(select group_concat(c order by a) from t2 where a=t1.a) as grp from t1 order by grp;
|
||||
a c grp
|
||||
3 5 3,3
|
||||
2 3 4
|
||||
2 4 4
|
||||
1 2 5
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 ( a int );
|
||||
CREATE TABLE t2 ( a int );
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
INSERT INTO t2 VALUES (1), (2);
|
||||
SELECT GROUP_CONCAT(t1.a*t2.a ORDER BY t2.a) FROM t1, t2 GROUP BY t1.a;
|
||||
GROUP_CONCAT(t1.a*t2.a ORDER BY t2.a)
|
||||
1,2
|
||||
2,4
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1 (a char(4));
|
||||
INSERT INTO t1 VALUES ('John'), ('Anna'), ('Bill');
|
||||
SELECT GROUP_CONCAT(a SEPARATOR '||') AS names FROM t1
|
||||
HAVING names LIKE '%An%';
|
||||
names
|
||||
John||Anna||Bill
|
||||
SELECT GROUP_CONCAT(a SEPARATOR '###') AS names FROM t1
|
||||
HAVING LEFT(names, 1) ='J';
|
||||
names
|
||||
John###Anna###Bill
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 ( a int, b TEXT );
|
||||
INSERT INTO t1 VALUES (1,'First Row'), (2,'Second Row');
|
||||
SELECT GROUP_CONCAT(b ORDER BY b) FROM t1 GROUP BY a;
|
||||
GROUP_CONCAT(b ORDER BY b)
|
||||
First Row
|
||||
Second Row
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (A_ID INT NOT NULL,A_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID));
|
||||
INSERT INTO t1 VALUES (1,'ABC'), (2,'EFG'), (3,'HIJ');
|
||||
CREATE TABLE t2 (A_ID INT NOT NULL,B_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID,B_DESC));
|
||||
INSERT INTO t2 VALUES (1,'A'),(1,'B'),(3,'F');
|
||||
SELECT t1.A_ID, GROUP_CONCAT(t2.B_DESC) AS B_DESC FROM t1 LEFT JOIN t2 ON t1.A_ID=t2.A_ID GROUP BY t1.A_ID ORDER BY t1.A_DESC;
|
||||
A_ID B_DESC
|
||||
1 A,B
|
||||
2 NULL
|
||||
3 F
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
create table t1 (a int, b text);
|
||||
insert into t1 values (1, 'bb'), (1, 'ccc'), (1, 'a'), (1, 'bb'), (1, 'ccc');
|
||||
insert into t1 values (2, 'BB'), (2, 'CCC'), (2, 'A'), (2, 'BB'), (2, 'CCC');
|
||||
select group_concat(b) from t1 group by a;
|
||||
group_concat(b)
|
||||
bb,ccc,a,bb,ccc
|
||||
BB,CCC,A,BB,CCC
|
||||
select group_concat(distinct b) from t1 group by a;
|
||||
group_concat(distinct b)
|
||||
bb,ccc,a
|
||||
BB,CCC,A
|
||||
select group_concat(b order by b) from t1 group by a;
|
||||
group_concat(b order by b)
|
||||
a,bb,bb,ccc,ccc
|
||||
A,BB,BB,CCC,CCC
|
||||
select group_concat(distinct b order by b) from t1 group by a;
|
||||
group_concat(distinct b order by b)
|
||||
a,bb,ccc
|
||||
A,BB,CCC
|
||||
set local group_concat_max_len=4;
|
||||
select group_concat(b) from t1 group by a;
|
||||
group_concat(b)
|
||||
bb,c
|
||||
BB,C
|
||||
Warnings:
|
||||
Warning 1260 2 line(s) were cut by GROUP_CONCAT()
|
||||
select group_concat(distinct b) from t1 group by a;
|
||||
group_concat(distinct b)
|
||||
bb,c
|
||||
BB,C
|
||||
Warnings:
|
||||
Warning 1260 2 line(s) were cut by GROUP_CONCAT()
|
||||
select group_concat(b order by b) from t1 group by a;
|
||||
group_concat(b order by b)
|
||||
a,bb
|
||||
A,BB
|
||||
Warnings:
|
||||
Warning 1260 2 line(s) were cut by GROUP_CONCAT()
|
||||
select group_concat(distinct b order by b) from t1 group by a;
|
||||
group_concat(distinct b order by b)
|
||||
a,bb
|
||||
A,BB
|
||||
Warnings:
|
||||
Warning 1260 2 line(s) were cut by GROUP_CONCAT()
|
||||
insert into t1 values (1, concat(repeat('1', 300), '2')),
|
||||
(1, concat(repeat('1', 300), '2')), (1, concat(repeat('0', 300), '1')),
|
||||
(2, concat(repeat('1', 300), '2')), (2, concat(repeat('1', 300), '2')),
|
||||
(2, concat(repeat('0', 300), '1'));
|
||||
set local group_concat_max_len=1024;
|
||||
select group_concat(b) from t1 group by a;
|
||||
group_concat(b)
|
||||
bb,ccc,a,bb,ccc,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
|
||||
BB,CCC,A,BB,CCC,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
|
||||
select group_concat(distinct b) from t1 group by a;
|
||||
group_concat(distinct b)
|
||||
bb,ccc,a,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
|
||||
BB,CCC,A,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
|
||||
select group_concat(b order by b) from t1 group by a;
|
||||
group_concat(b order by b)
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,a,bb,bb,ccc,ccc
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,A,BB,BB,CCC,CCC
|
||||
select group_concat(distinct b order by b) from t1 group by a;
|
||||
group_concat(distinct b order by b)
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,a,bb,ccc
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,A,BB,CCC
|
||||
set local group_concat_max_len=400;
|
||||
select group_concat(b) from t1 group by a;
|
||||
group_concat(b)
|
||||
bb,ccc,a,bb,ccc,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||
BB,CCC,A,BB,CCC,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||
Warnings:
|
||||
Warning 1260 2 line(s) were cut by GROUP_CONCAT()
|
||||
select group_concat(distinct b) from t1 group by a;
|
||||
group_concat(distinct b)
|
||||
bb,ccc,a,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
BB,CCC,A,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
Warnings:
|
||||
Warning 1260 2 line(s) were cut by GROUP_CONCAT()
|
||||
select group_concat(b order by b) from t1 group by a;
|
||||
group_concat(b order by b)
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||
Warnings:
|
||||
Warning 1260 2 line(s) were cut by GROUP_CONCAT()
|
||||
select group_concat(distinct b order by b) from t1 group by a;
|
||||
group_concat(distinct b order by b)
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||
Warnings:
|
||||
Warning 1260 2 line(s) were cut by GROUP_CONCAT()
|
||||
drop table t1;
|
||||
create table t1 (a varchar(255) character set cp1250 collate cp1250_general_ci,
|
||||
b varchar(255) character set koi8r);
|
||||
insert into t1 values ('xxx','yyy');
|
||||
select collation(a) from t1;
|
||||
collation(a)
|
||||
cp1250_general_ci
|
||||
select collation(group_concat(a)) from t1;
|
||||
collation(group_concat(a))
|
||||
cp1250_general_ci
|
||||
create table t2 select group_concat(a) as a from t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` varchar(400) CHARACTER SET cp1250 DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
select collation(group_concat(a,_koi8r'test')) from t1;
|
||||
collation(group_concat(a,_koi8r'test'))
|
||||
cp1250_general_ci
|
||||
select collation(group_concat(a,_koi8r 0xC1C2)) from t1;
|
||||
ERROR HY000: Illegal mix of collations (cp1250_general_ci,IMPLICIT) and (koi8r_general_ci,COERCIBLE) for operation 'group_concat'
|
||||
select collation(group_concat(a,b)) from t1;
|
||||
ERROR HY000: Illegal mix of collations (cp1250_general_ci,IMPLICIT) and (koi8r_general_ci,IMPLICIT) for operation 'group_concat'
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
CREATE TABLE t1 (a CHAR(10) CHARACTER SET cp850);
|
||||
INSERT INTO t1 VALUES ('<27>');
|
||||
SELECT a FROM t1;
|
||||
a
|
||||
<EFBFBD>
|
||||
SELECT GROUP_CONCAT(a) FROM t1;
|
||||
GROUP_CONCAT(a)
|
||||
<EFBFBD>
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (id int);
|
||||
SELECT GROUP_CONCAT(id) AS gc FROM t1 HAVING gc IS NULL;
|
||||
gc
|
||||
NULL
|
||||
DROP TABLE t1;
|
||||
create table t2 (a int, b int);
|
||||
insert into t2 values (1,1), (2,2);
|
||||
select b x, (select group_concat(x) from t2) from t2;
|
||||
x (select group_concat(x) from t2)
|
||||
1 1,1
|
||||
2 2,2
|
||||
drop table t2;
|
||||
create table t1 (d int not null auto_increment,primary key(d), a int, b int, c int);
|
||||
insert into t1(a,b) values (1,3), (1,4), (1,2), (2,7), (1,1), (1,2), (2,3), (2,3);
|
||||
select d,a,b from t1 order by a;
|
||||
d a b
|
||||
1 1 3
|
||||
2 1 4
|
||||
3 1 2
|
||||
5 1 1
|
||||
6 1 2
|
||||
4 2 7
|
||||
7 2 3
|
||||
8 2 3
|
||||
explain select a, group_concat(b) from t1 group by a with rollup;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using filesort
|
||||
select a, group_concat(b) from t1 group by a with rollup;
|
||||
a group_concat(b)
|
||||
1 3,4,2,1,2
|
||||
2 7,3,3
|
||||
NULL 3,4,2,1,2,7,3,3
|
||||
select a, group_concat(distinct b) from t1 group by a with rollup;
|
||||
a group_concat(distinct b)
|
||||
1 3,4,2,1
|
||||
2 7,3
|
||||
NULL 3,4,2,1,7
|
||||
select a, group_concat(b order by b) from t1 group by a with rollup;
|
||||
a group_concat(b order by b)
|
||||
1 1,2,2,3,4
|
||||
2 3,3,7
|
||||
NULL 1,2,2,3,3,3,4,7
|
||||
select a, group_concat(distinct b order by b) from t1 group by a with rollup;
|
||||
a group_concat(distinct b order by b)
|
||||
1 1,2,3,4
|
||||
2 3,7
|
||||
NULL 1,2,3,4,7
|
||||
drop table t1;
|
||||
create table t1 (a char(3), b char(20), primary key (a, b));
|
||||
insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English');
|
||||
select group_concat(a) from t1 group by b;
|
||||
group_concat(a)
|
||||
ABW
|
||||
ABW
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
aID smallint(5) unsigned NOT NULL auto_increment,
|
||||
sometitle varchar(255) NOT NULL default '',
|
||||
bID smallint(5) unsigned NOT NULL,
|
||||
PRIMARY KEY (aID),
|
||||
UNIQUE KEY sometitle (sometitle)
|
||||
);
|
||||
INSERT INTO t1 SET sometitle = 'title1', bID = 1;
|
||||
INSERT INTO t1 SET sometitle = 'title2', bID = 1;
|
||||
CREATE TABLE t2 (
|
||||
bID smallint(5) unsigned NOT NULL auto_increment,
|
||||
somename varchar(255) NOT NULL default '',
|
||||
PRIMARY KEY (bID),
|
||||
UNIQUE KEY somename (somename)
|
||||
);
|
||||
INSERT INTO t2 SET somename = 'test';
|
||||
SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
|
||||
FROM t1 JOIN t2 ON t1.bID = t2.bID;
|
||||
COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
|
||||
2 test
|
||||
INSERT INTO t2 SET somename = 'test2';
|
||||
SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
|
||||
FROM t1 JOIN t2 ON t1.bID = t2.bID;
|
||||
COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
|
||||
2 test
|
||||
DELETE FROM t2 WHERE somename = 'test2';
|
||||
SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
|
||||
FROM t1 JOIN t2 ON t1.bID = t2.bID;
|
||||
COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
|
||||
2 test
|
||||
DROP TABLE t1,t2;
|
||||
select * from (select group_concat('c') from DUAL) t;
|
||||
group_concat('c')
|
||||
c
|
||||
create table t1 ( a int not null default 0);
|
||||
select * from (select group_concat(a) from t1) t2;
|
||||
group_concat(a)
|
||||
NULL
|
||||
select group_concat('x') UNION ALL select 1;
|
||||
group_concat('x')
|
||||
x
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (id int, a varchar(9));
|
||||
INSERT INTO t1 VALUES
|
||||
(2, ''), (1, ''), (2, 'x'), (1, 'y'), (3, 'z'), (3, '');
|
||||
SELECT GROUP_CONCAT(a) FROM t1;
|
||||
GROUP_CONCAT(a)
|
||||
,,x,y,z,
|
||||
SELECT GROUP_CONCAT(a ORDER BY a) FROM t1;
|
||||
GROUP_CONCAT(a ORDER BY a)
|
||||
,,,x,y,z
|
||||
SELECT GROUP_CONCAT(a) FROM t1 GROUP BY id;
|
||||
GROUP_CONCAT(a)
|
||||
,y
|
||||
,x
|
||||
z,
|
||||
SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY id;
|
||||
GROUP_CONCAT(a ORDER BY a)
|
||||
,y
|
||||
,x
|
||||
,z
|
||||
DROP TABLE t1;
|
||||
create table t1(f1 int);
|
||||
insert into t1 values(1),(2),(3);
|
||||
select f1, group_concat(f1+1) from t1 group by f1 with rollup;
|
||||
f1 group_concat(f1+1)
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
NULL 2,3,4
|
||||
select count(distinct (f1+1)) from t1 group by f1 with rollup;
|
||||
count(distinct (f1+1))
|
||||
1
|
||||
1
|
||||
1
|
||||
3
|
||||
drop table t1;
|
||||
create table t1 (f1 int unsigned, f2 varchar(255));
|
||||
insert into t1 values (1,repeat('a',255)),(2,repeat('b',255));
|
||||
select f2,group_concat(f1) from t1 group by f2;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def test t1 t1 f2 f2 253 255 255 Y 0 0 8
|
||||
def group_concat(f1) 253 400 1 Y 128 0 63
|
||||
f2 group_concat(f1)
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 2
|
||||
drop table t1;
|
||||
set names latin1;
|
||||
create table t1 (a char, b char);
|
||||
insert into t1 values ('a', 'a'), ('a', 'b'), ('b', 'a'), ('b', 'b');
|
||||
create table t2 select group_concat(b) as a from t1 where a = 'a';
|
||||
create table t3 (select group_concat(a) as a from t1 where a = 'a') union
|
||||
(select group_concat(b) as a from t1 where a = 'b');
|
||||
select charset(a) from t2;
|
||||
charset(a)
|
||||
latin1
|
||||
select charset(a) from t3;
|
||||
charset(a)
|
||||
latin1
|
||||
latin1
|
||||
drop table t1, t2, t3;
|
||||
set names default;
|
||||
create table t1 (c1 varchar(10), c2 int);
|
||||
select charset(group_concat(c1 order by c2)) from t1;
|
||||
charset(group_concat(c1 order by c2))
|
||||
latin1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a INT(10), b LONGTEXT, PRIMARY KEY (a));
|
||||
SET GROUP_CONCAT_MAX_LEN = 20000000;
|
||||
INSERT INTO t1 VALUES (1,REPEAT(CONCAT('A',CAST(CHAR(0) AS BINARY),'B'), 40000));
|
||||
INSERT INTO t1 SELECT a + 1, b FROM t1;
|
||||
SELECT a, CHAR_LENGTH(b) FROM t1;
|
||||
a CHAR_LENGTH(b)
|
||||
1 120000
|
||||
2 120000
|
||||
SELECT CHAR_LENGTH( GROUP_CONCAT(b) ) FROM t1;
|
||||
CHAR_LENGTH( GROUP_CONCAT(b) )
|
||||
240001
|
||||
SET GROUP_CONCAT_MAX_LEN = 1024;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
INSERT INTO t1 VALUES (2,1), (1,2), (2,2), (1,3);
|
||||
SELECT GROUP_CONCAT(a), x
|
||||
FROM (SELECT a, GROUP_CONCAT(b) x FROM t1 GROUP BY a) AS s
|
||||
GROUP BY x;
|
||||
GROUP_CONCAT(a) x
|
||||
2 1,2
|
||||
1 2,3
|
||||
DROP TABLE t1;
|
||||
set names utf8;
|
||||
create table t1
|
||||
(
|
||||
x text character set utf8 not null,
|
||||
y integer not null
|
||||
);
|
||||
insert into t1 values (repeat('a', 1022), 0), (repeat(_utf8 0xc3b7, 4), 0);
|
||||
set group_concat_max_len= 1022 + 10;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1032 1031 1027 aaaaaaa,÷÷÷÷ C3B7C3B7C3B7
|
||||
set group_concat_max_len= 1022 + 9;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1031 1031 1027 aaaaaaa,÷÷÷÷ C3B7C3B7C3B7
|
||||
set group_concat_max_len= 1022 + 8;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1030 1029 1026 aaaaaaaa,÷÷÷ C3B7C3B7C3B7
|
||||
set group_concat_max_len= 1022 + 7;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1029 1029 1026 aaaaaaaa,÷÷÷ C3B7C3B7C3B7
|
||||
set group_concat_max_len= 1022 + 6;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1028 1027 1025 aaaaaaaaa,÷÷ 612CC3B7C3B7
|
||||
set group_concat_max_len= 1022 + 5;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1027 1027 1025 aaaaaaaaa,÷÷ 612CC3B7C3B7
|
||||
set group_concat_max_len= 1022 + 4;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1026 1025 1024 aaaaaaaaaa,÷ 6161612CC3B7
|
||||
set group_concat_max_len= 1022 + 3;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1025 1025 1024 aaaaaaaaaa,÷ 6161612CC3B7
|
||||
set group_concat_max_len= 1022 + 2;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1024 1023 1023 aaaaaaaaaaa, 61616161612C
|
||||
set group_concat_max_len= 1022 + 1;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1023 1023 1023 aaaaaaaaaaa, 61616161612C
|
||||
drop table t1;
|
||||
set group_concat_max_len=1024;
|
||||
set names latin1;
|
||||
create table t1 (f1 int unsigned, f2 varchar(255));
|
||||
insert into t1 values (1,repeat('a',255)),(2,repeat('b',255));
|
||||
select f2,group_concat(f1) from t1 group by f2;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def test t1 t1 f2 f2 253 255 255 Y 0 0 8
|
||||
def group_concat(f1) 252 1024 1 Y 128 0 63
|
||||
f2 group_concat(f1)
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 2
|
||||
drop table t1;
|
||||
1315
mysql-test/suite/pbxt/r/func_group.result
Normal file
1315
mysql-test/suite/pbxt/r/func_group.result
Normal file
File diff suppressed because it is too large
Load Diff
130
mysql-test/suite/pbxt/r/func_if.result
Normal file
130
mysql-test/suite/pbxt/r/func_if.result
Normal file
@@ -0,0 +1,130 @@
|
||||
drop table if exists t1;
|
||||
select IF(0,"ERROR","this"),IF(1,"is","ERROR"),IF(NULL,"ERROR","a"),IF(1,2,3)|0,IF(1,2.0,3.0)+0 ;
|
||||
IF(0,"ERROR","this") IF(1,"is","ERROR") IF(NULL,"ERROR","a") IF(1,2,3)|0 IF(1,2.0,3.0)+0
|
||||
this is a 2 2.0
|
||||
CREATE TABLE t1 (st varchar(255) NOT NULL, u int(11) NOT NULL) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('a',1),('A',1),('aa',1),('AA',1),('a',1),('aaa',0),('BBB',0);
|
||||
select if(1,st,st) s from t1 order by s;
|
||||
s
|
||||
a
|
||||
A
|
||||
a
|
||||
aa
|
||||
AA
|
||||
aaa
|
||||
BBB
|
||||
select if(u=1,st,st) s from t1 order by s;
|
||||
s
|
||||
a
|
||||
A
|
||||
a
|
||||
aa
|
||||
AA
|
||||
aaa
|
||||
BBB
|
||||
select if(u=1,binary st,st) s from t1 order by s;
|
||||
s
|
||||
A
|
||||
AA
|
||||
BBB
|
||||
a
|
||||
a
|
||||
aa
|
||||
aaa
|
||||
select if(u=1,st,binary st) s from t1 where st like "%a%" order by s;
|
||||
s
|
||||
A
|
||||
AA
|
||||
a
|
||||
a
|
||||
aa
|
||||
aaa
|
||||
explain extended select if(u=1,st,binary st) s from t1 where st like "%a%" order by s;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 100.00 Using where; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary)) AS `s` from `test`.`t1` where (`test`.`t1`.`st` like '%a%') order by if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary))
|
||||
select nullif(u, 1) from t1;
|
||||
nullif(u, 1)
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
0
|
||||
0
|
||||
explain extended select nullif(u, 1) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 100.00
|
||||
Warnings:
|
||||
Note 1003 select nullif(`test`.`t1`.`u`,1) AS `nullif(u, 1)` from `test`.`t1`
|
||||
drop table t1;
|
||||
select nullif(1,'test');
|
||||
nullif(1,'test')
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'test'
|
||||
select NULLIF(NULL,NULL), NULLIF(NULL,1), NULLIF(NULL,1.0), NULLIF(NULL,"test");
|
||||
NULLIF(NULL,NULL) NULLIF(NULL,1) NULLIF(NULL,1.0) NULLIF(NULL,"test")
|
||||
NULL NULL NULL NULL
|
||||
select NULLIF(1,NULL), NULLIF(1.0, NULL), NULLIF("test", NULL);
|
||||
NULLIF(1,NULL) NULLIF(1.0, NULL) NULLIF("test", NULL)
|
||||
1 1.0 test
|
||||
create table t1 (num double(12,2));
|
||||
insert into t1 values (144.54);
|
||||
select sum(if(num is null,0.00,num)) from t1;
|
||||
sum(if(num is null,0.00,num))
|
||||
144.54
|
||||
drop table t1;
|
||||
create table t1 (x int, y int);
|
||||
insert into t1 values (0,6),(10,16),(20,26),(30,10),(40,46),(50,56);
|
||||
select min(if(y -x > 5,y,NULL)), max(if(y - x > 5,y,NULL)) from t1;
|
||||
min(if(y -x > 5,y,NULL)) max(if(y - x > 5,y,NULL))
|
||||
6 56
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert t1 values (1),(2);
|
||||
select if(1>2,a,avg(a)) from t1;
|
||||
if(1>2,a,avg(a))
|
||||
1.5000
|
||||
drop table t1;
|
||||
SELECT NULLIF(5,5) IS NULL, NULLIF(5,5) IS NOT NULL;
|
||||
NULLIF(5,5) IS NULL NULLIF(5,5) IS NOT NULL
|
||||
1 0
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL ,
|
||||
`date` int(10) default NULL,
|
||||
`text` varchar(32) NOT NULL
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,1110000000,'Day 1'),(2,1111000000,'Day 2'),(3,1112000000,'Day 3');
|
||||
SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord ASC;
|
||||
id date_ord text
|
||||
1 05-03-2005 Day 1
|
||||
2 16-03-2005 Day 2
|
||||
3 28-03-2005 Day 3
|
||||
SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord DESC;
|
||||
id date_ord text
|
||||
3 28-03-2005 Day 3
|
||||
2 16-03-2005 Day 2
|
||||
1 05-03-2005 Day 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a CHAR(10));
|
||||
INSERT INTO t1 VALUES ('aaa'), (NULL), (''), ('bbb');
|
||||
SELECT a, NULLIF(a,'') FROM t1;
|
||||
a NULLIF(a,'')
|
||||
aaa aaa
|
||||
NULL NULL
|
||||
NULL
|
||||
bbb bbb
|
||||
SELECT a, NULLIF(a,'') FROM t1 WHERE NULLIF(a,'') IS NULL;
|
||||
a NULLIF(a,'')
|
||||
NULL NULL
|
||||
NULL
|
||||
DROP TABLE t1;
|
||||
create table t1 (f1 int, f2 int);
|
||||
insert into t1 values(1,1),(0,0);
|
||||
select f1, f2, if(f1, 40.0, 5.00) from t1 group by f1 order by f2;
|
||||
f1 f2 if(f1, 40.0, 5.00)
|
||||
0 0 5.00
|
||||
1 1 40.00
|
||||
drop table t1;
|
||||
442
mysql-test/suite/pbxt/r/func_in.result
Normal file
442
mysql-test/suite/pbxt/r/func_in.result
Normal file
@@ -0,0 +1,442 @@
|
||||
drop table if exists t1, t2;
|
||||
select 1 in (1,2,3);
|
||||
1 in (1,2,3)
|
||||
1
|
||||
select 10 in (1,2,3);
|
||||
10 in (1,2,3)
|
||||
0
|
||||
select NULL in (1,2,3);
|
||||
NULL in (1,2,3)
|
||||
NULL
|
||||
select 1 in (1,NULL,3);
|
||||
1 in (1,NULL,3)
|
||||
1
|
||||
select 3 in (1,NULL,3);
|
||||
3 in (1,NULL,3)
|
||||
1
|
||||
select 10 in (1,NULL,3);
|
||||
10 in (1,NULL,3)
|
||||
NULL
|
||||
select 1.5 in (1.5,2.5,3.5);
|
||||
1.5 in (1.5,2.5,3.5)
|
||||
1
|
||||
select 10.5 in (1.5,2.5,3.5);
|
||||
10.5 in (1.5,2.5,3.5)
|
||||
0
|
||||
select NULL in (1.5,2.5,3.5);
|
||||
NULL in (1.5,2.5,3.5)
|
||||
NULL
|
||||
select 1.5 in (1.5,NULL,3.5);
|
||||
1.5 in (1.5,NULL,3.5)
|
||||
1
|
||||
select 3.5 in (1.5,NULL,3.5);
|
||||
3.5 in (1.5,NULL,3.5)
|
||||
1
|
||||
select 10.5 in (1.5,NULL,3.5);
|
||||
10.5 in (1.5,NULL,3.5)
|
||||
NULL
|
||||
CREATE TABLE t1 (a int, b int, c int);
|
||||
insert into t1 values (1,2,3), (1,NULL,3);
|
||||
select 1 in (a,b,c) from t1;
|
||||
1 in (a,b,c)
|
||||
1
|
||||
1
|
||||
select 3 in (a,b,c) from t1;
|
||||
3 in (a,b,c)
|
||||
1
|
||||
1
|
||||
select 10 in (a,b,c) from t1;
|
||||
10 in (a,b,c)
|
||||
0
|
||||
NULL
|
||||
select NULL in (a,b,c) from t1;
|
||||
NULL in (a,b,c)
|
||||
NULL
|
||||
NULL
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a float, b float, c float);
|
||||
insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5);
|
||||
select 1.5 in (a,b,c) from t1;
|
||||
1.5 in (a,b,c)
|
||||
1
|
||||
1
|
||||
select 3.5 in (a,b,c) from t1;
|
||||
3.5 in (a,b,c)
|
||||
1
|
||||
1
|
||||
select 10.5 in (a,b,c) from t1;
|
||||
10.5 in (a,b,c)
|
||||
0
|
||||
NULL
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10));
|
||||
insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD');
|
||||
select 'A' in (a,b,c) from t1;
|
||||
'A' in (a,b,c)
|
||||
1
|
||||
1
|
||||
select 'EFD' in (a,b,c) from t1;
|
||||
'EFD' in (a,b,c)
|
||||
1
|
||||
1
|
||||
select 'XSFGGHF' in (a,b,c) from t1;
|
||||
'XSFGGHF' in (a,b,c)
|
||||
0
|
||||
NULL
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (field char(1));
|
||||
INSERT INTO t1 VALUES ('A'),(NULL);
|
||||
SELECT * from t1 WHERE field IN (NULL);
|
||||
field
|
||||
SELECT * from t1 WHERE field NOT IN (NULL);
|
||||
field
|
||||
SELECT * from t1 where field = field;
|
||||
field
|
||||
A
|
||||
SELECT * from t1 where field <=> field;
|
||||
field
|
||||
A
|
||||
NULL
|
||||
DELETE FROM t1 WHERE field NOT IN (NULL);
|
||||
SELECT * FROM t1;
|
||||
field
|
||||
A
|
||||
NULL
|
||||
drop table t1;
|
||||
create table t1 (id int(10) primary key);
|
||||
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
select * from t1 where id in (2,5,9);
|
||||
id
|
||||
2
|
||||
5
|
||||
9
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a char(1) character set latin1 collate latin1_general_ci,
|
||||
b char(1) character set latin1 collate latin1_swedish_ci,
|
||||
c char(1) character set latin1 collate latin1_danish_ci
|
||||
);
|
||||
insert into t1 values ('A','B','C');
|
||||
insert into t1 values ('a','c','c');
|
||||
select * from t1 where a in (b);
|
||||
ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '='
|
||||
select * from t1 where a in (b,c);
|
||||
ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN '
|
||||
select * from t1 where 'a' in (a,b,c);
|
||||
ERROR HY000: Illegal mix of collations for operation ' IN '
|
||||
select * from t1 where 'a' in (a);
|
||||
a b c
|
||||
A B C
|
||||
a c c
|
||||
select * from t1 where a in ('a');
|
||||
a b c
|
||||
A B C
|
||||
a c c
|
||||
select * from t1 where 'a' collate latin1_general_ci in (a,b,c);
|
||||
a b c
|
||||
A B C
|
||||
a c c
|
||||
select * from t1 where 'a' collate latin1_bin in (a,b,c);
|
||||
a b c
|
||||
a c c
|
||||
select * from t1 where 'a' in (a,b,c collate latin1_bin);
|
||||
a b c
|
||||
a c c
|
||||
explain extended select * from t1 where 'a' in (a,b,c collate latin1_bin);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin)))
|
||||
drop table t1;
|
||||
set names utf8;
|
||||
create table t1 (a char(10) character set utf8 not null);
|
||||
insert into t1 values ('bbbb'),(_koi8r'<27><><EFBFBD><EFBFBD>'),(_latin1'<27><><EFBFBD><EFBFBD>');
|
||||
select a from t1 where a in ('bbbb',_koi8r'<27><><EFBFBD><EFBFBD>',_latin1'<27><><EFBFBD><EFBFBD>') order by a;
|
||||
a
|
||||
ÄÄÄÄ
|
||||
bbbb
|
||||
цццц
|
||||
drop table t1;
|
||||
create table t1 (a char(10) character set latin1 not null);
|
||||
insert into t1 values ('a'),('b'),('c');
|
||||
select a from t1 where a IN ('a','b','c') order by a;
|
||||
a
|
||||
a
|
||||
b
|
||||
c
|
||||
drop table t1;
|
||||
set names latin1;
|
||||
select '1.0' in (1,2);
|
||||
'1.0' in (1,2)
|
||||
1
|
||||
select 1 in ('1.0',2);
|
||||
1 in ('1.0',2)
|
||||
1
|
||||
select 1 in (1,'2.0');
|
||||
1 in (1,'2.0')
|
||||
1
|
||||
select 1 in ('1.0',2.0);
|
||||
1 in ('1.0',2.0)
|
||||
1
|
||||
select 1 in (1.0,'2.0');
|
||||
1 in (1.0,'2.0')
|
||||
1
|
||||
select 1 in ('1.1',2);
|
||||
1 in ('1.1',2)
|
||||
0
|
||||
select 1 in ('1.1',2.0);
|
||||
1 in ('1.1',2.0)
|
||||
0
|
||||
create table t1 (a char(2) character set binary);
|
||||
insert into t1 values ('aa'), ('bb');
|
||||
select * from t1 where a in (NULL, 'aa');
|
||||
a
|
||||
aa
|
||||
drop table t1;
|
||||
create table t1 (id int, key(id));
|
||||
insert into t1 values (1),(2),(3);
|
||||
select count(*) from t1 where id not in (1);
|
||||
count(*)
|
||||
2
|
||||
select count(*) from t1 where id not in (1,2);
|
||||
count(*)
|
||||
1
|
||||
drop table t1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 SELECT 1 IN (2, NULL);
|
||||
SELECT should return NULL.
|
||||
SELECT * FROM t1;
|
||||
1 IN (2, NULL)
|
||||
NULL
|
||||
DROP TABLE t1;
|
||||
End of 4.1 tests
|
||||
CREATE TABLE t1 (a int PRIMARY KEY);
|
||||
INSERT INTO t1 VALUES (44), (45), (46);
|
||||
SELECT * FROM t1 WHERE a IN (45);
|
||||
a
|
||||
45
|
||||
SELECT * FROM t1 WHERE a NOT IN (0, 45);
|
||||
a
|
||||
44
|
||||
46
|
||||
SELECT * FROM t1 WHERE a NOT IN (45);
|
||||
a
|
||||
44
|
||||
46
|
||||
CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45);
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci
|
||||
SELECT * FROM v1;
|
||||
a
|
||||
44
|
||||
46
|
||||
DROP VIEW v1;
|
||||
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, filler char(200), key(a));
|
||||
insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C;
|
||||
insert into t2 select C.a*2+1, 'yes' from t1 C;
|
||||
explain
|
||||
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 5 NULL 11 Using where
|
||||
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
|
||||
a filler
|
||||
1 yes
|
||||
3 yes
|
||||
5 yes
|
||||
7 yes
|
||||
9 yes
|
||||
11 yes
|
||||
13 yes
|
||||
15 yes
|
||||
17 yes
|
||||
19 yes
|
||||
explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 5 NULL # Using where
|
||||
explain select * from t2 force index(a) where a <> 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 5 NULL # Using where
|
||||
drop table t2;
|
||||
create table t2 (a datetime, filler char(200), key(a));
|
||||
insert into t2 select '2006-04-25 10:00:00' + interval C.a minute,
|
||||
'no' from t1 A, t1 B, t1 C where C.a % 2 = 0;
|
||||
insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute,
|
||||
'yes' from t1 C;
|
||||
explain
|
||||
select * from t2 where a NOT IN (
|
||||
'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00',
|
||||
'2006-04-25 10:06:00', '2006-04-25 10:08:00');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 9 NULL 6 Using where
|
||||
select * from t2 where a NOT IN (
|
||||
'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00',
|
||||
'2006-04-25 10:06:00', '2006-04-25 10:08:00');
|
||||
a filler
|
||||
2006-04-25 10:01:00 yes
|
||||
2006-04-25 10:03:00 yes
|
||||
2006-04-25 10:05:00 yes
|
||||
2006-04-25 10:07:00 yes
|
||||
2006-04-25 10:09:00 yes
|
||||
2006-04-25 10:11:00 yes
|
||||
2006-04-25 10:13:00 yes
|
||||
2006-04-25 10:15:00 yes
|
||||
2006-04-25 10:17:00 yes
|
||||
2006-04-25 10:19:00 yes
|
||||
drop table t2;
|
||||
create table t2 (a varchar(10), filler char(200), key(a));
|
||||
insert into t2 select 'foo', 'no' from t1 A, t1 B;
|
||||
insert into t2 select 'barbar', 'no' from t1 A, t1 B;
|
||||
insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B;
|
||||
insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'),
|
||||
('barbas','1'), ('bazbazbay', '1'),('zz','1');
|
||||
analyze table t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 analyze status OK
|
||||
explain select * from t2 where a not in('foo','barbar', 'bazbazbaz');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 13 NULL 4 Using where
|
||||
drop table t2;
|
||||
create table t2 (a decimal(10,5), filler char(200), key(a));
|
||||
insert into t2 select 345.67890, 'no' from t1 A, t1 B;
|
||||
insert into t2 select 43245.34, 'no' from t1 A, t1 B;
|
||||
insert into t2 select 64224.56344, 'no' from t1 A, t1 B;
|
||||
insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'),
|
||||
(55555,'1'), (77777, '1');
|
||||
analyze table t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 analyze status OK
|
||||
explain
|
||||
select * from t2 where a not in (345.67890, 43245.34, 64224.56344);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 7 NULL 4 Using where
|
||||
select * from t2 where a not in (345.67890, 43245.34, 64224.56344);
|
||||
a filler
|
||||
0.00000 1
|
||||
22334.12300 1
|
||||
33333.00000 1
|
||||
55555.00000 1
|
||||
77777.00000 1
|
||||
drop table t2;
|
||||
create table t2 (a int, key(a), b int);
|
||||
insert into t2 values (1,1),(2,2);
|
||||
set @cnt= 1;
|
||||
set @str="update t2 set b=1 where a not in (";
|
||||
select count(*) from (
|
||||
select @str:=concat(@str, @cnt:=@cnt+1, ",")
|
||||
from t1 A, t1 B, t1 C, t1 D) Z;
|
||||
count(*)
|
||||
10000
|
||||
set @str:=concat(@str, "10000)");
|
||||
select substr(@str, 1, 50);
|
||||
substr(@str, 1, 50)
|
||||
update t2 set b=1 where a not in (2,3,4,5,6,7,8,9,
|
||||
prepare s from @str;
|
||||
execute s;
|
||||
deallocate prepare s;
|
||||
set @str=NULL;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
some_id smallint(5) unsigned,
|
||||
key (some_id)
|
||||
);
|
||||
insert into t1 values (1),(2);
|
||||
select some_id from t1 where some_id not in(2,-1);
|
||||
some_id
|
||||
1
|
||||
select some_id from t1 where some_id not in(-4,-1,-4);
|
||||
some_id
|
||||
1
|
||||
2
|
||||
select some_id from t1 where some_id not in(-4,-1,3423534,2342342);
|
||||
some_id
|
||||
1
|
||||
2
|
||||
select some_id from t1 where some_id not in('-1', '0');
|
||||
some_id
|
||||
1
|
||||
2
|
||||
drop table t1;
|
||||
End of 5.0 tests
|
||||
create table t1(f1 char(1));
|
||||
insert into t1 values ('a'),('b'),('1');
|
||||
select f1 from t1 where f1 in ('a',1);
|
||||
f1
|
||||
a
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
select f1, case f1 when 'a' then '+' when 1 then '-' end from t1;
|
||||
f1 case f1 when 'a' then '+' when 1 then '-' end
|
||||
a +
|
||||
b NULL
|
||||
1 -
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
create index t1f1_idx on t1(f1);
|
||||
select f1 from t1 where f1 in ('a',1);
|
||||
f1
|
||||
1
|
||||
a
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
explain select f1 from t1 where f1 in ('a',1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index
|
||||
select f1 from t1 where f1 in ('a','b');
|
||||
f1
|
||||
a
|
||||
b
|
||||
explain select f1 from t1 where f1 in ('a','b');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index
|
||||
select f1 from t1 where f1 in (2,1);
|
||||
f1
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
explain select f1 from t1 where f1 in (2,1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index
|
||||
create table t2(f2 int, index t2f2(f2));
|
||||
insert into t2 values(0),(1),(2);
|
||||
select f2 from t2 where f2 in ('a',2);
|
||||
f2
|
||||
0
|
||||
2
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
explain select f2 from t2 where f2 in ('a',2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
|
||||
select f2 from t2 where f2 in ('a','b');
|
||||
f2
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
explain select f2 from t2 where f2 in ('a','b');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
select f2 from t2 where f2 in (1,'b');
|
||||
f2
|
||||
0
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
explain select f2 from t2 where f2 in (1,'b');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
|
||||
drop table t1, t2;
|
||||
End of 5.1 tests
|
||||
7
mysql-test/suite/pbxt/r/func_isnull.result
Normal file
7
mysql-test/suite/pbxt/r/func_isnull.result
Normal file
@@ -0,0 +1,7 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (id int auto_increment primary key not null, mydate date not null);
|
||||
insert into t1 values (0,"2002-05-01"),(0,"2002-05-01"),(0,"2002-05-01");
|
||||
flush tables;
|
||||
select * from t1 where isnull(to_days(mydate));
|
||||
id mydate
|
||||
drop table t1;
|
||||
171
mysql-test/suite/pbxt/r/func_like.result
Normal file
171
mysql-test/suite/pbxt/r/func_like.result
Normal file
@@ -0,0 +1,171 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (a varchar(10), key(a));
|
||||
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
|
||||
explain extended select * from t1 where a like 'abc%';
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 index a a 13 NULL 5 20.00 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like 'abc%')
|
||||
explain extended select * from t1 where a like concat('abc','%');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 index a a 13 NULL 5 20.00 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like concat('abc','%'))
|
||||
select * from t1 where a like "abc%";
|
||||
a
|
||||
abc
|
||||
abcd
|
||||
select * from t1 where a like concat("abc","%");
|
||||
a
|
||||
abc
|
||||
abcd
|
||||
select * from t1 where a like "ABC%";
|
||||
a
|
||||
abc
|
||||
abcd
|
||||
select * from t1 where a like "test%";
|
||||
a
|
||||
test
|
||||
select * from t1 where a like "te_t";
|
||||
a
|
||||
test
|
||||
select * from t1 where a like "%a%";
|
||||
a
|
||||
a
|
||||
abc
|
||||
abcd
|
||||
select * from t1 where a like "%abcd%";
|
||||
a
|
||||
abcd
|
||||
select * from t1 where a like "%abc\d%";
|
||||
a
|
||||
abcd
|
||||
drop table t1;
|
||||
create table t1 (a varchar(10), key(a));
|
||||
insert into t1 values ('a'), ('a\\b');
|
||||
select * from t1 where a like 'a\\%' escape '#';
|
||||
a
|
||||
a\b
|
||||
select * from t1 where a like 'a\\%' escape '#' and a like 'a\\\\b';
|
||||
a
|
||||
a\b
|
||||
prepare stmt1 from 'select * from t1 where a like \'a\\%\' escape ?';
|
||||
set @esc='#';
|
||||
execute stmt1 using @esc;
|
||||
a
|
||||
a\b
|
||||
deallocate prepare stmt1;
|
||||
drop table t1;
|
||||
create table t1 (a datetime);
|
||||
insert into t1 values ('2004-03-11 12:00:21');
|
||||
select * from t1 where a like '2004-03-11 12:00:21';
|
||||
a
|
||||
2004-03-11 12:00:21
|
||||
drop table t1;
|
||||
SET NAMES koi8r;
|
||||
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET koi8r);
|
||||
INSERT INTO t1 VALUES ('<27><><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD>');
|
||||
INSERT INTO t1 VALUES ('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||||
INSERT INTO t1 VALUES ('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||||
INSERT INTO t1 VALUES ('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'),('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||||
SELECT * FROM t1 WHERE a LIKE '%<25><><EFBFBD><EFBFBD>%';
|
||||
a
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SELECT * FROM t1 WHERE a LIKE '%<25><><EFBFBD>%';
|
||||
a
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SELECT * FROM t1 WHERE a LIKE '<27><><EFBFBD><EFBFBD>%';
|
||||
a
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
DROP TABLE t1;
|
||||
SET NAMES cp1250;
|
||||
CREATE TABLE t1 (a varchar(250) NOT NULL) DEFAULT CHARACTER SET=cp1250;
|
||||
INSERT INTO t1 VALUES
|
||||
('Techni Tapes Sp. z o.o.'),
|
||||
('Pojazdy Szynowe PESA Bydgoszcz SA Holding'),
|
||||
('AKAPESTER 1 P.P.H.U.'),
|
||||
('Pojazdy Szynowe PESA Bydgoszcz S A Holding'),
|
||||
('PPUH PESKA-I Maria Struniarska');
|
||||
select * from t1 where a like '%PESA%';
|
||||
a
|
||||
Pojazdy Szynowe PESA Bydgoszcz SA Holding
|
||||
Pojazdy Szynowe PESA Bydgoszcz S A Holding
|
||||
select * from t1 where a like '%PESA %';
|
||||
a
|
||||
Pojazdy Szynowe PESA Bydgoszcz SA Holding
|
||||
Pojazdy Szynowe PESA Bydgoszcz S A Holding
|
||||
select * from t1 where a like '%PES%';
|
||||
a
|
||||
Techni Tapes Sp. z o.o.
|
||||
Pojazdy Szynowe PESA Bydgoszcz SA Holding
|
||||
AKAPESTER 1 P.P.H.U.
|
||||
Pojazdy Szynowe PESA Bydgoszcz S A Holding
|
||||
PPUH PESKA-I Maria Struniarska
|
||||
select * from t1 where a like '%PESKA%';
|
||||
a
|
||||
PPUH PESKA-I Maria Struniarska
|
||||
select * from t1 where a like '%ESKA%';
|
||||
a
|
||||
PPUH PESKA-I Maria Struniarska
|
||||
DROP TABLE t1;
|
||||
select _cp866'aaaaaaaaa' like _cp866'%aaaa%' collate cp866_bin;
|
||||
_cp866'aaaaaaaaa' like _cp866'%aaaa%' collate cp866_bin
|
||||
1
|
||||
set names koi8r;
|
||||
select 'andre%' like 'andre<72>%' escape '<27>';
|
||||
'andre%' like 'andre<72>%' escape '<27>'
|
||||
1
|
||||
select _cp1251'andre%' like convert('andre<72>%' using cp1251) escape '<27>';
|
||||
_cp1251'andre%' like convert('andre<72>%' using cp1251) escape '<27>'
|
||||
1
|
||||
287
mysql-test/suite/pbxt/r/func_math.result
Normal file
287
mysql-test/suite/pbxt/r/func_math.result
Normal file
@@ -0,0 +1,287 @@
|
||||
drop table if exists t1;
|
||||
select floor(5.5),floor(-5.5);
|
||||
floor(5.5) floor(-5.5)
|
||||
5 -6
|
||||
explain extended select floor(5.5),floor(-5.5);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select floor(5.5) AS `floor(5.5)`,floor(-(5.5)) AS `floor(-5.5)`
|
||||
select ceiling(5.5),ceiling(-5.5);
|
||||
ceiling(5.5) ceiling(-5.5)
|
||||
6 -5
|
||||
explain extended select ceiling(5.5),ceiling(-5.5);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select ceiling(5.5) AS `ceiling(5.5)`,ceiling(-(5.5)) AS `ceiling(-5.5)`
|
||||
select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
|
||||
truncate(52.64,1) truncate(52.64,2) truncate(52.64,-1) truncate(52.64,-2) truncate(-52.64,1) truncate(-52.64,-1)
|
||||
52.6 52.64 50 0 -52.6 -50
|
||||
explain extended select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select truncate(52.64,1) AS `truncate(52.64,1)`,truncate(52.64,2) AS `truncate(52.64,2)`,truncate(52.64,-(1)) AS `truncate(52.64,-1)`,truncate(52.64,-(2)) AS `truncate(52.64,-2)`,truncate(-(52.64),1) AS `truncate(-52.64,1)`,truncate(-(52.64),-(1)) AS `truncate(-52.64,-1)`
|
||||
select round(5.5),round(-5.5);
|
||||
round(5.5) round(-5.5)
|
||||
6 -6
|
||||
explain extended select round(5.5),round(-5.5);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select round(5.5,0) AS `round(5.5)`,round(-(5.5),0) AS `round(-5.5)`
|
||||
select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2);
|
||||
round(5.64,1) round(5.64,2) round(5.64,-1) round(5.64,-2)
|
||||
5.6 5.64 10 0
|
||||
select abs(-10), sign(-5), sign(5), sign(0);
|
||||
abs(-10) sign(-5) sign(5) sign(0)
|
||||
10 -1 1 0
|
||||
explain extended select abs(-10), sign(-5), sign(5), sign(0);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select abs(-(10)) AS `abs(-10)`,sign(-(5)) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)`
|
||||
select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
|
||||
log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2)
|
||||
10 10 NULL NULL NULL 2 NULL NULL
|
||||
explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select log(exp(10)) AS `log(exp(10))`,exp((log(sqrt(10)) * 2)) AS `exp(log(sqrt(10))*2)`,log(-(1)) AS `log(-1)`,log(NULL) AS `log(NULL)`,log(1,1) AS `log(1,1)`,log(3,9) AS `log(3,9)`,log(-(1),2) AS `log(-1,2)`,log(NULL,2) AS `log(NULL,2)`
|
||||
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
|
||||
ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL)
|
||||
10 10 NULL NULL NULL
|
||||
explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-(1)) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)`
|
||||
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
|
||||
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
|
||||
3 3.9068905956085 NULL NULL NULL
|
||||
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-(2)) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)`
|
||||
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
|
||||
log10(100) log10(18) log10(-4) log10(0) log10(NULL)
|
||||
2 1.2552725051033 NULL NULL NULL
|
||||
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select log10(100) AS `log10(100)`,log10(18) AS `log10(18)`,log10(-(4)) AS `log10(-4)`,log10(0) AS `log10(0)`,log10(NULL) AS `log10(NULL)`
|
||||
select pow(10,log10(10)),power(2,4);
|
||||
pow(10,log10(10)) power(2,4)
|
||||
10 16
|
||||
explain extended select pow(10,log10(10)),power(2,4);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select pow(10,log10(10)) AS `pow(10,log10(10))`,pow(2,4) AS `power(2,4)`
|
||||
set @@rand_seed1=10000000,@@rand_seed2=1000000;
|
||||
select rand(999999),rand();
|
||||
rand(999999) rand()
|
||||
0.014231365187309 0.028870999839968
|
||||
explain extended select rand(999999),rand();
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select rand(999999) AS `rand(999999)`,rand() AS `rand()`
|
||||
select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6);
|
||||
pi() format(sin(pi()/2),6) format(cos(pi()/2),6) format(abs(tan(pi())),6) format(cot(1),6) format(asin(1),6) format(acos(0),6) format(atan(1),6)
|
||||
3.141593 1.000000 0.000000 0.000000 0.642093 1.570796 1.570796 0.785398
|
||||
explain extended select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select pi() AS `pi()`,format(sin((pi() / 2)),6) AS `format(sin(pi()/2),6)`,format(cos((pi() / 2)),6) AS `format(cos(pi()/2),6)`,format(abs(tan(pi())),6) AS `format(abs(tan(pi())),6)`,format((1 / tan(1)),6) AS `format(cot(1),6)`,format(asin(1),6) AS `format(asin(1),6)`,format(acos(0),6) AS `format(acos(0),6)`,format(atan(1),6) AS `format(atan(1),6)`
|
||||
select degrees(pi()),radians(360);
|
||||
degrees(pi()) radians(360)
|
||||
180 6.2831853071796
|
||||
select format(atan(-2, 2), 6);
|
||||
format(atan(-2, 2), 6)
|
||||
-0.785398
|
||||
select format(atan(pi(), 0), 6);
|
||||
format(atan(pi(), 0), 6)
|
||||
1.570796
|
||||
select format(atan2(-2, 2), 6);
|
||||
format(atan2(-2, 2), 6)
|
||||
-0.785398
|
||||
select format(atan2(pi(), 0), 6);
|
||||
format(atan2(pi(), 0), 6)
|
||||
1.570796
|
||||
SELECT ACOS(1.0);
|
||||
ACOS(1.0)
|
||||
0
|
||||
SELECT ASIN(1.0);
|
||||
ASIN(1.0)
|
||||
1.5707963267949
|
||||
SELECT ACOS(0.2*5.0);
|
||||
ACOS(0.2*5.0)
|
||||
0
|
||||
SELECT ACOS(0.5*2.0);
|
||||
ACOS(0.5*2.0)
|
||||
0
|
||||
SELECT ASIN(0.8+0.2);
|
||||
ASIN(0.8+0.2)
|
||||
1.5707963267949
|
||||
SELECT ASIN(1.2-0.2);
|
||||
ASIN(1.2-0.2)
|
||||
1.5707963267949
|
||||
select format(4.55, 1), format(4.551, 1);
|
||||
format(4.55, 1) format(4.551, 1)
|
||||
4.6 4.6
|
||||
explain extended select degrees(pi()),radians(360);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select degrees(pi()) AS `degrees(pi())`,radians(360) AS `radians(360)`
|
||||
select rand(rand);
|
||||
ERROR 42S22: Unknown column 'rand' in 'field list'
|
||||
create table t1 (col1 int, col2 decimal(60,30));
|
||||
insert into t1 values(1,1234567890.12345);
|
||||
select format(col2,7) from t1;
|
||||
format(col2,7)
|
||||
1,234,567,890.1234500
|
||||
select format(col2,8) from t1;
|
||||
format(col2,8)
|
||||
1,234,567,890.12345000
|
||||
insert into t1 values(7,1234567890123456.12345);
|
||||
select format(col2,6) from t1 where col1=7;
|
||||
format(col2,6)
|
||||
1,234,567,890,123,456.123450
|
||||
drop table t1;
|
||||
select round(150, 2);
|
||||
round(150, 2)
|
||||
150
|
||||
select ceil(0.09);
|
||||
ceil(0.09)
|
||||
1
|
||||
select ceil(0.000000000000000009);
|
||||
ceil(0.000000000000000009)
|
||||
1
|
||||
create table t1 select round(1, 6);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`round(1, 6)` int(1) NOT NULL DEFAULT '0'
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
select * from t1;
|
||||
round(1, 6)
|
||||
1
|
||||
drop table t1;
|
||||
select abs(-2) * -2;
|
||||
abs(-2) * -2
|
||||
-4
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(1),(1),(2);
|
||||
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
FROM t1;
|
||||
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
656 405
|
||||
122 405
|
||||
645 405
|
||||
858 656
|
||||
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
FROM t1 WHERE a = 1;
|
||||
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
656 405
|
||||
122 405
|
||||
645 405
|
||||
INSERT INTO t1 VALUES (3);
|
||||
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
FROM t1;
|
||||
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
656 405
|
||||
122 405
|
||||
645 405
|
||||
858 656
|
||||
354 906
|
||||
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
FROM t1 WHERE a = 1;
|
||||
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
656 405
|
||||
122 405
|
||||
645 405
|
||||
PREPARE stmt FROM
|
||||
"SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(?) * 1000 AS UNSIGNED)
|
||||
FROM t1 WHERE a = 1";
|
||||
set @var=2;
|
||||
EXECUTE stmt USING @var;
|
||||
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(?) * 1000 AS UNSIGNED)
|
||||
656 656
|
||||
122 122
|
||||
645 645
|
||||
DROP TABLE t1;
|
||||
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8;
|
||||
insert into t1 values ('http://www.foo.com/', now());
|
||||
select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0));
|
||||
a
|
||||
http://www.foo.com/
|
||||
drop table t1;
|
||||
set sql_mode='traditional';
|
||||
select ln(-1);
|
||||
ln(-1)
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1365 Division by 0
|
||||
select log10(-1);
|
||||
log10(-1)
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1365 Division by 0
|
||||
select log2(-1);
|
||||
log2(-1)
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1365 Division by 0
|
||||
select log(2,-1);
|
||||
log(2,-1)
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1365 Division by 0
|
||||
select log(-2,1);
|
||||
log(-2,1)
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1365 Division by 0
|
||||
set sql_mode='';
|
||||
select round(111,-10);
|
||||
round(111,-10)
|
||||
0
|
||||
select round(-5000111000111000155,-1);
|
||||
round(-5000111000111000155,-1)
|
||||
-5000111000111000160
|
||||
select round(15000111000111000155,-1);
|
||||
round(15000111000111000155,-1)
|
||||
15000111000111000160
|
||||
select truncate(-5000111000111000155,-1);
|
||||
truncate(-5000111000111000155,-1)
|
||||
-5000111000111000150
|
||||
select truncate(15000111000111000155,-1);
|
||||
truncate(15000111000111000155,-1)
|
||||
15000111000111000150
|
||||
set names utf8;
|
||||
create table t1
|
||||
(f1 varchar(32) not null,
|
||||
f2 smallint(5) unsigned not null,
|
||||
f3 int(10) unsigned not null default '0')
|
||||
engine=myisam default charset=utf8;
|
||||
insert into t1 values ('zombie',0,0),('gold',1,10000),('silver',2,10000);
|
||||
create table t2
|
||||
(f1 int(10) unsigned not null,
|
||||
f2 int(10) unsigned not null,
|
||||
f3 smallint(5) unsigned not null)
|
||||
engine=myisam default charset=utf8;
|
||||
insert into t2 values (16777216,16787215,1),(33554432,33564431,2);
|
||||
select format(t2.f2-t2.f1+1,0) from t1,t2
|
||||
where t1.f2 = t2.f3 order by t1.f1;
|
||||
format(t2.f2-t2.f1+1,0)
|
||||
10,000
|
||||
10,000
|
||||
drop table t1, t2;
|
||||
set names default;
|
||||
144
mysql-test/suite/pbxt/r/func_misc.result
Normal file
144
mysql-test/suite/pbxt/r/func_misc.result
Normal file
@@ -0,0 +1,144 @@
|
||||
select format(1.5555,0),format(123.5555,1),format(1234.5555,2),format(12345.55555,3),format(123456.5555,4),format(1234567.5555,5),format("12345.2399",2);
|
||||
format(1.5555,0) format(123.5555,1) format(1234.5555,2) format(12345.55555,3) format(123456.5555,4) format(1234567.5555,5) format("12345.2399",2)
|
||||
2 123.6 1,234.56 12,345.556 123,456.5555 1,234,567.55550 12,345.24
|
||||
select inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"));
|
||||
inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"))
|
||||
NULL
|
||||
select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255");
|
||||
inet_aton("255.255.255.255.255") inet_aton("255.255.1.255") inet_aton("0.1.255")
|
||||
1099511627775 4294902271 65791
|
||||
select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511);
|
||||
inet_ntoa(1099511627775) inet_ntoa(4294902271) inet_ntoa(511)
|
||||
NULL 255.255.1.255 0.0.1.255
|
||||
select hex(inet_aton('127'));
|
||||
hex(inet_aton('127'))
|
||||
7F
|
||||
select hex(inet_aton('127.1'));
|
||||
hex(inet_aton('127.1'))
|
||||
7F000001
|
||||
select hex(inet_aton('127.1.1'));
|
||||
hex(inet_aton('127.1.1'))
|
||||
7F010001
|
||||
select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_utf8'')));
|
||||
length(uuid()) charset(uuid()) length(unhex(replace(uuid(),_utf8'-',_utf8'')))
|
||||
36 utf8 16
|
||||
select length(format('nan', 2)) > 0;
|
||||
length(format('nan', 2)) > 0
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'nan'
|
||||
select concat("$",format(2500,2));
|
||||
concat("$",format(2500,2))
|
||||
$2,500.00
|
||||
create table t1 ( a timestamp );
|
||||
insert into t1 values ( '2004-01-06 12:34' );
|
||||
select a from t1 where left(a+0,6) in ( left(20040106,6) );
|
||||
a
|
||||
2004-01-06 12:34:00
|
||||
select a from t1 where left(a+0,6) = ( left(20040106,6) );
|
||||
a
|
||||
2004-01-06 12:34:00
|
||||
select a from t1 where right(a+0,6) in ( right(20040106123400,6) );
|
||||
a
|
||||
2004-01-06 12:34:00
|
||||
select a from t1 where right(a+0,6) = ( right(20040106123400,6) );
|
||||
a
|
||||
2004-01-06 12:34:00
|
||||
select a from t1 where mid(a+0,6,3) in ( mid(20040106123400,6,3) );
|
||||
a
|
||||
2004-01-06 12:34:00
|
||||
select a from t1 where mid(a+0,6,3) = ( mid(20040106123400,6,3) );
|
||||
a
|
||||
2004-01-06 12:34:00
|
||||
drop table t1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (conn CHAR(7), connection_id INT);
|
||||
INSERT INTO t1 VALUES ('default', CONNECTION_ID());
|
||||
SELECT GET_LOCK('bug16501',600);
|
||||
GET_LOCK('bug16501',600)
|
||||
1
|
||||
INSERT INTO t1 VALUES ('con1', CONNECTION_ID());
|
||||
SELECT IS_USED_LOCK('bug16501') = connection_id
|
||||
FROM t1
|
||||
WHERE conn = 'default';
|
||||
IS_USED_LOCK('bug16501') = connection_id
|
||||
1
|
||||
SELECT GET_LOCK('bug16501',600);
|
||||
SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID();
|
||||
IS_USED_LOCK('bug16501') = CONNECTION_ID()
|
||||
1
|
||||
SELECT RELEASE_LOCK('bug16501');
|
||||
RELEASE_LOCK('bug16501')
|
||||
1
|
||||
GET_LOCK('bug16501',600)
|
||||
1
|
||||
SELECT IS_USED_LOCK('bug16501') = connection_id
|
||||
FROM t1
|
||||
WHERE conn = 'con1';
|
||||
IS_USED_LOCK('bug16501') = connection_id
|
||||
1
|
||||
SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID();
|
||||
IS_USED_LOCK('bug16501') = CONNECTION_ID()
|
||||
1
|
||||
SELECT RELEASE_LOCK('bug16501');
|
||||
RELEASE_LOCK('bug16501')
|
||||
1
|
||||
SELECT IS_USED_LOCK('bug16501');
|
||||
IS_USED_LOCK('bug16501')
|
||||
NULL
|
||||
DROP TABLE t1;
|
||||
select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
|
||||
export_set(3, _latin1'foo', _utf8'bar', ',', 4)
|
||||
foo,foo,bar,bar
|
||||
End of 4.1 tests
|
||||
create table t1 as select uuid(), length(uuid());
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`uuid()` varchar(36) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`length(uuid())` int(10) NOT NULL DEFAULT '0'
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (a timestamp default '2005-05-05 01:01:01',
|
||||
b timestamp default '2005-05-05 01:01:01');
|
||||
insert into t1 set a = now();
|
||||
select sleep(3);
|
||||
sleep(3)
|
||||
0
|
||||
update t1 set b = now();
|
||||
select timediff(b, a) >= '00:00:03' from t1;
|
||||
timediff(b, a) >= '00:00:03'
|
||||
1
|
||||
drop table t1;
|
||||
set global query_cache_size=1355776;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(1),(1);
|
||||
create table t2 (a datetime default null, b datetime default null);
|
||||
insert into t2 set a = now();
|
||||
select a from t1 where sleep(1);
|
||||
a
|
||||
update t2 set b = now() where b is null;
|
||||
insert into t2 set a = now();
|
||||
select a from t1 where sleep(a);
|
||||
a
|
||||
update t2 set b = now() where b is null;
|
||||
insert into t2 set a = now();
|
||||
select a from t1 where sleep(1);
|
||||
a
|
||||
update t2 set b = now() where b is null;
|
||||
select timediff(b, a) >= '00:00:03' from t2;
|
||||
timediff(b, a) >= '00:00:03'
|
||||
1
|
||||
1
|
||||
1
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
set global query_cache_size=default;
|
||||
create table t1 select INET_ATON('255.255.0.1') as `a`;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` bigint(21) unsigned DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
End of 5.0 tests
|
||||
48
mysql-test/suite/pbxt/r/func_op.result
Normal file
48
mysql-test/suite/pbxt/r/func_op.result
Normal file
@@ -0,0 +1,48 @@
|
||||
select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
|
||||
1+1 1-1 1+1*2 8/5 8%5 mod(8,5) mod(8,5)|0 -(1+1)*-2
|
||||
2 0 3 1.6000 3 3 3 4
|
||||
explain extended select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select (1 + 1) AS `1+1`,(1 - 1) AS `1-1`,(1 + (1 * 2)) AS `1+1*2`,(8 / 5) AS `8/5`,(8 % 5) AS `8%5`,(8 % 5) AS `mod(8,5)`,((8 % 5) | 0) AS `mod(8,5)|0`,(-((1 + 1)) * -(2)) AS `-(1+1)*-2`
|
||||
select 1 | (1+1),5 & 3,bit_count(7) ;
|
||||
1 | (1+1) 5 & 3 bit_count(7)
|
||||
3 1 3
|
||||
explain extended select 1 | (1+1),5 & 3,bit_count(7) ;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select (1 | (1 + 1)) AS `1 | (1+1)`,(5 & 3) AS `5 & 3`,bit_count(7) AS `bit_count(7)`
|
||||
select 1 << 32,1 << 63, 1 << 64, 4 >> 2, 4 >> 63, 1<< 63 >> 60;
|
||||
1 << 32 1 << 63 1 << 64 4 >> 2 4 >> 63 1<< 63 >> 60
|
||||
4294967296 9223372036854775808 0 1 0 8
|
||||
select -1 | 0, -1 ^ 0, -1 & 0;
|
||||
-1 | 0 -1 ^ 0 -1 & 0
|
||||
18446744073709551615 18446744073709551615 0
|
||||
select -1 | 1, -1 ^ 1, -1 & 1;
|
||||
-1 | 1 -1 ^ 1 -1 & 1
|
||||
18446744073709551615 18446744073709551614 1
|
||||
select 1 | -1, 1 ^ -1, 1 & -1;
|
||||
1 | -1 1 ^ -1 1 & -1
|
||||
18446744073709551615 18446744073709551614 1
|
||||
select 0 | -1, 0 ^ -1, 0 & -1;
|
||||
0 | -1 0 ^ -1 0 & -1
|
||||
18446744073709551615 18446744073709551615 0
|
||||
select -1 >> 0, -1 << 0;
|
||||
-1 >> 0 -1 << 0
|
||||
18446744073709551615 18446744073709551615
|
||||
select -1 >> 1, -1 << 1;
|
||||
-1 >> 1 -1 << 1
|
||||
9223372036854775807 18446744073709551614
|
||||
drop table if exists t1,t2;
|
||||
create table t1(a int);
|
||||
create table t2(a int, b int);
|
||||
insert into t1 values (1), (2), (3);
|
||||
insert into t2 values (1, 7), (3, 7);
|
||||
select t1.a, t2.a, t2.b, bit_count(t2.b) from t1 left join t2 on t1.a=t2.a;
|
||||
a a b bit_count(t2.b)
|
||||
1 1 7 3
|
||||
2 NULL NULL NULL
|
||||
3 3 7 3
|
||||
drop table t1, t2;
|
||||
100
mysql-test/suite/pbxt/r/func_regexp.result
Normal file
100
mysql-test/suite/pbxt/r/func_regexp.result
Normal file
@@ -0,0 +1,100 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (s1 char(64),s2 char(64));
|
||||
insert into t1 values('aaa','aaa');
|
||||
insert into t1 values('aaa|qqq','qqq');
|
||||
insert into t1 values('gheis','^[^a-dXYZ]+$');
|
||||
insert into t1 values('aab','^aa?b');
|
||||
insert into t1 values('Baaan','^Ba*n');
|
||||
insert into t1 values('aaa','qqq|aaa');
|
||||
insert into t1 values('qqq','qqq|aaa');
|
||||
insert into t1 values('bbb','qqq|aaa');
|
||||
insert into t1 values('bbb','qqq');
|
||||
insert into t1 values('aaa','aba');
|
||||
insert into t1 values(null,'abc');
|
||||
insert into t1 values('def',null);
|
||||
insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
drop table t1;
|
||||
create table t1 (xxx char(128));
|
||||
insert into t1 (xxx) values('this is a test of some long text to see what happens');
|
||||
select * from t1 where xxx regexp('is a test of some long text to');
|
||||
xxx
|
||||
this is a test of some long text to see what happens
|
||||
explain extended select * from t1 where xxx regexp('is a test of some long text to');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`xxx` AS `xxx` from `test`.`t1` where (`test`.`t1`.`xxx` regexp 'is a test of some long text to')
|
||||
select * from t1 where xxx regexp('is a test of some long text to ');
|
||||
xxx
|
||||
this is a test of some long text to see what happens
|
||||
select * from t1 where xxx regexp('is a test of some long text to s');
|
||||
xxx
|
||||
this is a test of some long text to see what happens
|
||||
select * from t1 where xxx regexp('is a test of some long text to se');
|
||||
xxx
|
||||
this is a test of some long text to see what happens
|
||||
drop table t1;
|
||||
create table t1 (xxx char(128));
|
||||
insert into t1 (xxx) values('this is some text: to test - out.reg exp (22/45)');
|
||||
select * from t1 where xxx REGEXP '^this is some text: to test - out\\.reg exp [[(][0-9]+[/\\][0-9]+[])][ ]*$';
|
||||
xxx
|
||||
this is some text: to test - out.reg exp (22/45)
|
||||
drop table t1;
|
||||
select _latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin;
|
||||
_latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin
|
||||
1
|
||||
select _koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin;
|
||||
_koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin
|
||||
0
|
||||
select _latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin;
|
||||
_latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin
|
||||
0
|
||||
select _koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin;
|
||||
_koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin
|
||||
1
|
||||
select _latin1 0xF7 regexp _latin1 '[[:alpha:]]';
|
||||
_latin1 0xF7 regexp _latin1 '[[:alpha:]]'
|
||||
0
|
||||
select _koi8r 0xF7 regexp _koi8r '[[:alpha:]]';
|
||||
_koi8r 0xF7 regexp _koi8r '[[:alpha:]]'
|
||||
1
|
||||
select _latin1'a' regexp _latin1'A' collate latin1_general_ci;
|
||||
_latin1'a' regexp _latin1'A' collate latin1_general_ci
|
||||
1
|
||||
select _latin1'a' regexp _latin1'A' collate latin1_bin;
|
||||
_latin1'a' regexp _latin1'A' collate latin1_bin
|
||||
0
|
||||
create table t1 (a varchar(40));
|
||||
insert into t1 values ('C1'),('C2'),('R1'),('C3'),('R2'),('R3');
|
||||
prepare stmt1 from 'select a from t1 where a rlike ? order by a';
|
||||
set @a="^C.*";
|
||||
execute stmt1 using @a;
|
||||
a
|
||||
C1
|
||||
C2
|
||||
C3
|
||||
set @a="^R.*";
|
||||
execute stmt1 using @a;
|
||||
a
|
||||
R1
|
||||
R2
|
||||
R3
|
||||
deallocate prepare stmt1;
|
||||
drop table t1;
|
||||
249
mysql-test/suite/pbxt/r/func_sapdb.result
Normal file
249
mysql-test/suite/pbxt/r/func_sapdb.result
Normal file
@@ -0,0 +1,249 @@
|
||||
drop table if exists t1, test;
|
||||
select extract(DAY_MICROSECOND FROM "1999-01-02 10:11:12.000123");
|
||||
extract(DAY_MICROSECOND FROM "1999-01-02 10:11:12.000123")
|
||||
2101112000123
|
||||
select extract(HOUR_MICROSECOND FROM "1999-01-02 10:11:12.000123");
|
||||
extract(HOUR_MICROSECOND FROM "1999-01-02 10:11:12.000123")
|
||||
101112000123
|
||||
select extract(MINUTE_MICROSECOND FROM "1999-01-02 10:11:12.000123");
|
||||
extract(MINUTE_MICROSECOND FROM "1999-01-02 10:11:12.000123")
|
||||
1112000123
|
||||
select extract(SECOND_MICROSECOND FROM "1999-01-02 10:11:12.000123");
|
||||
extract(SECOND_MICROSECOND FROM "1999-01-02 10:11:12.000123")
|
||||
12000123
|
||||
select extract(MICROSECOND FROM "1999-01-02 10:11:12.000123");
|
||||
extract(MICROSECOND FROM "1999-01-02 10:11:12.000123")
|
||||
123
|
||||
select date_format("1997-12-31 23:59:59.000002", "%f");
|
||||
date_format("1997-12-31 23:59:59.000002", "%f")
|
||||
000002
|
||||
select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000 99:99:99.999999" DAY_MICROSECOND);
|
||||
date_add("1997-12-31 23:59:59.000002",INTERVAL "10000 99:99:99.999999" DAY_MICROSECOND)
|
||||
2025-05-23 04:40:39.000001
|
||||
select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99:99.999999" HOUR_MICROSECOND);
|
||||
date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99:99.999999" HOUR_MICROSECOND)
|
||||
1999-02-21 17:40:39.000001
|
||||
select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99.999999" MINUTE_MICROSECOND);
|
||||
date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99.999999" MINUTE_MICROSECOND)
|
||||
1998-01-07 22:41:39.000001
|
||||
select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000.999999" SECOND_MICROSECOND);
|
||||
date_add("1997-12-31 23:59:59.000002",INTERVAL "10000.999999" SECOND_MICROSECOND)
|
||||
1998-01-01 02:46:40.000001
|
||||
select date_add("1997-12-31 23:59:59.000002",INTERVAL "999999" MICROSECOND);
|
||||
date_add("1997-12-31 23:59:59.000002",INTERVAL "999999" MICROSECOND)
|
||||
1998-01-01 00:00:00.000001
|
||||
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1 1:1:1.000002" DAY_MICROSECOND);
|
||||
date_sub("1998-01-01 00:00:00.000001",INTERVAL "1 1:1:1.000002" DAY_MICROSECOND)
|
||||
1997-12-30 22:58:58.999999
|
||||
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1:1.000002" HOUR_MICROSECOND);
|
||||
date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1:1.000002" HOUR_MICROSECOND)
|
||||
1997-12-31 22:58:58.999999
|
||||
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1.000002" MINUTE_MICROSECOND);
|
||||
date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1.000002" MINUTE_MICROSECOND)
|
||||
1997-12-31 23:58:58.999999
|
||||
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1.000002" SECOND_MICROSECOND);
|
||||
date_sub("1998-01-01 00:00:00.000001",INTERVAL "1.000002" SECOND_MICROSECOND)
|
||||
1997-12-31 23:59:58.999999
|
||||
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "000002" MICROSECOND);
|
||||
date_sub("1998-01-01 00:00:00.000001",INTERVAL "000002" MICROSECOND)
|
||||
1997-12-31 23:59:59.999999
|
||||
select adddate("1997-12-31 23:59:59.000001", 10);
|
||||
adddate("1997-12-31 23:59:59.000001", 10)
|
||||
1998-01-10 23:59:59.000001
|
||||
select subdate("1997-12-31 23:59:59.000001", 10);
|
||||
subdate("1997-12-31 23:59:59.000001", 10)
|
||||
1997-12-21 23:59:59.000001
|
||||
select datediff("1997-12-31 23:59:59.000001","1997-12-30");
|
||||
datediff("1997-12-31 23:59:59.000001","1997-12-30")
|
||||
1
|
||||
select datediff("1997-11-30 23:59:59.000001","1997-12-31");
|
||||
datediff("1997-11-30 23:59:59.000001","1997-12-31")
|
||||
-31
|
||||
SET @@SQL_MODE="ALLOW_INVALID_DATES";
|
||||
select datediff("1997-11-31 23:59:59.000001","1997-12-31");
|
||||
datediff("1997-11-31 23:59:59.000001","1997-12-31")
|
||||
-30
|
||||
SET @@SQL_MODE="";
|
||||
select datediff("1997-11-31 23:59:59.000001","1997-12-31");
|
||||
datediff("1997-11-31 23:59:59.000001","1997-12-31")
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '1997-11-31 23:59:59.000001'
|
||||
select datediff("1997-11-30 23:59:59.000001",null);
|
||||
datediff("1997-11-30 23:59:59.000001",null)
|
||||
NULL
|
||||
select weekofyear("1997-11-30 23:59:59.000001");
|
||||
weekofyear("1997-11-30 23:59:59.000001")
|
||||
48
|
||||
select makedate(1997,1);
|
||||
makedate(1997,1)
|
||||
1997-01-01
|
||||
select makedate(1997,0);
|
||||
makedate(1997,0)
|
||||
NULL
|
||||
select makedate(9999,365);
|
||||
makedate(9999,365)
|
||||
9999-12-31
|
||||
select makedate(9999,366);
|
||||
makedate(9999,366)
|
||||
NULL
|
||||
select addtime("1997-12-31 23:59:59.999999", "1 1:1:1.000002");
|
||||
addtime("1997-12-31 23:59:59.999999", "1 1:1:1.000002")
|
||||
1998-01-02 01:01:01.000001
|
||||
select subtime("1997-12-31 23:59:59.000001", "1 1:1:1.000002");
|
||||
subtime("1997-12-31 23:59:59.000001", "1 1:1:1.000002")
|
||||
1997-12-30 22:58:57.999999
|
||||
select addtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
|
||||
addtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999")
|
||||
NULL
|
||||
select subtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
|
||||
subtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999")
|
||||
NULL
|
||||
select subtime("01:00:00.999999", "02:00:00.999998");
|
||||
subtime("01:00:00.999999", "02:00:00.999998")
|
||||
-00:59:59.999999
|
||||
select subtime("02:01:01.999999", "01:01:01.999999");
|
||||
subtime("02:01:01.999999", "01:01:01.999999")
|
||||
01:00:00.000000
|
||||
select timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002");
|
||||
timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002")
|
||||
838:59:59
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '8807:59:59.999999'
|
||||
select timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002");
|
||||
timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002")
|
||||
46:58:57.999999
|
||||
select timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002");
|
||||
timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002")
|
||||
-24:00:00.000001
|
||||
select timediff("1997-12-31 23:59:59.000001","23:59:59.000001");
|
||||
timediff("1997-12-31 23:59:59.000001","23:59:59.000001")
|
||||
NULL
|
||||
select timediff("2000:01:01 00:00:00", "2000:01:01 00:00:00.000001");
|
||||
timediff("2000:01:01 00:00:00", "2000:01:01 00:00:00.000001")
|
||||
-00:00:00.000001
|
||||
select timediff("2005-01-11 15:48:49.999999", "2005-01-11 15:48:50");
|
||||
timediff("2005-01-11 15:48:49.999999", "2005-01-11 15:48:50")
|
||||
-00:00:00.000001
|
||||
select maketime(10,11,12);
|
||||
maketime(10,11,12)
|
||||
10:11:12
|
||||
select maketime(25,11,12);
|
||||
maketime(25,11,12)
|
||||
25:11:12
|
||||
select maketime(-25,11,12);
|
||||
maketime(-25,11,12)
|
||||
-25:11:12
|
||||
select timestamp("2001-12-01", "01:01:01.999999");
|
||||
timestamp("2001-12-01", "01:01:01.999999")
|
||||
2001-12-01 01:01:01.999999
|
||||
select timestamp("2001-13-01", "01:01:01.000001");
|
||||
timestamp("2001-13-01", "01:01:01.000001")
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '2001-13-01'
|
||||
select timestamp("2001-12-01", "25:01:01");
|
||||
timestamp("2001-12-01", "25:01:01")
|
||||
2001-12-02 01:01:01
|
||||
select timestamp("2001-12-01 01:01:01.000100");
|
||||
timestamp("2001-12-01 01:01:01.000100")
|
||||
2001-12-01 01:01:01.000100
|
||||
select timestamp("2001-12-01");
|
||||
timestamp("2001-12-01")
|
||||
2001-12-01 00:00:00
|
||||
select day("1997-12-31 23:59:59.000001");
|
||||
day("1997-12-31 23:59:59.000001")
|
||||
31
|
||||
select date("1997-12-31 23:59:59.000001");
|
||||
date("1997-12-31 23:59:59.000001")
|
||||
1997-12-31
|
||||
select date("1997-13-31 23:59:59.000001");
|
||||
date("1997-13-31 23:59:59.000001")
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '1997-13-31 23:59:59.000001'
|
||||
select time("1997-12-31 23:59:59.000001");
|
||||
time("1997-12-31 23:59:59.000001")
|
||||
23:59:59.000001
|
||||
select time("1997-12-31 25:59:59.000001");
|
||||
time("1997-12-31 25:59:59.000001")
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '1997-12-31 25:59:59.000001'
|
||||
select microsecond("1997-12-31 23:59:59.000001");
|
||||
microsecond("1997-12-31 23:59:59.000001")
|
||||
1
|
||||
create table t1
|
||||
select makedate(1997,1) as f1,
|
||||
addtime(cast("1997-12-31 23:59:59.000001" as datetime), "1 1:1:1.000002") as f2,
|
||||
addtime(cast("23:59:59.999999" as time) , "1 1:1:1.000002") as f3,
|
||||
timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002") as f4,
|
||||
timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002") as f5,
|
||||
maketime(10,11,12) as f6,
|
||||
timestamp(cast("2001-12-01" as date), "01:01:01") as f7,
|
||||
date("1997-12-31 23:59:59.000001") as f8,
|
||||
time("1997-12-31 23:59:59.000001") as f9;
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
f1 date NO 0000-00-00
|
||||
f2 datetime YES NULL
|
||||
f3 time YES NULL
|
||||
f4 time YES NULL
|
||||
f5 time YES NULL
|
||||
f6 time YES NULL
|
||||
f7 datetime YES NULL
|
||||
f8 date YES NULL
|
||||
f9 time YES NULL
|
||||
select * from t1;
|
||||
f1 f2 f3 f4 f5 f6 f7 f8 f9
|
||||
1997-01-01 1998-01-02 01:01:00 49:01:01 46:58:57 -24:00:00 10:11:12 2001-12-01 01:01:01 1997-12-31 23:59:59
|
||||
create table test(t1 datetime, t2 time, t3 time, t4 datetime);
|
||||
insert into test values
|
||||
('2001-01-01 01:01:01', '01:01:01', null, '2001-02-01 01:01:01'),
|
||||
('2001-01-01 01:01:01', '-01:01:01', '-23:59:59', "1997-12-31 23:59:59.000001"),
|
||||
('1997-12-31 23:59:59.000001', '-23:59:59', '-01:01:01', '2001-01-01 01:01:01'),
|
||||
('2001-01-01 01:01:01', '01:01:01', '-1 01:01:01', null),
|
||||
('2001-01-01 01:01:01', '-01:01:01', '1 01:01:01', '2001-01-01 01:01:01'),
|
||||
('2001-01-01 01:01:01', null, '-1 01:01:01', null),
|
||||
(null, null, null, null),
|
||||
('2001-01-01 01:01:01', '01:01:01', '1 01:01:01', '2001-01-01 01:01:01');
|
||||
SELECT ADDTIME(t1,t2) As ttt, ADDTIME(t2, t3) As qqq from test;
|
||||
ttt qqq
|
||||
2001-01-01 02:02:02 NULL
|
||||
2001-01-01 00:00:00 -25:01:00
|
||||
1997-12-31 00:00:00 -25:01:00
|
||||
2001-01-01 02:02:02 -24:00:00
|
||||
2001-01-01 00:00:00 24:00:00
|
||||
NULL NULL
|
||||
NULL NULL
|
||||
2001-01-01 02:02:02 26:02:02
|
||||
SELECT TIMEDIFF(t1, t4) As ttt, TIMEDIFF(t2, t3) As qqq,
|
||||
TIMEDIFF(t3, t2) As eee, TIMEDIFF(t2, t4) As rrr from test;
|
||||
ttt qqq eee rrr
|
||||
-744:00:00 NULL NULL NULL
|
||||
838:59:59 22:58:58 -22:58:58 NULL
|
||||
-838:59:59 -22:58:58 22:58:58 NULL
|
||||
NULL 26:02:02 -26:02:02 NULL
|
||||
00:00:00 -26:02:02 26:02:02 NULL
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
00:00:00 -24:00:00 24:00:00 NULL
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '26305:01:02'
|
||||
Warning 1292 Truncated incorrect time value: '-26305:01:02'
|
||||
drop table t1, test;
|
||||
select addtime("-01:01:01.01", "-23:59:59.1") as a;
|
||||
a
|
||||
-25:01:00.110000
|
||||
select microsecond("1997-12-31 23:59:59.01") as a;
|
||||
a
|
||||
10000
|
||||
select microsecond(19971231235959.01) as a;
|
||||
a
|
||||
10000
|
||||
select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a;
|
||||
a
|
||||
1997-12-31 00:00:10.090000
|
||||
select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f");
|
||||
str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f")
|
||||
2003-01-02 10:11:12.001200
|
||||
75
mysql-test/suite/pbxt/r/func_set.result
Normal file
75
mysql-test/suite/pbxt/r/func_set.result
Normal file
@@ -0,0 +1,75 @@
|
||||
select interval(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
|
||||
interval(55,10,20,30,40,50,60,70,80,90,100) interval(3,1,1+1,1+1+1+1) field("IBM","NCA","ICL","SUN","IBM","DIGITAL") field("A","B","C") elt(2,"ONE","TWO","THREE") interval(0,1,2,3,4) elt(1,1,2,3)|0 elt(1,1.1,1.2,1.3)+0
|
||||
5 2 4 0 TWO 0 1 1.1
|
||||
explain extended select INTERVAL(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select interval((55,10,20,30,40,50,60,70,80,90,100)) AS `INTERVAL(55,10,20,30,40,50,60,70,80,90,100)`,interval((3,1,(1 + 1),(((1 + 1) + 1) + 1))) AS `interval(3,1,1+1,1+1+1+1)`,field('IBM','NCA','ICL','SUN','IBM','DIGITAL') AS `field("IBM","NCA","ICL","SUN","IBM","DIGITAL")`,field('A','B','C') AS `field("A","B","C")`,elt(2,'ONE','TWO','THREE') AS `elt(2,"ONE","TWO","THREE")`,interval((0,1,2,3,4)) AS `interval(0,1,2,3,4)`,(elt(1,1,2,3) | 0) AS `elt(1,1,2,3)|0`,(elt(1,1.1,1.2,1.3) + 0) AS `elt(1,1.1,1.2,1.3)+0`
|
||||
SELECT INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56);
|
||||
INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56)
|
||||
1
|
||||
SELECT INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56, 77);
|
||||
INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56, 77)
|
||||
1
|
||||
select find_in_set("b","a,b,c"),find_in_set("c","a,b,c"),find_in_set("dd","a,bbb,dd"),find_in_set("bbb","a,bbb,dd");
|
||||
find_in_set("b","a,b,c") find_in_set("c","a,b,c") find_in_set("dd","a,bbb,dd") find_in_set("bbb","a,bbb,dd")
|
||||
2 3 3 2
|
||||
select find_in_set("d","a,b,c"),find_in_set("dd","a,bbb,d"),find_in_set("bb","a,bbb,dd");
|
||||
find_in_set("d","a,b,c") find_in_set("dd","a,bbb,d") find_in_set("bb","a,bbb,dd")
|
||||
0 0 0
|
||||
select make_set(0,'a','b','c'),make_set(-1,'a','b','c'),make_set(1,'a','b','c'),make_set(2,'a','b','c'),make_set(1+2,concat('a','b'),'c');
|
||||
make_set(0,'a','b','c') make_set(-1,'a','b','c') make_set(1,'a','b','c') make_set(2,'a','b','c') make_set(1+2,concat('a','b'),'c')
|
||||
a,b,c a b ab,c
|
||||
select make_set(NULL,'a','b','c'),make_set(1|4,'a',NULL,'c'),make_set(1+2,'a',NULL,'c');
|
||||
make_set(NULL,'a','b','c') make_set(1|4,'a',NULL,'c') make_set(1+2,'a',NULL,'c')
|
||||
NULL a,c a
|
||||
select export_set(9,"Y","N","-",5),export_set(9,"Y","N"),export_set(9,"Y","N","");
|
||||
export_set(9,"Y","N","-",5) export_set(9,"Y","N") export_set(9,"Y","N","")
|
||||
Y-N-N-Y-N Y,N,N,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,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,N,N,N,N,N YNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
|
||||
select elt(2,1),field(NULL,"a","b","c");
|
||||
elt(2,1) field(NULL,"a","b","c")
|
||||
NULL 0
|
||||
select field("b","a",NULL),field(1,0,NULL)+0,field(1.0,0.0,NULL)+0.0,field(1.0e1,0.0e1,NULL)+0.0e1;
|
||||
field("b","a",NULL) field(1,0,NULL)+0 field(1.0,0.0,NULL)+0.0 field(1.0e1,0.0e1,NULL)+0.0e1
|
||||
0 0 0.0 0
|
||||
select field(NULL,"a",NULL),field(NULL,0,NULL)+0,field(NULL,0.0,NULL)+0.0,field(NULL,0.0e1,NULL)+0.0e1;
|
||||
field(NULL,"a",NULL) field(NULL,0,NULL)+0 field(NULL,0.0,NULL)+0.0 field(NULL,0.0e1,NULL)+0.0e1
|
||||
0 0 0.0 0
|
||||
select find_in_set("","a,b,c"),find_in_set("","a,b,c,"),find_in_set("",",a,b,c");
|
||||
find_in_set("","a,b,c") find_in_set("","a,b,c,") find_in_set("",",a,b,c")
|
||||
0 4 1
|
||||
select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc");
|
||||
find_in_set("abc","abc") find_in_set("ab","abc") find_in_set("abcd","abc")
|
||||
1 0 0
|
||||
select interval(null, 1, 10, 100);
|
||||
interval(null, 1, 10, 100)
|
||||
-1
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (id int(10) not null unique);
|
||||
create table t2 (id int(10) not null primary key, val int(10) not null);
|
||||
insert into t1 values (1),(2),(4);
|
||||
insert into t2 values (1,1),(2,1),(3,1),(4,2);
|
||||
select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id;
|
||||
id elt(two.val,'one','two')
|
||||
1 one
|
||||
2 one
|
||||
4 two
|
||||
select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
|
||||
id elt(two.val,'one','two')
|
||||
1 one
|
||||
2 one
|
||||
4 two
|
||||
drop table t1,t2;
|
||||
select find_in_set(binary 'a',binary 'A,B,C');
|
||||
find_in_set(binary 'a',binary 'A,B,C')
|
||||
0
|
||||
select find_in_set('a',binary 'A,B,C');
|
||||
find_in_set('a',binary 'A,B,C')
|
||||
0
|
||||
select find_in_set(binary 'a', 'A,B,C');
|
||||
find_in_set(binary 'a', 'A,B,C')
|
||||
0
|
||||
select find_in_set('1','3,1,');
|
||||
find_in_set('1','3,1,')
|
||||
2
|
||||
2262
mysql-test/suite/pbxt/r/func_str.result
Normal file
2262
mysql-test/suite/pbxt/r/func_str.result
Normal file
File diff suppressed because it is too large
Load Diff
97
mysql-test/suite/pbxt/r/func_system.result
Normal file
97
mysql-test/suite/pbxt/r/func_system.result
Normal file
@@ -0,0 +1,97 @@
|
||||
select database();
|
||||
database()
|
||||
test
|
||||
select charset(database());
|
||||
charset(database())
|
||||
utf8
|
||||
select database() = "test";
|
||||
database() = "test"
|
||||
1
|
||||
select database() = _utf8"test";
|
||||
database() = _utf8"test"
|
||||
1
|
||||
select database() = _latin1"test";
|
||||
database() = _latin1"test"
|
||||
1
|
||||
select user() like "%@%";
|
||||
user() like "%@%"
|
||||
1
|
||||
select user() like _utf8"%@%";
|
||||
user() like _utf8"%@%"
|
||||
1
|
||||
select user() like _latin1"%@%";
|
||||
user() like _latin1"%@%"
|
||||
1
|
||||
select charset(user());
|
||||
charset(user())
|
||||
utf8
|
||||
select version()>="3.23.29";
|
||||
version()>="3.23.29"
|
||||
1
|
||||
select version()>=_utf8"3.23.29";
|
||||
version()>=_utf8"3.23.29"
|
||||
1
|
||||
select version()>=_latin1"3.23.29";
|
||||
version()>=_latin1"3.23.29"
|
||||
1
|
||||
select charset(version());
|
||||
charset(version())
|
||||
utf8
|
||||
explain extended select database(), user();
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select database() AS `database()`,user() AS `user()`
|
||||
create table t1 (version char(60)) select database(), user(), version() as 'version';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`database()` varchar(34) CHARACTER SET utf8 DEFAULT NULL,
|
||||
`user()` varchar(77) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`version` char(60) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
select charset(charset(_utf8'a')), charset(collation(_utf8'a'));
|
||||
charset(charset(_utf8'a')) charset(collation(_utf8'a'))
|
||||
utf8 utf8
|
||||
select collation(charset(_utf8'a')), collation(collation(_utf8'a'));
|
||||
collation(charset(_utf8'a')) collation(collation(_utf8'a'))
|
||||
utf8_general_ci utf8_general_ci
|
||||
create table t1 select charset(_utf8'a'), collation(_utf8'a');
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`charset(_utf8'a')` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`collation(_utf8'a')` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
select TRUE,FALSE,NULL;
|
||||
TRUE FALSE NULL
|
||||
1 0 NULL
|
||||
create table t1 (c1 char(5)) character set=latin1;
|
||||
insert into t1 values('row 1');
|
||||
insert into t1 values('row 2');
|
||||
insert into t1 values('row 3');
|
||||
select concat(user(), '--', c1) from t1;
|
||||
concat(user(), '--', c1)
|
||||
root@localhost--row 1
|
||||
root@localhost--row 2
|
||||
root@localhost--row 3
|
||||
select concat(database(), '--', c1) from t1;
|
||||
concat(database(), '--', c1)
|
||||
test--row 1
|
||||
test--row 2
|
||||
test--row 3
|
||||
drop table t1;
|
||||
create table t1 (a char(10)) character set latin1;
|
||||
select * from t1 where a=version();
|
||||
a
|
||||
select * from t1 where a=database();
|
||||
a
|
||||
select * from t1 where a=user();
|
||||
a
|
||||
insert into t1 values ('a');
|
||||
select left(concat(a,version()),1) from t1;
|
||||
left(concat(a,version()),1)
|
||||
a
|
||||
drop table t1;
|
||||
13
mysql-test/suite/pbxt/r/func_timestamp.result
Normal file
13
mysql-test/suite/pbxt/r/func_timestamp.result
Normal file
@@ -0,0 +1,13 @@
|
||||
drop table if exists t1;
|
||||
set time_zone="+03:00";
|
||||
create table t1 (Zeit time, Tag tinyint not null, Monat tinyint not null,
|
||||
Jahr smallint not null, index(Tag), index(Monat), index(Jahr) );
|
||||
insert into t1 values ("09:26:00",16,9,1998),("09:26:00",16,9,1998);
|
||||
SELECT CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit) AS Date,
|
||||
UNIX_TIMESTAMP(CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit)) AS Unix
|
||||
FROM t1;
|
||||
Date Unix
|
||||
1998-9-16 09:26:00 905927160
|
||||
1998-9-16 09:26:00 905927160
|
||||
drop table t1;
|
||||
set time_zone= @@global.time_zone;
|
||||
20
mysql-test/suite/pbxt/r/gcc296.result
Normal file
20
mysql-test/suite/pbxt/r/gcc296.result
Normal file
@@ -0,0 +1,20 @@
|
||||
drop table if exists t1;
|
||||
CREATE TABLE t1 (
|
||||
kodoboru varchar(10) default NULL,
|
||||
obor tinytext,
|
||||
aobor tinytext,
|
||||
UNIQUE INDEX kodoboru (kodoboru),
|
||||
FULLTEXT KEY obor (obor),
|
||||
FULLTEXT KEY aobor (aobor)
|
||||
) engine=myisam;
|
||||
INSERT INTO t1 VALUES ('0101000000','aaa','AAA');
|
||||
INSERT INTO t1 VALUES ('0102000000','bbb','BBB');
|
||||
INSERT INTO t1 VALUES ('0103000000','ccc','CCC');
|
||||
INSERT INTO t1 VALUES ('0104000000','xxx','XXX');
|
||||
select * from t1;
|
||||
kodoboru obor aobor
|
||||
0101000000 aaa AAA
|
||||
0102000000 bbb BBB
|
||||
0103000000 ccc CCC
|
||||
0104000000 xxx XXX
|
||||
drop table t1;
|
||||
1040
mysql-test/suite/pbxt/r/grant.result
Normal file
1040
mysql-test/suite/pbxt/r/grant.result
Normal file
File diff suppressed because it is too large
Load Diff
210
mysql-test/suite/pbxt/r/grant_cache.result
Normal file
210
mysql-test/suite/pbxt/r/grant_cache.result
Normal file
@@ -0,0 +1,210 @@
|
||||
drop table if exists test.t1,mysqltest.t1,mysqltest.t2;
|
||||
drop database if exists mysqltest;
|
||||
set GLOBAL query_cache_size=1355776;
|
||||
reset query cache;
|
||||
flush status;
|
||||
show grants for current_user;
|
||||
Grants for root@localhost
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
|
||||
show grants;
|
||||
Grants for root@localhost
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
|
||||
create database if not exists mysqltest;
|
||||
create table mysqltest.t1 (a int,b int,c int);
|
||||
create table mysqltest.t2 (a int,b int,c int);
|
||||
insert into mysqltest.t1 values (1,1,1),(2,2,2);
|
||||
insert into mysqltest.t2 values (3,3,3);
|
||||
create table test.t1 (a char (10)) engine=myisam;
|
||||
insert into test.t1 values ("test.t1");
|
||||
select * from t1;
|
||||
a
|
||||
test.t1
|
||||
select * from t1;
|
||||
a b c
|
||||
1 1 1
|
||||
2 2 2
|
||||
select a from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
select c from t1;
|
||||
c
|
||||
1
|
||||
2
|
||||
select * from t2;
|
||||
a b c
|
||||
3 3 3
|
||||
select * from mysqltest.t1,test.t1;
|
||||
a b c a
|
||||
1 1 1 test.t1
|
||||
2 2 2 test.t1
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits%";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
grant SELECT on mysqltest.* to mysqltest_1@localhost;
|
||||
grant SELECT on mysqltest.t1 to mysqltest_2@localhost;
|
||||
grant SELECT on test.t1 to mysqltest_2@localhost;
|
||||
grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;
|
||||
show grants for current_user();
|
||||
Grants for mysqltest_1@localhost
|
||||
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
|
||||
GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 0
|
||||
select "user1";
|
||||
user1
|
||||
user1
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 1
|
||||
select * from t1;
|
||||
a b c
|
||||
1 1 1
|
||||
2 2 2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 1
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 1
|
||||
select a from t1 ;
|
||||
a
|
||||
1
|
||||
2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 2
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 1
|
||||
select c from t1;
|
||||
c
|
||||
1
|
||||
2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 3
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 1
|
||||
show grants for current_user();
|
||||
Grants for @localhost
|
||||
GRANT USAGE ON *.* TO ''@'localhost'
|
||||
select "user2";
|
||||
user2
|
||||
user2
|
||||
select * from t1;
|
||||
a b c
|
||||
1 1 1
|
||||
2 2 2
|
||||
select a from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
select c from t1;
|
||||
c
|
||||
1
|
||||
2
|
||||
select * from mysqltest.t1,test.t1;
|
||||
a b c a
|
||||
1 1 1 test.t1
|
||||
2 2 2 test.t1
|
||||
select * from t2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't2'
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 7
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 2
|
||||
select "user3";
|
||||
user3
|
||||
user3
|
||||
select * from t1;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 't1'
|
||||
select a from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
select c from t1;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'c' in table 't1'
|
||||
select * from t2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 't2'
|
||||
select mysqltest.t1.c from test.t1,mysqltest.t1;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'c' in table 't1'
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 7
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 7
|
||||
select "user4";
|
||||
user4
|
||||
user4
|
||||
show grants;
|
||||
Grants for mysqltest_1@localhost
|
||||
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
|
||||
GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
|
||||
select a from t1;
|
||||
ERROR 3D000: No database selected
|
||||
select * from mysqltest.t1,test.t1;
|
||||
a b c a
|
||||
1 1 1 test.t1
|
||||
2 2 2 test.t1
|
||||
select a from mysqltest.t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
select a from mysqltest.t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 8
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 8
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 8
|
||||
set names binary;
|
||||
delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
||||
delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
||||
delete from mysql.tables_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
||||
delete from mysql.columns_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
||||
flush privileges;
|
||||
drop table test.t1,mysqltest.t1,mysqltest.t2;
|
||||
drop database mysqltest;
|
||||
set GLOBAL query_cache_size=default;
|
||||
657
mysql-test/suite/pbxt/r/greedy_optimizer.result
Normal file
657
mysql-test/suite/pbxt/r/greedy_optimizer.result
Normal file
@@ -0,0 +1,657 @@
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7;
|
||||
create table t1 (
|
||||
c11 integer,c12 integer,c13 integer,c14 integer,c15 integer,c16 integer,
|
||||
primary key (c11)
|
||||
);
|
||||
create table t2 (
|
||||
c21 integer,c22 integer,c23 integer,c24 integer,c25 integer,c26 integer
|
||||
);
|
||||
create table t3 (
|
||||
c31 integer,c32 integer,c33 integer,c34 integer,c35 integer,c36 integer,
|
||||
primary key (c31)
|
||||
);
|
||||
create table t4 (
|
||||
c41 integer,c42 integer,c43 integer,c44 integer,c45 integer,c46 integer
|
||||
);
|
||||
create table t5 (
|
||||
c51 integer,c52 integer,c53 integer,c54 integer,c55 integer,c56 integer,
|
||||
primary key (c51)
|
||||
);
|
||||
create table t6 (
|
||||
c61 integer,c62 integer,c63 integer,c64 integer,c65 integer,c66 integer
|
||||
);
|
||||
create table t7 (
|
||||
c71 integer,c72 integer,c73 integer,c74 integer,c75 integer,c76 integer,
|
||||
primary key (c71)
|
||||
);
|
||||
insert into t1 values (1,2,3,4,5,6);
|
||||
insert into t1 values (2,2,3,4,5,6);
|
||||
insert into t1 values (3,2,3,4,5,6);
|
||||
insert into t2 values (1,2,3,4,5,6);
|
||||
insert into t2 values (2,2,3,4,5,6);
|
||||
insert into t2 values (3,2,3,4,5,6);
|
||||
insert into t2 values (4,2,3,4,5,6);
|
||||
insert into t2 values (5,2,3,4,5,6);
|
||||
insert into t2 values (6,2,3,4,5,6);
|
||||
insert into t3 values (1,2,3,4,5,6);
|
||||
insert into t3 values (2,2,3,4,5,6);
|
||||
insert into t3 values (3,2,3,4,5,6);
|
||||
insert into t3 values (4,2,3,4,5,6);
|
||||
insert into t3 values (5,2,3,4,5,6);
|
||||
insert into t3 values (6,2,3,4,5,6);
|
||||
insert into t3 values (7,2,3,4,5,6);
|
||||
insert into t3 values (8,2,3,4,5,6);
|
||||
insert into t3 values (9,2,3,4,5,6);
|
||||
insert into t4 values (1,2,3,4,5,6);
|
||||
insert into t4 values (2,2,3,4,5,6);
|
||||
insert into t4 values (3,2,3,4,5,6);
|
||||
insert into t4 values (4,2,3,4,5,6);
|
||||
insert into t4 values (5,2,3,4,5,6);
|
||||
insert into t4 values (6,2,3,4,5,6);
|
||||
insert into t4 values (7,2,3,4,5,6);
|
||||
insert into t4 values (8,2,3,4,5,6);
|
||||
insert into t4 values (9,2,3,4,5,6);
|
||||
insert into t4 values (10,2,3,4,5,6);
|
||||
insert into t4 values (11,2,3,4,5,6);
|
||||
insert into t4 values (12,2,3,4,5,6);
|
||||
insert into t5 values (1,2,3,4,5,6);
|
||||
insert into t5 values (2,2,3,4,5,6);
|
||||
insert into t5 values (3,2,3,4,5,6);
|
||||
insert into t5 values (4,2,3,4,5,6);
|
||||
insert into t5 values (5,2,3,4,5,6);
|
||||
insert into t5 values (6,2,3,4,5,6);
|
||||
insert into t5 values (7,2,3,4,5,6);
|
||||
insert into t5 values (8,2,3,4,5,6);
|
||||
insert into t5 values (9,2,3,4,5,6);
|
||||
insert into t5 values (10,2,3,4,5,6);
|
||||
insert into t5 values (11,2,3,4,5,6);
|
||||
insert into t5 values (12,2,3,4,5,6);
|
||||
insert into t5 values (13,2,3,4,5,6);
|
||||
insert into t5 values (14,2,3,4,5,6);
|
||||
insert into t5 values (15,2,3,4,5,6);
|
||||
insert into t6 values (1,2,3,4,5,6);
|
||||
insert into t6 values (2,2,3,4,5,6);
|
||||
insert into t6 values (3,2,3,4,5,6);
|
||||
insert into t6 values (4,2,3,4,5,6);
|
||||
insert into t6 values (5,2,3,4,5,6);
|
||||
insert into t6 values (6,2,3,4,5,6);
|
||||
insert into t6 values (7,2,3,4,5,6);
|
||||
insert into t6 values (8,2,3,4,5,6);
|
||||
insert into t6 values (9,2,3,4,5,6);
|
||||
insert into t6 values (10,2,3,4,5,6);
|
||||
insert into t6 values (11,2,3,4,5,6);
|
||||
insert into t6 values (12,2,3,4,5,6);
|
||||
insert into t6 values (13,2,3,4,5,6);
|
||||
insert into t6 values (14,2,3,4,5,6);
|
||||
insert into t6 values (15,2,3,4,5,6);
|
||||
insert into t6 values (16,2,3,4,5,6);
|
||||
insert into t6 values (17,2,3,4,5,6);
|
||||
insert into t6 values (18,2,3,4,5,6);
|
||||
insert into t7 values (1,2,3,4,5,6);
|
||||
insert into t7 values (2,2,3,4,5,6);
|
||||
insert into t7 values (3,2,3,4,5,6);
|
||||
insert into t7 values (4,2,3,4,5,6);
|
||||
insert into t7 values (5,2,3,4,5,6);
|
||||
insert into t7 values (6,2,3,4,5,6);
|
||||
insert into t7 values (7,2,3,4,5,6);
|
||||
insert into t7 values (8,2,3,4,5,6);
|
||||
insert into t7 values (9,2,3,4,5,6);
|
||||
insert into t7 values (10,2,3,4,5,6);
|
||||
insert into t7 values (11,2,3,4,5,6);
|
||||
insert into t7 values (12,2,3,4,5,6);
|
||||
insert into t7 values (13,2,3,4,5,6);
|
||||
insert into t7 values (14,2,3,4,5,6);
|
||||
insert into t7 values (15,2,3,4,5,6);
|
||||
insert into t7 values (16,2,3,4,5,6);
|
||||
insert into t7 values (17,2,3,4,5,6);
|
||||
insert into t7 values (18,2,3,4,5,6);
|
||||
insert into t7 values (19,2,3,4,5,6);
|
||||
insert into t7 values (20,2,3,4,5,6);
|
||||
insert into t7 values (21,2,3,4,5,6);
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
62
|
||||
select @@optimizer_prune_level;
|
||||
@@optimizer_prune_level
|
||||
1
|
||||
set optimizer_search_depth=63;
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
63
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
set optimizer_prune_level=0;
|
||||
select @@optimizer_prune_level;
|
||||
@@optimizer_prune_level
|
||||
0
|
||||
set optimizer_search_depth=0;
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
0
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using join buffer
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 290.146368
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using join buffer
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 290.146368
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 290.146368
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 290.146368
|
||||
set optimizer_search_depth=1;
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
1
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
set optimizer_search_depth=62;
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
62
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using join buffer
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 290.146368
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using join buffer
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 290.146368
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 290.146368
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 290.146368
|
||||
set optimizer_prune_level=1;
|
||||
select @@optimizer_prune_level;
|
||||
@@optimizer_prune_level
|
||||
1
|
||||
set optimizer_search_depth=0;
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
0
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
set optimizer_search_depth=1;
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
1
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
set optimizer_search_depth=62;
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
62
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
drop table t1,t2,t3,t4,t5,t6,t7;
|
||||
944
mysql-test/suite/pbxt/r/group_by.result
Normal file
944
mysql-test/suite/pbxt/r/group_by.result
Normal file
@@ -0,0 +1,944 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
SELECT 1 FROM (SELECT 1) as a GROUP BY SUM(1);
|
||||
ERROR HY000: Invalid use of group function
|
||||
CREATE TABLE t1 (
|
||||
spID int(10) unsigned,
|
||||
userID int(10) unsigned,
|
||||
score smallint(5) unsigned,
|
||||
lsg char(40),
|
||||
date date
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,1,1,'','0000-00-00');
|
||||
INSERT INTO t1 VALUES (2,2,2,'','0000-00-00');
|
||||
INSERT INTO t1 VALUES (2,1,1,'','0000-00-00');
|
||||
INSERT INTO t1 VALUES (3,3,3,'','0000-00-00');
|
||||
CREATE TABLE t2 (
|
||||
userID int(10) unsigned NOT NULL auto_increment,
|
||||
niName char(15),
|
||||
passwd char(8),
|
||||
mail char(50),
|
||||
isAukt enum('N','Y') DEFAULT 'N',
|
||||
vName char(30),
|
||||
nName char(40),
|
||||
adr char(60),
|
||||
plz char(5),
|
||||
ort char(35),
|
||||
land char(20),
|
||||
PRIMARY KEY (userID)
|
||||
);
|
||||
INSERT INTO t2 VALUES (1,'name','pass','mail','Y','v','n','adr','1','1','1');
|
||||
INSERT INTO t2 VALUES (2,'name','pass','mail','Y','v','n','adr','1','1','1');
|
||||
INSERT INTO t2 VALUES (3,'name','pass','mail','Y','v','n','adr','1','1','1');
|
||||
INSERT INTO t2 VALUES (4,'name','pass','mail','Y','v','n','adr','1','1','1');
|
||||
INSERT INTO t2 VALUES (5,'name','pass','mail','Y','v','n','adr','1','1','1');
|
||||
SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid;
|
||||
userid MIN(t1.score)
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid ORDER BY NULL;
|
||||
userid MIN(t1.score)
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid;
|
||||
userid MIN(t1.score)
|
||||
1 1
|
||||
2 2
|
||||
SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid;
|
||||
userid MIN(t1.score+0.0)
|
||||
1 1.0
|
||||
2 2.0
|
||||
SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
|
||||
userid MIN(t1.score+0.0)
|
||||
2 2.0
|
||||
1 1.0
|
||||
EXPLAIN SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; Using temporary
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.userID 1 Using index
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (
|
||||
PID int(10) unsigned NOT NULL auto_increment,
|
||||
payDate date DEFAULT '0000-00-00' NOT NULL,
|
||||
recDate datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
||||
URID int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
CRID int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
amount int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
operator int(10) unsigned,
|
||||
method enum('unknown','cash','dealer','check','card','lazy','delayed','test') DEFAULT 'unknown' NOT NULL,
|
||||
DIID int(10) unsigned,
|
||||
reason char(1) binary DEFAULT '' NOT NULL,
|
||||
code_id int(10) unsigned,
|
||||
qty mediumint(8) unsigned DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (PID),
|
||||
KEY URID (URID),
|
||||
KEY reason (reason),
|
||||
KEY method (method),
|
||||
KEY payDate (payDate)
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,'1970-01-01','1997-10-17 00:00:00',2529,1,21000,11886,'check',0,'F',16200,6);
|
||||
SELECT COUNT(P.URID),SUM(P.amount),P.method, MIN(PP.recdate+0) > 19980501000000 AS IsNew FROM t1 AS P JOIN t1 as PP WHERE P.URID = PP.URID GROUP BY method,IsNew;
|
||||
ERROR 42000: Can't group on 'IsNew'
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
cid mediumint(9) NOT NULL auto_increment,
|
||||
firstname varchar(32) DEFAULT '' NOT NULL,
|
||||
surname varchar(32) DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (cid)
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,'That','Guy');
|
||||
INSERT INTO t1 VALUES (2,'Another','Gent');
|
||||
CREATE TABLE t2 (
|
||||
call_id mediumint(8) NOT NULL auto_increment,
|
||||
contact_id mediumint(8) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (call_id),
|
||||
KEY contact_id (contact_id)
|
||||
);
|
||||
lock tables t1 read,t2 write;
|
||||
INSERT INTO t2 VALUES (10,2);
|
||||
INSERT INTO t2 VALUES (18,2);
|
||||
INSERT INTO t2 VALUES (62,2);
|
||||
INSERT INTO t2 VALUES (91,2);
|
||||
INSERT INTO t2 VALUES (92,2);
|
||||
SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid;
|
||||
cid CONCAT(firstname, ' ', surname) COUNT(call_id)
|
||||
SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY NULL;
|
||||
cid CONCAT(firstname, ' ', surname) COUNT(call_id)
|
||||
SELECT HIGH_PRIORITY cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname;
|
||||
cid CONCAT(firstname, ' ', surname) COUNT(call_id)
|
||||
drop table t1,t2;
|
||||
unlock tables;
|
||||
CREATE TABLE t1 (
|
||||
bug_id mediumint(9) NOT NULL auto_increment,
|
||||
groupset bigint(20) DEFAULT '0' NOT NULL,
|
||||
assigned_to mediumint(9) DEFAULT '0' NOT NULL,
|
||||
bug_file_loc text,
|
||||
bug_severity enum('blocker','critical','major','normal','minor','trivial','enhancement') DEFAULT 'blocker' NOT NULL,
|
||||
bug_status enum('','NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') DEFAULT 'NEW' NOT NULL,
|
||||
creation_ts datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
||||
delta_ts timestamp,
|
||||
short_desc mediumtext,
|
||||
long_desc mediumtext,
|
||||
op_sys enum('All','Windows 3.1','Windows 95','Windows 98','Windows NT','Windows 2000','Linux','other') DEFAULT 'All' NOT NULL,
|
||||
priority enum('P1','P2','P3','P4','P5') DEFAULT 'P1' NOT NULL,
|
||||
product varchar(64) DEFAULT '' NOT NULL,
|
||||
rep_platform enum('All','PC','VTD-8','Other'),
|
||||
reporter mediumint(9) DEFAULT '0' NOT NULL,
|
||||
version varchar(16) DEFAULT '' NOT NULL,
|
||||
component varchar(50) DEFAULT '' NOT NULL,
|
||||
resolution enum('','FIXED','INVALID','WONTFIX','LATER','REMIND','DUPLICATE','WORKSFORME') DEFAULT '' NOT NULL,
|
||||
target_milestone varchar(20) DEFAULT '' NOT NULL,
|
||||
qa_contact mediumint(9) DEFAULT '0' NOT NULL,
|
||||
status_whiteboard mediumtext NOT NULL,
|
||||
votes mediumint(9) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (bug_id),
|
||||
KEY assigned_to (assigned_to),
|
||||
KEY creation_ts (creation_ts),
|
||||
KEY delta_ts (delta_ts),
|
||||
KEY bug_severity (bug_severity),
|
||||
KEY bug_status (bug_status),
|
||||
KEY op_sys (op_sys),
|
||||
KEY priority (priority),
|
||||
KEY product (product),
|
||||
KEY reporter (reporter),
|
||||
KEY version (version),
|
||||
KEY component (component),
|
||||
KEY resolution (resolution),
|
||||
KEY target_milestone (target_milestone),
|
||||
KEY qa_contact (qa_contact),
|
||||
KEY votes (votes)
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,0,0,'','normal','','2000-02-10 09:25:12',20000321114747,'','','Linux','P1','TestProduct','PC',3,'other','TestComponent','','M1',0,'',0);
|
||||
INSERT INTO t1 VALUES (9,0,0,'','enhancement','','2000-03-10 11:49:36',20000321114747,'','','All','P5','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (10,0,0,'','enhancement','','2000-03-10 18:10:16',20000321114747,'','','All','P4','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (7,0,0,'','critical','','2000-03-09 10:50:21',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (6,0,0,'','normal','','2000-03-09 10:42:44',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (8,0,0,'','major','','2000-03-09 11:32:14',20000321114747,'','','All','P3','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (5,0,0,'','enhancement','','2000-03-09 10:38:59',20000321114747,'','','All','P5','CCC/CCCCCC','PC',5,'7.00','Administration','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (4,0,0,'','normal','','2000-03-08 18:32:14',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent2','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (3,0,0,'','normal','','2000-03-08 18:30:52',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (2,0,0,'','enhancement','','2000-03-08 18:24:51',20000321114747,'','','All','P2','TestProduct','Other',4,'other','TestComponent2','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (11,0,0,'','blocker','','2000-03-13 09:43:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (12,0,0,'','normal','','2000-03-13 16:14:31',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (13,0,0,'','normal','','2000-03-15 16:20:44',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (14,0,0,'','blocker','','2000-03-15 18:13:47',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (15,0,0,'','minor','','2000-03-16 18:03:28',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (16,0,0,'','normal','','2000-03-16 18:33:41',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (17,0,0,'','normal','','2000-03-16 18:34:18',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (18,0,0,'','normal','','2000-03-16 18:34:56',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (19,0,0,'','enhancement','','2000-03-16 18:35:34',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (20,0,0,'','enhancement','','2000-03-16 18:36:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (21,0,0,'','enhancement','','2000-03-16 18:37:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (22,0,0,'','enhancement','','2000-03-16 18:38:16',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (23,0,0,'','normal','','2000-03-16 18:58:12',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (24,0,0,'','normal','','2000-03-17 11:08:10',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (25,0,0,'','normal','','2000-03-17 11:10:45',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (26,0,0,'','normal','','2000-03-17 11:15:47',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (27,0,0,'','normal','','2000-03-17 17:45:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (28,0,0,'','normal','','2000-03-20 09:51:45',20000321114747,'','','Windows NT','P2','TestProduct','PC',8,'other','TestComponent','','',0,'',0);
|
||||
INSERT INTO t1 VALUES (29,0,0,'','normal','','2000-03-20 11:15:09',20000321114747,'','','All','P5','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
|
||||
CREATE TABLE t2 (
|
||||
value tinytext,
|
||||
program varchar(64),
|
||||
initialowner tinytext NOT NULL,
|
||||
initialqacontact tinytext NOT NULL,
|
||||
description mediumtext NOT NULL
|
||||
);
|
||||
INSERT INTO t2 VALUES ('TestComponent','TestProduct','id0001','','');
|
||||
INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - conversion','AAAAA','id0001','','');
|
||||
INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - generic','AAAAA','id0001','','');
|
||||
INSERT INTO t2 VALUES ('TestComponent2','TestProduct','id0001','','');
|
||||
INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - eeeeeeeee','AAAAA','id0001','','');
|
||||
INSERT INTO t2 VALUES ('kkkkkkkkkkk lllllllllll','AAAAA','id0001','','');
|
||||
INSERT INTO t2 VALUES ('Test Procedures','AAAAA','id0001','','');
|
||||
INSERT INTO t2 VALUES ('Documentation','AAAAA','id0003','','');
|
||||
INSERT INTO t2 VALUES ('DDDDDDDDD','CCC/CCCCCC','id0002','','');
|
||||
INSERT INTO t2 VALUES ('Eeeeeeee Lite','CCC/CCCCCC','id0002','','');
|
||||
INSERT INTO t2 VALUES ('Eeeeeeee Full','CCC/CCCCCC','id0002','','');
|
||||
INSERT INTO t2 VALUES ('Administration','CCC/CCCCCC','id0002','','');
|
||||
INSERT INTO t2 VALUES ('Distribution','CCC/CCCCCC','id0002','','');
|
||||
INSERT INTO t2 VALUES ('Setup','CCC/CCCCCC','id0002','','');
|
||||
INSERT INTO t2 VALUES ('Unspecified','CCC/CCCCCC','id0002','','');
|
||||
INSERT INTO t2 VALUES ('Web Interface','AAAAAAAA-AAA','id0001','','');
|
||||
INSERT INTO t2 VALUES ('Host communication','AAAAA','id0001','','');
|
||||
select value,description,bug_id from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA";
|
||||
value description bug_id
|
||||
BBBBBBBBBBBBB - conversion 9
|
||||
BBBBBBBBBBBBB - conversion 10
|
||||
BBBBBBBBBBBBB - generic 7
|
||||
BBBBBBBBBBBBB - generic 14
|
||||
BBBBBBBBBBBBB - eeeeeeeee NULL
|
||||
kkkkkkkkkkk lllllllllll 6
|
||||
kkkkkkkkkkk lllllllllll 8
|
||||
kkkkkkkkkkk lllllllllll 12
|
||||
Test Procedures NULL
|
||||
Documentation NULL
|
||||
Host communication NULL
|
||||
select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value;
|
||||
value description COUNT(bug_id)
|
||||
BBBBBBBBBBBBB - conversion 2
|
||||
BBBBBBBBBBBBB - eeeeeeeee 0
|
||||
BBBBBBBBBBBBB - generic 2
|
||||
Documentation 0
|
||||
Host communication 0
|
||||
kkkkkkkkkkk lllllllllll 3
|
||||
Test Procedures 0
|
||||
select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value having COUNT(bug_id) IN (0,2);
|
||||
value description COUNT(bug_id)
|
||||
BBBBBBBBBBBBB - conversion 2
|
||||
BBBBBBBBBBBBB - eeeeeeeee 0
|
||||
BBBBBBBBBBBBB - generic 2
|
||||
Documentation 0
|
||||
Host communication 0
|
||||
Test Procedures 0
|
||||
drop table t1,t2;
|
||||
create table t1 (foo int);
|
||||
insert into t1 values (1);
|
||||
select 1+1, "a",count(*) from t1 where foo in (2);
|
||||
1+1 a count(*)
|
||||
2 a 0
|
||||
insert into t1 values (1);
|
||||
select 1+1,"a",count(*) from t1 where foo in (2);
|
||||
1+1 a count(*)
|
||||
2 a 0
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
spID int(10) unsigned,
|
||||
userID int(10) unsigned,
|
||||
score smallint(5) unsigned,
|
||||
key (spid),
|
||||
key (score)
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3),(6,3,3),(7,3,3);
|
||||
explain select userid,count(*) from t1 group by userid desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort
|
||||
explain select userid,count(*) from t1 group by userid desc order by null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary
|
||||
select userid,count(*) from t1 group by userid desc;
|
||||
userid count(*)
|
||||
3 5
|
||||
2 1
|
||||
1 2
|
||||
select userid,count(*) from t1 group by userid desc having (count(*)+1) IN (4,3);
|
||||
userid count(*)
|
||||
1 2
|
||||
select userid,count(*) from t1 group by userid desc having 3 IN (1,COUNT(*));
|
||||
userid count(*)
|
||||
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range spID spID 5 NULL 1 Using where; Using index
|
||||
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range spID spID 5 NULL 1 Using where; Using index
|
||||
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range spID spID 5 NULL 1 Using where; Using index
|
||||
select spid,count(*) from t1 where spid between 1 and 2 group by spid;
|
||||
spid count(*)
|
||||
1 1
|
||||
2 2
|
||||
select spid,count(*) from t1 where spid between 1 and 2 group by spid desc;
|
||||
spid count(*)
|
||||
2 2
|
||||
1 1
|
||||
explain extended select sql_big_result spid,sum(userid) from t1 group by spid desc;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using filesort
|
||||
Warnings:
|
||||
Note 1003 select sql_big_result `test`.`t1`.`spID` AS `spid`,sum(`test`.`t1`.`userID`) AS `sum(userid)` from `test`.`t1` group by `test`.`t1`.`spID` desc
|
||||
explain select sql_big_result spid,sum(userid) from t1 group by spid desc order by null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using filesort
|
||||
select sql_big_result spid,sum(userid) from t1 group by spid desc;
|
||||
spid sum(userid)
|
||||
7 3
|
||||
6 3
|
||||
5 3
|
||||
4 3
|
||||
3 3
|
||||
2 3
|
||||
1 1
|
||||
explain select sql_big_result score,count(*) from t1 group by score desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL score 3 NULL 8 Using index; Using filesort
|
||||
explain select sql_big_result score,count(*) from t1 group by score desc order by null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL score 3 NULL 8 Using index; Using filesort
|
||||
select sql_big_result score,count(*) from t1 group by score desc;
|
||||
score count(*)
|
||||
3 5
|
||||
2 1
|
||||
1 2
|
||||
drop table t1;
|
||||
create table t1 (a date default null, b date default null);
|
||||
insert t1 values ('1999-10-01','2000-01-10'), ('1997-01-01','1998-10-01');
|
||||
select a,min(b) c,count(distinct rand()) from t1 group by a having c<a + interval 1 day;
|
||||
a c count(distinct rand())
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a char(1));
|
||||
INSERT INTO t1 VALUES ('A'),('B'),('A'),('B'),('A'),('B'),(NULL),('a'),('b'),(NULL),('A'),('B'),(NULL);
|
||||
SELECT a FROM t1 GROUP BY a;
|
||||
a
|
||||
NULL
|
||||
A
|
||||
B
|
||||
SELECT a,count(*) FROM t1 GROUP BY a;
|
||||
a count(*)
|
||||
NULL 3
|
||||
A 5
|
||||
B 5
|
||||
SELECT a FROM t1 GROUP BY binary a;
|
||||
a
|
||||
NULL
|
||||
A
|
||||
B
|
||||
a
|
||||
b
|
||||
SELECT a,count(*) FROM t1 GROUP BY binary a;
|
||||
a count(*)
|
||||
NULL 3
|
||||
A 4
|
||||
B 4
|
||||
a 1
|
||||
b 1
|
||||
SELECT binary a FROM t1 GROUP BY 1;
|
||||
binary a
|
||||
NULL
|
||||
A
|
||||
B
|
||||
a
|
||||
b
|
||||
SELECT binary a,count(*) FROM t1 GROUP BY 1;
|
||||
binary a count(*)
|
||||
NULL 3
|
||||
A 4
|
||||
B 4
|
||||
a 1
|
||||
b 1
|
||||
SET SQL_BIG_TABLES=1;
|
||||
SELECT a FROM t1 GROUP BY a;
|
||||
a
|
||||
NULL
|
||||
A
|
||||
B
|
||||
SELECT a,count(*) FROM t1 GROUP BY a;
|
||||
a count(*)
|
||||
NULL 3
|
||||
A 5
|
||||
B 5
|
||||
SELECT a FROM t1 GROUP BY binary a;
|
||||
a
|
||||
NULL
|
||||
A
|
||||
B
|
||||
a
|
||||
b
|
||||
SELECT a,count(*) FROM t1 GROUP BY binary a;
|
||||
a count(*)
|
||||
NULL 3
|
||||
A 4
|
||||
B 4
|
||||
a 1
|
||||
b 1
|
||||
SELECT binary a FROM t1 GROUP BY 1;
|
||||
binary a
|
||||
NULL
|
||||
A
|
||||
B
|
||||
a
|
||||
b
|
||||
SELECT binary a,count(*) FROM t1 GROUP BY 1;
|
||||
binary a count(*)
|
||||
NULL 3
|
||||
A 4
|
||||
B 4
|
||||
a 1
|
||||
b 1
|
||||
SET SQL_BIG_TABLES=0;
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
`a` char(193) default NULL,
|
||||
`b` char(63) default NULL
|
||||
);
|
||||
INSERT INTO t1 VALUES ('abc','def'),('hij','klm');
|
||||
SELECT CONCAT(a, b) FROM t1 GROUP BY 1;
|
||||
CONCAT(a, b)
|
||||
abcdef
|
||||
hijklm
|
||||
SELECT CONCAT(a, b),count(*) FROM t1 GROUP BY 1;
|
||||
CONCAT(a, b) count(*)
|
||||
abcdef 1
|
||||
hijklm 1
|
||||
SELECT CONCAT(a, b),count(distinct a) FROM t1 GROUP BY 1;
|
||||
CONCAT(a, b) count(distinct a)
|
||||
abcdef 1
|
||||
hijklm 1
|
||||
SELECT 1 FROM t1 GROUP BY CONCAT(a, b);
|
||||
1
|
||||
1
|
||||
1
|
||||
INSERT INTO t1 values ('hij','klm');
|
||||
SELECT CONCAT(a, b),count(*) FROM t1 GROUP BY 1;
|
||||
CONCAT(a, b) count(*)
|
||||
abcdef 1
|
||||
hijklm 2
|
||||
DROP TABLE t1;
|
||||
create table t1 (One int unsigned, Two int unsigned, Three int unsigned, Four int unsigned);
|
||||
insert into t1 values (1,2,1,4),(1,2,2,4),(1,2,3,4),(1,2,4,4),(1,1,1,4),(1,1,2,4),(1,1,3,4),(1,1,4,4),(1,3,1,4),(1,3,2,4),(1,3,3,4),(1,3,4,4);
|
||||
select One, Two, sum(Four) from t1 group by One,Two;
|
||||
One Two sum(Four)
|
||||
1 1 16
|
||||
1 2 16
|
||||
1 3 16
|
||||
drop table t1;
|
||||
create table t1 (id integer primary key not null auto_increment, gender char(1));
|
||||
insert into t1 values (NULL, 'M'), (NULL, 'F'),(NULL, 'F'),(NULL, 'F'),(NULL, 'M');
|
||||
create table t2 (user_id integer not null, date date);
|
||||
insert into t2 values (1, '2002-06-09'),(2, '2002-06-09'),(1, '2002-06-09'),(3, '2002-06-09'),(4, '2002-06-09'),(4, '2002-06-09');
|
||||
select u.gender as gender, count(distinct u.id) as dist_count, (count(distinct u.id)/5*100) as percentage from t1 u, t2 l where l.user_id = u.id group by u.gender;
|
||||
gender dist_count percentage
|
||||
F 3 60.0000
|
||||
M 1 20.0000
|
||||
select u.gender as gender, count(distinct u.id) as dist_count, (count(distinct u.id)/5*100) as percentage from t1 u, t2 l where l.user_id = u.id group by u.gender order by percentage;
|
||||
gender dist_count percentage
|
||||
M 1 20.0000
|
||||
F 3 60.0000
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (ID1 int, ID2 int, ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID
|
||||
));
|
||||
insert into t1 values (1,244,NULL),(2,243,NULL),(134,223,NULL),(185,186,NULL);
|
||||
select S.ID as xID, S.ID1 as xID1 from t1 as S left join t1 as yS on S.ID1 between yS.ID1 and yS.ID2;
|
||||
xID xID1
|
||||
1 1
|
||||
2 2
|
||||
2 2
|
||||
3 134
|
||||
3 134
|
||||
3 134
|
||||
4 185
|
||||
4 185
|
||||
4 185
|
||||
4 185
|
||||
select S.ID as xID, S.ID1 as xID1, repeat('*',count(distinct yS.ID)) as Level from t1 as S left join t1 as yS on S.ID1 between yS.ID1 and yS.ID2 group by xID order by xID1;
|
||||
xID xID1 Level
|
||||
1 1 *
|
||||
2 2 **
|
||||
3 134 ***
|
||||
4 185 ****
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
pid int(11) unsigned NOT NULL default '0',
|
||||
c1id int(11) unsigned default NULL,
|
||||
c2id int(11) unsigned default NULL,
|
||||
value int(11) unsigned NOT NULL default '0',
|
||||
UNIQUE KEY pid2 (pid,c1id,c2id),
|
||||
UNIQUE KEY pid (pid,value)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1, 1, NULL, 1),(1, 2, NULL, 2),(1, NULL, 3, 3),(1, 4, NULL, 4),(1, 5, NULL, 5);
|
||||
CREATE TABLE t2 (
|
||||
id int(11) unsigned NOT NULL default '0',
|
||||
active enum('Yes','No') NOT NULL default 'Yes',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1, 'Yes'),(2, 'No'),(4, 'Yes'),(5, 'No');
|
||||
CREATE TABLE t3 (
|
||||
id int(11) unsigned NOT NULL default '0',
|
||||
active enum('Yes','No') NOT NULL default 'Yes',
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
INSERT INTO t3 VALUES (3, 'Yes');
|
||||
select * from t1 AS m LEFT JOIN t2 AS c1 ON m.c1id =
|
||||
c1.id AND c1.active = 'Yes' LEFT JOIN t3 AS c2 ON m.c2id = c2.id AND
|
||||
c2.active = 'Yes' WHERE m.pid=1 AND (c1.id IS NOT NULL OR c2.id IS NOT NULL);
|
||||
pid c1id c2id value id active id active
|
||||
1 1 NULL 1 1 Yes NULL NULL
|
||||
1 NULL 3 3 NULL NULL 3 Yes
|
||||
1 4 NULL 4 4 Yes NULL NULL
|
||||
select max(value) from t1 AS m LEFT JOIN t2 AS c1 ON
|
||||
m.c1id = c1.id AND c1.active = 'Yes' LEFT JOIN t3 AS c2 ON m.c2id =
|
||||
c2.id AND c2.active = 'Yes' WHERE m.pid=1 AND (c1.id IS NOT NULL OR c2.id IS
|
||||
NOT NULL);
|
||||
max(value)
|
||||
4
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (a blob null);
|
||||
insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(""),(""),(""),("b");
|
||||
select a,count(*) from t1 group by a;
|
||||
a count(*)
|
||||
NULL 9
|
||||
3
|
||||
b 1
|
||||
set option sql_big_tables=1;
|
||||
select a,count(*) from t1 group by a;
|
||||
a count(*)
|
||||
NULL 9
|
||||
3
|
||||
b 1
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b int not null);
|
||||
insert into t1 values (1,1),(1,2),(3,1),(3,2),(2,2),(2,1);
|
||||
create table t2 (a int not null, b int not null, key(a));
|
||||
insert into t2 values (1,3),(3,1),(2,2),(1,1);
|
||||
select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b;
|
||||
a b
|
||||
1 1
|
||||
1 3
|
||||
2 2
|
||||
3 1
|
||||
select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL;
|
||||
a b
|
||||
1 3
|
||||
3 1
|
||||
2 2
|
||||
1 1
|
||||
explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
|
||||
1 SIMPLE t2 ALL a NULL NULL NULL 4 Using where; Using join buffer
|
||||
explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary
|
||||
1 SIMPLE t2 ALL a NULL NULL NULL 4 Using where; Using join buffer
|
||||
drop table t1,t2;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1, 4),(10, 40),(1, 4),(10, 43),(1, 4),(10, 41),(1, 4),(10, 43),(1, 4);
|
||||
select a, MAX(b), INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000) from t1 group by a;
|
||||
a MAX(b) INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000)
|
||||
1 4 2
|
||||
10 43 6
|
||||
select a, MAX(b), CASE MAX(b) when 4 then 4 when 43 then 43 else 0 end from t1 group by a;
|
||||
a MAX(b) CASE MAX(b) when 4 then 4 when 43 then 43 else 0 end
|
||||
1 4 4
|
||||
10 43 43
|
||||
select a, MAX(b), FIELD(MAX(b), '43', '4', '5') from t1 group by a;
|
||||
a MAX(b) FIELD(MAX(b), '43', '4', '5')
|
||||
1 4 2
|
||||
10 43 1
|
||||
select a, MAX(b), CONCAT_WS(MAX(b), '43', '4', '5') from t1 group by a;
|
||||
a MAX(b) CONCAT_WS(MAX(b), '43', '4', '5')
|
||||
1 4 434445
|
||||
10 43 43434435
|
||||
select a, MAX(b), ELT(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f') from t1 group by a;
|
||||
a MAX(b) ELT(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f')
|
||||
1 4 d
|
||||
10 43 NULL
|
||||
select a, MAX(b), MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') from t1 group by a;
|
||||
a MAX(b) MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
|
||||
1 4 c
|
||||
10 43 a,b,d,f
|
||||
drop table t1;
|
||||
create table t1 (id int not null, qty int not null);
|
||||
insert into t1 values (1,2),(1,3),(2,4),(2,5);
|
||||
select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(qty)>2 and cqty>1;
|
||||
id sqty cqty
|
||||
1 5 2
|
||||
2 9 2
|
||||
select id, sum(qty) as sqty from t1 group by id having sqty>2 and count(qty)>1;
|
||||
id sqty
|
||||
1 5
|
||||
2 9
|
||||
select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sqty>2 and cqty>1;
|
||||
id sqty cqty
|
||||
1 5 2
|
||||
2 9 2
|
||||
select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(qty)>2 and count(qty)>1;
|
||||
id sqty cqty
|
||||
1 5 2
|
||||
2 9 2
|
||||
select count(*), case interval(qty,2,3,4,5,6,7,8) when -1 then NULL when 0 then "zero" when 1 then "one" when 2 then "two" end as category from t1 group by category;
|
||||
count(*) category
|
||||
2 NULL
|
||||
1 one
|
||||
1 two
|
||||
select count(*), interval(qty,2,3,4,5,6,7,8) as category from t1 group by category;
|
||||
count(*) category
|
||||
1 1
|
||||
1 2
|
||||
1 3
|
||||
1 4
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
userid int(10) unsigned,
|
||||
score smallint(5) unsigned,
|
||||
key (score)
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,1),(2,2),(1,1),(3,3),(3,3),(3,3),(3,3),(3,3);
|
||||
SELECT userid,count(*) FROM t1 GROUP BY userid DESC;
|
||||
userid count(*)
|
||||
3 5
|
||||
2 1
|
||||
1 2
|
||||
EXPLAIN SELECT userid,count(*) FROM t1 GROUP BY userid DESC;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
i int(11) default NULL,
|
||||
j int(11) default NULL
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,2),(2,3),(4,5),(3,5),(1,5),(23,5);
|
||||
SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL;
|
||||
i COUNT(DISTINCT(i))
|
||||
1 1
|
||||
2 1
|
||||
4 4
|
||||
explain SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values(null);
|
||||
select min(a) is null from t1;
|
||||
min(a) is null
|
||||
1
|
||||
select min(a) is null or null from t1;
|
||||
min(a) is null or null
|
||||
1
|
||||
select 1 and min(a) is null from t1;
|
||||
1 and min(a) is null
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 ( col1 int, col2 int );
|
||||
insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2);
|
||||
select group_concat( distinct col1 ) as alias from t1
|
||||
group by col2 having alias like '%';
|
||||
alias
|
||||
1,2
|
||||
1,2
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (a integer, b integer, c integer);
|
||||
insert into t1 (a,b) values (1,2),(1,3),(2,5);
|
||||
select a, 0.1*0+1 r2, sum(1) r1 from t1 where a = 1 group by a having r1>1 and r2=1;
|
||||
a r2 r1
|
||||
1 1.0 2
|
||||
select a, round(rand(100)*10) r2, sum(1) r1 from t1 where a = 1 group by a having r1>1 and r2<=2;
|
||||
a r2 r1
|
||||
1 2 2
|
||||
select a,sum(b) from t1 where a=1 group by c;
|
||||
a sum(b)
|
||||
1 5
|
||||
select a*sum(b) from t1 where a=1 group by c;
|
||||
a*sum(b)
|
||||
5
|
||||
select sum(a)*sum(b) from t1 where a=1 group by c;
|
||||
sum(a)*sum(b)
|
||||
10
|
||||
select a,sum(b) from t1 where a=1 group by c having a=1;
|
||||
a sum(b)
|
||||
1 5
|
||||
select a as d,sum(b) from t1 where a=1 group by c having d=1;
|
||||
d sum(b)
|
||||
1 5
|
||||
select sum(a)*sum(b) as d from t1 where a=1 group by c having d > 0;
|
||||
d
|
||||
10
|
||||
drop table t1;
|
||||
create table t1(a int);
|
||||
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(8),(9);
|
||||
create table t2 (
|
||||
a int,
|
||||
b varchar(200) NOT NULL,
|
||||
c varchar(50) NOT NULL,
|
||||
d varchar(100) NOT NULL,
|
||||
primary key (a,b(132),c,d),
|
||||
key a (a,b)
|
||||
) charset=utf8;
|
||||
insert into t2 select
|
||||
x3.a, -- 3
|
||||
concat('val-', x3.a + 3*x4.a), -- 12
|
||||
concat('val-', @a:=x3.a + 3*x4.a + 12*C.a), -- 120
|
||||
concat('val-', @a + 120*D.a)
|
||||
from t1 x3, t1 x4, t1 C, t1 D where x3.a < 3 and x4.a < 4 and D.a < 4;
|
||||
delete from t2 where a = 2 and b = 'val-2' order by a,b,c,d limit 30;
|
||||
explain select c from t2 where a = 2 and b = 'val-2' group by c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref PRIMARY,a PRIMARY 402 const,const # Using where
|
||||
select c from t2 where a = 2 and b = 'val-2' group by c;
|
||||
c
|
||||
val-74
|
||||
val-98
|
||||
drop table t1,t2;
|
||||
create table t1 (b int4 unsigned not null);
|
||||
insert into t1 values(3000000000);
|
||||
select * from t1;
|
||||
b
|
||||
3000000000
|
||||
select min(b) from t1;
|
||||
min(b)
|
||||
3000000000
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (id int PRIMARY KEY, user_id int, hostname longtext);
|
||||
INSERT INTO t1 VALUES
|
||||
(1, 7, 'cache-dtc-af05.proxy.aol.com'),
|
||||
(2, 3, 'what.ever.com'),
|
||||
(3, 7, 'cache-dtc-af05.proxy.aol.com'),
|
||||
(4, 7, 'cache-dtc-af05.proxy.aol.com');
|
||||
SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1
|
||||
WHERE hostname LIKE '%aol%'
|
||||
GROUP BY hostname;
|
||||
hostname no
|
||||
cache-dtc-af05.proxy.aol.com 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
INSERT INTO t1 VALUES (1,2), (1,3);
|
||||
SELECT a, b FROM t1 GROUP BY 'const';
|
||||
a b
|
||||
1 2
|
||||
SELECT DISTINCT a, b FROM t1 GROUP BY 'const';
|
||||
a b
|
||||
1 2
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (id INT, dt DATETIME);
|
||||
INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' );
|
||||
INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' );
|
||||
INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' );
|
||||
INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' );
|
||||
SELECT dt DIV 1 AS f, id FROM t1 GROUP BY f;
|
||||
f id
|
||||
20050501123000 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (id varchar(20) NOT NULL);
|
||||
INSERT INTO t1 VALUES ('trans1'), ('trans2');
|
||||
CREATE TABLE t2 (id varchar(20) NOT NULL, err_comment blob NOT NULL);
|
||||
INSERT INTO t2 VALUES ('trans1', 'a problem');
|
||||
SELECT COUNT(DISTINCT(t1.id)), LEFT(err_comment, 256) AS comment
|
||||
FROM t1 LEFT JOIN t2 ON t1.id=t2.id GROUP BY comment;
|
||||
COUNT(DISTINCT(t1.id)) comment
|
||||
1 NULL
|
||||
1 a problem
|
||||
DROP TABLE t1, t2;
|
||||
create table t1 (f1 date);
|
||||
insert into t1 values('2005-06-06');
|
||||
insert into t1 values('2005-06-06');
|
||||
select date(left(f1+0,8)) from t1 group by 1;
|
||||
date(left(f1+0,8))
|
||||
2005-06-06
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (n int);
|
||||
INSERT INTO t1 VALUES (1);
|
||||
SELECT n+1 AS n FROM t1 GROUP BY n;
|
||||
n
|
||||
2
|
||||
Warnings:
|
||||
Warning 1052 Column 'n' in group statement is ambiguous
|
||||
DROP TABLE t1;
|
||||
create table t1(f1 varchar(5) key);
|
||||
insert into t1 values (1),(2);
|
||||
select sql_buffer_result max(f1) is null from t1;
|
||||
max(f1) is null
|
||||
0
|
||||
select sql_buffer_result max(f1)+1 from t1;
|
||||
max(f1)+1
|
||||
3
|
||||
drop table t1;
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
SELECT a FROM t1 GROUP BY 'a';
|
||||
a
|
||||
1
|
||||
SELECT a FROM t1 GROUP BY "a";
|
||||
a
|
||||
1
|
||||
SELECT a FROM t1 GROUP BY `a`;
|
||||
a
|
||||
1
|
||||
2
|
||||
set sql_mode=ANSI_QUOTES;
|
||||
SELECT a FROM t1 GROUP BY "a";
|
||||
a
|
||||
1
|
||||
2
|
||||
SELECT a FROM t1 GROUP BY 'a';
|
||||
a
|
||||
1
|
||||
SELECT a FROM t1 GROUP BY `a`;
|
||||
a
|
||||
1
|
||||
2
|
||||
set sql_mode='';
|
||||
SELECT a FROM t1 HAVING 'a' > 1;
|
||||
a
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
SELECT a FROM t1 HAVING "a" > 1;
|
||||
a
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
SELECT a FROM t1 HAVING `a` > 1;
|
||||
a
|
||||
2
|
||||
SELECT a FROM t1 ORDER BY 'a' DESC;
|
||||
a
|
||||
1
|
||||
2
|
||||
SELECT a FROM t1 ORDER BY "a" DESC;
|
||||
a
|
||||
1
|
||||
2
|
||||
SELECT a FROM t1 ORDER BY `a` DESC;
|
||||
a
|
||||
2
|
||||
1
|
||||
DROP TABLE t1;
|
||||
create table t1 (c1 char(3), c2 char(3));
|
||||
create table t2 (c3 char(3), c4 char(3));
|
||||
insert into t1 values ('aaa', 'bb1'), ('aaa', 'bb2');
|
||||
insert into t2 values ('aaa', 'bb1'), ('aaa', 'bb2');
|
||||
select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4
|
||||
group by c2;
|
||||
c2
|
||||
aaa
|
||||
aaa
|
||||
Warnings:
|
||||
Warning 1052 Column 'c2' in group statement is ambiguous
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 1052 Column 'c2' in group statement is ambiguous
|
||||
select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4
|
||||
group by t1.c1;
|
||||
c2
|
||||
aaa
|
||||
show warnings;
|
||||
Level Code Message
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1 (a tinyint(3), b varchar(255), PRIMARY KEY (a));
|
||||
INSERT INTO t1 VALUES (1,'-----'), (6,'Allemagne'), (17,'Autriche'),
|
||||
(25,'Belgique'), (54,'Danemark'), (62,'Espagne'), (68,'France');
|
||||
CREATE TABLE t2 (a tinyint(3), b tinyint(3), PRIMARY KEY (a), KEY b (b));
|
||||
INSERT INTO t2 VALUES (1,1), (2,1), (6,6), (18,17), (15,25), (16,25),
|
||||
(17,25), (10,54), (5,62),(3,68);
|
||||
CREATE VIEW v1 AS select t1.a, concat(t1.b,'') AS b, t1.b as real_b from t1;
|
||||
explain
|
||||
SELECT straight_join sql_no_cache v1.a, v1.b, v1.real_b from t2, v1
|
||||
where t2.b=v1.a GROUP BY t2.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index b b 2 NULL 10 Using index
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 1 test.t2.b 1
|
||||
SELECT straight_join sql_no_cache v1.a, v1.b, v1.real_b from t2, v1
|
||||
where t2.b=v1.a GROUP BY t2.b;
|
||||
a b real_b
|
||||
1 ----- -----
|
||||
6 Allemagne Allemagne
|
||||
17 Autriche Autriche
|
||||
25 Belgique Belgique
|
||||
54 Danemark Danemark
|
||||
62 Espagne Espagne
|
||||
68 France France
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY, b INT, key (b));
|
||||
INSERT INTO t1 VALUES (1, 1);
|
||||
INSERT INTO t1 SELECT a + 1 , MOD(a + 1 , 20) FROM t1;
|
||||
INSERT INTO t1 SELECT a + 2 , MOD(a + 2 , 20) FROM t1;
|
||||
INSERT INTO t1 SELECT a + 4 , MOD(a + 4 , 20) FROM t1;
|
||||
INSERT INTO t1 SELECT a + 8 , MOD(a + 8 , 20) FROM t1;
|
||||
INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20) FROM t1;
|
||||
INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20) FROM t1;
|
||||
INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20) FROM t1;
|
||||
SELECT MIN(b), MAX(b) from t1;
|
||||
MIN(b) MAX(b)
|
||||
0 19
|
||||
EXPLAIN SELECT b, sum(1) FROM t1 GROUP BY b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL b 5 NULL 128 Using index
|
||||
EXPLAIN SELECT SQL_BIG_RESULT b, sum(1) FROM t1 GROUP BY b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL b 5 NULL 128 Using index; Using filesort
|
||||
SELECT b, sum(1) FROM t1 GROUP BY b;
|
||||
b sum(1)
|
||||
0 6
|
||||
1 7
|
||||
2 7
|
||||
3 7
|
||||
4 7
|
||||
5 7
|
||||
6 7
|
||||
7 7
|
||||
8 7
|
||||
9 6
|
||||
10 6
|
||||
11 6
|
||||
12 6
|
||||
13 6
|
||||
14 6
|
||||
15 6
|
||||
16 6
|
||||
17 6
|
||||
18 6
|
||||
19 6
|
||||
SELECT SQL_BIG_RESULT b, sum(1) FROM t1 GROUP BY b;
|
||||
b sum(1)
|
||||
0 6
|
||||
1 7
|
||||
2 7
|
||||
3 7
|
||||
4 7
|
||||
5 7
|
||||
6 7
|
||||
7 7
|
||||
8 7
|
||||
9 6
|
||||
10 6
|
||||
11 6
|
||||
12 6
|
||||
13 6
|
||||
14 6
|
||||
15 6
|
||||
16 6
|
||||
17 6
|
||||
18 6
|
||||
19 6
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT, b INT, KEY(a));
|
||||
INSERT INTO t1 VALUES (1, 1), (2, 2), (3,3), (4,4);
|
||||
EXPLAIN SELECT a, SUM(b) FROM t1 GROUP BY a LIMIT 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 5 NULL 2
|
||||
EXPLAIN SELECT a, SUM(b) FROM t1 IGNORE INDEX (a) GROUP BY a LIMIT 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort
|
||||
DROP TABLE t1;
|
||||
2375
mysql-test/suite/pbxt/r/group_min_max.result
Normal file
2375
mysql-test/suite/pbxt/r/group_min_max.result
Normal file
File diff suppressed because it is too large
Load Diff
407
mysql-test/suite/pbxt/r/having.result
Normal file
407
mysql-test/suite/pbxt/r/having.result
Normal file
@@ -0,0 +1,407 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
create table t1 (a int);
|
||||
select count(a) as b from t1 where a=0 having b > 0;
|
||||
b
|
||||
insert into t1 values (null);
|
||||
select count(a) as b from t1 where a=0 having b > 0;
|
||||
b
|
||||
select count(a) as b from t1 where a=0 having b >=0;
|
||||
b
|
||||
0
|
||||
explain extended select count(a) as b from t1 where a=0 having b >=0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select count(`test`.`t1`.`a`) AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 0) having (`b` >= 0)
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
raw_id int(10) NOT NULL default '0',
|
||||
chr_start int(10) NOT NULL default '0',
|
||||
chr_end int(10) NOT NULL default '0',
|
||||
raw_start int(10) NOT NULL default '0',
|
||||
raw_end int(10) NOT NULL default '0',
|
||||
raw_ori int(2) NOT NULL default '0'
|
||||
);
|
||||
INSERT INTO t1 VALUES (469713,1,164123,1,164123,1),(317330,164124,317193,101,153170,1),(469434,317194,375620,101,58527,1),(591816,375621,484273,1,108653,1),(591807,484274,534671,91,50488,1),(318885,534672,649362,101,114791,1),(318728,649363,775520,102,126259,1),(336829,775521,813997,101,38577,1),(317740,813998,953227,101,139330,1),(1,813998,953227,101,139330,1);
|
||||
CREATE TABLE t2 (
|
||||
id int(10) unsigned NOT NULL default '0',
|
||||
contig_id int(10) unsigned NOT NULL default '0',
|
||||
seq_start int(10) NOT NULL default '0',
|
||||
seq_end int(10) NOT NULL default '0',
|
||||
strand tinyint(2) NOT NULL default '0',
|
||||
KEY id (id)
|
||||
);
|
||||
INSERT INTO t2 VALUES (133195,469713,61327,61384,1),(133196,469713,64113,64387,1),(133197,1,1,1,0),(133197,1,1,1,-2);
|
||||
SELECT e.id,
|
||||
MIN( IF(sgp.raw_ori=1,
|
||||
(e.seq_start+sgp.chr_start-sgp.raw_start),
|
||||
(sgp.chr_start+sgp.raw_end-e.seq_end))) as start,
|
||||
MAX( IF(sgp.raw_ori=1,
|
||||
(e.seq_end+sgp.chr_start-sgp.raw_start),
|
||||
(sgp.chr_start+sgp.raw_end-e.seq_start))) as end,
|
||||
AVG(IF (sgp.raw_ori=1,e.strand,(-e.strand))) as chr_strand
|
||||
FROM t1 sgp,
|
||||
t2 e
|
||||
WHERE sgp.raw_id=e.contig_id
|
||||
GROUP BY e.id
|
||||
HAVING chr_strand= -1 and end >= 0
|
||||
AND start <= 999660;
|
||||
id start end chr_strand
|
||||
133197 813898 813898 -1.0000
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (Fld1 int(11) default NULL,Fld2 int(11) default NULL);
|
||||
INSERT INTO t1 VALUES (1,10),(1,20),(2,NULL),(2,NULL),(3,50);
|
||||
select Fld1, max(Fld2) as q from t1 group by Fld1 having q is not null;
|
||||
Fld1 q
|
||||
1 20
|
||||
3 50
|
||||
select Fld1, max(Fld2) from t1 group by Fld1 having max(Fld2) is not null;
|
||||
Fld1 max(Fld2)
|
||||
1 20
|
||||
3 50
|
||||
select Fld1, max(Fld2) from t1 group by Fld1 having avg(Fld2) is not null;
|
||||
Fld1 max(Fld2)
|
||||
1 20
|
||||
3 50
|
||||
select Fld1, max(Fld2) from t1 group by Fld1 having std(Fld2) is not null;
|
||||
Fld1 max(Fld2)
|
||||
1 20
|
||||
3 50
|
||||
select Fld1, max(Fld2) from t1 group by Fld1 having variance(Fld2) is not null;
|
||||
Fld1 max(Fld2)
|
||||
1 20
|
||||
3 50
|
||||
drop table t1;
|
||||
create table t1 (id int not null, qty int not null);
|
||||
insert into t1 values (1,2),(1,3),(2,4),(2,5);
|
||||
select id, sum(qty) as sqty from t1 group by id having sqty>2;
|
||||
id sqty
|
||||
1 5
|
||||
2 9
|
||||
select sum(qty) as sqty from t1 group by id having count(id) > 0;
|
||||
sqty
|
||||
5
|
||||
9
|
||||
select sum(qty) as sqty from t1 group by id having count(distinct id) > 0;
|
||||
sqty
|
||||
5
|
||||
9
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
`id` bigint(20) NOT NULL default '0',
|
||||
`description` text
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (
|
||||
`id` bigint(20) NOT NULL default '0',
|
||||
`description` varchar(20)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1, 'test');
|
||||
INSERT INTO t2 VALUES (1, 'test');
|
||||
CREATE TABLE t3 (
|
||||
`id` bigint(20) NOT NULL default '0',
|
||||
`order_id` bigint(20) NOT NULL default '0'
|
||||
) ENGINE=MyISAM;
|
||||
select
|
||||
a.id, a.description,
|
||||
count(b.id) as c
|
||||
from t1 a left join t3 b on a.id=b.order_id
|
||||
group by a.id, a.description
|
||||
having (a.description is not null) and (c=0);
|
||||
id description c
|
||||
1 test 0
|
||||
select
|
||||
a.*,
|
||||
count(b.id) as c
|
||||
from t2 a left join t3 b on a.id=b.order_id
|
||||
group by a.id, a.description
|
||||
having (a.description is not null) and (c=0);
|
||||
id description c
|
||||
1 test 0
|
||||
INSERT INTO t1 VALUES (2, 'test2');
|
||||
select
|
||||
a.id, a.description,
|
||||
count(b.id) as c
|
||||
from t1 a left join t3 b on a.id=b.order_id
|
||||
group by a.id, a.description
|
||||
having (a.description is not null) and (c=0);
|
||||
id description c
|
||||
1 test 0
|
||||
2 test2 0
|
||||
drop table t1,t2,t3;
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (3), (4), (1), (3), (1);
|
||||
SELECT SUM(a) FROM t1 GROUP BY a HAVING SUM(a)>0;
|
||||
SUM(a)
|
||||
2
|
||||
6
|
||||
4
|
||||
SELECT SUM(a) FROM t1 GROUP BY a HAVING SUM(a);
|
||||
SUM(a)
|
||||
2
|
||||
6
|
||||
4
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (1), (2), (1), (3), (2), (1);
|
||||
SELECT a FROM t1 GROUP BY a HAVING a > 1;
|
||||
a
|
||||
2
|
||||
3
|
||||
SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1;
|
||||
a
|
||||
SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
|
||||
x a
|
||||
EXPLAIN SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
DROP table t1;
|
||||
create table t1 (col1 int, col2 varchar(5), col_t1 int);
|
||||
create table t2 (col1 int, col2 varchar(5), col_t2 int);
|
||||
create table t3 (col1 int, col2 varchar(5), col_t3 int);
|
||||
insert into t1 values(10,'hello',10);
|
||||
insert into t1 values(20,'hello',20);
|
||||
insert into t1 values(30,'hello',30);
|
||||
insert into t1 values(10,'bye',10);
|
||||
insert into t1 values(10,'sam',10);
|
||||
insert into t1 values(10,'bob',10);
|
||||
insert into t2 select * from t1;
|
||||
insert into t3 select * from t1;
|
||||
select count(*) from t1 group by col1 having col1 = 10;
|
||||
count(*)
|
||||
4
|
||||
select count(*) as count_col1 from t1 group by col1 having col1 = 10;
|
||||
count_col1
|
||||
4
|
||||
select count(*) as count_col1 from t1 as tmp1 group by col1 having col1 = 10;
|
||||
count_col1
|
||||
4
|
||||
select count(*) from t1 group by col2 having col2 = 'hello';
|
||||
count(*)
|
||||
3
|
||||
select count(*) from t1 group by col2 having col1 = 10;
|
||||
ERROR 42S22: Unknown column 'col1' in 'having clause'
|
||||
select col1 as count_col1 from t1 as tmp1 group by col1 having col1 = 10;
|
||||
count_col1
|
||||
10
|
||||
select col1 as count_col1 from t1 as tmp1 group by col1 having count_col1 = 10;
|
||||
count_col1
|
||||
10
|
||||
select col1 as count_col1 from t1 as tmp1 group by count_col1 having col1 = 10;
|
||||
count_col1
|
||||
10
|
||||
select col1 as count_col1 from t1 as tmp1 group by count_col1 having count_col1 = 10;
|
||||
count_col1
|
||||
10
|
||||
select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col1 = 10;
|
||||
count_col1 col2
|
||||
10 bob
|
||||
10 bye
|
||||
10 hello
|
||||
10 sam
|
||||
select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having count_col1 = 10;
|
||||
count_col1 col2
|
||||
10 bob
|
||||
10 bye
|
||||
10 hello
|
||||
10 sam
|
||||
select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col2 = 'hello';
|
||||
count_col1 col2
|
||||
10 hello
|
||||
20 hello
|
||||
30 hello
|
||||
select col1 as count_col1,col2 as group_col2 from t1 as tmp1 group by col1,col2 having group_col2 = 'hello';
|
||||
count_col1 group_col2
|
||||
10 hello
|
||||
20 hello
|
||||
30 hello
|
||||
select sum(col1) as co12 from t1 group by col2 having col2 10;
|
||||
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 '10' at line 1
|
||||
select sum(col1) as co2, count(col2) as cc from t1 group by col1 having col1 =10;
|
||||
co2 cc
|
||||
40 4
|
||||
select t2.col2 from t2 group by t2.col1, t2.col2 having t1.col1 <= 10;
|
||||
ERROR 42S22: Unknown column 't1.col1' in 'having clause'
|
||||
select t1.col1 from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2 having t2.col1 <= 10);
|
||||
col1
|
||||
10
|
||||
20
|
||||
30
|
||||
10
|
||||
10
|
||||
10
|
||||
select t1.col1 from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2
|
||||
having t2.col1 <=
|
||||
(select min(t3.col1) from t3));
|
||||
col1
|
||||
10
|
||||
20
|
||||
30
|
||||
10
|
||||
10
|
||||
10
|
||||
select t1.col1 from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2 having t1.col1 <= 10);
|
||||
col1
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
select t1.col1 as tmp_col from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2 having tmp_col <= 10);
|
||||
tmp_col
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
select t1.col1 from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2 having col_t1 <= 10);
|
||||
col1
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
select sum(col1) from t1
|
||||
group by col_t1
|
||||
having (select col_t1 from t2 where col_t1 = col_t2 order by col_t2 limit 1);
|
||||
sum(col1)
|
||||
40
|
||||
20
|
||||
30
|
||||
select t1.col1 from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2 having col_t1 <= 10)
|
||||
having col_t1 <= 20;
|
||||
ERROR 42S22: Unknown column 'col_t1' in 'having clause'
|
||||
select t1.col1 from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2 having col_t1 <= 10)
|
||||
group by col_t1
|
||||
having col_t1 <= 20;
|
||||
col1
|
||||
10
|
||||
select col_t1, sum(col1) from t1
|
||||
group by col_t1
|
||||
having col_t1 > 10 and
|
||||
exists (select sum(t2.col1) from t2
|
||||
group by t2.col2 having t2.col2 > 'b');
|
||||
col_t1 sum(col1)
|
||||
20 20
|
||||
30 30
|
||||
select sum(col1) from t1
|
||||
group by col_t1
|
||||
having col_t1 in (select sum(t2.col1) from t2
|
||||
group by t2.col2, t2.col1 having t2.col1 = t1.col1);
|
||||
ERROR 42S22: Unknown column 't1.col1' in 'having clause'
|
||||
select sum(col1) from t1
|
||||
group by col_t1
|
||||
having col_t1 in (select sum(t2.col1) from t2
|
||||
group by t2.col2, t2.col1 having t2.col1 = col_t1);
|
||||
sum(col1)
|
||||
40
|
||||
20
|
||||
30
|
||||
select t1.col1, t2.col1 from t1, t2 where t1.col1 = t2.col1
|
||||
group by t1.col1, t2.col1 having col1 = 2;
|
||||
ERROR 23000: Column 'col1' in having clause is ambiguous
|
||||
select t1.col1*10+t2.col1 from t1,t2 where t1.col1=t2.col1
|
||||
group by t1.col1, t2.col1 having col1 = 2;
|
||||
ERROR 23000: Column 'col1' in having clause is ambiguous
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (s1 int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
select count(*) from t1 group by s1 having s1 is null;
|
||||
count(*)
|
||||
select s1*0 as s1 from t1 group by s1 having s1 <> 0;
|
||||
s1
|
||||
0
|
||||
0
|
||||
0
|
||||
Warnings:
|
||||
Warning 1052 Column 's1' in group statement is ambiguous
|
||||
Warning 1052 Column 's1' in having clause is ambiguous
|
||||
select s1*0 from t1 group by s1 having s1 = 0;
|
||||
s1*0
|
||||
select s1 from t1 group by 1 having 1 = 0;
|
||||
s1
|
||||
select count(s1) from t1 group by s1 having count(1+1)=2;
|
||||
count(s1)
|
||||
select count(s1) from t1 group by s1 having s1*0=0;
|
||||
count(s1)
|
||||
1
|
||||
1
|
||||
1
|
||||
select * from t1 a, t1 b group by a.s1 having s1 is null;
|
||||
ERROR 23000: Column 's1' in having clause is ambiguous
|
||||
drop table t1;
|
||||
create table t1 (s1 char character set latin1 collate latin1_german1_ci);
|
||||
insert into t1 values ('ü'),('y');
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 's1' at row 1
|
||||
select s1,count(s1) from t1
|
||||
group by s1 collate latin1_swedish_ci having s1 = 'y';
|
||||
s1 count(s1)
|
||||
y 1
|
||||
drop table t1;
|
||||
DROP SCHEMA IF EXISTS HU;
|
||||
CREATE SCHEMA HU ;
|
||||
USE HU ;
|
||||
CREATE TABLE STAFF
|
||||
(EMPNUM CHAR(3) NOT NULL UNIQUE,
|
||||
EMPNAME CHAR(20),
|
||||
GRADE DECIMAL(4),
|
||||
CITY CHAR(15));
|
||||
CREATE TABLE PROJ
|
||||
(PNUM CHAR(3) NOT NULL UNIQUE,
|
||||
PNAME CHAR(20),
|
||||
PTYPE CHAR(6),
|
||||
BUDGET DECIMAL(9),
|
||||
CITY CHAR(15));
|
||||
INSERT INTO STAFF VALUES ('E1','Alice',12,'Deale');
|
||||
INSERT INTO STAFF VALUES ('E2','Betty',10,'Vienna');
|
||||
INSERT INTO STAFF VALUES ('E3','Carmen',13,'Vienna');
|
||||
INSERT INTO STAFF VALUES ('E4','Don',12,'Deale');
|
||||
INSERT INTO STAFF VALUES ('E5','Ed',13,'Akron');
|
||||
INSERT INTO PROJ VALUES ('P1','MXSS','Design',10000,'Deale');
|
||||
INSERT INTO PROJ VALUES ('P2','CALM','Code',30000,'Vienna');
|
||||
INSERT INTO PROJ VALUES ('P3','SDP','Test',30000,'Tampa');
|
||||
INSERT INTO PROJ VALUES ('P4','SDP','Design',20000,'Deale');
|
||||
INSERT INTO PROJ VALUES ('P5','IRM','Test',10000,'Vienna');
|
||||
INSERT INTO PROJ VALUES ('P6','PAYR','Design',50000,'Deale');
|
||||
SELECT EMPNUM, GRADE*1000
|
||||
FROM HU.STAFF WHERE GRADE * 1000 >
|
||||
ANY (SELECT SUM(BUDGET) FROM HU.PROJ
|
||||
GROUP BY CITY, PTYPE
|
||||
HAVING HU.PROJ.CITY = HU.STAFF.CITY);
|
||||
EMPNUM GRADE*1000
|
||||
E3 13000
|
||||
DROP SCHEMA HU;
|
||||
USE test;
|
||||
create table t1(f1 int);
|
||||
select f1 from t1 having max(f1)=f1;
|
||||
f1
|
||||
select f1 from t1 group by f1 having max(f1)=f1;
|
||||
f1
|
||||
set session sql_mode='ONLY_FULL_GROUP_BY';
|
||||
select f1 from t1 having max(f1)=f1;
|
||||
ERROR 42000: non-grouping field 'f1' is used in HAVING clause
|
||||
select f1 from t1 group by f1 having max(f1)=f1;
|
||||
f1
|
||||
set session sql_mode='';
|
||||
drop table t1;
|
||||
733
mysql-test/suite/pbxt/r/heap.result
Normal file
733
mysql-test/suite/pbxt/r/heap.result
Normal file
@@ -0,0 +1,733 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where a=1 or a=0;
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
select * from t1 where a=4;
|
||||
a b
|
||||
4 4
|
||||
update t1 set b=5 where a=4;
|
||||
update t1 set b=b+1 where a>=3;
|
||||
replace t1 values (3,3);
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 3
|
||||
4 6
|
||||
alter table t1 add c int not null, add key (c,a);
|
||||
drop table t1;
|
||||
create table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps";
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where a > 0;
|
||||
select * from t1;
|
||||
a b
|
||||
drop table t1;
|
||||
create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps";
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
drop table t1;
|
||||
create table t1 (a int not null) engine=heap;
|
||||
insert into t1 values (869751),(736494),(226312),(802616),(728912);
|
||||
select * from t1 where a > 736494;
|
||||
a
|
||||
869751
|
||||
802616
|
||||
alter table t1 add unique uniq_id(a);
|
||||
select * from t1 where a > 736494;
|
||||
a
|
||||
869751
|
||||
802616
|
||||
select * from t1 where a = 736494;
|
||||
a
|
||||
736494
|
||||
select * from t1 where a=869751 or a=736494;
|
||||
a
|
||||
736494
|
||||
869751
|
||||
select * from t1 where a in (869751,736494,226312,802616);
|
||||
a
|
||||
226312
|
||||
736494
|
||||
802616
|
||||
869751
|
||||
alter table t1 engine=myisam;
|
||||
explain select * from t1 where a in (869751,736494,226312,802616);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
|
||||
drop table t1;
|
||||
create table t1 (x int not null, y int not null, key x (x), unique y (y))
|
||||
engine=heap;
|
||||
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
|
||||
select * from t1 where x=1;
|
||||
x y
|
||||
1 3
|
||||
1 1
|
||||
select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
x y x y
|
||||
1 1 1 1
|
||||
2 2 2 2
|
||||
1 3 1 1
|
||||
2 4 2 2
|
||||
2 5 2 2
|
||||
2 6 2 2
|
||||
explain select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL x NULL NULL NULL 6
|
||||
1 SIMPLE t2 eq_ref y y 4 test.t1.x 1
|
||||
drop table t1;
|
||||
create table t1 (a int) engine=heap;
|
||||
insert into t1 values(1);
|
||||
select max(a) from t1;
|
||||
max(a)
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key(a), key(b) ) ENGINE=HEAP;
|
||||
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
|
||||
select * from t1 where a=1;
|
||||
a b
|
||||
1 6
|
||||
1 5
|
||||
1 4
|
||||
1 3
|
||||
1 2
|
||||
1 1
|
||||
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
|
||||
select * from t1 where a=1;
|
||||
a b
|
||||
1 6
|
||||
1 5
|
||||
1 4
|
||||
1 3
|
||||
1 2
|
||||
1 1
|
||||
1 6
|
||||
1 5
|
||||
1 4
|
||||
1 3
|
||||
1 2
|
||||
1 1
|
||||
drop table t1;
|
||||
create table t1 (id int unsigned not null, primary key (id)) engine=HEAP;
|
||||
insert into t1 values(1);
|
||||
select max(id) from t1;
|
||||
max(id)
|
||||
1
|
||||
insert into t1 values(2);
|
||||
select max(id) from t1;
|
||||
max(id)
|
||||
2
|
||||
replace into t1 values(1);
|
||||
drop table t1;
|
||||
create table t1 (n int) engine=heap;
|
||||
drop table t1;
|
||||
create table t1 (n int) engine=heap;
|
||||
drop table if exists t1;
|
||||
CREATE table t1(f1 int not null,f2 char(20) not
|
||||
null,index(f2)) engine=heap;
|
||||
INSERT into t1 set f1=12,f2="bill";
|
||||
INSERT into t1 set f1=13,f2="bill";
|
||||
INSERT into t1 set f1=14,f2="bill";
|
||||
INSERT into t1 set f1=15,f2="bill";
|
||||
INSERT into t1 set f1=16,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
delete from t1 where f2="bill";
|
||||
select * from t1;
|
||||
f1 f2
|
||||
16 ted
|
||||
12 ted
|
||||
12 ted
|
||||
12 ted
|
||||
12 ted
|
||||
drop table t1;
|
||||
create table t1 (btn char(10) not null, key(btn)) engine=heap;
|
||||
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
|
||||
explain select * from t1 where btn like "q%";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where
|
||||
select * from t1 where btn like "q%";
|
||||
btn
|
||||
alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn;
|
||||
update t1 set new_col=left(btn,1);
|
||||
explain select * from t1 where btn="a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where
|
||||
explain select * from t1 where btn="a" and new_col="a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref btn btn 11 const,const 2 Using where
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a int default NULL,
|
||||
b int default NULL,
|
||||
KEY a (a),
|
||||
UNIQUE b (b)
|
||||
) engine=heap;
|
||||
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
|
||||
SELECT * FROM t1 WHERE a=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE a IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 2 Using where
|
||||
SELECT * FROM t1 WHERE a<=>NULL;
|
||||
a b
|
||||
NULL 99
|
||||
SELECT * FROM t1 WHERE b=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE b IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref b b 5 const 1 Using where
|
||||
SELECT * FROM t1 WHERE b<=>NULL;
|
||||
a b
|
||||
99 NULL
|
||||
INSERT INTO t1 VALUES (1,3);
|
||||
ERROR 23000: Duplicate entry '3' for key 'b'
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
a int default NULL,
|
||||
key a (a)
|
||||
) ENGINE=HEAP;
|
||||
INSERT INTO t1 VALUES (10), (10), (10);
|
||||
EXPLAIN SELECT * FROM t1 WHERE a=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 3 Using where
|
||||
SELECT * FROM t1 WHERE a=10;
|
||||
a
|
||||
10
|
||||
10
|
||||
10
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int not null, primary key(a)) engine=heap;
|
||||
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
|
||||
DELETE from t1 where a < 100;
|
||||
SELECT * from t1;
|
||||
a
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE `job_titles` (
|
||||
`job_title_id` int(6) unsigned NOT NULL default '0',
|
||||
`job_title` char(18) NOT NULL default '',
|
||||
PRIMARY KEY (`job_title_id`),
|
||||
UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
|
||||
) ENGINE=HEAP;
|
||||
SELECT MAX(job_title_id) FROM job_titles;
|
||||
MAX(job_title_id)
|
||||
NULL
|
||||
DROP TABLE job_titles;
|
||||
CREATE TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP;
|
||||
INSERT INTO t1 VALUES(1,1), (1,NULL);
|
||||
SELECT * FROM t1 WHERE B is not null;
|
||||
a B
|
||||
1 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int(10) unsigned NOT NULL) ENGINE=HEAP;
|
||||
INSERT INTO t1 VALUES ('massecot',1101106491),('altec',1101106492),('stitch+',1101106304),('Seb Corgan',1101106305),('beerfilou',1101106263),('flaker',1101106529),('joce8',5),('M4vrick',1101106418),('gabay008',1101106525),('Vamp irX',1101106291),('ZoomZip',1101106546),('rip666',1101106502),('CBP ',1101106397),('guezpard',1101106496);
|
||||
DELETE FROM t1 WHERE date<1101106546;
|
||||
SELECT * FROM t1;
|
||||
pseudo date
|
||||
ZoomZip 1101106546
|
||||
DROP TABLE t1;
|
||||
create table t1(a char(2)) engine=memory;
|
||||
insert into t1 values (NULL), (NULL);
|
||||
delete from t1 where a is null;
|
||||
insert into t1 values ('2'), ('3');
|
||||
select * from t1;
|
||||
a
|
||||
3
|
||||
2
|
||||
drop table t1;
|
||||
set storage_engine=HEAP;
|
||||
create table t1 (v varchar(10), c char(10), t varchar(50));
|
||||
insert into t1 values('+ ', '+ ', '+ ');
|
||||
set @a=repeat(' ',20);
|
||||
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'v' at row 1
|
||||
select concat('*',v,'*',c,'*',t,'*') from t1;
|
||||
concat('*',v,'*',c,'*',t,'*')
|
||||
*+ *+*+ *
|
||||
*+ *+*+ *
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` char(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
create table t2 like t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` char(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
create table t3 select * from t1;
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` char(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
alter table t1 modify c varchar(10);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` varchar(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
alter table t1 modify v char(10);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` char(10) DEFAULT NULL,
|
||||
`c` varchar(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
alter table t1 modify t varchar(10);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 't' at row 2
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` char(10) DEFAULT NULL,
|
||||
`c` varchar(10) DEFAULT NULL,
|
||||
`t` varchar(10) DEFAULT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
select concat('*',v,'*',c,'*',t,'*') from t1;
|
||||
concat('*',v,'*',c,'*',t,'*')
|
||||
*+*+*+ *
|
||||
*+*+*+ *
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` char(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL,
|
||||
KEY `v` (`v`),
|
||||
KEY `c` (`c`),
|
||||
KEY `t` (`t`(10))
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
270
|
||||
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
|
||||
select count(*) from t1 where v='a';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where c='a';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where t='a';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v='a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where c='a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where t='a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v between 'a' and 'a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v like 'a%';
|
||||
count(*)
|
||||
11
|
||||
select count(*) from t1 where c like 'a%';
|
||||
count(*)
|
||||
11
|
||||
select count(*) from t1 where t like 'a%';
|
||||
count(*)
|
||||
11
|
||||
select count(*) from t1 where v like 'a %';
|
||||
count(*)
|
||||
9
|
||||
explain select count(*) from t1 where v='a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const 10 Using where
|
||||
explain select count(*) from t1 where c='a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref c c 11 const 10 Using where
|
||||
explain select count(*) from t1 where t='a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref t t 13 const 10 Using where
|
||||
explain select count(*) from t1 where v like 'a%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL v NULL NULL NULL 271 Using where
|
||||
explain select count(*) from t1 where v between 'a' and 'a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const 10 Using where
|
||||
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const 10 Using where
|
||||
alter table t1 add unique(v);
|
||||
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
|
||||
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
|
||||
qq
|
||||
*a*a*a*
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
explain select * from t1 where v='a';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const 10 Using where
|
||||
select v,count(*) from t1 group by v limit 10;
|
||||
v count(*)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select v,count(t) from t1 group by v limit 10;
|
||||
v count(t)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select v,count(c) from t1 group by v limit 10;
|
||||
v count(c)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select sql_big_result trim(v),count(t) from t1 group by v limit 10;
|
||||
trim(v) count(t)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select sql_big_result trim(v),count(c) from t1 group by v limit 10;
|
||||
trim(v) count(c)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select c,count(*) from t1 group by c limit 10;
|
||||
c count(*)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select c,count(t) from t1 group by c limit 10;
|
||||
c count(t)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select sql_big_result c,count(t) from t1 group by c limit 10;
|
||||
c count(t)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select t,count(*) from t1 group by t limit 10;
|
||||
t count(*)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select t,count(t) from t1 group by t limit 10;
|
||||
t count(t)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
select sql_big_result trim(t),count(t) from t1 group by t limit 10;
|
||||
trim(t) count(t)
|
||||
a 1
|
||||
a 10
|
||||
b 10
|
||||
c 10
|
||||
d 10
|
||||
e 10
|
||||
f 10
|
||||
g 10
|
||||
h 10
|
||||
i 10
|
||||
drop table t1;
|
||||
create table t1 (a char(10), unique (a));
|
||||
insert into t1 values ('a');
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a' for key 'a'
|
||||
alter table t1 modify a varchar(10);
|
||||
insert into t1 values ('a '),('a '),('a '),('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
update t1 set a='a ' where a like 'a ';
|
||||
update t1 set a='a ' where a like 'a ';
|
||||
drop table t1;
|
||||
create table t1 (v varchar(10), c char(10), t varchar(50), key using btree (v), key using btree (c), key using btree (t(10)));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` char(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL,
|
||||
KEY `v` (`v`) USING BTREE,
|
||||
KEY `c` (`c`) USING BTREE,
|
||||
KEY `t` (`t`(10)) USING BTREE
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
270
|
||||
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
|
||||
select count(*) from t1 where v='a';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where c='a';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where t='a';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v='a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where c='a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where t='a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v between 'a' and 'a ';
|
||||
count(*)
|
||||
10
|
||||
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
|
||||
count(*)
|
||||
10
|
||||
explain select count(*) from t1 where v='a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const # Using where
|
||||
explain select count(*) from t1 where c='a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref c c 11 const # Using where
|
||||
explain select count(*) from t1 where t='a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref t t 13 const # Using where
|
||||
explain select count(*) from t1 where v like 'a%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range v v 13 NULL # Using where
|
||||
explain select count(*) from t1 where v between 'a' and 'a ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const # Using where
|
||||
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const # Using where
|
||||
alter table t1 add unique(v);
|
||||
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
|
||||
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
|
||||
qq
|
||||
*a*a*a*
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
*a *a*a *
|
||||
explain select * from t1 where v='a';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref v v 13 const # Using where
|
||||
drop table t1;
|
||||
create table t1 (a char(10), unique using btree (a)) engine=heap;
|
||||
insert into t1 values ('a');
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a' for key 'a'
|
||||
alter table t1 modify a varchar(10);
|
||||
insert into t1 values ('a '),('a '),('a '),('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
insert into t1 values ('a ');
|
||||
ERROR 23000: Duplicate entry 'a ' for key 'a'
|
||||
update t1 set a='a ' where a like 'a ';
|
||||
update t1 set a='a ' where a like 'a ';
|
||||
drop table t1;
|
||||
create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` varchar(10) DEFAULT NULL,
|
||||
`c` char(10) DEFAULT NULL,
|
||||
`t` varchar(50) DEFAULT NULL,
|
||||
KEY `v` (`v`(5)),
|
||||
KEY `c` (`c`(5)),
|
||||
KEY `t` (`t`(5))
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (v varchar(65530), key(v(10)));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`v` varchar(65530) DEFAULT NULL,
|
||||
KEY `v` (`v`(10))
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=latin1
|
||||
insert into t1 values(repeat('a',65530));
|
||||
select length(v) from t1 where v=repeat('a',65530);
|
||||
length(v)
|
||||
65530
|
||||
drop table t1;
|
||||
set storage_engine=PBXT;
|
||||
create table t1 (a bigint unsigned auto_increment primary key, b int,
|
||||
key (b, a)) engine=heap;
|
||||
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 1
|
||||
3 1
|
||||
4 1
|
||||
5 1
|
||||
6 1
|
||||
7 1
|
||||
8 1
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b int not null auto_increment,
|
||||
primary key(a, b), key(b)) engine=heap;
|
||||
insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
1 2
|
||||
1 3
|
||||
1 4
|
||||
1 5
|
||||
1 6
|
||||
1 7
|
||||
1 8
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b int not null auto_increment,
|
||||
primary key(a, b)) engine=heap;
|
||||
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
|
||||
create table t1 (c char(255), primary key(c(90)));
|
||||
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
|
||||
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
|
||||
ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 'PRIMARY'
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int, key(a)) engine=heap;
|
||||
insert into t1 values (0);
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a
|
||||
insert into t1 values (0), (1);
|
||||
select * from t1 where a = 0;
|
||||
a
|
||||
0
|
||||
drop table t1;
|
||||
create table t1 (c char(10)) engine=memory;
|
||||
create table t2 (c varchar(10)) engine=memory;
|
||||
show table status like 't_';
|
||||
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 MEMORY 10 Fixed 0 11 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL
|
||||
t2 MEMORY 10 Fixed 0 12 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
|
||||
KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY;
|
||||
INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256));
|
||||
SELECT COUNT(*) FROM t1 WHERE a='a';
|
||||
COUNT(*)
|
||||
2
|
||||
SELECT COUNT(*) FROM t1 WHERE b='aa';
|
||||
COUNT(*)
|
||||
2
|
||||
SELECT COUNT(*) FROM t1 WHERE c=REPEAT('a',256);
|
||||
COUNT(*)
|
||||
2
|
||||
DROP TABLE t1;
|
||||
41
mysql-test/suite/pbxt/r/heap_auto_increment.result
Normal file
41
mysql-test/suite/pbxt/r/heap_auto_increment.result
Normal file
@@ -0,0 +1,41 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (a int not null auto_increment,b int, primary key (a)) engine=heap auto_increment=3;
|
||||
insert into t1 values (1,1),(NULL,3),(NULL,4);
|
||||
delete from t1 where a=4;
|
||||
insert into t1 values (NULL,5),(NULL,6);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
3 3
|
||||
5 5
|
||||
6 6
|
||||
delete from t1 where a=6;
|
||||
replace t1 values (3,1);
|
||||
ALTER TABLE t1 add c int;
|
||||
replace t1 values (3,3,3);
|
||||
insert into t1 values (NULL,7,7);
|
||||
update t1 set a=8,b=b+1,c=c+1 where a=7;
|
||||
insert into t1 values (NULL,9,9);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 1 NULL
|
||||
3 3 3
|
||||
5 5 NULL
|
||||
8 8 8
|
||||
9 9 9
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
|
||||
sval char(20)
|
||||
) engine=heap;
|
||||
insert into t1 values (NULL, "hello");
|
||||
insert into t1 values (NULL, "hey");
|
||||
select * from t1;
|
||||
skey sval
|
||||
1 hello
|
||||
2 hey
|
||||
select _rowid,t1._rowid,skey,sval from t1;
|
||||
_rowid _rowid skey sval
|
||||
1 1 1 hello
|
||||
2 2 2 hey
|
||||
drop table t1;
|
||||
297
mysql-test/suite/pbxt/r/heap_btree.result
Normal file
297
mysql-test/suite/pbxt/r/heap_btree.result
Normal file
@@ -0,0 +1,297 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where a=1 or a=0;
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 a A NULL NULL NULL BTREE
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
select * from t1 where a=4;
|
||||
a b
|
||||
4 4
|
||||
update t1 set b=5 where a=4;
|
||||
update t1 set b=b+1 where a>=3;
|
||||
replace t1 values (3,3);
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 3
|
||||
4 6
|
||||
alter table t1 add c int not null, add key using BTREE (c,a);
|
||||
drop table t1;
|
||||
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps";
|
||||
insert into t1 values(-2,-2),(-1,-1),(0,0),(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where a > -3;
|
||||
select * from t1;
|
||||
a b
|
||||
drop table t1;
|
||||
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps";
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
drop table t1;
|
||||
create table t1 (a int not null) engine=heap;
|
||||
insert into t1 values (869751),(736494),(226312),(802616),(728912);
|
||||
select * from t1 where a > 736494;
|
||||
a
|
||||
869751
|
||||
802616
|
||||
alter table t1 add unique uniq_id using BTREE (a);
|
||||
select * from t1 where a > 736494;
|
||||
a
|
||||
802616
|
||||
869751
|
||||
select * from t1 where a = 736494;
|
||||
a
|
||||
736494
|
||||
select * from t1 where a=869751 or a=736494;
|
||||
a
|
||||
736494
|
||||
869751
|
||||
select * from t1 where a in (869751,736494,226312,802616);
|
||||
a
|
||||
226312
|
||||
736494
|
||||
802616
|
||||
869751
|
||||
alter table t1 engine=myisam;
|
||||
explain select * from t1 where a in (869751,736494,226312,802616);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
|
||||
drop table t1;
|
||||
create table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y))
|
||||
engine=heap;
|
||||
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
|
||||
explain select * from t1 where x=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref x x 4 const 1
|
||||
select * from t1 where x=1;
|
||||
x y
|
||||
1 1
|
||||
1 3
|
||||
select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
x y x y
|
||||
1 1 1 1
|
||||
2 2 2 2
|
||||
1 3 1 1
|
||||
2 4 2 2
|
||||
2 5 2 2
|
||||
2 6 2 2
|
||||
explain select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL x NULL NULL NULL 6
|
||||
1 SIMPLE t2 eq_ref y y 4 test.t1.x 1
|
||||
drop table t1;
|
||||
create table t1 (a int) engine=heap;
|
||||
insert into t1 values(1);
|
||||
select max(a) from t1;
|
||||
max(a)
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using BTREE (a,b), key using BTREE (b) ) ENGINE=HEAP;
|
||||
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
|
||||
select * from t1 where a=1;
|
||||
a b
|
||||
1 1
|
||||
1 2
|
||||
1 3
|
||||
1 4
|
||||
1 5
|
||||
1 6
|
||||
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
|
||||
select * from t1 where a=1;
|
||||
a b
|
||||
1 1
|
||||
1 1
|
||||
1 2
|
||||
1 2
|
||||
1 3
|
||||
1 3
|
||||
1 4
|
||||
1 4
|
||||
1 5
|
||||
1 5
|
||||
1 6
|
||||
1 6
|
||||
explain select * from tx where a=x order by a,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
x SIMPLE tx ref a a x const x Using where
|
||||
explain select * from tx where a=x order by b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
x SIMPLE tx ref a a x const x Using where
|
||||
select * from t1 where b=1;
|
||||
a b
|
||||
1 1
|
||||
1 1
|
||||
explain select * from tx where b=x;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
x SIMPLE tx ref b b x const x
|
||||
drop table t1;
|
||||
create table t1 (id int unsigned not null, primary key using BTREE (id)) engine=HEAP;
|
||||
insert into t1 values(1);
|
||||
select max(id) from t1;
|
||||
max(id)
|
||||
1
|
||||
insert into t1 values(2);
|
||||
select max(id) from t1;
|
||||
max(id)
|
||||
2
|
||||
replace into t1 values(1);
|
||||
drop table t1;
|
||||
create table t1 (n int) engine=heap;
|
||||
drop table t1;
|
||||
create table t1 (n int) engine=heap;
|
||||
drop table if exists t1;
|
||||
CREATE table t1(f1 int not null,f2 char(20) not
|
||||
null,index(f2)) engine=heap;
|
||||
INSERT into t1 set f1=12,f2="bill";
|
||||
INSERT into t1 set f1=13,f2="bill";
|
||||
INSERT into t1 set f1=14,f2="bill";
|
||||
INSERT into t1 set f1=15,f2="bill";
|
||||
INSERT into t1 set f1=16,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
delete from t1 where f2="bill";
|
||||
select * from t1;
|
||||
f1 f2
|
||||
16 ted
|
||||
12 ted
|
||||
12 ted
|
||||
12 ted
|
||||
12 ted
|
||||
drop table t1;
|
||||
create table t1 (btn char(10) not null, key using BTREE (btn)) engine=heap;
|
||||
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
|
||||
explain select * from t1 where btn like "i%";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range btn btn 10 NULL 1 Using where
|
||||
explain select * from t1 where btn like "h%";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range btn btn 10 NULL # Using where
|
||||
explain select * from t1 where btn like "a%";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range btn btn 10 NULL 1 Using where
|
||||
explain select * from t1 where btn like "b%";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range btn btn 10 NULL 1 Using where
|
||||
select * from t1 where btn like "ff%";
|
||||
btn
|
||||
select * from t1 where btn like " %";
|
||||
btn
|
||||
select * from t1 where btn like "q%";
|
||||
btn
|
||||
alter table t1 add column new_col char(1) not null, add key using BTREE (btn,new_col), drop key btn;
|
||||
update t1 set new_col=left(btn,1);
|
||||
explain select * from t1 where btn="a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref btn btn 10 const 1 Using where
|
||||
explain select * from t1 where btn="a" and new_col="a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref btn btn 11 const,const 1 Using where
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a int default NULL,
|
||||
b int default NULL,
|
||||
KEY a using BTREE (a),
|
||||
UNIQUE b using BTREE (b)
|
||||
) engine=heap;
|
||||
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
|
||||
SELECT * FROM t1 WHERE a=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE a IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 1 Using where
|
||||
SELECT * FROM t1 WHERE a<=>NULL;
|
||||
a b
|
||||
NULL 99
|
||||
SELECT * FROM t1 WHERE b=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE b IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref b b 5 const 1 Using where
|
||||
SELECT * FROM t1 WHERE b<=>NULL;
|
||||
a b
|
||||
99 NULL
|
||||
INSERT INTO t1 VALUES (1,3);
|
||||
ERROR 23000: Duplicate entry '3' for key 'b'
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) engine=heap;
|
||||
INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1);
|
||||
SELECT * FROM t1 WHERE a=1 and b IS NULL;
|
||||
a b c
|
||||
1 NULL NULL
|
||||
1 NULL 1
|
||||
SELECT * FROM t1 WHERE a=1 and c IS NULL;
|
||||
a b c
|
||||
1 NULL NULL
|
||||
1 1 NULL
|
||||
SELECT * FROM t1 WHERE a=1 and b IS NULL and c IS NULL;
|
||||
a b c
|
||||
1 NULL NULL
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int not null, primary key using BTREE (a)) engine=heap;
|
||||
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
|
||||
DELETE from t1 where a < 100;
|
||||
SELECT * from t1;
|
||||
a
|
||||
DROP TABLE t1;
|
||||
create table t1(a int not null, key using btree(a)) engine=heap;
|
||||
insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
|
||||
select a from t1 where a > 2 order by a;
|
||||
a
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
delete from t1 where a < 4;
|
||||
select a from t1 order by a;
|
||||
a
|
||||
insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
|
||||
select a from t1 where a > 4 order by a;
|
||||
a
|
||||
delete from t1 where a > 4;
|
||||
select a from t1 order by a;
|
||||
a
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
select a from t1 where a > 3 order by a;
|
||||
a
|
||||
delete from t1 where a >= 2;
|
||||
select a from t1 order by a;
|
||||
a
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
End of 4.1 tests
|
||||
CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
|
||||
INSERT INTO t1 VALUES(0);
|
||||
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
|
||||
INDEX_LENGTH
|
||||
21
|
||||
UPDATE t1 SET val=1;
|
||||
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
|
||||
INDEX_LENGTH
|
||||
21
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
|
||||
INSERT INTO t1 VALUES(NULL),(NULL);
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
368
mysql-test/suite/pbxt/r/heap_hash.result
Normal file
368
mysql-test/suite/pbxt/r/heap_hash.result
Normal file
@@ -0,0 +1,368 @@
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where a=1 or a=0;
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
select * from t1 where a=4;
|
||||
a b
|
||||
4 4
|
||||
update t1 set b=5 where a=4;
|
||||
update t1 set b=b+1 where a>=3;
|
||||
replace t1 values (3,3);
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 3
|
||||
4 6
|
||||
alter table t1 add c int not null, add key using HASH (c,a);
|
||||
drop table t1;
|
||||
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps";
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where a > 0;
|
||||
select * from t1;
|
||||
a b
|
||||
drop table t1;
|
||||
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps";
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
drop table t1;
|
||||
create table t1 (a int not null) engine=heap;
|
||||
insert into t1 values (869751),(736494),(226312),(802616),(728912);
|
||||
select * from t1 where a > 736494;
|
||||
a
|
||||
869751
|
||||
802616
|
||||
alter table t1 add unique uniq_id using HASH (a);
|
||||
select * from t1 where a > 736494;
|
||||
a
|
||||
869751
|
||||
802616
|
||||
select * from t1 where a = 736494;
|
||||
a
|
||||
736494
|
||||
select * from t1 where a=869751 or a=736494;
|
||||
a
|
||||
736494
|
||||
869751
|
||||
select * from t1 where a in (869751,736494,226312,802616);
|
||||
a
|
||||
226312
|
||||
736494
|
||||
802616
|
||||
869751
|
||||
alter table t1 engine=myisam;
|
||||
explain select * from t1 where a in (869751,736494,226312,802616);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
|
||||
drop table t1;
|
||||
create table t1 (x int not null, y int not null, key x using HASH (x), unique y using HASH (y))
|
||||
engine=heap;
|
||||
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
|
||||
select * from t1 where x=1;
|
||||
x y
|
||||
1 3
|
||||
1 1
|
||||
select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
x y x y
|
||||
1 1 1 1
|
||||
2 2 2 2
|
||||
1 3 1 1
|
||||
2 4 2 2
|
||||
2 5 2 2
|
||||
2 6 2 2
|
||||
explain select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL x NULL NULL NULL 6
|
||||
1 SIMPLE t2 eq_ref y y 4 test.t1.x 1
|
||||
drop table t1;
|
||||
create table t1 (a int) engine=heap;
|
||||
insert into t1 values(1);
|
||||
select max(a) from t1;
|
||||
max(a)
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using HASH (a), key using HASH (b) ) ENGINE=HEAP;
|
||||
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
|
||||
select * from t1 where a=1;
|
||||
a b
|
||||
1 6
|
||||
1 5
|
||||
1 4
|
||||
1 3
|
||||
1 2
|
||||
1 1
|
||||
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
|
||||
select * from t1 where a=1;
|
||||
a b
|
||||
1 6
|
||||
1 5
|
||||
1 4
|
||||
1 3
|
||||
1 2
|
||||
1 1
|
||||
1 6
|
||||
1 5
|
||||
1 4
|
||||
1 3
|
||||
1 2
|
||||
1 1
|
||||
drop table t1;
|
||||
create table t1 (id int unsigned not null, primary key using HASH (id)) engine=HEAP;
|
||||
insert into t1 values(1);
|
||||
select max(id) from t1;
|
||||
max(id)
|
||||
1
|
||||
insert into t1 values(2);
|
||||
select max(id) from t1;
|
||||
max(id)
|
||||
2
|
||||
replace into t1 values(1);
|
||||
drop table t1;
|
||||
create table t1 (n int) engine=heap;
|
||||
drop table t1;
|
||||
create table t1 (n int) engine=heap;
|
||||
drop table if exists t1;
|
||||
CREATE table t1(f1 int not null,f2 char(20) not
|
||||
null,index(f2)) engine=heap;
|
||||
INSERT into t1 set f1=12,f2="bill";
|
||||
INSERT into t1 set f1=13,f2="bill";
|
||||
INSERT into t1 set f1=14,f2="bill";
|
||||
INSERT into t1 set f1=15,f2="bill";
|
||||
INSERT into t1 set f1=16,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
delete from t1 where f2="bill";
|
||||
select * from t1;
|
||||
f1 f2
|
||||
16 ted
|
||||
12 ted
|
||||
12 ted
|
||||
12 ted
|
||||
12 ted
|
||||
drop table t1;
|
||||
create table t1 (btn char(10) not null, key using HASH (btn)) engine=heap;
|
||||
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
|
||||
explain select * from t1 where btn like "q%";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where
|
||||
select * from t1 where btn like "q%";
|
||||
btn
|
||||
alter table t1 add column new_col char(1) not null, add key using HASH (btn,new_col), drop key btn;
|
||||
update t1 set new_col=left(btn,1);
|
||||
explain select * from t1 where btn="a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where
|
||||
explain select * from t1 where btn="a" and new_col="a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref btn btn 11 const,const 2 Using where
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a int default NULL,
|
||||
b int default NULL,
|
||||
KEY a using HASH (a),
|
||||
UNIQUE b using HASH (b)
|
||||
) engine=heap;
|
||||
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
|
||||
SELECT * FROM t1 WHERE a=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE a IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 2 Using where
|
||||
SELECT * FROM t1 WHERE a<=>NULL;
|
||||
a b
|
||||
NULL 99
|
||||
SELECT * FROM t1 WHERE b=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE b IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref b b 5 const 1 Using where
|
||||
SELECT * FROM t1 WHERE b<=>NULL;
|
||||
a b
|
||||
99 NULL
|
||||
INSERT INTO t1 VALUES (1,3);
|
||||
ERROR 23000: Duplicate entry '3' for key 'b'
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int not null, primary key using HASH (a)) engine=heap;
|
||||
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
|
||||
DELETE from t1 where a < 100;
|
||||
SELECT * from t1;
|
||||
a
|
||||
DROP TABLE t1;
|
||||
create table t1
|
||||
(
|
||||
a char(8) not null,
|
||||
b char(20) not null,
|
||||
c int not null,
|
||||
key (a)
|
||||
) engine=heap;
|
||||
insert into t1 values ('aaaa', 'prefill-hash=5',0);
|
||||
insert into t1 values ('aaab', 'prefill-hash=0',0);
|
||||
insert into t1 values ('aaac', 'prefill-hash=7',0);
|
||||
insert into t1 values ('aaad', 'prefill-hash=2',0);
|
||||
insert into t1 values ('aaae', 'prefill-hash=1',0);
|
||||
insert into t1 values ('aaaf', 'prefill-hash=4',0);
|
||||
insert into t1 values ('aaag', 'prefill-hash=3',0);
|
||||
insert into t1 values ('aaah', 'prefill-hash=6',0);
|
||||
explain select * from t1 where a='aaaa';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaac';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaad';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
insert into t1 select * from t1;
|
||||
flush tables;
|
||||
explain select * from t1 where a='aaaa';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaac';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaad';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
flush tables;
|
||||
explain select * from t1 where a='aaaa';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaac';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaad';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
create table t2 as select * from t1;
|
||||
delete from t1;
|
||||
insert into t1 select * from t2;
|
||||
explain select * from t1 where a='aaaa';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaac';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaad';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
drop table t1, t2;
|
||||
create table t1 (
|
||||
id int unsigned not null primary key auto_increment,
|
||||
name varchar(20) not null,
|
||||
index heap_idx(name),
|
||||
index btree_idx using btree(name)
|
||||
) engine=heap;
|
||||
create table t2 (
|
||||
id int unsigned not null primary key auto_increment,
|
||||
name varchar(20) not null,
|
||||
index btree_idx using btree(name),
|
||||
index heap_idx(name)
|
||||
) engine=heap;
|
||||
insert into t1 (name) values ('Matt'), ('Lilu'), ('Corbin'), ('Carly'),
|
||||
('Suzy'), ('Hoppy'), ('Burrito'), ('Mimi'), ('Sherry'), ('Ben'), ('Phil'),
|
||||
('Emily'), ('Mike');
|
||||
insert into t2 select * from t1;
|
||||
explain select * from t1 where name='matt';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t2 where name='matt';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t1 where name='Lilu';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t2 where name='Lilu';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t1 where name='Phil';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t2 where name='Phil';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t1 where name='Lilu';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t2 where name='Lilu';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 22 const 1 Using where
|
||||
insert into t1 (name) select name from t2;
|
||||
insert into t1 (name) select name from t2;
|
||||
insert into t1 (name) select name from t2;
|
||||
insert into t1 (name) select name from t2;
|
||||
insert into t1 (name) select name from t2;
|
||||
insert into t1 (name) select name from t2;
|
||||
flush tables;
|
||||
select count(*) from t1 where name='Matt';
|
||||
count(*)
|
||||
7
|
||||
explain select * from t1 ignore index (btree_idx) where name='matt';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref heap_idx heap_idx 22 const 7 Using where
|
||||
show index from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 id NULL 91 NULL NULL HASH
|
||||
t1 1 heap_idx 1 name NULL 13 NULL NULL HASH
|
||||
t1 1 btree_idx 1 name A NULL NULL NULL BTREE
|
||||
show index from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 id NULL 91 NULL NULL HASH
|
||||
t1 1 heap_idx 1 name NULL 13 NULL NULL HASH
|
||||
t1 1 btree_idx 1 name A NULL NULL NULL BTREE
|
||||
create table t3
|
||||
(
|
||||
a varchar(20) not null,
|
||||
b varchar(20) not null,
|
||||
key (a,b)
|
||||
) engine=heap;
|
||||
insert into t3 select name, name from t1;
|
||||
show index from t3;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t3 1 a 1 a NULL NULL NULL NULL HASH
|
||||
t3 1 a 2 b NULL 13 NULL NULL HASH
|
||||
show index from t3;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t3 1 a 1 a NULL NULL NULL NULL HASH
|
||||
t3 1 a 2 b NULL 13 NULL NULL HASH
|
||||
explain select * from t1 ignore key(btree_idx), t3 where t1.name='matt' and t3.a = concat('',t1.name) and t3.b=t1.name;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref heap_idx heap_idx 22 const 7 Using where
|
||||
1 SIMPLE t3 ref a a 44 func,const 7 Using where
|
||||
drop table t1, t2, t3;
|
||||
create temporary table t1 ( a int, index (a) ) engine=memory;
|
||||
insert into t1 values (1),(2),(3),(4),(5);
|
||||
select a from t1 where a in (1,3);
|
||||
a
|
||||
1
|
||||
3
|
||||
explain select a from t1 where a in (1,3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 4 Using where
|
||||
drop table t1;
|
||||
268
mysql-test/suite/pbxt/r/help.result
Normal file
268
mysql-test/suite/pbxt/r/help.result
Normal file
@@ -0,0 +1,268 @@
|
||||
insert into mysql.help_category(help_category_id,name)values(10001,'impossible_category_1');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @category1_id:= 10001;
|
||||
@category1_id:= 10001
|
||||
10001
|
||||
insert into mysql.help_category(help_category_id,name)values(10002,'impossible_category_2');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @category2_id:= 10002;
|
||||
@category2_id:= 10002
|
||||
10002
|
||||
insert into mysql.help_category(help_category_id,name,parent_category_id)values(10003,'impossible_category_3',@category2_id);
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @category3_id:= 10003;
|
||||
@category3_id:= 10003
|
||||
10003
|
||||
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(10101,'impossible_function_1',@category1_id,'description of \n impossible_function1\n','example of \n impossible_function1');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @topic1_id:= 10101;
|
||||
@topic1_id:= 10101
|
||||
10101
|
||||
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(10102,'impossible_function_2',@category1_id,'description of \n impossible_function2\n','example of \n impossible_function2');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @topic2_id:= 10102;
|
||||
@topic2_id:= 10102
|
||||
10102
|
||||
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(10103,'impossible_function_3',@category2_id,'description of \n impossible_function3\n','example of \n impossible_function3');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @topic3_id:= 10103;
|
||||
@topic3_id:= 10103
|
||||
10103
|
||||
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(10104,'impossible_function_4',@category2_id,'description of \n impossible_function4\n','example of \n impossible_function4');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @topic4_id:= 10104;
|
||||
@topic4_id:= 10104
|
||||
10104
|
||||
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(10105,'impossible_function_7',@category3_id,'description of \n impossible_function5\n','example of \n impossible_function7');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @topic5_id:= 10105;
|
||||
@topic5_id:= 10105
|
||||
10105
|
||||
insert into mysql.help_keyword(help_keyword_id,name)values(10201,'impossible_function_1');
|
||||
select @keyword1_id:= 10201;
|
||||
@keyword1_id:= 10201
|
||||
10201
|
||||
insert into mysql.help_keyword(help_keyword_id,name)values(10202,'impossible_function_5');
|
||||
select @keyword2_id:= 10202;
|
||||
@keyword2_id:= 10202
|
||||
10202
|
||||
insert into mysql.help_keyword(help_keyword_id,name)values(10203,'impossible_function_6');
|
||||
select @keyword3_id:= 10203;
|
||||
@keyword3_id:= 10203
|
||||
10203
|
||||
insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword1_id,@topic2_id);
|
||||
insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword2_id,@topic1_id);
|
||||
insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword3_id,@topic3_id);
|
||||
insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword3_id,@topic4_id);
|
||||
help 'function_of_my_dream';
|
||||
name is_it_category
|
||||
help '%possible_f%';
|
||||
name is_it_category
|
||||
impossible_function_1 N
|
||||
impossible_function_2 N
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
impossible_function_7 N
|
||||
help 'impossible_func%';
|
||||
name is_it_category
|
||||
impossible_function_1 N
|
||||
impossible_function_2 N
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
impossible_function_7 N
|
||||
help 'impossible_category%';
|
||||
name is_it_category
|
||||
impossible_category_1 Y
|
||||
impossible_category_2 Y
|
||||
impossible_category_3 Y
|
||||
help 'impossible_%';
|
||||
name is_it_category
|
||||
impossible_function_1 N
|
||||
impossible_function_2 N
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
impossible_function_7 N
|
||||
impossible_category_1 Y
|
||||
impossible_category_2 Y
|
||||
impossible_category_3 Y
|
||||
help '%function_1';
|
||||
name description example
|
||||
impossible_function_1 description of
|
||||
impossible_function1
|
||||
example of
|
||||
impossible_function1
|
||||
help '%function_2';
|
||||
name description example
|
||||
impossible_function_2 description of
|
||||
impossible_function2
|
||||
example of
|
||||
impossible_function2
|
||||
help '%function_3';
|
||||
name description example
|
||||
impossible_function_3 description of
|
||||
impossible_function3
|
||||
example of
|
||||
impossible_function3
|
||||
help '%function_4';
|
||||
name description example
|
||||
impossible_function_4 description of
|
||||
impossible_function4
|
||||
example of
|
||||
impossible_function4
|
||||
help '%function_5';
|
||||
name description example
|
||||
impossible_function_1 description of
|
||||
impossible_function1
|
||||
example of
|
||||
impossible_function1
|
||||
help '%function_6';
|
||||
name is_it_category
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
help '%function_7';
|
||||
name description example
|
||||
impossible_function_7 description of
|
||||
impossible_function5
|
||||
example of
|
||||
impossible_function7
|
||||
help '%category_2';
|
||||
source_category_name name is_it_category
|
||||
impossible_category_2 impossible_function_3 N
|
||||
impossible_category_2 impossible_function_4 N
|
||||
impossible_category_2 impossible_category_3 Y
|
||||
help 'impossible_function_1';
|
||||
name description example
|
||||
impossible_function_1 description of
|
||||
impossible_function1
|
||||
example of
|
||||
impossible_function1
|
||||
help 'impossible_category_1';
|
||||
source_category_name name is_it_category
|
||||
impossible_category_1 impossible_function_1 N
|
||||
impossible_category_1 impossible_function_2 N
|
||||
alter table mysql.help_relation engine=innodb;
|
||||
alter table mysql.help_keyword engine=innodb;
|
||||
alter table mysql.help_topic engine=innodb;
|
||||
alter table mysql.help_category engine=innodb;
|
||||
help 'function_of_my_dream';
|
||||
name is_it_category
|
||||
help '%possible_f%';
|
||||
name is_it_category
|
||||
impossible_function_1 N
|
||||
impossible_function_2 N
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
impossible_function_7 N
|
||||
help 'impossible_func%';
|
||||
name is_it_category
|
||||
impossible_function_1 N
|
||||
impossible_function_2 N
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
impossible_function_7 N
|
||||
help 'impossible_category%';
|
||||
name is_it_category
|
||||
impossible_category_1 Y
|
||||
impossible_category_2 Y
|
||||
impossible_category_3 Y
|
||||
help 'impossible_%';
|
||||
name is_it_category
|
||||
impossible_function_1 N
|
||||
impossible_function_2 N
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
impossible_function_7 N
|
||||
impossible_category_1 Y
|
||||
impossible_category_2 Y
|
||||
impossible_category_3 Y
|
||||
help '%function_1';
|
||||
name description example
|
||||
impossible_function_1 description of
|
||||
impossible_function1
|
||||
example of
|
||||
impossible_function1
|
||||
help '%function_2';
|
||||
name description example
|
||||
impossible_function_2 description of
|
||||
impossible_function2
|
||||
example of
|
||||
impossible_function2
|
||||
help '%function_3';
|
||||
name description example
|
||||
impossible_function_3 description of
|
||||
impossible_function3
|
||||
example of
|
||||
impossible_function3
|
||||
help '%function_4';
|
||||
name description example
|
||||
impossible_function_4 description of
|
||||
impossible_function4
|
||||
example of
|
||||
impossible_function4
|
||||
help '%function_5';
|
||||
name description example
|
||||
impossible_function_1 description of
|
||||
impossible_function1
|
||||
example of
|
||||
impossible_function1
|
||||
help '%function_6';
|
||||
name is_it_category
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
help '%function_7';
|
||||
name description example
|
||||
impossible_function_7 description of
|
||||
impossible_function5
|
||||
example of
|
||||
impossible_function7
|
||||
help '%category_2';
|
||||
source_category_name name is_it_category
|
||||
impossible_category_2 impossible_function_3 N
|
||||
impossible_category_2 impossible_function_4 N
|
||||
impossible_category_2 impossible_category_3 Y
|
||||
help 'impossible_function_1';
|
||||
name description example
|
||||
impossible_function_1 description of
|
||||
impossible_function1
|
||||
example of
|
||||
impossible_function1
|
||||
help 'impossible_category_1';
|
||||
source_category_name name is_it_category
|
||||
impossible_category_1 impossible_function_1 N
|
||||
impossible_category_1 impossible_function_2 N
|
||||
alter table mysql.help_relation engine=myisam;
|
||||
alter table mysql.help_keyword engine=myisam;
|
||||
alter table mysql.help_topic engine=myisam;
|
||||
alter table mysql.help_category engine=myisam;
|
||||
delete from mysql.help_topic where help_topic_id=@topic1_id;
|
||||
delete from mysql.help_topic where help_topic_id=@topic2_id;
|
||||
delete from mysql.help_topic where help_topic_id=@topic3_id;
|
||||
delete from mysql.help_topic where help_topic_id=@topic4_id;
|
||||
delete from mysql.help_topic where help_topic_id=@topic5_id;
|
||||
delete from mysql.help_category where help_category_id=@category3_id;
|
||||
delete from mysql.help_category where help_category_id=@category2_id;
|
||||
delete from mysql.help_category where help_category_id=@category1_id;
|
||||
delete from mysql.help_keyword where help_keyword_id=@keyword1_id;
|
||||
delete from mysql.help_keyword where help_keyword_id=@keyword2_id;
|
||||
delete from mysql.help_keyword where help_keyword_id=@keyword3_id;
|
||||
delete from mysql.help_relation where help_keyword_id=@keyword1_id and help_topic_id=@topic2_id;
|
||||
delete from mysql.help_relation where help_keyword_id=@keyword2_id and help_topic_id=@topic1_id;
|
||||
delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic3_id;
|
||||
delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic4_id;
|
||||
End of 4.1 tests.
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (i INT);
|
||||
LOCK TABLES t1 WRITE;
|
||||
HELP no_such_topic;
|
||||
name is_it_category
|
||||
UNLOCK TABLES;
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests.
|
||||
364
mysql-test/suite/pbxt/r/insert.result
Normal file
364
mysql-test/suite/pbxt/r/insert.result
Normal file
@@ -0,0 +1,364 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
create table t1 (a int not null);
|
||||
insert into t1 values (1);
|
||||
insert into t1 values (a+2);
|
||||
insert into t1 values (a+3),(a+4);
|
||||
insert into t1 values (5),(a+6);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
drop table t1;
|
||||
create table t1 (id int not null auto_increment primary key, username varchar(32) not null, unique (username));
|
||||
insert into t1 values (0,"mysql");
|
||||
insert into t1 values (0,"mysql ab");
|
||||
insert into t1 values (0,"mysql a");
|
||||
insert into t1 values (0,"r1manic");
|
||||
insert into t1 values (0,"r1man");
|
||||
drop table t1;
|
||||
create table t1 (a int not null auto_increment, primary key (a), t timestamp, c char(10) default "hello", i int);
|
||||
insert into t1 values (default,default,default,default), (default,default,default,default), (4,0,"a",5),(default,default,default,default);
|
||||
select a,t>0,c,i from t1;
|
||||
a t>0 c i
|
||||
1 1 hello NULL
|
||||
2 1 hello NULL
|
||||
4 0 a 5
|
||||
5 1 hello NULL
|
||||
truncate table t1;
|
||||
insert into t1 set a=default,t=default,c=default;
|
||||
insert into t1 set a=default,t=default,c=default,i=default;
|
||||
insert into t1 set a=4,t=0,c="a",i=5;
|
||||
insert into t1 set a=5,t=0,c="a",i=null;
|
||||
insert into t1 set a=default,t=default,c=default,i=default;
|
||||
select a,t>0,c,i from t1;
|
||||
a t>0 c i
|
||||
1 1 hello NULL
|
||||
2 1 hello NULL
|
||||
4 0 a 5
|
||||
5 0 a NULL
|
||||
6 1 hello NULL
|
||||
drop table t1;
|
||||
create table t1 (sid char(20), id int(2) NOT NULL auto_increment, key(sid, id));
|
||||
insert into t1 values ('skr',NULL),('skr',NULL),('test',NULL);
|
||||
select * from t1;
|
||||
sid id
|
||||
skr 1
|
||||
skr 2
|
||||
test 3
|
||||
insert into t1 values ('rts',NULL),('rts',NULL),('test',NULL);
|
||||
select * from t1;
|
||||
sid id
|
||||
rts 4
|
||||
rts 5
|
||||
skr 1
|
||||
skr 2
|
||||
test 3
|
||||
test 6
|
||||
drop table t1;
|
||||
create table t1 (id int NOT NULL DEFAULT 8);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 23000: Column 'id' cannot be null
|
||||
insert into t1 values (1), (NULL), (2);
|
||||
Warnings:
|
||||
Warning 1048 Column 'id' cannot be null
|
||||
select * from t1;
|
||||
id
|
||||
1
|
||||
0
|
||||
2
|
||||
drop table t1;
|
||||
create table t1 (email varchar(50));
|
||||
insert into t1 values ('sasha@mysql.com'),('monty@mysql.com'),('foo@hotmail.com'),('foo@aol.com'),('bar@aol.com');
|
||||
create table t2(id int not null auto_increment primary key, t2 varchar(50), unique(t2));
|
||||
insert into t2 (t2) select distinct substring(email, locate('@', email)+1) from t1;
|
||||
select * from t2;
|
||||
id t2
|
||||
1 mysql.com
|
||||
2 hotmail.com
|
||||
3 aol.com
|
||||
drop table t1,t2;
|
||||
drop database if exists mysqltest;
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
create table t1 (c int);
|
||||
insert into mysqltest.t1 set mysqltest.t1.c = '1';
|
||||
drop database mysqltest;
|
||||
use test;
|
||||
create table t1(number int auto_increment primary key, original_value varchar(50), f_double double, f_float float, f_double_7_2 double(7,2), f_float_4_3 float (4,3), f_double_u double unsigned, f_float_u float unsigned, f_double_15_1_u double(15,1) unsigned, f_float_3_1_u float (3,1) unsigned);
|
||||
set @value= "aa";
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'f_double' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_7_2' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_4_3' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_15_1_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 1
|
||||
original_value aa
|
||||
f_double 0
|
||||
f_float 0
|
||||
f_double_7_2 0.00
|
||||
f_float_4_3 0.000
|
||||
f_double_u 0
|
||||
f_float_u 0
|
||||
f_double_15_1_u 0.0
|
||||
f_float_3_1_u 0.0
|
||||
set @value= "1aa";
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'f_double' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_7_2' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_4_3' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_15_1_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 2
|
||||
original_value 1aa
|
||||
f_double 1
|
||||
f_float 1
|
||||
f_double_7_2 1.00
|
||||
f_float_4_3 1.000
|
||||
f_double_u 1
|
||||
f_float_u 1
|
||||
f_double_15_1_u 1.0
|
||||
f_float_3_1_u 1.0
|
||||
set @value= "aa1";
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'f_double' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_7_2' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_4_3' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_15_1_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 3
|
||||
original_value aa1
|
||||
f_double 0
|
||||
f_float 0
|
||||
f_double_7_2 0.00
|
||||
f_float_4_3 0.000
|
||||
f_double_u 0
|
||||
f_float_u 0
|
||||
f_double_15_1_u 0.0
|
||||
f_float_3_1_u 0.0
|
||||
set @value= "1e+1111111111a";
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f_double' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_7_2' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_7_2' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_4_3' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_4_3' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 4
|
||||
original_value 1e+1111111111a
|
||||
f_double 1.79769313486232e+308
|
||||
f_float 3.40282e+38
|
||||
f_double_7_2 99999.99
|
||||
f_float_4_3 9.999
|
||||
f_double_u 1.79769313486232e+308
|
||||
f_float_u 3.40282e+38
|
||||
f_double_15_1_u 99999999999999.9
|
||||
f_float_3_1_u 99.9
|
||||
set @value= "-1e+1111111111a";
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f_double' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_7_2' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_7_2' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_4_3' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_4_3' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 5
|
||||
original_value -1e+1111111111a
|
||||
f_double -1.79769313486232e+308
|
||||
f_float -3.40282e+38
|
||||
f_double_7_2 -99999.99
|
||||
f_float_4_3 -9.999
|
||||
f_double_u 0
|
||||
f_float_u 0
|
||||
f_double_15_1_u 0.0
|
||||
f_float_3_1_u 0.0
|
||||
set @value= 1e+1111111111;
|
||||
ERROR 22007: Illegal double '1e+1111111111' value found during parsing
|
||||
set @value= -1e+1111111111;
|
||||
ERROR 22007: Illegal double '1e+1111111111' value found during parsing
|
||||
set @value= 1e+111;
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f_float' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_7_2' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_4_3' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 6
|
||||
original_value 1e+111
|
||||
f_double 1e+111
|
||||
f_float 3.40282e+38
|
||||
f_double_7_2 99999.99
|
||||
f_float_4_3 9.999
|
||||
f_double_u 1e+111
|
||||
f_float_u 3.40282e+38
|
||||
f_double_15_1_u 99999999999999.9
|
||||
f_float_3_1_u 99.9
|
||||
set @value= -1e+111;
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f_float' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_7_2' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_4_3' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 7
|
||||
original_value -1e+111
|
||||
f_double -1e+111
|
||||
f_float -3.40282e+38
|
||||
f_double_7_2 -99999.99
|
||||
f_float_4_3 -9.999
|
||||
f_double_u 0
|
||||
f_float_u 0
|
||||
f_double_15_1_u 0.0
|
||||
f_float_3_1_u 0.0
|
||||
set @value= 1;
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 8
|
||||
original_value 1
|
||||
f_double 1
|
||||
f_float 1
|
||||
f_double_7_2 1.00
|
||||
f_float_4_3 1.000
|
||||
f_double_u 1
|
||||
f_float_u 1
|
||||
f_double_15_1_u 1.0
|
||||
f_float_3_1_u 1.0
|
||||
set @value= -1;
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f_double_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 9
|
||||
original_value -1
|
||||
f_double -1
|
||||
f_float -1
|
||||
f_double_7_2 -1.00
|
||||
f_float_4_3 -1.000
|
||||
f_double_u 0
|
||||
f_float_u 0
|
||||
f_double_15_1_u 0.0
|
||||
f_float_3_1_u 0.0
|
||||
drop table t1;
|
||||
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));
|
||||
select count(*) from t2;
|
||||
count(*)
|
||||
500
|
||||
insert into t2 select t1.* from t1, t2 t, t3 where t1.id1 = t.id2 and t.id2 = t3.id3;
|
||||
select count(*) from t2;
|
||||
count(*)
|
||||
25500
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 (a,b) values (a,b);
|
||||
insert into t1 SET a=1, b=a+1;
|
||||
insert into t1 (a,b) select 1,2;
|
||||
INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
|
||||
prepare stmt1 from ' replace into t1 (a,a) select 100, ''hundred'' ';
|
||||
execute stmt1;
|
||||
ERROR 42000: Column 'a' specified twice
|
||||
insert into t1 (a,b,b) values (1,1,1);
|
||||
ERROR 42000: Column 'b' specified twice
|
||||
insert into t1 (a,a) values (1,1,1);
|
||||
ERROR 21S01: Column count doesn't match value count at row 1
|
||||
insert into t1 (a,a) values (1,1);
|
||||
ERROR 42000: Column 'a' specified twice
|
||||
insert into t1 SET a=1,b=2,a=1;
|
||||
ERROR 42000: Column 'a' specified twice
|
||||
insert into t1 (b,b) select 1,2;
|
||||
ERROR 42000: Column 'b' specified twice
|
||||
INSERT INTO t1 (b,b) SELECT 0,0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
|
||||
ERROR 42000: Column 'b' specified twice
|
||||
drop table t1;
|
||||
create table t1 (id int primary key, data int);
|
||||
insert into t1 values (1, 1), (2, 2), (3, 3);
|
||||
select row_count();
|
||||
row_count()
|
||||
3
|
||||
insert ignore into t1 values (1, 1);
|
||||
select row_count();
|
||||
row_count()
|
||||
0
|
||||
replace into t1 values (1, 11);
|
||||
select row_count();
|
||||
row_count()
|
||||
2
|
||||
replace into t1 values (4, 4);
|
||||
select row_count();
|
||||
row_count()
|
||||
1
|
||||
insert into t1 values (2, 2) on duplicate key update data= data + 10;
|
||||
select row_count();
|
||||
row_count()
|
||||
2
|
||||
insert into t1 values (5, 5) on duplicate key update data= data + 10;
|
||||
select row_count();
|
||||
row_count()
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (id int primary key auto_increment, data int, unique(data));
|
||||
insert ignore into t1 values(NULL,100),(NULL,110),(NULL,120);
|
||||
insert ignore into t1 values(NULL,10),(NULL,20),(NULL,110),(NULL,120),(NULL,100),(NULL,90);
|
||||
insert ignore into t1 values(NULL,130),(NULL,140),(500,110),(550,120),(450,100),(NULL,150);
|
||||
select * from t1 order by id;
|
||||
id data
|
||||
1 100
|
||||
2 110
|
||||
3 120
|
||||
4 10
|
||||
5 20
|
||||
6 90
|
||||
7 130
|
||||
8 140
|
||||
551 150
|
||||
706
mysql-test/suite/pbxt/r/insert_select.result
Normal file
706
mysql-test/suite/pbxt/r/insert_select.result
Normal file
@@ -0,0 +1,706 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
|
||||
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
|
||||
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
|
||||
insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
|
||||
insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
|
||||
ERROR 23000: Duplicate entry '16' for key 'PRIMARY'
|
||||
insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1;
|
||||
select * from t2;
|
||||
payoutID
|
||||
1
|
||||
4
|
||||
6
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
14
|
||||
16
|
||||
19
|
||||
20
|
||||
22
|
||||
drop table t1,t2;
|
||||
CREATE TABLE `t1` (
|
||||
`numeropost` bigint(20) unsigned NOT NULL default '0',
|
||||
`icone` tinyint(4) unsigned NOT NULL default '0',
|
||||
`numreponse` bigint(20) unsigned NOT NULL auto_increment,
|
||||
`contenu` text NOT NULL,
|
||||
`pseudo` varchar(50) NOT NULL default '',
|
||||
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`ip` bigint(11) NOT NULL default '0',
|
||||
`signature` tinyint(1) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`numeropost`,`numreponse`)
|
||||
,KEY `ip` (`ip`),
|
||||
KEY `date` (`date`),
|
||||
KEY `pseudo` (`pseudo`),
|
||||
KEY `numreponse` (`numreponse`)
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE `t2` (
|
||||
`numeropost` bigint(20) unsigned NOT NULL default '0',
|
||||
`icone` tinyint(4) unsigned NOT NULL default '0',
|
||||
`numreponse` bigint(20) unsigned NOT NULL auto_increment,
|
||||
`contenu` text NOT NULL,
|
||||
`pseudo` varchar(50) NOT NULL default '',
|
||||
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`ip` bigint(11) NOT NULL default '0',
|
||||
`signature` tinyint(1) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`numeropost`,`numreponse`),
|
||||
KEY `ip` (`ip`),
|
||||
KEY `date` (`date`),
|
||||
KEY `pseudo` (`pseudo`),
|
||||
KEY `numreponse` (`numreponse`)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2
|
||||
(numeropost,icone,numreponse,contenu,pseudo,date,ip,signature) VALUES
|
||||
(9,1,56,'test','joce','2001-07-25 13:50:53'
|
||||
,3649052399,0);
|
||||
INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip)
|
||||
SELECT 1618,icone,contenu,pseudo,date,signature,ip FROM t2
|
||||
WHERE numeropost=9 ORDER BY numreponse ASC;
|
||||
show variables like '%bulk%';
|
||||
Variable_name Value
|
||||
bulk_insert_buffer_size 8388608
|
||||
INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip)
|
||||
SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM t2
|
||||
WHERE numeropost=9 ORDER BY numreponse ASC;
|
||||
DROP TABLE t1,t2;
|
||||
create table t1 (a int not null);
|
||||
create table t2 (a int not null);
|
||||
insert into t1 values (1);
|
||||
insert into t1 values (a+2);
|
||||
insert into t1 values (a+3);
|
||||
insert into t1 values (4),(a+5);
|
||||
insert into t1 select * from t1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
insert into t1 select * from t1 as t2;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
insert into t2 select * from t1 as t2;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
insert into t1 select t2.a from t1,t2;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
insert into t1 select * from t1,t1;
|
||||
ERROR 42000: Not unique table/alias: 't1'
|
||||
drop table t1,t2;
|
||||
create table t1 (a int not null primary key, b char(10));
|
||||
create table t2 (a int not null, b char(10));
|
||||
insert into t1 values (1,"t1:1"),(3,"t1:3");
|
||||
insert into t2 values (2,"t2:2"), (3,"t2:3");
|
||||
insert into t1 select * from t2;
|
||||
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
|
||||
select * from t1;
|
||||
a b
|
||||
1 t1:1
|
||||
3 t1:3
|
||||
replace into t1 select * from t2;
|
||||
select * from t1;
|
||||
a b
|
||||
1 t1:1
|
||||
2 t2:2
|
||||
3 t2:3
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 ( USID INTEGER UNSIGNED, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User CHAR(32) NOT NULL DEFAULT '<UNKNOWN>', NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL);
|
||||
CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User TEXT NOT NULL, NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL, INDEX(USID,ServerID,NASAddr,SessionID), INDEX(AssignedAddr));
|
||||
INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121);
|
||||
INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1;
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1(
|
||||
Month date NOT NULL,
|
||||
Type tinyint(3) unsigned NOT NULL auto_increment,
|
||||
Field int(10) unsigned NOT NULL,
|
||||
Count int(10) unsigned NOT NULL,
|
||||
UNIQUE KEY Month (Month,Type,Field)
|
||||
);
|
||||
insert into t1 Values
|
||||
(20030901, 1, 1, 100),
|
||||
(20030901, 1, 2, 100),
|
||||
(20030901, 2, 1, 100),
|
||||
(20030901, 2, 2, 100),
|
||||
(20030901, 3, 1, 100);
|
||||
select * from t1;
|
||||
Month Type Field Count
|
||||
2003-09-01 1 1 100
|
||||
2003-09-01 1 2 100
|
||||
2003-09-01 2 1 100
|
||||
2003-09-01 2 2 100
|
||||
2003-09-01 3 1 100
|
||||
Select null, Field, Count From t1 Where Month=20030901 and Type=2;
|
||||
NULL Field Count
|
||||
NULL 1 100
|
||||
NULL 2 100
|
||||
create table t2(No int not null, Field int not null, Count int not null);
|
||||
insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2;
|
||||
Warnings:
|
||||
Warning 1048 Column 'No' cannot be null
|
||||
Warning 1048 Column 'No' cannot be null
|
||||
select * from t2;
|
||||
No Field Count
|
||||
0 1 100
|
||||
0 2 100
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
NO int(11) NOT NULL default '0',
|
||||
SEQ int(11) NOT NULL default '0',
|
||||
PRIMARY KEY (ID),
|
||||
KEY t1$NO (SEQ,NO)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 AS NO FROM t1 WHERE (SEQ = 1);
|
||||
select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1);
|
||||
ID NO SEQ
|
||||
1 1 1
|
||||
drop table t1;
|
||||
create table t1 (f1 int);
|
||||
create table t2 (ff1 int unique, ff2 int default 1);
|
||||
insert into t1 values (1),(1),(2);
|
||||
insert into t2(ff1) select f1 from t1 on duplicate key update ff2=ff2+1;
|
||||
select * from t2;
|
||||
ff1 ff2
|
||||
1 2
|
||||
2 1
|
||||
drop table t1, t2;
|
||||
create table t1 (a int unique);
|
||||
create table t2 (a int, b int);
|
||||
create table t3 (c int, d int);
|
||||
insert into t1 values (1),(2);
|
||||
insert into t2 values (1,2);
|
||||
insert into t3 values (1,6),(3,7);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
insert into t1 select a from t2 on duplicate key update a= t1.a + t2.b;
|
||||
select * from t1;
|
||||
a
|
||||
2
|
||||
3
|
||||
insert into t1 select a+1 from t2 on duplicate key update t1.a= t1.a + t2.b+1;
|
||||
select * from t1;
|
||||
a
|
||||
3
|
||||
5
|
||||
insert into t1 select t3.c from t3 on duplicate key update a= a + t3.d;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
5
|
||||
10
|
||||
insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= a + 10;
|
||||
insert into t1 select t2.a from t2 on duplicate key update a= a + t2.b;
|
||||
ERROR 23000: Column 'a' in field list is ambiguous
|
||||
insert into t1 select t2.a from t2 on duplicate key update t2.a= a + t2.b;
|
||||
ERROR 42S22: Unknown column 't2.a' in 'field list'
|
||||
insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= t1.a + t2.b;
|
||||
ERROR 42S22: Unknown column 't2.b' in 'field list'
|
||||
drop table t1,t2,t3;
|
||||
create table t1(f1 varchar(5) key);
|
||||
insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1;
|
||||
insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1;
|
||||
insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1;
|
||||
select * from t1;
|
||||
f1
|
||||
2000
|
||||
2001
|
||||
2002
|
||||
drop table t1;
|
||||
create table t1(x int, y int);
|
||||
create table t2(x int, z int);
|
||||
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(x);
|
||||
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z);
|
||||
ERROR 42S22: Unknown column 'z' in 'field list'
|
||||
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
|
||||
ERROR 42S22: Unknown column 't2.x' in 'field list'
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (a int PRIMARY KEY);
|
||||
INSERT INTO t1 values (1), (2);
|
||||
INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (x int, y int);
|
||||
CREATE TABLE t2 (z int, y int);
|
||||
CREATE TABLE t3 (a int, b int);
|
||||
INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
CREATE DATABASE bug21774_1;
|
||||
CREATE DATABASE bug21774_2;
|
||||
CREATE TABLE bug21774_1.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
|
||||
CREATE TABLE bug21774_2.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
|
||||
CREATE TABLE bug21774_1.t2(id VARCHAR(10) NOT NULL,label VARCHAR(255));
|
||||
INSERT INTO bug21774_2.t1 SELECT t1.* FROM bug21774_1.t1;
|
||||
use bug21774_1;
|
||||
INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1;
|
||||
DROP DATABASE bug21774_1;
|
||||
DROP DATABASE bug21774_2;
|
||||
221
mysql-test/suite/pbxt/r/insert_update.result
Normal file
221
mysql-test/suite/pbxt/r/insert_update.result
Normal file
@@ -0,0 +1,221 @@
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B));
|
||||
INSERT t1 VALUES (1,2,10), (3,4,20);
|
||||
INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE c=c+100;
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 20
|
||||
5 6 30
|
||||
INSERT t1 VALUES (5,7,40) ON DUPLICATE KEY UPDATE c=c+100;
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 20
|
||||
5 6 130
|
||||
INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE c=c+1000;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 1020
|
||||
5 6 130
|
||||
INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE c=c+10000;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10010
|
||||
3 4 1020
|
||||
5 6 130
|
||||
INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4;
|
||||
ERROR 23000: Duplicate entry '4' for key 'b'
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10010
|
||||
3 4 1020
|
||||
5 6 130
|
||||
TRUNCATE TABLE t1;
|
||||
INSERT t1 VALUES (1,2,10), (3,4,20);
|
||||
INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE c=c+100;
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 2 10
|
||||
5 6 30
|
||||
3 4 120
|
||||
8 9 60
|
||||
INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 120
|
||||
5 0 30
|
||||
8 9 60
|
||||
INSERT t1 VALUES (2,1,11), (7,4,40) ON DUPLICATE KEY UPDATE c=c+VALUES(a);
|
||||
SELECT *, VALUES(a) FROM t1 order by a;
|
||||
a b c VALUES(a)
|
||||
1 2 10 NULL
|
||||
2 1 11 NULL
|
||||
3 4 127 NULL
|
||||
5 0 30 NULL
|
||||
8 9 60 NULL
|
||||
explain extended SELECT *, VALUES(a) FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL ROWS 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,values(`test`.`t1`.`a`) AS `VALUES(a)` from `test`.`t1`
|
||||
explain extended select * from t1 where values(a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL ROWS 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where values(`test`.`t1`.`a`)
|
||||
DROP TABLE t1;
|
||||
create table t1(a int primary key, b int);
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
5 5
|
||||
insert into t1 values(4,14),(5,15),(6,16),(7,17),(8,18)
|
||||
on duplicate key update b=b+10;
|
||||
affected rows: 7
|
||||
info: Records: 5 Duplicates: 2 Warnings: 0
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 14
|
||||
5 15
|
||||
6 16
|
||||
7 17
|
||||
8 18
|
||||
replace into t1 values(5,25),(6,26),(7,27),(8,28),(9,29);
|
||||
affected rows: 9
|
||||
info: Records: 5 Duplicates: 4 Warnings: 0
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 14
|
||||
5 25
|
||||
6 26
|
||||
7 27
|
||||
8 28
|
||||
9 29
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B));
|
||||
INSERT t1 VALUES (1,2,10), (3,4,20);
|
||||
INSERT t1 SELECT 5,6,30 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 20
|
||||
5 6 30
|
||||
INSERT t1 SELECT 5,7,40 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 20
|
||||
5 6 130
|
||||
INSERT t1 SELECT 8,4,50 FROM DUAL ON DUPLICATE KEY UPDATE c=c+1000;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 1020
|
||||
5 6 130
|
||||
INSERT t1 SELECT 1,4,60 FROM DUAL ON DUPLICATE KEY UPDATE c=c+10000;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10010
|
||||
3 4 1020
|
||||
5 6 130
|
||||
INSERT t1 SELECT 1,9,70 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100000, b=4;
|
||||
ERROR 23000: Duplicate entry '4' for key 'b'
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10010
|
||||
3 4 1020
|
||||
5 6 130
|
||||
TRUNCATE TABLE t1;
|
||||
INSERT t1 VALUES (1,2,10), (3,4,20);
|
||||
CREATE TABLE t2 (a INT, b INT, c INT, d INT);
|
||||
INSERT t2 VALUES (5,6,30,1), (7,4,40,1), (8,9,60,1);
|
||||
INSERT t2 VALUES (2,1,11,2), (7,4,40,2);
|
||||
INSERT t1 SELECT a,b,c FROM t2 WHERE d=1 ON DUPLICATE KEY UPDATE c=t1.c+100;
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 2 10
|
||||
5 6 30
|
||||
3 4 120
|
||||
8 9 60
|
||||
INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 120
|
||||
5 0 30
|
||||
8 9 60
|
||||
INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=c+VALUES(a);
|
||||
ERROR 23000: Column 'c' in field list is ambiguous
|
||||
INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=t1.c+VALUES(t1.a);
|
||||
SELECT *, VALUES(a) FROM t1 order by a;
|
||||
a b c VALUES(a)
|
||||
1 2 10 NULL
|
||||
2 1 11 NULL
|
||||
3 4 127 NULL
|
||||
5 0 30 NULL
|
||||
8 9 60 NULL
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
create table t1 (a int not null unique) engine=myisam;
|
||||
insert into t1 values (1),(2);
|
||||
insert ignore into t1 select 1 on duplicate key update a=2;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
insert ignore into t1 select a from t1 as t2 on duplicate key update a=t1.a+1 ;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
3
|
||||
insert into t1 select 1 on duplicate key update a=2;
|
||||
select * from t1;
|
||||
a
|
||||
2
|
||||
3
|
||||
insert into t1 select a from t1 on duplicate key update a=a+1 ;
|
||||
ERROR 23000: Column 'a' in field list is ambiguous
|
||||
insert ignore into t1 select a from t1 on duplicate key update a=t1.a+1 ;
|
||||
ERROR 23000: Column 't1.a' in field list is ambiguous
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a BIGINT(20) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (a)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a) ;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1
|
||||
(
|
||||
a BIGINT UNSIGNED,
|
||||
b BIGINT UNSIGNED,
|
||||
PRIMARY KEY (a)
|
||||
);
|
||||
INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
|
||||
IF(VALUES(b) > t1.b, VALUES(b), t1.b);
|
||||
SELECT * FROM t1;
|
||||
a b
|
||||
45 1
|
||||
INSERT INTO t1 VALUES (45, 2) ON DUPLICATE KEY UPDATE b =
|
||||
IF(VALUES(b) > t1.b, VALUES(b), t1.b);
|
||||
SELECT * FROM t1;
|
||||
a b
|
||||
45 2
|
||||
INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
|
||||
IF(VALUES(b) > t1.b, VALUES(b), t1.b);
|
||||
SELECT * FROM t1;
|
||||
a b
|
||||
45 2
|
||||
DROP TABLE t1;
|
||||
822
mysql-test/suite/pbxt/r/join.result
Normal file
822
mysql-test/suite/pbxt/r/join.result
Normal file
@@ -0,0 +1,822 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
CREATE TABLE t1 (S1 INT);
|
||||
CREATE TABLE t2 (S1 INT);
|
||||
INSERT INTO t1 VALUES (1);
|
||||
INSERT INTO t2 VALUES (2);
|
||||
SELECT * FROM t1 JOIN t2;
|
||||
S1 S1
|
||||
1 2
|
||||
SELECT * FROM t1 INNER JOIN t2;
|
||||
S1 S1
|
||||
1 2
|
||||
SELECT * from t1 JOIN t2 USING (S1);
|
||||
S1
|
||||
SELECT * FROM t1 INNER JOIN t2 USING (S1);
|
||||
S1
|
||||
SELECT * from t1 CROSS JOIN t2;
|
||||
S1 S1
|
||||
1 2
|
||||
SELECT * from t1 LEFT JOIN t2 USING(S1);
|
||||
S1
|
||||
1
|
||||
SELECT * from t1 LEFT JOIN t2 ON(t2.S1=2);
|
||||
S1 S1
|
||||
1 2
|
||||
SELECT * from t1 RIGHT JOIN t2 USING(S1);
|
||||
S1
|
||||
2
|
||||
SELECT * from t1 RIGHT JOIN t2 ON(t1.S1=1);
|
||||
S1 S1
|
||||
1 2
|
||||
drop table t1,t2;
|
||||
create table t1 (id int primary key);
|
||||
create table t2 (id int);
|
||||
insert into t1 values (75);
|
||||
insert into t1 values (79);
|
||||
insert into t1 values (78);
|
||||
insert into t1 values (77);
|
||||
replace into t1 values (76);
|
||||
replace into t1 values (76);
|
||||
insert into t1 values (104);
|
||||
insert into t1 values (103);
|
||||
insert into t1 values (102);
|
||||
insert into t1 values (101);
|
||||
insert into t1 values (105);
|
||||
insert into t1 values (106);
|
||||
insert into t1 values (107);
|
||||
insert into t2 values (107),(75),(1000);
|
||||
select t1.id, t2.id from t1, t2 where t2.id = t1.id;
|
||||
id id
|
||||
107 107
|
||||
75 75
|
||||
select t1.id, count(t2.id) from t1,t2 where t2.id = t1.id group by t1.id;
|
||||
id count(t2.id)
|
||||
75 1
|
||||
107 1
|
||||
select t1.id, count(t2.id) from t1,t2 where t2.id = t1.id group by t2.id;
|
||||
id count(t2.id)
|
||||
75 1
|
||||
107 1
|
||||
select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 where t2.id=75 and t1.id is null;
|
||||
id id
|
||||
NULL 75
|
||||
explain select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 where t2.id=75 and t1.id is null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const PRIMARY NULL NULL NULL 1 Impossible ON condition
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
explain select t1.id, t2.id from t1, t2 where t2.id = t1.id and t1.id <0 and t1.id > 0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (
|
||||
id int(11) NOT NULL auto_increment,
|
||||
token varchar(100) DEFAULT '' NOT NULL,
|
||||
count int(11) DEFAULT '0' NOT NULL,
|
||||
qty int(11),
|
||||
phone char(1) DEFAULT '' NOT NULL,
|
||||
timestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY token (token(15)),
|
||||
KEY timestamp (timestamp),
|
||||
UNIQUE token_2 (token(75),count,phone)
|
||||
);
|
||||
INSERT INTO t1 VALUES (21,'e45703b64de71482360de8fec94c3ade',3,7800,'n','1999-12-23 17:22:21');
|
||||
INSERT INTO t1 VALUES (22,'e45703b64de71482360de8fec94c3ade',4,5000,'y','1999-12-23 17:22:21');
|
||||
INSERT INTO t1 VALUES (18,'346d1cb63c89285b2351f0ca4de40eda',3,13200,'b','1999-12-23 11:58:04');
|
||||
INSERT INTO t1 VALUES (17,'ca6ddeb689e1b48a04146b1b5b6f936a',4,15000,'b','1999-12-23 11:36:53');
|
||||
INSERT INTO t1 VALUES (16,'ca6ddeb689e1b48a04146b1b5b6f936a',3,13200,'b','1999-12-23 11:36:53');
|
||||
INSERT INTO t1 VALUES (26,'a71250b7ed780f6ef3185bfffe027983',5,1500,'b','1999-12-27 09:44:24');
|
||||
INSERT INTO t1 VALUES (24,'4d75906f3c37ecff478a1eb56637aa09',3,5400,'y','1999-12-23 17:29:12');
|
||||
INSERT INTO t1 VALUES (25,'4d75906f3c37ecff478a1eb56637aa09',4,6500,'y','1999-12-23 17:29:12');
|
||||
INSERT INTO t1 VALUES (27,'a71250b7ed780f6ef3185bfffe027983',3,6200,'b','1999-12-27 09:44:24');
|
||||
INSERT INTO t1 VALUES (28,'a71250b7ed780f6ef3185bfffe027983',3,5400,'y','1999-12-27 09:44:36');
|
||||
INSERT INTO t1 VALUES (29,'a71250b7ed780f6ef3185bfffe027983',4,17700,'b','1999-12-27 09:45:05');
|
||||
CREATE TABLE t2 (
|
||||
id int(11) NOT NULL auto_increment,
|
||||
category int(11) DEFAULT '0' NOT NULL,
|
||||
county int(11) DEFAULT '0' NOT NULL,
|
||||
state int(11) DEFAULT '0' NOT NULL,
|
||||
phones int(11) DEFAULT '0' NOT NULL,
|
||||
nophones int(11) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY category (category,county,state)
|
||||
);
|
||||
INSERT INTO t2 VALUES (3,2,11,12,5400,7800);
|
||||
INSERT INTO t2 VALUES (4,2,25,12,6500,11200);
|
||||
INSERT INTO t2 VALUES (5,1,37,6,10000,12000);
|
||||
select a.id, b.category as catid, b.state as stateid, b.county as countyid from t1 a, t2 b ignore index (primary) where (a.token ='a71250b7ed780f6ef3185bfffe027983') and (a.count = b.id);
|
||||
id catid stateid countyid
|
||||
27 2 12 11
|
||||
28 2 12 11
|
||||
29 2 12 25
|
||||
26 1 6 37
|
||||
select a.id, b.category as catid, b.state as stateid, b.county as
|
||||
countyid from t1 a, t2 b where (a.token =
|
||||
'a71250b7ed780f6ef3185bfffe027983') and (a.count = b.id) order by a.id;
|
||||
id catid stateid countyid
|
||||
26 1 6 37
|
||||
27 2 12 11
|
||||
28 2 12 11
|
||||
29 2 12 25
|
||||
drop table t1, t2;
|
||||
create table t1 (a int primary key);
|
||||
insert into t1 values(1),(2);
|
||||
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a);
|
||||
a
|
||||
1
|
||||
2
|
||||
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
|
||||
ERROR HY000: Too many tables; MySQL can only use XX tables in a join
|
||||
select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a);
|
||||
a
|
||||
1
|
||||
2
|
||||
select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
|
||||
ERROR HY000: Too many tables; MySQL can only use XX tables in a join
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a int(11) NOT NULL,
|
||||
b int(11) NOT NULL,
|
||||
PRIMARY KEY (a,b)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(2,3);
|
||||
CREATE TABLE t2 (
|
||||
a int(11) default NULL
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (2),(3);
|
||||
SELECT t1.a,t2.a,b FROM t1,t2 WHERE t1.a=t2.a AND (t1.a=1 OR t1.a=2) AND b>=1 AND b<=3;
|
||||
a a b
|
||||
2 2 3
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1 (d DATE NOT NULL);
|
||||
CREATE TABLE t2 (d DATE NOT NULL);
|
||||
INSERT INTO t1 (d) VALUES ('2001-08-01'),('0000-00-00');
|
||||
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE t2.d IS NULL;
|
||||
d
|
||||
2001-08-01
|
||||
0000-00-00
|
||||
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE d IS NULL;
|
||||
d
|
||||
0000-00-00
|
||||
SELECT * from t1 WHERE t1.d IS NULL;
|
||||
d
|
||||
0000-00-00
|
||||
SELECT * FROM t1 WHERE 1/0 IS NULL;
|
||||
d
|
||||
2001-08-01
|
||||
0000-00-00
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (
|
||||
Document_ID varchar(50) NOT NULL default '',
|
||||
Contractor_ID varchar(6) NOT NULL default '',
|
||||
Language_ID char(3) NOT NULL default '',
|
||||
Expiration_Date datetime default NULL,
|
||||
Publishing_Date datetime default NULL,
|
||||
Title text,
|
||||
Column_ID varchar(50) NOT NULL default '',
|
||||
PRIMARY KEY (Language_ID,Document_ID,Contractor_ID)
|
||||
);
|
||||
INSERT INTO t1 VALUES ('xep80','1','ger','2001-12-31 20:00:00','2001-11-12 10:58:00','Kartenbestellung - jetzt auch online','anle'),('','999998','',NULL,NULL,NULL,'');
|
||||
CREATE TABLE t2 (
|
||||
Contractor_ID char(6) NOT NULL default '',
|
||||
Language_ID char(3) NOT NULL default '',
|
||||
Document_ID char(50) NOT NULL default '',
|
||||
CanRead char(1) default NULL,
|
||||
Customer_ID int(11) NOT NULL default '0',
|
||||
PRIMARY KEY (Contractor_ID,Language_ID,Document_ID,Customer_ID)
|
||||
);
|
||||
INSERT INTO t2 VALUES ('5','ger','xep80','1',999999),('1','ger','xep80','1',999999);
|
||||
CREATE TABLE t3 (
|
||||
Language_ID char(3) NOT NULL default '',
|
||||
Column_ID char(50) NOT NULL default '',
|
||||
Contractor_ID char(6) NOT NULL default '',
|
||||
CanRead char(1) default NULL,
|
||||
Active char(1) default NULL,
|
||||
PRIMARY KEY (Language_ID,Column_ID,Contractor_ID)
|
||||
);
|
||||
INSERT INTO t3 VALUES ('ger','home','1','1','1'),('ger','Test','1','0','0'),('ger','derclu','1','0','0'),('ger','clubne','1','0','0'),('ger','philos','1','0','0'),('ger','clubko','1','0','0'),('ger','clubim','1','1','1'),('ger','progra','1','0','0'),('ger','progvo','1','0','0'),('ger','progsp','1','0','0'),('ger','progau','1','0','0'),('ger','progku','1','0','0'),('ger','progss','1','0','0'),('ger','nachl','1','0','0'),('ger','mitgli','1','0','0'),('ger','mitsu','1','0','0'),('ger','mitbus','1','0','0'),('ger','ergmar','1','1','1'),('ger','home','4','1','1'),('ger','derclu','4','1','1'),('ger','clubne','4','0','0'),('ger','philos','4','1','1'),('ger','clubko','4','1','1'),('ger','clubim','4','1','1'),('ger','progra','4','1','1'),('ger','progvo','4','1','1'),('ger','progsp','4','1','1'),('ger','progau','4','0','0'),('ger','progku','4','1','1'),('ger','progss','4','1','1'),('ger','nachl','4','1','1'),('ger','mitgli','4','0','0'),('ger','mitsu','4','0','0'),('ger','mitbus','4','0','0'),('ger','ergmar','4','1','1'),('ger','progra2','1','0','0'),('ger','archiv','4','1','1'),('ger','anmeld','4','1','1'),('ger','thema','4','1','1'),('ger','edito','4','1','1'),('ger','madis','4','1','1'),('ger','enma','4','1','1'),('ger','madis','1','1','1'),('ger','enma','1','1','1'),('ger','vorsch','4','0','0'),('ger','veranst','4','0','0'),('ger','anle','4','1','1'),('ger','redak','4','1','1'),('ger','nele','4','1','1'),('ger','aukt','4','1','1'),('ger','callcenter','4','1','1'),('ger','anle','1','0','0');
|
||||
delete from t1 where Contractor_ID='999998';
|
||||
insert into t1 (Contractor_ID) Values ('999998');
|
||||
SELECT DISTINCT COUNT(t1.Title) FROM t1,
|
||||
t2, t3 WHERE
|
||||
t1.Document_ID='xep80' AND t1.Contractor_ID='1' AND
|
||||
t1.Language_ID='ger' AND '2001-12-21 23:14:24' >=
|
||||
Publishing_Date AND '2001-12-21 23:14:24' <= Expiration_Date AND
|
||||
t1.Document_ID = t2.Document_ID AND
|
||||
t1.Language_ID = t2.Language_ID AND
|
||||
t1.Contractor_ID = t2.Contractor_ID AND (
|
||||
t2.Customer_ID = '4' OR
|
||||
t2.Customer_ID = '999999' OR
|
||||
t2.Customer_ID = '1' )AND t2.CanRead
|
||||
= '1' AND t1.Column_ID=t3.Column_ID AND
|
||||
t1.Language_ID=t3.Language_ID AND (
|
||||
t3.Contractor_ID = '4' OR
|
||||
t3.Contractor_ID = '999999' OR
|
||||
t3.Contractor_ID = '1') AND
|
||||
t3.CanRead='1' AND t3.Active='1';
|
||||
COUNT(t1.Title)
|
||||
1
|
||||
SELECT DISTINCT COUNT(t1.Title) FROM t1,
|
||||
t2, t3 WHERE
|
||||
t1.Document_ID='xep80' AND t1.Contractor_ID='1' AND
|
||||
t1.Language_ID='ger' AND '2001-12-21 23:14:24' >=
|
||||
Publishing_Date AND '2001-12-21 23:14:24' <= Expiration_Date AND
|
||||
t1.Document_ID = t2.Document_ID AND
|
||||
t1.Language_ID = t2.Language_ID AND
|
||||
t1.Contractor_ID = t2.Contractor_ID AND (
|
||||
t2.Customer_ID = '4' OR
|
||||
t2.Customer_ID = '999999' OR
|
||||
t2.Customer_ID = '1' )AND t2.CanRead
|
||||
= '1' AND t1.Column_ID=t3.Column_ID AND
|
||||
t1.Language_ID=t3.Language_ID AND (
|
||||
t3.Contractor_ID = '4' OR
|
||||
t3.Contractor_ID = '999999' OR
|
||||
t3.Contractor_ID = '1') AND
|
||||
t3.CanRead='1' AND t3.Active='1';
|
||||
COUNT(t1.Title)
|
||||
1
|
||||
drop table t1,t2,t3;
|
||||
CREATE TABLE t1 (
|
||||
t1_id int(11) default NULL,
|
||||
t2_id int(11) default NULL,
|
||||
type enum('Cost','Percent') default NULL,
|
||||
cost_unit enum('Cost','Unit') default NULL,
|
||||
min_value double default NULL,
|
||||
max_value double default NULL,
|
||||
t3_id int(11) default NULL,
|
||||
item_id int(11) default NULL
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (12,5,'Percent','Cost',-1,0,-1,-1),(14,4,'Percent','Cost',-1,0,-1,-1),(18,5,'Percent','Cost',-1,0,-1,-1),(19,4,'Percent','Cost',-1,0,-1,-1),(20,5,'Percent','Cost',100,-1,22,291),(21,5,'Percent','Cost',100,-1,18,291),(22,1,'Percent','Cost',100,-1,6,291),(23,1,'Percent','Cost',100,-1,21,291),(24,1,'Percent','Cost',100,-1,9,291),(25,1,'Percent','Cost',100,-1,4,291),(26,1,'Percent','Cost',100,-1,20,291),(27,4,'Percent','Cost',100,-1,7,202),(28,1,'Percent','Cost',50,-1,-1,137),(29,2,'Percent','Cost',100,-1,4,354),(30,2,'Percent','Cost',100,-1,9,137),(93,2,'Cost','Cost',-1,10000000,-1,-1);
|
||||
CREATE TABLE t2 (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
name varchar(255) default NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,'s1'),(2,'s2'),(3,'s3'),(4,'s4'),(5,'s5');
|
||||
select t1.*, t2.* from t1, t2 where t2.id=t1.t2_id limit 2;
|
||||
t1_id t2_id type cost_unit min_value max_value t3_id item_id id name
|
||||
22 1 Percent Cost 100 -1 6 291 1 s1
|
||||
23 1 Percent Cost 100 -1 21 291 1 s1
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (
|
||||
siteid varchar(25) NOT NULL default '',
|
||||
emp_id varchar(30) NOT NULL default '',
|
||||
rate_code varchar(10) default NULL,
|
||||
UNIQUE KEY site_emp (siteid,emp_id),
|
||||
KEY siteid (siteid)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('rivercats','psmith','cust'), ('rivercats','KWalker','cust');
|
||||
CREATE TABLE t2 (
|
||||
siteid varchar(25) NOT NULL default '',
|
||||
rate_code varchar(10) NOT NULL default '',
|
||||
base_rate float NOT NULL default '0',
|
||||
PRIMARY KEY (siteid,rate_code),
|
||||
FULLTEXT KEY rate_code (rate_code)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES ('rivercats','cust',20);
|
||||
SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND lr.siteid = 'rivercats';
|
||||
rate_code base_rate
|
||||
cust 20
|
||||
SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE lr.siteid = 'rivercats' AND emp.emp_id = 'psmith';
|
||||
rate_code base_rate
|
||||
cust 20
|
||||
SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND siteid = 'rivercats';
|
||||
rate_code base_rate
|
||||
cust 20
|
||||
SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE siteid = 'rivercats' AND emp.emp_id = 'psmith';
|
||||
rate_code base_rate
|
||||
cust 20
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, Value1 VARCHAR(255));
|
||||
CREATE TABLE t2 (ID INTEGER NOT NULL PRIMARY KEY, Value2 VARCHAR(255));
|
||||
INSERT INTO t1 VALUES (1, 'A');
|
||||
INSERT INTO t2 VALUES (1, 'B');
|
||||
SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND (Value1 = 'A' AND Value2 <> 'B');
|
||||
ID Value1 Value2
|
||||
SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND Value1 = 'A' AND Value2 <> 'B';
|
||||
ID Value1 Value2
|
||||
SELECT * FROM t1 NATURAL JOIN t2 WHERE (Value1 = 'A' AND Value2 <> 'B') AND 1;
|
||||
ID Value1 Value2
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (a int);
|
||||
CREATE TABLE t2 (b int);
|
||||
CREATE TABLE t3 (c int);
|
||||
SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN t3;
|
||||
a b c
|
||||
DROP TABLE t1, t2, t3;
|
||||
create table t1 (i int);
|
||||
create table t2 (i int);
|
||||
create table t3 (i int);
|
||||
insert into t1 values(1),(2);
|
||||
insert into t2 values(2),(3);
|
||||
insert into t3 values (2),(4);
|
||||
select * from t1 natural left join t2;
|
||||
i
|
||||
1
|
||||
2
|
||||
select * from t1 left join t2 on (t1.i=t2.i);
|
||||
i i
|
||||
1 NULL
|
||||
2 2
|
||||
select * from t1 natural left join t2 natural left join t3;
|
||||
i
|
||||
1
|
||||
2
|
||||
select * from t1 left join t2 on (t1.i=t2.i) left join t3 on (t2.i=t3.i);
|
||||
i i i
|
||||
1 NULL NULL
|
||||
2 2 2
|
||||
select * from t3 natural right join t2;
|
||||
i
|
||||
2
|
||||
3
|
||||
select * from t3 right join t2 on (t3.i=t2.i);
|
||||
i i
|
||||
2 2
|
||||
NULL 3
|
||||
select * from t3 natural right join t2 natural right join t1;
|
||||
i
|
||||
1
|
||||
2
|
||||
select * from t3 right join t2 on (t3.i=t2.i) right join t1 on (t2.i=t1.i);
|
||||
i i i
|
||||
NULL NULL 1
|
||||
2 2 2
|
||||
select * from t1,t2 natural left join t3 order by t1.i,t2.i,t3.i;
|
||||
i i
|
||||
1 2
|
||||
1 3
|
||||
2 2
|
||||
2 3
|
||||
select * from t1,t2 left join t3 on (t2.i=t3.i) order by t1.i,t2.i,t3.i;
|
||||
i i i
|
||||
1 2 2
|
||||
1 3 NULL
|
||||
2 2 2
|
||||
2 3 NULL
|
||||
select t1.i,t2.i,t3.i from t2 natural left join t3,t1 order by t1.i,t2.i,t3.i;
|
||||
i i i
|
||||
1 2 2
|
||||
1 3 NULL
|
||||
2 2 2
|
||||
2 3 NULL
|
||||
select t1.i,t2.i,t3.i from t2 left join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i;
|
||||
i i i
|
||||
1 2 2
|
||||
1 3 NULL
|
||||
2 2 2
|
||||
2 3 NULL
|
||||
select * from t1,t2 natural right join t3 order by t1.i,t2.i,t3.i;
|
||||
i i
|
||||
1 4
|
||||
1 2
|
||||
2 4
|
||||
2 2
|
||||
select * from t1,t2 right join t3 on (t2.i=t3.i) order by t1.i,t2.i,t3.i;
|
||||
i i i
|
||||
1 NULL 4
|
||||
1 2 2
|
||||
2 NULL 4
|
||||
2 2 2
|
||||
select t1.i,t2.i,t3.i from t2 natural right join t3,t1 order by t1.i,t2.i,t3.i;
|
||||
i i i
|
||||
1 NULL 4
|
||||
1 2 2
|
||||
2 NULL 4
|
||||
2 2 2
|
||||
select t1.i,t2.i,t3.i from t2 right join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i;
|
||||
i i i
|
||||
1 NULL 4
|
||||
1 2 2
|
||||
2 NULL 4
|
||||
2 2 2
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (c int, b int);
|
||||
create table t2 (a int, b int);
|
||||
create table t3 (b int, c int);
|
||||
create table t4 (y int, c int);
|
||||
create table t5 (y int, z int);
|
||||
create table t6 (a int, c int);
|
||||
insert into t1 values (10,1);
|
||||
insert into t1 values (3 ,1);
|
||||
insert into t1 values (3 ,2);
|
||||
insert into t2 values (2, 1);
|
||||
insert into t3 values (1, 3);
|
||||
insert into t3 values (1,10);
|
||||
insert into t4 values (11,3);
|
||||
insert into t4 values (2, 3);
|
||||
insert into t5 values (11,4);
|
||||
insert into t6 values (2, 3);
|
||||
create algorithm=merge view v1a as
|
||||
select * from t1 natural join t2;
|
||||
create algorithm=merge view v1b(a,b,c) as
|
||||
select * from t1 natural join t2;
|
||||
create algorithm=merge view v1c as
|
||||
select b as a, c as b, a as c from t1 natural join t2;
|
||||
create algorithm=merge view v1d(b, a, c) as
|
||||
select a as c, c as b, b as a from t1 natural join t2;
|
||||
create algorithm=merge view v2a as
|
||||
select t1.c, t1.b, t2.a from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c;
|
||||
create algorithm=merge view v2b as
|
||||
select t1.c as b, t1.b as a, t2.a as c
|
||||
from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c;
|
||||
create algorithm=merge view v3a as
|
||||
select * from t1 natural join t2 natural join t3;
|
||||
create algorithm=merge view v3b as
|
||||
select * from t1 natural join (t2 natural join t3);
|
||||
create algorithm=merge view v4 as
|
||||
select * from v2a natural join v3a;
|
||||
select * from (t1 natural join t2) natural join (t3 natural join t4);
|
||||
b c a y
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select * from (t1 natural join t2) natural left join (t3 natural join t4);
|
||||
b c a y
|
||||
1 10 2 NULL
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select * from (t3 natural join t4) natural right join (t1 natural join t2);
|
||||
b c a y
|
||||
1 10 2 NULL
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select * from (t1 natural left join t2) natural left join (t3 natural left join t4);
|
||||
b c a y
|
||||
1 10 2 NULL
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
2 3 NULL NULL
|
||||
select * from (t4 natural right join t3) natural right join (t2 natural right join t1);
|
||||
b c a y
|
||||
1 10 2 NULL
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
2 3 NULL NULL
|
||||
select * from t1 natural join t2 natural join t3 natural join t4;
|
||||
c b a y
|
||||
3 1 2 11
|
||||
3 1 2 2
|
||||
select * from ((t1 natural join t2) natural join t3) natural join t4;
|
||||
c b a y
|
||||
3 1 2 11
|
||||
3 1 2 2
|
||||
select * from t1 natural join (t2 natural join (t3 natural join t4));
|
||||
c b a y
|
||||
3 1 2 11
|
||||
3 1 2 2
|
||||
select * from t5 natural right join (t4 natural right join ((t2 natural right join t1) natural right join t3));
|
||||
y c b a z
|
||||
11 3 1 2 4
|
||||
2 3 1 2 NULL
|
||||
NULL 10 1 2 NULL
|
||||
select * from (t1 natural join t2), (t3 natural join t4);
|
||||
b c a c b y
|
||||
1 10 2 3 1 11
|
||||
1 10 2 3 1 2
|
||||
1 3 2 3 1 11
|
||||
1 3 2 3 1 2
|
||||
select * from t5 natural join ((t1 natural join t2), (t3 natural join t4));
|
||||
y z b c a c b
|
||||
11 4 1 10 2 3 1
|
||||
11 4 1 3 2 3 1
|
||||
select * from ((t1 natural join t2), (t3 natural join t4)) natural join t5;
|
||||
y b c a c b z
|
||||
11 1 10 2 3 1 4
|
||||
11 1 3 2 3 1 4
|
||||
select * from t5 natural join ((t1 natural join t2) cross join (t3 natural join t4));
|
||||
y z b c a c b
|
||||
11 4 1 10 2 3 1
|
||||
11 4 1 3 2 3 1
|
||||
select * from ((t1 natural join t2) cross join (t3 natural join t4)) natural join t5;
|
||||
y b c a c b z
|
||||
11 1 10 2 3 1 4
|
||||
11 1 3 2 3 1 4
|
||||
select * from (t1 join t2 using (b)) join (t3 join t4 using (c)) using (c);
|
||||
c b a b y
|
||||
3 1 2 1 11
|
||||
3 1 2 1 2
|
||||
select * from (t1 join t2 using (b)) natural join (t3 join t4 using (c));
|
||||
b c a y
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select a,b,c from (t1 natural join t2) natural join (t3 natural join t4)
|
||||
where b + 1 = y or b + 10 = y group by b,c,a having min(b) < max(y) order by a;
|
||||
a b c
|
||||
2 1 3
|
||||
select * from (t1 natural join t2) natural left join (t3 natural join t4)
|
||||
where b + 1 = y or b + 10 = y group by b,c,a,y having min(b) < max(y) order by a, y;
|
||||
b c a y
|
||||
1 3 2 2
|
||||
1 3 2 11
|
||||
select * from (t3 natural join t4) natural right join (t1 natural join t2)
|
||||
where b + 1 = y or b + 10 = y group by b,c,a,y having min(b) < max(y) order by a, y;
|
||||
b c a y
|
||||
1 3 2 2
|
||||
1 3 2 11
|
||||
select * from t1 natural join t2 where t1.c > t2.a;
|
||||
b c a
|
||||
1 10 2
|
||||
1 3 2
|
||||
select * from t1 natural join t2 where t1.b > t2.b;
|
||||
b c a
|
||||
select * from t1 natural left join (t4 natural join t5) where t5.z is not NULL;
|
||||
c b y z
|
||||
3 1 11 4
|
||||
3 2 11 4
|
||||
select * from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c;
|
||||
c b a b y c
|
||||
3 1 2 1 2 3
|
||||
3 2 2 1 2 3
|
||||
select * from (t2 join t4 on b + 1 = y) join t1 on t1.c = t4.c;
|
||||
a b y c c b
|
||||
2 1 2 3 3 1
|
||||
2 1 2 3 3 2
|
||||
select * from t1 natural join (t2 join t4 on b + 1 = y);
|
||||
c b a y
|
||||
3 1 2 2
|
||||
select * from (t1 cross join t2) join (t3 cross join t4) on (a < y and t2.b < t3.c);
|
||||
c b a b b c y c
|
||||
10 1 2 1 1 3 11 3
|
||||
10 1 2 1 1 10 11 3
|
||||
3 1 2 1 1 3 11 3
|
||||
3 1 2 1 1 10 11 3
|
||||
3 2 2 1 1 3 11 3
|
||||
3 2 2 1 1 10 11 3
|
||||
select * from (t1, t2) join (t3, t4) on (a < y and t2.b < t3.c);
|
||||
c b a b b c y c
|
||||
10 1 2 1 1 3 11 3
|
||||
10 1 2 1 1 10 11 3
|
||||
3 1 2 1 1 3 11 3
|
||||
3 1 2 1 1 10 11 3
|
||||
3 2 2 1 1 3 11 3
|
||||
3 2 2 1 1 10 11 3
|
||||
select * from (t1 natural join t2) join (t3 natural join t4) on a = y;
|
||||
b c a c b y
|
||||
1 10 2 3 1 2
|
||||
1 3 2 3 1 2
|
||||
select * from ((t3 join (t1 join t2 on c > a) on t3.b < t2.a) join t4 on y > t1.c) join t5 on z = t1.b + 3;
|
||||
b c c b a b y c y z
|
||||
1 3 10 1 2 1 11 3 11 4
|
||||
1 10 10 1 2 1 11 3 11 4
|
||||
1 3 3 1 2 1 11 3 11 4
|
||||
1 10 3 1 2 1 11 3 11 4
|
||||
select * from t1 natural join t2 where t1.b > 0;
|
||||
b c a
|
||||
1 10 2
|
||||
1 3 2
|
||||
select * from t1 natural join (t4 natural join t5) where t4.y > 7;
|
||||
c b y z
|
||||
3 1 11 4
|
||||
3 2 11 4
|
||||
select * from (t4 natural join t5) natural join t1 where t4.y > 7;
|
||||
c y z b
|
||||
3 11 4 1
|
||||
3 11 4 2
|
||||
select * from t1 natural left join (t4 natural join t5) where t4.y > 7;
|
||||
c b y z
|
||||
3 1 11 4
|
||||
3 2 11 4
|
||||
select * from (t4 natural join t5) natural right join t1 where t4.y > 7;
|
||||
c b y z
|
||||
3 1 11 4
|
||||
3 2 11 4
|
||||
select * from (t1 natural join t2) join (t3 natural join t4) on t1.b = t3.b;
|
||||
b c a c b y
|
||||
1 10 2 3 1 11
|
||||
1 10 2 3 1 2
|
||||
1 3 2 3 1 11
|
||||
1 3 2 3 1 2
|
||||
select t1.*, t2.* from t1 natural join t2;
|
||||
c b a b
|
||||
10 1 2 1
|
||||
3 1 2 1
|
||||
select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) natural join (t3 natural join t4);
|
||||
c b a b b c y c
|
||||
3 1 2 1 1 3 11 3
|
||||
3 1 2 1 1 3 2 3
|
||||
select * from (select * from t1 natural join t2) as t12
|
||||
natural join
|
||||
(select * from t3 natural join t4) as t34;
|
||||
b c a y
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select * from (select * from t1 natural join t2) as t12
|
||||
natural left join
|
||||
(select * from t3 natural join t4) as t34;
|
||||
b c a y
|
||||
1 10 2 NULL
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select * from (select * from t3 natural join t4) as t34
|
||||
natural right join
|
||||
(select * from t1 natural join t2) as t12;
|
||||
b c a y
|
||||
1 10 2 NULL
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select * from v1a;
|
||||
b c a
|
||||
1 10 2
|
||||
1 3 2
|
||||
select * from v1b;
|
||||
a b c
|
||||
1 10 2
|
||||
1 3 2
|
||||
select * from v1c;
|
||||
a b c
|
||||
1 10 2
|
||||
1 3 2
|
||||
select * from v1d;
|
||||
b a c
|
||||
2 10 1
|
||||
2 3 1
|
||||
select * from v2a;
|
||||
c b a
|
||||
3 1 2
|
||||
3 2 2
|
||||
select * from v2b;
|
||||
b a c
|
||||
3 1 2
|
||||
3 2 2
|
||||
select * from v3a;
|
||||
b c a
|
||||
1 10 2
|
||||
1 3 2
|
||||
select * from v3b;
|
||||
c b a
|
||||
10 1 2
|
||||
3 1 2
|
||||
select * from v4;
|
||||
c b a
|
||||
3 1 2
|
||||
select * from v1a natural join v2a;
|
||||
b c a
|
||||
1 3 2
|
||||
select v2a.* from v1a natural join v2a;
|
||||
c b a
|
||||
3 1 2
|
||||
select * from v1b join v2a on v1b.b = v2a.c;
|
||||
a b c c b a
|
||||
1 3 2 3 1 2
|
||||
1 3 2 3 2 2
|
||||
select * from v1c join v2a on v1c.b = v2a.c;
|
||||
a b c c b a
|
||||
1 3 2 3 1 2
|
||||
1 3 2 3 2 2
|
||||
select * from v1d join v2a on v1d.a = v2a.c;
|
||||
b a c c b a
|
||||
2 3 1 3 1 2
|
||||
2 3 1 3 2 2
|
||||
select * from v1a join (t3 natural join t4) on a = y;
|
||||
b c a c b y
|
||||
1 10 2 3 1 2
|
||||
1 3 2 3 1 2
|
||||
select * from t1 natural join (t3 cross join t4);
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select * from (t3 cross join t4) natural join t1;
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select * from t1 join (t2, t3) using (b);
|
||||
ERROR 23000: Column 'b' in from clause is ambiguous
|
||||
select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6;
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6;
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select * from t6 natural join ((t1 natural join t2), (t3 natural join t4));
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select * from (t1 join t2 on t1.b=t2.b) natural join (t3 natural join t4);
|
||||
ERROR 23000: Column 'b' in from clause is ambiguous
|
||||
select * from (t3 natural join t4) natural join (t1 join t2 on t1.b=t2.b);
|
||||
ERROR 23000: Column 'b' in from clause is ambiguous
|
||||
select * from (t3 join (t4 natural join t5) on (b < z))
|
||||
natural join
|
||||
(t1 natural join t2);
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select * from (t1 natural join t2) natural join (t3 join (t4 natural join t5) on (b < z));
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select t1.b from v1a;
|
||||
ERROR 42S22: Unknown column 't1.b' in 'field list'
|
||||
select * from v1a join v1b on t1.b = t2.b;
|
||||
ERROR 42S22: Unknown column 't1.b' in 'on clause'
|
||||
select * from information_schema.statistics join information_schema.columns
|
||||
using(table_name,column_name) where table_name='user';
|
||||
TABLE_NAME COLUMN_NAME TABLE_CATALOG TABLE_SCHEMA NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
|
||||
user Host NULL mysql 0 mysql PRIMARY 1 A NULL NULL NULL BTREE NULL mysql 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI #
|
||||
user User NULL mysql 0 mysql PRIMARY 2 A 3 NULL NULL BTREE NULL mysql 2 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI #
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
drop table t3;
|
||||
drop table t4;
|
||||
drop table t5;
|
||||
drop table t6;
|
||||
drop view v1a;
|
||||
drop view v1b;
|
||||
drop view v1c;
|
||||
drop view v1d;
|
||||
drop view v2a;
|
||||
drop view v2b;
|
||||
drop view v3a;
|
||||
drop view v3b;
|
||||
drop view v4;
|
||||
create table t1 (a1 int, a2 int);
|
||||
create table t2 (a1 int, b int);
|
||||
create table t3 (c1 int, c2 int);
|
||||
create table t4 (c2 int);
|
||||
insert into t1 values (1,1);
|
||||
insert into t2 values (1,1);
|
||||
insert into t3 values (1,1);
|
||||
insert into t4 values (1);
|
||||
select * from t1 join t2 using (a1) join t3 on b=c1 join t4 using (c2);
|
||||
c2 a1 a2 b c1
|
||||
1 1 1 1 1
|
||||
select * from t3 join (t1 join t2 using (a1)) on b=c1 join t4 using (c2);
|
||||
c2 c1 a1 a2 b
|
||||
1 1 1 1 1
|
||||
select a2 from t1 join t2 using (a1) join t3 on b=c1 join t4 using (c2);
|
||||
a2
|
||||
1
|
||||
select a2 from t3 join (t1 join t2 using (a1)) on b=c1 join t4 using (c2);
|
||||
a2
|
||||
1
|
||||
select a2 from ((t1 join t2 using (a1)) join t3 on b=c1) join t4 using (c2);
|
||||
a2
|
||||
1
|
||||
select a2 from ((t1 natural join t2) join t3 on b=c1) natural join t4;
|
||||
a2
|
||||
1
|
||||
drop table t1,t2,t3,t4;
|
||||
create table t1 (c int, b int);
|
||||
create table t2 (a int, b int);
|
||||
create table t3 (b int, c int);
|
||||
create table t4 (y int, c int);
|
||||
create table t5 (y int, z int);
|
||||
insert into t1 values (3,2);
|
||||
insert into t2 values (1,2);
|
||||
insert into t3 values (2,3);
|
||||
insert into t4 values (1,3);
|
||||
insert into t5 values (1,4);
|
||||
prepare stmt1 from "select * from ((t3 natural join (t1 natural join t2))
|
||||
natural join t4) natural join t5";
|
||||
execute stmt1;
|
||||
y c b a z
|
||||
1 3 2 1 4
|
||||
select * from ((t3 natural join (t1 natural join t2)) natural join t4)
|
||||
natural join t5;
|
||||
y c b a z
|
||||
1 3 2 1 4
|
||||
drop table t1, t2, t3, t4, t5;
|
||||
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, filler char(100), key(a), key(b));
|
||||
create table t3 (a int, b int, filler char(100), key(a), key(b));
|
||||
insert into t2
|
||||
select @a:= A.a + 10*(B.a + 10*C.a), @a, 'filler' from t1 A, t1 B, t1 C;
|
||||
insert into t3 select * from t2 where a < 800;
|
||||
explain select * from t2,t3 where t2.a < 200 and t2.b=t3.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a,b a 5 NULL 1 Using where
|
||||
1 SIMPLE t3 ref b b 5 test.t2.b 11 Using where
|
||||
drop table t1, t2, t3;
|
||||
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, primary key(a));
|
||||
insert into t2 select @v:=A.a+10*B.a, @v from t1 A, t1 B;
|
||||
explain select * from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10
|
||||
show status like '%cost%';
|
||||
Variable_name Value
|
||||
Last_query_cost 4.262158
|
||||
select 'The cost of accessing t1 (dont care if it changes' '^';
|
||||
The cost of accessing t1 (dont care if it changes
|
||||
The cost of accessing t1 (dont care if it changes^
|
||||
select 'vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv' Z;
|
||||
Z
|
||||
vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv
|
||||
explain select * from t1, t2 A, t2 B where A.a = t1.a and B.a=A.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10
|
||||
1 SIMPLE A eq_ref PRIMARY PRIMARY 4 test.t1.a 1
|
||||
1 SIMPLE B eq_ref PRIMARY PRIMARY 4 test.A.b 1
|
||||
show status like '%cost%';
|
||||
Variable_name Value
|
||||
Last_query_cost 24.262158
|
||||
select '^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error' Z;
|
||||
Z
|
||||
^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1 (ID INTEGER, Name VARCHAR(50));
|
||||
CREATE TABLE t2 (Test_ID INTEGER);
|
||||
CREATE VIEW v1 (Test_ID, Description) AS SELECT ID, Name FROM t1;
|
||||
CREATE TABLE tv1 SELECT Description AS Name FROM v1 JOIN t2
|
||||
USING (Test_ID);
|
||||
DESCRIBE tv1;
|
||||
Field Type Null Key Default Extra
|
||||
Name varchar(50) YES NULL
|
||||
CREATE TABLE tv2 SELECT Description AS Name FROM v1 JOIN t2
|
||||
ON v1.Test_ID = t2.Test_ID;
|
||||
DESCRIBE tv2;
|
||||
Field Type Null Key Default Extra
|
||||
Name varchar(50) YES NULL
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2,tv1,tv2;
|
||||
End of 5.0 tests.
|
||||
103
mysql-test/suite/pbxt/r/join_crash.result
Normal file
103
mysql-test/suite/pbxt/r/join_crash.result
Normal file
@@ -0,0 +1,103 @@
|
||||
DROP TABLE IF EXISTS t1,t2,t3,t4;
|
||||
CREATE TABLE t1 (
|
||||
project_id int(11) NOT NULL auto_increment,
|
||||
project_row_lock int(11) NOT NULL default '0',
|
||||
project_name varchar(80) NOT NULL default '',
|
||||
client_ptr int(11) NOT NULL default '0',
|
||||
project_contact_ptr int(11) default NULL,
|
||||
client_contact_ptr int(11) default NULL,
|
||||
billing_contact_ptr int(11) default NULL,
|
||||
comments mediumtext,
|
||||
PRIMARY KEY (project_id),
|
||||
UNIQUE KEY project (client_ptr,project_name)
|
||||
) ENGINE=MyISAM PACK_KEYS=1;
|
||||
INSERT INTO t1 VALUES (1,0,'Rejected Time',1,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO t1 VALUES (209,0,'MDGRAD Proposal/Investigation',97,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (208,0,'Font 9 Design',84,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (207,0,'Web Based Order Processing',95,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (205,0,'Mac Screen Saver',95,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (206,0,'Web Site',96,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (204,0,'Magnafire Glue',94,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (203,0,'Print Bid',93,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (202,0,'EPOC Port',92,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (201,0,'TravelMate',88,NULL,NULL,NULL,'');
|
||||
CREATE TABLE t2 (
|
||||
period_id int(11) NOT NULL auto_increment,
|
||||
period_type enum('user_table','client_table','role_table','member_table','project_table') default NULL,
|
||||
period_key int(11) default NULL,
|
||||
start_date datetime default NULL,
|
||||
end_date datetime default NULL,
|
||||
work_load int(11) default NULL,
|
||||
PRIMARY KEY (period_id),
|
||||
KEY period_index (period_type,period_key),
|
||||
KEY date_index (start_date,end_date)
|
||||
) ENGINE=MyISAM PACK_KEYS=1;
|
||||
INSERT INTO t2 VALUES (1,'user_table',98,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (2,'user_table',99,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (3,'user_table',100,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (49,'project_table',148,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (50,'client_table',68,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (51,'project_table',149,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (52,'project_table',150,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (53,'client_table',69,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (54,'project_table',151,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (55,'client_table',70,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (155,'role_table',1,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (156,'role_table',2,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (160,'member_table',1,'2000-01-01 00:00:00',NULL,1);
|
||||
INSERT INTO t2 VALUES (161,'member_table',2,'2000-01-01 00:00:00',NULL,1);
|
||||
INSERT INTO t2 VALUES (162,'member_table',3,'2000-01-01 00:00:00',NULL,1);
|
||||
CREATE TABLE t3 (
|
||||
budget_id int(11) NOT NULL auto_increment,
|
||||
project_ptr int(11) NOT NULL default '0',
|
||||
po_number varchar(20) NOT NULL default '',
|
||||
status enum('open','closed') default NULL,
|
||||
date_received datetime default NULL,
|
||||
amount_received float(10,2) default NULL,
|
||||
adjustment float(10,2) default NULL,
|
||||
PRIMARY KEY (budget_id),
|
||||
UNIQUE KEY po (project_ptr,po_number)
|
||||
) ENGINE=MyISAM PACK_KEYS=1;
|
||||
CREATE TABLE t4 (
|
||||
client_id int(11) NOT NULL auto_increment,
|
||||
client_row_lock int(11) NOT NULL default '0',
|
||||
client_name varchar(80) NOT NULL default '',
|
||||
contact_ptr int(11) default NULL,
|
||||
comments mediumtext,
|
||||
PRIMARY KEY (client_id),
|
||||
UNIQUE KEY client_name (client_name)
|
||||
) ENGINE=MyISAM PACK_KEYS=1;
|
||||
INSERT INTO t4 VALUES (1,0,'CPS',NULL,NULL);
|
||||
select distinct
|
||||
t1.project_id as project_id,
|
||||
t1.project_name as project_name,
|
||||
t1.client_ptr as client_ptr,
|
||||
t1.comments as comments,
|
||||
sum( t3.amount_received ) + sum( t3.adjustment ) as total_budget
|
||||
from
|
||||
t2 as client_period ,
|
||||
t2 as project_period,
|
||||
t3 left join t1 on (t3.project_ptr = t1.project_id and
|
||||
t3.date_received <= '2001-03-22 14:15:09')
|
||||
left join t4 on t4.client_id = t1.client_ptr
|
||||
where
|
||||
1
|
||||
and ( client_period.period_type = 'client_table'
|
||||
and client_period.period_key = t4.client_id
|
||||
and ( client_period.start_date <= '2001-03-22 14:15:09' or isnull( client_period.start_date ))
|
||||
and ( client_period.end_date > '2001-03-21 14:15:09' or isnull( client_period.end_date ))
|
||||
)
|
||||
and ( project_period.period_type = 'project_table'
|
||||
and project_period.period_key = t1.project_id
|
||||
and ( project_period.start_date <= '2001-03-22 14:15:09' or isnull( project_period.start_date ))
|
||||
and ( project_period.end_date > '2001-03-21 14:15:09' or isnull( project_period.end_date )) )
|
||||
group by
|
||||
client_id,
|
||||
project_id ,
|
||||
client_period.period_id ,
|
||||
project_period.period_id
|
||||
order by
|
||||
client_name asc,
|
||||
project_name asc;
|
||||
project_id project_name client_ptr comments total_budget
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
1613
mysql-test/suite/pbxt/r/join_nested.result
Normal file
1613
mysql-test/suite/pbxt/r/join_nested.result
Normal file
File diff suppressed because it is too large
Load Diff
1196
mysql-test/suite/pbxt/r/join_outer.result
Normal file
1196
mysql-test/suite/pbxt/r/join_outer.result
Normal file
File diff suppressed because it is too large
Load Diff
484
mysql-test/suite/pbxt/r/key.result
Normal file
484
mysql-test/suite/pbxt/r/key.result
Normal file
@@ -0,0 +1,484 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
SET SQL_WARNINGS=1;
|
||||
CREATE TABLE t1 (
|
||||
ID CHAR(32) NOT NULL,
|
||||
name CHAR(32) NOT NULL,
|
||||
value CHAR(255),
|
||||
INDEX indexIDname (ID(8),name(8))
|
||||
) ;
|
||||
INSERT INTO t1 VALUES
|
||||
('keyword','indexdir','/export/home/local/www/database/indexes/keyword');
|
||||
INSERT INTO t1 VALUES ('keyword','urlprefix','text/ /text');
|
||||
INSERT INTO t1 VALUES ('keyword','urlmap','/text/ /');
|
||||
INSERT INTO t1 VALUES ('keyword','attr','personal employee company');
|
||||
INSERT INTO t1 VALUES
|
||||
('emailgids','indexdir','/export/home/local/www/database/indexes/emailgids');
|
||||
INSERT INTO t1 VALUES ('emailgids','urlprefix','text/ /text');
|
||||
INSERT INTO t1 VALUES ('emailgids','urlmap','/text/ /');
|
||||
INSERT INTO t1 VALUES ('emailgids','attr','personal employee company');
|
||||
SELECT value FROM t1 WHERE ID='emailgids' AND name='attr';
|
||||
value
|
||||
personal employee company
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
price int(5) DEFAULT '0' NOT NULL,
|
||||
area varchar(40) DEFAULT '' NOT NULL,
|
||||
type varchar(40) DEFAULT '' NOT NULL,
|
||||
transityes enum('Y','N') DEFAULT 'Y' NOT NULL,
|
||||
shopsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
|
||||
schoolsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
|
||||
petsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
|
||||
KEY price (price,area,type,transityes,shopsyes,schoolsyes,petsyes)
|
||||
);
|
||||
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
|
||||
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
|
||||
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','','','','');
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'transityes' at row 1
|
||||
Warning 1265 Data truncated for column 'shopsyes' at row 1
|
||||
Warning 1265 Data truncated for column 'schoolsyes' at row 1
|
||||
Warning 1265 Data truncated for column 'petsyes' at row 1
|
||||
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
|
||||
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
|
||||
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
|
||||
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
|
||||
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
|
||||
SELECT * FROM t1 WHERE area='Vancouver' and transityes='y' and schoolsyes='y' and ( ((type='1 Bedroom' or type='Studio/Bach') and (price<=500)) or ((type='2 Bedroom') and (price<=550)) or ((type='Shared/Roomate') and (price<=300)) or ((type='Room and Board') and (price<=500)) ) and price <= 400;
|
||||
price area type transityes shopsyes schoolsyes petsyes
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (program enum('signup','unique','sliding') not null, type enum('basic','sliding','signup'), sites set('mt'), PRIMARY KEY (program));
|
||||
ALTER TABLE t1 modify program enum('signup','unique','sliding');
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
name varchar(50) DEFAULT '' NOT NULL,
|
||||
author varchar(50) DEFAULT '' NOT NULL,
|
||||
category decimal(10,0) DEFAULT '0' NOT NULL,
|
||||
email varchar(50),
|
||||
password varchar(50),
|
||||
proxy varchar(50),
|
||||
bitmap varchar(20),
|
||||
msg varchar(255),
|
||||
urlscol varchar(127),
|
||||
urlhttp varchar(127),
|
||||
timeout decimal(10,0),
|
||||
nbcnx decimal(10,0),
|
||||
creation decimal(10,0),
|
||||
livinguntil decimal(10,0),
|
||||
lang decimal(10,0),
|
||||
type decimal(10,0),
|
||||
subcat decimal(10,0),
|
||||
subtype decimal(10,0),
|
||||
reg char(1),
|
||||
scs varchar(255),
|
||||
capacity decimal(10,0),
|
||||
userISP varchar(50),
|
||||
CCident varchar(50) DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (name,author,category)
|
||||
);
|
||||
INSERT INTO t1 VALUES
|
||||
('patnom','patauteur',0,'p.favre@cryo-networks.fr',NULL,NULL,'#p2sndnq6ae5g1u6t','essai salut','scol://195.242.78.119:patauteur.patnom',NULL,NULL,NULL,950036174,-882087474,NULL,3,0,3,'1','Pub/patnom/futur_divers.scs',NULL,'pat','CC1');
|
||||
INSERT INTO t1 VALUES
|
||||
('LeNomDeMonSite','Marc',0,'m.barilley@cryo-networks.fr',NULL,NULL,NULL,NULL,'scol://195.242.78.119:Marc.LeNomDeMonSite',NULL,NULL,NULL,950560434,-881563214,NULL,3,0,3,'1','Pub/LeNomDeMonSite/domus_hibere.scs',NULL,'Marq','CC1');
|
||||
select * from t1 where name='patnom' and author='patauteur' and category=0;
|
||||
name author category email password proxy bitmap msg urlscol urlhttp timeout nbcnx creation livinguntil lang type subcat subtype reg scs capacity userISP CCident
|
||||
patnom patauteur 0 p.favre@cryo-networks.fr NULL NULL #p2sndnq6ae5g1u6t essai salut scol://195.242.78.119:patauteur.patnom NULL NULL NULL 950036174 -882087474 NULL 3 0 3 1 Pub/patnom/futur_divers.scs NULL pat CC1
|
||||
drop table t1;
|
||||
create table t1
|
||||
(
|
||||
name_id int not null auto_increment,
|
||||
name blob,
|
||||
INDEX name_idx (name(5)),
|
||||
primary key (name_id)
|
||||
);
|
||||
INSERT t1 VALUES(NULL,'/');
|
||||
INSERT t1 VALUES(NULL,'[T,U]_axpby');
|
||||
SELECT * FROM t1 WHERE name='[T,U]_axpy';
|
||||
name_id name
|
||||
SELECT * FROM t1 WHERE name='[T,U]_axpby';
|
||||
name_id name
|
||||
2 [T,U]_axpby
|
||||
create table t2
|
||||
(
|
||||
name_id int not null auto_increment,
|
||||
name char(255) binary,
|
||||
INDEX name_idx (name(5)),
|
||||
primary key (name_id)
|
||||
);
|
||||
INSERT t2 select * from t1;
|
||||
SELECT * FROM t2 WHERE name='[T,U]_axpy';
|
||||
name_id name
|
||||
SELECT * FROM t2 WHERE name='[T,U]_axpby';
|
||||
name_id name
|
||||
2 [T,U]_axpby
|
||||
CREATE TABLE t3 SELECT * FROM t2 WHERE name='[T,U]_axpby';
|
||||
SELECT * FROM t2 WHERE name='[T,U]_axpby';
|
||||
name_id name
|
||||
2 [T,U]_axpby
|
||||
drop table t1,t2,t3;
|
||||
create table t1
|
||||
(
|
||||
SEQNO numeric(12 ) not null,
|
||||
MOTYPEID numeric(12 ) not null,
|
||||
MOINSTANCEID numeric(12 ) not null,
|
||||
ATTRID numeric(12 ) not null,
|
||||
VALUE varchar(120) not null,
|
||||
primary key (SEQNO, MOTYPEID, MOINSTANCEID, ATTRID, VALUE )
|
||||
);
|
||||
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
|
||||
INSERT INTO t1 VALUES (1, 1, 1, 1, 'b');
|
||||
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
|
||||
ERROR 23000: Duplicate entry '1-1-1-1-a' for key 'PRIMARY'
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a tinytext NOT NULL,
|
||||
b tinyint(3) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (a(32),b)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('a',1),('a',2);
|
||||
SELECT * FROM t1 WHERE a='a' AND b=2;
|
||||
a b
|
||||
a 2
|
||||
SELECT * FROM t1 WHERE a='a' AND b in (2);
|
||||
a b
|
||||
a 2
|
||||
SELECT * FROM t1 WHERE a='a' AND b in (1,2);
|
||||
a b
|
||||
a 1
|
||||
a 2
|
||||
drop table t1;
|
||||
create table t1 (a int not null unique, b int unique, c int, d int not null primary key, key(c), e int not null unique);
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 d A 0 NULL NULL BTREE
|
||||
t1 0 a 1 a A 0 NULL NULL BTREE
|
||||
t1 0 e 1 e A 0 NULL NULL BTREE
|
||||
t1 0 b 1 b A 0 NULL NULL YES BTREE
|
||||
t1 1 c 1 c A NULL NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (c CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT,
|
||||
UNIQUE (c,i));
|
||||
INSERT INTO t1 (c) VALUES (NULL),(NULL);
|
||||
Warnings:
|
||||
Warning 1048 Column 'c' cannot be null
|
||||
Warning 1048 Column 'c' cannot be null
|
||||
SELECT * FROM t1;
|
||||
c i
|
||||
1
|
||||
2
|
||||
INSERT INTO t1 (c) VALUES ('a'),('a');
|
||||
SELECT * FROM t1;
|
||||
c i
|
||||
1
|
||||
2
|
||||
a 3
|
||||
a 4
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (c CHAR(10) NULL, i INT NOT NULL AUTO_INCREMENT,
|
||||
UNIQUE (c,i));
|
||||
INSERT INTO t1 (c) VALUES (NULL),(NULL);
|
||||
SELECT * FROM t1;
|
||||
c i
|
||||
NULL 1
|
||||
NULL 2
|
||||
INSERT INTO t1 (c) VALUES ('a'),('a');
|
||||
SELECT * FROM t1;
|
||||
c i
|
||||
NULL 1
|
||||
NULL 2
|
||||
a 3
|
||||
a 4
|
||||
drop table t1;
|
||||
create table t1 (i int, a char(200), b text, unique (a), unique (b(300))) charset utf8;
|
||||
insert t1 values (1, repeat('a',210), repeat('b', 310));
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'a' at row 1
|
||||
insert t1 values (2, repeat(0xD0B1,215), repeat(0xD0B1, 310));
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'a' at row 1
|
||||
select i, length(a), length(b), char_length(a), char_length(b) from t1;
|
||||
i length(a) length(b) char_length(a) char_length(b)
|
||||
1 200 310 200 310
|
||||
2 400 620 200 310
|
||||
select i from t1 where a=repeat(_utf8 'a',200);
|
||||
i
|
||||
1
|
||||
select i from t1 where a=repeat(_utf8 0xD0B1,200);
|
||||
i
|
||||
2
|
||||
select i from t1 where b=repeat(_utf8 'b',310);
|
||||
i
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (id int unsigned auto_increment, name char(50), primary key (id)) engine=myisam;
|
||||
insert into t1 (name) values ('a'), ('b'),('c'),('d'),('e'),('f'),('g');
|
||||
explain select 1 from t1 where id =2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
|
||||
explain select 1 from t1 where id =2 or id=3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index
|
||||
explain select name from t1 where id =2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
|
||||
ALTER TABLE t1 DROP PRIMARY KEY, ADD INDEX (id);
|
||||
explain select 1 from t1 where id =2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref id id 4 const 1 Using index
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (numeropost mediumint(8) unsigned NOT NULL default '0', numreponse int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (numeropost,numreponse), UNIQUE KEY numreponse (numreponse));
|
||||
INSERT INTO t1 (numeropost,numreponse) VALUES ('1','1'),('1','2'),('2','3'),('2','4');
|
||||
SELECT numeropost FROM t1 WHERE numreponse='1';
|
||||
numeropost
|
||||
1
|
||||
EXPLAIN SELECT numeropost FROM t1 WHERE numreponse='1';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const numreponse numreponse 4 const 1 Using index
|
||||
FLUSH TABLES;
|
||||
SELECT numeropost FROM t1 WHERE numreponse='1';
|
||||
numeropost
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (c varchar(30) character set utf8, t text character set utf8, unique (c(2)), unique (t(3))) engine=myisam;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c` varchar(30) CHARACTER SET utf8 DEFAULT NULL,
|
||||
`t` text CHARACTER SET utf8,
|
||||
UNIQUE KEY `c` (`c`(2)),
|
||||
UNIQUE KEY `t` (`t`(3))
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
insert t1 values ('cccc', 'tttt'),
|
||||
(0xD0B1212223D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1212223D0B1D0B1D0B1D0B1),
|
||||
(0xD0B1222123D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1222123D0B1D0B1D0B1D0B1);
|
||||
insert t1 (c) values ('cc22');
|
||||
ERROR 23000: Duplicate entry 'cc22' for key 'c'
|
||||
insert t1 (t) values ('ttt22');
|
||||
ERROR 23000: Duplicate entry 'ttt22' for key 't'
|
||||
insert t1 (c) values (0xD0B1212322D0B1D0B1D0B1D0B1D0B1);
|
||||
ERROR 23000: Duplicate entry 'б!#"<22>' for key 'c'
|
||||
insert t1 (t) values (0xD0B1D0B1212322D0B1D0B1D0B1D0B1);
|
||||
ERROR 23000: Duplicate entry 'бб!#"б' for key 't'
|
||||
select c from t1 where c='cccc';
|
||||
c
|
||||
cccc
|
||||
select t from t1 where t='tttt';
|
||||
t
|
||||
tttt
|
||||
select c from t1 where c=0xD0B1212223D0B1D0B1D0B1D0B1D0B1;
|
||||
c
|
||||
?!"#?????
|
||||
select t from t1 where t=0xD0B1D0B1212223D0B1D0B1D0B1D0B1;
|
||||
t
|
||||
??!"#????
|
||||
drop table t1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
CREATE TABLE t1 (
|
||||
c1 int,
|
||||
c2 varbinary(240),
|
||||
UNIQUE KEY (c1),
|
||||
KEY (c2)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1,'\Z\Z\Z\Z');
|
||||
INSERT INTO t1 VALUES (2,'\Z\Z\Z\Z\Z\Z');
|
||||
INSERT INTO t1 VALUES (3,'\Z\Z\Z\Z');
|
||||
select c1 from t1 where c2='\Z\Z\Z\Z';
|
||||
c1
|
||||
1
|
||||
3
|
||||
DELETE FROM t1 WHERE (c1 = 1);
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
select c1 from t1 where c2='\Z\Z\Z\Z';
|
||||
c1
|
||||
3
|
||||
DELETE FROM t1 WHERE (c1 = 3);
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
select c1 from t1 where c2='\Z\Z\Z\Z';
|
||||
c1
|
||||
truncate table t1;
|
||||
insert into t1 values(1,"aaaa"),(2,"aaab"),(3,"aaac"),(4,"aaccc");
|
||||
delete from t1 where c1=3;
|
||||
delete from t1 where c1=1;
|
||||
delete from t1 where c1=4;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
create table t1 (c char(10), index (c(0)));
|
||||
ERROR HY000: Key part 'c' length cannot be 0
|
||||
create table t1 (c char(10), index (c,c));
|
||||
ERROR 42S21: Duplicate column name 'c'
|
||||
create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1));
|
||||
ERROR 42S21: Duplicate column name 'c1'
|
||||
create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2));
|
||||
ERROR 42S21: Duplicate column name 'c1'
|
||||
create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1));
|
||||
ERROR 42S21: Duplicate column name 'c1'
|
||||
create table t1 (c1 char(10), c2 char(10));
|
||||
alter table t1 add key (c1,c1);
|
||||
ERROR 42S21: Duplicate column name 'c1'
|
||||
alter table t1 add key (c2,c1,c1);
|
||||
ERROR 42S21: Duplicate column name 'c1'
|
||||
alter table t1 add key (c1,c2,c1);
|
||||
ERROR 42S21: Duplicate column name 'c1'
|
||||
alter table t1 add key (c1,c1,c2);
|
||||
ERROR 42S21: Duplicate column name 'c1'
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
i1 INT NOT NULL,
|
||||
i2 INT NOT NULL,
|
||||
UNIQUE i1idx (i1),
|
||||
UNIQUE i2idx (i2));
|
||||
desc t1;
|
||||
Field Type Null Key Default Extra
|
||||
i1 int(11) NO PRI NULL
|
||||
i2 int(11) NO UNI NULL
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i1` int(11) NOT NULL,
|
||||
`i2` int(11) NOT NULL,
|
||||
UNIQUE KEY `i1idx` (`i1`),
|
||||
UNIQUE KEY `i2idx` (`i2`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
c1 int,
|
||||
c2 varchar(20) not null,
|
||||
primary key (c1),
|
||||
key (c2(10))
|
||||
) engine=myisam;
|
||||
insert into t1 values (1,'');
|
||||
insert into t1 values (2,' \t\tTest String');
|
||||
insert into t1 values (3,' \n\tTest String');
|
||||
update t1 set c2 = 'New Test String' where c1 = 1;
|
||||
select * from t1;
|
||||
c1 c2
|
||||
1 New Test String
|
||||
2 Test String
|
||||
3
|
||||
Test String
|
||||
drop table t1;
|
||||
create table t1 (a varchar(10), b varchar(10), key(a(10),b(10)));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varchar(10) DEFAULT NULL,
|
||||
`b` varchar(10) DEFAULT NULL,
|
||||
KEY `a` (`a`,`b`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
alter table t1 modify b varchar(20);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varchar(10) DEFAULT NULL,
|
||||
`b` varchar(20) DEFAULT NULL,
|
||||
KEY `a` (`a`,`b`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
alter table t1 modify a varchar(20);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varchar(20) DEFAULT NULL,
|
||||
`b` varchar(20) DEFAULT NULL,
|
||||
KEY `a` (`a`,`b`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (a int not null primary key, b varchar(20) not null unique);
|
||||
desc t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) NO PRI NULL
|
||||
b varchar(20) NO UNI NULL
|
||||
drop table t1;
|
||||
create table t1 (a int not null primary key, b int not null unique);
|
||||
desc t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) NO PRI NULL
|
||||
b int(11) NO UNI NULL
|
||||
drop table t1;
|
||||
create table t1 (a int not null primary key, b varchar(20) not null, unique (b(10)));
|
||||
desc t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) NO PRI NULL
|
||||
b varchar(20) NO UNI NULL
|
||||
drop table t1;
|
||||
create table t1 (a int not null primary key, b varchar(20) not null, c varchar(20) not null, unique(b(10),c(10)));
|
||||
desc t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) NO PRI NULL
|
||||
b varchar(20) NO MUL NULL
|
||||
c varchar(20) NO NULL
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
c1 int,
|
||||
c2 char(12),
|
||||
c3 varchar(123),
|
||||
c4 timestamp,
|
||||
index (c1),
|
||||
index i1 (c1),
|
||||
index i2 (c2),
|
||||
index i3 (c3),
|
||||
unique i4 (c4),
|
||||
index i5 (c1, c2, c3, c4),
|
||||
primary key (c2, c3),
|
||||
index (c2, c4));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` int(11) DEFAULT NULL,
|
||||
`c2` char(12) NOT NULL DEFAULT '',
|
||||
`c3` varchar(123) NOT NULL DEFAULT '',
|
||||
`c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`c2`,`c3`),
|
||||
UNIQUE KEY `i4` (`c4`),
|
||||
KEY `c1` (`c1`),
|
||||
KEY `i1` (`c1`),
|
||||
KEY `i2` (`c2`),
|
||||
KEY `i3` (`c3`),
|
||||
KEY `i5` (`c1`,`c2`,`c3`,`c4`),
|
||||
KEY `c2` (`c2`,`c4`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
alter table t1 drop index c1;
|
||||
alter table t1 add index (c1);
|
||||
alter table t1 add index (c1);
|
||||
alter table t1 drop index i3;
|
||||
alter table t1 add index i3 (c3);
|
||||
alter table t1 drop index i2, drop index i4;
|
||||
alter table t1 add index i2 (c2), add index i4 (c4);
|
||||
alter table t1 drop index i2, drop index i4, add index i6 (c2, c4);
|
||||
alter table t1 add index i2 (c2), add index i4 (c4), drop index i6;
|
||||
alter table t1 drop index i2, drop index i4, add unique i4 (c4);
|
||||
alter table t1 add index i2 (c2), drop index i4, add index i4 (c4);
|
||||
alter table t1 drop index c2, add index (c2(4),c3(7));
|
||||
alter table t1 drop index c2, add index (c2(4),c3(7));
|
||||
alter table t1 add primary key (c1, c2), drop primary key;
|
||||
alter table t1 drop primary key;
|
||||
alter table t1 add primary key (c1, c2), drop primary key;
|
||||
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` int(11) NOT NULL DEFAULT '0',
|
||||
`c2` char(12) NOT NULL DEFAULT '',
|
||||
`c3` varchar(123) NOT NULL DEFAULT '',
|
||||
`c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
KEY `i1` (`c1`),
|
||||
KEY `i5` (`c1`,`c2`,`c3`,`c4`),
|
||||
KEY `c1` (`c1`),
|
||||
KEY `c1_2` (`c1`),
|
||||
KEY `i3` (`c3`),
|
||||
KEY `i2` (`c2`),
|
||||
KEY `i4` (`c4`),
|
||||
KEY `c2` (`c2`(4),`c3`(7))
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
insert into t1 values(1, 'a', 'a', NULL);
|
||||
insert into t1 values(1, 'b', 'b', NULL);
|
||||
alter table t1 drop index i3, drop index i2, drop index i1;
|
||||
alter table t1 add index i3 (c3), add index i2 (c2), add unique index i1 (c1);
|
||||
ERROR 23000: Duplicate entry '1' for key 'i1'
|
||||
drop table t1;
|
||||
324
mysql-test/suite/pbxt/r/key_cache.result
Normal file
324
mysql-test/suite/pbxt/r/key_cache.result
Normal file
@@ -0,0 +1,324 @@
|
||||
drop table if exists t1, t2, t3;
|
||||
SET @save_key_buffer=@@key_buffer_size;
|
||||
SELECT @@key_buffer_size, @@small.key_buffer_size;
|
||||
@@key_buffer_size @@small.key_buffer_size
|
||||
1048576 0
|
||||
SET @@global.key_buffer_size=16*1024*1024;
|
||||
SET @@global.default.key_buffer_size=16*1024*1024;
|
||||
SET @@global.default.key_buffer_size=16*1024*1024;
|
||||
SET @@global.small.key_buffer_size=1*1024*1024;
|
||||
SET @@global.medium.key_buffer_size=4*1024*1024;
|
||||
SET @@global.medium.key_buffer_size=0;
|
||||
SET @@global.medium.key_buffer_size=0;
|
||||
SHOW VARIABLES like "key_buffer_size";
|
||||
Variable_name Value
|
||||
key_buffer_size 16777216
|
||||
SELECT @@key_buffer_size;
|
||||
@@key_buffer_size
|
||||
16777216
|
||||
SELECT @@global.key_buffer_size;
|
||||
@@global.key_buffer_size
|
||||
16777216
|
||||
SELECT @@global.default.key_buffer_size;
|
||||
@@global.default.key_buffer_size
|
||||
16777216
|
||||
SELECT @@global.default.`key_buffer_size`;
|
||||
@@global.default.`key_buffer_size`
|
||||
16777216
|
||||
SELECT @@global.`default`.`key_buffer_size`;
|
||||
@@global.`default`.`key_buffer_size`
|
||||
16777216
|
||||
SELECT @@`default`.key_buffer_size;
|
||||
@@`default`.key_buffer_size
|
||||
16777216
|
||||
SELECT @@small.key_buffer_size;
|
||||
@@small.key_buffer_size
|
||||
1048576
|
||||
SELECT @@medium.key_buffer_size;
|
||||
@@medium.key_buffer_size
|
||||
0
|
||||
SET @@global.key_buffer_size=@save_key_buffer;
|
||||
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";
|
||||
ERROR HY000: Variable 'storage_engine' is not a variable component (can't be used as XXXX.variable_name)
|
||||
select @@keycache1.key_cache_block_size;
|
||||
@@keycache1.key_cache_block_size
|
||||
0
|
||||
select @@keycache1.key_buffer_size;
|
||||
@@keycache1.key_buffer_size
|
||||
0
|
||||
set global keycache1.key_cache_block_size=2048;
|
||||
select @@keycache1.key_buffer_size;
|
||||
@@keycache1.key_buffer_size
|
||||
0
|
||||
select @@keycache1.key_cache_block_size;
|
||||
@@keycache1.key_cache_block_size
|
||||
2048
|
||||
set global keycache1.key_buffer_size=1*1024*1024;
|
||||
select @@keycache1.key_buffer_size;
|
||||
@@keycache1.key_buffer_size
|
||||
1048576
|
||||
select @@keycache1.key_cache_block_size;
|
||||
@@keycache1.key_cache_block_size
|
||||
2048
|
||||
set global keycache2.key_buffer_size=4*1024*1024;
|
||||
select @@keycache2.key_buffer_size;
|
||||
@@keycache2.key_buffer_size
|
||||
4194304
|
||||
select @@keycache2.key_cache_block_size;
|
||||
@@keycache2.key_cache_block_size
|
||||
1024
|
||||
set global keycache1.key_buffer_size=0;
|
||||
select @@keycache1.key_buffer_size;
|
||||
@@keycache1.key_buffer_size
|
||||
0
|
||||
select @@keycache1.key_cache_block_size;
|
||||
@@keycache1.key_cache_block_size
|
||||
2048
|
||||
select @@key_buffer_size;
|
||||
@@key_buffer_size
|
||||
1048576
|
||||
select @@key_cache_block_size;
|
||||
@@key_cache_block_size
|
||||
1024
|
||||
set global keycache1.key_buffer_size=1024*1024;
|
||||
create table t1 (p int primary key, a char(10)) delay_key_write=1;
|
||||
create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a));
|
||||
insert into t1 values (1, 'qqqq'), (11, 'yyyy');
|
||||
insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
|
||||
(3, 1, 'yyyy'), (4, 3, 'zzzz');
|
||||
select * from t1;
|
||||
p a
|
||||
1 qqqq
|
||||
11 yyyy
|
||||
select * from t2;
|
||||
p i a
|
||||
1 1 qqqq
|
||||
2 1 pppp
|
||||
3 1 yyyy
|
||||
4 3 zzzz
|
||||
update t1 set p=2 where p=1;
|
||||
update t2 set i=2 where i=1;
|
||||
cache index t1 key (`primary`) in keycache1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
|
||||
explain select p from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
|
||||
select p from t1;
|
||||
p
|
||||
2
|
||||
11
|
||||
explain select i from t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL k1 5 NULL 4 Using index
|
||||
select i from t2;
|
||||
i
|
||||
2
|
||||
2
|
||||
2
|
||||
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 t1 index PRIMARY PRIMARY 4 NULL 2 Using index
|
||||
1 SIMPLE t2 ref k1 k1 5 test.t1.p 2 Using where; Using index
|
||||
select count(*) from t1, t2 where t1.p = t2.i;
|
||||
count(*)
|
||||
3
|
||||
cache index t2 in keycache1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
|
||||
update t2 set p=p+1000, i=2 where a='qqqq';
|
||||
cache index t2 in keycache2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
|
||||
insert into t2 values (2000, 3, 'yyyy');
|
||||
cache index t2 in keycache1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
|
||||
update t2 set p=3000 where a='zzzz';
|
||||
select * from t2 order by p;
|
||||
p i a
|
||||
2 2 pppp
|
||||
3 2 yyyy
|
||||
1001 2 qqqq
|
||||
2000 3 yyyy
|
||||
3000 3 zzzz
|
||||
explain select p from t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL PRIMARY 4 NULL 5 Using index
|
||||
select p from t2;
|
||||
p
|
||||
2
|
||||
3
|
||||
1001
|
||||
2000
|
||||
3000
|
||||
explain select i from t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL k1 5 NULL 5 Using index
|
||||
select i from t2;
|
||||
i
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
explain select a from t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL k2 11 NULL 5 Using index
|
||||
select a from t2;
|
||||
a
|
||||
pppp
|
||||
qqqq
|
||||
yyyy
|
||||
yyyy
|
||||
zzzz
|
||||
cache index t1 in unknown_key_cache;
|
||||
ERROR HY000: Unknown key cache 'unknown_key_cache'
|
||||
cache index t1 key (unknown_key) in keycache1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
|
||||
select @@keycache2.key_buffer_size;
|
||||
@@keycache2.key_buffer_size
|
||||
4194304
|
||||
select @@keycache2.key_cache_block_size;
|
||||
@@keycache2.key_cache_block_size
|
||||
1024
|
||||
set global keycache2.key_buffer_size=0;
|
||||
select @@keycache2.key_buffer_size;
|
||||
@@keycache2.key_buffer_size
|
||||
0
|
||||
select @@keycache2.key_cache_block_size;
|
||||
@@keycache2.key_cache_block_size
|
||||
1024
|
||||
set global keycache2.key_buffer_size=1024*1024;
|
||||
select @@keycache2.key_buffer_size;
|
||||
@@keycache2.key_buffer_size
|
||||
1048576
|
||||
update t2 set p=4000 where a='zzzz';
|
||||
update t1 set p=p+1;
|
||||
set global keycache1.key_buffer_size=0;
|
||||
select * from t2 order by p;
|
||||
p i a
|
||||
2 2 pppp
|
||||
3 2 yyyy
|
||||
1001 2 qqqq
|
||||
2000 3 yyyy
|
||||
4000 3 zzzz
|
||||
select p from t2 order by p;
|
||||
p
|
||||
2
|
||||
3
|
||||
1001
|
||||
2000
|
||||
4000
|
||||
explain select i from t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL k1 5 NULL 5 Using index
|
||||
select i from t2;
|
||||
i
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
explain select a from t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL k2 11 NULL 5 Using index
|
||||
select a from t2;
|
||||
a
|
||||
pppp
|
||||
qqqq
|
||||
yyyy
|
||||
yyyy
|
||||
zzzz
|
||||
select * from t1;
|
||||
p a
|
||||
12 yyyy
|
||||
3 qqqq
|
||||
select p from t1;
|
||||
p
|
||||
3
|
||||
12
|
||||
create table t3 (like t1);
|
||||
cache index t3 in small;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t3 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
|
||||
insert into t3 select * from t1;
|
||||
cache index t3 in keycache2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t3 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
|
||||
cache index t1,t2 in default;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
|
||||
test.t2 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
|
||||
drop table t1,t2,t3;
|
||||
set global keycache2.key_buffer_size=0;
|
||||
set global keycache3.key_buffer_size=100;
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect key_buffer_size value: '100'
|
||||
set global keycache3.key_buffer_size=0;
|
||||
create table t1 (mytext text, FULLTEXT (mytext)) engine=myisam;
|
||||
insert t1 values ('aaabbb');
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
set @my_key_cache_block_size= @@global.key_cache_block_size;
|
||||
set GLOBAL key_cache_block_size=2048;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
set global key_cache_block_size= @my_key_cache_block_size;
|
||||
CREATE TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY);
|
||||
SET @my_key_cache_block_size= @@global.key_cache_block_size;
|
||||
SET GLOBAL key_cache_block_size=1536;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
SELECT @@key_cache_block_size;
|
||||
@@key_cache_block_size
|
||||
1536
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int);
|
||||
CREATE TABLE t2(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int);
|
||||
SET GLOBAL key_cache_block_size=1536;
|
||||
INSERT INTO t1 VALUES (1,0);
|
||||
INSERT INTO t2(b) SELECT b FROM t1;
|
||||
INSERT INTO t1(b) SELECT b FROM t2;
|
||||
INSERT INTO t2(b) SELECT b FROM t1;
|
||||
INSERT INTO t1(b) SELECT b FROM t2;
|
||||
INSERT INTO t2(b) SELECT b FROM t1;
|
||||
INSERT INTO t1(b) SELECT b FROM t2;
|
||||
INSERT INTO t2(b) SELECT b FROM t1;
|
||||
INSERT INTO t1(b) SELECT b FROM t2;
|
||||
INSERT INTO t2(b) SELECT b FROM t1;
|
||||
INSERT INTO t1(b) SELECT b FROM t2;
|
||||
INSERT INTO t2(b) SELECT b FROM t1;
|
||||
INSERT INTO t1(b) SELECT b FROM t2;
|
||||
INSERT INTO t2(b) SELECT b FROM t1;
|
||||
INSERT INTO t1(b) SELECT b FROM t2;
|
||||
INSERT INTO t2(b) SELECT b FROM t1;
|
||||
INSERT INTO t1(b) SELECT b FROM t2;
|
||||
INSERT INTO t2(b) SELECT b FROM t1;
|
||||
INSERT INTO t1(b) SELECT b FROM t2;
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
4181
|
||||
SELECT @@key_cache_block_size;
|
||||
@@key_cache_block_size
|
||||
1536
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
DROP TABLE t1,t2;
|
||||
set global key_cache_block_size= @my_key_cache_block_size;
|
||||
set @@global.key_buffer_size=0;
|
||||
Warnings:
|
||||
Warning 1438 Cannot drop default keycache
|
||||
select @@global.key_buffer_size;
|
||||
@@global.key_buffer_size
|
||||
1048576
|
||||
52
mysql-test/suite/pbxt/r/key_diff.result
Normal file
52
mysql-test/suite/pbxt/r/key_diff.result
Normal file
@@ -0,0 +1,52 @@
|
||||
drop table if exists t1;
|
||||
CREATE TABLE t1 (
|
||||
a char(5) NOT NULL,
|
||||
b char(4) NOT NULL,
|
||||
KEY (a),
|
||||
KEY (b)
|
||||
);
|
||||
INSERT INTO t1 VALUES ('A','B'),('b','A'),('C','c'),('D','E'),('a','a');
|
||||
select * from t1,t1 as t2;
|
||||
a b a b
|
||||
A B A B
|
||||
b A A B
|
||||
C c A B
|
||||
D E A B
|
||||
a a A B
|
||||
A B b A
|
||||
b A b A
|
||||
C c b A
|
||||
D E b A
|
||||
a a b A
|
||||
A B C c
|
||||
b A C c
|
||||
C c C c
|
||||
D E C c
|
||||
a a C c
|
||||
A B D E
|
||||
b A D E
|
||||
C c D E
|
||||
D E D E
|
||||
a a D E
|
||||
A B a a
|
||||
b A a a
|
||||
C c a a
|
||||
D E a a
|
||||
a a a a
|
||||
explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL a NULL NULL NULL 5
|
||||
1 SIMPLE t2 ALL b NULL NULL NULL 5 Using where; Using join buffer
|
||||
select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a;
|
||||
a b a b
|
||||
A B a a
|
||||
A B b A
|
||||
C c C c
|
||||
a a a a
|
||||
a a b A
|
||||
b A A B
|
||||
select * from t1 where a='a';
|
||||
a b
|
||||
A B
|
||||
a a
|
||||
drop table t1;
|
||||
20
mysql-test/suite/pbxt/r/key_primary.result
Normal file
20
mysql-test/suite/pbxt/r/key_primary.result
Normal file
@@ -0,0 +1,20 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (t1 char(3) primary key);
|
||||
insert into t1 values("ABC");
|
||||
insert into t1 values("ABA");
|
||||
insert into t1 values("AB%");
|
||||
select * from t1 where t1="ABC";
|
||||
t1
|
||||
ABC
|
||||
select * from t1 where t1="ABCD";
|
||||
t1
|
||||
select * from t1 where t1 like "a_\%";
|
||||
t1
|
||||
AB%
|
||||
describe select * from t1 where t1="ABC";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const PRIMARY PRIMARY 3 const 1 Using index
|
||||
describe select * from t1 where t1="ABCD";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
drop table t1;
|
||||
34
mysql-test/suite/pbxt/r/keywords.result
Normal file
34
mysql-test/suite/pbxt/r/keywords.result
Normal file
@@ -0,0 +1,34 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (time time, date date, timestamp timestamp,
|
||||
quarter int, week int, year int, timestampadd int, timestampdiff int);
|
||||
insert into t1 values ("12:22:22","97:02:03","1997-01-02",1,2,3,4,5);
|
||||
select * from t1;
|
||||
time date timestamp quarter week year timestampadd timestampdiff
|
||||
12:22:22 1997-02-03 1997-01-02 00:00:00 1 2 3 4 5
|
||||
select t1.time+0,t1.date+0,t1.timestamp+0,concat(date," ",time),
|
||||
t1.quarter+t1.week, t1.year+timestampadd, timestampdiff from t1;
|
||||
t1.time+0 t1.date+0 t1.timestamp+0 concat(date," ",time) t1.quarter+t1.week t1.year+timestampadd timestampdiff
|
||||
122222 19970203 19970102000000 1997-02-03 12:22:22 3 7 5
|
||||
drop table t1;
|
||||
create table events(binlog int);
|
||||
insert into events values(1);
|
||||
select events.binlog from events;
|
||||
binlog
|
||||
1
|
||||
drop table events;
|
||||
create procedure p1()
|
||||
begin
|
||||
declare n int default 2;
|
||||
authors: while n > 0 do
|
||||
set n = n -1;
|
||||
end while authors;
|
||||
end|
|
||||
create procedure p2()
|
||||
begin
|
||||
declare n int default 2;
|
||||
contributors: while n > 0 do
|
||||
set n = n -1;
|
||||
end while contributors;
|
||||
end|
|
||||
drop procedure p1;
|
||||
drop procedure p2;
|
||||
93
mysql-test/suite/pbxt/r/limit.result
Normal file
93
mysql-test/suite/pbxt/r/limit.result
Normal file
@@ -0,0 +1,93 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (a int not null default 0 primary key, b int not null default 0);
|
||||
insert into t1 () values ();
|
||||
insert into t1 values (1,1),(2,1),(3,1);
|
||||
update t1 set a=4 where b=1 limit 1;
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
0 0
|
||||
2 1
|
||||
3 1
|
||||
4 1
|
||||
update t1 set b=2 where b=1 limit 2;
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
0 0
|
||||
2 2
|
||||
3 2
|
||||
4 1
|
||||
update t1 set b=4 where b=1;
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
0 0
|
||||
2 2
|
||||
3 2
|
||||
4 4
|
||||
delete from t1 where b=2 limit 1;
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
0 0
|
||||
3 2
|
||||
4 4
|
||||
delete from t1 limit 1;
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
3 2
|
||||
4 4
|
||||
drop table t1;
|
||||
create table t1 (i int);
|
||||
insert into t1 (i) values(1),(1),(1);
|
||||
delete from t1 limit 1;
|
||||
update t1 set i=2 limit 1;
|
||||
delete from t1 limit 0;
|
||||
update t1 set i=3 limit 0;
|
||||
select * from t1;
|
||||
i
|
||||
1
|
||||
2
|
||||
drop table t1;
|
||||
select 0 limit 0;
|
||||
0
|
||||
CREATE TABLE t1(id int auto_increment primary key, id2 int, index(id2));
|
||||
INSERT INTO t1 (id2) values (0),(0),(0);
|
||||
DELETE FROM t1 WHERE id=1;
|
||||
INSERT INTO t1 SET id2=0;
|
||||
SELECT * FROM t1;
|
||||
id id2
|
||||
2 0
|
||||
3 0
|
||||
4 0
|
||||
DELETE FROM t1 WHERE id2 = 0 ORDER BY id LIMIT 1;
|
||||
SELECT * FROM t1;
|
||||
id id2
|
||||
3 0
|
||||
4 0
|
||||
DELETE FROM t1 WHERE id2 = 0 ORDER BY id desc LIMIT 1;
|
||||
SELECT * FROM t1;
|
||||
id id2
|
||||
3 0
|
||||
DROP TABLE t1;
|
||||
create table t1 (a integer);
|
||||
insert into t1 values (1);
|
||||
select 1 as a from t1 union all select 1 from dual limit 1;
|
||||
a
|
||||
1
|
||||
(select 1 as a from t1) union all (select 1 from dual) limit 1;
|
||||
a
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
|
||||
explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where; Using temporary
|
||||
select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
|
||||
c
|
||||
7
|
||||
explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where; Using temporary
|
||||
select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
|
||||
c
|
||||
28
|
||||
drop table t1;
|
||||
78
mysql-test/suite/pbxt/r/lock.result
Normal file
78
mysql-test/suite/pbxt/r/lock.result
Normal file
@@ -0,0 +1,78 @@
|
||||
drop table if exists t1,t2;
|
||||
CREATE TABLE t1 ( `id` int(11) NOT NULL default '0', `id2` int(11) NOT NULL default '0', `id3` int(11) NOT NULL default '0', `dummy1` char(30) default NULL, PRIMARY KEY (`id`,`id2`), KEY `index_id3` (`id3`)) ENGINE=MyISAM;
|
||||
insert into t1 (id,id2) values (1,1),(1,2),(1,3);
|
||||
LOCK TABLE t1 WRITE;
|
||||
select dummy1,count(distinct id) from t1 group by dummy1;
|
||||
dummy1 count(distinct id)
|
||||
NULL 1
|
||||
update t1 set id=-1 where id=1;
|
||||
LOCK TABLE t1 READ;
|
||||
update t1 set id=1 where id=1;
|
||||
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
|
||||
create table t2 SELECT * from t1;
|
||||
ERROR HY000: Table 't2' was not locked with LOCK TABLES
|
||||
create temporary table t2 SELECT * from t1;
|
||||
drop table if exists t2;
|
||||
unlock tables;
|
||||
create table t2 SELECT * from t1;
|
||||
LOCK TABLE t1 WRITE,t2 write;
|
||||
insert into t2 SELECT * from t1;
|
||||
update t1 set id=1 where id=-1;
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (
|
||||
index1 smallint(6) default NULL,
|
||||
nr smallint(6) default NULL,
|
||||
KEY index1(index1)
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (
|
||||
nr smallint(6) default NULL,
|
||||
name varchar(20) default NULL
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,'item1');
|
||||
INSERT INTO t2 VALUES (2,'item2');
|
||||
lock tables t1 write, t2 read;
|
||||
insert into t1 select 1,nr from t2 where name='item1';
|
||||
insert into t1 select 2,nr from t2 where name='item2';
|
||||
unlock tables;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
lock tables t1 write;
|
||||
check table t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 check Error Table 't2' was not locked with LOCK TABLES
|
||||
test.t2 check error Corrupt
|
||||
insert into t1 select index1,nr from t1;
|
||||
ERROR HY000: Table 't1' was not locked with LOCK TABLES
|
||||
unlock tables;
|
||||
lock tables t1 write, t1 as t1_alias read;
|
||||
insert into t1 select index1,nr from t1 as t1_alias;
|
||||
drop table t1,t2;
|
||||
create table t1 (c1 int);
|
||||
create table t2 (c1 int);
|
||||
create table t3 (c1 int);
|
||||
lock tables t1 write, t2 write, t3 write;
|
||||
drop table t2, t3, t1;
|
||||
create table t1 (c1 int);
|
||||
create table t2 (c1 int);
|
||||
create table t3 (c1 int);
|
||||
lock tables t1 write, t2 write, t3 write, t1 as t4 read;
|
||||
alter table t2 add column c2 int;
|
||||
drop table t1, t2, t3;
|
||||
create table t1 ( a int(11) not null auto_increment, primary key(a));
|
||||
create table t2 ( a int(11) not null auto_increment, primary key(a));
|
||||
lock tables t1 write, t2 read;
|
||||
delete from t1 using t1,t2 where t1.a=t2.a;
|
||||
delete t1 from t1,t2 where t1.a=t2.a;
|
||||
delete from t2 using t1,t2 where t1.a=t2.a;
|
||||
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
|
||||
delete t2 from t1,t2 where t1.a=t2.a;
|
||||
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
|
||||
drop table t1,t2;
|
||||
drop table if exists t1;
|
||||
create table t1 (a int);
|
||||
lock table t1 write;
|
||||
flush tables with read lock;
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
96
mysql-test/suite/pbxt/r/lock_multi.result
Normal file
96
mysql-test/suite/pbxt/r/lock_multi.result
Normal file
@@ -0,0 +1,96 @@
|
||||
drop table if exists t1,t2;
|
||||
create table t1(n int);
|
||||
insert into t1 values (1);
|
||||
lock tables t1 write;
|
||||
update low_priority t1 set n = 4;
|
||||
select n from t1;
|
||||
unlock tables;
|
||||
n
|
||||
1
|
||||
drop table t1;
|
||||
create table t1(n int);
|
||||
insert into t1 values (1);
|
||||
lock tables t1 read;
|
||||
update low_priority t1 set n = 4;
|
||||
select n from t1;
|
||||
unlock tables;
|
||||
n
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (a int, b int);
|
||||
create table t2 (c int, d int);
|
||||
insert into t1 values(1,1);
|
||||
insert into t1 values(2,2);
|
||||
insert into t2 values(1,2);
|
||||
lock table t1 read;
|
||||
update t1,t2 set c=a where b=d;
|
||||
select c from t2;
|
||||
c
|
||||
2
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
lock table t1 write, t2 write;
|
||||
insert t1 select * from t2;
|
||||
drop table t2;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
lock table t1 write, t2 write, t1 as t1_2 write, t2 as t2_2 write;
|
||||
insert t1 select * from t2;
|
||||
drop table t2;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
drop table t1;
|
||||
create table t1(a int);
|
||||
lock tables t1 write;
|
||||
show columns from t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
use mysql;
|
||||
LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
|
||||
FLUSH TABLES;
|
||||
use mysql;
|
||||
SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
|
||||
OPTIMIZE TABLES columns_priv, db, host, user;
|
||||
Table Op Msg_type Msg_text
|
||||
mysql.columns_priv optimize status OK
|
||||
mysql.db optimize status OK
|
||||
mysql.host optimize status OK
|
||||
mysql.user optimize status OK
|
||||
UNLOCK TABLES;
|
||||
Select_priv
|
||||
use test;
|
||||
use test;
|
||||
CREATE TABLE t1 (c1 int);
|
||||
LOCK TABLE t1 WRITE;
|
||||
FLUSH TABLES WITH READ LOCK;
|
||||
CREATE TABLE t2 (c1 int);
|
||||
UNLOCK TABLES;
|
||||
UNLOCK TABLES;
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1 (c1 int);
|
||||
LOCK TABLE t1 WRITE;
|
||||
FLUSH TABLES WITH READ LOCK;
|
||||
CREATE TABLE t2 AS SELECT * FROM t1;
|
||||
ERROR HY000: Table 't2' was not locked with LOCK TABLES
|
||||
UNLOCK TABLES;
|
||||
UNLOCK TABLES;
|
||||
DROP TABLE t1;
|
||||
CREATE DATABASE mysqltest_1;
|
||||
FLUSH TABLES WITH READ LOCK;
|
||||
DROP DATABASE mysqltest_1;
|
||||
DROP DATABASE mysqltest_1;
|
||||
ERROR HY000: Can't execute the query because you have a conflicting read lock
|
||||
UNLOCK TABLES;
|
||||
DROP DATABASE mysqltest_1;
|
||||
ERROR HY000: Can't drop database 'mysqltest_1'; database doesn't exist
|
||||
create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb;
|
||||
lock tables t1 write;
|
||||
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
|
||||
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
8
mysql-test/suite/pbxt/r/lock_tables_lost_commit.result
Normal file
8
mysql-test/suite/pbxt/r/lock_tables_lost_commit.result
Normal file
@@ -0,0 +1,8 @@
|
||||
drop table if exists t1;
|
||||
create table t1(a int) engine=innodb;
|
||||
lock tables t1 write;
|
||||
insert into t1 values(10);
|
||||
select * from t1;
|
||||
a
|
||||
10
|
||||
drop table t1;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user