~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/mix2_myisam.result

  • Committer: Brian Aker
  • Date: 2009-02-27 21:38:40 UTC
  • Revision ID: brian@tangent.org-20090227213840-r9hq3sfk8d8qrg72
Code cleanup in signal_handler.cc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
SET SESSION STORAGE_ENGINE = MEMORY;
2
2
drop table if exists t1,t2,t3,t4;
3
3
drop database if exists mysqltest;
4
 
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=MyISAM;
 
4
create table t1 (id int not null auto_increment, code int not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=MyISAM;
5
5
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
6
6
select id, code, name from t1 order by id;
7
7
id      code    name
34
34
12      1       Ralph
35
35
drop table t1;
36
36
CREATE TABLE t1 (
37
 
id int(11) NOT NULL auto_increment,
38
 
parent_id int(11) DEFAULT '0' NOT NULL,
39
 
level tinyint(4) DEFAULT '0' NOT NULL,
 
37
id int NOT NULL auto_increment,
 
38
parent_id int DEFAULT '0' NOT NULL,
 
39
level int DEFAULT '0' NOT NULL,
40
40
PRIMARY KEY (id),
41
41
KEY parent_id (parent_id),
42
42
KEY level (level)
142
142
1015    102     2
143
143
explain select level from t1 where level=1;
144
144
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
145
 
1       SIMPLE  t1      ref     level   level   1       const   #       Using index
 
145
1       SIMPLE  t1      ref     level   level   4       const   #       Using index
146
146
explain select level,id from t1 where level=1;
147
147
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
148
 
1       SIMPLE  t1      ref     level   level   1       const   #       
 
148
1       SIMPLE  t1      ref     level   level   4       const   #       
149
149
explain select level,id,parent_id from t1 where level=1;
150
150
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
151
 
1       SIMPLE  t1      ref     level   level   1       const   #       
 
151
1       SIMPLE  t1      ref     level   level   4       const   #       
152
152
select level,id from t1 where level=1;
153
153
level   id
154
154
1       1003
175
175
t1      1       level   1       level   A       #       NULL    NULL            BTREE           
176
176
drop table t1;
177
177
CREATE TABLE t1 (
178
 
gesuchnr int(11) DEFAULT '0' NOT NULL,
179
 
benutzer_id int(11) DEFAULT '0' NOT NULL,
 
178
gesuchnr int DEFAULT '0' NOT NULL,
 
179
benutzer_id int DEFAULT '0' NOT NULL,
180
180
PRIMARY KEY (gesuchnr,benutzer_id)
181
181
) engine=MyISAM;
182
182
replace into t1 (gesuchnr,benutzer_id) values (2,1);
222
222
1       
223
223
drop table t1;
224
224
CREATE TABLE t1 (
225
 
user_id int(10) DEFAULT '0' NOT NULL,
 
225
user_id int DEFAULT '0' NOT NULL,
226
226
name varchar(100),
227
227
phone varchar(100),
228
228
ref_email varchar(100) DEFAULT '' NOT NULL,
330
330
3       3
331
331
drop table t1,t2;
332
332
CREATE TABLE t1 (
333
 
id int(11) NOT NULL auto_increment,
 
333
id int NOT NULL auto_increment,
334
334
ggid varchar(32) binary DEFAULT '' NOT NULL,
335
335
email varchar(64) DEFAULT '' NOT NULL,
336
336
passwd varchar(32) binary DEFAULT '' NOT NULL,
370
370
user_name varchar(12),
371
371
password text,
372
372
subscribed char(1),
373
 
user_id int(11) DEFAULT '0' NOT NULL,
374
 
quota bigint(20),
 
373
user_id int DEFAULT '0' NOT NULL,
 
374
quota bigint,
375
375
weight double,
376
376
access_date date,
377
377
access_time time,
378
378
approved datetime,
379
 
dummy_primary_key int(11) NOT NULL auto_increment,
 
379
dummy_primary_key int NOT NULL auto_increment,
380
380
PRIMARY KEY (dummy_primary_key)
381
381
) ENGINE=MyISAM;
382
382
INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1);
393
393
user_4  somepassword    N       4       4       2       2000-09-07      23:06:59        2000-09-07 23:06:59     5
394
394
drop table t1;
395
395
CREATE TABLE t1 (
396
 
id int(11) NOT NULL auto_increment,
397
 
parent_id int(11) DEFAULT '0' NOT NULL,
398
 
level tinyint(4) DEFAULT '0' NOT NULL,
 
396
id int NOT NULL auto_increment,
 
397
parent_id int DEFAULT '0' NOT NULL,
 
398
level int DEFAULT '0' NOT NULL,
399
399
KEY (id),
400
400
KEY parent_id (parent_id),
401
401
KEY level (level)
501
501
1016    102     2
502
502
explain select level from t1 where level=1;
503
503
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
504
 
1       SIMPLE  t1      ref     level   level   1       const   #       Using index
 
504
1       SIMPLE  t1      ref     level   level   4       const   #       Using index
505
505
select level,id from t1 where level=1;
506
506
level   id
507
507
1       1004
649
649
1       2
650
650
drop table t1;
651
651
CREATE TABLE t1 (
652
 
a int3 unsigned NOT NULL,
653
 
b int1 unsigned NOT NULL,
 
652
a int NOT NULL,
 
653
b int NOT NULL,
654
654
UNIQUE (a, b)
655
655
) ENGINE = MyISAM;
656
656
INSERT INTO t1 VALUES (1, 1);
658
658
MIN(B)  MAX(b)
659
659
1       1
660
660
drop table t1;
661
 
CREATE TABLE t1 (a int unsigned NOT NULL) engine=MyISAM;
 
661
CREATE TABLE t1 (a int NOT NULL) engine=MyISAM;
662
662
INSERT INTO t1 VALUES (1);
663
663
SELECT * FROM t1;
664
664
a
718
718
show create table t1;
719
719
Table   Create Table
720
720
t1      CREATE TABLE `t1` (
721
 
  `a` char(20) DEFAULT NULL,
722
 
  KEY `a` (`a`(5))
723
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
721
  `a` varchar(20) DEFAULT NULL,
 
722
  KEY `a` (`a`())
 
723
) ENGINE=MyISAM
724
724
drop table t1;
725
725
create temporary table t1 (a int not null auto_increment, primary key(a)) engine=MyISAM;
726
726
insert into t1 values (NULL),(NULL),(NULL);
748
748
) engine=MyISAM;
749
749
insert into t1 values (1,'one','one value',101),
750
750
(2,'two','two value',102),(3,'three','three value',103);
751
 
set insert_id=5;
752
751
replace into t1 (value,name,uid) values ('other value','two',102);
753
752
delete from t1 where uid=102;
754
 
set insert_id=5;
755
753
replace into t1 (value,name,uid) values ('other value','two',102);
756
 
set insert_id=6;
757
754
replace into t1 (value,name,uid) values ('other value','two',102);
758
755
select * from t1;
759
756
id      name    value   uid
760
757
1       one     one value       101
 
758
6       two     other value     102
761
759
3       three   three value     103
762
 
6       two     other value     102
763
760
drop table t1;
764
761
create database mysqltest;
765
762
create table mysqltest.t1 (a int not null) engine= MyISAM;
832
829
create table t1 (t int not null default 1, key (t)) engine=MyISAM;
833
830
desc t1;
834
831
Field   Type    Null    Key     Default Extra
835
 
t       int(11) NO      MUL     1       
 
832
t       int     NO      MUL     1       
836
833
drop table t1;
837
834
CREATE TABLE t1 (
838
 
number bigint(20) NOT NULL default '0',
 
835
number bigint NOT NULL default '0',
839
836
cname char(15) NOT NULL default '',
840
 
carrier_id smallint(6) NOT NULL default '0',
841
 
privacy tinyint(4) NOT NULL default '0',
 
837
carrier_id int NOT NULL default '0',
 
838
privacy int NOT NULL default '0',
842
839
last_mod_date timestamp NOT NULL,
843
 
last_mod_id smallint(6) NOT NULL default '0',
 
840
last_mod_id int NOT NULL default '0',
844
841
last_app_date timestamp NOT NULL,
845
 
last_app_id smallint(6) default '-1',
846
 
version smallint(6) NOT NULL default '0',
847
 
assigned_scps int(11) default '0',
848
 
status tinyint(4) default '0'
 
842
last_app_id int default '-1',
 
843
version int NOT NULL default '0',
 
844
assigned_scps int default '0',
 
845
status int default '0'
849
846
) ENGINE=MyISAM;
850
847
INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1);
851
848
INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
854
851
INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
855
852
INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
856
853
CREATE TABLE t2 (
857
 
number bigint(20) NOT NULL default '0',
 
854
number bigint NOT NULL default '0',
858
855
cname char(15) NOT NULL default '',
859
 
carrier_id smallint(6) NOT NULL default '0',
860
 
privacy tinyint(4) NOT NULL default '0',
 
856
carrier_id int NOT NULL default '0',
 
857
privacy int NOT NULL default '0',
861
858
last_mod_date timestamp NOT NULL,
862
 
last_mod_id smallint(6) NOT NULL default '0',
 
859
last_mod_id int NOT NULL default '0',
863
860
last_app_date timestamp NOT NULL,
864
 
last_app_id smallint(6) default '-1',
865
 
version smallint(6) NOT NULL default '0',
866
 
assigned_scps int(11) default '0',
867
 
status tinyint(4) default '0'
 
861
last_app_id int default '-1',
 
862
version int NOT NULL default '0',
 
863
assigned_scps int default '0',
 
864
status int default '0'
868
865
) ENGINE=MyISAM;
869
866
INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1);
870
867
INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
896
893
number  cname   carrier_id      privacy last_mod_date   last_mod_id     last_app_date   last_app_id     version assigned_scps   status
897
894
333     tubs    99      2       2002-01-09 11:34:53     501     2002-01-09 11:34:53     500     3       10      0
898
895
drop table t1,t2;
899
 
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=MyISAM;
 
896
create table t1 (id int not null auto_increment, code int not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=MyISAM;
900
897
BEGIN;
901
898
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
902
899
SELECT @@tx_isolation,@@global.tx_isolation;
934
931
7       4       Matt
935
932
COMMIT;
936
933
DROP TABLE t1;
937
 
create table t1 (n int(10), d int(10)) engine=MyISAM;
938
 
create table t2 (n int(10), d int(10)) engine=MyISAM;
 
934
create table t1 (n int, d int) engine=MyISAM;
 
935
create table t2 (n int, d int) engine=MyISAM;
939
936
insert into t1 values(1,1),(1,2);
940
937
insert into t2 values(1,10),(2,20);
941
938
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
1114
1111
29267
1115
1112
explain select * from t1 where c between 1 and 2500;
1116
1113
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1117
 
1       SIMPLE  t1      range   c       c       5       NULL    #       Using index condition; Using MRR
 
1114
1       SIMPLE  t1      range   c       c       5       NULL    #       Using where; Using MRR
1118
1115
update t1 set c=a;
1119
1116
explain select * from t1 where c between 1 and 2500;
1120
1117
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1121
 
1       SIMPLE  t1      range   c       c       5       NULL    #       Using index condition; Using MRR
 
1118
1       SIMPLE  t1      range   c       c       5       NULL    #       Using where; Using MRR
1122
1119
drop table t1,t2;
1123
1120
create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=MyISAM;
1124
1121
insert into t1 (id) values (null),(null),(null),(null),(null);
1171
1168
insert into t1 (a) values (NULL),(NULL);
1172
1169
SELECT * from t1;
1173
1170
a
1174
 
1
1175
 
2
 
1171
3
 
1172
4
1176
1173
drop table t1;
1177
 
CREATE TABLE t1 (col1 int(1))ENGINE=MyISAM;
1178
 
CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
 
1174
CREATE TABLE t1 (col1 int)ENGINE=MyISAM;
 
1175
CREATE TABLE t2 (col1 int,stamp TIMESTAMP,INDEX stamp_idx
1179
1176
(stamp))ENGINE=MyISAM;
1180
1177
insert into t1 values (1),(2),(3);
1181
1178
insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
1182
 
Warnings:
1183
 
Warning 1265    Data truncated for column 'stamp' at row 3
 
1179
ERROR 22007: Incorrect datetime value: '20020204310000' for column 'stamp' at row 3
1184
1180
SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
1185
1181
'20020204120000' GROUP BY col1;
1186
1182
col1
1187
1183
1
1188
1184
2
1189
1185
3
1190
 
4
1191
1186
drop table t1,t2;
1192
1187
CREATE TABLE t1 (
1193
 
`id` int(10) unsigned NOT NULL auto_increment,
1194
 
`id_object` int(10) unsigned default '0',
1195
 
`id_version` int(10) unsigned NOT NULL default '1',
 
1188
`id` int NOT NULL auto_increment,
 
1189
`id_object` int default '0',
 
1190
`id_version` int NOT NULL default '1',
1196
1191
`label` varchar(100) NOT NULL default '',
1197
1192
`description` text,
1198
1193
PRIMARY KEY  (`id`),
1201
1196
) ENGINE=MyISAM;
1202
1197
INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL);
1203
1198
CREATE TABLE t2 (
1204
 
`id` int(10) unsigned NOT NULL auto_increment,
1205
 
`id_version` int(10) unsigned NOT NULL default '1',
 
1199
`id` int NOT NULL auto_increment,
 
1200
`id_version` int NOT NULL default '1',
1206
1201
PRIMARY KEY  (`id`),
1207
1202
KEY `id_version` (`id_version`)
1208
1203
) ENGINE=MyISAM;
1283
1278
show create table t2;
1284
1279
Table   Create Table
1285
1280
t2      CREATE TABLE `t2` (
1286
 
  `a` int(11) DEFAULT NULL
1287
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1281
  `a` int DEFAULT NULL
 
1282
) ENGINE=MyISAM
1288
1283
drop table t1,t2;
1289
1284
flush status;
1290
1285
show status like "binlog_cache_use";
1291
1286
Variable_name   Value
1292
 
Binlog_cache_use        0
1293
1287
show status like "binlog_cache_disk_use";
1294
1288
Variable_name   Value
1295
 
Binlog_cache_disk_use   0
1296
1289
create table t1 (a int) engine=MyISAM;
1297
1290
show status like "binlog_cache_use";
1298
1291
Variable_name   Value
1299
 
Binlog_cache_use        0
1300
1292
show status like "binlog_cache_disk_use";
1301
1293
Variable_name   Value
1302
 
Binlog_cache_disk_use   0
1303
1294
begin;
1304
1295
delete from t1;
1305
1296
commit;
1306
1297
show status like "binlog_cache_use";
1307
1298
Variable_name   Value
1308
 
Binlog_cache_use        0
1309
1299
show status like "binlog_cache_disk_use";
1310
1300
Variable_name   Value
1311
 
Binlog_cache_disk_use   0
1312
1301
drop table t1;
1313
1302
create table t1 (c char(10), index (c,c)) engine=MyISAM;
1314
1303
ERROR 42S21: Duplicate column name 'c'
1328
1317
alter table t1 add key (c1,c1,c2);
1329
1318
ERROR 42S21: Duplicate column name 'c1'
1330
1319
drop table t1;
1331
 
create table t1(a int(1) , b int(1)) engine=MyISAM;
 
1320
create table t1(a int, b int) engine=MyISAM;
1332
1321
insert into t1 values ('1111', '3333');
1333
1322
select distinct concat(a, b) from t1;
1334
1323
concat(a, b)
1370
1359
min(b)
1371
1360
6
1372
1361
drop table t1;
1373
 
create table t1 (x bigint unsigned not null primary key) engine=MyISAM;
 
1362
create table t1 (x bigint not null primary key) engine=MyISAM;
1374
1363
insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1);
 
1364
ERROR 22003: Out of range value for column 'x' at row 1
1375
1365
select * from t1;
1376
1366
x
1377
 
18446744073709551600
1378
 
18446744073709551601
1379
1367
select count(*) from t1 where x>0;
1380
1368
count(*)
1381
 
2
 
1369
0
1382
1370
select count(*) from t1 where x=0;
1383
1371
count(*)
1384
1372
0
1393
1381
0
1394
1382
explain select count(*) from t1 where x > -16;
1395
1383
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1396
 
1       SIMPLE  t1      index   PRIMARY PRIMARY 8       NULL    2       Using where; Using index
 
1384
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE noticed after reading const tables
1397
1385
select count(*) from t1 where x > -16;
1398
1386
count(*)
1399
 
2
 
1387
0
1400
1388
select * from t1 where x > -16;
1401
1389
x
1402
 
18446744073709551600
1403
 
18446744073709551601
1404
1390
select count(*) from t1 where x = 18446744073709551601;
1405
1391
count(*)
1406
 
1
 
1392
0
1407
1393
drop table t1;
1408
1394
set storage_engine=MyISAM;
1409
1395
drop table if exists t1,t2,t3;
1418
1404
Note    1265    Data truncated for column 'c' at row 1
1419
1405
select concat('*',v,'*',c,'*',t,'*') from t1;
1420
1406
concat('*',v,'*',c,'*',t,'*')
1421
 
*+ *+*+ *
1422
 
*+         *+*+                    *
 
1407
*+ *+ *+ *
 
1408
*+         *+         *+                    *
1423
1409
show create table t1;
1424
1410
Table   Create Table
1425
1411
t1      CREATE TABLE `t1` (
1426
1412
  `v` varchar(10) DEFAULT NULL,
1427
 
  `c` char(10) DEFAULT NULL,
 
1413
  `c` varchar(10) DEFAULT NULL,
1428
1414
  `t` text
1429
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1415
) ENGINE=MyISAM
1430
1416
create table t2 like t1;
1431
1417
show create table t2;
1432
1418
Table   Create Table
1433
1419
t2      CREATE TABLE `t2` (
1434
1420
  `v` varchar(10) DEFAULT NULL,
1435
 
  `c` char(10) DEFAULT NULL,
 
1421
  `c` varchar(10) DEFAULT NULL,
1436
1422
  `t` text
1437
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1423
) ENGINE=MyISAM
1438
1424
create table t3 select * from t1;
1439
1425
show create table t3;
1440
1426
Table   Create Table
1441
1427
t3      CREATE TABLE `t3` (
1442
1428
  `v` varchar(10) DEFAULT NULL,
1443
 
  `c` char(10) DEFAULT NULL,
 
1429
  `c` varchar(10) DEFAULT NULL,
1444
1430
  `t` text
1445
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1431
) ENGINE=MyISAM
1446
1432
alter table t1 modify c varchar(10);
1447
1433
show create table t1;
1448
1434
Table   Create Table
1450
1436
  `v` varchar(10) DEFAULT NULL,
1451
1437
  `c` varchar(10) DEFAULT NULL,
1452
1438
  `t` text
1453
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1439
) ENGINE=MyISAM
1454
1440
alter table t1 modify v char(10);
1455
1441
show create table t1;
1456
1442
Table   Create Table
1457
1443
t1      CREATE TABLE `t1` (
1458
 
  `v` char(10) DEFAULT NULL,
 
1444
  `v` varchar(10) DEFAULT NULL,
1459
1445
  `c` varchar(10) DEFAULT NULL,
1460
1446
  `t` text
1461
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1447
) ENGINE=MyISAM
1462
1448
alter table t1 modify t varchar(10);
1463
1449
Warnings:
1464
1450
Note    1265    Data truncated for column 't' at row 2
1465
1451
show create table t1;
1466
1452
Table   Create Table
1467
1453
t1      CREATE TABLE `t1` (
1468
 
  `v` char(10) DEFAULT NULL,
 
1454
  `v` varchar(10) DEFAULT NULL,
1469
1455
  `c` varchar(10) DEFAULT NULL,
1470
1456
  `t` varchar(10) DEFAULT NULL
1471
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1457
) ENGINE=MyISAM
1472
1458
select concat('*',v,'*',c,'*',t,'*') from t1;
1473
1459
concat('*',v,'*',c,'*',t,'*')
1474
 
*+*+*+ *
1475
 
*+*+*+         *
 
1460
*+ *+ *+ *
 
1461
*+         *+         *+         *
1476
1462
drop table t1,t2,t3;
1477
1463
create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10)));
1478
1464
show create table t1;
1479
1465
Table   Create Table
1480
1466
t1      CREATE TABLE `t1` (
1481
1467
  `v` varchar(10) DEFAULT NULL,
1482
 
  `c` char(10) DEFAULT NULL,
 
1468
  `c` varchar(10) DEFAULT NULL,
1483
1469
  `t` text,
1484
1470
  KEY `v` (`v`),
1485
1471
  KEY `c` (`c`),
1486
 
  KEY `t` (`t`(10))
1487
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1472
  KEY `t` (`t`())
 
1473
) ENGINE=MyISAM
1488
1474
select count(*) from t1;
1489
1475
count(*)
1490
1476
270
1527
1513
9
1528
1514
explain select count(*) from t1 where v='a  ';
1529
1515
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1530
 
1       SIMPLE  t1      ref     v       v       13      const   #       Using where; Using index
 
1516
1       SIMPLE  t1      ref     v       v       43      const   #       Using where; Using index
1531
1517
explain select count(*) from t1 where c='a  ';
1532
1518
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1533
 
1       SIMPLE  t1      ref     c       c       11      const   #       Using where; Using index
 
1519
1       SIMPLE  t1      ref     c       c       43      const   #       Using where; Using index
1534
1520
explain select count(*) from t1 where t='a  ';
1535
1521
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1536
 
1       SIMPLE  t1      ref     t       t       13      const   #       Using where
 
1522
1       SIMPLE  t1      ref     t       t       43      const   #       Using where
1537
1523
explain select count(*) from t1 where v like 'a%';
1538
1524
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1539
 
1       SIMPLE  t1      range   v       v       13      NULL    #       Using where; Using index
 
1525
1       SIMPLE  t1      range   v       v       43      NULL    #       Using where; Using index
1540
1526
explain select count(*) from t1 where v between 'a' and 'a ';
1541
1527
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1542
 
1       SIMPLE  t1      ref     v       v       13      const   #       Using where; Using index
 
1528
1       SIMPLE  t1      ref     v       v       43      const   #       Using where; Using index
1543
1529
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
1544
1530
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1545
 
1       SIMPLE  t1      ref     v       v       13      const   #       Using where; Using index
 
1531
1       SIMPLE  t1      ref     v       v       43      const   #       Using where; Using index
1546
1532
alter table t1 add unique(v);
1547
1533
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
1548
1534
alter table t1 add key(v);
1549
1535
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
1550
1536
qq
1551
1537
*a*a*a*
1552
 
*a *a*a *
1553
 
*a  *a*a  *
1554
 
*a   *a*a   *
1555
 
*a    *a*a    *
1556
 
*a     *a*a     *
1557
 
*a      *a*a      *
1558
 
*a       *a*a       *
1559
 
*a        *a*a        *
1560
 
*a         *a*a         *
 
1538
*a *a *a *
 
1539
*a  *a  *a  *
 
1540
*a   *a   *a   *
 
1541
*a    *a    *a    *
 
1542
*a     *a     *a     *
 
1543
*a      *a      *a      *
 
1544
*a       *a       *a       *
 
1545
*a        *a        *a        *
 
1546
*a         *a         *a         *
1561
1547
explain select * from t1 where v='a';
1562
1548
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1563
 
1       SIMPLE  t1      ref     v,v_2   #       13      const   #       Using index condition
 
1549
1       SIMPLE  t1      ref     v,v_2   #       43      const   #       Using where
1564
1550
select v,count(*) from t1 group by v limit 10;
1565
1551
v       count(*)
1566
1552
a      1
1698
1684
Table   Create Table
1699
1685
t1      CREATE TABLE `t1` (
1700
1686
  `v` varchar(300) DEFAULT NULL,
1701
 
  `c` char(10) DEFAULT NULL,
 
1687
  `c` varchar(10) DEFAULT NULL,
1702
1688
  `t` text,
1703
1689
  KEY `c` (`c`),
1704
 
  KEY `t` (`t`(10)),
 
1690
  KEY `t` (`t`()),
1705
1691
  KEY `v` (`v`)
1706
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1692
) ENGINE=MyISAM
1707
1693
select count(*) from t1 where v='a';
1708
1694
count(*)
1709
1695
10
1724
1710
9
1725
1711
explain select count(*) from t1 where v='a  ';
1726
1712
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1727
 
1       SIMPLE  t1      ref     v       v       303     const   #       Using where; Using index
 
1713
1       SIMPLE  t1      ref     v       v       1203    const   #       Using where; Using index
1728
1714
explain select count(*) from t1 where v like 'a%';
1729
1715
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1730
 
1       SIMPLE  t1      range   v       v       303     NULL    #       Using where; Using index
 
1716
1       SIMPLE  t1      range   v       v       1203    NULL    #       Using where; Using index
1731
1717
explain select count(*) from t1 where v between 'a' and 'a ';
1732
1718
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1733
 
1       SIMPLE  t1      ref     v       v       303     const   #       Using where; Using index
 
1719
1       SIMPLE  t1      ref     v       v       1203    const   #       Using where; Using index
1734
1720
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
1735
1721
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1736
 
1       SIMPLE  t1      ref     v       v       303     const   #       Using where; Using index
 
1722
1       SIMPLE  t1      ref     v       v       1203    const   #       Using where; Using index
1737
1723
explain select * from t1 where v='a';
1738
1724
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1739
 
1       SIMPLE  t1      ref     v       v       303     const   #       Using index condition
 
1725
1       SIMPLE  t1      ref     v       v       1203    const   #       Using where
1740
1726
select v,count(*) from t1 group by v limit 10;
1741
1727
v       count(*)
1742
1728
a      1
1778
1764
Table   Create Table
1779
1765
t1      CREATE TABLE `t1` (
1780
1766
  `v` varchar(300) DEFAULT NULL,
1781
 
  `c` char(10) DEFAULT NULL,
 
1767
  `c` varchar(10) DEFAULT NULL,
1782
1768
  `t` text,
1783
1769
  KEY `c` (`c`),
1784
 
  KEY `t` (`t`(10)),
1785
 
  KEY `v` (`v`(30))
1786
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1770
  KEY `t` (`t`()),
 
1771
  KEY `v` (`v`())
 
1772
) ENGINE=MyISAM
1787
1773
select count(*) from t1 where v='a';
1788
1774
count(*)
1789
1775
10
1804
1790
9
1805
1791
explain select count(*) from t1 where v='a  ';
1806
1792
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1807
 
1       SIMPLE  t1      ref     v       v       33      const   #       Using where
 
1793
1       SIMPLE  t1      ref     v       v       123     const   #       Using where
1808
1794
explain select count(*) from t1 where v like 'a%';
1809
1795
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1810
 
1       SIMPLE  t1      range   v       v       33      NULL    #       Using where
 
1796
1       SIMPLE  t1      range   v       v       123     NULL    #       Using where
1811
1797
explain select count(*) from t1 where v between 'a' and 'a ';
1812
1798
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1813
 
1       SIMPLE  t1      ref     v       v       33      const   #       Using where
 
1799
1       SIMPLE  t1      ref     v       v       123     const   #       Using where
1814
1800
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
1815
1801
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1816
 
1       SIMPLE  t1      ref     v       v       33      const   #       Using where
 
1802
1       SIMPLE  t1      ref     v       v       123     const   #       Using where
1817
1803
explain select * from t1 where v='a';
1818
1804
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1819
 
1       SIMPLE  t1      ref     v       v       33      const   #       Using where
 
1805
1       SIMPLE  t1      ref     v       v       123     const   #       Using where
1820
1806
select v,count(*) from t1 group by v limit 10;
1821
1807
v       count(*)
1822
1808
a      1
1854
1840
h       10
1855
1841
i       10
1856
1842
alter table t1 modify v varchar(600), drop key v, add key v (v);
 
1843
Warnings:
 
1844
Warning 1071    Specified key was too long; max key length is 1332 bytes
 
1845
Warning 1071    Specified key was too long; max key length is 1332 bytes
 
1846
Warning 1071    Specified key was too long; max key length is 1332 bytes
1857
1847
show create table t1;
1858
1848
Table   Create Table
1859
1849
t1      CREATE TABLE `t1` (
1860
1850
  `v` varchar(600) DEFAULT NULL,
1861
 
  `c` char(10) DEFAULT NULL,
 
1851
  `c` varchar(10) DEFAULT NULL,
1862
1852
  `t` text,
1863
1853
  KEY `c` (`c`),
1864
 
  KEY `t` (`t`(10)),
1865
 
  KEY `v` (`v`)
1866
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1854
  KEY `t` (`t`()),
 
1855
  KEY `v` (`v`())
 
1856
) ENGINE=MyISAM
1867
1857
select v,count(*) from t1 group by v limit 10;
1868
1858
v       count(*)
1869
1859
a      1
1904
1894
create table t1 (a char(10), unique (a));
1905
1895
insert into t1 values ('a   ');
1906
1896
insert into t1 values ('a ');
1907
 
ERROR 23000: Duplicate entry 'a' for key 'a'
 
1897
ERROR 23000: Duplicate entry 'a ' for key 'a'
1908
1898
alter table t1 modify a varchar(10);
1909
1899
insert into t1 values ('a '),('a  '),('a   '),('a         ');
1910
1900
ERROR 23000: Duplicate entry 'a ' for key 'a'
1936
1926
Table   Create Table
1937
1927
t1      CREATE TABLE `t1` (
1938
1928
  `v` varchar(10) DEFAULT NULL,
1939
 
  `c` char(10) DEFAULT NULL,
 
1929
  `c` varchar(10) DEFAULT NULL,
1940
1930
  `t` text,
1941
 
  KEY `v` (`v`(5)),
1942
 
  KEY `c` (`c`(5)),
1943
 
  KEY `t` (`t`(5))
1944
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1931
  KEY `v` (`v`()),
 
1932
  KEY `c` (`c`()),
 
1933
  KEY `t` (`t`())
 
1934
) ENGINE=MyISAM
1945
1935
drop table t1;
1946
 
create table t1 (v char(10) character set utf8);
 
1936
create table t1 (v char(10));
1947
1937
show create table t1;
1948
1938
Table   Create Table
1949
1939
t1      CREATE TABLE `t1` (
1950
 
  `v` char(10) CHARACTER SET utf8 DEFAULT NULL
1951
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1940
  `v` varchar(10) DEFAULT NULL
 
1941
) ENGINE=MyISAM
1952
1942
drop table t1;
1953
1943
create table t1 (v varchar(10), c char(10)) row_format=fixed;
1954
1944
show create table t1;
1955
1945
Table   Create Table
1956
1946
t1      CREATE TABLE `t1` (
1957
1947
  `v` varchar(10) DEFAULT NULL,
1958
 
  `c` char(10) DEFAULT NULL
1959
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
 
1948
  `c` varchar(10) DEFAULT NULL
 
1949
) ENGINE=MyISAM ROW_FORMAT=FIXED
1960
1950
insert into t1 values('a','a'),('a ','a ');
1961
1951
select concat('*',v,'*',c,'*') from t1;
1962
1952
concat('*',v,'*',c,'*')
1963
1953
*a*a*
1964
 
*a *a*
1965
 
drop table t1;
1966
 
create table t1 (v varchar(65530), key(v(10)));
1967
 
insert into t1 values(repeat('a',65530));
1968
 
select length(v) from t1 where v=repeat('a',65530);
1969
 
length(v)
1970
 
65530
 
1954
*a *a *
1971
1955
drop table t1;
1972
1956
create table t1(a int, b varchar(12), key ba(b, a));
1973
1957
insert into t1 values (1, 'A'), (20, NULL);
1974
1958
explain select * from t1 where a=20 and b is null;
1975
1959
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1976
 
1       SIMPLE  t1      ref     ba      ba      20      const,const     1       Using where; Using index
 
1960
1       SIMPLE  t1      ref     ba      ba      56      const,const     1       Using where; Using index
1977
1961
select * from t1 where a=20 and b is null;
1978
1962
a       b
1979
1963
20      NULL
1980
1964
drop table t1;
1981
 
create table t1 (v varchar(65530), key(v));
1982
 
Warnings:
1983
 
Warning 1071    Specified key was too long; max key length is 1332 bytes
1984
 
drop table t1;
1985
 
create table t1 (v varchar(65536));
1986
 
Warnings:
1987
 
Note    1246    Converting column 'v' from VARCHAR to TEXT
1988
 
show create table t1;
1989
 
Table   Create Table
1990
 
t1      CREATE TABLE `t1` (
1991
 
  `v` mediumtext
1992
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1993
 
drop table t1;
1994
 
create table t1 (v varchar(65530) character set utf8);
1995
 
Warnings:
1996
 
Note    1246    Converting column 'v' from VARCHAR to TEXT
1997
 
show create table t1;
1998
 
Table   Create Table
1999
 
t1      CREATE TABLE `t1` (
2000
 
  `v` mediumtext CHARACTER SET utf8
2001
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
2002
 
drop table t1;
2003
 
set storage_engine=MEMORY;
2004
 
create table t1 (v varchar(16384)) engine=MyISAM;
2005
 
drop table t1;
2006
1965
create table t1 (a char(1), b char(1), key(a, b)) engine=MyISAM;
2007
1966
insert into t1 values ('8', '6'), ('4', '7');
2008
1967
select min(a) from t1;
2012
1971
min(b)
2013
1972
6
2014
1973
drop table t1;
2015
 
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`)) ENGINE=MyISAM;
 
1974
CREATE TABLE t1 ( `a` int NOT NULL auto_increment, `b` int default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`)) ENGINE=MyISAM;
2016
1975
insert into t1 (b) values (1);
2017
1976
replace into t1 (b) values (2), (1), (3);
2018
1977
select * from t1;
2027
1986
replace into t1 (b) values (3);
2028
1987
select * from t1;
2029
1988
a       b
2030
 
3       1
2031
 
2       2
2032
 
4       3
 
1989
7       1
 
1990
6       2
 
1991
8       3
2033
1992
drop table t1;
2034
1993
create table t1 (rowid int not null auto_increment, val int not null,primary
2035
1994
key (rowid), unique(val)) engine=MyISAM;
2059
2018
select * from t1;
2060
2019
f1      f2
2061
2020
drop table t1,t2;
2062
 
create table t1(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
2063
 
insert into t1(a) values (1),(2),(3);
2064
 
commit;
2065
 
set autocommit = 0;
2066
 
update t1 set b = 5 where a = 2;
2067
 
create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
2068
 
set autocommit = 0;
2069
 
insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
2070
 
(11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
2071
 
(12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
2072
 
(13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
2073
 
(14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
2074
 
commit;
2075
 
commit;
2076
 
drop trigger t1t;
2077
 
drop table t1;
2078
 
create table t1(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
2079
 
create table t2(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
2080
 
create table t3(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
2081
 
create table t4(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
2082
 
create table t5(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
2083
 
insert into t1(a) values (1),(2),(3);
2084
 
insert into t2(a) values (1),(2),(3);
2085
 
insert into t3(a) values (1),(2),(3);
2086
 
insert into t4(a) values (1),(2),(3);
2087
 
insert into t3(a) values (5),(7),(8);
2088
 
insert into t4(a) values (5),(7),(8);
2089
 
insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
2090
 
create trigger t1t before insert on t1 for each row begin
2091
 
INSERT INTO t2 SET a = NEW.a;
2092
 
end |
2093
 
create trigger t2t before insert on t2 for each row begin
2094
 
DELETE FROM t3 WHERE a = NEW.a;
2095
 
end |
2096
 
create trigger t3t before delete on t3 for each row begin
2097
 
UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
2098
 
end |
2099
 
create trigger t4t before update on t4 for each row begin
2100
 
UPDATE t5 SET b = b + 1 where a = NEW.a;
2101
 
end |
2102
 
commit;
2103
 
set autocommit = 0;
2104
 
update t1 set b = b + 5 where a = 1;
2105
 
update t2 set b = b + 5 where a = 1;
2106
 
update t3 set b = b + 5 where a = 1;
2107
 
update t4 set b = b + 5 where a = 1;
2108
 
insert into t5(a) values(20);
2109
 
set autocommit = 0;
2110
 
insert into t1(a) values(7);
2111
 
insert into t2(a) values(8);
2112
 
delete from t2 where a = 3;
2113
 
update t4 set b = b + 1 where a = 3;
2114
 
commit;
2115
 
drop trigger t1t;
2116
 
drop trigger t2t;
2117
 
drop trigger t3t;
2118
 
drop trigger t4t;
2119
 
drop table t1, t2, t3, t4, t5;
2120
2021
create table t1(a date) engine=MyISAM;
2121
2022
create table t2(a date, key(a)) engine=MyISAM;
2122
2023
insert into t1 values('2005-10-01');