mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
merging
mysql-test/r/ps.result: Auto merged sql/sql_class.cc: Auto merged sql/sql_select.cc: Auto merged
This commit is contained in:
@ -36,12 +36,19 @@ test_SCRIPTS = mysql-test-run install_test_db
|
||||
test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem
|
||||
CLEANFILES = $(test_SCRIPTS) $(test_DATA)
|
||||
|
||||
INCLUDES = -I$(srcdir)/../include -I../include -I..
|
||||
EXTRA_PROGRAMS = mysql_test_run_new
|
||||
noinst_HEADERS = my_manage.h
|
||||
mysql_test_run_new_SOURCES= mysql_test_run_new.c my_manage.c my_create_tables.c
|
||||
|
||||
|
||||
dist-hook:
|
||||
mkdir -p $(distdir)/t $(distdir)/r $(distdir)/include \
|
||||
$(distdir)/std_data
|
||||
$(INSTALL_DATA) $(srcdir)/t/*.test $(srcdir)/t/*.opt $(srcdir)/t/*.sh $(srcdir)/t/*.slave-mi $(distdir)/t
|
||||
$(INSTALL_DATA) $(srcdir)/include/*.inc $(distdir)/include
|
||||
$(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.require $(distdir)/r
|
||||
$(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.result.es $(srcdir)/r/*.require $(distdir)/r
|
||||
$(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(distdir)/std_data
|
||||
$(INSTALL_DATA) $(srcdir)/std_data/*.dat $(srcdir)/std_data/*.000001 $(distdir)/std_data
|
||||
$(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(distdir)/std_data
|
||||
$(INSTALL_DATA) $(srcdir)/std_data/*.pem $(distdir)/std_data
|
||||
@ -58,12 +65,13 @@ install-data-local:
|
||||
$(INSTALL_DATA) $(srcdir)/t/*.opt $(DESTDIR)$(testdir)/t
|
||||
$(INSTALL_DATA) $(srcdir)/t/*.sh $(DESTDIR)$(testdir)/t
|
||||
$(INSTALL_DATA) $(srcdir)/t/*.slave-mi $(DESTDIR)$(testdir)/t
|
||||
$(INSTALL_DATA) $(srcdir)/r/*.result $(DESTDIR)$(testdir)/r
|
||||
$(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.result.es $(DESTDIR)$(testdir)/r
|
||||
$(INSTALL_DATA) $(srcdir)/r/*.require $(DESTDIR)$(testdir)/r
|
||||
$(INSTALL_DATA) $(srcdir)/include/*.inc $(DESTDIR)$(testdir)/include
|
||||
$(INSTALL_DATA) $(srcdir)/std_data/*.dat $(DESTDIR)$(testdir)/std_data
|
||||
$(INSTALL_DATA) $(srcdir)/std_data/*.*001 $(DESTDIR)$(testdir)/std_data
|
||||
$(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(DESTDIR)$(testdir)/std_data
|
||||
$(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(DESTDIR)$(testdir)/std_data
|
||||
$(INSTALL_DATA) $(srcdir)/std_data/*.pem $(DESTDIR)$(testdir)/std_data
|
||||
|
||||
std_data/%.pem:
|
||||
|
58
mysql-test/include/ctype_common.inc
Normal file
58
mysql-test/include/ctype_common.inc
Normal file
@ -0,0 +1,58 @@
|
||||
#
|
||||
# Common tests for all character sets and collations.
|
||||
# Include this file from a test with @test_characrer_set
|
||||
# and @test_collation set to desired values.
|
||||
#
|
||||
# Please don't use SHOW CREATE TABLE in this file,
|
||||
# we want it to be HANDLER independent. You can
|
||||
# use SHOW FULL COLUMNS instead.
|
||||
#
|
||||
# Please surround all CREATE TABLE with --disable_warnings
|
||||
# and --enable_warnings to be able to set storage_engine
|
||||
# without having to check if the hanlder exists.
|
||||
|
||||
SET @safe_character_set_server= @@character_set_server;
|
||||
SET @safe_collation_server= @@collation_server;
|
||||
SET character_set_server= @test_character_set;
|
||||
SET collation_server= @test_collation;
|
||||
CREATE DATABASE d1;
|
||||
USE d1;
|
||||
|
||||
#
|
||||
# Bug 1883: LIKE did not work in some cases with a key.
|
||||
#
|
||||
--disable_warnings
|
||||
CREATE TABLE t1 (c CHAR(10), KEY(c));
|
||||
--enable_warnings
|
||||
# check the column was created with the expected charset/collation
|
||||
--replace_result select,insert,update,references ""
|
||||
SHOW FULL COLUMNS FROM t1;
|
||||
INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa');
|
||||
SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%';
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug 6643 incorrect response with partial utf8 index
|
||||
#
|
||||
--disable_warnings
|
||||
CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2)));
|
||||
--enable_warnings
|
||||
# check the column was created with the expected charset/collation
|
||||
--replace_result select,insert,update,references ""
|
||||
SHOW FULL COLUMNS FROM t1;
|
||||
INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab');
|
||||
SELECT c1 as want3results from t1 where c1 like 'l%';
|
||||
SELECT c1 as want3results from t1 where c1 like 'lo%';
|
||||
SELECT c1 as want1result from t1 where c1 like 'loc%';
|
||||
SELECT c1 as want1result from t1 where c1 like 'loca%';
|
||||
SELECT c1 as want1result from t1 where c1 like 'locat%';
|
||||
SELECT c1 as want1result from t1 where c1 like 'locati%';
|
||||
SELECT c1 as want1result from t1 where c1 like 'locatio%';
|
||||
SELECT c1 as want1result from t1 where c1 like 'location%';
|
||||
DROP TABLE t1;
|
||||
|
||||
DROP DATABASE d1;
|
||||
# Restore settings
|
||||
USE test;
|
||||
SET character_set_server= @safe_character_set_server;
|
||||
SET collation_server= @safe_collation_server;
|
15
mysql-test/include/ctype_filesort.inc
Normal file
15
mysql-test/include/ctype_filesort.inc
Normal file
@ -0,0 +1,15 @@
|
||||
#
|
||||
# Set desired charset_connection and collation_collation
|
||||
# before including this file.
|
||||
#
|
||||
|
||||
# The next query creates a LONGTEXT column
|
||||
# using the current character_set_connection
|
||||
# and collation_connection.
|
||||
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
drop table t1;
|
7
mysql-test/include/endspace.inc
Normal file
7
mysql-test/include/endspace.inc
Normal file
@ -0,0 +1,7 @@
|
||||
select 'a' = 'a', 'a' = 'a ', 'a ' = 'a';
|
||||
select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a';
|
||||
select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0';
|
||||
select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a ';
|
||||
select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0';
|
||||
select 'a a' > 'a', 'a \0' < 'a';
|
||||
select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a';
|
@ -1,3 +1,4 @@
|
||||
--exec test x$NDB_STATUS_OK = x1
|
||||
-- require r/have_ndb.require
|
||||
disable_query_log;
|
||||
show variables like "have_ndbcluster";
|
||||
|
@ -322,8 +322,11 @@ select a,b from t1 where a >= 1000 order by a ;
|
||||
delete from t1 where a >= 1000 ;
|
||||
|
||||
## replace
|
||||
--error 1295
|
||||
prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' ';
|
||||
execute stmt1;
|
||||
execute stmt1;
|
||||
execute stmt1;
|
||||
|
||||
|
||||
|
||||
## multi table statements
|
||||
|
@ -65,6 +65,9 @@ execute stmt1 using @1000, @duplicate, @5;
|
||||
select a,b from t1 where a >= 1000 order by a ;
|
||||
delete from t1 where a >= 1000 ;
|
||||
|
||||
set @1=1 ;
|
||||
set @2=2 ;
|
||||
set @100=100 ;
|
||||
set @float=1.00;
|
||||
set @five='five' ;
|
||||
--disable_warnings
|
||||
|
58
mysql-test/init_db.sql
Normal file
58
mysql-test/init_db.sql
Normal file
File diff suppressed because one or more lines are too long
470
mysql-test/lib/init_db.sql
Normal file
470
mysql-test/lib/init_db.sql
Normal file
@ -0,0 +1,470 @@
|
||||
USE mysql;
|
||||
|
||||
CREATE TABLE db (
|
||||
Host char(60) binary DEFAULT '' NOT NULL,
|
||||
Db char(64) binary DEFAULT '' NOT NULL,
|
||||
User char(16) binary DEFAULT '' NOT NULL,
|
||||
Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
References_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
PRIMARY KEY Host (Host,Db,User),
|
||||
KEY User (User)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8 COLLATE utf8_bin
|
||||
comment='Database privileges';
|
||||
|
||||
|
||||
INSERT INTO db VALUES ('%','test' ,'','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
|
||||
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
|
||||
|
||||
|
||||
CREATE TABLE host (
|
||||
Host char(60) binary DEFAULT '' NOT NULL,
|
||||
Db char(64) binary DEFAULT '' NOT NULL,
|
||||
Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
References_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
PRIMARY KEY Host (Host,Db)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8 COLLATE utf8_bin
|
||||
comment='Host privileges; Merged with database privileges';
|
||||
|
||||
|
||||
CREATE TABLE user (
|
||||
Host char(60) binary DEFAULT '' NOT NULL,
|
||||
User char(16) binary DEFAULT '' NOT NULL,
|
||||
Password char(41) binary DEFAULT '' NOT NULL,
|
||||
Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Process_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
File_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
References_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Super_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
ssl_type enum('','ANY','X509', 'SPECIFIED') DEFAULT '' NOT NULL,
|
||||
ssl_cipher BLOB NOT NULL,
|
||||
x509_issuer BLOB NOT NULL,
|
||||
x509_subject BLOB NOT NULL,
|
||||
max_questions int(11) unsigned DEFAULT 0 NOT NULL,
|
||||
max_updates int(11) unsigned DEFAULT 0 NOT NULL,
|
||||
max_connections int(11) unsigned DEFAULT 0 NOT NULL,
|
||||
PRIMARY KEY Host (Host,User)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8 COLLATE utf8_bin
|
||||
comment='Users and global privileges';
|
||||
|
||||
|
||||
INSERT INTO user VALUES ('localhost' ,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
|
||||
INSERT INTO user VALUES ('@HOSTNAME@%','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
|
||||
REPLACE INTO user VALUES ('127.0.0.1' ,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
|
||||
INSERT INTO user (host,user) VALUES ('localhost','');
|
||||
INSERT INTO user (host,user) VALUES ('@HOSTNAME@%','');
|
||||
|
||||
|
||||
CREATE TABLE func (
|
||||
name char(64) binary DEFAULT '' NOT NULL,
|
||||
ret tinyint(1) DEFAULT '0' NOT NULL,
|
||||
dl char(128) DEFAULT '' NOT NULL,
|
||||
type enum ('function','aggregate') NOT NULL,
|
||||
PRIMARY KEY (name)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8 COLLATE utf8_bin
|
||||
comment='User defined functions';
|
||||
|
||||
|
||||
CREATE TABLE tables_priv (
|
||||
Host char(60) binary DEFAULT '' NOT NULL,
|
||||
Db char(64) binary DEFAULT '' NOT NULL,
|
||||
User char(16) binary DEFAULT '' NOT NULL,
|
||||
Table_name char(64) binary DEFAULT '' NOT NULL,
|
||||
Grantor char(77) DEFAULT '' NOT NULL,
|
||||
Timestamp timestamp(14),
|
||||
Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,
|
||||
Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (Host,Db,User,Table_name),KEY Grantor (Grantor)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8 COLLATE utf8_bin
|
||||
comment='Table privileges';
|
||||
|
||||
|
||||
CREATE TABLE columns_priv (
|
||||
Host char(60) binary DEFAULT '' NOT NULL,
|
||||
Db char(64) binary DEFAULT '' NOT NULL,
|
||||
User char(16) binary DEFAULT '' NOT NULL,
|
||||
Table_name char(64) binary DEFAULT '' NOT NULL,
|
||||
Column_name char(64) binary DEFAULT '' NOT NULL,
|
||||
Timestamp timestamp(14),
|
||||
Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (Host,Db,User,Table_name,Column_name)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8 COLLATE utf8_bin
|
||||
comment='Column privileges';
|
||||
|
||||
|
||||
CREATE TABLE help_topic (
|
||||
help_topic_id int unsigned not null,
|
||||
name varchar(64) not null,
|
||||
help_category_id smallint unsigned not null,
|
||||
description text not null,
|
||||
example text not null,
|
||||
url varchar(128) not null,
|
||||
primary key (help_topic_id),
|
||||
unique index (name)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8
|
||||
comment='help topics';
|
||||
|
||||
|
||||
CREATE TABLE help_category (
|
||||
help_category_id smallint unsigned not null,
|
||||
name varchar(64) not null,
|
||||
parent_category_id smallint unsigned null,
|
||||
url varchar(128) not null,
|
||||
primary key (help_category_id),unique index (name)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8
|
||||
comment='help categories';
|
||||
|
||||
|
||||
CREATE TABLE help_keyword (
|
||||
help_keyword_id int unsigned not null,
|
||||
name varchar(64) not null,
|
||||
primary key (help_keyword_id),unique index (name)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8
|
||||
comment='help keywords';
|
||||
|
||||
|
||||
CREATE TABLE help_relation (
|
||||
help_topic_id int unsigned not null references help_topic,
|
||||
help_keyword_id int unsigned not null references help_keyword,
|
||||
primary key (help_keyword_id, help_topic_id)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8
|
||||
comment='keyword-topic relation';
|
||||
|
||||
|
||||
CREATE TABLE time_zone_name (
|
||||
Name char(64) NOT NULL,
|
||||
Time_zone_id int unsigned NOT NULL,
|
||||
PRIMARY KEY Name (Name)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8
|
||||
comment='Time zone names';
|
||||
|
||||
|
||||
INSERT INTO time_zone_name (Name, Time_Zone_id) VALUES
|
||||
('MET', 1), ('UTC', 2), ('Universal', 2),
|
||||
('Europe/Moscow',3), ('leap/Europe/Moscow',4),
|
||||
('Japan', 5);
|
||||
|
||||
|
||||
CREATE TABLE time_zone (
|
||||
Time_zone_id int unsigned NOT NULL auto_increment,
|
||||
Use_leap_seconds enum('Y','N') DEFAULT 'N' NOT NULL,
|
||||
PRIMARY KEY TzId (Time_zone_id)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8
|
||||
comment='Time zones';
|
||||
|
||||
|
||||
INSERT INTO time_zone (Time_zone_id, Use_leap_seconds)
|
||||
VALUES (1,'N'), (2,'N'), (3,'N'), (4,'Y'), (5,'N');
|
||||
|
||||
|
||||
CREATE TABLE time_zone_transition (
|
||||
Time_zone_id int unsigned NOT NULL,
|
||||
Transition_time bigint signed NOT NULL,
|
||||
Transition_type_id int unsigned NOT NULL,
|
||||
PRIMARY KEY TzIdTranTime (Time_zone_id, Transition_time)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8
|
||||
comment='Time zone transitions';
|
||||
|
||||
|
||||
INSERT INTO time_zone_transition
|
||||
(Time_zone_id, Transition_time, Transition_type_id)
|
||||
VALUES
|
||||
(1, -1693706400, 0) ,(1, -1680483600, 1)
|
||||
,(1, -1663455600, 2) ,(1, -1650150000, 3)
|
||||
,(1, -1632006000, 2) ,(1, -1618700400, 3)
|
||||
,(1, -938905200, 2) ,(1, -857257200, 3)
|
||||
,(1, -844556400, 2) ,(1, -828226800, 3)
|
||||
,(1, -812502000, 2) ,(1, -796777200, 3)
|
||||
,(1, 228877200, 2) ,(1, 243997200, 3)
|
||||
,(1, 260326800, 2) ,(1, 276051600, 3)
|
||||
,(1, 291776400, 2) ,(1, 307501200, 3)
|
||||
,(1, 323830800, 2) ,(1, 338950800, 3)
|
||||
,(1, 354675600, 2) ,(1, 370400400, 3)
|
||||
,(1, 386125200, 2) ,(1, 401850000, 3)
|
||||
,(1, 417574800, 2) ,(1, 433299600, 3)
|
||||
,(1, 449024400, 2) ,(1, 465354000, 3)
|
||||
,(1, 481078800, 2) ,(1, 496803600, 3)
|
||||
,(1, 512528400, 2) ,(1, 528253200, 3)
|
||||
,(1, 543978000, 2) ,(1, 559702800, 3)
|
||||
,(1, 575427600, 2) ,(1, 591152400, 3)
|
||||
,(1, 606877200, 2) ,(1, 622602000, 3)
|
||||
,(1, 638326800, 2) ,(1, 654656400, 3)
|
||||
,(1, 670381200, 2) ,(1, 686106000, 3)
|
||||
,(1, 701830800, 2) ,(1, 717555600, 3)
|
||||
,(1, 733280400, 2) ,(1, 749005200, 3)
|
||||
,(1, 764730000, 2) ,(1, 780454800, 3)
|
||||
,(1, 796179600, 2) ,(1, 811904400, 3)
|
||||
,(1, 828234000, 2) ,(1, 846378000, 3)
|
||||
,(1, 859683600, 2) ,(1, 877827600, 3)
|
||||
,(1, 891133200, 2) ,(1, 909277200, 3)
|
||||
,(1, 922582800, 2) ,(1, 941331600, 3)
|
||||
,(1, 954032400, 2) ,(1, 972781200, 3)
|
||||
,(1, 985482000, 2) ,(1, 1004230800, 3)
|
||||
,(1, 1017536400, 2) ,(1, 1035680400, 3)
|
||||
,(1, 1048986000, 2) ,(1, 1067130000, 3)
|
||||
,(1, 1080435600, 2) ,(1, 1099184400, 3)
|
||||
,(1, 1111885200, 2) ,(1, 1130634000, 3)
|
||||
,(1, 1143334800, 2) ,(1, 1162083600, 3)
|
||||
,(1, 1174784400, 2) ,(1, 1193533200, 3)
|
||||
,(1, 1206838800, 2) ,(1, 1224982800, 3)
|
||||
,(1, 1238288400, 2) ,(1, 1256432400, 3)
|
||||
,(1, 1269738000, 2) ,(1, 1288486800, 3)
|
||||
,(1, 1301187600, 2) ,(1, 1319936400, 3)
|
||||
,(1, 1332637200, 2) ,(1, 1351386000, 3)
|
||||
,(1, 1364691600, 2) ,(1, 1382835600, 3)
|
||||
,(1, 1396141200, 2) ,(1, 1414285200, 3)
|
||||
,(1, 1427590800, 2) ,(1, 1445734800, 3)
|
||||
,(1, 1459040400, 2) ,(1, 1477789200, 3)
|
||||
,(1, 1490490000, 2) ,(1, 1509238800, 3)
|
||||
,(1, 1521939600, 2) ,(1, 1540688400, 3)
|
||||
,(1, 1553994000, 2) ,(1, 1572138000, 3)
|
||||
,(1, 1585443600, 2) ,(1, 1603587600, 3)
|
||||
,(1, 1616893200, 2) ,(1, 1635642000, 3)
|
||||
,(1, 1648342800, 2) ,(1, 1667091600, 3)
|
||||
,(1, 1679792400, 2) ,(1, 1698541200, 3)
|
||||
,(1, 1711846800, 2) ,(1, 1729990800, 3)
|
||||
,(1, 1743296400, 2) ,(1, 1761440400, 3)
|
||||
,(1, 1774746000, 2) ,(1, 1792890000, 3)
|
||||
,(1, 1806195600, 2) ,(1, 1824944400, 3)
|
||||
,(1, 1837645200, 2) ,(1, 1856394000, 3)
|
||||
,(1, 1869094800, 2) ,(1, 1887843600, 3)
|
||||
,(1, 1901149200, 2) ,(1, 1919293200, 3)
|
||||
,(1, 1932598800, 2) ,(1, 1950742800, 3)
|
||||
,(1, 1964048400, 2) ,(1, 1982797200, 3)
|
||||
,(1, 1995498000, 2) ,(1, 2014246800, 3)
|
||||
,(1, 2026947600, 2) ,(1, 2045696400, 3)
|
||||
,(1, 2058397200, 2) ,(1, 2077146000, 3)
|
||||
,(1, 2090451600, 2) ,(1, 2108595600, 3)
|
||||
,(1, 2121901200, 2) ,(1, 2140045200, 3)
|
||||
,(3, -1688265000, 2) ,(3, -1656819048, 1)
|
||||
,(3, -1641353448, 2) ,(3, -1627965048, 3)
|
||||
,(3, -1618716648, 1) ,(3, -1596429048, 3)
|
||||
,(3, -1593829848, 5) ,(3, -1589860800, 4)
|
||||
,(3, -1542427200, 5) ,(3, -1539493200, 6)
|
||||
,(3, -1525323600, 5) ,(3, -1522728000, 4)
|
||||
,(3, -1491188400, 7) ,(3, -1247536800, 4)
|
||||
,(3, 354920400, 5) ,(3, 370728000, 4)
|
||||
,(3, 386456400, 5) ,(3, 402264000, 4)
|
||||
,(3, 417992400, 5) ,(3, 433800000, 4)
|
||||
,(3, 449614800, 5) ,(3, 465346800, 8)
|
||||
,(3, 481071600, 9) ,(3, 496796400, 8)
|
||||
,(3, 512521200, 9) ,(3, 528246000, 8)
|
||||
,(3, 543970800, 9) ,(3, 559695600, 8)
|
||||
,(3, 575420400, 9) ,(3, 591145200, 8)
|
||||
,(3, 606870000, 9) ,(3, 622594800, 8)
|
||||
,(3, 638319600, 9) ,(3, 654649200, 8)
|
||||
,(3, 670374000, 10) ,(3, 686102400, 11)
|
||||
,(3, 695779200, 8) ,(3, 701812800, 5)
|
||||
,(3, 717534000, 4) ,(3, 733273200, 9)
|
||||
,(3, 748998000, 8) ,(3, 764722800, 9)
|
||||
,(3, 780447600, 8) ,(3, 796172400, 9)
|
||||
,(3, 811897200, 8) ,(3, 828226800, 9)
|
||||
,(3, 846370800, 8) ,(3, 859676400, 9)
|
||||
,(3, 877820400, 8) ,(3, 891126000, 9)
|
||||
,(3, 909270000, 8) ,(3, 922575600, 9)
|
||||
,(3, 941324400, 8) ,(3, 954025200, 9)
|
||||
,(3, 972774000, 8) ,(3, 985474800, 9)
|
||||
,(3, 1004223600, 8) ,(3, 1017529200, 9)
|
||||
,(3, 1035673200, 8) ,(3, 1048978800, 9)
|
||||
,(3, 1067122800, 8) ,(3, 1080428400, 9)
|
||||
,(3, 1099177200, 8) ,(3, 1111878000, 9)
|
||||
,(3, 1130626800, 8) ,(3, 1143327600, 9)
|
||||
,(3, 1162076400, 8) ,(3, 1174777200, 9)
|
||||
,(3, 1193526000, 8) ,(3, 1206831600, 9)
|
||||
,(3, 1224975600, 8) ,(3, 1238281200, 9)
|
||||
,(3, 1256425200, 8) ,(3, 1269730800, 9)
|
||||
,(3, 1288479600, 8) ,(3, 1301180400, 9)
|
||||
,(3, 1319929200, 8) ,(3, 1332630000, 9)
|
||||
,(3, 1351378800, 8) ,(3, 1364684400, 9)
|
||||
,(3, 1382828400, 8) ,(3, 1396134000, 9)
|
||||
,(3, 1414278000, 8) ,(3, 1427583600, 9)
|
||||
,(3, 1445727600, 8) ,(3, 1459033200, 9)
|
||||
,(3, 1477782000, 8) ,(3, 1490482800, 9)
|
||||
,(3, 1509231600, 8) ,(3, 1521932400, 9)
|
||||
,(3, 1540681200, 8) ,(3, 1553986800, 9)
|
||||
,(3, 1572130800, 8) ,(3, 1585436400, 9)
|
||||
,(3, 1603580400, 8) ,(3, 1616886000, 9)
|
||||
,(3, 1635634800, 8) ,(3, 1648335600, 9)
|
||||
,(3, 1667084400, 8) ,(3, 1679785200, 9)
|
||||
,(3, 1698534000, 8) ,(3, 1711839600, 9)
|
||||
,(3, 1729983600, 8) ,(3, 1743289200, 9)
|
||||
,(3, 1761433200, 8) ,(3, 1774738800, 9)
|
||||
,(3, 1792882800, 8) ,(3, 1806188400, 9)
|
||||
,(3, 1824937200, 8) ,(3, 1837638000, 9)
|
||||
,(3, 1856386800, 8) ,(3, 1869087600, 9)
|
||||
,(3, 1887836400, 8) ,(3, 1901142000, 9)
|
||||
,(3, 1919286000, 8) ,(3, 1932591600, 9)
|
||||
,(3, 1950735600, 8) ,(3, 1964041200, 9)
|
||||
,(3, 1982790000, 8) ,(3, 1995490800, 9)
|
||||
,(3, 2014239600, 8) ,(3, 2026940400, 9)
|
||||
,(3, 2045689200, 8) ,(3, 2058390000, 9)
|
||||
,(3, 2077138800, 8) ,(3, 2090444400, 9)
|
||||
,(3, 2108588400, 8) ,(3, 2121894000, 9)
|
||||
,(3, 2140038000, 8)
|
||||
,(4, -1688265000, 2) ,(4, -1656819048, 1)
|
||||
,(4, -1641353448, 2) ,(4, -1627965048, 3)
|
||||
,(4, -1618716648, 1) ,(4, -1596429048, 3)
|
||||
,(4, -1593829848, 5) ,(4, -1589860800, 4)
|
||||
,(4, -1542427200, 5) ,(4, -1539493200, 6)
|
||||
,(4, -1525323600, 5) ,(4, -1522728000, 4)
|
||||
,(4, -1491188400, 7) ,(4, -1247536800, 4)
|
||||
,(4, 354920409, 5) ,(4, 370728010, 4)
|
||||
,(4, 386456410, 5) ,(4, 402264011, 4)
|
||||
,(4, 417992411, 5) ,(4, 433800012, 4)
|
||||
,(4, 449614812, 5) ,(4, 465346812, 8)
|
||||
,(4, 481071612, 9) ,(4, 496796413, 8)
|
||||
,(4, 512521213, 9) ,(4, 528246013, 8)
|
||||
,(4, 543970813, 9) ,(4, 559695613, 8)
|
||||
,(4, 575420414, 9) ,(4, 591145214, 8)
|
||||
,(4, 606870014, 9) ,(4, 622594814, 8)
|
||||
,(4, 638319615, 9) ,(4, 654649215, 8)
|
||||
,(4, 670374016, 10) ,(4, 686102416, 11)
|
||||
,(4, 695779216, 8) ,(4, 701812816, 5)
|
||||
,(4, 717534017, 4) ,(4, 733273217, 9)
|
||||
,(4, 748998018, 8) ,(4, 764722818, 9)
|
||||
,(4, 780447619, 8) ,(4, 796172419, 9)
|
||||
,(4, 811897219, 8) ,(4, 828226820, 9)
|
||||
,(4, 846370820, 8) ,(4, 859676420, 9)
|
||||
,(4, 877820421, 8) ,(4, 891126021, 9)
|
||||
,(4, 909270021, 8) ,(4, 922575622, 9)
|
||||
,(4, 941324422, 8) ,(4, 954025222, 9)
|
||||
,(4, 972774022, 8) ,(4, 985474822, 9)
|
||||
,(4, 1004223622, 8) ,(4, 1017529222, 9)
|
||||
,(4, 1035673222, 8) ,(4, 1048978822, 9)
|
||||
,(4, 1067122822, 8) ,(4, 1080428422, 9)
|
||||
,(4, 1099177222, 8) ,(4, 1111878022, 9)
|
||||
,(4, 1130626822, 8) ,(4, 1143327622, 9)
|
||||
,(4, 1162076422, 8) ,(4, 1174777222, 9)
|
||||
,(4, 1193526022, 8) ,(4, 1206831622, 9)
|
||||
,(4, 1224975622, 8) ,(4, 1238281222, 9)
|
||||
,(4, 1256425222, 8) ,(4, 1269730822, 9)
|
||||
,(4, 1288479622, 8) ,(4, 1301180422, 9)
|
||||
,(4, 1319929222, 8) ,(4, 1332630022, 9)
|
||||
,(4, 1351378822, 8) ,(4, 1364684422, 9)
|
||||
,(4, 1382828422, 8) ,(4, 1396134022, 9)
|
||||
,(4, 1414278022, 8) ,(4, 1427583622, 9)
|
||||
,(4, 1445727622, 8) ,(4, 1459033222, 9)
|
||||
,(4, 1477782022, 8) ,(4, 1490482822, 9)
|
||||
,(4, 1509231622, 8) ,(4, 1521932422, 9)
|
||||
,(4, 1540681222, 8) ,(4, 1553986822, 9)
|
||||
,(4, 1572130822, 8) ,(4, 1585436422, 9)
|
||||
,(4, 1603580422, 8) ,(4, 1616886022, 9)
|
||||
,(4, 1635634822, 8) ,(4, 1648335622, 9)
|
||||
,(4, 1667084422, 8) ,(4, 1679785222, 9)
|
||||
,(4, 1698534022, 8) ,(4, 1711839622, 9)
|
||||
,(4, 1729983622, 8) ,(4, 1743289222, 9)
|
||||
,(4, 1761433222, 8) ,(4, 1774738822, 9)
|
||||
,(4, 1792882822, 8) ,(4, 1806188422, 9)
|
||||
,(4, 1824937222, 8) ,(4, 1837638022, 9)
|
||||
,(4, 1856386822, 8) ,(4, 1869087622, 9)
|
||||
,(4, 1887836422, 8) ,(4, 1901142022, 9)
|
||||
,(4, 1919286022, 8) ,(4, 1932591622, 9)
|
||||
,(4, 1950735622, 8) ,(4, 1964041222, 9)
|
||||
,(4, 1982790022, 8) ,(4, 1995490822, 9)
|
||||
,(4, 2014239622, 8) ,(4, 2026940422, 9)
|
||||
,(4, 2045689222, 8) ,(4, 2058390022, 9)
|
||||
,(4, 2077138822, 8) ,(4, 2090444422, 9)
|
||||
,(4, 2108588422, 8) ,(4, 2121894022, 9)
|
||||
,(4, 2140038022, 8)
|
||||
,(5, -1009875600, 1);
|
||||
|
||||
|
||||
CREATE TABLE time_zone_transition_type (
|
||||
Time_zone_id int unsigned NOT NULL,
|
||||
Transition_type_id int unsigned NOT NULL,
|
||||
Offset int signed DEFAULT 0 NOT NULL,
|
||||
Is_DST tinyint unsigned DEFAULT 0 NOT NULL,
|
||||
Abbreviation char(8) DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY TzIdTrTId (Time_zone_id, Transition_type_id)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8
|
||||
comment='Time zone transition types';
|
||||
|
||||
|
||||
INSERT INTO time_zone_transition_type (
|
||||
Time_zone_id,Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
|
||||
(1, 0, 7200, 1, 'MEST') ,(1, 1, 3600, 0, 'MET')
|
||||
,(1, 2, 7200, 1, 'MEST') ,(1, 3, 3600, 0, 'MET')
|
||||
,(2, 0, 0, 0, 'UTC')
|
||||
,(3, 0, 9000, 0, 'MMT') ,(3, 1, 12648, 1, 'MST')
|
||||
,(3, 2, 9048, 0, 'MMT') ,(3, 3, 16248, 1, 'MDST')
|
||||
,(3, 4, 10800, 0, 'MSK') ,(3, 5, 14400, 1, 'MSD')
|
||||
,(3, 6, 18000, 1, 'MSD') ,(3, 7, 7200, 0, 'EET')
|
||||
,(3, 8, 10800, 0, 'MSK') ,(3, 9, 14400, 1, 'MSD')
|
||||
,(3, 10, 10800, 1, 'EEST') ,(3, 11, 7200, 0, 'EET')
|
||||
,(4, 0, 9000, 0, 'MMT') ,(4, 1, 12648, 1, 'MST')
|
||||
,(4, 2, 9048, 0, 'MMT') ,(4, 3, 16248, 1, 'MDST')
|
||||
,(4, 4, 10800, 0, 'MSK') ,(4, 5, 14400, 1, 'MSD')
|
||||
,(4, 6, 18000, 1, 'MSD') ,(4, 7, 7200, 0, 'EET')
|
||||
,(4, 8, 10800, 0, 'MSK') ,(4, 9, 14400, 1, 'MSD')
|
||||
,(4, 10, 10800, 1, 'EEST') ,(4, 11, 7200, 0, 'EET')
|
||||
,(5, 0, 32400, 0, 'CJT') ,(5, 1, 32400, 0, 'JST');
|
||||
|
||||
|
||||
CREATE TABLE time_zone_leap_second (
|
||||
Transition_time bigint signed NOT NULL,
|
||||
Correction int signed NOT NULL,
|
||||
PRIMARY KEY TranTime (Transition_time)
|
||||
) engine=MyISAM
|
||||
CHARACTER SET utf8
|
||||
comment='Leap seconds information for time zones';
|
||||
|
||||
|
||||
INSERT INTO time_zone_leap_second (
|
||||
Transition_time, Correction) VALUES
|
||||
(78796800, 1) ,(94694401, 2) ,(126230402, 3)
|
||||
,(157766403, 4) ,(189302404, 5) ,(220924805, 6)
|
||||
,(252460806, 7) ,(283996807, 8) ,(315532808, 9)
|
||||
,(362793609, 10) ,(394329610, 11) ,(425865611, 12)
|
||||
,(489024012, 13) ,(567993613, 14) ,(631152014, 15)
|
||||
,(662688015, 16) ,(709948816, 17) ,(741484817, 18)
|
||||
,(773020818, 19) ,(820454419, 20) ,(867715220, 21)
|
||||
,(915148821, 22);
|
270
mysql-test/lib/mtr_cases.pl
Normal file
270
mysql-test/lib/mtr_cases.pl
Normal file
@ -0,0 +1,270 @@
|
||||
# -*- cperl -*-
|
||||
|
||||
# This is a library file used by the Perl version of mysql-test-run,
|
||||
# and is part of the translation of the Bourne shell script with the
|
||||
# same name.
|
||||
|
||||
use strict;
|
||||
|
||||
sub collect_test_cases ($);
|
||||
sub collect_one_test_case ($$$$$);
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Collect information about test cases we are to run
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub collect_test_cases ($) {
|
||||
my $suite= shift; # Test suite name
|
||||
|
||||
my $testdir;
|
||||
my $resdir;
|
||||
|
||||
if ( $suite eq "main" )
|
||||
{
|
||||
$testdir= "$::glob_mysql_test_dir/t";
|
||||
$resdir= "$::glob_mysql_test_dir/r";
|
||||
}
|
||||
else
|
||||
{
|
||||
$testdir= "$::glob_mysql_test_dir/suite/$suite/t";
|
||||
$resdir= "$::glob_mysql_test_dir/suite/$suite/r";
|
||||
}
|
||||
|
||||
my $cases = []; # Array of hash, will be array of C struct
|
||||
|
||||
opendir(TESTDIR, $testdir) or mtr_error("Can't open dir \"$testdir\": $!");
|
||||
|
||||
if ( @::opt_cases )
|
||||
{
|
||||
foreach my $tname ( @::opt_cases ) { # Run in specified order, no sort
|
||||
my $elem= "$tname.test";
|
||||
if ( ! -f "$testdir/$elem")
|
||||
{
|
||||
mtr_error("Test case $tname ($testdir/$elem) is not found");
|
||||
}
|
||||
collect_one_test_case($testdir,$resdir,$tname,$elem,$cases);
|
||||
}
|
||||
closedir TESTDIR;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach my $elem ( sort readdir(TESTDIR) ) {
|
||||
my $tname= mtr_match_extension($elem,"test");
|
||||
next if ! defined $tname;
|
||||
next if $::opt_do_test and ! defined mtr_match_prefix($elem,$::opt_do_test);
|
||||
|
||||
collect_one_test_case($testdir,$resdir,$tname,$elem,$cases);
|
||||
}
|
||||
closedir TESTDIR;
|
||||
}
|
||||
|
||||
# To speed things up, we sort first in if the test require a restart
|
||||
# or not, second in alphanumeric order.
|
||||
|
||||
# @$cases = sort {
|
||||
# if ( $a->{'master_restart'} and $b->{'master_restart'} or
|
||||
# ! $a->{'master_restart'} and ! $b->{'master_restart'} )
|
||||
# {
|
||||
# return $a->{'name'} cmp $b->{'name'};
|
||||
# }
|
||||
# if ( $a->{'master_restart'} )
|
||||
# {
|
||||
# return 1; # Is greater
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# return -1; # Is less
|
||||
# }
|
||||
# } @$cases;
|
||||
|
||||
return $cases;
|
||||
}
|
||||
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Collect information about a single test case
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
sub collect_one_test_case($$$$$) {
|
||||
my $testdir= shift;
|
||||
my $resdir= shift;
|
||||
my $tname= shift;
|
||||
my $elem= shift;
|
||||
my $cases= shift;
|
||||
|
||||
my $path= "$testdir/$elem";
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Skip some tests silently
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
if ( $::opt_start_from and $tname lt $::opt_start_from )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Skip some tests but include in list, just mark them to skip
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
my $tinfo= {};
|
||||
$tinfo->{'name'}= $tname;
|
||||
$tinfo->{'result_file'}= "$resdir/$tname.result";
|
||||
push(@$cases, $tinfo);
|
||||
|
||||
if ( $::opt_skip_test and defined mtr_match_prefix($tname,$::opt_skip_test) )
|
||||
{
|
||||
$tinfo->{'skip'}= 1;
|
||||
return;
|
||||
}
|
||||
|
||||
# FIXME temporary solution, we have a hard coded list of test cases to
|
||||
# skip if we are using the embedded server
|
||||
|
||||
if ( $::glob_use_embedded_server and
|
||||
mtr_match_any_exact($tname,\@::skip_if_embedded_server) )
|
||||
{
|
||||
$tinfo->{'skip'}= 1;
|
||||
return;
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Collect information about test case
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
$tinfo->{'path'}= $path;
|
||||
$tinfo->{'timezone'}= "GMT-3"; # for UNIX_TIMESTAMP tests to work
|
||||
|
||||
if ( defined mtr_match_prefix($tname,"rpl") )
|
||||
{
|
||||
if ( $::opt_skip_rpl )
|
||||
{
|
||||
$tinfo->{'skip'}= 1;
|
||||
return;
|
||||
}
|
||||
|
||||
$tinfo->{'slave_num'}= 1; # Default, use one slave
|
||||
|
||||
# FIXME currently we always restart slaves
|
||||
$tinfo->{'slave_restart'}= 1;
|
||||
|
||||
if ( $tname eq 'rpl_failsafe' or $tname eq 'rpl_chain_temp_table' )
|
||||
{
|
||||
# $tinfo->{'slave_num'}= 3; # Not 3 ? Check old code, strange
|
||||
}
|
||||
}
|
||||
|
||||
# FIXME what about embedded_server + ndbcluster, skip ?!
|
||||
|
||||
my $master_opt_file= "$testdir/$tname-master.opt";
|
||||
my $slave_opt_file= "$testdir/$tname-slave.opt";
|
||||
my $slave_mi_file= "$testdir/$tname.slave-mi";
|
||||
my $master_sh= "$testdir/$tname-master.sh";
|
||||
my $slave_sh= "$testdir/$tname-slave.sh";
|
||||
my $disabled= "$testdir/$tname.disabled";
|
||||
|
||||
$tinfo->{'master_opt'}= [];
|
||||
$tinfo->{'slave_opt'}= [];
|
||||
$tinfo->{'slave_mi'}= [];
|
||||
|
||||
if ( -f $master_opt_file )
|
||||
{
|
||||
$tinfo->{'master_restart'}= 1; # We think so for now
|
||||
# This is a dirty hack from old mysql-test-run, we use the opt file
|
||||
# to flag other things as well, it is not a opt list at all
|
||||
my $extra_master_opt= mtr_get_opts_from_file($master_opt_file);
|
||||
|
||||
foreach my $opt (@$extra_master_opt)
|
||||
{
|
||||
my $value;
|
||||
|
||||
$value= mtr_match_prefix($opt, "--timezone=");
|
||||
|
||||
if ( defined $value )
|
||||
{
|
||||
$tinfo->{'timezone'}= $value;
|
||||
$extra_master_opt= [];
|
||||
$tinfo->{'master_restart'}= 0;
|
||||
last;
|
||||
}
|
||||
|
||||
$value= mtr_match_prefix($opt, "--result-file=");
|
||||
|
||||
if ( defined $value )
|
||||
{
|
||||
$tinfo->{'result_file'}= "r/$value.result";
|
||||
if ( $::opt_result_ext and $::opt_record or
|
||||
-f "$tinfo->{'result_file'}$::opt_result_ext")
|
||||
{
|
||||
$tinfo->{'result_file'}.= $::opt_result_ext;
|
||||
}
|
||||
$extra_master_opt= [];
|
||||
$tinfo->{'master_restart'}= 0;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$tinfo->{'master_opt'}= $extra_master_opt;
|
||||
}
|
||||
|
||||
if ( -f $slave_opt_file )
|
||||
{
|
||||
$tinfo->{'slave_opt'}= mtr_get_opts_from_file($slave_opt_file);
|
||||
$tinfo->{'slave_restart'}= 1;
|
||||
}
|
||||
|
||||
if ( -f $slave_mi_file )
|
||||
{
|
||||
$tinfo->{'slave_mi'}= mtr_get_opts_from_file($slave_mi_file);
|
||||
$tinfo->{'slave_restart'}= 1;
|
||||
}
|
||||
|
||||
if ( -f $master_sh )
|
||||
{
|
||||
if ( $::glob_win32_perl )
|
||||
{
|
||||
$tinfo->{'skip'}= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$tinfo->{'master_sh'}= $master_sh;
|
||||
$tinfo->{'master_restart'}= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( -f $slave_sh )
|
||||
{
|
||||
if ( $::glob_win32_perl )
|
||||
{
|
||||
$tinfo->{'skip'}= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$tinfo->{'slave_sh'}= $slave_sh;
|
||||
$tinfo->{'slave_restart'}= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( -f $disabled )
|
||||
{
|
||||
$tinfo->{'skip'}= 1;
|
||||
$tinfo->{'disable'}= 1; # Sub type of 'skip'
|
||||
$tinfo->{'comment'}= mtr_fromfile($disabled);
|
||||
}
|
||||
|
||||
# We can't restart a running server that may be in use
|
||||
|
||||
if ( $::glob_use_running_server and
|
||||
( $tinfo->{'master_restart'} or $tinfo->{'slave_restart'} ) )
|
||||
{
|
||||
$tinfo->{'skip'}= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
44
mysql-test/lib/mtr_gcov.pl
Normal file
44
mysql-test/lib/mtr_gcov.pl
Normal file
@ -0,0 +1,44 @@
|
||||
# -*- cperl -*-
|
||||
|
||||
# This is a library file used by the Perl version of mysql-test-run,
|
||||
# and is part of the translation of the Bourne shell script with the
|
||||
# same name.
|
||||
|
||||
use strict;
|
||||
|
||||
# These are not to be prefixed with "mtr_"
|
||||
|
||||
sub gcov_prepare ();
|
||||
sub gcov_collect ();
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub gcov_prepare () {
|
||||
|
||||
`find $::glob_basedir -name \*.gcov \
|
||||
-or -name \*.da | xargs rm`;
|
||||
}
|
||||
|
||||
sub gcov_collect () {
|
||||
|
||||
print "Collecting source coverage info...\n";
|
||||
-f $::opt_gcov_msg and unlink($::opt_gcov_msg);
|
||||
-f $::opt_gcov_err and unlink($::opt_gcov_err);
|
||||
foreach my $d ( @::mysqld_src_dirs )
|
||||
{
|
||||
chdir("$::glob_basedir/$d");
|
||||
foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) )
|
||||
{
|
||||
`$::opt_gcov $f 2>>$::opt_gcov_err >>$::opt_gcov_msg`;
|
||||
}
|
||||
chdir($::glob_mysql_test_dir);
|
||||
}
|
||||
print "gcov info in $::opt_gcov_msg, errors in $::opt_gcov_err\n";
|
||||
}
|
||||
|
||||
|
||||
1;
|
50
mysql-test/lib/mtr_gprof.pl
Normal file
50
mysql-test/lib/mtr_gprof.pl
Normal file
@ -0,0 +1,50 @@
|
||||
# -*- cperl -*-
|
||||
|
||||
# This is a library file used by the Perl version of mysql-test-run,
|
||||
# and is part of the translation of the Bourne shell script with the
|
||||
# same name.
|
||||
|
||||
use strict;
|
||||
|
||||
# These are not to be prefixed with "mtr_"
|
||||
|
||||
sub gprof_prepare ();
|
||||
sub gprof_collect ();
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub gprof_prepare () {
|
||||
|
||||
rmtree($::opt_gprof_dir);
|
||||
mkdir($::opt_gprof_dir);
|
||||
}
|
||||
|
||||
# FIXME what about master1 and slave1?!
|
||||
sub gprof_collect () {
|
||||
|
||||
if ( -f "$::master->[0]->{'path_myddir'}/gmon.out" )
|
||||
{
|
||||
# FIXME check result code?!
|
||||
mtr_run("gprof",
|
||||
[$::exe_master_mysqld,
|
||||
"$::master->[0]->{'path_myddir'}/gmon.out"],
|
||||
$::opt_gprof_master, "", "", "");
|
||||
print "Master execution profile has been saved in $::opt_gprof_master\n";
|
||||
}
|
||||
if ( -f "$::slave->[0]->{'path_myddir'}/gmon.out" )
|
||||
{
|
||||
# FIXME check result code?!
|
||||
mtr_run("gprof",
|
||||
[$::exe_slave_mysqld,
|
||||
"$::slave->[0]->{'path_myddir'}/gmon.out"],
|
||||
$::opt_gprof_slave, "", "", "");
|
||||
print "Slave execution profile has been saved in $::opt_gprof_slave\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
133
mysql-test/lib/mtr_io.pl
Normal file
133
mysql-test/lib/mtr_io.pl
Normal file
@ -0,0 +1,133 @@
|
||||
# -*- cperl -*-
|
||||
|
||||
# This is a library file used by the Perl version of mysql-test-run,
|
||||
# and is part of the translation of the Bourne shell script with the
|
||||
# same name.
|
||||
|
||||
use strict;
|
||||
|
||||
sub mtr_get_pid_from_file ($);
|
||||
sub mtr_get_opts_from_file ($);
|
||||
sub mtr_fromfile ($);
|
||||
sub mtr_tofile ($@);
|
||||
sub mtr_tonewfile($@);
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub mtr_get_pid_from_file ($) {
|
||||
my $file= shift;
|
||||
|
||||
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
|
||||
my $pid= <FILE>;
|
||||
chomp($pid);
|
||||
close FILE;
|
||||
return $pid;
|
||||
}
|
||||
|
||||
sub mtr_get_opts_from_file ($) {
|
||||
my $file= shift;
|
||||
|
||||
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
|
||||
my @args;
|
||||
while ( <FILE> )
|
||||
{
|
||||
chomp;
|
||||
|
||||
# --set-variable=init_connect=set @a='a\\0c'
|
||||
s/^\s+//; # Remove leading space
|
||||
s/\s+$//; # Remove ending space
|
||||
|
||||
# This is strange, but we need to fill whitespace inside
|
||||
# quotes with something, to remove later. We do this to
|
||||
# be able to split on space. Else, we have trouble with
|
||||
# options like
|
||||
#
|
||||
# --someopt="--insideopt1 --insideopt2"
|
||||
#
|
||||
# But still with this, we are not 100% sure it is right,
|
||||
# we need a shell to do it right.
|
||||
|
||||
# print STDERR "\n";
|
||||
# print STDERR "AAA: $_\n";
|
||||
|
||||
s/\'([^\'\"]*)\'/unspace($1,"\x0a")/ge;
|
||||
s/\"([^\'\"]*)\"/unspace($1,"\x0b")/ge;
|
||||
s/\'([^\'\"]*)\'/unspace($1,"\x0a")/ge;
|
||||
s/\"([^\'\"]*)\"/unspace($1,"\x0b")/ge;
|
||||
|
||||
# print STDERR "BBB: $_\n";
|
||||
|
||||
# foreach my $arg (/(--?\w.*?)(?=\s+--?\w|$)/)
|
||||
|
||||
# FIXME ENV vars should be expanded!!!!
|
||||
|
||||
foreach my $arg (split(/[ \t]+/))
|
||||
{
|
||||
$arg =~ tr/\x11\x0a\x0b/ \'\"/; # Put back real chars
|
||||
# The outermost quotes has to go
|
||||
$arg =~ s/^([^\'\"]*)\'(.*)\'([^\'\"]*)$/$1$2$3/
|
||||
or $arg =~ s/^([^\'\"]*)\"(.*)\"([^\'\"]*)$/$1$2$3/;
|
||||
$arg =~ s/\\\\/\\/g;
|
||||
|
||||
$arg =~ s/\$\{(\w+)\}/envsubst($1)/ge;
|
||||
$arg =~ s/\$(\w+)/envsubst($1)/ge;
|
||||
|
||||
# print STDERR "ARG: $arg\n";
|
||||
push(@args, $arg);
|
||||
}
|
||||
}
|
||||
close FILE;
|
||||
return \@args;
|
||||
}
|
||||
|
||||
sub envsubst {
|
||||
my $string= shift;
|
||||
|
||||
if ( ! defined $ENV{$string} )
|
||||
{
|
||||
mtr_error("opt file referense \$$string that is unknown");
|
||||
}
|
||||
|
||||
return $ENV{$string};
|
||||
}
|
||||
|
||||
sub unspace {
|
||||
my $string= shift;
|
||||
my $quote= shift;
|
||||
$string =~ s/[ \t]/\x11/g;
|
||||
return "$quote$string$quote";
|
||||
}
|
||||
|
||||
sub mtr_fromfile ($) {
|
||||
my $file= shift;
|
||||
|
||||
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
|
||||
my $text= join('', <FILE>);
|
||||
close FILE;
|
||||
$text =~ s/^\s+//; # Remove starting space, incl newlines
|
||||
$text =~ s/\s+$//; # Remove ending space, incl newlines
|
||||
return $text;
|
||||
}
|
||||
|
||||
sub mtr_tofile ($@) {
|
||||
my $file= shift;
|
||||
|
||||
open(FILE,">>",$file) or mtr_error("can't open file \"$file\": $!");
|
||||
print FILE join("", @_);
|
||||
close FILE;
|
||||
}
|
||||
|
||||
sub mtr_tonewfile ($@) {
|
||||
my $file= shift;
|
||||
|
||||
open(FILE,">",$file) or mtr_error("can't open file \"$file\": $!");
|
||||
print FILE join("", @_);
|
||||
close FILE;
|
||||
}
|
||||
|
||||
|
||||
1;
|
67
mysql-test/lib/mtr_match.pl
Normal file
67
mysql-test/lib/mtr_match.pl
Normal file
@ -0,0 +1,67 @@
|
||||
# -*- cperl -*-
|
||||
|
||||
# This is a library file used by the Perl version of mysql-test-run,
|
||||
# and is part of the translation of the Bourne shell script with the
|
||||
# same name.
|
||||
|
||||
use strict;
|
||||
|
||||
sub mtr_match_prefix ($$);
|
||||
sub mtr_match_extension ($$);
|
||||
sub mtr_match_any_exact ($$);
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Match a prefix and return what is after the prefix
|
||||
|
||||
sub mtr_match_prefix ($$) {
|
||||
my $string= shift;
|
||||
my $prefix= shift;
|
||||
|
||||
if ( $string =~ /^\Q$prefix\E(.*)$/ ) # strncmp
|
||||
{
|
||||
return $1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return undef; # NULL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Match extension and return the name without extension
|
||||
|
||||
sub mtr_match_extension ($$) {
|
||||
my $file= shift;
|
||||
my $ext= shift;
|
||||
|
||||
if ( $file =~ /^(.*)\.\Q$ext\E$/ ) # strchr+strcmp or something
|
||||
{
|
||||
return $1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return undef; # NULL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub mtr_match_any_exact ($$) {
|
||||
my $string= shift;
|
||||
my $mlist= shift;
|
||||
|
||||
foreach my $m (@$mlist)
|
||||
{
|
||||
if ( $string eq $m )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
50
mysql-test/lib/mtr_misc.pl
Normal file
50
mysql-test/lib/mtr_misc.pl
Normal file
@ -0,0 +1,50 @@
|
||||
# -*- cperl -*-
|
||||
|
||||
# This is a library file used by the Perl version of mysql-test-run,
|
||||
# and is part of the translation of the Bourne shell script with the
|
||||
# same name.
|
||||
|
||||
use strict;
|
||||
|
||||
sub mtr_full_hostname ();
|
||||
sub mtr_init_args ($);
|
||||
sub mtr_add_arg ($$);
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Misc
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# We want the fully qualified host name and hostname() may have returned
|
||||
# only the short name. So we use the resolver to find out.
|
||||
|
||||
sub mtr_full_hostname () {
|
||||
|
||||
my $hostname= hostname();
|
||||
if ( $hostname !~ /\./ )
|
||||
{
|
||||
my $address= gethostbyname($hostname)
|
||||
or die "Couldn't resolve $hostname : $!";
|
||||
my $fullname= gethostbyaddr($address, AF_INET);
|
||||
$hostname= $fullname if $fullname;
|
||||
}
|
||||
return $hostname;
|
||||
}
|
||||
|
||||
# FIXME move to own lib
|
||||
|
||||
sub mtr_init_args ($) {
|
||||
my $args = shift;
|
||||
$$args = []; # Empty list
|
||||
}
|
||||
|
||||
sub mtr_add_arg ($$) {
|
||||
my $args= shift;
|
||||
my $format= shift;
|
||||
my @fargs = @_;
|
||||
|
||||
push(@$args, sprintf($format, @fargs));
|
||||
}
|
||||
|
||||
1;
|
787
mysql-test/lib/mtr_process.pl
Normal file
787
mysql-test/lib/mtr_process.pl
Normal file
@ -0,0 +1,787 @@
|
||||
# -*- cperl -*-
|
||||
|
||||
# This is a library file used by the Perl version of mysql-test-run,
|
||||
# and is part of the translation of the Bourne shell script with the
|
||||
# same name.
|
||||
|
||||
#use Carp qw(cluck);
|
||||
use Socket;
|
||||
use Errno;
|
||||
use strict;
|
||||
|
||||
#use POSIX ":sys_wait_h";
|
||||
use POSIX 'WNOHANG';
|
||||
|
||||
sub mtr_run ($$$$$$);
|
||||
sub mtr_spawn ($$$$$$);
|
||||
sub mtr_stop_mysqld_servers ($);
|
||||
sub mtr_kill_leftovers ();
|
||||
sub mtr_record_dead_children ();
|
||||
sub sleep_until_file_created ($$$);
|
||||
|
||||
# static in C
|
||||
sub spawn_impl ($$$$$$$);
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Execute an external command
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# This function try to mimic the C version used in "netware/mysql_test_run.c"
|
||||
# FIXME learn it to handle append mode as well, a "new" flag or a "append"
|
||||
|
||||
sub mtr_run ($$$$$$) {
|
||||
my $path= shift;
|
||||
my $arg_list_t= shift;
|
||||
my $input= shift;
|
||||
my $output= shift;
|
||||
my $error= shift;
|
||||
my $pid_file= shift;
|
||||
|
||||
return spawn_impl($path,$arg_list_t,'run',$input,$output,$error,$pid_file);
|
||||
}
|
||||
|
||||
sub mtr_run_test ($$$$$$) {
|
||||
my $path= shift;
|
||||
my $arg_list_t= shift;
|
||||
my $input= shift;
|
||||
my $output= shift;
|
||||
my $error= shift;
|
||||
my $pid_file= shift;
|
||||
|
||||
return spawn_impl($path,$arg_list_t,'test',$input,$output,$error,$pid_file);
|
||||
}
|
||||
|
||||
sub mtr_spawn ($$$$$$) {
|
||||
my $path= shift;
|
||||
my $arg_list_t= shift;
|
||||
my $input= shift;
|
||||
my $output= shift;
|
||||
my $error= shift;
|
||||
my $pid_file= shift;
|
||||
|
||||
return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error,$pid_file);
|
||||
}
|
||||
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# If $join is set, we return the error code, else we return the PID
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub spawn_impl ($$$$$$$) {
|
||||
my $path= shift;
|
||||
my $arg_list_t= shift;
|
||||
my $mode= shift;
|
||||
my $input= shift;
|
||||
my $output= shift;
|
||||
my $error= shift;
|
||||
my $pid_file= shift; # FIXME
|
||||
|
||||
if ( $::opt_script_debug )
|
||||
{
|
||||
print STDERR "\n";
|
||||
print STDERR "#### ", "-" x 78, "\n";
|
||||
print STDERR "#### ", "STDIN $input\n" if $input;
|
||||
print STDERR "#### ", "STDOUT $output\n" if $output;
|
||||
print STDERR "#### ", "STDERR $error\n" if $error;
|
||||
print STDERR "#### ", "$mode : $path ", join(" ",@$arg_list_t), "\n";
|
||||
print STDERR "#### ", "-" x 78, "\n";
|
||||
}
|
||||
|
||||
FORK:
|
||||
{
|
||||
my $pid= fork();
|
||||
|
||||
if ( ! defined $pid )
|
||||
{
|
||||
if ( $! == $!{EAGAIN} ) # See "perldoc Errno"
|
||||
{
|
||||
mtr_debug("Got EAGAIN from fork(), sleep 1 second and redo");
|
||||
sleep(1);
|
||||
redo FORK;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtr_error("$path ($pid) can't be forked");
|
||||
}
|
||||
}
|
||||
|
||||
if ( $pid )
|
||||
{
|
||||
spawn_parent_impl($pid,$mode,$path);
|
||||
}
|
||||
else
|
||||
{
|
||||
# Child, redirect output and exec
|
||||
# FIXME I tried POSIX::setsid() here to detach and, I hoped,
|
||||
# avoid zombies. But everything went wild, somehow the parent
|
||||
# became a deamon as well, and was hard to kill ;-)
|
||||
# Need to catch SIGCHLD and do waitpid or something instead......
|
||||
|
||||
$SIG{INT}= 'DEFAULT'; # Parent do some stuff, we don't
|
||||
|
||||
if ( $::glob_cygwin_shell and $mode eq 'test' )
|
||||
{
|
||||
# Programs started from mysqltest under Cygwin, are to
|
||||
# execute them within Cygwin. Else simple things in test
|
||||
# files like
|
||||
# --system "echo 1 > file"
|
||||
# will fail.
|
||||
# FIXME not working :-(
|
||||
# $ENV{'COMSPEC'}= "$::glob_cygwin_shell -c";
|
||||
}
|
||||
|
||||
if ( $output )
|
||||
{
|
||||
if ( ! open(STDOUT,">",$output) )
|
||||
{
|
||||
mtr_error("can't redirect STDOUT to \"$output\": $!");
|
||||
}
|
||||
}
|
||||
|
||||
if ( $error )
|
||||
{
|
||||
if ( $output eq $error )
|
||||
{
|
||||
if ( ! open(STDERR,">&STDOUT") )
|
||||
{
|
||||
mtr_error("can't dup STDOUT: $!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! open(STDERR,">",$error) )
|
||||
{
|
||||
mtr_error("can't redirect STDERR to \"$output\": $!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $input )
|
||||
{
|
||||
if ( ! open(STDIN,"<",$input) )
|
||||
{
|
||||
mtr_error("can't redirect STDIN to \"$input\": $!");
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! exec($path,@$arg_list_t) )
|
||||
{
|
||||
mtr_error("failed to execute \"$path\": $!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub spawn_parent_impl {
|
||||
my $pid= shift;
|
||||
my $mode= shift;
|
||||
my $path= shift;
|
||||
|
||||
if ( $mode eq 'run' or $mode eq 'test' )
|
||||
{
|
||||
my $exit_value= -1;
|
||||
my $signal_num= 0;
|
||||
my $dumped_core= 0;
|
||||
|
||||
if ( $mode eq 'run' )
|
||||
{
|
||||
# Simple run of command, we wait for it to return
|
||||
my $ret_pid= waitpid($pid,0);
|
||||
|
||||
if ( $ret_pid <= 0 )
|
||||
{
|
||||
mtr_error("$path ($pid) got lost somehow");
|
||||
}
|
||||
|
||||
$exit_value= $? >> 8;
|
||||
$signal_num= $? & 127;
|
||||
$dumped_core= $? & 128;
|
||||
|
||||
return $exit_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
# We run mysqltest and wait for it to return. But we try to
|
||||
# catch dying mysqld processes as well.
|
||||
#
|
||||
# We do blocking waitpid() until we get the return from the
|
||||
# "mysqltest" call. But if a mysqld process dies that we
|
||||
# started, we take this as an error, and kill mysqltest.
|
||||
#
|
||||
# FIXME is this as it should be? Can't mysqld terminate
|
||||
# normally from running a test case?
|
||||
|
||||
my $ret_pid; # What waitpid() returns
|
||||
|
||||
while ( ($ret_pid= waitpid(-1,0)) != -1 )
|
||||
{
|
||||
# Someone terminated, don't know who. Collect
|
||||
# status info first before $? is lost,
|
||||
# but not $exit_value, this is flagged from
|
||||
#
|
||||
|
||||
if ( $ret_pid == $pid )
|
||||
{
|
||||
# We got termination of mysqltest, we are done
|
||||
$exit_value= $? >> 8;
|
||||
$signal_num= $? & 127;
|
||||
$dumped_core= $? & 128;
|
||||
last;
|
||||
}
|
||||
|
||||
# If one of the mysqld processes died, we want to
|
||||
# mark this, and kill the mysqltest process.
|
||||
|
||||
foreach my $idx (0..1)
|
||||
{
|
||||
if ( $::master->[$idx]->{'pid'} eq $ret_pid )
|
||||
{
|
||||
mtr_debug("child $ret_pid was master[$idx], " .
|
||||
"exit during mysqltest run");
|
||||
$::master->[$idx]->{'pid'}= 0;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $idx (0..2)
|
||||
{
|
||||
if ( $::slave->[$idx]->{'pid'} eq $ret_pid )
|
||||
{
|
||||
mtr_debug("child $ret_pid was slave[$idx], " .
|
||||
"exit during mysqltest run");
|
||||
$::slave->[$idx]->{'pid'}= 0;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
mtr_debug("waitpid() catched exit of unknown child $ret_pid, " .
|
||||
"exit during mysqltest run");
|
||||
}
|
||||
|
||||
if ( $ret_pid != $pid )
|
||||
{
|
||||
# We terminated the waiting because a "mysqld" process died.
|
||||
# Kill the mysqltest process.
|
||||
|
||||
kill(9,$pid);
|
||||
|
||||
$ret_pid= waitpid($pid,0);
|
||||
|
||||
if ( $ret_pid == -1 )
|
||||
{
|
||||
mtr_error("$path ($pid) got lost somehow");
|
||||
}
|
||||
}
|
||||
|
||||
return $exit_value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# We spawned a process we don't wait for
|
||||
return $pid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Kill processes left from previous runs
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# We just "ping" on the ports, and if we can't do a socket connect
|
||||
# we assume the server is dead. So we don't *really* know a server
|
||||
# is dead, we just hope that it after letting the listen port go,
|
||||
# it is dead enough for us to start a new server.
|
||||
|
||||
sub mtr_kill_leftovers () {
|
||||
|
||||
# First, kill all masters and slaves that would conflict with
|
||||
# this run. Make sure to remove the PID file, if any.
|
||||
|
||||
my @args;
|
||||
|
||||
for ( my $idx; $idx < 2; $idx++ )
|
||||
{
|
||||
push(@args,{
|
||||
pid => 0, # We don't know the PID
|
||||
pidfile => $::master->[$idx]->{'path_mypid'},
|
||||
sockfile => $::master->[$idx]->{'path_mysock'},
|
||||
port => $::master->[$idx]->{'path_myport'},
|
||||
});
|
||||
}
|
||||
|
||||
for ( my $idx; $idx < 3; $idx++ )
|
||||
{
|
||||
push(@args,{
|
||||
pid => 0, # We don't know the PID
|
||||
pidfile => $::slave->[$idx]->{'path_mypid'},
|
||||
sockfile => $::slave->[$idx]->{'path_mysock'},
|
||||
port => $::slave->[$idx]->{'path_myport'},
|
||||
});
|
||||
}
|
||||
|
||||
mtr_mysqladmin_shutdown(\@args);
|
||||
|
||||
# We now have tried to terminate nice. We have waited for the listen
|
||||
# port to be free, but can't really tell if the mysqld process died
|
||||
# or not. We now try to find the process PID from the PID file, and
|
||||
# send a kill to that process. Note that Perl let kill(0,@pids) be
|
||||
# a way to just return the numer of processes the kernel can send
|
||||
# signals to. So this can be used (except on Cygwin) to determine
|
||||
# if there are processes left running that we cound out might exists.
|
||||
#
|
||||
# But still after all this work, all we know is that we have
|
||||
# the ports free.
|
||||
|
||||
# We scan the "var/run/" directory for other process id's to kill
|
||||
|
||||
# FIXME $path_run_dir or something
|
||||
my $rundir= "$::glob_mysql_test_dir/var/run";
|
||||
|
||||
if ( -d $rundir )
|
||||
{
|
||||
opendir(RUNDIR, $rundir)
|
||||
or mtr_error("can't open directory \"$rundir\": $!");
|
||||
|
||||
my @pids;
|
||||
|
||||
while ( my $elem= readdir(RUNDIR) )
|
||||
{
|
||||
my $pidfile= "$rundir/$elem";
|
||||
|
||||
if ( -f $pidfile )
|
||||
{
|
||||
my $pid= mtr_get_pid_from_file($pidfile);
|
||||
|
||||
# Race, could have been removed between I tested with -f
|
||||
# and the unlink() below, so I better check again with -f
|
||||
|
||||
if ( ! unlink($pidfile) and -f $pidfile )
|
||||
{
|
||||
mtr_error("can't remove $pidfile");
|
||||
}
|
||||
|
||||
if ( $::glob_cygwin_perl or kill(0, $pid) )
|
||||
{
|
||||
push(@pids, $pid); # We know (cygwin guess) it exists
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(RUNDIR);
|
||||
|
||||
if ( @pids )
|
||||
{
|
||||
if ( $::glob_cygwin_perl )
|
||||
{
|
||||
# We have no (easy) way of knowing the Cygwin controlling
|
||||
# process, in the PID file we only have the Windows process id.
|
||||
system("kill -f " . join(" ",@pids)); # Hope for the best....
|
||||
mtr_debug("Sleep 5 seconds waiting for processes to die");
|
||||
sleep(5);
|
||||
}
|
||||
else
|
||||
{
|
||||
my $retries= 10; # 10 seconds
|
||||
do
|
||||
{
|
||||
kill(9, @pids);
|
||||
mtr_debug("Sleep 1 second waiting for processes to die");
|
||||
sleep(1) # Wait one second
|
||||
} while ( $retries-- and kill(0, @pids) );
|
||||
|
||||
if ( kill(0, @pids) ) # Check if some left
|
||||
{
|
||||
# FIXME maybe just mtr_warning() ?
|
||||
mtr_error("can't kill process(es) " . join(" ", @pids));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# We may have failed everything, bug we now check again if we have
|
||||
# the listen ports free to use, and if they are free, just go for it.
|
||||
|
||||
foreach my $srv ( @args )
|
||||
{
|
||||
if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) )
|
||||
{
|
||||
mtr_error("can't kill old mysqld holding port $srv->{'port'}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Shut down mysqld servers we have started from this run of this script
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# To speed things we kill servers in parallel. The argument is a list
|
||||
# of 'ports', 'pids', 'pidfiles' and 'socketfiles'.
|
||||
|
||||
# FIXME On Cygwin, and maybe some other platforms, $srv->{'pid'} and
|
||||
# $srv->{'pidfile'} will not be the same PID. We need to try to kill
|
||||
# both I think.
|
||||
|
||||
sub mtr_stop_mysqld_servers ($) {
|
||||
my $spec= shift;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# First try nice normal shutdown using 'mysqladmin'
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
mtr_mysqladmin_shutdown($spec);
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# We loop with waitpid() nonblocking to see how many of the ones we
|
||||
# are to kill, actually got killed by mtr_mysqladmin_shutdown().
|
||||
# Note that we don't rely on this, the mysqld server might have stop
|
||||
# listening to the port, but still be alive. But it is a start.
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
foreach my $srv ( @$spec )
|
||||
{
|
||||
if ( $srv->{'pid'} and (waitpid($srv->{'pid'},&WNOHANG) == $srv->{'pid'}) )
|
||||
{
|
||||
$srv->{'pid'}= 0;
|
||||
}
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# We know the process was started from this file, so there is a PID
|
||||
# saved, or else we have nothing to do.
|
||||
# Might be that is is recorded to be missing, but we failed to
|
||||
# take away the PID file earlier, then we do it now.
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
my %mysqld_pids;
|
||||
|
||||
foreach my $srv ( @$spec )
|
||||
{
|
||||
if ( $srv->{'pid'} )
|
||||
{
|
||||
$mysqld_pids{$srv->{'pid'}}= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
# Race, could have been removed between I tested with -f
|
||||
# and the unlink() below, so I better check again with -f
|
||||
|
||||
if ( -f $srv->{'pidfile'} and ! unlink($srv->{'pidfile'}) and
|
||||
-f $srv->{'pidfile'} )
|
||||
{
|
||||
mtr_error("can't remove $srv->{'pidfile'}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# If the processes where started from this script, and we had no PIDS
|
||||
# then we don't have to do anything.
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
if ( ! keys %mysqld_pids )
|
||||
{
|
||||
# cluck "This is how we got here!";
|
||||
return;
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# In mtr_mysqladmin_shutdown() we only waited for the mysqld servers
|
||||
# not to listen to the port. But we are not sure we got them all
|
||||
# killed. If we suspect it lives, try nice kill with SIG_TERM. Note
|
||||
# that for true Win32 processes, kill(0,$pid) will not return 1.
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
SIGNAL:
|
||||
foreach my $sig (15,9)
|
||||
{
|
||||
my $retries= 10; # 10 seconds
|
||||
kill($sig, keys %mysqld_pids);
|
||||
while ( $retries-- and kill(0, keys %mysqld_pids) )
|
||||
{
|
||||
mtr_debug("Sleep 1 second waiting for processes to die");
|
||||
sleep(1) # Wait one second
|
||||
}
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Now, we check if all we can find using kill(0,$pid) are dead,
|
||||
# and just assume the rest are. We cleanup socket and PID files.
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
{
|
||||
my $errors= 0;
|
||||
foreach my $srv ( @$spec )
|
||||
{
|
||||
if ( $srv->{'pid'} )
|
||||
{
|
||||
if ( kill(0,$srv->{'pid'}) )
|
||||
{
|
||||
# FIXME In Cygwin there seem to be some fast reuse
|
||||
# of PIDs, so dying may not be the right thing to do.
|
||||
$errors++;
|
||||
mtr_warning("can't kill process $srv->{'pid'}");
|
||||
}
|
||||
else
|
||||
{
|
||||
# We managed to kill it at last
|
||||
# FIXME In Cygwin, we will get here even if the process lives.
|
||||
|
||||
# Not needed as we know the process is dead, but to be safe
|
||||
# we unlink and check success in two steps. We first unlink
|
||||
# without checking the error code, and then check if the
|
||||
# file still exists.
|
||||
|
||||
foreach my $file ($srv->{'pidfile'}, $srv->{'sockfile'})
|
||||
{
|
||||
# Know it is dead so should be no race, careful anyway
|
||||
if ( -f $file and ! unlink($file) and -f $file )
|
||||
{
|
||||
$errors++;
|
||||
mtr_warning("couldn't delete $file");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $errors )
|
||||
{
|
||||
# We are in trouble, just die....
|
||||
mtr_error("we could not kill or clean up all processes");
|
||||
}
|
||||
}
|
||||
|
||||
# FIXME We just assume they are all dead, for Cygwin we are not
|
||||
# really sure
|
||||
|
||||
}
|
||||
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Shut down mysqld servers using "mysqladmin ... shutdown".
|
||||
# To speed this up, we start them in parallel and use waitpid() to
|
||||
# catch their termination. Note that this doesn't say the servers
|
||||
# are terminated, just that 'mysqladmin' is terminated.
|
||||
#
|
||||
# Note that mysqladmin will ask the server about what PID file it uses,
|
||||
# and mysqladmin will wait for it to be removed before it terminates
|
||||
# (unless passes timeout).
|
||||
#
|
||||
# This function will take at most about 20 seconds, and we still are not
|
||||
# sure we killed them all. If none is responding to ping, we return 1,
|
||||
# else we return 0.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub mtr_mysqladmin_shutdown () {
|
||||
my $spec= shift;
|
||||
|
||||
my %mysql_admin_pids;
|
||||
my @to_kill_specs;
|
||||
|
||||
foreach my $srv ( @$spec )
|
||||
{
|
||||
if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) )
|
||||
{
|
||||
push(@to_kill_specs, $srv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach my $srv ( @to_kill_specs )
|
||||
{
|
||||
# FIXME wrong log.....
|
||||
# FIXME, stderr.....
|
||||
# Shutdown time must be high as slave may be in reconnect
|
||||
my $args;
|
||||
|
||||
mtr_init_args(\$args);
|
||||
|
||||
mtr_add_arg($args, "--no-defaults");
|
||||
mtr_add_arg($args, "--user=%s", $::opt_user);
|
||||
mtr_add_arg($args, "--password=");
|
||||
if ( -e $srv->{'sockfile'} )
|
||||
{
|
||||
mtr_add_arg($args, "--socket=%s", $srv->{'sockfile'});
|
||||
}
|
||||
if ( $srv->{'port'} )
|
||||
{
|
||||
mtr_add_arg($args, "--port=%s", $srv->{'port'});
|
||||
}
|
||||
if ( $srv->{'port'} and ! -e $srv->{'sockfile'} )
|
||||
{
|
||||
mtr_add_arg($args, "--protocol=tcp"); # Needed if no --socket
|
||||
}
|
||||
mtr_add_arg($args, "--connect_timeout=5");
|
||||
mtr_add_arg($args, "--shutdown_timeout=20");
|
||||
mtr_add_arg($args, "shutdown");
|
||||
# We don't wait for termination of mysqladmin
|
||||
my $pid= mtr_spawn($::exe_mysqladmin, $args,
|
||||
"", $::path_manager_log, $::path_manager_log, "");
|
||||
$mysql_admin_pids{$pid}= 1;
|
||||
}
|
||||
|
||||
# We wait blocking, we wait for the last one anyway
|
||||
while (keys %mysql_admin_pids)
|
||||
{
|
||||
foreach my $pid (keys %mysql_admin_pids)
|
||||
{
|
||||
if ( waitpid($pid,0) > 0 )
|
||||
{
|
||||
delete $mysql_admin_pids{$pid};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# If we trusted "mysqladmin --shutdown_timeout= ..." we could just
|
||||
# terminate now, but we don't (FIXME should be debugged).
|
||||
# So we try again to ping and at least wait the same amount of time
|
||||
# mysqladmin would for all to die.
|
||||
|
||||
my $timeout= 20; # 20 seconds max
|
||||
my $res= 1; # If we just fall through, we are done
|
||||
|
||||
TIME:
|
||||
while ( $timeout-- )
|
||||
{
|
||||
foreach my $srv ( @to_kill_specs )
|
||||
{
|
||||
$res= 1; # We are optimistic
|
||||
if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) )
|
||||
{
|
||||
mtr_debug("Sleep 1 second waiting for processes to stop using port");
|
||||
sleep(1); # One second
|
||||
$res= 0;
|
||||
next TIME;
|
||||
}
|
||||
}
|
||||
last; # If we got here, we are done
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# The operating system will keep information about dead children,
|
||||
# we read this information here, and if we have records the process
|
||||
# is alive, we mark it as dead.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub mtr_record_dead_children () {
|
||||
|
||||
my $ret_pid;
|
||||
|
||||
# FIXME the man page says to wait for -1 to terminate,
|
||||
# but on OS X we get '0' all the time...
|
||||
while ( ($ret_pid= waitpid(-1,&WNOHANG)) > 0 )
|
||||
{
|
||||
mtr_debug("waitpid() catched exit of child $ret_pid");
|
||||
foreach my $idx (0..1)
|
||||
{
|
||||
if ( $::master->[$idx]->{'pid'} eq $ret_pid )
|
||||
{
|
||||
mtr_debug("child $ret_pid was master[$idx]");
|
||||
$::master->[$idx]->{'pid'}= 0;
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $idx (0..2)
|
||||
{
|
||||
if ( $::slave->[$idx]->{'pid'} eq $ret_pid )
|
||||
{
|
||||
mtr_debug("child $ret_pid was slave[$idx]");
|
||||
$::slave->[$idx]->{'pid'}= 0;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub start_reap_all {
|
||||
$SIG{CHLD}= 'IGNORE'; # FIXME is this enough?
|
||||
}
|
||||
|
||||
sub stop_reap_all {
|
||||
$SIG{CHLD}= 'DEFAULT';
|
||||
}
|
||||
|
||||
sub mtr_ping_mysqld_server () {
|
||||
my $port= shift;
|
||||
|
||||
my $remote= "localhost";
|
||||
my $iaddr= inet_aton($remote);
|
||||
if ( ! $iaddr )
|
||||
{
|
||||
mtr_error("can't find IP number for $remote");
|
||||
}
|
||||
my $paddr= sockaddr_in($port, $iaddr);
|
||||
my $proto= getprotobyname('tcp');
|
||||
if ( ! socket(SOCK, PF_INET, SOCK_STREAM, $proto) )
|
||||
{
|
||||
mtr_error("can't create socket: $!");
|
||||
}
|
||||
if ( connect(SOCK, $paddr) )
|
||||
{
|
||||
close(SOCK); # FIXME check error?
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Wait for a file to be created
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
sub sleep_until_file_created ($$$) {
|
||||
my $pidfile= shift;
|
||||
my $timeout= shift;
|
||||
my $pid= shift;
|
||||
|
||||
for ( my $loop= 1; $loop <= $timeout; $loop++ )
|
||||
{
|
||||
if ( -r $pidfile )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Check if it died after the fork() was successful
|
||||
if ( waitpid($pid,&WNOHANG) == $pid )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
mtr_debug("Sleep 1 second waiting for creation of $pidfile");
|
||||
|
||||
if ( $loop % 60 == 0 )
|
||||
{
|
||||
my $left= $timeout - $loop;
|
||||
mtr_warning("Waited $loop seconds for $pidfile to be created, " .
|
||||
"still waiting for $left seconds...");
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
1;
|
281
mysql-test/lib/mtr_report.pl
Normal file
281
mysql-test/lib/mtr_report.pl
Normal file
@ -0,0 +1,281 @@
|
||||
# -*- cperl -*-
|
||||
|
||||
# This is a library file used by the Perl version of mysql-test-run,
|
||||
# and is part of the translation of the Bourne shell script with the
|
||||
# same name.
|
||||
|
||||
use strict;
|
||||
|
||||
sub mtr_report_test_name($);
|
||||
sub mtr_report_test_passed($);
|
||||
sub mtr_report_test_failed($);
|
||||
sub mtr_report_test_skipped($);
|
||||
sub mtr_report_test_disabled($);
|
||||
|
||||
sub mtr_show_failed_diff ($);
|
||||
sub mtr_report_stats ($);
|
||||
sub mtr_print_line ();
|
||||
sub mtr_print_thick_line ();
|
||||
sub mtr_print_header ();
|
||||
sub mtr_report (@);
|
||||
sub mtr_warning (@);
|
||||
sub mtr_error (@);
|
||||
sub mtr_debug (@);
|
||||
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# We can't use diff -u or diff -a as these are not portable
|
||||
|
||||
sub mtr_show_failed_diff ($) {
|
||||
my $tname= shift;
|
||||
|
||||
my $reject_file= "r/$tname.reject";
|
||||
my $result_file= "r/$tname.result";
|
||||
my $eval_file= "r/$tname.eval";
|
||||
|
||||
if ( -f $eval_file )
|
||||
{
|
||||
$result_file= $eval_file;
|
||||
}
|
||||
elsif ( $::opt_result_ext and
|
||||
( $::opt_record or -f "$result_file$::opt_result_ext" ))
|
||||
{
|
||||
# If we have an special externsion for result files we use it if we are
|
||||
# recording or a result file with that extension exists.
|
||||
$result_file= "$result_file$::opt_result_ext";
|
||||
}
|
||||
|
||||
my $diffopts= $::opt_udiff ? "-u" : "-c";
|
||||
|
||||
if ( -f $reject_file )
|
||||
{
|
||||
print "Below are the diffs between actual and expected results:\n";
|
||||
print "-------------------------------------------------------\n";
|
||||
# FIXME check result code?!
|
||||
mtr_run("diff",[$diffopts,$result_file,$reject_file], "", "", "", "");
|
||||
print "-------------------------------------------------------\n";
|
||||
print "Please follow the instructions outlined at\n";
|
||||
print "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html\n";
|
||||
print "to find the reason to this problem and how to report this.\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub mtr_report_test_name ($) {
|
||||
my $tinfo= shift;
|
||||
|
||||
printf "%-31s ", $tinfo->{'name'};
|
||||
}
|
||||
|
||||
sub mtr_report_test_skipped ($) {
|
||||
my $tinfo= shift;
|
||||
|
||||
$tinfo->{'result'}= 'MTR_RES_SKIPPED';
|
||||
if ( $tinfo->{'disable'} )
|
||||
{
|
||||
print "[ disabled ] $tinfo->{'comment'}\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "[ skipped ]\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub mtr_report_test_passed ($) {
|
||||
my $tinfo= shift;
|
||||
|
||||
my $timer= "";
|
||||
# FIXME
|
||||
# if ( $::opt_timer and -f "$::glob_mysql_test_dir/var/log/timer" )
|
||||
# {
|
||||
# $timer= `cat var/log/timer`;
|
||||
# $timer= sprintf "%13s", $timer;
|
||||
# }
|
||||
$tinfo->{'result'}= 'MTR_RES_PASSED';
|
||||
print "[ pass ] $timer\n";
|
||||
}
|
||||
|
||||
sub mtr_report_test_failed ($) {
|
||||
my $tinfo= shift;
|
||||
|
||||
$tinfo->{'result'}= 'MTR_RES_FAILED';
|
||||
print "[ fail ]\n";
|
||||
|
||||
# FIXME Instead of this test, and meaningless error message in 'else'
|
||||
# we should write out into $::path_timefile when the error occurs.
|
||||
if ( -f $::path_timefile )
|
||||
{
|
||||
print "Errors are (from $::path_timefile) :\n";
|
||||
print mtr_fromfile($::path_timefile); # FIXME print_file() instead
|
||||
print "\n(the last lines may be the most important ones)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Unexpected termination, probably when starting mysqld\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub mtr_report_stats ($) {
|
||||
my $tests= shift;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Find out how we where doing
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
my $tot_skiped= 0;
|
||||
my $tot_passed= 0;
|
||||
my $tot_failed= 0;
|
||||
my $tot_tests= 0;
|
||||
|
||||
foreach my $tinfo (@$tests)
|
||||
{
|
||||
if ( $tinfo->{'result'} eq 'MTR_RES_SKIPPED' )
|
||||
{
|
||||
$tot_skiped++;
|
||||
}
|
||||
elsif ( $tinfo->{'result'} eq 'MTR_RES_PASSED' )
|
||||
{
|
||||
$tot_tests++;
|
||||
$tot_passed++;
|
||||
}
|
||||
elsif ( $tinfo->{'result'} eq 'MTR_RES_FAILED' )
|
||||
{
|
||||
$tot_tests++;
|
||||
$tot_failed++;
|
||||
}
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Print out a summary report to screen
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
if ( ! $tot_failed )
|
||||
{
|
||||
print "All $tot_tests tests were successful.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
my $ratio= $tot_passed * 100 / $tot_tests;
|
||||
printf "Failed $tot_failed/$tot_tests tests, " .
|
||||
"%.2f\% successful.\n\n", $ratio;
|
||||
print
|
||||
"The log files in var/log may give you some hint\n",
|
||||
"of what when wrong.\n",
|
||||
"If you want to report this error, please read first ",
|
||||
"the documentation at\n",
|
||||
"http://www.mysql.com/doc/en/MySQL_test_suite.html\n";
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
if ( ! $::glob_use_running_server )
|
||||
{
|
||||
|
||||
# Report if there was any fatal warnings/errors in the log files
|
||||
#
|
||||
unlink("$::glob_mysql_test_dir/var/log/warnings");
|
||||
unlink("$::glob_mysql_test_dir/var/log/warnings.tmp");
|
||||
# Remove some non fatal warnings from the log files
|
||||
|
||||
# FIXME what is going on ????? ;-)
|
||||
# sed -e 's!Warning: Table:.* on delete!!g' -e 's!Warning: Setting lower_case_table_names=2!!g' -e 's!Warning: One can only use the --user.*root!!g' \
|
||||
# var/log/*.err \
|
||||
# | sed -e 's!Warning: Table:.* on rename!!g' \
|
||||
# > var/log/warnings.tmp;
|
||||
#
|
||||
# found_error=0;
|
||||
# # Find errors
|
||||
# for i in "^Warning:" "^Error:" "^==.* at 0x"
|
||||
# do
|
||||
# if ( $GREP "$i" var/log/warnings.tmp >> var/log/warnings )
|
||||
# {
|
||||
# found_error=1
|
||||
# }
|
||||
# done
|
||||
# unlink("$::glob_mysql_test_dir/var/log/warnings.tmp");
|
||||
# if ( $found_error= "1" )
|
||||
# {
|
||||
# print "WARNING: Got errors/warnings while running tests. Please examine\n"
|
||||
# print "$::glob_mysql_test_dir/var/log/warnings for details.\n"
|
||||
# }
|
||||
# }
|
||||
}
|
||||
|
||||
print "\n";
|
||||
|
||||
if ( $tot_failed != 0 )
|
||||
{
|
||||
print "mysql-test-run: *** Failing the test(s):";
|
||||
|
||||
foreach my $tinfo (@$tests)
|
||||
{
|
||||
if ( $tinfo->{'result'} eq 'MTR_RES_FAILED' )
|
||||
{
|
||||
print " $tinfo->{'name'}";
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
mtr_error("there where failing test cases");
|
||||
}
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Text formatting
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub mtr_print_line () {
|
||||
print '-' x 55, "\n";
|
||||
}
|
||||
|
||||
sub mtr_print_thick_line () {
|
||||
print '=' x 55, "\n";
|
||||
}
|
||||
|
||||
sub mtr_print_header () {
|
||||
print "\n";
|
||||
if ( $::opt_timer )
|
||||
{
|
||||
print "TEST RESULT TIME (ms)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "TEST RESULT\n";
|
||||
}
|
||||
mtr_print_line();
|
||||
print "\n";
|
||||
}
|
||||
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Misc
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub mtr_report (@) {
|
||||
print join(" ", @_),"\n";
|
||||
}
|
||||
|
||||
sub mtr_warning (@) {
|
||||
print STDERR "mysql-test-run: WARNING: ",join(" ", @_),"\n";
|
||||
}
|
||||
|
||||
sub mtr_error (@) {
|
||||
die "mysql-test-run: *** ERROR: ",join(" ", @_),"\n";
|
||||
}
|
||||
|
||||
sub mtr_debug (@) {
|
||||
if ( $::opt_script_debug )
|
||||
{
|
||||
print STDERR "####: ",join(" ", @_),"\n";
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
673
mysql-test/my_create_tables.c
Normal file
673
mysql-test/my_create_tables.c
Normal file
@ -0,0 +1,673 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#ifndef __WIN__
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#ifdef __NETWARE__
|
||||
#include <screen.h>
|
||||
#include <proc.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#ifndef __WIN__
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <direct.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include "my_manage.h"
|
||||
|
||||
/*
|
||||
Synopsis:
|
||||
This function testes a exist file
|
||||
|
||||
Arguments:
|
||||
mdata: path to data
|
||||
file_name: name of file
|
||||
Output:
|
||||
A zero value indicates that file is exist.
|
||||
*/
|
||||
bool test_sys_file(const char *mdata,const char *file_name)
|
||||
{
|
||||
struct stat file;
|
||||
char path_file_name[PATH_MAX];
|
||||
snprintf(path_file_name, PATH_MAX, "%s/%s", mdata, file_name);
|
||||
return(stat(path_file_name,&file));
|
||||
}
|
||||
|
||||
/*
|
||||
Synopsis:
|
||||
This function creates a file with sql requstes for creating
|
||||
system data files.
|
||||
|
||||
Arguments:
|
||||
mdata: path to data
|
||||
output_file: file name for output file
|
||||
test: to create system files with test data
|
||||
Output:
|
||||
A zero value indicates a success.
|
||||
*/
|
||||
bool create_system_files(const char *mdata,const char *output_file, bool test)
|
||||
{
|
||||
FILE *out;
|
||||
|
||||
out = fopen(output_file, "w+");
|
||||
|
||||
if (!out)
|
||||
return 1;
|
||||
|
||||
if (test_sys_file(mdata,"mysql"))
|
||||
{
|
||||
fprintf(out,"CREATE DATABASE mysql;\n");
|
||||
}
|
||||
|
||||
if (test && test_sys_file(mdata,"test"))
|
||||
{
|
||||
fprintf(out,"CREATE DATABASE test;\n");
|
||||
}
|
||||
|
||||
fprintf(out,"USE mysql;\n");
|
||||
|
||||
if (test_sys_file(mdata,"mysql/db.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE db ("
|
||||
"Host char(60) binary DEFAULT '' NOT NULL,"
|
||||
"Db char(64) binary DEFAULT '' NOT NULL,"
|
||||
"User char(16) binary DEFAULT '' NOT NULL,"
|
||||
"Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"PRIMARY KEY Host (Host,Db,User),"
|
||||
"KEY User (User))"
|
||||
"engine=MyISAM "
|
||||
"CHARACTER SET utf8 COLLATE utf8_bin "
|
||||
"comment='Database privileges';\n");
|
||||
|
||||
if (test)
|
||||
{
|
||||
fprintf(out,"INSERT INTO db VALUES ('%%','test','','Y','Y','Y','Y'"
|
||||
",'Y','Y','N','Y','Y','Y','Y','Y');\n");
|
||||
fprintf(out,"INSERT INTO db VALUES ('%%','test\\_%%','','Y','Y','Y'"
|
||||
",'Y','Y','Y','N','Y','Y','Y','Y','Y');\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (test_sys_file(mdata,"mysql/host.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE host ("
|
||||
"Host char(60) binary DEFAULT '' NOT NULL,"
|
||||
"Db char(64) binary DEFAULT '' NOT NULL,"
|
||||
"Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"PRIMARY KEY Host (Host,Db))"
|
||||
"engine=MyISAM "
|
||||
"CHARACTER SET utf8 COLLATE utf8_bin "
|
||||
"comment='Host privileges; Merged with database privileges';\n");
|
||||
}
|
||||
|
||||
|
||||
if (test_sys_file(mdata,"mysql/user.frm"))
|
||||
{
|
||||
#ifdef __WIN__
|
||||
WSADATA wsa_data;
|
||||
#endif
|
||||
char hostname[FN_REFLEN];
|
||||
|
||||
#ifdef __WIN__
|
||||
if (WSAStartup(MAKEWORD( 2, 2 ),&wsa_data))
|
||||
return 1;
|
||||
#endif
|
||||
if (gethostname(hostname, FN_REFLEN))
|
||||
return 1;
|
||||
#ifdef __WIN__
|
||||
WSACleanup( );
|
||||
#endif
|
||||
|
||||
if (strchr(hostname, '.') == NULL)
|
||||
strcat(hostname, "%");
|
||||
|
||||
fprintf(out,
|
||||
"CREATE TABLE user ("
|
||||
"Host char(60) binary DEFAULT '' NOT NULL,"
|
||||
"User char(16) binary DEFAULT '' NOT NULL,"
|
||||
"Password char(41) binary DEFAULT '' NOT NULL,"
|
||||
"Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Process_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"File_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Super_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
|
||||
"ssl_type enum('','ANY','X509', 'SPECIFIED') DEFAULT '' NOT NULL,"
|
||||
"ssl_cipher BLOB NOT NULL,"
|
||||
"x509_issuer BLOB NOT NULL,"
|
||||
"x509_subject BLOB NOT NULL,"
|
||||
"max_questions int(11) unsigned DEFAULT 0 NOT NULL,"
|
||||
"max_updates int(11) unsigned DEFAULT 0 NOT NULL,"
|
||||
"max_connections int(11) unsigned DEFAULT 0 NOT NULL,"
|
||||
"PRIMARY KEY Host (Host,User)"
|
||||
") engine=MyISAM "
|
||||
"CHARACTER SET utf8 COLLATE utf8_bin "
|
||||
"comment='Users and global privileges';\n");
|
||||
|
||||
|
||||
if (test)
|
||||
{
|
||||
fprintf(out,
|
||||
"INSERT INTO user VALUES ('localhost','root',''"
|
||||
",'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'"
|
||||
",'Y','Y','Y','Y','Y','','','','',0,0,0);\n");
|
||||
fprintf(out,
|
||||
"INSERT INTO user VALUES ('%s','root','','Y','Y',"
|
||||
"'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',"
|
||||
"'Y','Y','Y','Y','','','','',0,0,0);\n",hostname);
|
||||
fprintf(out,
|
||||
"REPLACE INTO user VALUES ('127.0.0.1','root','',"
|
||||
"'Y','Y','Y','Y','Y','Y',"
|
||||
"'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'"
|
||||
",'Y','','','','',0,0,0);\n");
|
||||
fprintf(out,"INSERT INTO user (host,user) values ('localhost','');\n");
|
||||
fprintf(out,"INSERT INTO user (host,user) values ('%s','');\n",hostname);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(out,
|
||||
"INSERT INTO user VALUES ('localhost','root','',"
|
||||
"'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',"
|
||||
"'Y','Y','Y','Y','','','','',0,0,0);\n");
|
||||
#ifndef __WIN__
|
||||
fprintf(out,
|
||||
"INSERT INTO user VALUES ('%s','root','','Y','Y',"
|
||||
"'Y','Y','Y','Y','Y','Y'"
|
||||
"'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','',''"
|
||||
",'','',0,0,0);\n",hostname);
|
||||
fprintf(out,"INSERT INTO user (host,user) values ('%s','');\n",hostname);
|
||||
fprintf(out,"INSERT INTO user (host,user) values ('localhost','');\n");
|
||||
#else
|
||||
fprintf(out,
|
||||
"INSERT INTO user VALUES ('localhost','','','Y','Y','Y'"
|
||||
",'Y','Y','Y','Y','Y','Y'"
|
||||
",'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','',"
|
||||
"'','',0,0,0);\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (test_sys_file(mdata,"mysql/func.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE func ("
|
||||
"name char(64) binary DEFAULT '' NOT NULL,"
|
||||
"ret tinyint(1) DEFAULT '0' NOT NULL,"
|
||||
"dl char(128) DEFAULT '' NOT NULL,"
|
||||
"type enum ('function','aggregate') NOT NULL,"
|
||||
"PRIMARY KEY (name)"
|
||||
") engine=MyISAM "
|
||||
"CHARACTER SET utf8 COLLATE utf8_bin "
|
||||
"comment='User defined functions';\n");
|
||||
}
|
||||
|
||||
if (test_sys_file(mdata,"mysql/tables_priv.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE tables_priv ("
|
||||
"Host char(60) binary DEFAULT '' NOT NULL,"
|
||||
"Db char(64) binary DEFAULT '' NOT NULL,"
|
||||
"User char(16) binary DEFAULT '' NOT NULL,"
|
||||
"Table_name char(64) binary DEFAULT '' NOT NULL,"
|
||||
"Grantor char(77) DEFAULT '' NOT NULL,"
|
||||
"Timestamp timestamp(14),"
|
||||
"Table_priv set('Select','Insert','Update','Delete',"
|
||||
"'Create','Drop','Grant','References','Index','Alter')"
|
||||
" DEFAULT '' NOT NULL,"
|
||||
"Column_priv set('Select','Insert','Update','References')"
|
||||
" DEFAULT '' NOT NULL,"
|
||||
"PRIMARY KEY (Host,Db,User,Table_name),"
|
||||
"KEY Grantor (Grantor)"
|
||||
") engine=MyISAM "
|
||||
"CHARACTER SET utf8 COLLATE utf8_bin "
|
||||
"comment='Table privileges';\n");
|
||||
}
|
||||
|
||||
if (test_sys_file(mdata,"mysql/columns_priv.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE columns_priv ("
|
||||
"Host char(60) binary DEFAULT '' NOT NULL,"
|
||||
"Db char(64) binary DEFAULT '' NOT NULL,"
|
||||
"User char(16) binary DEFAULT '' NOT NULL,"
|
||||
"Table_name char(64) binary DEFAULT '' NOT NULL,"
|
||||
"Column_name char(64) binary DEFAULT '' NOT NULL,"
|
||||
"Timestamp timestamp(14),"
|
||||
"Column_priv set('Select','Insert','Update','References')"
|
||||
" DEFAULT '' NOT NULL,"
|
||||
"PRIMARY KEY (Host,Db,User,Table_name,Column_name)"
|
||||
") engine=MyISAM "
|
||||
"CHARACTER SET utf8 COLLATE utf8_bin "
|
||||
"comment='Column privileges';\n");
|
||||
}
|
||||
|
||||
if (test_sys_file(mdata,"mysql/help_topic.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE help_topic ("
|
||||
"help_topic_id int unsigned not null,"
|
||||
"name varchar(64) not null,"
|
||||
"help_category_id smallint unsigned not null,"
|
||||
"description text not null,"
|
||||
"example text not null,"
|
||||
"url varchar(128) not null,"
|
||||
"primary key (help_topic_id),"
|
||||
"unique index (name)"
|
||||
") engine=MyISAM "
|
||||
"CHARACTER SET utf8 "
|
||||
"comment='help topics';\n");
|
||||
}
|
||||
|
||||
if (test_sys_file(mdata,"mysql/help_category.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE help_category ("
|
||||
"help_category_id smallint unsigned not null,"
|
||||
"name varchar(64) not null,"
|
||||
"parent_category_id smallint unsigned null,"
|
||||
"url varchar(128) not null,"
|
||||
"primary key (help_category_id),"
|
||||
"unique index (name)"
|
||||
") engine=MyISAM "
|
||||
"CHARACTER SET utf8 "
|
||||
"comment='help categories';\n");
|
||||
}
|
||||
|
||||
if (test_sys_file(mdata,"mysql/help_keyword.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE help_keyword ("
|
||||
"help_keyword_id int unsigned not null,"
|
||||
"name varchar(64) not null,"
|
||||
"primary key (help_keyword_id),"
|
||||
"unique index (name)"
|
||||
") engine=MyISAM "
|
||||
"CHARACTER SET utf8 "
|
||||
"comment='help keywords';\n");
|
||||
}
|
||||
|
||||
if (test_sys_file(mdata,"mysql/help_relation.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE help_relation ("
|
||||
"help_topic_id int unsigned not null references help_topic,"
|
||||
"help_keyword_id int unsigned not null references help_keyword,"
|
||||
"primary key (help_keyword_id, help_topic_id)"
|
||||
") engine=MyISAM "
|
||||
"CHARACTER SET utf8 "
|
||||
"comment='keyword-topic relation';\n");
|
||||
}
|
||||
|
||||
if (test_sys_file(mdata,"mysql/time_zone_name.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE time_zone_name ("
|
||||
"Name char(64) NOT NULL,"
|
||||
"Time_zone_id int unsigned NOT NULL,"
|
||||
"PRIMARY KEY Name (Name)"
|
||||
") engine=MyISAM CHARACTER SET utf8 "
|
||||
"comment='Time zone names';\n");
|
||||
|
||||
if (test)
|
||||
{
|
||||
fprintf(out,
|
||||
"INSERT INTO time_zone_name (Name, Time_Zone_id) VALUES"
|
||||
"('MET', 1), ('UTC', 2), ('Universal', 2), "
|
||||
"('Europe/Moscow',3), ('leap/Europe/Moscow',4),"
|
||||
"('Japan', 5);\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (test_sys_file(mdata,"mysql/time_zone.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE time_zone ("
|
||||
"Time_zone_id int unsigned NOT NULL auto_increment,"
|
||||
"Use_leap_seconds enum('Y','N') DEFAULT 'N' NOT NULL,"
|
||||
"PRIMARY KEY TzId (Time_zone_id)"
|
||||
") engine=MyISAM CHARACTER SET utf8 "
|
||||
"comment='Time zones';\n");
|
||||
|
||||
if (test)
|
||||
{
|
||||
fprintf(out,"INSERT INTO time_zone (Time_zone_id, Use_leap_seconds)"
|
||||
"VALUES (1,'N'), (2,'N'), (3,'N'), (4,'Y'), (5,'N');\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (test_sys_file(mdata,"mysql/time_zone_transition.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE time_zone_transition ("
|
||||
"Time_zone_id int unsigned NOT NULL,"
|
||||
"Transition_time bigint signed NOT NULL,"
|
||||
"Transition_type_id int unsigned NOT NULL,"
|
||||
"PRIMARY KEY TzIdTranTime (Time_zone_id, Transition_time)"
|
||||
") engine=MyISAM CHARACTER SET utf8 "
|
||||
"comment='Time zone transitions';\n");
|
||||
|
||||
if (test)
|
||||
{
|
||||
fprintf(out,
|
||||
"INSERT INTO time_zone_transition"
|
||||
"(Time_zone_id, Transition_time, Transition_type_id)"
|
||||
"VALUES"
|
||||
" (1, -1693706400, 0) ,(1, -1680483600, 1)"
|
||||
",(1, -1663455600, 2) ,(1, -1650150000, 3)"
|
||||
",(1, -1632006000, 2) ,(1, -1618700400, 3)"
|
||||
",(1, -938905200, 2) ,(1, -857257200, 3)"
|
||||
",(1, -844556400, 2) ,(1, -828226800, 3)"
|
||||
",(1, -812502000, 2) ,(1, -796777200, 3)"
|
||||
",(1, 228877200, 2) ,(1, 243997200, 3)"
|
||||
",(1, 260326800, 2) ,(1, 276051600, 3)"
|
||||
",(1, 291776400, 2) ,(1, 307501200, 3)"
|
||||
",(1, 323830800, 2) ,(1, 338950800, 3)"
|
||||
",(1, 354675600, 2) ,(1, 370400400, 3)"
|
||||
",(1, 386125200, 2) ,(1, 401850000, 3)"
|
||||
",(1, 417574800, 2) ,(1, 433299600, 3)"
|
||||
",(1, 449024400, 2) ,(1, 465354000, 3)"
|
||||
",(1, 481078800, 2) ,(1, 496803600, 3)"
|
||||
",(1, 512528400, 2) ,(1, 528253200, 3)"
|
||||
",(1, 543978000, 2) ,(1, 559702800, 3)"
|
||||
",(1, 575427600, 2) ,(1, 591152400, 3)"
|
||||
",(1, 606877200, 2) ,(1, 622602000, 3)"
|
||||
",(1, 638326800, 2) ,(1, 654656400, 3)"
|
||||
",(1, 670381200, 2) ,(1, 686106000, 3)"
|
||||
",(1, 701830800, 2) ,(1, 717555600, 3)"
|
||||
",(1, 733280400, 2) ,(1, 749005200, 3)"
|
||||
",(1, 764730000, 2) ,(1, 780454800, 3)"
|
||||
",(1, 796179600, 2) ,(1, 811904400, 3)"
|
||||
",(1, 828234000, 2) ,(1, 846378000, 3)"
|
||||
",(1, 859683600, 2) ,(1, 877827600, 3)"
|
||||
",(1, 891133200, 2) ,(1, 909277200, 3)"
|
||||
",(1, 922582800, 2) ,(1, 941331600, 3)"
|
||||
",(1, 954032400, 2) ,(1, 972781200, 3)"
|
||||
",(1, 985482000, 2) ,(1, 1004230800, 3)"
|
||||
",(1, 1017536400, 2) ,(1, 1035680400, 3)"
|
||||
",(1, 1048986000, 2) ,(1, 1067130000, 3)"
|
||||
",(1, 1080435600, 2) ,(1, 1099184400, 3)"
|
||||
",(1, 1111885200, 2) ,(1, 1130634000, 3)"
|
||||
",(1, 1143334800, 2) ,(1, 1162083600, 3)"
|
||||
",(1, 1174784400, 2) ,(1, 1193533200, 3)"
|
||||
",(1, 1206838800, 2) ,(1, 1224982800, 3)"
|
||||
",(1, 1238288400, 2) ,(1, 1256432400, 3)"
|
||||
",(1, 1269738000, 2) ,(1, 1288486800, 3)"
|
||||
",(1, 1301187600, 2) ,(1, 1319936400, 3)"
|
||||
",(1, 1332637200, 2) ,(1, 1351386000, 3)"
|
||||
",(1, 1364691600, 2) ,(1, 1382835600, 3)"
|
||||
",(1, 1396141200, 2) ,(1, 1414285200, 3)"
|
||||
",(1, 1427590800, 2) ,(1, 1445734800, 3)"
|
||||
",(1, 1459040400, 2) ,(1, 1477789200, 3)"
|
||||
",(1, 1490490000, 2) ,(1, 1509238800, 3)"
|
||||
",(1, 1521939600, 2) ,(1, 1540688400, 3)"
|
||||
",(1, 1553994000, 2) ,(1, 1572138000, 3)"
|
||||
",(1, 1585443600, 2) ,(1, 1603587600, 3)"
|
||||
",(1, 1616893200, 2) ,(1, 1635642000, 3)"
|
||||
",(1, 1648342800, 2) ,(1, 1667091600, 3)"
|
||||
",(1, 1679792400, 2) ,(1, 1698541200, 3)"
|
||||
",(1, 1711846800, 2) ,(1, 1729990800, 3)"
|
||||
",(1, 1743296400, 2) ,(1, 1761440400, 3)"
|
||||
",(1, 1774746000, 2) ,(1, 1792890000, 3)"
|
||||
",(1, 1806195600, 2) ,(1, 1824944400, 3)"
|
||||
",(1, 1837645200, 2) ,(1, 1856394000, 3)"
|
||||
",(1, 1869094800, 2) ,(1, 1887843600, 3)"
|
||||
",(1, 1901149200, 2) ,(1, 1919293200, 3)"
|
||||
",(1, 1932598800, 2) ,(1, 1950742800, 3)"
|
||||
",(1, 1964048400, 2) ,(1, 1982797200, 3)"
|
||||
",(1, 1995498000, 2) ,(1, 2014246800, 3)"
|
||||
",(1, 2026947600, 2) ,(1, 2045696400, 3)"
|
||||
",(1, 2058397200, 2) ,(1, 2077146000, 3)"
|
||||
",(1, 2090451600, 2) ,(1, 2108595600, 3)"
|
||||
",(1, 2121901200, 2) ,(1, 2140045200, 3)"
|
||||
",(3, -1688265000, 2) ,(3, -1656819048, 1)"
|
||||
",(3, -1641353448, 2) ,(3, -1627965048, 3)"
|
||||
",(3, -1618716648, 1) ,(3, -1596429048, 3)"
|
||||
",(3, -1593829848, 5) ,(3, -1589860800, 4)"
|
||||
",(3, -1542427200, 5) ,(3, -1539493200, 6)"
|
||||
",(3, -1525323600, 5) ,(3, -1522728000, 4)"
|
||||
",(3, -1491188400, 7) ,(3, -1247536800, 4)"
|
||||
",(3, 354920400, 5) ,(3, 370728000, 4)"
|
||||
",(3, 386456400, 5) ,(3, 402264000, 4)"
|
||||
",(3, 417992400, 5) ,(3, 433800000, 4)"
|
||||
",(3, 449614800, 5) ,(3, 465346800, 8)"
|
||||
",(3, 481071600, 9) ,(3, 496796400, 8)"
|
||||
",(3, 512521200, 9) ,(3, 528246000, 8)"
|
||||
",(3, 543970800, 9) ,(3, 559695600, 8)"
|
||||
",(3, 575420400, 9) ,(3, 591145200, 8)"
|
||||
",(3, 606870000, 9) ,(3, 622594800, 8)"
|
||||
",(3, 638319600, 9) ,(3, 654649200, 8)"
|
||||
",(3, 670374000, 10) ,(3, 686102400, 11)"
|
||||
",(3, 695779200, 8) ,(3, 701812800, 5)"
|
||||
",(3, 717534000, 4) ,(3, 733273200, 9)"
|
||||
",(3, 748998000, 8) ,(3, 764722800, 9)"
|
||||
",(3, 780447600, 8) ,(3, 796172400, 9)"
|
||||
",(3, 811897200, 8) ,(3, 828226800, 9)"
|
||||
",(3, 846370800, 8) ,(3, 859676400, 9)"
|
||||
",(3, 877820400, 8) ,(3, 891126000, 9)"
|
||||
",(3, 909270000, 8) ,(3, 922575600, 9)"
|
||||
",(3, 941324400, 8) ,(3, 954025200, 9)"
|
||||
",(3, 972774000, 8) ,(3, 985474800, 9)"
|
||||
",(3, 1004223600, 8) ,(3, 1017529200, 9)"
|
||||
",(3, 1035673200, 8) ,(3, 1048978800, 9)"
|
||||
",(3, 1067122800, 8) ,(3, 1080428400, 9)"
|
||||
",(3, 1099177200, 8) ,(3, 1111878000, 9)"
|
||||
",(3, 1130626800, 8) ,(3, 1143327600, 9)"
|
||||
",(3, 1162076400, 8) ,(3, 1174777200, 9)"
|
||||
",(3, 1193526000, 8) ,(3, 1206831600, 9)"
|
||||
",(3, 1224975600, 8) ,(3, 1238281200, 9)"
|
||||
",(3, 1256425200, 8) ,(3, 1269730800, 9)"
|
||||
",(3, 1288479600, 8) ,(3, 1301180400, 9)"
|
||||
",(3, 1319929200, 8) ,(3, 1332630000, 9)"
|
||||
",(3, 1351378800, 8) ,(3, 1364684400, 9)"
|
||||
",(3, 1382828400, 8) ,(3, 1396134000, 9)"
|
||||
",(3, 1414278000, 8) ,(3, 1427583600, 9)"
|
||||
",(3, 1445727600, 8) ,(3, 1459033200, 9)"
|
||||
",(3, 1477782000, 8) ,(3, 1490482800, 9)"
|
||||
",(3, 1509231600, 8) ,(3, 1521932400, 9)"
|
||||
",(3, 1540681200, 8) ,(3, 1553986800, 9)"
|
||||
",(3, 1572130800, 8) ,(3, 1585436400, 9)"
|
||||
",(3, 1603580400, 8) ,(3, 1616886000, 9)"
|
||||
",(3, 1635634800, 8) ,(3, 1648335600, 9)"
|
||||
",(3, 1667084400, 8) ,(3, 1679785200, 9)"
|
||||
",(3, 1698534000, 8) ,(3, 1711839600, 9)"
|
||||
",(3, 1729983600, 8) ,(3, 1743289200, 9)"
|
||||
",(3, 1761433200, 8) ,(3, 1774738800, 9)"
|
||||
",(3, 1792882800, 8) ,(3, 1806188400, 9)"
|
||||
",(3, 1824937200, 8) ,(3, 1837638000, 9)"
|
||||
",(3, 1856386800, 8) ,(3, 1869087600, 9)"
|
||||
",(3, 1887836400, 8) ,(3, 1901142000, 9)"
|
||||
",(3, 1919286000, 8) ,(3, 1932591600, 9)"
|
||||
",(3, 1950735600, 8) ,(3, 1964041200, 9)"
|
||||
",(3, 1982790000, 8) ,(3, 1995490800, 9)"
|
||||
",(3, 2014239600, 8) ,(3, 2026940400, 9)"
|
||||
",(3, 2045689200, 8) ,(3, 2058390000, 9)"
|
||||
",(3, 2077138800, 8) ,(3, 2090444400, 9)"
|
||||
",(3, 2108588400, 8) ,(3, 2121894000, 9)"
|
||||
",(3, 2140038000, 8)"
|
||||
",(4, -1688265000, 2) ,(4, -1656819048, 1)"
|
||||
",(4, -1641353448, 2) ,(4, -1627965048, 3)"
|
||||
",(4, -1618716648, 1) ,(4, -1596429048, 3)"
|
||||
",(4, -1593829848, 5) ,(4, -1589860800, 4)"
|
||||
",(4, -1542427200, 5) ,(4, -1539493200, 6)"
|
||||
",(4, -1525323600, 5) ,(4, -1522728000, 4)"
|
||||
",(4, -1491188400, 7) ,(4, -1247536800, 4)"
|
||||
",(4, 354920409, 5) ,(4, 370728010, 4)"
|
||||
",(4, 386456410, 5) ,(4, 402264011, 4)"
|
||||
",(4, 417992411, 5) ,(4, 433800012, 4)"
|
||||
",(4, 449614812, 5) ,(4, 465346812, 8)"
|
||||
",(4, 481071612, 9) ,(4, 496796413, 8)"
|
||||
",(4, 512521213, 9) ,(4, 528246013, 8)"
|
||||
",(4, 543970813, 9) ,(4, 559695613, 8)"
|
||||
",(4, 575420414, 9) ,(4, 591145214, 8)"
|
||||
",(4, 606870014, 9) ,(4, 622594814, 8)"
|
||||
",(4, 638319615, 9) ,(4, 654649215, 8)"
|
||||
",(4, 670374016, 10) ,(4, 686102416, 11)"
|
||||
",(4, 695779216, 8) ,(4, 701812816, 5)"
|
||||
",(4, 717534017, 4) ,(4, 733273217, 9)"
|
||||
",(4, 748998018, 8) ,(4, 764722818, 9)"
|
||||
",(4, 780447619, 8) ,(4, 796172419, 9)"
|
||||
",(4, 811897219, 8) ,(4, 828226820, 9)"
|
||||
",(4, 846370820, 8) ,(4, 859676420, 9)"
|
||||
",(4, 877820421, 8) ,(4, 891126021, 9)"
|
||||
",(4, 909270021, 8) ,(4, 922575622, 9)"
|
||||
",(4, 941324422, 8) ,(4, 954025222, 9)"
|
||||
",(4, 972774022, 8) ,(4, 985474822, 9)"
|
||||
",(4, 1004223622, 8) ,(4, 1017529222, 9)"
|
||||
",(4, 1035673222, 8) ,(4, 1048978822, 9)"
|
||||
",(4, 1067122822, 8) ,(4, 1080428422, 9)"
|
||||
",(4, 1099177222, 8) ,(4, 1111878022, 9)"
|
||||
",(4, 1130626822, 8) ,(4, 1143327622, 9)"
|
||||
",(4, 1162076422, 8) ,(4, 1174777222, 9)"
|
||||
",(4, 1193526022, 8) ,(4, 1206831622, 9)"
|
||||
",(4, 1224975622, 8) ,(4, 1238281222, 9)"
|
||||
",(4, 1256425222, 8) ,(4, 1269730822, 9)"
|
||||
",(4, 1288479622, 8) ,(4, 1301180422, 9)"
|
||||
",(4, 1319929222, 8) ,(4, 1332630022, 9)"
|
||||
",(4, 1351378822, 8) ,(4, 1364684422, 9)"
|
||||
",(4, 1382828422, 8) ,(4, 1396134022, 9)"
|
||||
",(4, 1414278022, 8) ,(4, 1427583622, 9)"
|
||||
",(4, 1445727622, 8) ,(4, 1459033222, 9)"
|
||||
",(4, 1477782022, 8) ,(4, 1490482822, 9)"
|
||||
",(4, 1509231622, 8) ,(4, 1521932422, 9)"
|
||||
",(4, 1540681222, 8) ,(4, 1553986822, 9)"
|
||||
",(4, 1572130822, 8) ,(4, 1585436422, 9)"
|
||||
",(4, 1603580422, 8) ,(4, 1616886022, 9)"
|
||||
",(4, 1635634822, 8) ,(4, 1648335622, 9)"
|
||||
",(4, 1667084422, 8) ,(4, 1679785222, 9)"
|
||||
",(4, 1698534022, 8) ,(4, 1711839622, 9)"
|
||||
",(4, 1729983622, 8) ,(4, 1743289222, 9)"
|
||||
",(4, 1761433222, 8) ,(4, 1774738822, 9)"
|
||||
",(4, 1792882822, 8) ,(4, 1806188422, 9)"
|
||||
",(4, 1824937222, 8) ,(4, 1837638022, 9)"
|
||||
",(4, 1856386822, 8) ,(4, 1869087622, 9)"
|
||||
",(4, 1887836422, 8) ,(4, 1901142022, 9)"
|
||||
",(4, 1919286022, 8) ,(4, 1932591622, 9)"
|
||||
",(4, 1950735622, 8) ,(4, 1964041222, 9)"
|
||||
",(4, 1982790022, 8) ,(4, 1995490822, 9)"
|
||||
",(4, 2014239622, 8) ,(4, 2026940422, 9)"
|
||||
",(4, 2045689222, 8) ,(4, 2058390022, 9)"
|
||||
",(4, 2077138822, 8) ,(4, 2090444422, 9)"
|
||||
",(4, 2108588422, 8) ,(4, 2121894022, 9)"
|
||||
",(4, 2140038022, 8), (5, -1009875600, 1);\n");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (test_sys_file(mdata,"mysql/time_zone_transition_type.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE time_zone_transition_type ("
|
||||
"Time_zone_id int unsigned NOT NULL,"
|
||||
"Transition_type_id int unsigned NOT NULL,"
|
||||
"Offset int signed DEFAULT 0 NOT NULL,"
|
||||
"Is_DST tinyint unsigned DEFAULT 0 NOT NULL,"
|
||||
"Abbreviation char(8) DEFAULT '' NOT NULL,"
|
||||
"PRIMARY KEY TzIdTrTId (Time_zone_id, Transition_type_id)"
|
||||
") engine=MyISAM CHARACTER SET utf8 "
|
||||
"comment='Time zone transition types';\n");
|
||||
|
||||
if (test)
|
||||
{
|
||||
fprintf(out,
|
||||
"INSERT INTO time_zone_transition_type (Time_zone_id,"
|
||||
"Transition_type_id, Offset, Is_DST, Abbreviation) VALUES"
|
||||
"(1, 0, 7200, 1, 'MEST') ,(1, 1, 3600, 0, 'MET')"
|
||||
",(1, 2, 7200, 1, 'MEST') ,(1, 3, 3600, 0, 'MET')"
|
||||
",(2, 0, 0, 0, 'UTC')"
|
||||
",(3, 0, 9000, 0, 'MMT') ,(3, 1, 12648, 1, 'MST')"
|
||||
",(3, 2, 9048, 0, 'MMT') ,(3, 3, 16248, 1, 'MDST')"
|
||||
",(3, 4, 10800, 0, 'MSK') ,(3, 5, 14400, 1, 'MSD')"
|
||||
",(3, 6, 18000, 1, 'MSD') ,(3, 7, 7200, 0, 'EET')"
|
||||
",(3, 8, 10800, 0, 'MSK') ,(3, 9, 14400, 1, 'MSD')"
|
||||
",(3, 10, 10800, 1, 'EEST') ,(3, 11, 7200, 0, 'EET')"
|
||||
",(4, 0, 9000, 0, 'MMT') ,(4, 1, 12648, 1, 'MST')"
|
||||
",(4, 2, 9048, 0, 'MMT') ,(4, 3, 16248, 1, 'MDST')"
|
||||
",(4, 4, 10800, 0, 'MSK') ,(4, 5, 14400, 1, 'MSD')"
|
||||
",(4, 6, 18000, 1, 'MSD') ,(4, 7, 7200, 0, 'EET')"
|
||||
",(4, 8, 10800, 0, 'MSK') ,(4, 9, 14400, 1, 'MSD')"
|
||||
",(4, 10, 10800, 1, 'EEST') ,(4, 11, 7200, 0, 'EET')"
|
||||
",(5, 0, 32400, 0, 'CJT') ,(5, 1, 32400, 0, 'JST');\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (test_sys_file(mdata,"mysql/time_zone_leap_second.frm"))
|
||||
{
|
||||
fprintf(out,
|
||||
"CREATE TABLE time_zone_leap_second ("
|
||||
"Transition_time bigint signed NOT NULL,"
|
||||
"Correction int signed NOT NULL,"
|
||||
"PRIMARY KEY TranTime (Transition_time)"
|
||||
") engine=MyISAM CHARACTER SET utf8 "
|
||||
"comment='Leap seconds information for time zones';\n");
|
||||
|
||||
if (test)
|
||||
{
|
||||
fprintf(out,
|
||||
"INSERT INTO time_zone_leap_second "
|
||||
"(Transition_time, Correction) VALUES "
|
||||
"(78796800, 1) ,(94694401, 2) ,(126230402, 3)"
|
||||
",(157766403, 4) ,(189302404, 5) ,(220924805, 6)"
|
||||
",(252460806, 7) ,(283996807, 8) ,(315532808, 9)"
|
||||
",(362793609, 10) ,(394329610, 11) ,(425865611, 12)"
|
||||
",(489024012, 13) ,(567993613, 14) ,(631152014, 15)"
|
||||
",(662688015, 16) ,(709948816, 17) ,(741484817, 18)"
|
||||
",(773020818, 19) ,(820454419, 20) ,(867715220, 21)"
|
||||
",(915148821, 22);\n");
|
||||
}
|
||||
}
|
||||
|
||||
return fclose(out);
|
||||
}
|
887
mysql-test/my_manage.c
Normal file
887
mysql-test/my_manage.c
Normal file
@ -0,0 +1,887 @@
|
||||
/*
|
||||
Copyright (c) 2003 Novell, Inc. All Rights Reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#ifndef __WIN__
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#ifdef __NETWARE__
|
||||
#include <screen.h>
|
||||
#include <proc.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#ifndef __WIN__
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <fnmatch.h> /* FIXME HAVE_FNMATCH_H or something */
|
||||
#else
|
||||
#include <direct.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "my_manage.h"
|
||||
|
||||
#ifndef __NETWARE__
|
||||
#define ASSERT assert
|
||||
extern char **environ;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
macros
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
global variables
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
functions
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
init_args()
|
||||
|
||||
Init an argument list.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
void init_args(arg_list_t *al)
|
||||
{
|
||||
ASSERT(al != NULL);
|
||||
|
||||
al->argc= 0;
|
||||
al->size= ARG_BUF;
|
||||
al->argv= malloc(al->size * sizeof(char *));
|
||||
ASSERT(al->argv != NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
add_arg()
|
||||
|
||||
Add an argument to a list.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
void add_arg(arg_list_t *al, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char temp[FN_REFLEN];
|
||||
|
||||
ASSERT(al != NULL);
|
||||
|
||||
/* increase size */
|
||||
if (al->argc >= (int)al->size)
|
||||
{
|
||||
al->size+= ARG_BUF;
|
||||
al->argv= realloc(al->argv, al->size * sizeof(char *));
|
||||
ASSERT(al->argv != NULL);
|
||||
}
|
||||
|
||||
if (format)
|
||||
{
|
||||
va_start(ap, format);
|
||||
vsprintf(temp, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
al->argv[al->argc]= malloc(strlen(temp)+1);
|
||||
ASSERT(al->argv[al->argc] != NULL);
|
||||
strcpy(al->argv[al->argc], temp);
|
||||
|
||||
++(al->argc);
|
||||
}
|
||||
else
|
||||
{
|
||||
al->argv[al->argc]= NULL;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
free_args()
|
||||
|
||||
Free an argument list.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
void free_args(arg_list_t *al)
|
||||
{
|
||||
int i;
|
||||
|
||||
ASSERT(al != NULL);
|
||||
|
||||
for (i= 0; i < al->argc; i++)
|
||||
{
|
||||
ASSERT(al->argv[i] != NULL);
|
||||
free(al->argv[i]);
|
||||
al->argv[i]= NULL;
|
||||
}
|
||||
|
||||
free(al->argv);
|
||||
al->argc= 0;
|
||||
al->argv= NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
sleep_until_file_deleted()
|
||||
|
||||
Sleep until the given file is no longer found.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __WIN__
|
||||
int sleep_until_file_deleted(char *pid_file)
|
||||
#else
|
||||
int sleep_until_file_deleted(HANDLE pid_file)
|
||||
#endif
|
||||
{
|
||||
int err= 0; /* Initiate to supress warning */
|
||||
#ifndef __WIN__
|
||||
struct stat buf;
|
||||
int i;
|
||||
|
||||
for (i= 0; (i < TRY_MAX) && (err= !stat(pid_file, &buf)); i++) sleep(1);
|
||||
|
||||
if (err != 0) err= errno;
|
||||
#else
|
||||
err= (WaitForSingleObject(pid_file, TRY_MAX*1000) == WAIT_TIMEOUT);
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
sleep_until_file_exists()
|
||||
|
||||
Sleep until the given file exists.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __WIN__
|
||||
int sleep_until_file_exists(char *pid_file)
|
||||
#else
|
||||
int sleep_until_file_exists(HANDLE pid_file)
|
||||
#endif
|
||||
{
|
||||
int err= 0; /* Initiate to supress warning */
|
||||
#ifndef __WIN__
|
||||
struct stat buf;
|
||||
int i;
|
||||
|
||||
for (i= 0; (i < TRY_MAX) && (err= stat(pid_file, &buf)); i++) sleep(1);
|
||||
|
||||
if (err != 0) err= errno;
|
||||
#else
|
||||
err= (WaitForSingleObject(pid_file, TRY_MAX*1000) == WAIT_TIMEOUT);
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
wait_for_server_start()
|
||||
|
||||
Wait for the server on the given port to start.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
int wait_for_server_start(char *bin_dir __attribute__((unused)),
|
||||
char *mysqladmin_file,
|
||||
char *user, char *password, int port,char *tmp_dir)
|
||||
{
|
||||
arg_list_t al;
|
||||
int err= 0, i;
|
||||
char trash[FN_REFLEN];
|
||||
|
||||
/* mysqladmin file */
|
||||
snprintf(trash, FN_REFLEN, "%s/trash.out",tmp_dir);
|
||||
|
||||
/* args */
|
||||
init_args(&al);
|
||||
add_arg(&al, "%s", mysqladmin_file);
|
||||
add_arg(&al, "--no-defaults");
|
||||
add_arg(&al, "--port=%u", port);
|
||||
add_arg(&al, "--user=%s", user);
|
||||
add_arg(&al, "--password=%s", password);
|
||||
add_arg(&al, "--silent");
|
||||
|
||||
/* #ifdef NOT_USED */
|
||||
#ifndef __NETWARE__
|
||||
add_arg(&al, "-O");
|
||||
add_arg(&al, "connect_timeout=10");
|
||||
add_arg(&al, "-w");
|
||||
#endif
|
||||
|
||||
add_arg(&al, "--host=localhost");
|
||||
#ifndef __NETWARE__
|
||||
add_arg(&al, "--protocol=tcp");
|
||||
#endif
|
||||
add_arg(&al, "ping");
|
||||
|
||||
/*
|
||||
NetWare does not support the connect timeout in the TCP/IP stack
|
||||
-- we will try the ping multiple times
|
||||
*/
|
||||
#ifndef __WIN__
|
||||
for (i= 0; (i < TRY_MAX)
|
||||
&& (err= spawn(mysqladmin_file, &al, TRUE, NULL,
|
||||
trash, NULL, NULL)); i++) sleep(1);
|
||||
#else
|
||||
err= spawn(mysqladmin_file, &al, TRUE, NULL,trash, NULL, NULL);
|
||||
#endif
|
||||
|
||||
/* free args */
|
||||
free_args(&al);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
spawn()
|
||||
|
||||
Spawn the given path with the given arguments.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __NETWARE__
|
||||
int spawn(char *path, arg_list_t *al, int join, char *input,
|
||||
char *output, char *error, char *pid_file)
|
||||
{
|
||||
pid_t pid;
|
||||
int result= 0;
|
||||
wiring_t wiring= { FD_UNUSED, FD_UNUSED, FD_UNUSED };
|
||||
unsigned long flags= PROC_CURRENT_SPACE | PROC_INHERIT_CWD;
|
||||
|
||||
/* open wiring */
|
||||
if (input)
|
||||
wiring.infd= open(input, O_RDONLY);
|
||||
|
||||
if (output)
|
||||
wiring.outfd= open(output, O_WRONLY | O_CREAT | O_TRUNC);
|
||||
|
||||
if (error)
|
||||
wiring.errfd= open(error, O_WRONLY | O_CREAT | O_TRUNC);
|
||||
|
||||
/* procve requires a NULL */
|
||||
add_arg(al, NULL);
|
||||
|
||||
/* go */
|
||||
pid= procve(path, flags, NULL, &wiring, NULL, NULL, 0,
|
||||
NULL, (const char **)al->argv);
|
||||
|
||||
/* close wiring */
|
||||
if (wiring.infd != -1)
|
||||
close(wiring.infd);
|
||||
|
||||
if (wiring.outfd != -1)
|
||||
close(wiring.outfd);
|
||||
|
||||
if (wiring.errfd != -1)
|
||||
close(wiring.errfd);
|
||||
|
||||
return result;
|
||||
}
|
||||
#elif __WIN__
|
||||
|
||||
int spawn(char *path, arg_list_t *al, int join, char *input,
|
||||
char *output, char *error, HANDLE *pid)
|
||||
{
|
||||
bool result;
|
||||
int i;
|
||||
STARTUPINFO startup_info;
|
||||
PROCESS_INFORMATION process_information;
|
||||
DWORD exit_code;
|
||||
char win_args[1024]= "";
|
||||
|
||||
/* Skip the first parameter */
|
||||
for (i= 1; i < al->argc; i++)
|
||||
{
|
||||
ASSERT(al->argv[i] != NULL);
|
||||
strcat(win_args,al->argv[i]);
|
||||
strcat(win_args," ");
|
||||
}
|
||||
|
||||
memset(&startup_info,0,sizeof(STARTUPINFO));
|
||||
startup_info.cb= sizeof(STARTUPINFO);
|
||||
|
||||
if (input)
|
||||
freopen(input, "rb", stdin);
|
||||
|
||||
if (output)
|
||||
freopen(output, "wb", stdout);
|
||||
|
||||
if (error)
|
||||
freopen(error, "wb", stderr);
|
||||
|
||||
result= CreateProcess(
|
||||
path,
|
||||
(LPSTR)&win_args,
|
||||
NULL,
|
||||
NULL,
|
||||
TRUE,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
&startup_info,
|
||||
&process_information
|
||||
);
|
||||
|
||||
if (result && process_information.hProcess)
|
||||
{
|
||||
if (join)
|
||||
{
|
||||
if (WaitForSingleObject(process_information.hProcess, mysqld_timeout)
|
||||
== WAIT_TIMEOUT)
|
||||
{
|
||||
exit_code= -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
GetExitCodeProcess(process_information.hProcess, &exit_code);
|
||||
}
|
||||
CloseHandle(process_information.hProcess);
|
||||
}
|
||||
else
|
||||
{
|
||||
exit_code= 0;
|
||||
}
|
||||
if (pid != NULL)
|
||||
*pid= process_information.hProcess;
|
||||
}
|
||||
else
|
||||
{
|
||||
exit_code= -1;
|
||||
}
|
||||
if (input)
|
||||
freopen("CONIN$","rb",stdin);
|
||||
if (output)
|
||||
freopen("CONOUT$","wb",stdout);
|
||||
if (error)
|
||||
freopen("CONOUT$","wb",stderr);
|
||||
|
||||
return exit_code;
|
||||
}
|
||||
#else
|
||||
int spawn(char *path, arg_list_t *al, int join, char *input,
|
||||
char *output, char *error, char *pid_file __attribute__((unused)))
|
||||
{
|
||||
pid_t pid;
|
||||
int res_exec= 0;
|
||||
int result= 0;
|
||||
|
||||
pid= fork();
|
||||
|
||||
if (pid == -1)
|
||||
{
|
||||
fprintf(stderr, "fork was't created\n");
|
||||
/* We can't create the fork...exit with error */
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (pid > 0)
|
||||
{
|
||||
/* The parent process is waiting for child process if join is not zero */
|
||||
if (join)
|
||||
{
|
||||
waitpid(pid, &result, 0);
|
||||
if (WIFEXITED(result) != 0)
|
||||
{
|
||||
result= WEXITSTATUS(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result= EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Child process */
|
||||
add_arg(al, NULL);
|
||||
|
||||
/* Reassign streams */
|
||||
if (input)
|
||||
freopen(input, "r", stdin);
|
||||
|
||||
if (output)
|
||||
freopen(output, "w", stdout);
|
||||
|
||||
if (error)
|
||||
freopen(error, "w", stderr);
|
||||
|
||||
/* Spawn the process */
|
||||
if ((res_exec= execve(path, al->argv, environ)) < 0)
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
/* Restore streams */
|
||||
if (input)
|
||||
freopen("/dev/tty", "r", stdin);
|
||||
|
||||
if (output)
|
||||
freopen("/dev/tty", "w", stdout);
|
||||
|
||||
if (error)
|
||||
freopen("/dev/tty", "w", stderr);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
/******************************************************************************
|
||||
|
||||
stop_server()
|
||||
|
||||
Stop the server with the given port and pid file.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
int stop_server(char *bin_dir __attribute__((unused)), char *mysqladmin_file,
|
||||
char *user, char *password, int port,
|
||||
#ifndef __WIN__
|
||||
char *pid_file,
|
||||
#else
|
||||
HANDLE pid_file,
|
||||
#endif
|
||||
char *tmp_dir)
|
||||
{
|
||||
arg_list_t al;
|
||||
int err= 0;
|
||||
char trash[FN_REFLEN];
|
||||
|
||||
snprintf(trash, FN_REFLEN, "%s/trash.out",tmp_dir);
|
||||
|
||||
/* args */
|
||||
init_args(&al);
|
||||
add_arg(&al, "%s", mysqladmin_file);
|
||||
add_arg(&al, "--no-defaults");
|
||||
add_arg(&al, "--port=%u", port);
|
||||
add_arg(&al, "--user=%s", user);
|
||||
add_arg(&al, "--password=%s", password);
|
||||
add_arg(&al, "-O");
|
||||
add_arg(&al, "shutdown_timeout=20");
|
||||
#ifndef __NETWARE__
|
||||
add_arg(&al, "--protocol=tcp");
|
||||
#endif
|
||||
add_arg(&al, "shutdown");
|
||||
|
||||
/* spawn */
|
||||
if ((err= spawn(mysqladmin_file, &al, TRUE, NULL,
|
||||
trash, NULL, NULL)) == 0)
|
||||
{
|
||||
sleep_until_file_deleted(pid_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef __WIN__
|
||||
pid_t pid= get_server_pid(pid_file);
|
||||
|
||||
/* shutdown failed - kill server */
|
||||
kill_server(pid);
|
||||
|
||||
sleep(TRY_MAX);
|
||||
|
||||
/* remove pid file if possible */
|
||||
err= remove(pid_file);
|
||||
#else
|
||||
TerminateProcess(pid_file,err);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* free args */
|
||||
free_args(&al);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
get_server_pid()
|
||||
|
||||
Get the VM id with the given pid file.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __WIN__
|
||||
pid_t get_server_pid(char *pid_file)
|
||||
{
|
||||
char buf[FN_REFLEN];
|
||||
int fd, err;
|
||||
char *p;
|
||||
pid_t id= 0;
|
||||
|
||||
/* discover id */
|
||||
fd= open(pid_file, O_RDONLY);
|
||||
|
||||
err= read(fd, buf, FN_REFLEN);
|
||||
|
||||
close(fd);
|
||||
|
||||
if (err > 0)
|
||||
{
|
||||
/* terminate string */
|
||||
if ((p= strchr(buf, '\n')) != NULL)
|
||||
{
|
||||
*p= '\0';
|
||||
|
||||
/* check for a '\r' */
|
||||
if ((p= strchr(buf, '\r')) != NULL)
|
||||
{
|
||||
*p= '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[err]= '\0';
|
||||
}
|
||||
|
||||
id= strtol(buf, NULL, 0);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
kill_server()
|
||||
|
||||
Force a kill of the server with the given pid.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
void kill_server(pid_t pid)
|
||||
{
|
||||
if (pid > 0)
|
||||
{
|
||||
#if !defined(__NETWARE__)
|
||||
/* Send SIGTERM to pid */
|
||||
kill(pid, SIGTERM);
|
||||
#else /* __NETWARE__ */
|
||||
/* destroy vm */
|
||||
NXVmDestroy(pid);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/******************************************************************************
|
||||
|
||||
del_tree()
|
||||
|
||||
Delete the directory and subdirectories.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
void del_tree(char *dir)
|
||||
{
|
||||
#ifndef __WIN__
|
||||
DIR *parent= opendir(dir);
|
||||
struct dirent *entry;
|
||||
char temp[FN_REFLEN];
|
||||
|
||||
if (parent == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while ((entry= readdir(parent)) != NULL)
|
||||
{
|
||||
/* create long name */
|
||||
snprintf(temp, FN_REFLEN, "%s/%s", dir, entry->d_name);
|
||||
|
||||
if (entry->d_name[0] == '.')
|
||||
{
|
||||
/* Skip */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME missing test in acinclude.m4 */
|
||||
#ifndef STRUCT_DIRENT_HAS_D_TYPE
|
||||
struct stat st;
|
||||
|
||||
if (lstat(entry->d_name, &st) == -1)
|
||||
{
|
||||
/* FIXME error */
|
||||
return;
|
||||
}
|
||||
if (S_ISDIR(st.st_mode))
|
||||
#else
|
||||
if (S_ISDIR(entry->d_type))
|
||||
#endif
|
||||
{
|
||||
/* delete subdirectory */
|
||||
del_tree(temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* remove file */
|
||||
remove(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* remove directory */
|
||||
rmdir(dir);
|
||||
#else
|
||||
struct _finddata_t parent;
|
||||
#if defined(_MSC_VER) && _MSC_VER > 1200
|
||||
intptr_t handle;
|
||||
#else
|
||||
long handle;
|
||||
#endif /* _MSC_VER && _MSC_VER > 1200 */
|
||||
char temp[FN_REFLEN];
|
||||
char mask[FN_REFLEN];
|
||||
|
||||
snprintf(mask,FN_REFLEN,"%s/*.*",dir);
|
||||
|
||||
if ((handle=_findfirst(mask,&parent)) == -1L)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
/* create long name */
|
||||
snprintf(temp, FN_REFLEN, "%s/%s", dir, parent.name);
|
||||
if (parent.name[0] == '.')
|
||||
{
|
||||
/* Skip */
|
||||
}
|
||||
else
|
||||
if (parent.attrib & _A_SUBDIR)
|
||||
{
|
||||
/* delete subdirectory */
|
||||
del_tree(temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* remove file */
|
||||
remove(temp);
|
||||
}
|
||||
} while (_findnext(handle,&parent) == 0);
|
||||
|
||||
_findclose(handle);
|
||||
|
||||
/* remove directory */
|
||||
_rmdir(dir);
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
removef()
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
int removef(const char *format, ...)
|
||||
{
|
||||
#ifdef __NETWARE__
|
||||
va_list ap;
|
||||
char path[FN_REFLEN];
|
||||
|
||||
va_start(ap, format);
|
||||
|
||||
vsnprintf(path, FN_REFLEN, format, ap);
|
||||
|
||||
va_end(ap);
|
||||
return remove(path);
|
||||
|
||||
#elif __WIN__
|
||||
{
|
||||
va_list ap;
|
||||
char path[FN_REFLEN];
|
||||
struct _finddata_t parent;
|
||||
#if defined(_MSC_VER) && _MSC_VER > 1200
|
||||
intptr_t handle;
|
||||
#else
|
||||
long handle;
|
||||
#endif /* _MSC_VER && _MSC_VER > 1200 */
|
||||
char temp[FN_REFLEN];
|
||||
char *p;
|
||||
|
||||
va_start(ap, format);
|
||||
|
||||
vsnprintf(path, FN_REFLEN, format, ap);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
p= path + strlen(path);
|
||||
while (*p != '\\' && *p != '/' && p > path) p--;
|
||||
|
||||
if ((handle=_findfirst(path,&parent)) == -1L)
|
||||
{
|
||||
/* if there is not files....it's ok */
|
||||
return 0;
|
||||
}
|
||||
|
||||
*p= '\0';
|
||||
|
||||
do
|
||||
{
|
||||
if (! (parent.attrib & _A_SUBDIR))
|
||||
{
|
||||
snprintf(temp, FN_REFLEN, "%s/%s", path, parent.name);
|
||||
remove(temp);
|
||||
}
|
||||
}while (_findnext(handle,&parent) == 0);
|
||||
|
||||
_findclose(handle);
|
||||
}
|
||||
#else
|
||||
DIR *parent;
|
||||
struct dirent *entry;
|
||||
char temp[FN_REFLEN];
|
||||
va_list ap;
|
||||
char path[FN_REFLEN];
|
||||
char *p;
|
||||
/* Get path with mask */
|
||||
va_start(ap, format);
|
||||
|
||||
vsnprintf(path, FN_REFLEN, format, ap);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
p= path + strlen(path);
|
||||
while (*p != '\\' && *p != '/' && p > path) p--;
|
||||
*p= '\0';
|
||||
p++;
|
||||
|
||||
parent= opendir(path);
|
||||
|
||||
if (parent == NULL)
|
||||
{
|
||||
return 1; /* Error, directory missing */
|
||||
}
|
||||
|
||||
while ((entry= readdir(parent)) != NULL)
|
||||
{
|
||||
/* entry is not directory and entry matches with mask */
|
||||
#ifndef STRUCT_DIRENT_HAS_D_TYPE
|
||||
struct stat st;
|
||||
|
||||
/* create long name */
|
||||
snprintf(temp, FN_REFLEN, "%s/%s", path, entry->d_name);
|
||||
|
||||
if (lstat(temp, &st) == -1)
|
||||
{
|
||||
return 1; /* Error couldn't lstat file */
|
||||
}
|
||||
|
||||
if (!S_ISDIR(st.st_mode) && !fnmatch(p, entry->d_name,0))
|
||||
#else
|
||||
if (!S_ISDIR(entry->d_type) && !fnmatch(p, entry->d_name,0))
|
||||
#endif
|
||||
{
|
||||
/* create long name */
|
||||
snprintf(temp, FN_REFLEN, "%s/%s", path, entry->d_name);
|
||||
/* Delete only files */
|
||||
remove(temp);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
get_basedir()
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
void get_basedir(char *argv0, char *basedir)
|
||||
{
|
||||
char temp[FN_REFLEN];
|
||||
char *p;
|
||||
int position;
|
||||
|
||||
ASSERT(argv0 != NULL);
|
||||
ASSERT(basedir != NULL);
|
||||
|
||||
strcpy(temp, strlwr(argv0));
|
||||
while ((p= strchr(temp, '\\')) != NULL) *p= '/';
|
||||
|
||||
if ((position= strinstr(temp, "/bin/")) != 0)
|
||||
{
|
||||
p= temp + position;
|
||||
*p= '\0';
|
||||
strcpy(basedir, temp);
|
||||
}
|
||||
}
|
||||
|
||||
uint strinstr(reg1 const char *str,reg4 const char *search)
|
||||
{
|
||||
reg2 my_string i,j;
|
||||
my_string start= (my_string) str;
|
||||
|
||||
skipp:
|
||||
while (*str != '\0')
|
||||
{
|
||||
if (*str++ == *search)
|
||||
{
|
||||
i=(my_string) str;
|
||||
j= (my_string) search+1;
|
||||
while (*j)
|
||||
if (*i++ != *j++) goto skipp;
|
||||
return ((uint) (str - start));
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
remove_empty_file()
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
void remove_empty_file(const char *file_name)
|
||||
{
|
||||
struct stat file;
|
||||
|
||||
if (!stat(file_name,&file))
|
||||
{
|
||||
if (!file.st_size)
|
||||
remove(file_name);
|
||||
}
|
||||
}
|
137
mysql-test/my_manage.h
Normal file
137
mysql-test/my_manage.h
Normal file
@ -0,0 +1,137 @@
|
||||
/*
|
||||
Copyright (c) 2002 Novell, Inc. All Rights Reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _MY_MANAGE
|
||||
#define _MY_MANAGE
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
includes
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifndef __WIN__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifndef __NETWARE__
|
||||
#include <string.h>
|
||||
#include <my_global.h>
|
||||
#include <m_string.h>
|
||||
|
||||
#ifndef __WIN__
|
||||
#define strnicmp strncasecmp
|
||||
#define strlwr(STRARG) (STRARG)
|
||||
#else
|
||||
int my_vsnprintf_(char *to, size_t n, const char* value, ...);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
macros
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#define ARG_BUF 10
|
||||
#define TRY_MAX 5
|
||||
|
||||
#ifdef __WIN__
|
||||
#define PATH_MAX _MAX_PATH
|
||||
#define NAME_MAX _MAX_FNAME
|
||||
#define kill(A,B) TerminateProcess((HANDLE)A,0)
|
||||
#define NOT_NEED_PID 0
|
||||
#define MASTER_PID 1
|
||||
#define SLAVE_PID 2
|
||||
#define mysqld_timeout 60000
|
||||
|
||||
int pid_mode;
|
||||
bool run_server;
|
||||
bool skip_first_param;
|
||||
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
structures
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
size_t size;
|
||||
|
||||
} arg_list_t;
|
||||
|
||||
#ifdef __WIN__
|
||||
typedef int pid_t;
|
||||
#endif
|
||||
/******************************************************************************
|
||||
|
||||
global variables
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
prototypes
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
void init_args(arg_list_t *);
|
||||
void add_arg(arg_list_t *, const char *, ...);
|
||||
void free_args(arg_list_t *);
|
||||
|
||||
#ifndef __WIN__
|
||||
int sleep_until_file_exists(char *);
|
||||
int sleep_until_file_deleted(char *);
|
||||
#else
|
||||
int sleep_until_file_exists(HANDLE);
|
||||
int sleep_until_file_deleted(HANDLE);
|
||||
#endif
|
||||
int wait_for_server_start(char *, char *, char *, char *, int,char *);
|
||||
|
||||
#ifndef __WIN__
|
||||
int spawn(char *, arg_list_t *, int, char *, char *, char *, char *);
|
||||
#else
|
||||
int spawn(char *, arg_list_t *, int , char *, char *, char *, HANDLE *);
|
||||
#endif
|
||||
|
||||
#ifndef __WIN__
|
||||
int stop_server(char *, char *, char *, char *, int, char *,char *);
|
||||
pid_t get_server_pid(char *);
|
||||
void kill_server(pid_t pid);
|
||||
#else
|
||||
int stop_server(char *, char *, char *, char *, int, HANDLE,char *);
|
||||
#endif
|
||||
void del_tree(char *);
|
||||
int removef(const char *, ...);
|
||||
|
||||
void get_basedir(char *, char *);
|
||||
void remove_empty_file(const char *file_name);
|
||||
|
||||
bool create_system_files(const char *mdata,const char *output_file, bool test);
|
||||
|
||||
#endif /* _MY_MANAGE */
|
2190
mysql-test/mysql-test-run.pl
Executable file
2190
mysql-test/mysql-test-run.pl
Executable file
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,7 @@
|
||||
# Slightly updated by Monty
|
||||
# Cleaned up again by Matt
|
||||
# Fixed by Sergei
|
||||
# List of failed cases (--force) backported from 4.1 by Joerg
|
||||
# :-)
|
||||
|
||||
#++
|
||||
@ -193,8 +194,8 @@ MY_LOG_DIR="$MYSQL_TEST_DIR/var/log"
|
||||
#
|
||||
# Set LD_LIBRARY_PATH if we are using shared libraries
|
||||
#
|
||||
LD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$LD_LIBRARY_PATH"
|
||||
DYLD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$DYLD_LIBRARY_PATH"
|
||||
LD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$BASEDIR/zlib/.libs:$LD_LIBRARY_PATH"
|
||||
DYLD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$BASEDIR/zlib/.libs:$DYLD_LIBRARY_PATH"
|
||||
export LD_LIBRARY_PATH DYLD_LIBRARY_PATH
|
||||
|
||||
MASTER_RUNNING=0
|
||||
@ -219,6 +220,8 @@ EXTRA_MYSQLBINLOG_OPT=""
|
||||
USE_RUNNING_SERVER=""
|
||||
USE_NDBCLUSTER=""
|
||||
USE_RUNNING_NDBCLUSTER=""
|
||||
USE_PURIFY=""
|
||||
PURIFY_LOGS=""
|
||||
DO_GCOV=""
|
||||
DO_GDB=""
|
||||
MANUAL_GDB=""
|
||||
@ -227,7 +230,7 @@ DO_CLIENT_GDB=""
|
||||
SLEEP_TIME_AFTER_RESTART=1
|
||||
SLEEP_TIME_FOR_DELETE=10
|
||||
SLEEP_TIME_FOR_FIRST_MASTER=400 # Enough time to create innodb tables
|
||||
SLEEP_TIME_FOR_SECOND_MASTER=30
|
||||
SLEEP_TIME_FOR_SECOND_MASTER=400
|
||||
SLEEP_TIME_FOR_FIRST_SLAVE=400
|
||||
SLEEP_TIME_FOR_SECOND_SLAVE=30
|
||||
CHARACTER_SET=latin1
|
||||
@ -238,11 +241,25 @@ MYSQL_TEST_SSL_OPTS=""
|
||||
USE_TIMER=""
|
||||
USE_EMBEDDED_SERVER=""
|
||||
RESULT_EXT=""
|
||||
TEST_MODE=""
|
||||
|
||||
NDB_MGM_EXTRA_OPTS=
|
||||
NDB_MGMD_EXTRA_OPTS=
|
||||
NDBD_EXTRA_OPTS=
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
--embedded-server) USE_EMBEDDED_SERVER=1 ; USE_MANAGER=0 ; NO_SLAVE=1 ; \
|
||||
USE_RUNNING_SERVER="" RESULT_EXT=".es" ;;
|
||||
--embedded-server)
|
||||
USE_EMBEDDED_SERVER=1
|
||||
USE_MANAGER=0 NO_SLAVE=1
|
||||
USE_RUNNING_SERVER=""
|
||||
RESULT_EXT=".es"
|
||||
TEST_MODE="$TEST_MODE embedded" ;;
|
||||
--purify)
|
||||
USE_PURIFY=1
|
||||
USE_MANAGER=0
|
||||
USE_RUNNING_SERVER=""
|
||||
TEST_MODE="$TEST_MODE purify" ;;
|
||||
--user=*) DBUSER=`$ECHO "$1" | $SED -e "s;--user=;;"` ;;
|
||||
--force) FORCE=1 ;;
|
||||
--timer) USE_TIMER=1 ;;
|
||||
@ -259,6 +276,12 @@ while test $# -gt 0; do
|
||||
--ndb-connectstring=*)
|
||||
USE_NDBCLUSTER="--ndbcluster" ;
|
||||
USE_RUNNING_NDBCLUSTER=`$ECHO "$1" | $SED -e "s;--ndb-connectstring=;;"` ;;
|
||||
--ndb_mgm-extra-opts=*)
|
||||
NDB_MGM_EXTRA_OPTS=`$ECHO "$1" | $SED -e "s;--ndb_mgm-extra-opts=;;"` ;;
|
||||
--ndb_mgmd-extra-opts=*)
|
||||
NDB_MGMD_EXTRA_OPTS=`$ECHO "$1" | $SED -e "s;--ndb_mgmd-extra-opts=;;"` ;;
|
||||
--ndbd-extra-opts=*)
|
||||
NDBD_EXTRA_OPTS=`$ECHO "$1" | $SED -e "s;--ndbd-extra-opts=;;"` ;;
|
||||
--tmpdir=*) MYSQL_TMP_DIR=`$ECHO "$1" | $SED -e "s;--tmpdir=;;"` ;;
|
||||
--local-master)
|
||||
MASTER_MYPORT=3306;
|
||||
@ -322,7 +345,7 @@ while test $# -gt 0; do
|
||||
SLEEP_TIME_AFTER_RESTART=`$ECHO "$1" | $SED -e "s;--sleep=;;"`
|
||||
;;
|
||||
--ps-protocol)
|
||||
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;;
|
||||
TEST_MODE="$TEST_MODE ps-protocol" EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;;
|
||||
--user-test=*)
|
||||
USER_TEST=`$ECHO "$1" | $SED -e "s;--user-test=;;"`
|
||||
;;
|
||||
@ -421,6 +444,7 @@ while test $# -gt 0; do
|
||||
--debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysqldump.trace"
|
||||
EXTRA_MYSQLBINLOG_OPT="$EXTRA_MYSQLBINLOG_OPT \
|
||||
--debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysqlbinlog.trace"
|
||||
EXTRA_MYSQL_CLIENT_TEST_OPT="--debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysql_client_test.trace"
|
||||
;;
|
||||
--fast)
|
||||
FAST_START=1
|
||||
@ -432,6 +456,13 @@ while test $# -gt 0; do
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$TEST_MODE" ] ; then
|
||||
TEST_MODE="default"
|
||||
else
|
||||
# Remove the leading space if any
|
||||
TEST_MODE=`echo $TEST_MODE | sed 's/^ *//'`
|
||||
fi
|
||||
|
||||
#++
|
||||
# mysqld Environment Parameters
|
||||
#--
|
||||
@ -457,6 +488,11 @@ SMALL_SERVER="--key_buffer_size=1M --sort_buffer=256K --max_heap_table_size=1M"
|
||||
|
||||
export MASTER_MYPORT MASTER_MYPORT1 SLAVE_MYPORT MYSQL_TCP_PORT MASTER_MYSOCK MASTER_MYSOCK1
|
||||
|
||||
NDBCLUSTER_BASE_PORT=`expr $NDBCLUSTER_PORT + 2`
|
||||
NDBCLUSTER_OPTS="--port=$NDBCLUSTER_PORT --port-base=$NDBCLUSTER_BASE_PORT --data-dir=$MYSQL_TEST_DIR/var --ndb_mgm-extra-opts=$NDB_MGM_EXTRA_OPTS --ndb_mgmd-extra-opts=$NDB_MGMD_EXTRA_OPTS --ndbd-extra-opts=$NDBD_EXTRA_OPTS"
|
||||
NDB_BACKUP_DIR=$MYSQL_TEST_DIR/var/ndbcluster-$NDBCLUSTER_PORT
|
||||
NDB_TOOLS_OUTPUT=$MYSQL_TEST_DIR/var/log/ndb_tools.log
|
||||
|
||||
if [ x$SOURCE_DIST = x1 ] ; then
|
||||
MY_BASEDIR=$MYSQL_TEST_DIR
|
||||
else
|
||||
@ -481,14 +517,18 @@ DASH72=`$ECHO '-------------------------------------------------------'|$CUT -c
|
||||
# on binary, use what is installed
|
||||
if [ x$SOURCE_DIST = x1 ] ; then
|
||||
if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then
|
||||
if [ -f "$BASEDIR/libmysqld/examples/mysqltest" ] ; then
|
||||
MYSQL_TEST="$VALGRIND $BASEDIR/libmysqld/examples/mysqltest"
|
||||
if [ -f "$BASEDIR/libmysqld/examples/mysqltest_embedded" ] ; then
|
||||
MYSQL_TEST="$VALGRIND $BASEDIR/libmysqld/examples/mysqltest_embedded"
|
||||
else
|
||||
echo "Fatal error: Cannot find embedded server 'mysqltest'" 1>&2
|
||||
echo "Fatal error: Cannot find embedded server 'mysqltest_embedded'" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
MYSQL_CLIENT_TEST="$BASEDIR/libmysqld/examples/mysql_client_test_embedded"
|
||||
else
|
||||
MYSQLD="$VALGRIND $BASEDIR/sql/mysqld"
|
||||
MYSQLD="$BASEDIR/sql/mysqld"
|
||||
if [ -n "$VALGRIND" ] ; then
|
||||
MYSQLD="$VALGRIND $MYSQLD"
|
||||
fi
|
||||
if [ -f "$BASEDIR/client/.libs/lt-mysqltest" ] ; then
|
||||
MYSQL_TEST="$BASEDIR/client/.libs/lt-mysqltest"
|
||||
elif [ -f "$BASEDIR/client/.libs/mysqltest" ] ; then
|
||||
@ -496,6 +536,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
|
||||
else
|
||||
MYSQL_TEST="$BASEDIR/client/mysqltest"
|
||||
fi
|
||||
MYSQL_CLIENT_TEST="$BASEDIR/tests/mysql_client_test"
|
||||
fi
|
||||
if [ -f "$BASEDIR/client/.libs/mysqldump" ] ; then
|
||||
MYSQL_DUMP="$BASEDIR/client/.libs/mysqldump"
|
||||
@ -512,7 +553,6 @@ if [ x$SOURCE_DIST = x1 ] ; then
|
||||
fi
|
||||
|
||||
CLIENT_BINDIR="$BASEDIR/client"
|
||||
TESTS_BINDIR="$BASEDIR/tests"
|
||||
MYSQLADMIN="$CLIENT_BINDIR/mysqladmin"
|
||||
WAIT_PID="$BASEDIR/extra/mysql_waitpid"
|
||||
MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqlmanagerc"
|
||||
@ -524,7 +564,41 @@ if [ x$SOURCE_DIST = x1 ] ; then
|
||||
INSTALL_DB="./install_test_db"
|
||||
MYSQL_FIX_SYSTEM_TABLES="$BASEDIR/scripts/mysql_fix_privilege_tables"
|
||||
NDB_TOOLS_DIR="$BASEDIR/ndb/tools"
|
||||
NDB_MGM="$BASEDIR/ndb/src/mgmclient/ndb_mgm"
|
||||
|
||||
if [ -n "$USE_PURIFY" ] ; then
|
||||
PSUP="$MYSQL_TEST_DIR/purify.suppress"
|
||||
echo "suppress UMR rw_read_held; mi_open; ha_myisam::open64; handler::ha_open; openfrm" > $PSUP
|
||||
echo "suppress UMR my_end; main" >> $PSUP
|
||||
echo "suppress UMR _doprnt; fprintf; my_end; main" >> $PSUP
|
||||
PURIFYOPTIONS="-windows=no -log-file=%v.purifylog -append-logfile -add-suppression-files=$PSUP"
|
||||
if [ -f "${MYSQL_TEST}-purify" ] ; then
|
||||
MYSQL_TEST="${MYSQL_TEST}-purify"
|
||||
PLOG="$MYSQL_TEST.purifylog"
|
||||
if [ -f $PLOG ]; then
|
||||
mv $PLOG $PLOG.$$
|
||||
fi
|
||||
PURIFY_LOGS="$PLOG"
|
||||
fi
|
||||
if [ -f "${MYSQLD}-purify" ] ; then
|
||||
MYSQLD="${MYSQLD}-purify"
|
||||
PLOG="$MYSQLD.purifylog"
|
||||
if [ -f $PLOG ]; then
|
||||
mv $PLOG $PLOG.$$
|
||||
fi
|
||||
PURIFY_LOGS="$PURIFY_LOGS $PLOG"
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
# We have a binary installation. Note that this can be both from
|
||||
# unpacking a MySQL AB binary distribution (created using
|
||||
# "scripts/make_binary_distribution", and from a "make install".
|
||||
# Unfortunately the structure differs a bit, for a "make install"
|
||||
# currently all binaries are in "bin", for a MySQL AB packaging
|
||||
# some are in "tests".
|
||||
|
||||
if test -x "$BASEDIR/libexec/mysqld"
|
||||
then
|
||||
MYSQLD="$VALGRIND $BASEDIR/libexec/mysqld"
|
||||
@ -532,7 +606,12 @@ else
|
||||
MYSQLD="$VALGRIND $BASEDIR/bin/mysqld"
|
||||
fi
|
||||
CLIENT_BINDIR="$BASEDIR/bin"
|
||||
TESTS_BINDIR="$BASEDIR/tests"
|
||||
if test -d "$BASEDIR/tests"
|
||||
then
|
||||
TESTS_BINDIR="$BASEDIR/tests"
|
||||
else
|
||||
TESTS_BINDIR="$BASEDIR/bin"
|
||||
fi
|
||||
MYSQL_TEST="$CLIENT_BINDIR/mysqltest"
|
||||
MYSQL_DUMP="$CLIENT_BINDIR/mysqldump"
|
||||
MYSQL_BINLOG="$CLIENT_BINDIR/mysqlbinlog"
|
||||
@ -545,6 +624,7 @@ else
|
||||
INSTALL_DB="./install_test_db --bin"
|
||||
MYSQL_FIX_SYSTEM_TABLES="$CLIENT_BINDIR/mysql_fix_privilege_tables"
|
||||
NDB_TOOLS_DIR="$CLIENT_BINDIR"
|
||||
NDB_MGM="$CLIENT_BINDIR/ndb_mgm"
|
||||
if test -d "$BASEDIR/share/mysql/english"
|
||||
then
|
||||
LANGUAGE="$BASEDIR/share/mysql/english/"
|
||||
@ -552,7 +632,23 @@ else
|
||||
else
|
||||
LANGUAGE="$BASEDIR/share/english/"
|
||||
CHARSETSDIR="$BASEDIR/share/charsets"
|
||||
fi
|
||||
fi
|
||||
if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then
|
||||
if [ -f "$CLIENT_BINDIR/mysqltest_embedded" ] ; then
|
||||
MYSQL_TEST="$VALGRIND $CLIENT_BINDIR/mysqltest_embedded"
|
||||
else
|
||||
echo "Fatal error: Cannot find embedded server 'mysqltest_embedded'" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -d "$BASEDIR/tests/mysql_client_test_embedded" ] ; then
|
||||
MYSQL_CLIENT_TEST="$TESTS_BINDIR/mysql_client_test_embedded"
|
||||
else
|
||||
MYSQL_CLIENT_TEST="$CLIENT_BINDIR/mysql_client_test_embedded"
|
||||
fi
|
||||
else
|
||||
MYSQL_TEST="$CLIENT_BINDIR/mysqltest"
|
||||
MYSQL_CLIENT_TEST="$CLIENT_BINDIR/mysql_client_test"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$MASTER_MYSQLD" ]
|
||||
@ -586,13 +682,20 @@ then
|
||||
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --user=root"
|
||||
fi
|
||||
|
||||
|
||||
MYSQL_CLIENT_TEST="$MYSQL_CLIENT_TEST --no-defaults --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT --silent $EXTRA_MYSQL_CLIENT_TEST_OPT"
|
||||
MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT"
|
||||
MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYSQLBINLOG_OPT"
|
||||
MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose"
|
||||
MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD"
|
||||
export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES CLIENT_BINDIR TESTS_BINDIR
|
||||
export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES
|
||||
export CLIENT_BINDIR MYSQL_CLIENT_TEST CHARSETSDIR
|
||||
export NDB_TOOLS_DIR
|
||||
export NDB_MGM
|
||||
export NDB_BACKUP_DIR
|
||||
export NDB_TOOLS_OUTPUT
|
||||
export PURIFYOPTIONS
|
||||
NDB_STATUS_OK=1
|
||||
export NDB_STATUS_OK
|
||||
|
||||
MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB \
|
||||
--user=$DBUSER --password=$DBPASSWD --silent -v --skip-safemalloc \
|
||||
@ -709,6 +812,17 @@ skip_test() {
|
||||
$ECHO "$RES$RES_SPACE [ skipped ]"
|
||||
}
|
||||
|
||||
report_current_test () {
|
||||
tname=$1
|
||||
echo "CURRENT_TEST: $tname" >> $MASTER_MYERR
|
||||
if [ -n "$PURIFY_LOGS" ] ; then
|
||||
for log in $PURIFY_LOGS
|
||||
do
|
||||
echo "CURRENT_TEST: $tname" >> $log
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
report_stats () {
|
||||
if [ $TOT_FAIL = 0 ]; then
|
||||
$ECHO "All $TOT_TEST tests were successful."
|
||||
@ -934,16 +1048,25 @@ start_ndbcluster()
|
||||
{
|
||||
if [ ! -z "$USE_NDBCLUSTER" ]
|
||||
then
|
||||
rm -f $NDB_TOOLS_OUTPUT
|
||||
if [ -z "$USE_RUNNING_NDBCLUSTER" ]
|
||||
then
|
||||
echo "Starting ndbcluster"
|
||||
if [ "$DO_BENCH" = 1 ]
|
||||
then
|
||||
NDBCLUSTER_OPTS=""
|
||||
NDBCLUSTER_EXTRA_OPTS=""
|
||||
else
|
||||
NDBCLUSTER_OPTS="--small"
|
||||
NDBCLUSTER_EXTRA_OPTS="--small"
|
||||
fi
|
||||
./ndb/ndbcluster --port-base=$NDBCLUSTER_PORT $NDBCLUSTER_OPTS --diskless --initial --data-dir=$MYSQL_TEST_DIR/var || exit 1
|
||||
./ndb/ndbcluster $NDBCLUSTER_OPTS $NDBCLUSTER_EXTRA_OPTS --initial || NDB_STATUS_OK=0
|
||||
if [ x$NDB_STATUS_OK != x1 ] ; then
|
||||
if [ x$FORCE != x1 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
USE_NDBCLUSTER=
|
||||
return
|
||||
fi
|
||||
|
||||
NDB_CONNECTSTRING="host=localhost:$NDBCLUSTER_PORT"
|
||||
else
|
||||
NDB_CONNECTSTRING="$USE_RUNNING_NDBCLUSTER"
|
||||
@ -961,7 +1084,7 @@ stop_ndbcluster()
|
||||
if [ -z "$USE_RUNNING_NDBCLUSTER" ]
|
||||
then
|
||||
# Kill any running ndbcluster stuff
|
||||
./ndb/ndbcluster --data-dir=$MYSQL_TEST_DIR/var --port-base=$NDBCLUSTER_PORT --stop
|
||||
./ndb/ndbcluster $NDBCLUSTER_OPTS --stop
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -994,9 +1117,11 @@ start_master()
|
||||
if [ -n "$1" ] ; then
|
||||
id=`$EXPR $1 + 101`;
|
||||
this_master_myport=`$EXPR $MASTER_MYPORT + $1`
|
||||
NOT_FIRST_MASTER_EXTRA_OPTS="--skip-innodb"
|
||||
else
|
||||
id=1;
|
||||
this_master_myport=$MASTER_MYPORT
|
||||
NOT_FIRST_MASTER_EXTRA_OPTS=""
|
||||
fi
|
||||
if [ -z "$DO_BENCH" ]
|
||||
then
|
||||
@ -1020,7 +1145,8 @@ start_master()
|
||||
--open-files-limit=1024 \
|
||||
$MASTER_40_ARGS \
|
||||
$SMALL_SERVER \
|
||||
$EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT"
|
||||
$EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT \
|
||||
$NOT_FIRST_MASTER_EXTRA_OPTS"
|
||||
else
|
||||
master_args="--no-defaults --log-bin=$MYSQL_TEST_DIR/var/log/master-bin$1 \
|
||||
--server-id=$id --rpl-recovery-rank=1 \
|
||||
@ -1039,7 +1165,8 @@ start_master()
|
||||
--innodb_data_file_path=ibdata1:50M \
|
||||
$MASTER_40_ARGS \
|
||||
$SMALL_SERVER \
|
||||
$EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT"
|
||||
$EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT \
|
||||
$NOT_FIRST_MASTER_EXTRA_OPTS"
|
||||
fi
|
||||
|
||||
CUR_MYERR=$MASTER_MYERR
|
||||
@ -1340,7 +1467,7 @@ run_testcase ()
|
||||
result_file="$result_file$RESULT_EXT"
|
||||
fi
|
||||
if [ "$USE_MANAGER" = 1 ] ; then
|
||||
many_slaves=`$EXPR \( \( $tname : rpl_failsafe \) != 0 \) \| \( \( $tname : rpl_chain_temp_table \) != 0 \)`
|
||||
many_slaves=`$EXPR \( \( $tname : rpl_failsafe \) != 0 \) \| \( \( $tname : rpl_chain_temp_table \) != 0 \)`
|
||||
fi
|
||||
if $EXPR "$tname" '<' "$START_FROM" > /dev/null ; then
|
||||
#skip_test $tname
|
||||
@ -1380,13 +1507,18 @@ run_testcase ()
|
||||
# script soon anyway so it is not worth it spending the time
|
||||
if [ "x$USE_EMBEDDED_SERVER" = "x1" -a -z "$DO_TEST" ] ; then
|
||||
for t in \
|
||||
"alter_table" \
|
||||
"bdb-deadlock" \
|
||||
"connect" \
|
||||
"ctype_latin1_de" \
|
||||
"ctype_ucs" \
|
||||
"flush_block_commit" \
|
||||
"grant2" \
|
||||
"grant_cache" \
|
||||
"grant" \
|
||||
"init_connect" \
|
||||
"init_file" \
|
||||
"innodb" \
|
||||
"innodb-deadlock" \
|
||||
"innodb-lock" \
|
||||
"mix_innodb_myisam_binlog" \
|
||||
@ -1394,10 +1526,12 @@ run_testcase ()
|
||||
"mysqlbinlog" \
|
||||
"mysqldump" \
|
||||
"mysql_protocols" \
|
||||
"packet" \
|
||||
"ps_1general" \
|
||||
"rename" \
|
||||
"show_check" \
|
||||
"system_mysql_db_fix" \
|
||||
"timezone2" \
|
||||
"user_var" \
|
||||
"variables"
|
||||
do
|
||||
@ -1432,7 +1566,7 @@ run_testcase ()
|
||||
esac
|
||||
stop_master
|
||||
stop_master 1
|
||||
echo "CURRENT_TEST: $tname" >> $MASTER_MYERR
|
||||
report_current_test $tname
|
||||
start_master
|
||||
if [ -n "$USE_NDBCLUSTER" -a -z "$DO_BENCH" ] ; then
|
||||
start_master 1
|
||||
@ -1448,13 +1582,13 @@ run_testcase ()
|
||||
EXTRA_MASTER_OPT=""
|
||||
stop_master
|
||||
stop_master 1
|
||||
echo "CURRENT_TEST: $tname" >> $MASTER_MYERR
|
||||
report_current_test $tname
|
||||
start_master
|
||||
if [ -n "$USE_NDBCLUSTER" -a -z "$DO_BENCH" ] ; then
|
||||
start_master 1
|
||||
fi
|
||||
else
|
||||
echo "CURRENT_TEST: $tname" >> $MASTER_MYERR
|
||||
report_current_test $tname
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -1497,6 +1631,12 @@ run_testcase ()
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "x$START_AND_EXIT" = "x1" ] ; then
|
||||
echo "Servers started, exiting"
|
||||
exit
|
||||
fi
|
||||
|
||||
cd $MYSQL_TEST_DIR
|
||||
|
||||
if [ -f $tf ] ; then
|
||||
@ -1544,7 +1684,7 @@ run_testcase ()
|
||||
show_failed_diff $tname
|
||||
$ECHO
|
||||
if [ x$FORCE != x1 ] ; then
|
||||
$ECHO "Aborting: $tname failed. To continue, re-run with '--force'."
|
||||
$ECHO "Aborting: $tname failed in $TEST_MODE mode. To continue, re-run with '--force'."
|
||||
$ECHO
|
||||
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \
|
||||
[ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ]
|
||||
@ -1634,11 +1774,6 @@ then
|
||||
mysql_loadstd
|
||||
fi
|
||||
|
||||
if [ "x$START_AND_EXIT" = "x1" ] ; then
|
||||
echo "Servers started, exiting"
|
||||
exit
|
||||
fi
|
||||
|
||||
$ECHO "Starting Tests"
|
||||
|
||||
#
|
||||
@ -1725,7 +1860,7 @@ $ECHO
|
||||
[ "$DO_GPROF" ] && gprof_collect # collect coverage information
|
||||
|
||||
if [ $TOT_FAIL -ne 0 ]; then
|
||||
$ECHO "mysql-test-run: *** Failing the test(s):$FAILED_CASES"
|
||||
$ECHO "mysql-test-run in $TEST_MODE mode: *** Failing the test(s):$FAILED_CASES"
|
||||
$ECHO
|
||||
exit 1
|
||||
else
|
||||
|
1909
mysql-test/mysql_test_run_new.c
Normal file
1909
mysql-test/mysql_test_run_new.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,8 @@ SUFFIXES = .sh
|
||||
.sh:
|
||||
@RM@ -f $@ $@-t
|
||||
@SED@ \
|
||||
-e 's!@''ndb_port''@!$(ndb_port)!g' \
|
||||
-e 's!@''ndb_port_base''@!$(ndb_port_base)!g' \
|
||||
-e 's!@''ndbbindir''@!$(ndbbindir)!g' \
|
||||
-e 's!@''ndbtoolsdir''@!$(ndbtoolsdir)!g' \
|
||||
$< > $@-t
|
||||
|
69
mysql-test/ndb/basic.result
Normal file
69
mysql-test/ndb/basic.result
Normal file
@ -0,0 +1,69 @@
|
||||
-- NDB Cluster -- Management Client --
|
||||
---------------------------------------------------------------------------
|
||||
NDB Cluster -- Management Client -- Help
|
||||
---------------------------------------------------------------------------
|
||||
HELP Print help text
|
||||
HELP SHOW Help for SHOW command
|
||||
HELP DEBUG Help for debug compiled version
|
||||
SHOW Print information about cluster
|
||||
START BACKUP [NOWAIT | WAIT STARTED | WAIT COMPLETED]
|
||||
Start backup (default WAIT COMPLETED)
|
||||
ABORT BACKUP <backup id> Abort backup
|
||||
SHUTDOWN Shutdown all processes in cluster
|
||||
CLUSTERLOG ON [<severity>] ... Enable Cluster logging
|
||||
CLUSTERLOG OFF [<severity>] ... Disable Cluster logging
|
||||
CLUSTERLOG TOGGLE [<severity>] ... Toggle severity filter on/off
|
||||
CLUSTERLOG INFO Print cluster log information
|
||||
<id> START Start DB node (started with -n)
|
||||
<id> RESTART [-n] [-i] Restart DB node
|
||||
<id> STOP Stop DB node
|
||||
ENTER SINGLE USER MODE <api-node> Enter single user mode
|
||||
EXIT SINGLE USER MODE Exit single user mode
|
||||
<id> STATUS Print status
|
||||
<id> CLUSTERLOG {<category>=<level>}+ Set log level for cluster log
|
||||
PURGE STALE SESSIONS Reset reserved nodeid's in the mgmt server
|
||||
CONNECT [<connectstring>] Connect to management server (reconnect if already connected)
|
||||
QUIT Quit management client
|
||||
|
||||
<severity> = ALERT | CRITICAL | ERROR | WARNING | INFO | DEBUG
|
||||
<category> = STARTUP | SHUTDOWN | STATISTICS | CHECKPOINT | NODERESTART | CONNECTION | INFO | ERROR | GREP | DEBUG | BACKUP
|
||||
<level> = 0 - 15
|
||||
<id> = ALL | Any database node id
|
||||
|
||||
Connected to Management Server at: localhost:1186
|
||||
Node 1: started (Version 4.1.9)
|
||||
Node 2: started (Version 4.1.9)
|
||||
|
||||
Node 1: started (Version 4.1.9)
|
||||
|
||||
Node 2: started (Version 4.1.9)
|
||||
|
||||
Executing CLUSTERLOG on node 1 OK!
|
||||
Executing CLUSTERLOG on node 2 OK!
|
||||
|
||||
Executing CLUSTERLOG on node 1 OK!
|
||||
Executing CLUSTERLOG on node 2 OK!
|
||||
|
||||
Executing CLUSTERLOG on node 1 OK!
|
||||
Executing CLUSTERLOG on node 2 OK!
|
||||
|
||||
Executing CLUSTERLOG on node 1 OK!
|
||||
Executing CLUSTERLOG on node 2 OK!
|
||||
|
||||
Executing CLUSTERLOG on node 1 OK!
|
||||
Executing CLUSTERLOG on node 2 OK!
|
||||
|
||||
Executing CLUSTERLOG on node 1 OK!
|
||||
Executing CLUSTERLOG on node 2 OK!
|
||||
|
||||
Executing CLUSTERLOG on node 1 OK!
|
||||
Executing CLUSTERLOG on node 2 OK!
|
||||
|
||||
Executing CLUSTERLOG on node 1 OK!
|
||||
Executing CLUSTERLOG on node 2 OK!
|
||||
|
||||
Cluster logging is disabled
|
||||
Cluster logging is enabled.
|
||||
Cluster logging is disabled
|
||||
ALL disabled
|
||||
ALL enabled
|
17
mysql-test/ndb/basic.test
Normal file
17
mysql-test/ndb/basic.test
Normal file
@ -0,0 +1,17 @@
|
||||
help
|
||||
all status
|
||||
1 status
|
||||
2 status
|
||||
all clusterlog connection=8
|
||||
all clusterlog startup=7
|
||||
all clusterlog checkpoint=7
|
||||
all clusterlog noderestart=15
|
||||
all clusterlog statistics=7
|
||||
all clusterlog error=7
|
||||
all clusterlog info=7
|
||||
all clusterlog backup=15
|
||||
clusterlog off
|
||||
clusterlog toggle
|
||||
clusterlog off
|
||||
clusterlog off all
|
||||
clusterlog on all
|
0
mysql-test/ndb/basic_log.result
Normal file
0
mysql-test/ndb/basic_log.result
Normal file
@ -9,13 +9,13 @@ DataDir= CHOOSE_FILESYSTEM
|
||||
MaxNoOfOrderedIndexes= CHOOSE_MaxNoOfOrderedIndexes
|
||||
|
||||
[ndbd]
|
||||
HostName= CHOOSE_HOSTNAME_1
|
||||
HostName= CHOOSE_HOSTNAME_1 # hostname is a valid network adress
|
||||
|
||||
[ndbd]
|
||||
HostName= CHOOSE_HOSTNAME_2
|
||||
HostName= CHOOSE_HOSTNAME_2 # hostname is a valid network adress
|
||||
|
||||
[ndb_mgmd]
|
||||
DataDir= CHOOSE_FILESYSTEM
|
||||
DataDir= CHOOSE_FILESYSTEM #
|
||||
PortNumber= CHOOSE_PORT_MGM
|
||||
|
||||
[mysqld]
|
||||
|
@ -5,7 +5,8 @@
|
||||
# This scripts starts the table handler ndbcluster
|
||||
|
||||
# configurable parameters, make sure to change in mysqlcluterd as well
|
||||
port_base="2200"
|
||||
port=@ndb_port@
|
||||
port_base=@ndb_port_base@
|
||||
fsdir=`pwd`
|
||||
# end configurable parameters
|
||||
|
||||
@ -22,6 +23,7 @@ if [ -d ../sql ] ; then
|
||||
exec_ndb=$ndbtop/src/kernel/ndbd
|
||||
exec_mgmtsrvr=$ndbtop/src/mgmsrv/ndb_mgmd
|
||||
exec_waiter=$ndbtop/tools/ndb_waiter
|
||||
exec_test=$ndbtop/tools/ndb_test_platform
|
||||
exec_mgmtclient=$ndbtop/src/mgmclient/ndb_mgm
|
||||
else
|
||||
BINARY_DIST=1
|
||||
@ -34,11 +36,18 @@ else
|
||||
exec_mgmtsrvr=$BASEDIR/bin/ndb_mgmd
|
||||
fi
|
||||
exec_waiter=$BASEDIR/bin/ndb_waiter
|
||||
exec_test=$BASEDIR/bin/ndb_test_platform
|
||||
exec_mgmtclient=$BASEDIR/bin/ndb_mgm
|
||||
fi
|
||||
|
||||
if $exec_test ; then :; else
|
||||
echo "ndb not correctly compiled to support this platform"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pidfile=ndbcluster.pid
|
||||
cfgfile=Ndb.cfg
|
||||
test_ndb=
|
||||
stop_ndb=
|
||||
initial_ndb=
|
||||
status_ndb=
|
||||
@ -49,8 +58,15 @@ ndb_con_op=105000
|
||||
ndb_dmem=80M
|
||||
ndb_imem=24M
|
||||
|
||||
NDB_MGM_EXTRA_OPTS=
|
||||
NDB_MGMD_EXTRA_OPTS=
|
||||
NDBD_EXTRA_OPTS=
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
--test)
|
||||
test_ndb=1
|
||||
;;
|
||||
--stop)
|
||||
stop_ndb=1
|
||||
;;
|
||||
@ -59,8 +75,7 @@ while test $# -gt 0; do
|
||||
initial_ndb=1
|
||||
;;
|
||||
--debug*)
|
||||
f=`echo "$1" | sed -e "s;--debug=;;"`
|
||||
flags_ndb="$flags_ndb $f"
|
||||
flags_ndb="$flags_ndb $1"
|
||||
;;
|
||||
--status)
|
||||
status_ndb=1
|
||||
@ -77,9 +92,21 @@ while test $# -gt 0; do
|
||||
--data-dir=*)
|
||||
fsdir=`echo "$1" | sed -e "s;--data-dir=;;"`
|
||||
;;
|
||||
--port=*)
|
||||
port=`echo "$1" | sed -e "s;--port=;;"`
|
||||
;;
|
||||
--port-base=*)
|
||||
port_base=`echo "$1" | sed -e "s;--port-base=;;"`
|
||||
;;
|
||||
--ndb_mgm-extra-opts=*)
|
||||
NDB_MGM_EXTRA_OPTS=`echo "$1" | sed -e "s;--ndb_mgm-extra-opts=;;"`
|
||||
;;
|
||||
--ndb_mgmd-extra-opts=*)
|
||||
NDB_MGMD_EXTRA_OPTS=`echo "$1" | sed -e "s;--ndb_mgmd-extra-opts=;;"`
|
||||
;;
|
||||
--ndbd-extra-opts=*)
|
||||
NDBD_EXTRA_OPTS=`echo "$1" | sed -e "s;--ndbd-extra-opts=;;"`
|
||||
;;
|
||||
-- ) shift; break ;;
|
||||
--* ) $ECHO "Unrecognized option: $1"; exit 1 ;;
|
||||
* ) break ;;
|
||||
@ -87,7 +114,7 @@ while test $# -gt 0; do
|
||||
shift
|
||||
done
|
||||
|
||||
fs_ndb="$fsdir/ndbcluster-$port_base"
|
||||
fs_ndb="$fsdir/ndbcluster-$port"
|
||||
|
||||
NDB_HOME=
|
||||
if [ ! -x "$fsdir" ]; then
|
||||
@ -102,12 +129,43 @@ if [ ! -x "$exec_mgmtsrvr" ]; then
|
||||
echo "$exec_mgmtsrvr missing"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -x "$exec_waiter" ]; then
|
||||
echo "$exec_waiter missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec_mgmtclient="$exec_mgmtclient --no-defaults $NDB_MGM_EXTRA_OPTS"
|
||||
exec_mgmtsrvr="$exec_mgmtsrvr --no-defaults $NDB_MGMD_EXTRA_OPTS"
|
||||
exec_ndb="$exec_ndb --no-defaults $NDBD_EXTRA_OPTS"
|
||||
exec_waiter="$exec_waiter --no-defaults"
|
||||
|
||||
ndb_host="localhost"
|
||||
ndb_mgmd_port=$port_base
|
||||
ndb_mgmd_port=$port
|
||||
NDB_CONNECTSTRING="host=$ndb_host:$ndb_mgmd_port"
|
||||
export NDB_CONNECTSTRING
|
||||
|
||||
sleep_until_file_created () {
|
||||
file=$1
|
||||
loop=$2
|
||||
org_time=$2
|
||||
message=$3
|
||||
while (test $loop -gt 0)
|
||||
do
|
||||
if [ -r $file ]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
loop=`expr $loop - 1`
|
||||
done
|
||||
if [ $message ]
|
||||
then
|
||||
echo $message
|
||||
fi
|
||||
echo "ERROR: $file was not created in $org_time seconds; Aborting"
|
||||
return 1;
|
||||
}
|
||||
|
||||
start_default_ndbcluster() {
|
||||
|
||||
# do some checks
|
||||
@ -120,16 +178,12 @@ if [ -d "$fs_ndb" ]; then :; else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# set som help variables
|
||||
|
||||
port_transporter=`expr $ndb_mgmd_port + 2`
|
||||
|
||||
# Start management server as deamon
|
||||
|
||||
# Edit file system path and ports in config file
|
||||
|
||||
if [ $initial_ndb ] ; then
|
||||
sed \
|
||||
rm -f $fs_ndb/ndb_* 2>&1 | cat > /dev/null
|
||||
sed \
|
||||
-e s,"CHOOSE_MaxNoOfOrderedIndexes","$ndb_no_ord",g \
|
||||
-e s,"CHOOSE_MaxNoOfConcurrentOperations","$ndb_con_op",g \
|
||||
-e s,"CHOOSE_DataMemory","$ndb_dmem",g \
|
||||
@ -138,7 +192,7 @@ sed \
|
||||
-e s,"CHOOSE_HOSTNAME_".*,"$ndb_host",g \
|
||||
-e s,"CHOOSE_FILESYSTEM","$fs_ndb",g \
|
||||
-e s,"CHOOSE_PORT_MGM","$ndb_mgmd_port",g \
|
||||
-e s,"CHOOSE_PORT_TRANSPORTER","$port_transporter",g \
|
||||
-e s,"CHOOSE_PORT_TRANSPORTER","$port_base",g \
|
||||
< ndb/ndb_config_2_node.ini \
|
||||
> "$fs_ndb/config.ini"
|
||||
fi
|
||||
@ -146,25 +200,36 @@ fi
|
||||
rm -f "$cfgfile" 2>&1 | cat > /dev/null
|
||||
rm -f "$fs_ndb/$cfgfile" 2>&1 | cat > /dev/null
|
||||
|
||||
if ( cd "$fs_ndb" ; $exec_mgmtsrvr -c config.ini ) ; then :; else
|
||||
if ( cd "$fs_ndb" ; $exec_mgmtsrvr -f config.ini ) ; then :; else
|
||||
echo "Unable to start $exec_mgmtsrvr from `pwd`"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if sleep_until_file_created $fs_ndb/ndb_3.pid 120
|
||||
then :; else
|
||||
exit 1
|
||||
fi
|
||||
cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
|
||||
|
||||
# Start database node
|
||||
|
||||
echo "Starting ndbd"
|
||||
( cd "$fs_ndb" ; $exec_ndb $flags_ndb & )
|
||||
|
||||
if sleep_until_file_created $fs_ndb/ndb_1.pid 120
|
||||
then :; else
|
||||
stop_default_ndbcluster
|
||||
exit 1
|
||||
fi
|
||||
cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
|
||||
|
||||
# Start database node
|
||||
|
||||
echo "Starting ndbd"
|
||||
( cd "$fs_ndb" ; $exec_ndb $flags_ndb & )
|
||||
|
||||
if sleep_until_file_created $fs_ndb/ndb_2.pid 120
|
||||
then :; else
|
||||
stop_default_ndbcluster
|
||||
exit 1
|
||||
fi
|
||||
cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
|
||||
|
||||
# test if Ndb Cluster starts properly
|
||||
@ -172,6 +237,7 @@ cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
|
||||
echo "Waiting for started..."
|
||||
if ( $exec_waiter ) | grep "NDBT_ProgramExit: 0 - OK"; then :; else
|
||||
echo "Ndbcluster startup failed"
|
||||
stop_default_ndbcluster
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -182,7 +248,7 @@ status_ndbcluster
|
||||
|
||||
status_ndbcluster() {
|
||||
# Start management client
|
||||
echo "show" | $exec_mgmtclient
|
||||
$exec_mgmtclient -e show
|
||||
}
|
||||
|
||||
stop_default_ndbcluster() {
|
||||
@ -191,17 +257,19 @@ stop_default_ndbcluster() {
|
||||
|
||||
exec_mgmtclient="$exec_mgmtclient --try-reconnect=1"
|
||||
|
||||
echo "shutdown" | $exec_mgmtclient 2>&1 | cat > /dev/null
|
||||
$exec_mgmtclient -e shutdown 2>&1 | cat > /dev/null
|
||||
|
||||
if [ -f "$fs_ndb/$pidfile" ] ; then
|
||||
kill_pids=`cat "$fs_ndb/$pidfile"`
|
||||
attempt=0
|
||||
while [ $attempt -lt 10 ] ; do
|
||||
new_kill_pid=""
|
||||
kill_pids2=""
|
||||
for p in $kill_pids ; do
|
||||
kill -0 $p 2> /dev/null
|
||||
if [ $? -eq 0 ] ; then
|
||||
new_kill_pid="$p $new_kill_pid"
|
||||
kill_pids2="-$p $kill_pids2"
|
||||
fi
|
||||
done
|
||||
kill_pids=$new_kill_pid
|
||||
@ -211,14 +279,57 @@ if [ -f "$fs_ndb/$pidfile" ] ; then
|
||||
sleep 1
|
||||
attempt=`expr $attempt + 1`
|
||||
done
|
||||
if [ "$kill_pids" != "" ] ; then
|
||||
echo "Failed to shutdown ndbcluster, executing kill -9 "$kill_pids
|
||||
kill -9 $kill_pids
|
||||
if [ "$kill_pids2" != "" ] ; then
|
||||
echo "Failed to shutdown ndbcluster, executing kill "$kill_pids2
|
||||
kill -9 -- $kill_pids2 2> /dev/null
|
||||
/bin/kill -9 -- $kill_pids2 2> /dev/null
|
||||
/usr/bin/kill -9 -- $kill_pids2 2> /dev/null
|
||||
kill -9 $kill_pids2 2> /dev/null
|
||||
/bin/kill -9 $kill_pids2 2> /dev/null
|
||||
/usr/bin/kill -9 $kill_pids2 2> /dev/null
|
||||
fi
|
||||
rm "$fs_ndb/$pidfile"
|
||||
fi
|
||||
}
|
||||
|
||||
initialize_ndb_test ()
|
||||
{
|
||||
fs_result=$fs_ndb/r
|
||||
rm -rf $fs_result
|
||||
mkdir $fs_result
|
||||
echo ------------------
|
||||
echo starting ndb tests
|
||||
echo ------------------
|
||||
}
|
||||
|
||||
do_ndb_test ()
|
||||
{
|
||||
test_name=$1
|
||||
|
||||
clusterlog=$fs_ndb/ndb_3_cluster.log
|
||||
|
||||
test_log_result=$fs_result/${test_name}_log.result
|
||||
test_log_reject=$fs_result/${test_name}_log.reject
|
||||
test_result=$fs_result/${test_name}.result
|
||||
test_reject=$fs_result/${test_name}.reject
|
||||
|
||||
clean_log='s/.*\[MgmSrvr\]//'
|
||||
|
||||
cat $clusterlog ndb/${test_name}_log.result | sed -e $clean_log > $test_log_result
|
||||
|
||||
cp ndb/${test_name}.result $test_result
|
||||
|
||||
cat ndb/${test_name}.test | $exec_mgmtclient > $test_reject
|
||||
cat $clusterlog | sed -e $clean_log > $test_log_reject
|
||||
|
||||
t="pass"
|
||||
diff -C 5 $test_result $test_reject || t="fail"
|
||||
printf "ndb_mgm output %20s [%s]\n" $test_name $t
|
||||
t="pass"
|
||||
diff -C 5 $test_log_result $test_log_reject || t="fail"
|
||||
printf "clusterlog output %20s [%s]\n" $test_name $t
|
||||
}
|
||||
|
||||
if [ $status_ndb ] ; then
|
||||
status_ndbcluster
|
||||
exit 0
|
||||
@ -230,4 +341,15 @@ else
|
||||
start_default_ndbcluster
|
||||
fi
|
||||
|
||||
if [ $test_ndb ] ; then
|
||||
initialize_ndb_test
|
||||
all_tests=`ls ndb/*.test | sed "s#ndb/##" | sed "s#.test##"`
|
||||
for a in $all_tests ; do
|
||||
do_ndb_test $a
|
||||
done
|
||||
echo ------------------
|
||||
echo shutting down cluster
|
||||
stop_default_ndbcluster
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
16
mysql-test/ndb/restart.result
Normal file
16
mysql-test/ndb/restart.result
Normal file
@ -0,0 +1,16 @@
|
||||
-- NDB Cluster -- Management Client --
|
||||
Connected to Management Server at: localhost:1186
|
||||
ALL disabled
|
||||
Cluster logging is enabled.
|
||||
ALERT enabled
|
||||
Executing CLUSTERLOG on node 1 OK!
|
||||
Executing CLUSTERLOG on node 2 OK!
|
||||
|
||||
Node 1 is being restarted.
|
||||
|
||||
Executing CLUSTERLOG on node 1 OK!
|
||||
Executing CLUSTERLOG on node 2 OK!
|
||||
|
||||
Node 1 is being restarted.
|
||||
|
||||
ALL enabled
|
12
mysql-test/ndb/restart.test
Normal file
12
mysql-test/ndb/restart.test
Normal file
@ -0,0 +1,12 @@
|
||||
clusterlog off all
|
||||
clusterlog on
|
||||
clusterlog on alert
|
||||
all clusterlog connection=0
|
||||
sleep 1
|
||||
1 restart
|
||||
sleep 5
|
||||
all clusterlog connection=8
|
||||
sleep 1
|
||||
1 restart
|
||||
sleep 5
|
||||
clusterlog on all
|
20
mysql-test/ndb/restart_log.result
Normal file
20
mysql-test/ndb/restart_log.result
Normal file
@ -0,0 +1,20 @@
|
||||
ALERT -- Node 2: Network partitioning - arbitration required
|
||||
ALERT -- Node 2: Arbitration won - positive reply from node 3
|
||||
ALERT -- Node 2: Node 1 has failed. The Node state at failure was 0
|
||||
ALERT -- Node 2: Node failure of 1 DBLQH completed
|
||||
ALERT -- Node 2: Node failure of 1 DBDICT completed
|
||||
ALERT -- Node 2: Node failure of 1 DBDIH completed
|
||||
ALERT -- Node 2: Node failure of 1 DBTC completed
|
||||
ALERT -- Node 2: Node 2 completed failure of Node 1
|
||||
ALERT -- Node 2: All nodes completed failure of Node 1
|
||||
ALERT -- Node 3: Node 1 Disconnected
|
||||
ALERT -- Node 2: Node 1 Disconnected
|
||||
ALERT -- Node 2: Network partitioning - arbitration required
|
||||
ALERT -- Node 2: Arbitration won - positive reply from node 3
|
||||
ALERT -- Node 2: Node 1 has failed. The Node state at failure was 0
|
||||
ALERT -- Node 2: Node failure of 1 DBLQH completed
|
||||
ALERT -- Node 2: Node failure of 1 DBDICT completed
|
||||
ALERT -- Node 2: Node failure of 1 DBDIH completed
|
||||
ALERT -- Node 2: Node failure of 1 DBTC completed
|
||||
ALERT -- Node 2: Node 2 completed failure of Node 1
|
||||
ALERT -- Node 2: All nodes completed failure of Node 1
|
@ -121,7 +121,7 @@ create database mysqltest;
|
||||
create table mysqltest.t1 (a int,b int,c int);
|
||||
grant all on mysqltest.t1 to mysqltest_1@localhost;
|
||||
alter table t1 rename t2;
|
||||
ERROR 42000: insert command denied to user 'mysqltest_1'@'localhost' for table 't2'
|
||||
ERROR 42000: INSERT,CREATE command denied to user 'mysqltest_1'@'localhost' for table 't2'
|
||||
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
|
||||
delete from mysql.user where user=_binary'mysqltest_1';
|
||||
drop database mysqltest;
|
||||
@ -349,6 +349,7 @@ 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` (
|
||||
@ -482,3 +483,17 @@ ERROR 42000: Incorrect table name 't1\\'
|
||||
rename table t1 to `t1\\`;
|
||||
ERROR 42000: Incorrect table name 't1\\'
|
||||
drop table t1;
|
||||
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 sub part 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 sub keys
|
||||
drop table t1;
|
||||
|
@ -36,16 +36,16 @@ create table t2 select * from t1 where 0=1 procedure analyse();
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`Field_name` char(255) NOT NULL default '',
|
||||
`Min_value` char(255) default NULL,
|
||||
`Max_value` char(255) default NULL,
|
||||
`Field_name` binary(255) NOT NULL default '',
|
||||
`Min_value` binary(255) default NULL,
|
||||
`Max_value` binary(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` char(255) NOT NULL default '',
|
||||
`Std` char(255) default NULL,
|
||||
`Optimal_fieldtype` char(64) NOT NULL default ''
|
||||
`Avg_value_or_avg_length` binary(255) NOT NULL default '',
|
||||
`Std` binary(255) default NULL,
|
||||
`Optimal_fieldtype` binary(64) NOT NULL default ''
|
||||
) ENGINE=MyISAM 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
|
||||
@ -55,16 +55,16 @@ create table t2 select * from t1 where 0=1 procedure analyse();
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`Field_name` char(255) NOT NULL default '',
|
||||
`Min_value` char(255) default NULL,
|
||||
`Max_value` char(255) default NULL,
|
||||
`Field_name` binary(255) NOT NULL default '',
|
||||
`Min_value` binary(255) default NULL,
|
||||
`Max_value` binary(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` char(255) NOT NULL default '',
|
||||
`Std` char(255) default NULL,
|
||||
`Optimal_fieldtype` char(64) NOT NULL default ''
|
||||
`Avg_value_or_avg_length` binary(255) NOT NULL default '',
|
||||
`Std` binary(255) default NULL,
|
||||
`Optimal_fieldtype` binary(64) NOT NULL default ''
|
||||
) ENGINE=MyISAM 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
|
||||
@ -78,16 +78,16 @@ create table t2 select * from t1 where 0=1 procedure analyse();
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`Field_name` char(255) NOT NULL default '',
|
||||
`Min_value` char(255) default NULL,
|
||||
`Max_value` char(255) default NULL,
|
||||
`Field_name` binary(255) NOT NULL default '',
|
||||
`Min_value` binary(255) default NULL,
|
||||
`Max_value` binary(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` char(255) NOT NULL default '',
|
||||
`Std` char(255) default NULL,
|
||||
`Optimal_fieldtype` char(64) NOT NULL default ''
|
||||
`Avg_value_or_avg_length` binary(255) NOT NULL default '',
|
||||
`Std` binary(255) default NULL,
|
||||
`Optimal_fieldtype` binary(64) NOT NULL default ''
|
||||
) ENGINE=MyISAM 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
|
||||
@ -96,3 +96,9 @@ 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;
|
||||
|
@ -134,3 +134,10 @@ 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=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
|
@ -98,10 +98,10 @@ Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '',
|
||||
`c2` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '',
|
||||
`c3` char(1) NOT NULL default '',
|
||||
`c4` char(1) NOT NULL default '',
|
||||
`c5` char(3) NOT NULL default '',
|
||||
`c6` char(3) NOT NULL default '',
|
||||
`c3` binary(1) NOT NULL default '',
|
||||
`c4` binary(1) NOT NULL default '',
|
||||
`c5` binary(3) NOT NULL default '',
|
||||
`c6` binary(3) NOT NULL default '',
|
||||
`c7` double(3,1) NOT NULL default '0.0',
|
||||
`c8` double(3,1) NOT NULL default '0.0',
|
||||
`c9` double(3,1) default NULL
|
||||
@ -149,8 +149,8 @@ t1 CREATE TABLE `t1` (
|
||||
`COALESCE(1.0)` double(3,1) NOT NULL default '0.0',
|
||||
`COALESCE('a')` char(1) NOT NULL default '',
|
||||
`COALESCE(1,1.0)` double(3,1) NOT NULL default '0.0',
|
||||
`COALESCE(1,'1')` char(1) NOT NULL default '',
|
||||
`COALESCE(1.1,'1')` char(3) NOT NULL default '',
|
||||
`COALESCE(1,'1')` binary(1) NOT NULL default '',
|
||||
`COALESCE(1.1,'1')` binary(3) NOT NULL default '',
|
||||
`COALESCE('a' COLLATE latin1_bin,'b')` char(1) character set latin1 collate latin1_bin NOT NULL default ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
|
@ -178,3 +178,12 @@ aaa aa
|
||||
aab aa
|
||||
aac aa
|
||||
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
|
||||
|
@ -36,3 +36,9 @@ hex(a) STRCMP(a,'a') STRCMP(a,'a ')
|
||||
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
|
||||
|
15
mysql-test/r/consistent_snapshot.result
Normal file
15
mysql-test/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;
|
@ -1,10 +1,79 @@
|
||||
drop table if exists t1;
|
||||
SET NAMES big5;
|
||||
CREATE TABLE t1 (c CHAR(10) CHARACTER SET big5, KEY(c));
|
||||
SET @test_character_set= 'big5';
|
||||
SET @test_collation= 'big5_chinese_ci';
|
||||
SET @safe_character_set_server= @@character_set_server;
|
||||
SET @safe_collation_server= @@collation_server;
|
||||
SET character_set_server= @test_character_set;
|
||||
SET collation_server= @test_collation;
|
||||
CREATE DATABASE d1;
|
||||
USE d1;
|
||||
CREATE TABLE t1 (c CHAR(10), KEY(c));
|
||||
SHOW FULL COLUMNS FROM t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
c char(10) big5_chinese_ci YES MUL NULL
|
||||
INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa');
|
||||
SELECT * FROM t1 WHERE c LIKE 'aaa%';
|
||||
c
|
||||
SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%';
|
||||
want3results
|
||||
aaa
|
||||
aaaa
|
||||
aaaaa
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2)));
|
||||
SHOW FULL COLUMNS FROM t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
c1 varchar(15) big5_chinese_ci YES MUL NULL
|
||||
INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab');
|
||||
SELECT c1 as want3results from t1 where c1 like 'l%';
|
||||
want3results
|
||||
location
|
||||
loberge
|
||||
lotre
|
||||
SELECT c1 as want3results from t1 where c1 like 'lo%';
|
||||
want3results
|
||||
location
|
||||
loberge
|
||||
lotre
|
||||
SELECT c1 as want1result from t1 where c1 like 'loc%';
|
||||
want1result
|
||||
location
|
||||
SELECT c1 as want1result from t1 where c1 like 'loca%';
|
||||
want1result
|
||||
location
|
||||
SELECT c1 as want1result from t1 where c1 like 'locat%';
|
||||
want1result
|
||||
location
|
||||
SELECT c1 as want1result from t1 where c1 like 'locati%';
|
||||
want1result
|
||||
location
|
||||
SELECT c1 as want1result from t1 where c1 like 'locatio%';
|
||||
want1result
|
||||
location
|
||||
SELECT c1 as want1result from t1 where c1 like 'location%';
|
||||
want1result
|
||||
location
|
||||
DROP TABLE t1;
|
||||
DROP DATABASE d1;
|
||||
USE test;
|
||||
SET character_set_server= @safe_character_set_server;
|
||||
SET collation_server= @safe_collation_server;
|
||||
SET NAMES big5;
|
||||
SET collation_connection='big5_chinese_ci';
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
big5_chinese_ci 6109
|
||||
big5_chinese_ci 61
|
||||
big5_chinese_ci 6120
|
||||
drop table t1;
|
||||
SET collation_connection='big5_bin';
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
big5_bin 6109
|
||||
big5_bin 61
|
||||
big5_bin 6120
|
||||
drop table t1;
|
||||
|
@ -54,3 +54,19 @@ select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1;
|
||||
collation(a) collation(b) collation(binary 'ccc')
|
||||
cp1251_bin binary binary
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a varchar(16) character set cp1251 collate cp1251_bin not null,
|
||||
b int(10) default null,
|
||||
primary key(a)
|
||||
) charset=cp1251;
|
||||
insert into t1 (a) values ('air'),
|
||||
('we'),('g'),('we_toshko'), ('s0urce'),('we_ivo'),('we_iliyan'),
|
||||
('we_martin'),('vw_grado'),('vw_vasko'),('tn_vili'),('tn_kalina'),
|
||||
('tn_fakira'),('vw_silvia'),('vw_starshi'),('vw_geo'),('vw_b0x1');
|
||||
select * from t1 where a like 'we_%';
|
||||
a b
|
||||
we_iliyan NULL
|
||||
we_ivo NULL
|
||||
we_martin NULL
|
||||
we_toshko NULL
|
||||
drop table t1;
|
||||
|
@ -63,3 +63,12 @@ ERROR HY000: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET
|
||||
create database d1 default character set latin1 collate latin2_bin;
|
||||
ERROR 42000: COLLATION 'latin2_bin' is not valid for CHARACTER SET 'latin1'
|
||||
DROP DATABASE mysqltest1;
|
||||
CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET latin7;
|
||||
use mysqltest2;
|
||||
ALTER DATABASE DEFAULT CHARACTER SET latin2;
|
||||
show create database mysqltest2;
|
||||
Database Create Database
|
||||
mysqltest2 CREATE DATABASE `mysqltest2` /*!40100 DEFAULT CHARACTER SET latin2 */
|
||||
drop database mysqltest2;
|
||||
ALTER DATABASE DEFAULT CHARACTER SET latin2;
|
||||
ERROR 3D000: No database selected
|
||||
|
@ -296,3 +296,37 @@ FD C3BD FD 1
|
||||
FE C3BE FE 1
|
||||
FF C3BF FF 1
|
||||
DROP TABLE t1;
|
||||
select 'a' regexp 'A' collate latin1_general_ci;
|
||||
'a' regexp 'A' collate latin1_general_ci
|
||||
1
|
||||
select 'a' regexp 'A' collate latin1_general_cs;
|
||||
'a' regexp 'A' collate latin1_general_cs
|
||||
0
|
||||
select 'a' regexp 'A' collate latin1_bin;
|
||||
'a' regexp 'A' collate latin1_bin
|
||||
0
|
||||
SET collation_connection='latin1_swedish_ci';
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
latin1_swedish_ci 6109
|
||||
latin1_swedish_ci 61
|
||||
latin1_swedish_ci 6120
|
||||
drop table t1;
|
||||
SET collation_connection='latin1_bin';
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
latin1_bin 6109
|
||||
latin1_bin 61
|
||||
latin1_bin 6120
|
||||
drop table t1;
|
||||
CREATE TABLE <20>a (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 '<27>a (a int)' at line 1
|
||||
SELECT '<27>a' as str;
|
||||
str
|
||||
<EFBFBD>a
|
||||
|
@ -317,3 +317,24 @@ FIELD('ue',s1) FIELD('
|
||||
1 1 1 1
|
||||
1 1 1 1
|
||||
DROP TABLE t1;
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
latin1_german2_ci 6109
|
||||
latin1_german2_ci 61
|
||||
latin1_german2_ci 6120
|
||||
drop table t1;
|
||||
SET NAMES latin1;
|
||||
CREATE TABLE t1 (
|
||||
col1 varchar(255) NOT NULL default ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 collate latin1_german2_ci;
|
||||
INSERT INTO t1 VALUES ('<27>'),('ss'),('ss');
|
||||
ALTER TABLE t1 ADD KEY ifword(col1);
|
||||
SELECT * FROM t1 WHERE col1='<27>' ORDER BY col1, BINARY col1;
|
||||
col1
|
||||
ss
|
||||
ss
|
||||
<EFBFBD>
|
||||
DROP TABLE t1;
|
||||
|
@ -33,7 +33,7 @@ t1 CREATE TABLE `t1` (
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
SHOW KEYS FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 key_a 1 a A NULL 9 NULL YES BTREE
|
||||
t1 1 key_a 1 a A NULL 3 NULL YES BTREE
|
||||
ALTER TABLE t1 CHANGE a a CHAR(4);
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
@ -53,5 +53,5 @@ t1 CREATE TABLE `t1` (
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
SHOW KEYS FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 key_a 1 a A NULL 9 NULL YES BTREE
|
||||
t1 1 key_a 1 a A NULL 3 NULL YES BTREE
|
||||
DROP TABLE t1;
|
||||
|
@ -166,3 +166,77 @@ ERROR HY000: Invalid utf8 character string: '
|
||||
SET NAMES utf8;
|
||||
CREATE TABLE `good<6F><64><EFBFBD><EFBFBD><EFBFBD>` (a int);
|
||||
ERROR HY000: Invalid utf8 character string: '<27><><EFBFBD><EFBFBD><EFBFBD>` (a int)'
|
||||
set names latin1;
|
||||
create table t1 (a char(10) character set koi8r, b text character set koi8r);
|
||||
insert into t1 values ('test','test');
|
||||
insert into t1 values ('<27><><EFBFBD><EFBFBD>','<27><><EFBFBD><EFBFBD>');
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'a' at row 1
|
||||
Warning 1265 Data truncated for column 'b' at row 1
|
||||
drop table t1;
|
||||
set names koi8r;
|
||||
create table t1 (a char(10) character set cp1251);
|
||||
insert into t1 values (_koi8r'<27><><EFBFBD><EFBFBD>');
|
||||
select * from t1 where a=_koi8r'<27><><EFBFBD><EFBFBD>';
|
||||
a
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
select * from t1 where a=concat(_koi8r'<27><><EFBFBD><EFBFBD>');
|
||||
ERROR HY000: Illegal mix of collations (cp1251_general_ci,IMPLICIT) and (koi8r_general_ci,COERCIBLE) for operation '='
|
||||
select * from t1 where a=_latin1'<27><><EFBFBD><EFBFBD>';
|
||||
ERROR HY000: Illegal mix of collations (cp1251_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation '='
|
||||
drop table t1;
|
||||
set names latin1;
|
||||
set names koi8r;
|
||||
create table t1 (c1 char(10) character set cp1251);
|
||||
insert into t1 values ('<27>');
|
||||
select c1 from t1 where c1 between '<27>' and '<27>';
|
||||
c1
|
||||
<EFBFBD>
|
||||
select ifnull(c1,'<27>'), ifnull(null,c1) from t1;
|
||||
ifnull(c1,'<27>') ifnull(null,c1)
|
||||
<EFBFBD> <09>
|
||||
select if(1,c1,'<27>'), if(0,c1,'<27>') from t1;
|
||||
if(1,c1,'<27>') if(0,c1,'<27>')
|
||||
<EFBFBD> <09>
|
||||
select coalesce('<27>',c1), coalesce(null,c1) from t1;
|
||||
coalesce('<27>',c1) coalesce(null,c1)
|
||||
<EFBFBD> <09>
|
||||
select least(c1,'<27>'), greatest(c1,'<27>') from t1;
|
||||
least(c1,'<27>') greatest(c1,'<27>')
|
||||
<EFBFBD> <09>
|
||||
select locate(c1,'<27>'), locate('<27>',c1) from t1;
|
||||
locate(c1,'<27>') locate('<27>',c1)
|
||||
1 1
|
||||
select field(c1,'<27>'),field('<27>',c1) from t1;
|
||||
field(c1,'<27>') field('<27>',c1)
|
||||
1 1
|
||||
select concat(c1,'<27>'), concat('<27>',c1) from t1;
|
||||
concat(c1,'<27>') concat('<27>',c1)
|
||||
<EFBFBD><EFBFBD> <09><>
|
||||
select concat_ws(c1,'<27>','<27>'), concat_ws('<27>',c1,'<27>') from t1;
|
||||
concat_ws(c1,'<27>','<27>') concat_ws('<27>',c1,'<27>')
|
||||
<EFBFBD><EFBFBD><EFBFBD> <09><><EFBFBD>
|
||||
select replace(c1,'<27>','<27>'), replace('<27>',c1,'<27>') from t1;
|
||||
replace(c1,'<27>','<27>') replace('<27>',c1,'<27>')
|
||||
<EFBFBD> <09>
|
||||
select substring_index(c1,'<27><><EFBFBD><EFBFBD>',2) from t1;
|
||||
substring_index(c1,'<27><><EFBFBD><EFBFBD>',2)
|
||||
<EFBFBD>
|
||||
select elt(1,c1,'<27>'),elt(1,'<27>',c1) from t1;
|
||||
elt(1,c1,'<27>') elt(1,'<27>',c1)
|
||||
<EFBFBD> <09>
|
||||
select make_set(3,c1,'<27>'), make_set(3,'<27>',c1) from t1;
|
||||
make_set(3,c1,'<27>') make_set(3,'<27>',c1)
|
||||
<EFBFBD>,<2C> <09>,<2C>
|
||||
select insert(c1,1,2,'<27>'),insert('<27>',1,2,c1) from t1;
|
||||
insert(c1,1,2,'<27>') insert('<27>',1,2,c1)
|
||||
<EFBFBD> <09>
|
||||
select trim(c1 from '<27>'),trim('<27>' from c1) from t1;
|
||||
trim(c1 from '<27>') trim('<27>' from c1)
|
||||
|
||||
select lpad(c1,3,'<27>'), lpad('<27>',3,c1) from t1;
|
||||
lpad(c1,3,'<27>') lpad('<27>',3,c1)
|
||||
<EFBFBD><EFBFBD><EFBFBD> <09><><EFBFBD>
|
||||
select rpad(c1,3,'<27>'), rpad('<27>',3,c1) from t1;
|
||||
rpad(c1,3,'<27>') rpad('<27>',3,c1)
|
||||
<EFBFBD><EFBFBD><EFBFBD> <09><><EFBFBD>
|
||||
|
@ -60,3 +60,38 @@ hex(c)
|
||||
9353
|
||||
9373
|
||||
drop table t1;
|
||||
SET NAMES sjis;
|
||||
CREATE TABLE t1 (
|
||||
c char(16) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=sjis;
|
||||
insert into t1 values(0xb1),(0xb2),(0xb3);
|
||||
select hex(c) from t1;
|
||||
hex(c)
|
||||
B1
|
||||
B2
|
||||
B3
|
||||
drop table t1;
|
||||
SET collation_connection='sjis_japanese_ci';
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
sjis_japanese_ci 6109
|
||||
sjis_japanese_ci 61
|
||||
sjis_japanese_ci 6120
|
||||
drop table t1;
|
||||
SET collation_connection='sjis_bin';
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
sjis_bin 6109
|
||||
sjis_bin 61
|
||||
sjis_bin 6120
|
||||
drop table t1;
|
||||
SET NAMES sjis;
|
||||
SELECT HEX('<27><><EFBFBD><EFBFBD><EFBFBD>@\<5C>\') FROM DUAL;
|
||||
HEX('<27><><EFBFBD><EFBFBD><EFBFBD>@<40>_<EFBFBD>\')
|
||||
8DB2939181408C5C
|
||||
|
@ -2899,3 +2899,61 @@ hex(a) STRCMP(a,'a') STRCMP(a,'a ')
|
||||
6109 -1 -1
|
||||
61 0 0
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`url` varchar(200) NOT NULL default '',
|
||||
`name` varchar(250) NOT NULL default '',
|
||||
`type` int(11) NOT NULL default '0',
|
||||
`website` varchar(250) NOT NULL default '',
|
||||
`adddate` date NOT NULL default '0000-00-00',
|
||||
`size` varchar(20) NOT NULL default '',
|
||||
`movieid` int(11) NOT NULL default '0',
|
||||
`musicid` int(11) NOT NULL default '0',
|
||||
`star` varchar(20) NOT NULL default '',
|
||||
`download` int(11) NOT NULL default '0',
|
||||
`lastweek` int(11) NOT NULL default '0',
|
||||
`thisweek` int(11) NOT NULL default '0',
|
||||
`page` varchar(250) NOT NULL default '',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `url` (`url`)
|
||||
) CHARACTER SET tis620;
|
||||
INSERT INTO t1 VALUES
|
||||
(1,'http://www.siamzone.com/download/download/000001-frodo_1024.jpg','The Lord
|
||||
of the Rings
|
||||
Wallpapers',1,'http://www.lordoftherings.net','2002-01-22','',448,0,'',3805,0,0,
|
||||
'');
|
||||
INSERT INTO t1 VALUES (2,'http://www.othemovie.com/OScreenSaver1.EXE','O
|
||||
Screensaver',2,'','2002-01-22','',491,0,'',519,0,0,'');
|
||||
INSERT INTO t1 VALUES
|
||||
(3,'http://www.siamzone.com/download/download/000003-jasonx2(800x600).jpg','Jaso
|
||||
n X Wallpapers',1,'','2002-05-31','',579,0,'',1091,0,0,'');
|
||||
select * from t1 order by id;
|
||||
id url name type website adddate size movieid musicid star download lastweek thisweek page
|
||||
1 http://www.siamzone.com/download/download/000001-frodo_1024.jpg The Lord
|
||||
of the Rings
|
||||
Wallpapers 1 http://www.lordoftherings.net 2002-01-22 448 0 3805 0 0
|
||||
2 http://www.othemovie.com/OScreenSaver1.EXE O
|
||||
Screensaver 2 2002-01-22 491 0 519 0 0
|
||||
3 http://www.siamzone.com/download/download/000003-jasonx2(800x600).jpg Jaso
|
||||
n X Wallpapers 1 2002-05-31 579 0 1091 0 0
|
||||
DROP TABLE t1;
|
||||
SET collation_connection='tis620_thai_ci';
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
tis620_thai_ci 6109
|
||||
tis620_thai_ci 61
|
||||
tis620_thai_ci 6120
|
||||
drop table t1;
|
||||
SET collation_connection='tis620_bin';
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
tis620_bin 6109
|
||||
tis620_bin 61
|
||||
tis620_bin 6120
|
||||
drop table t1;
|
||||
|
@ -19,6 +19,9 @@ select 'a ' = 'a\t', 'a ' < 'a\t', 'a ' > 'a\t';
|
||||
select 'a a' > 'a', 'a \t' < 'a';
|
||||
'a a' > 'a' 'a \t' < 'a'
|
||||
1 1
|
||||
select 'c' like '\_' as want0;
|
||||
want0
|
||||
0
|
||||
CREATE TABLE t (
|
||||
c char(20) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
@ -2315,3 +2318,81 @@ HEX(CONVERT(col1 USING ucs2))
|
||||
064A06A9062F064A06AF0631
|
||||
064A06A9064A
|
||||
DROP TABLE t1;
|
||||
SET @test_character_set= 'utf8';
|
||||
SET @test_collation= 'utf8_swedish_ci';
|
||||
SET @safe_character_set_server= @@character_set_server;
|
||||
SET @safe_collation_server= @@collation_server;
|
||||
SET character_set_server= @test_character_set;
|
||||
SET collation_server= @test_collation;
|
||||
CREATE DATABASE d1;
|
||||
USE d1;
|
||||
CREATE TABLE t1 (c CHAR(10), KEY(c));
|
||||
SHOW FULL COLUMNS FROM t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
c char(10) utf8_swedish_ci YES MUL NULL
|
||||
INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa');
|
||||
SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%';
|
||||
want3results
|
||||
aaa
|
||||
aaaa
|
||||
aaaaa
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2)));
|
||||
SHOW FULL COLUMNS FROM t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
c1 varchar(15) utf8_swedish_ci YES MUL NULL
|
||||
INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab');
|
||||
SELECT c1 as want3results from t1 where c1 like 'l%';
|
||||
want3results
|
||||
location
|
||||
loberge
|
||||
lotre
|
||||
SELECT c1 as want3results from t1 where c1 like 'lo%';
|
||||
want3results
|
||||
location
|
||||
loberge
|
||||
lotre
|
||||
SELECT c1 as want1result from t1 where c1 like 'loc%';
|
||||
want1result
|
||||
location
|
||||
SELECT c1 as want1result from t1 where c1 like 'loca%';
|
||||
want1result
|
||||
location
|
||||
SELECT c1 as want1result from t1 where c1 like 'locat%';
|
||||
want1result
|
||||
location
|
||||
SELECT c1 as want1result from t1 where c1 like 'locati%';
|
||||
want1result
|
||||
location
|
||||
SELECT c1 as want1result from t1 where c1 like 'locatio%';
|
||||
want1result
|
||||
location
|
||||
SELECT c1 as want1result from t1 where c1 like 'location%';
|
||||
want1result
|
||||
location
|
||||
DROP TABLE t1;
|
||||
DROP DATABASE d1;
|
||||
USE test;
|
||||
SET character_set_server= @safe_character_set_server;
|
||||
SET collation_server= @safe_collation_server;
|
||||
create table t1 (a varchar(1)) character set utf8 collate utf8_estonian_ci;
|
||||
insert into t1 values ('A'),('B'),('C'),('a'),('b'),('c');
|
||||
select a, a regexp '[a]' from t1 order by binary a;
|
||||
a a regexp '[a]'
|
||||
A 1
|
||||
B 0
|
||||
C 0
|
||||
a 1
|
||||
b 0
|
||||
c 0
|
||||
drop table t1;
|
||||
SET collation_connection='utf8_unicode_ci';
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
utf8_unicode_ci 6109
|
||||
utf8_unicode_ci 61
|
||||
utf8_unicode_ci 6120
|
||||
drop table t1;
|
||||
|
@ -1,4 +1,27 @@
|
||||
DROP TABLE IF EXISTS t1;
|
||||
SET NAMES latin1;
|
||||
SET character_set_connection=ucs2;
|
||||
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
|
||||
SET CHARACTER SET koi8r;
|
||||
CREATE TABLE t1 (word VARCHAR(64) CHARACTER SET ucs2);
|
||||
INSERT INTO t1 VALUES (_koi8r'<27>'), (X'2004');
|
||||
@ -480,3 +503,127 @@ a 0061
|
||||
b 0062
|
||||
c 0063
|
||||
drop table t1;
|
||||
set @ivar= 1234;
|
||||
set @str1 = 'select ?';
|
||||
set @str2 = convert(@str1 using ucs2);
|
||||
prepare stmt1 from @str2;
|
||||
execute stmt1 using @ivar;
|
||||
?
|
||||
1234
|
||||
SET TIMESTAMP=10000;
|
||||
create table t2 (c char(30)) charset=ucs2;
|
||||
set @v=convert('abc' using ucs2);
|
||||
reset master;
|
||||
insert into t2 values (@v);
|
||||
show binlog events from 79;
|
||||
Log_name Pos Event_type Server_id Orig_log_pos Info
|
||||
master-bin.000001 79 User var 1 79 @`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci
|
||||
master-bin.000001 119 Query 1 119 use `test`; insert into t2 values (@v)
|
||||
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
|
||||
SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`;
|
||||
use test;
|
||||
SET TIMESTAMP=10000;
|
||||
insert into t2 values (@v);
|
||||
drop table t2;
|
||||
set names latin1;
|
||||
create table t1 (a enum('x','y','z') character set ucs2);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` enum('x','y','z') character set ucs2 default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
insert into t1 values ('x');
|
||||
insert into t1 values ('y');
|
||||
insert into t1 values ('z');
|
||||
select a, hex(a) from t1 order by a;
|
||||
a hex(a)
|
||||
x 0078
|
||||
y 0079
|
||||
z 007A
|
||||
alter table t1 change a a enum('x','y','z','d','e','<27>','<27>','<27>') character set ucs2;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` enum('x','y','z','d','e','<27>','<27>','<27>') character set ucs2 default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
insert into t1 values ('D');
|
||||
insert into t1 values ('E ');
|
||||
insert into t1 values ('<27>');
|
||||
insert into t1 values ('<27>');
|
||||
insert into t1 values ('<27>');
|
||||
select a, hex(a) from t1 order by a;
|
||||
a hex(a)
|
||||
x 0078
|
||||
y 0079
|
||||
z 007A
|
||||
d 0064
|
||||
e 0065
|
||||
<EFBFBD> 00E4
|
||||
<EFBFBD> 00F6
|
||||
<EFBFBD> 00FC
|
||||
drop table t1;
|
||||
create table t1 (a set ('x','y','z','<27>','<27>','<27>') character set ucs2);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` set('x','y','z','<27>','<27>','<27>') character set ucs2 default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
insert into t1 values ('x');
|
||||
insert into t1 values ('y');
|
||||
insert into t1 values ('z');
|
||||
insert into t1 values ('x,y');
|
||||
insert into t1 values ('x,y,z,<2C>,<2C>,<2C>');
|
||||
select a, hex(a) from t1 order by a;
|
||||
a hex(a)
|
||||
x 0078
|
||||
y 0079
|
||||
x,y 0078002C0079
|
||||
z 007A
|
||||
x,y,z,<2C>,<2C>,<2C> 0078002C0079002C007A002C00E4002C00F6002C00FC
|
||||
drop table t1;
|
||||
create table t1(a enum('a','b','c')) default character set ucs2;
|
||||
insert into t1 values('a'),('b'),('c');
|
||||
alter table t1 add b char(1);
|
||||
show warnings;
|
||||
Level Code Message
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
a NULL
|
||||
b NULL
|
||||
c NULL
|
||||
drop table t1;
|
||||
SET collation_connection='ucs2_general_ci';
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
ucs2_general_ci 00610009
|
||||
ucs2_general_ci 0061
|
||||
ucs2_general_ci 00610020
|
||||
drop table t1;
|
||||
SET NAMES latin1;
|
||||
SET collation_connection='ucs2_bin';
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
ucs2_bin 00610009
|
||||
ucs2_bin 0061
|
||||
ucs2_bin 00610020
|
||||
drop table t1;
|
||||
SET NAMES latin1;
|
||||
SET collation_connection='ucs2_swedish_ci';
|
||||
CREATE TABLE t1 (Field1 int(10) default '0');
|
||||
INSERT INTO t1 VALUES ('-1');
|
||||
SELECT * FROM t1;
|
||||
Field1
|
||||
-1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (Field1 int(10) unsigned default '0');
|
||||
INSERT INTO t1 VALUES ('-1');
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'Field1' at row 1
|
||||
DROP TABLE t1;
|
||||
SET NAMES latin1;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -412,7 +412,7 @@ show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c` char(10) character set utf8 default NULL,
|
||||
UNIQUE KEY `a` (`c`(1))
|
||||
UNIQUE KEY `a` TYPE HASH (`c`(1))
|
||||
) ENGINE=HEAP DEFAULT CHARSET=latin1
|
||||
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
|
||||
insert into t1 values ('aa');
|
||||
@ -570,7 +570,7 @@ show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c` char(10) character set utf8 collate utf8_bin default NULL,
|
||||
UNIQUE KEY `a` (`c`(1))
|
||||
UNIQUE KEY `a` TYPE HASH (`c`(1))
|
||||
) ENGINE=HEAP DEFAULT CHARSET=latin1
|
||||
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
|
||||
insert into t1 values ('aa');
|
||||
@ -814,3 +814,53 @@ t2 CREATE TABLE `t2` (
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
select 'c' like '\_' as want0;
|
||||
want0
|
||||
0
|
||||
create table t1 (id integer, a varchar(100) character set utf8 collate utf8_unicode_ci);
|
||||
insert into t1 values (1, 'Test');
|
||||
select * from t1 where soundex(a) = soundex('Test');
|
||||
id a
|
||||
1 Test
|
||||
select * from t1 where soundex(a) = soundex('TEST');
|
||||
id a
|
||||
1 Test
|
||||
select * from t1 where soundex(a) = soundex('test');
|
||||
id a
|
||||
1 Test
|
||||
drop table t1;
|
||||
SET collation_connection='utf8_general_ci';
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
utf8_general_ci 6109
|
||||
utf8_general_ci 61
|
||||
utf8_general_ci 6120
|
||||
drop table t1;
|
||||
SET collation_connection='utf8_bin';
|
||||
create table t1 select repeat('a',4000) a;
|
||||
delete from t1;
|
||||
insert into t1 values ('a'), ('a '), ('a\t');
|
||||
select collation(a),hex(a) from t1 order by a;
|
||||
collation(a) hex(a)
|
||||
utf8_bin 6109
|
||||
utf8_bin 61
|
||||
utf8_bin 6120
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
user varchar(255) NOT NULL default ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES ('one'),('two');
|
||||
SELECT CHARSET('a');
|
||||
CHARSET('a')
|
||||
utf8
|
||||
SELECT user, CONCAT('<', user, '>') AS c FROM t1;
|
||||
user c
|
||||
one <one>
|
||||
two <two>
|
||||
DROP TABLE t1;
|
||||
select convert(_koi8r'<27>' using utf8) < convert(_koi8r'<27>' using utf8);
|
||||
convert(_koi8r'<27>' using utf8) < convert(_koi8r'<27>' using utf8)
|
||||
1
|
||||
|
@ -296,6 +296,9 @@ Tuesday 52 2001 %W %V %X 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'),
|
||||
|
@ -16,12 +16,34 @@ SET AUTOCOMMIT=0;
|
||||
DELETE from t1;
|
||||
SET AUTOCOMMIT=1;
|
||||
drop table t1;
|
||||
create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a));
|
||||
insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23);
|
||||
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, primary key (a,a,a,a,a,a,a,a,a,a));
|
||||
insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27);
|
||||
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` (
|
||||
@ -141,3 +163,12 @@ 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;
|
||||
|
@ -330,3 +330,31 @@ SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MA
|
||||
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 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;
|
||||
|
@ -190,7 +190,7 @@ 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 10 Using where; Using index; Distinct
|
||||
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
|
||||
|
@ -1,5 +1,6 @@
|
||||
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);
|
||||
|
@ -1,7 +1,9 @@
|
||||
reset master;
|
||||
create database `drop-temp+table-test`;
|
||||
use `drop-temp+table-test`;
|
||||
create temporary table shortn1 (a int);
|
||||
create temporary table `table:name` (a int);
|
||||
create temporary table shortn2 (a int);
|
||||
select get_lock("a",10);
|
||||
get_lock("a",10)
|
||||
1
|
||||
@ -10,9 +12,11 @@ get_lock("a",10)
|
||||
1
|
||||
show binlog events;
|
||||
Log_name Pos Event_type Server_id Orig_log_pos Info
|
||||
master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
|
||||
master-bin.000001 79 Query 1 79 use `test`; create database `drop-temp+table-test`
|
||||
master-bin.000001 152 Query 1 152 use `drop-temp+table-test`; create temporary table `table:name` (a int)
|
||||
master-bin.000001 246 Query 1 246 use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `drop-temp+table-test`.`table:name`
|
||||
master-bin.000001 375 Query 1 375 use `drop-temp+table-test`; DO RELEASE_LOCK("a")
|
||||
master-bin.000001 # Start 1 # Server ver: VERSION, Binlog ver: 3
|
||||
master-bin.000001 # Query 1 # create database `drop-temp+table-test`
|
||||
master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table shortn1 (a int)
|
||||
master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table `table:name` (a int)
|
||||
master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table shortn2 (a int)
|
||||
master-bin.000001 # Query 1 # use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `drop-temp+table-test`.`shortn2`,`drop-temp+table-test`.`table:name`,`drop-temp+table-test`.`shortn1`
|
||||
master-bin.000001 # Query 1 # use `drop-temp+table-test`; DO RELEASE_LOCK("a")
|
||||
drop database `drop-temp+table-test`;
|
||||
|
@ -20,4 +20,20 @@ commit;
|
||||
a
|
||||
1
|
||||
unlock tables;
|
||||
commit;
|
||||
begin;
|
||||
insert into t1 values(10);
|
||||
flush tables with read lock;
|
||||
commit;
|
||||
unlock tables;
|
||||
flush tables with read lock;
|
||||
unlock tables;
|
||||
begin;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
10
|
||||
show create database test;
|
||||
Database Create Database
|
||||
test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */
|
||||
drop table t1;
|
||||
|
@ -148,6 +148,9 @@ select * from t1 where MATCH a,b AGAINST ('+(support collections) +foobar*' IN B
|
||||
a b
|
||||
select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE);
|
||||
a b
|
||||
select * from t1 where MATCH a,b AGAINST ('+collections -supp* -foobar*' IN BOOLEAN MODE);
|
||||
a b
|
||||
Full-text indexes are called collections
|
||||
select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE);
|
||||
a b
|
||||
select * from t1 where MATCH a,b AGAINST('"space model' IN BOOLEAN MODE);
|
||||
@ -190,6 +193,14 @@ a
|
||||
select * from t1 where match a against ("+aaa10 +(bbb*)" in boolean mode);
|
||||
a
|
||||
aaa10 bbb20
|
||||
select * from t1 where match a against ("+(+aaa* +bbb1*)" in boolean mode);
|
||||
a
|
||||
aaa20 bbb15
|
||||
aaa30 bbb10
|
||||
select * from t1 where match a against ("(+aaa* +bbb1*)" in boolean mode);
|
||||
a
|
||||
aaa20 bbb15
|
||||
aaa30 bbb10
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
id int(11),
|
||||
@ -330,6 +341,9 @@ t1_id name t2_id t1_id name
|
||||
select * from t2 where match name against ('a* b* c* d* e* f*' in boolean mode);
|
||||
t2_id t1_id name
|
||||
drop table t1,t2;
|
||||
create table t1 (a text, fulltext key (a));
|
||||
insert into t1 select "xxxx yyyy zzzz";
|
||||
drop table t1;
|
||||
SET NAMES latin1;
|
||||
CREATE TABLE t1 (t text character set utf8 not null, fulltext(t));
|
||||
INSERT t1 VALUES ('Mit freundlichem Gr<47><72>'), ('aus Osnabr<62>ck');
|
||||
@ -352,10 +366,15 @@ t collation(t)
|
||||
aus Osnabr<62>ck utf8_general_ci
|
||||
SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrueck');
|
||||
t collation(t)
|
||||
SELECT t, collation(t),MATCH t AGAINST ('Osnabruck') FROM t1 WHERE MATCH t AGAINST ('Osnabruck');
|
||||
t collation(t) MATCH t AGAINST ('Osnabruck')
|
||||
aus Osnabr<62>ck utf8_general_ci 1.591139793396
|
||||
SELECT t, collation(t),FORMAT(MATCH t AGAINST ('Osnabruck'),6) FROM t1 WHERE MATCH t AGAINST ('Osnabruck');
|
||||
t collation(t) FORMAT(MATCH t AGAINST ('Osnabruck'),6)
|
||||
aus Osnabr<62>ck utf8_general_ci 1.591140
|
||||
alter table t1 modify t varchar(200) collate latin1_german2_ci not null;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 't' at row 3
|
||||
Warning 1265 Data truncated for column 't' at row 4
|
||||
Warning 1265 Data truncated for column 't' at row 5
|
||||
Warning 1265 Data truncated for column 't' at row 6
|
||||
SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabr<62>ck');
|
||||
t collation(t)
|
||||
aus Osnabr<62>ck latin1_german2_ci
|
||||
@ -374,3 +393,31 @@ s
|
||||
p<EFBFBD>ra para para
|
||||
para para para
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (h text, FULLTEXT (h));
|
||||
INSERT INTO t1 VALUES ('Jesses Hasse Ling and his syncopators of Swing');
|
||||
REPAIR TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 repair status OK
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( a TEXT, FULLTEXT (a) );
|
||||
INSERT INTO t1 VALUES ('testing ft_nlq_find_relevance');
|
||||
SELECT MATCH(a) AGAINST ('nosuchword') FROM t1;
|
||||
MATCH(a) AGAINST ('nosuchword')
|
||||
0
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int primary key, b text, fulltext(b));
|
||||
create table t2 (a int, b text);
|
||||
insert t1 values (1, "aaaa"), (2, "bbbb");
|
||||
insert t2 values (10, "aaaa"), (2, "cccc");
|
||||
replace t1 select * from t2;
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1 (t VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci, FULLTEXT (t));
|
||||
SET NAMES latin1;
|
||||
INSERT INTO t1 VALUES('Mit freundlichem Gr<47><72> aus Osnabr<62>ck');
|
||||
SELECT COUNT(*) FROM t1 WHERE MATCH(t) AGAINST ('"osnabr<62>ck"' IN BOOLEAN MODE);
|
||||
COUNT(*)
|
||||
1
|
||||
DROP TABLE t1;
|
||||
|
@ -21,17 +21,17 @@ INSERT INTO t2 VALUES (5,2,'um copo de Vodka');
|
||||
INSERT INTO t2 VALUES (6,2,'um chocolate Snickers');
|
||||
INSERT INTO t2 VALUES (7,1,'Bife');
|
||||
INSERT INTO t2 VALUES (8,1,'Pizza de Salmao');
|
||||
SELECT t1.q, t2.item, t2.id, round(MATCH t2.item AGAINST ('sushi'),8)
|
||||
SELECT t1.q, t2.item, t2.id, round(MATCH t2.item AGAINST ('sushi'),6)
|
||||
as x FROM t1, t2 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id;
|
||||
q item id x
|
||||
aaaaaaaaa dsaass de sushi 1 1.92378664
|
||||
aaaaaaaaa dsaass de Bolo de Chocolate 2 0.00000000
|
||||
aaaaaaaaa dsaass de Feijoada 3 0.00000000
|
||||
aaaaaaaaa dsaass de Mousse de Chocolate 4 0.00000000
|
||||
ssde df s fsda sad er um copo de Vodka 5 0.00000000
|
||||
ssde df s fsda sad er um chocolate Snickers 6 0.00000000
|
||||
aaaaaaaaa dsaass de Bife 7 0.00000000
|
||||
aaaaaaaaa dsaass de Pizza de Salmao 8 0.00000000
|
||||
aaaaaaaaa dsaass de sushi 1 1.923787
|
||||
aaaaaaaaa dsaass de Bolo de Chocolate 2 0.000000
|
||||
aaaaaaaaa dsaass de Feijoada 3 0.000000
|
||||
aaaaaaaaa dsaass de Mousse de Chocolate 4 0.000000
|
||||
ssde df s fsda sad er um copo de Vodka 5 0.000000
|
||||
ssde df s fsda sad er um chocolate Snickers 6 0.000000
|
||||
aaaaaaaaa dsaass de Bife 7 0.000000
|
||||
aaaaaaaaa dsaass de Pizza de Salmao 8 0.000000
|
||||
SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi' IN BOOLEAN MODE)
|
||||
as x FROM t1, t2 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id;
|
||||
q item id x
|
||||
@ -43,17 +43,17 @@ ssde df s fsda sad er um copo de Vodka 5 0
|
||||
ssde df s fsda sad er um chocolate Snickers 6 0
|
||||
aaaaaaaaa dsaass de Bife 7 0
|
||||
aaaaaaaaa dsaass de Pizza de Salmao 8 0
|
||||
SELECT t1.q, t2.item, t2.id, round(MATCH t2.item AGAINST ('sushi'),8)
|
||||
SELECT t1.q, t2.item, t2.id, round(MATCH t2.item AGAINST ('sushi'),6)
|
||||
as x FROM t2, t1 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id;
|
||||
q item id x
|
||||
aaaaaaaaa dsaass de sushi 1 1.92378664
|
||||
aaaaaaaaa dsaass de Bolo de Chocolate 2 0.00000000
|
||||
aaaaaaaaa dsaass de Feijoada 3 0.00000000
|
||||
aaaaaaaaa dsaass de Mousse de Chocolate 4 0.00000000
|
||||
ssde df s fsda sad er um copo de Vodka 5 0.00000000
|
||||
ssde df s fsda sad er um chocolate Snickers 6 0.00000000
|
||||
aaaaaaaaa dsaass de Bife 7 0.00000000
|
||||
aaaaaaaaa dsaass de Pizza de Salmao 8 0.00000000
|
||||
aaaaaaaaa dsaass de sushi 1 1.923787
|
||||
aaaaaaaaa dsaass de Bolo de Chocolate 2 0.000000
|
||||
aaaaaaaaa dsaass de Feijoada 3 0.000000
|
||||
aaaaaaaaa dsaass de Mousse de Chocolate 4 0.000000
|
||||
ssde df s fsda sad er um copo de Vodka 5 0.000000
|
||||
ssde df s fsda sad er um chocolate Snickers 6 0.000000
|
||||
aaaaaaaaa dsaass de Bife 7 0.000000
|
||||
aaaaaaaaa dsaass de Pizza de Salmao 8 0.000000
|
||||
SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi' IN BOOLEAN MODE)
|
||||
as x FROM t2, t1 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id;
|
||||
q item id x
|
||||
|
@ -6,53 +6,53 @@ FULLTEXT(message)
|
||||
) comment = 'original testcase by sroussey@network54.com';
|
||||
INSERT INTO t1 (message) VALUES ("Testing"),("table"),("testbug"),
|
||||
("steve"),("is"),("cool"),("steve is cool");
|
||||
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve');
|
||||
a MATCH (message) AGAINST ('steve')
|
||||
4 0.90587323904037
|
||||
7 0.89568990468979
|
||||
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve');
|
||||
a FORMAT(MATCH (message) AGAINST ('steve'),6)
|
||||
4 0.905873
|
||||
7 0.895690
|
||||
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve');
|
||||
a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE)
|
||||
4 1
|
||||
7 1
|
||||
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE);
|
||||
a MATCH (message) AGAINST ('steve')
|
||||
4 0.90587323904037
|
||||
7 0.89568990468979
|
||||
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE);
|
||||
a FORMAT(MATCH (message) AGAINST ('steve'),6)
|
||||
4 0.905873
|
||||
7 0.895690
|
||||
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE);
|
||||
a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE)
|
||||
4 1
|
||||
7 1
|
||||
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY a;
|
||||
a MATCH (message) AGAINST ('steve')
|
||||
4 0.90587323904037
|
||||
7 0.89568990468979
|
||||
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY a;
|
||||
a FORMAT(MATCH (message) AGAINST ('steve'),6)
|
||||
4 0.905873
|
||||
7 0.895690
|
||||
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a;
|
||||
a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE)
|
||||
4 1
|
||||
7 1
|
||||
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve') ORDER BY a DESC;
|
||||
a MATCH (message) AGAINST ('steve')
|
||||
7 0.89568990468979
|
||||
4 0.90587323904037
|
||||
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve') ORDER BY a DESC;
|
||||
a FORMAT(MATCH (message) AGAINST ('steve'),6)
|
||||
7 0.895690
|
||||
4 0.905873
|
||||
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a DESC;
|
||||
a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE)
|
||||
7 1
|
||||
4 1
|
||||
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve') ORDER BY 1;
|
||||
a MATCH (message) AGAINST ('steve')
|
||||
7 0.89568990468979
|
||||
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve') ORDER BY 1;
|
||||
a FORMAT(MATCH (message) AGAINST ('steve'),6)
|
||||
7 0.895690
|
||||
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY 1;
|
||||
a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE)
|
||||
7 1
|
||||
SELECT a, MATCH (message) AGAINST ('steve') as rel FROM t1 ORDER BY rel;
|
||||
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) as rel FROM t1 ORDER BY rel;
|
||||
a rel
|
||||
1 0
|
||||
2 0
|
||||
3 0
|
||||
5 0
|
||||
6 0
|
||||
7 0.89568990468979
|
||||
4 0.90587323904037
|
||||
1 0.000000
|
||||
2 0.000000
|
||||
3 0.000000
|
||||
5 0.000000
|
||||
6 0.000000
|
||||
7 0.895690
|
||||
4 0.905873
|
||||
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel;
|
||||
a rel
|
||||
1 0
|
||||
|
@ -69,6 +69,6 @@ Error 1259 ZLIB: Input data corrupted
|
||||
Error 1256 Uncompressed data size too large; the maximum size is 1048576 (probably, length of uncompressed data was corrupted)
|
||||
drop table t1;
|
||||
set @@max_allowed_packet=1048576*100;
|
||||
select compress(repeat('aaaaaaaaaa', 10000000)) is null;
|
||||
compress(repeat('aaaaaaaaaa', 10000000)) is null
|
||||
select compress(repeat('aaaaaaaaaa', IF(XXX, 10, 10000000))) is null;
|
||||
compress(repeat('aaaaaaaaaa', IF(XXX, 10, 10000000))) is null
|
||||
0
|
||||
|
@ -32,3 +32,35 @@ 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
|
||||
good
|
||||
|
@ -457,3 +457,8 @@ group_concat(distinct b order by b)
|
||||
Warnings:
|
||||
Warning 1260 2 line(s) were cut by GROUP_CONCAT()
|
||||
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;
|
||||
|
@ -637,8 +637,22 @@ create table t1 (a char(10));
|
||||
insert into t1 values ('a'),('b'),('c');
|
||||
select coercibility(max(a)) from t1;
|
||||
coercibility(max(a))
|
||||
3
|
||||
2
|
||||
drop table t1;
|
||||
create table t1 (a char character set latin2);
|
||||
insert into t1 values ('a'),('b');
|
||||
select charset(max(a)), coercibility(max(a)),
|
||||
charset(min(a)), coercibility(min(a)) from t1;
|
||||
charset(max(a)) coercibility(max(a)) charset(min(a)) coercibility(min(a))
|
||||
latin2 2 latin2 2
|
||||
create table t2 select max(a),min(a) from t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`max(a)` char(1) character set latin2 default NULL,
|
||||
`min(a)` char(1) character set latin2 default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t2,t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1);
|
||||
select max(a) as b from t1 having b=1;
|
||||
@ -719,3 +733,15 @@ one 2
|
||||
two 2
|
||||
three 1
|
||||
drop table t1;
|
||||
create table t1(f1 datetime);
|
||||
insert into t1 values (now());
|
||||
create table t2 select f2 from (select max(now()) f2 from t1) a;
|
||||
show columns from t2;
|
||||
Field Type Null Key Default Extra
|
||||
f2 datetime 0000-00-00 00:00:00
|
||||
drop table t2;
|
||||
create table t2 select f2 from (select now() f2 from t1) a;
|
||||
show columns from t2;
|
||||
Field Type Null Key Default Extra
|
||||
f2 datetime 0000-00-00 00:00:00
|
||||
drop table t2, t1;
|
||||
|
@ -157,6 +157,14 @@ 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)
|
||||
@ -179,3 +187,9 @@ select 1 in ('1.1',2);
|
||||
select 1 in ('1.1',2.0);
|
||||
1 in ('1.1',2.0)
|
||||
0
|
||||
create table t1 (a char(20) character set binary);
|
||||
insert into t1 values ('aa'), ('bb');
|
||||
select * from t1 where a in (NULL, 'aa');
|
||||
a
|
||||
aa
|
||||
drop table t1;
|
||||
|
@ -124,3 +124,5 @@ 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
|
||||
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'
|
||||
|
@ -28,3 +28,24 @@ length(format('nan', 2)) > 0
|
||||
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;
|
||||
|
@ -97,13 +97,16 @@ 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")
|
||||
-23:59:59.999999
|
||||
-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
|
||||
@ -175,7 +178,7 @@ 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 -23:59:59 10:11:12 2001-12-01 01:01:01 1997-12-31 23:59:59
|
||||
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'),
|
||||
|
@ -201,6 +201,9 @@ hex(unhex("1")) hex(unhex("12")) hex(unhex("123")) hex(unhex("1234")) hex(unhex(
|
||||
select length(unhex(md5("abrakadabra")));
|
||||
length(unhex(md5("abrakadabra")))
|
||||
16
|
||||
select concat('a', quote(NULL));
|
||||
concat('a', quote(NULL))
|
||||
aNULL
|
||||
select reverse("");
|
||||
reverse("")
|
||||
|
||||
@ -312,7 +315,7 @@ insert into t1 values ('one'),(NULL),('two'),('four');
|
||||
select a, quote(a), isnull(quote(a)), quote(a) is null, ifnull(quote(a), 'n') from t1;
|
||||
a quote(a) isnull(quote(a)) quote(a) is null ifnull(quote(a), 'n')
|
||||
one 'one' 0 0 'one'
|
||||
NULL NULL 1 1 n
|
||||
NULL NULL 0 0 NULL
|
||||
two 'two' 0 0 'two'
|
||||
four 'four' 0 0 'four'
|
||||
drop table t1;
|
||||
@ -322,6 +325,19 @@ trim(trailing 'foo' from 'foo')
|
||||
select trim(leading 'foo' from 'foo');
|
||||
trim(leading 'foo' from 'foo')
|
||||
|
||||
select quote(ltrim(concat(' ', 'a')));
|
||||
quote(ltrim(concat(' ', 'a')))
|
||||
'a'
|
||||
select quote(trim(concat(' ', 'a')));
|
||||
quote(trim(concat(' ', 'a')))
|
||||
'a'
|
||||
CREATE TABLE t1 SELECT 1 UNION SELECT 2 UNION SELECT 3;
|
||||
SELECT QUOTE('A') FROM t1;
|
||||
QUOTE('A')
|
||||
'A'
|
||||
'A'
|
||||
'A'
|
||||
DROP TABLE t1;
|
||||
select 1=_latin1'1';
|
||||
1=_latin1'1'
|
||||
1
|
||||
@ -460,7 +476,7 @@ collation(hex(130)) coercibility(hex(130))
|
||||
latin1_swedish_ci 3
|
||||
select collation(char(130)), coercibility(hex(130));
|
||||
collation(char(130)) coercibility(hex(130))
|
||||
binary 3
|
||||
latin1_swedish_ci 3
|
||||
select collation(format(130,10)), coercibility(format(130,10));
|
||||
collation(format(130,10)) coercibility(format(130,10))
|
||||
latin1_swedish_ci 3
|
||||
@ -682,3 +698,44 @@ drop table t1;
|
||||
select left(1234, 3) + 0;
|
||||
left(1234, 3) + 0
|
||||
123
|
||||
create table t1 (a int not null primary key, b varchar(40), c datetime);
|
||||
insert into t1 (a,b,c) values (1,'Tom','2004-12-10 12:13:14'),(2,'ball games','2004-12-10 12:13:14'), (3,'Basil','2004-12-10 12:13:14'), (4,'Dean','2004-12-10 12:13:14'),(5,'Ellis','2004-12-10 12:13:14'), (6,'Serg','2004-12-10 12:13:14'), (7,'Sergei','2004-12-10 12:13:14'),(8,'Georg','2004-12-10 12:13:14'),(9,'Salle','2004-12-10 12:13:14'),(10,'Sinisa','2004-12-10 12:13:14');
|
||||
select count(*) as total, left(c,10) as reg from t1 group by reg order by reg desc limit 0,12;
|
||||
total reg
|
||||
10 2004-12-10
|
||||
drop table t1;
|
||||
select trim(null from 'kate') as "must_be_null";
|
||||
must_be_null
|
||||
NULL
|
||||
select trim('xyz' from null) as "must_be_null";
|
||||
must_be_null
|
||||
NULL
|
||||
CREATE TABLE t1 (
|
||||
id int(11) NOT NULL auto_increment,
|
||||
a bigint(20) unsigned default NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES
|
||||
('0','16307858876001849059');
|
||||
SELECT CONV('e251273eb74a8ee3', 16, 10);
|
||||
CONV('e251273eb74a8ee3', 16, 10)
|
||||
16307858876001849059
|
||||
EXPLAIN
|
||||
SELECT id
|
||||
FROM t1
|
||||
WHERE a = 16307858876001849059;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
||||
EXPLAIN
|
||||
SELECT id
|
||||
FROM t1
|
||||
WHERE a = CONV('e251273eb74a8ee3', 16, 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
||||
DROP TABLE t1;
|
||||
SELECT CHAR(NULL,121,83,81,'76') as my_column;
|
||||
my_column
|
||||
ySQL
|
||||
SELECT CHAR_LENGTH(CHAR(NULL,121,83,81,'76')) as my_column;
|
||||
my_column
|
||||
4
|
||||
|
@ -474,6 +474,15 @@ unix_timestamp(@a)
|
||||
select unix_timestamp('1969-12-01 19:00:01');
|
||||
unix_timestamp('1969-12-01 19:00:01')
|
||||
0
|
||||
select from_unixtime(-1);
|
||||
from_unixtime(-1)
|
||||
NULL
|
||||
select from_unixtime(2145916800);
|
||||
from_unixtime(2145916800)
|
||||
NULL
|
||||
select from_unixtime(0);
|
||||
from_unixtime(0)
|
||||
1970-01-01 03:00:00
|
||||
CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time);
|
||||
INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02", "06:07:08");
|
||||
SELECT * from t1;
|
||||
|
@ -757,3 +757,50 @@ SPATIAL KEY(g)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText('LineString(1 2, 2 4)'));
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
geoobjid INT NOT NULL,
|
||||
line LINESTRING NOT NULL,
|
||||
kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po',
|
||||
name VARCHAR(32),
|
||||
SPATIAL KEY (line)
|
||||
) engine=myisam;
|
||||
ALTER TABLE t1 DISABLE KEYS;
|
||||
INSERT INTO t1 (name, kind, line) VALUES
|
||||
("Aadaouane", "pp", GeomFromText("POINT(32.816667 35.983333)")),
|
||||
("Aadassiye", "pp", GeomFromText("POINT(35.816667 36.216667)")),
|
||||
("Aadbel", "pp", GeomFromText("POINT(34.533333 36.100000)")),
|
||||
("Aadchit", "pp", GeomFromText("POINT(33.347222 35.423611)")),
|
||||
("Aadchite", "pp", GeomFromText("POINT(33.347222 35.423611)")),
|
||||
("Aadchit el Qoussair", "pp", GeomFromText("POINT(33.283333 35.483333)")),
|
||||
("Aaddaye", "pp", GeomFromText("POINT(36.716667 40.833333)")),
|
||||
("'Aadeissa", "pp", GeomFromText("POINT(32.823889 35.698889)")),
|
||||
("Aaderup", "pp", GeomFromText("POINT(55.216667 11.766667)")),
|
||||
("Qalaat Aades", "pp", GeomFromText("POINT(33.503333 35.377500)")),
|
||||
("A ad'ino", "pp", GeomFromText("POINT(54.812222 38.209167)")),
|
||||
("Aadi Noia", "pp", GeomFromText("POINT(13.800000 39.833333)")),
|
||||
("Aad La Macta", "pp", GeomFromText("POINT(35.779444 -0.129167)")),
|
||||
("Aadland", "pp", GeomFromText("POINT(60.366667 5.483333)")),
|
||||
("Aadliye", "pp", GeomFromText("POINT(33.366667 36.333333)")),
|
||||
("Aadloun", "pp", GeomFromText("POINT(33.403889 35.273889)")),
|
||||
("Aadma", "pp", GeomFromText("POINT(58.798333 22.663889)")),
|
||||
("Aadma Asundus", "pp", GeomFromText("POINT(58.798333 22.663889)")),
|
||||
("Aadmoun", "pp", GeomFromText("POINT(34.150000 35.650000)")),
|
||||
("Aadneram", "pp", GeomFromText("POINT(59.016667 6.933333)")),
|
||||
("Aadneskaar", "pp", GeomFromText("POINT(58.083333 6.983333)")),
|
||||
("Aadorf", "pp", GeomFromText("POINT(47.483333 8.900000)")),
|
||||
("Aadorp", "pp", GeomFromText("POINT(52.366667 6.633333)")),
|
||||
("Aadouane", "pp", GeomFromText("POINT(32.816667 35.983333)")),
|
||||
("Aadoui", "pp", GeomFromText("POINT(34.450000 35.983333)")),
|
||||
("Aadouiye", "pp", GeomFromText("POINT(34.583333 36.183333)")),
|
||||
("Aadouss", "pp", GeomFromText("POINT(33.512500 35.601389)")),
|
||||
("Aadra", "pp", GeomFromText("POINT(33.616667 36.500000)")),
|
||||
("Aadzi", "pp", GeomFromText("POINT(38.100000 64.850000)"));
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
INSERT INTO t1 (name, kind, line) VALUES ("austria", "pp", GeomFromText('LINESTRING(14.9906 48.9887,14.9946 48.9904,14.9947 48.9916)'));
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (st varchar(100));
|
||||
INSERT INTO t1 VALUES ("Fake string");
|
||||
CREATE TABLE t2 (geom GEOMETRY NOT NULL, SPATIAL KEY gk(geom));
|
||||
INSERT INTO t2 SELECT GeomFromText(st) FROM t1;
|
||||
ERROR HY000: Unknown error
|
||||
drop table t1, t2;
|
||||
|
@ -581,3 +581,77 @@ t1 CREATE TABLE `t1` (
|
||||
`POINT(1,3)` longblob NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (`object_id` bigint(20) unsigned NOT NULL default '0', `geo`
|
||||
geometry NOT NULL default '') ENGINE=MyISAM ;
|
||||
insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363
|
||||
36.305435,-114.992394 36.305202,-114.991219 36.305975,-114.991163
|
||||
36.306845,-114.989432 36.309452,-114.978275 36.312642,-114.977363
|
||||
36.311978,-114.975327 36.312344,-114.96502 36.31597,-114.963364
|
||||
36.313629,-114.961723 36.313721,-114.956398 36.316057,-114.951882
|
||||
36.320979,-114.947073 36.323475,-114.945207 36.326451,-114.945207
|
||||
36.326451,-114.944132 36.326061,-114.94003 36.326588,-114.924017
|
||||
36.334484,-114.923281 36.334146,-114.92564 36.331504,-114.94072
|
||||
36.319282,-114.945348 36.314812,-114.948091 36.314762,-114.951755
|
||||
36.316211,-114.952446 36.313883,-114.952644 36.309488,-114.944725
|
||||
36.313083,-114.93706 36.32043,-114.932478 36.323497,-114.924556
|
||||
36.327708,-114.922608 36.329715,-114.92009 36.328695,-114.912105
|
||||
36.323566,-114.901647 36.317952,-114.897436 36.313968,-114.895344
|
||||
36.309573,-114.891699 36.304398,-114.890569 36.303551,-114.886356
|
||||
36.302702,-114.885141 36.301351,-114.885709 36.297391,-114.892499
|
||||
36.290893,-114.902142 36.288974,-114.904941 36.288838,-114.905308
|
||||
36.289845,-114.906325 36.290395,-114.909916 36.289549,-114.914527
|
||||
36.287535,-114.918797 36.284423,-114.922982 36.279731,-114.924113
|
||||
36.277282,-114.924057 36.275817,-114.927733 36.27053,-114.929354
|
||||
36.269029,-114.929354 36.269029,-114.950856 36.268715,-114.950768
|
||||
36.264324,-114.960206 36.264293,-114.960301 36.268943,-115.006662
|
||||
36.268929,-115.008583 36.265619,-115.00665 36.264247,-115.006659
|
||||
36.246873,-115.006659 36.246873,-115.006838 36.247697,-115.010764
|
||||
36.247774,-115.015609 36.25113,-115.015765 36.254505,-115.029517
|
||||
36.254619,-115.038573 36.249317,-115.038573 36.249317,-115.023403
|
||||
36.25841,-115.023873 36.258994,-115.031845 36.259829,-115.03183
|
||||
36.261053,-115.025561 36.261095,-115.036417 36.274632,-115.033729
|
||||
36.276041,-115.032217 36.274851,-115.029845 36.273959,-115.029934
|
||||
36.274966,-115.025763 36.274896,-115.025406 36.281044,-115.028731
|
||||
36.284471,-115.036497 36.290377,-115.042071 36.291039,-115.026759
|
||||
36.298478,-115.008995 36.301966,-115.006363 36.305435),(-115.079835
|
||||
36.244369,-115.079735 36.260186,-115.076435 36.262369,-115.069758
|
||||
36.265,-115.070235 36.268757,-115.064542 36.268655,-115.061843
|
||||
36.269857,-115.062676 36.270693,-115.06305 36.272344,-115.059051
|
||||
36.281023,-115.05918 36.283008,-115.060591 36.285246,-115.061913
|
||||
36.290022,-115.062499 36.306353,-115.062499 36.306353,-115.060918
|
||||
36.30642,-115.06112 36.289779,-115.05713 36.2825,-115.057314
|
||||
36.279446,-115.060779 36.274659,-115.061366 36.27209,-115.057858
|
||||
36.26557,-115.055805 36.262883,-115.054688 36.262874,-115.047335
|
||||
36.25037,-115.044234 36.24637,-115.052434 36.24047,-115.061734
|
||||
36.23507,-115.061934 36.22677,-115.061934 36.22677,-115.061491
|
||||
36.225267,-115.062024 36.218194,-115.060134 36.218278,-115.060133
|
||||
36.210771,-115.057833 36.210771,-115.057433 36.196271,-115.062233
|
||||
36.196271,-115.062233 36.190371,-115.062233 36.190371,-115.065533
|
||||
36.190371,-115.071333 36.188571,-115.098331 36.188275,-115.098331
|
||||
36.188275,-115.098435 36.237569,-115.097535 36.240369,-115.097535
|
||||
36.240369,-115.093235 36.240369,-115.089135 36.240469,-115.083135
|
||||
36.240569,-115.083135 36.240569,-115.079835
|
||||
36.244369)))')),('85998',GeomFromText('MULTIPOLYGON(((-115.333107
|
||||
36.264587,-115.333168 36.280638,-115.333168 36.280638,-115.32226
|
||||
36.280643,-115.322538 36.274311,-115.327222 36.274258,-115.32733
|
||||
36.263026,-115.330675 36.262984,-115.332132 36.264673,-115.333107
|
||||
36.264587),(-115.247239 36.247066,-115.247438 36.218267,-115.247438
|
||||
36.218267,-115.278525 36.219263,-115.278525 36.219263,-115.301545
|
||||
36.219559,-115.332748 36.219197,-115.332757 36.220041,-115.332757
|
||||
36.220041,-115.332895 36.233514,-115.349023 36.233479,-115.351489
|
||||
36.234475,-115.353681 36.237021,-115.357106 36.239789,-115.36519
|
||||
36.243331,-115.368156 36.243487,-115.367389 36.244902,-115.364553
|
||||
36.246014,-115.359219 36.24616,-115.356186 36.248025,-115.353347
|
||||
36.248004,-115.350813 36.249507,-115.339673 36.25387,-115.333069
|
||||
36.255018,-115.333069 36.255018,-115.333042 36.247767,-115.279039
|
||||
36.248666,-115.263639 36.247466,-115.263839 36.252766,-115.261439
|
||||
36.252666,-115.261439 36.247366,-115.247239 36.247066)))'));
|
||||
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
|
||||
t1 where object_id=85998;
|
||||
object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo))
|
||||
85998 MULTIPOLYGON 0 POINT(115.31877315203 -36.237472821022)
|
||||
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
|
||||
t1 where object_id=85984;
|
||||
object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo))
|
||||
85984 MULTIPOLYGON 0 POINT(-114.87787186923 36.33101763469)
|
||||
drop table t1;
|
||||
|
@ -37,6 +37,28 @@ Grants for mysqltest_1@localhost
|
||||
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE ISSUER 'MySQL AB' SUBJECT 'testsubject' CIPHER 'EDH-RSA-DES-CBC3-SHA'
|
||||
delete from mysql.user where user='mysqltest_1';
|
||||
flush privileges;
|
||||
delete from mysql.user where user='mysqltest_1';
|
||||
flush privileges;
|
||||
grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 10;
|
||||
select * from mysql.user where user="mysqltest_1";
|
||||
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections
|
||||
localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N 10 0 0
|
||||
show grants for mysqltest_1@localhost;
|
||||
Grants for mysqltest_1@localhost
|
||||
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_QUERIES_PER_HOUR 10
|
||||
grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 20 max_connections_per_hour 30;
|
||||
select * from mysql.user where user="mysqltest_1";
|
||||
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections
|
||||
localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N 10 20 30
|
||||
show grants for mysqltest_1@localhost;
|
||||
Grants for mysqltest_1@localhost
|
||||
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_QUERIES_PER_HOUR 10 MAX_UPDATES_PER_HOUR 20 MAX_CONNECTIONS_PER_HOUR 30
|
||||
flush privileges;
|
||||
show grants for mysqltest_1@localhost;
|
||||
Grants for mysqltest_1@localhost
|
||||
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_QUERIES_PER_HOUR 10 MAX_UPDATES_PER_HOUR 20 MAX_CONNECTIONS_PER_HOUR 30
|
||||
delete from mysql.user where user='mysqltest_1';
|
||||
flush privileges;
|
||||
grant CREATE TEMPORARY TABLES, LOCK TABLES on mysqltest.* to mysqltest_1@localhost;
|
||||
show grants for mysqltest_1@localhost;
|
||||
Grants for mysqltest_1@localhost
|
||||
@ -134,6 +156,31 @@ ERROR HY000: Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
|
||||
select 1;
|
||||
1
|
||||
1
|
||||
insert into mysql.user (host, user) values ('localhost', 'test11');
|
||||
insert into mysql.db (host, db, user, select_priv) values
|
||||
('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y');
|
||||
alter table mysql.db order by db asc;
|
||||
flush privileges;
|
||||
show grants for test11@localhost;
|
||||
Grants for test11@localhost
|
||||
GRANT USAGE ON *.* TO 'test11'@'localhost'
|
||||
GRANT SELECT ON `ab%`.* TO 'test11'@'localhost'
|
||||
GRANT SELECT ON `a%`.* TO 'test11'@'localhost'
|
||||
alter table mysql.db order by db desc;
|
||||
flush privileges;
|
||||
show grants for test11@localhost;
|
||||
Grants for test11@localhost
|
||||
GRANT USAGE ON *.* TO 'test11'@'localhost'
|
||||
GRANT SELECT ON `ab%`.* TO 'test11'@'localhost'
|
||||
GRANT SELECT ON `a%`.* TO 'test11'@'localhost'
|
||||
delete from mysql.user where user='test11';
|
||||
delete from mysql.db where user='test11';
|
||||
create database mysqltest1;
|
||||
grant usage on mysqltest1.* to test6123 identified by 'magic123';
|
||||
select host,db,user,select_priv,insert_priv from mysql.db where db="mysqltest1";
|
||||
host db user select_priv insert_priv
|
||||
delete from mysql.user where user='test6123';
|
||||
drop database mysqltest1;
|
||||
create table t1 (a int);
|
||||
grant ALL PRIVILEGES on *.* to drop_user2@localhost with GRANT OPTION;
|
||||
show grants for drop_user2@localhost;
|
||||
@ -229,25 +276,6 @@ GRANT SELECT (
|
||||
REVOKE SELECT (<28><><EFBFBD>) ON <20><>.<2E><><EFBFBD> FROM <20><><EFBFBD><EFBFBD>@localhost;
|
||||
DROP DATABASE <20><>;
|
||||
SET NAMES latin1;
|
||||
insert into mysql.user (host, user) values ('localhost', 'test11');
|
||||
insert into mysql.db (host, db, user, select_priv) values
|
||||
('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y');
|
||||
alter table mysql.db order by db asc;
|
||||
flush privileges;
|
||||
show grants for test11@localhost;
|
||||
Grants for test11@localhost
|
||||
GRANT USAGE ON *.* TO 'test11'@'localhost'
|
||||
GRANT SELECT ON `ab%`.* TO 'test11'@'localhost'
|
||||
GRANT SELECT ON `a%`.* TO 'test11'@'localhost'
|
||||
alter table mysql.db order by db desc;
|
||||
flush privileges;
|
||||
show grants for test11@localhost;
|
||||
Grants for test11@localhost
|
||||
GRANT USAGE ON *.* TO 'test11'@'localhost'
|
||||
GRANT SELECT ON `ab%`.* TO 'test11'@'localhost'
|
||||
GRANT SELECT ON `a%`.* TO 'test11'@'localhost'
|
||||
delete from mysql.user where user='test11';
|
||||
delete from mysql.db where user='test11';
|
||||
USE test;
|
||||
CREATE TABLE t1 (a int );
|
||||
CREATE TABLE t2 LIKE t1;
|
||||
@ -315,3 +343,87 @@ DROP DATABASE testdb7;
|
||||
DROP DATABASE testdb8;
|
||||
DROP DATABASE testdb9;
|
||||
DROP DATABASE testdb10;
|
||||
create table t1(a int, b int, c int, d int);
|
||||
grant insert(b), insert(c), insert(d), insert(a) on t1 to grant_user@localhost;
|
||||
show grants for grant_user@localhost;
|
||||
Grants for grant_user@localhost
|
||||
GRANT USAGE ON *.* TO 'grant_user'@'localhost'
|
||||
GRANT INSERT (a, d, c, b) ON `test`.`t1` TO 'grant_user'@'localhost'
|
||||
select Host,Db,User,Table_name,Column_name,Column_priv from mysql.columns_priv;
|
||||
Host Db User Table_name Column_name Column_priv
|
||||
localhost test grant_user t1 c Insert
|
||||
localhost test grant_user t1 b Insert
|
||||
localhost test grant_user t1 a Insert
|
||||
localhost test grant_user t1 d Insert
|
||||
revoke ALL PRIVILEGES on t1 from grant_user@localhost;
|
||||
show grants for grant_user@localhost;
|
||||
Grants for grant_user@localhost
|
||||
GRANT USAGE ON *.* TO 'grant_user'@'localhost'
|
||||
select Host,Db,User,Table_name,Column_name,Column_priv from mysql.columns_priv;
|
||||
Host Db User Table_name Column_name Column_priv
|
||||
drop user grant_user@localhost;
|
||||
drop table t1;
|
||||
create database mysqltest_1;
|
||||
create database mysqltest_2;
|
||||
create table mysqltest_1.t1 select 1 a, 2 q;
|
||||
create table mysqltest_1.t2 select 1 b, 2 r;
|
||||
create table mysqltest_2.t1 select 1 c, 2 s;
|
||||
create table mysqltest_2.t2 select 1 d, 2 t;
|
||||
grant update (a) on mysqltest_1.t1 to mysqltest_3@localhost;
|
||||
grant select (b) on mysqltest_1.t2 to mysqltest_3@localhost;
|
||||
grant select (c) on mysqltest_2.t1 to mysqltest_3@localhost;
|
||||
grant update (d) on mysqltest_2.t2 to mysqltest_3@localhost;
|
||||
show grants for mysqltest_3@localhost;
|
||||
Grants for mysqltest_3@localhost
|
||||
GRANT USAGE ON *.* TO 'mysqltest_3'@'localhost'
|
||||
GRANT SELECT (b) ON `mysqltest_1`.`t2` TO 'mysqltest_3'@'localhost'
|
||||
GRANT SELECT (c) ON `mysqltest_2`.`t1` TO 'mysqltest_3'@'localhost'
|
||||
GRANT UPDATE (a) ON `mysqltest_1`.`t1` TO 'mysqltest_3'@'localhost'
|
||||
GRANT UPDATE (d) ON `mysqltest_2`.`t2` TO 'mysqltest_3'@'localhost'
|
||||
update mysqltest_1.t1, mysqltest_1.t2 set q=10 where b=1;
|
||||
ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for column 'q' in table 't1'
|
||||
update mysqltest_1.t1, mysqltest_2.t2 set d=20 where d=1;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'd' in table 't2'
|
||||
update mysqltest_2.t1, mysqltest_1.t2 set c=20 where b=1;
|
||||
ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for column 'c' in table 't1'
|
||||
update mysqltest_2.t1, mysqltest_2.t2 set d=10 where s=2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 's' in table 't1'
|
||||
update mysqltest_1.t1, mysqltest_2.t2 set a=10,d=10;
|
||||
update mysqltest_1.t1, mysqltest_2.t1 set a=20 where c=20;
|
||||
select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
|
||||
a q b r
|
||||
10 2 1 2
|
||||
select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
|
||||
c s d t
|
||||
1 2 10 2
|
||||
revoke all on mysqltest_1.t1 from mysqltest_3@localhost;
|
||||
revoke all on mysqltest_1.t2 from mysqltest_3@localhost;
|
||||
revoke all on mysqltest_2.t1 from mysqltest_3@localhost;
|
||||
revoke all on mysqltest_2.t2 from mysqltest_3@localhost;
|
||||
grant all on mysqltest_2.* to mysqltest_3@localhost;
|
||||
grant select on *.* to mysqltest_3@localhost;
|
||||
flush privileges;
|
||||
use mysqltest_1;
|
||||
update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600;
|
||||
update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
|
||||
ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for column 'a' in table 't1'
|
||||
use mysqltest_2;
|
||||
update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
|
||||
ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysqltest_1'
|
||||
update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200;
|
||||
ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysqltest_1'
|
||||
update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200;
|
||||
ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysqltest_1'
|
||||
select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
|
||||
a q b r
|
||||
10 2 1 2
|
||||
select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
|
||||
c s d t
|
||||
500 2 600 2
|
||||
delete from mysql.user where user='mysqltest_3';
|
||||
delete from mysql.db where user="mysqltest_3";
|
||||
delete from mysql.tables_priv where user="mysqltest_3";
|
||||
delete from mysql.columns_priv where user="mysqltest_3";
|
||||
flush privileges;
|
||||
drop database mysqltest_1;
|
||||
drop database mysqltest_2;
|
||||
|
@ -37,7 +37,6 @@ show grants for current_user();
|
||||
Grants for mysqltest_1@localhost
|
||||
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
|
||||
GRANT SELECT, INSERT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
|
||||
use mysqltest;
|
||||
insert into t1 values (1, 'I can''t change it!');
|
||||
update t1 set data='I can change it!' where id = 1;
|
||||
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
|
||||
@ -47,8 +46,20 @@ select * from t1;
|
||||
id data
|
||||
1 I can't change it!
|
||||
drop table t1;
|
||||
drop database mysqltest;
|
||||
use test;
|
||||
delete from mysql.user where user like 'mysqltest\_%';
|
||||
delete from mysql.db where user like 'mysqltest\_%';
|
||||
flush privileges;
|
||||
create table t1 (a int, b int);
|
||||
grant select (a) on t1 to mysqltest_1@localhost with grant option;
|
||||
grant select (a,b) on t1 to mysqltest_2@localhost;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't1'
|
||||
grant select on t1 to mysqltest_3@localhost;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1'
|
||||
drop table t1;
|
||||
delete from mysql.user where user like 'mysqltest\_%';
|
||||
delete from mysql.db where user like 'mysqltest\_%';
|
||||
delete from mysql.tables_priv where user like 'mysqltest\_%';
|
||||
delete from mysql.columns_priv where user like 'mysqltest\_%';
|
||||
flush privileges;
|
||||
drop database mysqltest;
|
||||
use test;
|
||||
|
@ -134,7 +134,7 @@ 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'
|
||||
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
|
||||
@ -148,7 +148,7 @@ select "user3";
|
||||
user3
|
||||
user3
|
||||
select * from t1;
|
||||
ERROR 42000: select command denied to user 'mysqltest_3'@'localhost' for column 'b' in table 't1'
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'b' in table 't1'
|
||||
select a from t1;
|
||||
a
|
||||
1
|
||||
@ -156,7 +156,7 @@ a
|
||||
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'
|
||||
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";
|
||||
|
@ -629,6 +629,18 @@ 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
|
||||
@ -638,3 +650,30 @@ alias
|
||||
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;
|
||||
|
@ -1,2 +1,2 @@
|
||||
Variable_name Value
|
||||
have_exampledb YES
|
||||
have_example_engine YES
|
||||
|
2
mysql-test/r/have_moscow_leap_timezone.require
Normal file
2
mysql-test/r/have_moscow_leap_timezone.require
Normal file
@ -0,0 +1,2 @@
|
||||
from_unixtime(1072904422)
|
||||
2004-01-01 00:00:00
|
@ -1,2 +1,2 @@
|
||||
Variable_name Value
|
||||
Ssl_cipher EDH-RSA-DES-CBC3-SHA
|
||||
Ssl_cipher DHE-RSA-AES256-SHA
|
||||
|
@ -4,7 +4,7 @@ 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 NULL NULL NULL HASH
|
||||
t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
@ -169,7 +169,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL btn NULL NULL NULL 11 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 10 Using where
|
||||
1 SIMPLE t1 ref btn btn 11 const,const 2 Using where
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a int default NULL,
|
||||
@ -182,7 +182,7 @@ 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 10 Using where
|
||||
1 SIMPLE t1 ref a a 5 const 1 Using where
|
||||
SELECT * FROM t1 WHERE a<=>NULL;
|
||||
a b
|
||||
NULL 99
|
||||
@ -204,7 +204,7 @@ key a (a)
|
||||
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 10 Using where
|
||||
1 SIMPLE t1 ref a a 5 const 3 Using where
|
||||
SELECT * FROM t1 WHERE a=10;
|
||||
a
|
||||
10
|
||||
@ -233,3 +233,19 @@ 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;
|
||||
|
@ -1,10 +1,10 @@
|
||||
drop table if exists t1;
|
||||
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 NULL NULL NULL HASH
|
||||
t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
@ -169,7 +169,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL btn NULL NULL NULL 11 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 10 Using where
|
||||
1 SIMPLE t1 ref btn btn 11 const,const 2 Using where
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a int default NULL,
|
||||
@ -182,7 +182,7 @@ 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 10 Using where
|
||||
1 SIMPLE t1 ref a a 5 const 1 Using where
|
||||
SELECT * FROM t1 WHERE a<=>NULL;
|
||||
a b
|
||||
NULL 99
|
||||
@ -203,3 +203,165 @@ 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 1 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 1 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 1 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 1 Using where
|
||||
insert into t1 select * from t1;
|
||||
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 1 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 1 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 1 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 1 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 1 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 1 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 1 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 1 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 heap_idx 20 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 20 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 heap_idx 20 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 20 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 heap_idx 20 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 20 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 heap_idx 20 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 20 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 20 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 15 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 15 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 20 const 7 Using where
|
||||
1 SIMPLE t3 ref a a 40 func,const 6 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 2 Using where
|
||||
drop table t1;
|
||||
|
@ -1630,3 +1630,21 @@ show status like "binlog_cache_disk_use";
|
||||
Variable_name Value
|
||||
Binlog_cache_disk_use 1
|
||||
drop table t1;
|
||||
create table t1 (c char(10), index (c,c)) engine=innodb;
|
||||
ERROR 42S21: Duplicate column name 'c'
|
||||
create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
|
||||
ERROR 42S21: Duplicate column name 'c1'
|
||||
create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb;
|
||||
ERROR 42S21: Duplicate column name 'c1'
|
||||
create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb;
|
||||
ERROR 42S21: Duplicate column name 'c1'
|
||||
create table t1 (c1 char(10), c2 char(10)) engine=innodb;
|
||||
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;
|
||||
|
1653
mysql-test/r/innodb.result.es
Normal file
1653
mysql-test/r/innodb.result.es
Normal file
File diff suppressed because it is too large
Load Diff
@ -81,6 +81,15 @@ a
|
||||
1
|
||||
2
|
||||
drop table t1, t2;
|
||||
create table t1(a int);
|
||||
insert into t1 values(1),(1);
|
||||
reset master;
|
||||
create table t2(unique(a)) select a from t1;
|
||||
ERROR 23000: Duplicate entry '1' for key 1
|
||||
show binlog events;
|
||||
Log_name Pos Event_type Server_id Orig_log_pos Info
|
||||
master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
|
||||
drop table t1;
|
||||
create table t1 (a int not null);
|
||||
create table t2 (a int not null);
|
||||
insert into t1 values (1);
|
||||
@ -629,3 +638,15 @@ 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;
|
||||
|
@ -78,6 +78,13 @@ a
|
||||
1
|
||||
2
|
||||
drop table t1, t2;
|
||||
create table t1(a int);
|
||||
insert into t1 values(1),(1);
|
||||
reset master;
|
||||
create table t2(unique(a)) select a from t1;
|
||||
ERROR 23000: Duplicate entry '1' for key 1
|
||||
show binlog events;
|
||||
drop table t1;
|
||||
create table t1 (a int not null);
|
||||
create table t2 (a int not null);
|
||||
insert into t1 values (1);
|
||||
@ -626,3 +633,15 @@ 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;
|
||||
|
@ -105,3 +105,65 @@ a b
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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 2
|
||||
SELECT * FROM t1;
|
||||
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=c+100;
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 120
|
||||
5 6 30
|
||||
8 9 60
|
||||
INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0;
|
||||
SELECT * FROM t1;
|
||||
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);
|
||||
SELECT *, VALUES(a) FROM t1;
|
||||
a b c VALUES(a)
|
||||
1 2 10 NULL
|
||||
3 4 127 NULL
|
||||
5 0 30 NULL
|
||||
8 9 60 NULL
|
||||
2 1 11 NULL
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
|
@ -751,3 +751,68 @@ player_id match_1_h * match_id home UUX
|
||||
7 4 * 1 2 2
|
||||
3 3 * 1 2 1
|
||||
drop table t1, t2;
|
||||
create table t1 (a int, b int, unique index idx (a, b));
|
||||
create table t2 (a int, b int, c int, unique index idx (a, b));
|
||||
insert into t1 values (1, 10), (1,11), (2,10), (2,11);
|
||||
insert into t2 values (1,10,3);
|
||||
select t1.a, t1.b, t2.c from t1 left join t2
|
||||
on t1.a=t2.a and t1.b=t2.b and t2.c=3
|
||||
where t1.a=1 and t2.c is null;
|
||||
a b c
|
||||
1 11 NULL
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1 (
|
||||
ts_id bigint(20) default NULL,
|
||||
inst_id tinyint(4) default NULL,
|
||||
flag_name varchar(64) default NULL,
|
||||
flag_value text,
|
||||
UNIQUE KEY ts_id (ts_id,inst_id,flag_name)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE t2 (
|
||||
ts_id bigint(20) default NULL,
|
||||
inst_id tinyint(4) default NULL,
|
||||
flag_name varchar(64) default NULL,
|
||||
flag_value text,
|
||||
UNIQUE KEY ts_id (ts_id,inst_id,flag_name)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
INSERT INTO t1 VALUES
|
||||
(111056548820001, 0, 'flag1', NULL),
|
||||
(111056548820001, 0, 'flag2', NULL),
|
||||
(2, 0, 'other_flag', NULL);
|
||||
INSERT INTO t2 VALUES
|
||||
(111056548820001, 3, 'flag1', 'sss');
|
||||
SELECT t1.flag_name,t2.flag_value
|
||||
FROM t1 LEFT JOIN t2
|
||||
ON (t1.ts_id = t2.ts_id AND t1.flag_name = t2.flag_name AND
|
||||
t2.inst_id = 3)
|
||||
WHERE t1.inst_id = 0 AND t1.ts_id=111056548820001 AND
|
||||
t2.flag_value IS NULL;
|
||||
flag_name flag_value
|
||||
flag2 NULL
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE invoice (
|
||||
id int(11) unsigned NOT NULL auto_increment,
|
||||
text_id int(10) unsigned default NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
INSERT INTO invoice VALUES("1", "0");
|
||||
INSERT INTO invoice VALUES("2", "10");
|
||||
CREATE TABLE text_table (
|
||||
text_id char(3) NOT NULL default '',
|
||||
language_id char(3) NOT NULL default '',
|
||||
text_data text,
|
||||
PRIMARY KEY (text_id,language_id)
|
||||
);
|
||||
INSERT INTO text_table VALUES("0", "EN", "0-EN");
|
||||
INSERT INTO text_table VALUES("0", "SV", "0-SV");
|
||||
INSERT INTO text_table VALUES("10", "EN", "10-EN");
|
||||
INSERT INTO text_table VALUES("10", "SV", "10-SV");
|
||||
SELECT invoice.id, invoice.text_id, text_table.text_data
|
||||
FROM invoice LEFT JOIN text_table
|
||||
ON invoice.text_id = text_table.text_id
|
||||
AND text_table.language_id = 'SV'
|
||||
WHERE (invoice.id LIKE '%' OR text_table.text_data LIKE '%');
|
||||
id text_id text_data
|
||||
1 0 0-SV
|
||||
2 10 10-SV
|
||||
DROP TABLE invoice, text_table;
|
||||
|
@ -307,3 +307,21 @@ 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;
|
||||
|
@ -277,3 +277,13 @@ Key_blocks_unused KEY_BLOCKS_UNUSED
|
||||
set global keycache2.key_buffer_size=0;
|
||||
set global keycache3.key_buffer_size=100;
|
||||
set global keycache3.key_buffer_size=0;
|
||||
create table t1 (mytext text, FULLTEXT (mytext));
|
||||
insert t1 values ('aaabbb');
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
set GLOBAL key_cache_block_size=2048;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
|
@ -67,3 +67,12 @@ 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;
|
||||
|
@ -131,3 +131,31 @@ show tables like 't1%';
|
||||
Tables_in_test (t1%)
|
||||
t1
|
||||
drop table t1;
|
||||
create temporary table T1(a int(11), b varchar(8));
|
||||
insert into T1 values (1, 'abc');
|
||||
select * from T1;
|
||||
a b
|
||||
1 abc
|
||||
alter table T1 add index (a);
|
||||
select * from T1;
|
||||
a b
|
||||
1 abc
|
||||
drop table T1;
|
||||
create database mysqltest_LC2;
|
||||
use mysqltest_LC2;
|
||||
create table myUC (i int);
|
||||
insert into myUC values (1),(2),(3);
|
||||
select * from myUC;
|
||||
i
|
||||
1
|
||||
2
|
||||
3
|
||||
use test;
|
||||
drop database mysqltest_LC2;
|
||||
create database mysqltest_LC2;
|
||||
use mysqltest_LC2;
|
||||
create table myUC (i int);
|
||||
select * from myUC;
|
||||
i
|
||||
use test;
|
||||
drop database mysqltest_LC2;
|
||||
|
@ -6,5 +6,5 @@ drop table t1;
|
||||
flush tables;
|
||||
CREATE TABLE t1 (a int) ENGINE=INNODB;
|
||||
SELECT * from T1;
|
||||
ERROR HY000: Can't open file: 'T1.InnoDB' (errno: 1)
|
||||
ERROR HY000: Can't open file: 'T1.ibd' (errno: 1)
|
||||
drop table t1;
|
||||
|
23
mysql-test/r/lowercase_table_grant.result
Normal file
23
mysql-test/r/lowercase_table_grant.result
Normal file
@ -0,0 +1,23 @@
|
||||
use mysql;
|
||||
create database MYSQLtest;
|
||||
grant all on MySQLtest.* to mysqltest_1@localhost;
|
||||
show grants for mysqltest_1@localhost;
|
||||
Grants for mysqltest_1@localhost
|
||||
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
|
||||
GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
|
||||
select * from db where user = 'mysqltest_1';
|
||||
Host Db User Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Grant_priv References_priv Index_priv Alter_priv Create_tmp_table_priv Lock_tables_priv
|
||||
localhost mysqltest mysqltest_1 Y Y Y Y Y Y N Y Y Y Y Y
|
||||
update db set db = 'MYSQLtest' where db = 'mysqltest' and user = 'mysqltest_1' and host = 'localhost';
|
||||
flush privileges;
|
||||
show grants for mysqltest_1@localhost;
|
||||
Grants for mysqltest_1@localhost
|
||||
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
|
||||
GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
|
||||
select * from db where user = 'mysqltest_1';
|
||||
Host Db User Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Grant_priv References_priv Index_priv Alter_priv Create_tmp_table_priv Lock_tables_priv
|
||||
localhost MYSQLtest mysqltest_1 Y Y Y Y Y Y N Y Y Y Y Y
|
||||
delete from db where db = 'MYSQLtest' and user = 'mysqltest_1' and host = 'localhost';
|
||||
flush privileges;
|
||||
drop user mysqltest_1@localhost;
|
||||
drop database MYSQLtest;
|
@ -651,3 +651,33 @@ ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
||||
create table t3 engine=merge union=(t1, t2) select * from t2;
|
||||
ERROR HY000: You can't specify target table 't2' for update in FROM clause
|
||||
drop table t1, t2;
|
||||
create table t1 (a int,b int,c int, index (a,b,c));
|
||||
create table t2 (a int,b int,c int, index (a,b,c));
|
||||
create table t3 (a int,b int,c int, index (a,b,c))
|
||||
engine=merge union=(t1 ,t2);
|
||||
insert into t1 (a,b,c) values (1,1,0),(1,2,0);
|
||||
insert into t2 (a,b,c) values (1,1,1),(1,2,1);
|
||||
explain select a,b,c from t3 force index (a) where a=1 order by a,b,c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ref a a 5 const 2 Using where; Using index
|
||||
select a,b,c from t3 force index (a) where a=1 order by a,b,c;
|
||||
a b c
|
||||
1 1 0
|
||||
1 1 1
|
||||
1 2 0
|
||||
1 2 1
|
||||
explain select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ref a a 5 const 2 Using where; Using index
|
||||
select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc;
|
||||
a b c
|
||||
1 2 1
|
||||
1 2 0
|
||||
1 1 1
|
||||
1 1 0
|
||||
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 A NULL NULL NULL YES BTREE
|
||||
t3 1 a 2 b A NULL NULL NULL YES BTREE
|
||||
t3 1 a 3 c A NULL NULL NULL YES BTREE
|
||||
drop table t1, t2, t3;
|
||||
|
@ -1,11 +1,11 @@
|
||||
drop table if exists t1,t2;
|
||||
select 1, 1.0, -1, "hello", NULL;
|
||||
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def 1 8 1 1 N 32769 0 8
|
||||
def 1.0 5 3 3 N 32769 1 8
|
||||
def -1 8 1 2 N 32769 0 8
|
||||
def 1 8 1 1 N 32897 0 63
|
||||
def 1.0 5 3 3 N 32897 1 63
|
||||
def -1 8 2 2 N 32897 0 63
|
||||
def hello 254 5 5 N 1 31 8
|
||||
def NULL 6 0 0 Y 32768 0 8
|
||||
def NULL 6 0 0 Y 32896 0 63
|
||||
1 1.0 -1 hello NULL
|
||||
1 1.0 -1 hello NULL
|
||||
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));
|
||||
|
@ -180,4 +180,25 @@ master-bin.000001 79 Query 1 79 use `test`; BEGIN
|
||||
master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(16)
|
||||
master-bin.000001 179 Query 1 79 use `test`; insert into t1 values(18)
|
||||
master-bin.000001 239 Query 1 239 use `test`; COMMIT
|
||||
delete from t1;
|
||||
delete from t2;
|
||||
alter table t2 type=MyISAM;
|
||||
insert into t1 values (1);
|
||||
begin;
|
||||
select * from t1 for update;
|
||||
a
|
||||
1
|
||||
select (@before:=unix_timestamp())*0;
|
||||
(@before:=unix_timestamp())*0
|
||||
0
|
||||
begin;
|
||||
select * from t1 for update;
|
||||
insert into t2 values (20);
|
||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||
select (@after:=unix_timestamp())*0;
|
||||
(@after:=unix_timestamp())*0
|
||||
0
|
||||
select (@after-@before) >= 2;
|
||||
(@after-@before) >= 2
|
||||
1
|
||||
drop table t1,t2;
|
||||
|
@ -31,3 +31,20 @@ select 5'abcd'
|
||||
select 'finish';
|
||||
finish
|
||||
finish
|
||||
flush status;
|
||||
create table t1 (i int);
|
||||
insert into t1 values (1);
|
||||
select * from t1 where i = 1;
|
||||
insert into t1 values (2),(3),(4);
|
||||
select * from t1 where i = 2;
|
||||
select * from t1 where i = 3||||
|
||||
i
|
||||
1
|
||||
i
|
||||
2
|
||||
i
|
||||
3
|
||||
show status like 'Slow_queries'||||
|
||||
Variable_name Value
|
||||
Slow_queries 2
|
||||
drop table t1||||
|
||||
|
@ -464,3 +464,14 @@ ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
||||
delete t1 from t1,t2 where t1.col1 < (select max(col1) from t1) and t1.col1 = t2.col1;
|
||||
ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
||||
drop table t1,t2;
|
||||
create table t1 (
|
||||
aclid bigint not null primary key,
|
||||
status tinyint(1) not null
|
||||
) engine = innodb;
|
||||
create table t2 (
|
||||
refid bigint not null primary key,
|
||||
aclid bigint, index idx_acl(aclid)
|
||||
) engine = innodb;
|
||||
insert into t2 values(1,null);
|
||||
delete t2, t1 from t2 left join t1 on (t2.aclid=t1.aclid) where t2.refid='1';
|
||||
drop table t1, t2;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user