Commit 34d901c0 authored by Sergey Petrunya's avatar Sergey Petrunya

Merge

parents 005c24e9 d841ea23
......@@ -71,12 +71,16 @@ EXTRA_DIST = FINISH.sh \
compile-ppc-max \
compile-solaris-amd64 \
compile-solaris-amd64-debug \
compile-solaris-amd64-debug-forte \
compile-solaris-amd64-forte \
compile-solaris-amd64-forte-debug \
compile-solaris-sparc \
compile-solaris-sparc-debug \
compile-solaris-sparc-forte \
compile-solaris-sparc-purify
compile-solaris-sparc-purify \
compile-solaris-x86-32 \
compile-solaris-x86-32-debug \
compile-solaris-x86-32-debug-forte \
compile-solaris-x86-forte-32
# Don't update the files from bitkeeper
%::SCCS/s.%
......@@ -94,7 +94,7 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
../mysys/safemalloc.c ../mysys/sha1.c ../strings/str2int.c
../strings/str_alloc.c ../strings/strcend.c ../strings/strcont.c ../strings/strend.c
../strings/strfill.c ../mysys/string.c ../strings/strinstr.c ../strings/strmake.c
../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c
../strings/strmov.c ../strings/strmov_overlapp.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c
../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c
../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c
../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c ../mysys/mf_qsort.c
......
This diff is collapsed.
......@@ -56,5 +56,5 @@ Table Op Msg_type Msg_text
test.t1 analyze status OK
show index from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 a 1 a A NULL NULL NULL YES BTREE
t1 1 a 1 a A 5 NULL NULL YES BTREE
drop table t1;
......@@ -229,7 +229,8 @@ a b
204 7
delete from t1 where a=0;
update t1 set a=NULL where b=6;
ERROR 23000: Column 'a' cannot be null
Warnings:
Warning 1048 Column 'a' cannot be null
update t1 set a=300 where b=7;
SET SQL_MODE='';
insert into t1(a,b)values(NULL,8);
......@@ -244,7 +245,7 @@ a b
1 1
200 2
201 4
203 6
0 6
300 7
301 8
400 9
......@@ -260,7 +261,6 @@ a b
1 1
200 2
201 4
203 6
300 7
301 8
400 9
......@@ -271,20 +271,20 @@ a b
405 14
delete from t1 where a=0;
update t1 set a=NULL where b=13;
ERROR 23000: Column 'a' cannot be null
Warnings:
Warning 1048 Column 'a' cannot be null
update t1 set a=500 where b=14;
select * from t1 order by b;
a b
1 1
200 2
201 4
203 6
300 7
301 8
400 9
401 10
402 11
404 13
0 13
500 14
drop table t1;
create table t1 (a bigint);
......
......@@ -125,18 +125,19 @@ a b
0 11
2 12
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
Warnings:
Error 1242 Subquery returns more than 1 row
Error 1242 Subquery returns more than 1 row
ERROR 21000: Subquery returns more than 1 row
select * from t11;
a b
0 10
1 11
2 12
select * from t12;
a b
33 10
0 11
2 12
insert into t11 values (2, 12);
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
ERROR 21000: Subquery returns more than 1 row
select * from t11;
......@@ -145,13 +146,12 @@ a b
1 11
2 12
delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
Warnings:
Error 1242 Subquery returns more than 1 row
Error 1242 Subquery returns more than 1 row
ERROR 21000: Subquery returns more than 1 row
select * from t11;
a b
0 10
1 11
2 12
drop table t11, t12, t2;
create table t1 (a int, b int, unique key (a), key (b));
insert into t1 values (3, 3), (7, 7);
......
......@@ -174,8 +174,8 @@ INSERT INTO t3 VALUES (1,'1'),(2,'2'),(1,'1'),(2,'2');
explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using temporary
1 SIMPLE t3 ref a a 5 test.t1.b 2 Using where; Using index
1 SIMPLE t2 index a a 4 NULL 5 Using where; Using index; Distinct; Using join buffer
1 SIMPLE t2 ref a a 4 test.t1.a 1 Using index
1 SIMPLE t3 ref a a 5 test.t1.b 1 Using where; Using index
SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
a
1
......@@ -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 11 Using where; Using index; Distinct
1 SIMPLE t3 ref a a 5 test.t1.a 1 Using where; Using index; Distinct
select distinct t1.a from t1,t3 where t1.a=t3.a;
a
1
......@@ -212,7 +212,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 1 Using index
explain SELECT distinct a from t3 order by a desc limit 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 index NULL a 5 NULL 40 Using index
1 SIMPLE t3 index NULL a 5 NULL 2 Using index
explain SELECT distinct a,b from t3 order by a+1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
......
......@@ -61,7 +61,7 @@ grp sum
NULL NULL
1 7
2 20.25
3 45.483163247594
3 45.4831632475944
create table t2 (grp int, a bigint unsigned, c char(10));
insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp;
replace into t2 select grp, a, c from t1 limit 2,1;
......@@ -613,8 +613,8 @@ id select_type table type possible_keys key key_len ref rows Extra
explain
select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 > 'CA';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range k1 k1 3 NULL 1 Using where; Using index
1 SIMPLE t1 range k1 k1 7 NULL 1 Using where; Using index; Using join buffer
1 SIMPLE t1 range k1 k1 7 NULL 1 Using where; Using index
1 SIMPLE t2 range k1 k1 3 NULL 1 Using where; Using index; Using join buffer
explain
select min(a4 - 0.01) from t1;
id select_type table type possible_keys key key_len ref rows Extra
......@@ -1186,7 +1186,7 @@ std(s1/s2)
0.21325764
select std(o1/o2) from bug22555;
std(o1/o2)
0.21325763586649
0.213257635866493
select std(e1/e2) from bug22555;
std(e1/e2)
0.21325764
......@@ -1212,7 +1212,7 @@ round(std(s1/s2), 17)
0.21325763586649341
select std(o1/o2) from bug22555;
std(o1/o2)
0.21325763586649
0.213257635866493
select round(std(e1/e2), 17) from bug22555;
round(std(e1/e2), 17)
0.21325763586649341
......@@ -1237,7 +1237,7 @@ round(std(s1/s2), 17)
0.21325763586649341
select std(o1/o2) from bug22555;
std(o1/o2)
0.21325763586649
0.213257635866493
select round(std(e1/e2), 17) from bug22555;
round(std(e1/e2), 17)
0.21325763586649341
......
......@@ -60,7 +60,7 @@ Warnings:
Note 1003 select ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-(1)) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)`
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
3 3.9068905956085 NULL NULL NULL
3 3.90689059560852 NULL NULL NULL
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
......@@ -68,7 +68,7 @@ Warnings:
Note 1003 select log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-(2)) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)`
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
log10(100) log10(18) log10(-4) log10(0) log10(NULL)
2 1.2552725051033 NULL NULL NULL
2 1.25527250510331 NULL NULL NULL
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
......@@ -85,7 +85,7 @@ Note 1003 select pow(10,log10(10)) AS `pow(10,log10(10))`,pow(2,4) AS `power(2,4
set @@rand_seed1=10000000,@@rand_seed2=1000000;
select rand(999999),rand();
rand(999999) rand()
0.014231365187309 0.028870999839968
0.0142313651873091 0.028870999839968
explain extended select rand(999999),rand();
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
......@@ -101,7 +101,7 @@ Warnings:
Note 1003 select pi() AS `pi()`,format(sin((pi() / 2)),6) AS `format(sin(pi()/2),6)`,format(cos((pi() / 2)),6) AS `format(cos(pi()/2),6)`,format(abs(tan(pi())),6) AS `format(abs(tan(pi())),6)`,format((1 / tan(1)),6) AS `format(cot(1),6)`,format(asin(1),6) AS `format(asin(1),6)`,format(acos(0),6) AS `format(acos(0),6)`,format(atan(1),6) AS `format(atan(1),6)`
select degrees(pi()),radians(360);
degrees(pi()) radians(360)
180 6.2831853071796
180 6.28318530717959
select format(atan(-2, 2), 6);
format(atan(-2, 2), 6)
-0.785398
......
......@@ -1327,10 +1327,10 @@ cast(rtrim(ltrim(' 20.06 ')) as decimal(19,2))
20.06
select conv("18383815659218730760",10,10) + 0;
conv("18383815659218730760",10,10) + 0
1.8383815659219e+19
1.83838156592187e+19
select "18383815659218730760" + 0;
"18383815659218730760" + 0
1.8383815659219e+19
1.83838156592187e+19
CREATE TABLE t1 (code varchar(10));
INSERT INTO t1 VALUES ('a12'), ('A12'), ('a13');
SELECT ASCII(code), code FROM t1 WHERE code='A12';
......
......@@ -457,7 +457,7 @@ Privilege Context Comment
Alter Tables To alter the table
Alter routine Functions,Procedures To alter or drop stored functions/procedures
Create Databases,Tables,Indexes To create new databases and tables
Create routine Functions,Procedures To use CREATE FUNCTION/PROCEDURE
Create routine Databases To use CREATE FUNCTION/PROCEDURE
Create temporary tables Databases To use CREATE TEMPORARY TABLE
Create view Tables To create new views
Create user Server Admin To create new users
......
......@@ -774,7 +774,7 @@ insert into t3 select * from t2 where a < 800;
explain select * from t2,t3 where t2.a < 200 and t2.b=t3.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range a,b a 5 NULL 1 Using where
1 SIMPLE t3 ref b b 5 test.t2.b 11 Using where
1 SIMPLE t3 ref b b 5 test.t2.b 1 Using where
drop table t1, t2, t3;
create table t1 (a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
......
This diff is collapsed.
......@@ -153,7 +153,7 @@ t1 0 PRIMARY 1 d A 0 NULL NULL BTREE
t1 0 a 1 a A 0 NULL NULL BTREE
t1 0 e 1 e A 0 NULL NULL BTREE
t1 0 b 1 b A 0 NULL NULL YES BTREE
t1 1 c 1 c A NULL NULL NULL YES BTREE
t1 1 c 1 c A 0 NULL NULL YES BTREE
drop table t1;
CREATE TABLE t1 (c CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT,
UNIQUE (c,i));
......
......@@ -122,7 +122,7 @@ i
explain select count(*) from t1, t2 where t1.p = t2.i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index
1 SIMPLE t2 ref k1 k1 5 test.t1.p 2 Using where; Using index
1 SIMPLE t2 ref k1 k1 5 test.t1.p 1 Using where; Using index
select count(*) from t1, t2 where t1.p = t2.i;
count(*)
3
......@@ -257,8 +257,6 @@ test.t2 assign_to_keycache note The storage engine for the table doesn't support
drop table t1,t2,t3;
set global keycache2.key_buffer_size=0;
set global keycache3.key_buffer_size=100;
Warnings:
Warning 1292 Truncated incorrect key_buffer_size value: '100'
set global keycache3.key_buffer_size=0;
create table t1 (mytext text, FULLTEXT (mytext)) engine=myisam;
insert t1 values ('aaabbb');
......
......@@ -36,7 +36,7 @@ a a a a
explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL a NULL NULL NULL 5
1 SIMPLE t2 ALL b NULL NULL NULL 5 Using where; Using join buffer
1 SIMPLE t2 ref b b 4 test.t1.a 1 Using where
select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a;
a b a b
A B a a
......
......@@ -119,7 +119,7 @@ create table t1Aa (col1 int);
create view v1Aa as select col1 from t1Aa as AaA;
show create view v1AA;
View Create View character_set_client collation_connection
v1aa CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `AaA`.`col1` AS `col1` from `t1aa` `AaA` latin1 latin1_swedish_ci
v1aa CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `aaa` latin1 latin1_swedish_ci
drop view v1AA;
select Aaa.col1 from t1Aa as AaA;
col1
......@@ -128,7 +128,7 @@ drop view v1AA;
create view v1Aa as select AaA.col1 from t1Aa as AaA;
show create view v1AA;
View Create View character_set_client collation_connection
v1aa CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `AaA`.`col1` AS `col1` from `t1aa` `AaA` latin1 latin1_swedish_ci
v1aa CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `aaa` latin1 latin1_swedish_ci
drop view v1AA;
drop table t1Aa;
CREATE TABLE t1 (a int, b int);
......@@ -142,7 +142,7 @@ CREATE OR REPLACE VIEW v1 AS
select X.a from t1 AS X group by X.b having (X.a = 1);
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `X`.`a` AS `a` from `t1` `X` group by `X`.`b` having (`X`.`a` = 1) latin1 latin1_swedish_ci
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `x`.`a` AS `a` from `t1` `x` group by `x`.`b` having (`x`.`a` = 1) latin1 latin1_swedish_ci
SELECT * FROM v1;
a
DROP VIEW v1;
......
......@@ -107,7 +107,21 @@ Database: information_schema
| TRIGGERS |
| USER_PRIVILEGES |
| VIEWS |
| INNODB_BUFFER_POOL_PAGES |
| PBXT_STATISTICS |
| INNODB_CMP |
| INNODB_RSEG |
| XTRADB_ENHANCEMENTS |
| INNODB_BUFFER_POOL_PAGES_INDEX |
| INNODB_INDEX_STATS |
| INNODB_TRX |
| INNODB_CMP_RESET |
| INNODB_LOCK_WAITS |
| INNODB_CMPMEM_RESET |
| INNODB_LOCKS |
| INNODB_CMPMEM |
| INNODB_TABLE_STATS |
| INNODB_BUFFER_POOL_PAGES_BLOB |
+---------------------------------------+
Database: INFORMATION_SCHEMA
+---------------------------------------+
......@@ -141,7 +155,21 @@ Database: INFORMATION_SCHEMA
| TRIGGERS |
| USER_PRIVILEGES |
| VIEWS |
| INNODB_BUFFER_POOL_PAGES |
| PBXT_STATISTICS |
| INNODB_CMP |
| INNODB_RSEG |
| XTRADB_ENHANCEMENTS |
| INNODB_BUFFER_POOL_PAGES_INDEX |
| INNODB_INDEX_STATS |
| INNODB_TRX |
| INNODB_CMP_RESET |
| INNODB_LOCK_WAITS |
| INNODB_CMPMEM_RESET |
| INNODB_LOCKS |
| INNODB_CMPMEM |
| INNODB_TABLE_STATS |
| INNODB_BUFFER_POOL_PAGES_BLOB |
+---------------------------------------+
Wildcard: inf_rmation_schema
+--------------------+
......
......@@ -93,9 +93,11 @@ INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55";
Warnings:
Warning 1265 Data truncated for column 'd' at row 1
UPDATE t1 SET d=1/NULL;
ERROR 23000: Column 'd' cannot be null
Warnings:
Warning 1265 Data truncated for column 'd' at row 1
UPDATE t1 SET d=NULL;
ERROR 23000: Column 'd' cannot be null
Warnings:
Warning 1048 Column 'd' cannot be null
INSERT INTO t1 (a) values (null);
ERROR 23000: Column 'a' cannot be null
INSERT INTO t1 (a) values (1/null);
......@@ -130,7 +132,7 @@ Warning 1048 Column 'd' cannot be null
Warning 1048 Column 'd' cannot be null
select * from t1;
a b c d
0 0000-00-00 00:00:00 2003
0 0000-00-00 00:00:00 0
0 0000-00-00 00:00:00 0
0 0000-00-00 00:00:00 0
0 0000-00-00 00:00:00 0
......
......@@ -407,8 +407,8 @@ EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a
LEFT JOIN t3 ON t2.b=t3.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
1 SIMPLE t2 ref idx idx 5 test.t1.a 2
1 SIMPLE t3 ref idx idx 5 test.t2.b 186 Using index
1 SIMPLE t2 ref idx idx 5 test.t1.a 1
1 SIMPLE t3 ref idx idx 5 test.t2.b 1 Using index
FLUSH STATUS ;
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a
LEFT JOIN t3 ON t2.b=t3.b;
......
......@@ -338,12 +338,12 @@ select * from t1 X, t1 Y
where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3);
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE X p1,p2 ALL a,b NULL NULL NULL 2 Using where
1 SIMPLE Y p2,p3 ref a,b b 4 test.X.b 2 Using where
1 SIMPLE Y p2,p3 ref a,b b 4 test.X.b 1 Using where
explain partitions
select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2);
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE X p1,p2 ALL a NULL NULL NULL 4 Using where
1 SIMPLE Y p1,p2 ref a a 4 test.X.a 2
1 SIMPLE Y p1,p2 ref a a 4 test.X.a 1
drop table t1;
create table t1 (a int) partition by hash(a) partitions 20;
insert into t1 values (1),(2),(3);
......
......@@ -1218,3 +1218,59 @@ c1 c2
0 opq
1 jkl
DROP TABLE t1;
create table parent (id int primary key);
create table child (id int PRIMARY KEY, FOREIGN KEY (id) REFERENCES parent(id));
insert into parent values (2), (3), (4);
insert into child values (3), (4);
delete ignore from parent;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (Constraint: `FOREIGN_1`)
select * from parent;
id
2
3
4
drop table child, parent;
create schema test378222;
use test378222;
create table t1 (id int primary key);
create table t2 (id int primary key);
alter table t1 add constraint foreign key (id) references t2 (id);
alter table t2 add constraint foreign key (id) references t1 (id);
drop schema test378222;
create schema test378222a;
create schema test378222b;
create table test378222a.t1 (id int primary key);
create table test378222b.t2 (id int primary key);
alter table test378222a.t1 add constraint foreign key (id) references test378222b.t2 (id);
alter table test378222b.t2 add constraint foreign key (id) references test378222a.t1 (id);
set foreign_key_checks = 1;
drop schema test378222a;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
drop schema test378222b;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
set foreign_key_checks = 0;
drop schema test378222a;
drop schema test378222b;
set foreign_key_checks = 1;
use test;
CREATE TABLE t1(c1 TINYINT AUTO_INCREMENT NULL KEY ) AUTO_INCREMENT=10;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` tinyint(4) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`)
) ENGINE=PBXT AUTO_INCREMENT=10 DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES(null);
INSERT INTO t1 VALUES(null);
INSERT INTO t1 VALUES(null);
SELECT * FROM t1;
c1
10
11
12
TRUNCATE TABLE t1;
INSERT INTO t1 VALUES(null);
SELECT * FROM t1;
c1
1
DROP TABLE t1;
......@@ -166,7 +166,7 @@ child CREATE TABLE `child` (
`parent_id` int(11) DEFAULT NULL,
KEY `par_ind` (`parent_id`),
KEY `child_ind` (`id`),
CONSTRAINT `FOREIGN_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)
CONSTRAINT `FOREIGN_1` FOREIGN KEY (`parent_id`) REFERENCES `test`.`parent` (`id`)
) ENGINE=PBXT DEFAULT CHARSET=latin1
drop index child_ind on child;
show create table child;
......@@ -175,7 +175,7 @@ child CREATE TABLE `child` (
`id` int(11) DEFAULT NULL,
`parent_id` int(11) DEFAULT NULL,
KEY `par_ind` (`parent_id`),
CONSTRAINT `FOREIGN_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)
CONSTRAINT `FOREIGN_1` FOREIGN KEY (`parent_id`) REFERENCES `test`.`parent` (`id`)
) ENGINE=PBXT DEFAULT CHARSET=latin1
alter table parent add column c1 varchar(40);
insert child values(2000, 2);
......@@ -243,7 +243,7 @@ child CREATE TABLE `child` (
`id` int(11) DEFAULT NULL,
`parent_id` int(11) DEFAULT NULL,
KEY `par_ind` (`parent_id`),
CONSTRAINT `FOREIGN_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)
CONSTRAINT `FOREIGN_1` FOREIGN KEY (`parent_id`) REFERENCES `test`.`parent` (`id`)
) ENGINE=PBXT DEFAULT CHARSET=latin1
alter table child add column c1 varchar(40);
insert child values(400, 1, "asd");
......@@ -284,7 +284,7 @@ child CREATE TABLE `child` (
`id` int(11) DEFAULT NULL,
`parent_id` int(11) DEFAULT NULL,
KEY `par_ind` (`parent_id`),
CONSTRAINT `FOREIGN_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`) ON DELETE CASCADE
CONSTRAINT `FOREIGN_1` FOREIGN KEY (`parent_id`) REFERENCES `test`.`parent` (`id`) ON DELETE CASCADE
) ENGINE=PBXT DEFAULT CHARSET=latin1
insert parent values(1);
insert child values(100, 1);
......
......@@ -144,7 +144,7 @@ Key_reads 0
load index into cache t3, t2 key (primary,b) ;
Table Op Msg_type Msg_text
test.t3 preload_keys Error Table 'test.t3' doesn't exist
test.t3 preload_keys error Corrupt
test.t3 preload_keys status Operation failed
test.t2 preload_keys note The storage engine for the table doesn't support preload_keys
show status like "key_read%";
Variable_name Value
......@@ -159,7 +159,7 @@ Key_reads 0
load index into cache t3 key (b), t2 key (c) ;
Table Op Msg_type Msg_text
test.t3 preload_keys Error Table 'test.t3' doesn't exist
test.t3 preload_keys error Corrupt
test.t3 preload_keys status Operation failed
test.t2 preload_keys note The storage engine for the table doesn't support preload_keys
show status like "key_read%";
Variable_name Value
......
......@@ -289,11 +289,11 @@ prepare stmt4 from ' show index from t2 from test ';
execute stmt4;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t2 0 PRIMARY 1 a A 0 NULL NULL BTREE
t2 1 t2_idx 1 b A NULL NULL NULL YES BTREE
t2 1 t2_idx 1 b A 0 NULL NULL YES BTREE
prepare stmt4 from ' show table status from test like ''t2%'' ';
execute stmt4;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t2 PBXT 10 Fixed 0 29 1 # 4096 0 NULL # # # latin1_swedish_ci NULL
t2 PBXT 10 Fixed 0 29 1024 # 4096 0 NULL # # # latin1_swedish_ci NULL
prepare stmt4 from ' show table status from test like ''t9%'' ';
execute stmt4;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
......@@ -447,7 +447,7 @@ def type 253 10 3 Y 0 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 253 4096 0 Y 0 31 8
def ref 253 1024 0 Y 0 31 8
def ref 253 2048 0 Y 0 31 8
def rows 8 10 1 Y 32928 0 63
def Extra 253 255 14 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
......@@ -463,7 +463,7 @@ def type 253 10 5 Y 0 31 8
def possible_keys 253 4096 7 Y 0 31 8
def key 253 64 7 Y 0 31 8
def key_len 253 4096 1 Y 0 31 8
def ref 253 1024 0 Y 0 31 8
def ref 253 2048 0 Y 0 31 8
def rows 8 10 1 Y 32928 0 63
def Extra 253 255 27 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
......
......@@ -423,19 +423,19 @@ test.t2 analyze status OK
explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uid_index uid_index 4 NULL 1 Using where
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 12
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 1
explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uid_index uid_index 4 NULL 1 Using where
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 12
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 1
explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uid_index uid_index 4 NULL 2 Using where
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 12
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 1
explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uid_index uid_index 4 NULL 2 Using where
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 12
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 1
select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
id name uid id name uid
1001 A 1 1001 A 1
......
......@@ -3,11 +3,13 @@ create schema foo;
show create schema foo;
Database Create Database
foo CREATE DATABASE `foo` /*!40100 DEFAULT CHARACTER SET latin1 */
create table t1 (id int) engine=pbxt;
show schemas;
Database
information_schema
foo
mtr
mysql
pbxt
test
drop schema foo;
......@@ -604,15 +604,15 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort
1 SIMPLE t3 ref period period 4 test.t1.period 18
1 SIMPLE t3 ref period period 4 test.t1.period 1
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 index period period 4 NULL 1
1 SIMPLE t1 ref period period 4 test.t3.period 18
1 SIMPLE t3 index period period 4 NULL 10
1 SIMPLE t1 ref period period 4 test.t3.period 1
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index period period 4 NULL 1
1 SIMPLE t3 ref period period 4 test.t1.period 18
1 SIMPLE t1 index period period 4 NULL 10
1 SIMPLE t3 ref period period 4 test.t1.period 1
select period from t1;
period
9410
......@@ -2095,7 +2095,7 @@ show keys from t2;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE
t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE
t2 1 fld3 1 fld3 A NULL NULL NULL BTREE
t2 1 fld3 1 fld3 A 1199 NULL NULL BTREE
drop table t4, t3, t2, t1;
DO 1;
DO benchmark(100,1+1),1,1;
......@@ -2369,7 +2369,7 @@ insert into t2 values (1,3), (2,3), (3,4), (4,4);
explain select * from t1 left join t2 on a=c where d in (4);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref c,d d 5 const 1 Using where
1 SIMPLE t1 ref a a 5 test.t2.c 2 Using where
1 SIMPLE t1 ref a a 5 test.t2.c 1 Using where
select * from t1 left join t2 on a=c where d in (4);
a b c d
3 2 3 4
......@@ -2377,7 +2377,7 @@ a b c d
explain select * from t1 left join t2 on a=c where d = 4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref c,d d 5 const 1 Using where
1 SIMPLE t1 ref a a 5 test.t2.c 2 Using where
1 SIMPLE t1 ref a a 5 test.t2.c 1 Using where
select * from t1 left join t2 on a=c where d = 4;
a b c d
3 2 3 4
......@@ -2403,11 +2403,11 @@ INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref a a 23 test.t1.a 2
1 SIMPLE t2 ref a a 23 test.t1.a 1
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref a a 23 test.t1.a 2
1 SIMPLE t2 ref a a 23 test.t1.a 1
DROP TABLE t1, t2;
CREATE TABLE t1 ( city char(30) );
INSERT INTO t1 VALUES ('London');
......@@ -2792,26 +2792,26 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
select max(key1) from t1 where key1 <= 0.6158;
max(key1)
0.61580002307892
0.615800023078918
select max(key2) from t2 where key2 <= 1.6158;
max(key2)
1.6158000230789
1.61580002307892
select min(key1) from t1 where key1 >= 0.3762;
min(key1)
0.37619999051094
0.376199990510941
select min(key2) from t2 where key2 >= 1.3762;
min(key2)
1.3761999607086
1.37619996070862
select max(key1), min(key2) from t1, t2
where key1 <= 0.6158 and key2 >= 1.3762;
max(key1) min(key2)
0.61580002307892 1.3761999607086
0.615800023078918 1.37619996070862
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
max(key1)
0.61580002307892
0.615800023078918
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
min(key1)
0.37619999051094
0.376199990510941
DROP TABLE t1,t2;
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
INSERT INTO t1 VALUES (10);
......@@ -3454,7 +3454,7 @@ explain select * from t2 A, t2 B where A.a=5 and A.b=5 and A.C<5
and B.a=5 and B.b=A.e and (B.b =1 or B.b = 3 or B.b=5);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A range PRIMARY PRIMARY 12 NULL 1 Using where
1 SIMPLE B ref PRIMARY PRIMARY 8 const,test.A.e 11
1 SIMPLE B ref PRIMARY PRIMARY 8 const,test.A.e 1
drop table t1, t2;
CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b));
INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2),
......@@ -3468,12 +3468,12 @@ EXPLAIN
SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY,b b 5 NULL 1 Using where
1 SIMPLE t2 ref c c 5 test.t1.a 2 Using where
1 SIMPLE t2 ref c c 5 test.t1.a 1 Using where
EXPLAIN
SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY,b PRIMARY 4 NULL 1 Using where
1 SIMPLE t2 ref c c 5 test.t1.a 2 Using where
1 SIMPLE t2 ref c c 5 test.t1.a 1 Using where
DROP TABLE t1, t2;
create table t1 (
a int unsigned not null auto_increment primary key,
......
......@@ -70,12 +70,12 @@ insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(nu
explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL b NULL NULL NULL 21
1 SIMPLE t2 ref b b 21 test.t1.b 2 Using where
1 SIMPLE t2 ref b b 21 test.t1.b 1 Using where
set MAX_SEEKS_FOR_KEY=1;
explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL b NULL NULL NULL 21
1 SIMPLE t2 ref b b 21 test.t1.b 2 Using where
1 SIMPLE t2 ref b b 21 test.t1.b 1 Using where
SET MAX_SEEKS_FOR_KEY=DEFAULT;
drop table t1;
create table t1 (a int);
......
......@@ -1333,7 +1333,7 @@ a
explain extended select * from t2 where t2.a in (select a from t1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1 100.00 Using index; Using where
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
......@@ -1343,7 +1343,7 @@ a
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1 100.00 Using index; Using where
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
......@@ -1353,8 +1353,8 @@ a
explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 ref a a 5 func 1001 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 100.00 Using where; Using index; Using join buffer
2 DEPENDENT SUBQUERY t1 ref a a 5 func 1 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t3 ref a a 5 test.t1.b 1 100.00 Using where; Using index
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(select 1 AS `Not_used` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))
insert into t1 values (3,31);
......@@ -1370,7 +1370,7 @@ a
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1 100.00 Using index; Using where
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
drop table t1, t2, t3;
......@@ -3546,7 +3546,7 @@ ORDER BY t1.t DESC LIMIT 1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 1
1 PRIMARY t1 index NULL PRIMARY 16 NULL 11 Using where; Using index; Using join buffer
2 DEPENDENT SUBQUERY t1 ref PRIMARY PRIMARY 8 test.t2.i1,const 2 Using where; Using index; Using filesort
2 DEPENDENT SUBQUERY t1 ref PRIMARY PRIMARY 8 test.t2.i1,const 1 Using where; Using index; Using filesort
SELECT * FROM t1,t2
WHERE t1.t = (SELECT t1.t FROM t1
WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
......@@ -4214,7 +4214,7 @@ CREATE INDEX I2 ON t1 (b);
EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 2 Using index; Using where
2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 1 Using index; Using where
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
a b
CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10));
......@@ -4224,14 +4224,14 @@ CREATE INDEX I2 ON t2 (b);
EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 index_subquery I1 I1 4 func 2 Using index; Using where
2 DEPENDENT SUBQUERY t2 index_subquery I1 I1 4 func 1 Using index; Using where
SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
a b
EXPLAIN
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 2 Using index; Using where
2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 1 Using index; Using where
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
a b
DROP TABLE t1,t2;
......
......@@ -1776,8 +1776,14 @@ t1 CREATE TABLE `t1` (
`russian_deviant` enum('E','F','EF','F,E') NOT NULL DEFAULT 'E'
) ENGINE=PBXT DEFAULT CHARSET=latin1
drop table t1;
select @@SESSION.sql_mode;
@@SESSION.sql_mode
select @@GLOBAL.sql_mode;
@@GLOBAL.sql_mode
create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ','
 !"','#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~','xx\','yy\','zz'));
ERROR HY000: Can't create table 'test.t1' (errno: -1)
drop table t1;
End of 5.1 tests
......@@ -70,19 +70,19 @@ flags set('one','two','tree') latin1_swedish_ci NO #
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 auto A 0 NULL NULL BTREE
t1 1 utiny 1 utiny A NULL NULL NULL BTREE
t1 1 tiny 1 tiny A NULL NULL NULL BTREE
t1 1 short 1 short A NULL NULL NULL BTREE
t1 1 any_name 1 medium A NULL NULL NULL BTREE
t1 1 longlong 1 longlong A NULL NULL NULL BTREE
t1 1 real_float 1 real_float A NULL NULL NULL BTREE
t1 1 ushort 1 ushort A NULL NULL NULL BTREE
t1 1 umedium 1 umedium A NULL NULL NULL BTREE
t1 1 ulong 1 ulong A NULL NULL NULL BTREE
t1 1 ulonglong 1 ulonglong A NULL NULL NULL BTREE
t1 1 ulonglong 2 ulong A NULL NULL NULL BTREE
t1 1 options 1 options A NULL NULL NULL BTREE
t1 1 options 2 flags A NULL NULL NULL BTREE
t1 1 utiny 1 utiny A 0 NULL NULL BTREE
t1 1 tiny 1 tiny A 0 NULL NULL BTREE
t1 1 short 1 short A 0 NULL NULL BTREE
t1 1 any_name 1 medium A 0 NULL NULL BTREE
t1 1 longlong 1 longlong A 0 NULL NULL BTREE
t1 1 real_float 1 real_float A 0 NULL NULL BTREE
t1 1 ushort 1 ushort A 0 NULL NULL BTREE
t1 1 umedium 1 umedium A 0 NULL NULL BTREE
t1 1 ulong 1 ulong A 0 NULL NULL BTREE
t1 1 ulonglong 1 ulonglong A 0 NULL NULL BTREE
t1 1 ulonglong 2 ulong A 0 NULL NULL BTREE
t1 1 options 1 options A 0 NULL NULL BTREE
t1 1 options 2 flags A 0 NULL NULL BTREE
CREATE UNIQUE INDEX test on t1 ( auto ) ;
CREATE INDEX test2 on t1 ( ulonglong,ulong) ;
CREATE INDEX test3 on t1 ( medium ) ;
......
......@@ -101,13 +101,13 @@ create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
t14 timestamp(14));
Warnings:
Warning 1287 The syntax 'TIMESTAMP(2)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
Warning 1287 The syntax 'TIMESTAMP(4)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
Warning 1287 The syntax 'TIMESTAMP(6)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
Warning 1287 The syntax 'TIMESTAMP(8)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
Warning 1287 The syntax 'TIMESTAMP(10)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
Warning 1287 The syntax 'TIMESTAMP(12)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
Warning 1287 The syntax 'TIMESTAMP(14)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
Warning 1287 The syntax 'TIMESTAMP(2)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
Warning 1287 The syntax 'TIMESTAMP(4)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
Warning 1287 The syntax 'TIMESTAMP(6)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
Warning 1287 The syntax 'TIMESTAMP(8)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
Warning 1287 The syntax 'TIMESTAMP(10)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
Warning 1287 The syntax 'TIMESTAMP(12)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
Warning 1287 The syntax 'TIMESTAMP(14)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
insert t1 values (0,0,0,0,0,0,0),
("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
......
......@@ -1301,12 +1301,14 @@ t3 CREATE TABLE `t3` (
`left(a,100000000)` longtext
) ENGINE=PBXT DEFAULT CHARSET=latin1
drop tables t1,t2,t3;
SELECT @tmp_max:= @@global.max_allowed_packet;
@tmp_max:= @@global.max_allowed_packet
1048576
SET @@global.max_allowed_packet=25000000;
CREATE TABLE t1 (a mediumtext);
CREATE TABLE t2 (b varchar(20));
INSERT INTO t1 VALUES ('a');
CREATE TABLE t3 SELECT REPEAT(a,20000000) AS a FROM t1 UNION SELECT b FROM t2;
Warnings:
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
SHOW CREATE TABLE t3;
Table Create Table
t3 CREATE TABLE `t3` (
......@@ -1340,6 +1342,7 @@ t3 CREATE TABLE `t3` (
`a` varbinary(510) DEFAULT NULL
) ENGINE=PBXT DEFAULT CHARSET=latin1
DROP TABLES t1,t2,t3;
SET @@global.max_allowed_packet:= @tmp_max;
create table t1 ( id int not null auto_increment, primary key (id), col1 int);
insert into t1 (col1) values (2),(3),(4),(5),(6);
select 99 union all select id from t1 order by 1;
......
......@@ -28,7 +28,7 @@ create view v2 as select * from mysqltest.t2;
ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for table 't2'
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` latin1 latin1_swedish_ci
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` latin1 latin1_swedish_ci
grant create view,drop,select on test.* to mysqltest_1@localhost;
use test;
alter view v1 as select * from mysqltest.t1;
......@@ -309,7 +309,7 @@ grant create view,select on test.* to mysqltest_1@localhost;
create view v1 as select * from mysqltest.t1;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` latin1 latin1_swedish_ci
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` latin1 latin1_swedish_ci
revoke select on mysqltest.t1 from mysqltest_1@localhost;
select * from v1;
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
......
......@@ -150,7 +150,6 @@ delete from t1 where a=0;
update t1 set a=0 where b=5;
select * from t1 order by b;
delete from t1 where a=0;
--error 1048
update t1 set a=NULL where b=6;
update t1 set a=300 where b=7;
SET SQL_MODE='';
......@@ -166,7 +165,6 @@ delete from t1 where a=0;
update t1 set a=0 where b=12;
select * from t1 order by b;
delete from t1 where a=0;
--error 1048
update t1 set a=NULL where b=13;
update t1 set a=500 where b=14;
select * from t1 order by b;
......
......@@ -120,13 +120,16 @@ select * from t2;
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
select * from t11;
select * from t12;
--error 1242
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
select * from t11;
select * from t12;
--error 1062
insert into t11 values (2, 12);
-- error 1242
delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
select * from t11;
--error 1242
delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
select * from t11;
drop table t11, t12, t2;
......
......@@ -546,6 +546,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
CREATE INDEX idx_b ON t8(b);
--sorted_result
EXPLAIN EXTENDED
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
......@@ -585,6 +586,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
CREATE INDEX idx_b ON t1(b);
CREATE INDEX idx_a ON t0(a);
--sorted_result
EXPLAIN EXTENDED
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
......@@ -621,6 +623,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
(t8.b=t9.b OR t8.c IS NULL) AND
(t9.a=1);
--sorted_result
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
FROM t0,t1
......
......@@ -61,9 +61,7 @@ drop table t1;
#
CREATE TABLE t1 (a varchar(16) NOT NULL default '', b smallint(6) NOT NULL default 0, c datetime NOT NULL default '0000-00-00 00:00:00', d smallint(6) NOT NULL default 0);
INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55";
--error 1048
UPDATE t1 SET d=1/NULL;
--error 1048
UPDATE t1 SET d=NULL;
--error 1048
INSERT INTO t1 (a) values (null);
......
......@@ -926,7 +926,59 @@ LOAD DATA LOCAL INFILE 'suite/pbxt/t/load_unique_error1.inc' REPLACE INTO TABLE
SELECT * FROM t1 ORDER BY c1;
DROP TABLE t1;
create table parent (id int primary key);
create table child (id int PRIMARY KEY, FOREIGN KEY (id) REFERENCES parent(id));
insert into parent values (2), (3), (4);
insert into child values (3), (4);
--error 1451
delete ignore from parent;
--sorted_result
select * from parent;
drop table child, parent;
# bug 378222: Drop sakila causes error: Cannot delete or update a parent row: a foreign key constraint fails
create schema test378222;
use test378222;
create table t1 (id int primary key);
create table t2 (id int primary key);
alter table t1 add constraint foreign key (id) references t2 (id);
alter table t2 add constraint foreign key (id) references t1 (id);
drop schema test378222;
create schema test378222a;
create schema test378222b;
create table test378222a.t1 (id int primary key);
create table test378222b.t2 (id int primary key);
alter table test378222a.t1 add constraint foreign key (id) references test378222b.t2 (id);
alter table test378222b.t2 add constraint foreign key (id) references test378222a.t1 (id);
set foreign_key_checks = 1;
--error 1217
drop schema test378222a;
--error 1217
drop schema test378222b;
set foreign_key_checks = 0;
drop schema test378222a;
drop schema test378222b;
set foreign_key_checks = 1;
use test;
# bug 369086: Incosistent/Incorrect Truncate behavior
CREATE TABLE t1(c1 TINYINT AUTO_INCREMENT NULL KEY ) AUTO_INCREMENT=10;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES(null);
INSERT INTO t1 VALUES(null);
INSERT INTO t1 VALUES(null);
SELECT * FROM t1;
TRUNCATE TABLE t1;
INSERT INTO t1 VALUES(null);
SELECT * FROM t1;
DROP TABLE t1;
--disable_query_log
DROP TABLE t2, t5;
drop database pbxt;
--enable_query_log
......@@ -63,7 +63,28 @@ connection con2;
# Wait for the the tables to be renamed
# i.e the query below succeds
let $query= select * from t2, t4;
source include/wait_for_query_to_suceed.inc;
# source include/wait_for_query_to_suceed.inc;
let $counter= 100;
disable_abort_on_error;
disable_query_log;
disable_result_log;
eval $query;
while ($mysql_errno)
{
eval $query;
sleep 0.1;
dec $counter;
if (!$counter)
{
die("Waited too long for query to suceed");
}
}
enable_abort_on_error;
enable_query_log;
enable_result_log;
show tables;
......
......@@ -10,5 +10,12 @@ drop database if exists mysqltest1;
create schema foo;
show create schema foo;
# force PBXT schema to be created
create table t1 (id int) engine=pbxt;
show schemas;
drop schema foo;
--disable_query_log
drop table if exists t1;
drop database pbxt;
--enable_query_log
......@@ -153,12 +153,19 @@ create table t1(russian_deviant enum('E','F','E
show create table t1;
drop table t1;
# ER_WRONG_FIELD_TERMINATORS
--error 1005
# the following create statement sometimes fails like it would if NO_BACKSLASH_ESCAPES sql mode was on,
# we check sql mode here
select @@SESSION.sql_mode;
select @@GLOBAL.sql_mode;
## ER_WRONG_FIELD_TERMINATORS
#--error 1005
create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ','
 !"','#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~','xx\','yy\','zz'));
drop table t1;
--disable_query_log
drop database pbxt;
--enable_query_log
......
......@@ -802,6 +802,10 @@ drop tables t1,t2,t3;
# exceeds mediumtext maximum length
#
SELECT @tmp_max:= @@global.max_allowed_packet;
SET @@global.max_allowed_packet=25000000;
# switching connection to allow the new max_allowed_packet take effect
--connect (newconn, localhost, root,,)
CREATE TABLE t1 (a mediumtext);
CREATE TABLE t2 (b varchar(20));
INSERT INTO t1 VALUES ('a');
......@@ -823,6 +827,9 @@ INSERT INTO t1 VALUES ('a');
CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2;
SHOW CREATE TABLE t3;
DROP TABLES t1,t2,t3;
--connection default
SET @@global.max_allowed_packet:= @tmp_max;
--disconnect newconn
#
# Bug #10032 Bug in parsing UNION with ORDER BY when one node does not use FROM
......
......@@ -25,6 +25,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/regex
${CMAKE_SOURCE_DIR}/zlib
${CMAKE_SOURCE_DIR}/extra/libevent
)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/sql/sql_yacc.h
......@@ -85,7 +86,7 @@ ADD_EXECUTABLE(mysqld
TARGET_LINK_LIBRARIES(mysqld
heap myisam myisammrg mysys yassl zlib debug dbug yassl
taocrypt strings vio regex wsock32 ws2_32)
taocrypt strings vio regex libevent wsock32 ws2_32)
SET_TARGET_PROPERTIES(mysqld PROPERTIES OUTPUT_NAME mysqld${MYSQLD_EXE_SUFFIX})
......@@ -139,7 +140,7 @@ ADD_CUSTOM_COMMAND(
# Gen_lex_hash
ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc)
TARGET_LINK_LIBRARIES(gen_lex_hash debug dbug mysqlclient wsock32)
TARGET_LINK_LIBRARIES(gen_lex_hash debug dbug mysqlclient strings wsock32)
GET_TARGET_PROPERTY(GEN_LEX_HASH_EXE gen_lex_hash LOCATION)
ADD_CUSTOM_COMMAND(
OUTPUT ${PROJECT_SOURCE_DIR}/sql/lex_hash.h
......
PBXT Release Notes
==================
------- 1.0.08 RC - Not yet released
------- 1.0.08c RC2 - 2009-08-18
RN266: Updated BLOB streaming glue, used with the PBMS engine. The glue code is now identical to the version of "1.0.08-rc-pbms" version of PBXT available from http://blobstreaming.org/download.
RN265: Changes the sequential reading of data log files to skip gaps, instead of returning EOF. This ensures that extended data records are preserved even when something goes wrong with the way the file is written.
RN264: Fixed a bug that cased an "Data log not found" error after an out of disk space error on a log file. This bug is similar to RN262 in that it allows "gaps" to appear in the data logs.
RN263: Updated xtstat to compile on Windows/MS Visual C++.
RN262: Merged changes for PBMS version 0.5.09.
RN261: Concerning bug #377788: Cannot find index for FK. Fixed buffer overflow which occurred when the error was reported.
RN260: Fixed bug #377788: Cannot find index for FK. PBXT now correctly uses prefix of an index to support FK references (e.g. if key = (c1, c2) then an index on (c1, c2, c3) will work). Also fixed buffer overflow, which occurred when reporting the error.
RN259: Fixed bug #309424: xtstat doesn't use my.cnf. You can now add an [xtstat] section to my.cnf, for use with xtstat.
RN258: updated xt_p_join implementation for Windows to check if a thread has already exited or has not yet started
RN257: Removed false assertion that could fail during restore if a transaction log page was zero-filled
RN256: Update datalog eof pointer only if write opearions were sucessful
RN255: Added re-allocation of of filemap if allocating the of the new map failed. This often happens if there's not enough space on disk.
RN254: When a table with a corrupted index is detected, PBXT creates a file called 'repair-pending' in the pbxt directory, with the name of the table in it. Each table in the file is listed on a line by itself (the last line has no trailing \n). When the table is repaired (using the REPAIR TABLE command), this entry is removed from the file.
RN253: Use fcntl(F_FULLFSYNC) instead of fsync on platforms that support it. Improper fsync operation was presumably the reason of index corruption on Mac OS X.
RN252: Fixed bug #368692: PBXT not reporting data size correctly in information_schema.
------- 1.0.08 RC2 - 2009-06-30
RN251: A Windows-specific test update, also removed false assertion that failed on Windows.
RN250: Fixed a bug that caused recovery to fail when the transaction log ID exceeded 255. The problem was a checksum failed in the log record.
RN249: Fixed bug #313176: Test case timeout. This happened because record cache pages where not properly freed and as soon as cache filled up the performacne degraded.
RN248: PBXT now compiles and runs with MySQL 5.1.35. All tests pass.
RN247: Fixed bug #369086: Incosistent/Incorrect Truncate behavior
RN246: Fixed bug #378222: Drop sakila causes error: Cannot delete or update a parent row: a foreign key constraint fails
RN245: Fixed bug #379315: Inconsistent behavior of DELETE IGNORE and FK constraint.
RN244: Fixed a recovery problem: during the recovery of "record modified" action the table was updated before the old index entries were removed; then the xres_remove_index_entries was supplied the new record which lead to incorrect index update.
RN243: Fixed a bug that caused a recovery failure if partitioned pbxt tables where present. This happended because the recovery used a MySQL function to open tables and the PBXT handler was not yet registered
RN242: Fixed a bug that caused a deadlock if pbxt initialization failed. This happened because pbxt ceanup was done from pbxt_init() with PLUGIN_lock being held by MySQL which lead to a deadlock in the freeer thread
RN241: Fixed a heap corruption bug (writing to a freed memory location). It happened only when memory mapped files were used leading to heap inconsistency and program crash or termination by heap checker. Likely to happen right after or during DROP TABLE but possible in other cases too.
RN240: Load the record cache on read when no using memory mapped files.
RN239: Added PBXT variable pbxt_max_threads. This is the maximum number of threads that can be created PBXT. By default this value is set to 0 which means the number of threads is derived from the MySQL variable max_connections. The value used is max_connections+7. Under Drizzle the default value is 500.
RN238: Added an option to wait for the sweeper to clean up old transactions on a particular connection. This prevents the sweeper from getting too far behind.
RN237: Added an option to lazy delete fixed length index entries. This means the index entries are just marked for deletion, instead of removing the items from the index page. This has the advantage that an exclusive lock is not always required for deletion.
RN236: Fixed bug #349177: a bug in configure.in script.
RN235: Fixed bug 349176: a compiler warning.
RN234: Completed Drizzle integration. All Drizzle tests now run with PBXT.
RN233: Fixed bugs which occur when PBXT is used together with PBMS (BLOB Streaming engine).
......
......@@ -19,7 +19,7 @@ noinst_HEADERS = bsearch_xt.h cache_xt.h ccutils_xt.h database_xt.h \
datadic_xt.h datalog_xt.h filesys_xt.h hashtab_xt.h \
ha_pbxt.h heap_xt.h index_xt.h linklist_xt.h \
memory_xt.h myxt_xt.h pthread_xt.h restart_xt.h \
streaming_xt.h sortedlist_xt.h strutil_xt.h \
pbms_enabled.h sortedlist_xt.h strutil_xt.h \
tabcache_xt.h table_xt.h trace_xt.h thread_xt.h \
util_xt.h xaction_xt.h xactlog_xt.h lock_xt.h \
systab_xt.h ha_xtsys.h discover_xt.h \
......@@ -30,7 +30,7 @@ libpbxt_la_SOURCES = bsearch_xt.cc cache_xt.cc ccutils_xt.cc database_xt.cc \
datadic_xt.cc datalog_xt.cc filesys_xt.cc hashtab_xt.cc \
ha_pbxt.cc heap_xt.cc index_xt.cc linklist_xt.cc \
memory_xt.cc myxt_xt.cc pthread_xt.cc restart_xt.cc \
streaming_xt.cc sortedlist_xt.cc strutil_xt.cc \
pbms_enabled.cc sortedlist_xt.cc strutil_xt.cc \
tabcache_xt.cc table_xt.cc trace_xt.cc thread_xt.cc \
systab_xt.cc ha_xtsys.cc discover_xt.cc \
util_xt.cc xaction_xt.cc xactlog_xt.cc lock_xt.cc locklist_xt.cc
......
This diff is collapsed.
......@@ -45,8 +45,46 @@ struct XTIdxReadBuffer;
#define IDX_CAC_BLOCK_CLEAN 1
#define IDX_CAC_BLOCK_DIRTY 2
typedef enum XTPageLockType { XT_LOCK_READ, XT_LOCK_WRITE, XT_XLOCK_LEAF };
typedef enum XTPageUnlockType { XT_UNLOCK_NONE, XT_UNLOCK_READ, XT_UNLOCK_WRITE, XT_UNLOCK_R_UPDATE, XT_UNLOCK_W_UPDATE };
#ifdef XT_NO_ATOMICS
#define XT_IPAGE_USE_PTHREAD_RW
#else
//#define XT_IPAGE_USE_ATOMIC_RW
#define XT_IPAGE_USE_SPINXSLOCK
//#define XT_IPAGE_USE_SKEW_RW
#endif
#ifdef XT_IPAGE_USE_ATOMIC_RW
#define XT_IPAGE_LOCK_TYPE XTAtomicRWLockRec
#define XT_IPAGE_INIT_LOCK(s, i) xt_atomicrwlock_init_with_autoname(s, i)
#define XT_IPAGE_FREE_LOCK(s, i) xt_atomicrwlock_free(s, i)
#define XT_IPAGE_READ_LOCK(i) xt_atomicrwlock_slock(i)
#define XT_IPAGE_WRITE_LOCK(i, o) xt_atomicrwlock_xlock(i, o)
#define XT_IPAGE_UNLOCK(i, x) xt_atomicrwlock_unlock(i, x)
#elif defined(XT_IPAGE_USE_PTHREAD_RW)
#define XT_IPAGE_LOCK_TYPE xt_rwlock_type
#define XT_IPAGE_INIT_LOCK(s, i) xt_init_rwlock(s, i)
#define XT_IPAGE_FREE_LOCK(s, i) xt_free_rwlock(i)
#define XT_IPAGE_READ_LOCK(i) xt_slock_rwlock_ns(i)
#define XT_IPAGE_WRITE_LOCK(i, s) xt_xlock_rwlock_ns(i)
#define XT_IPAGE_UNLOCK(i, x) xt_unlock_rwlock_ns(i)
#elif defined(XT_IPAGE_USE_SPINXSLOCK)
#define XT_IPAGE_LOCK_TYPE XTSpinXSLockRec
#define XT_IPAGE_INIT_LOCK(s, i) xt_spinxslock_init_with_autoname(s, i)
#define XT_IPAGE_FREE_LOCK(s, i) xt_spinxslock_free(s, i)
#define XT_IPAGE_READ_LOCK(i) xt_spinxslock_slock(i)
#define XT_IPAGE_WRITE_LOCK(i, o) xt_spinxslock_xlock(i, o)
#define XT_IPAGE_UNLOCK(i, x) xt_spinxslock_unlock(i, x)
#else // XT_IPAGE_USE_SKEW_RW
#define XT_IPAGE_LOCK_TYPE XTSkewRWLockRec
#define XT_IPAGE_INIT_LOCK(s, i) xt_skewrwlock_init_with_autoname(s, i)
#define XT_IPAGE_FREE_LOCK(s, i) xt_skewrwlock_free(s, i)
#define XT_IPAGE_READ_LOCK(i) xt_skewrwlock_slock(i)
#define XT_IPAGE_WRITE_LOCK(i, o) xt_skewrwlock_xlock(i, o)
#define XT_IPAGE_UNLOCK(i, x) xt_skewrwlock_unlock(i, x)
#endif
enum XTPageLockType { XT_LOCK_READ, XT_LOCK_WRITE, XT_XLOCK_LEAF, XT_XLOCK_DEL_LEAF };
enum XTPageUnlockType { XT_UNLOCK_NONE, XT_UNLOCK_READ, XT_UNLOCK_WRITE, XT_UNLOCK_R_UPDATE, XT_UNLOCK_W_UPDATE };
/* A block is X locked if it is being changed or freed.
* A block is S locked if it is being read.
......@@ -64,10 +102,11 @@ typedef struct XTIndBlock {
struct XTIndBlock *cb_mr_used; /* More recently used blocks. */
struct XTIndBlock *cb_lr_used; /* Less recently used blocks. */
/* Protected by cb_lock: */
XTAtomicRWLockRec cb_lock;
XT_IPAGE_LOCK_TYPE cb_lock;
xtWord1 cb_state; /* Block status. */
xtWord2 cb_handle_count; /* TRUE if this page is referenced by a handle. */
xtWord2 cp_flush_seq;
xtWord2 cp_del_count; /* Number of deleted entries. */
#ifdef XT_USE_DIRECT_IO_ON_INDEX
xtWord1 *cb_data;
#else
......@@ -76,16 +115,18 @@ typedef struct XTIndBlock {
} XTIndBlockRec, *XTIndBlockPtr;
typedef struct XTIndReference {
XTPageUnlockType ir_ulock;
xtBool ir_xlock; /* Set to TRUE if the cache block is X locked. */
xtBool ir_updated; /* Set to TRUE if the cache block is updated. */
XTIndBlockPtr ir_block;
XTIdxBranchDPtr ir_branch;
} XTIndReferenceRec, *XTIndReferencePtr;
typedef struct XTIndFreeBlock {
XTDiskValue1 if_zero1_1; /* Must be set to zero. */
XTDiskValue1 if_zero2_1; /* Must be set to zero. */
XTDiskValue1 if_status_1;
XTDiskValue1 if_unused1_1;
XTDiskValue2 if_unused2_2;
XTDiskValue4 if_unused3_4;
XTDiskValue4 if_unused2_4;
XTDiskValue8 if_next_block_8;
} XTIndFreeBlockRec, *XTIndFreeBlockPtr;
......@@ -116,14 +157,13 @@ xtInt8 xt_ind_get_size();
xtBool xt_ind_write(struct XTOpenTable *ot, XTIndexPtr ind, xtIndexNodeID offset, size_t size, xtWord1 *data);
xtBool xt_ind_write_cache(struct XTOpenTable *ot, xtIndexNodeID offset, size_t size, xtWord1 *data);
xtBool xt_ind_clean(struct XTOpenTable *ot, XTIndexPtr ind, xtIndexNodeID offset);
xtBool xt_ind_read_bytes(struct XTOpenTable *ot, xtIndexNodeID offset, size_t size, xtWord1 *data);
xtBool xt_ind_read_bytes(struct XTOpenTable *ot, XTIndexPtr ind, xtIndexNodeID offset, size_t size, xtWord1 *data);
void xt_ind_check_cache(XTIndexPtr ind);
xtBool xt_ind_reserve(struct XTOpenTable *ot, u_int count, XTIdxBranchDPtr not_this);
void xt_ind_free_reserved(struct XTOpenTable *ot);
void xt_ind_unreserve(struct XTOpenTable *ot);
void xt_load_indices(XTThreadPtr self, struct XTOpenTable *ot);
xtBool xt_ind_fetch(struct XTOpenTable *ot, xtIndexNodeID node, XTPageLockType ltype, XTIndReferencePtr iref);
xtBool xt_ind_fetch(struct XTOpenTable *ot, XTIndexPtr ind, xtIndexNodeID node, XTPageLockType ltype, XTIndReferencePtr iref);
xtBool xt_ind_release(struct XTOpenTable *ot, XTIndexPtr ind, XTPageUnlockType utype, XTIndReferencePtr iref);
void xt_ind_lock_handle(XTIndHandlePtr handle);
......
......@@ -29,7 +29,7 @@
#include "ccutils_xt.h"
#include "bsearch_xt.h"
static int ccu_compare_object(XTThreadPtr XT_UNUSED(self), register const void XT_UNUSED(*thunk), register const void *a, register const void *b)
static int ccu_compare_object(XTThreadPtr XT_UNUSED(self), register const void *XT_UNUSED(thunk), register const void *a, register const void *b)
{
XTObject *obj_ptr = (XTObject *) b;
......
......@@ -23,6 +23,10 @@
#include "xt_config.h"
#ifdef DRIZZLED
#include <bitset>
#endif
#include <string.h>
#include <stdio.h>
......@@ -240,7 +244,7 @@ static void db_hash_free(XTThreadPtr self, void *data)
xt_heap_release(self, (XTDatabaseHPtr) data);
}
static int db_cmp_db_id(struct XTThread XT_UNUSED(*self), register const void XT_UNUSED(*thunk), register const void *a, register const void *b)
static int db_cmp_db_id(struct XTThread *XT_UNUSED(self), register const void *XT_UNUSED(thunk), register const void *a, register const void *b)
{
xtDatabaseID db_id = *((xtDatabaseID *) a);
XTDatabaseHPtr *db_ptr = (XTDatabaseHPtr *) b;
......@@ -346,7 +350,7 @@ static void db_finalize(XTThreadPtr self, void *x)
}
}
static void db_onrelease(XTThreadPtr self, void XT_UNUSED(*x))
static void db_onrelease(XTThreadPtr self, void *XT_UNUSED(x))
{
/* Signal threads waiting for exclusive use of the database: */
if (xt_db_open_databases) // The database may already be closed.
......@@ -612,7 +616,7 @@ xtPublic void xt_drop_database(XTThreadPtr self, XTDatabaseHPtr db)
xtPublic void xt_open_database(XTThreadPtr self, char *path, xtBool multi_path)
{
XTDatabaseHPtr db;
/* We cannot get a database, without unusing the current
* first. The reason is that the restart process will
* partially set the current database!
......@@ -621,7 +625,7 @@ xtPublic void xt_open_database(XTThreadPtr self, char *path, xtBool multi_path)
db = xt_get_database(self, path, multi_path);
pushr_(xt_heap_release, db);
xt_use_database(self, db, XT_FOR_USER);
freer_(); // xt_heap_release(self, db);
freer_(); // xt_heap_release(self, db);
}
/* This function can only be called if you do not already have a database in
......@@ -638,6 +642,12 @@ xtPublic void xt_use_database(XTThreadPtr self, XTDatabaseHPtr db, int what_for)
xt_heap_reference(self, db);
self->st_database = db;
#ifdef XT_WAIT_FOR_CLEANUP
self->st_last_xact = 0;
for (int i=0; i<XT_MAX_XACT_BEHIND; i++) {
self->st_prev_xact[i] = db->db_xn_curr_id;
}
#endif
xt_xn_init_thread(self, what_for);
}
......@@ -1117,15 +1127,18 @@ xtPublic void xt_db_return_table_to_pool_ns(XTOpenTablePtr ot)
XTDatabaseHPtr db = ot->ot_table->tab_db;
xtBool flush_table = TRUE;
/* No open table returned to the pool should still
* have a cache handle!
*/
ASSERT_NS(!ot->ot_ind_rhandle);
xt_lock_mutex_ns(&db->db_ot_pool.opt_lock);
if (!(table_pool = db_get_open_table_pool(db, ot->ot_table->tab_id)))
goto failed;
if (table_pool->opt_locked && !table_pool->opt_flushing) {
table_pool->opt_total_open--;
/* Table will be closed below: */
if (table_pool->opt_total_open > 0)
if (table_pool->opt_total_open > 1)
flush_table = FALSE;
}
else {
......@@ -1151,14 +1164,21 @@ xtPublic void xt_db_return_table_to_pool_ns(XTOpenTablePtr ot)
ot = NULL;
}
if (ot) {
xt_unlock_mutex_ns(&db->db_ot_pool.opt_lock);
xt_close_table(ot, flush_table, FALSE);
/* assume that table_pool cannot be invalidated in between as we have table_pool->opt_total_open > 0 */
xt_lock_mutex_ns(&db->db_ot_pool.opt_lock);
table_pool->opt_total_open--;
}
db_free_open_table_pool(NULL, table_pool);
if (!xt_broadcast_cond_ns(&db->db_ot_pool.opt_cond))
goto failed;
xt_unlock_mutex_ns(&db->db_ot_pool.opt_lock);
if (ot)
xt_close_table(ot, flush_table, FALSE);
return;
failed:
......
This diff is collapsed.
......@@ -137,6 +137,7 @@ class XTDDColumnRef : public XTObject {
return new_obj;
}
virtual void init(XTThreadPtr self) { XTObject::init(self); }
virtual void init(XTThreadPtr self, XTObject *obj);
virtual void finalize(XTThreadPtr self);
};
......@@ -156,6 +157,7 @@ class XTDDConstraint : public XTObject {
co_ind_name(NULL) {
}
virtual void init(XTThreadPtr self) { XTObject::init(self); }
virtual void init(XTThreadPtr self, XTObject *obj);
virtual void finalize(XTThreadPtr self) {
if (co_name)
......@@ -169,6 +171,7 @@ class XTDDConstraint : public XTObject {
virtual void alterColumnName(XTThreadPtr self, char *from_name, char *to_name);
void getColumnList(char *buffer, size_t size);
bool sameColumns(XTDDConstraint *co);
bool samePrefixColumns(XTDDConstraint *co);
bool attachColumns();
};
......@@ -198,6 +201,7 @@ class XTDDIndex : public XTDDConstraint {
return new_obj;
}
virtual void init(XTThreadPtr self) { XTDDConstraint::init(self); };
virtual void init(XTThreadPtr self, XTObject *obj);
struct XTIndex *getIndexPtr();
};
......@@ -230,12 +234,14 @@ class XTDDForeignKey : public XTDDIndex {
return new_obj;
}
virtual void init(XTThreadPtr self) { XTDDIndex::init(self); }
virtual void init(XTThreadPtr self, XTObject *obj);
virtual void finalize(XTThreadPtr self);
virtual void loadString(XTThreadPtr self, XTStringBufferPtr sb);
void getReferenceList(char *buffer, size_t size);
struct XTIndex *getReferenceIndexPtr();
bool sameReferenceColumns(XTDDConstraint *co);
bool samePrefixReferenceColumns(XTDDConstraint *co);
bool checkReferencedTypes(XTDDTable *dt);
void removeReference(XTThreadPtr self);
bool insertRow(xtWord1 *before, xtWord1 *after, XTThreadPtr thread);
......@@ -284,7 +290,7 @@ class XTDDTable : public XTObject {
XTDDIndex *findReferenceIndex(XTDDForeignKey *fk);
bool insertRow(struct XTOpenTable *rec_ot, xtWord1 *buffer);
bool checkNoAction(struct XTOpenTable *ot, xtRecordID rec_id);
xtBool checkCanDrop();
xtBool checkCanDrop(xtBool drop_db);
bool deleteRow(struct XTOpenTable *rec_ot, xtWord1 *buffer);
void deleteAllRows(XTThreadPtr self);
bool updateRow(struct XTOpenTable *rec_ot, xtWord1 *before, xtWord1 *after);
......
This diff is collapsed.
......@@ -183,8 +183,8 @@ typedef struct XTSeqLogRead {
virtual xtBool sl_rnd_read(xtLogOffset log_offset, size_t size, xtWord1 *data, size_t *read, struct XTThread *thread) {
(void) log_offset; (void) size; (void) data; (void) read; (void) thread; return OK;
};
virtual xtBool sl_seq_next(XTXactLogBufferDPtr *entry, xtBool verify, struct XTThread *thread) {
(void) entry; (void) verify; (void) thread; return OK;
virtual xtBool sl_seq_next(XTXactLogBufferDPtr *entry, struct XTThread *thread) {
(void) entry; (void) thread; return OK;
};
virtual void sl_seq_skip(size_t size) { (void) size; }
} XTSeqLogReadRec, *XTSeqLogReadPtr;
......@@ -195,6 +195,7 @@ typedef struct XTDataSeqRead : public XTSeqLogRead {
xtLogOffset sl_rec_log_offset; /* The current log read position. */
size_t sl_record_len; /* The length of the current record. */
xtLogOffset sl_log_eof;
xtLogOffset sl_extra_garbage; /* Garbage found during a scan. */
size_t sl_buffer_size; /* Size of the buffer. */
xtLogOffset sl_buf_log_offset; /* File offset of the buffer. */
......@@ -208,7 +209,7 @@ typedef struct XTDataSeqRead : public XTSeqLogRead {
virtual void sl_seq_pos(xtLogID *log_id, xtLogOffset *log_offset);
virtual xtBool sl_seq_start(xtLogID log_id, xtLogOffset log_offset, xtBool missing_ok);
virtual xtBool sl_rnd_read(xtLogOffset log_offset, size_t size, xtWord1 *data, size_t *read, struct XTThread *thread);
virtual xtBool sl_seq_next(XTXactLogBufferDPtr *entry, xtBool verify, struct XTThread *thread);
virtual xtBool sl_seq_next(XTXactLogBufferDPtr *entry, struct XTThread *thread);
virtual void sl_seq_skip(size_t size);
virtual void sl_seq_skip_to(off_t offset);
} XTDataSeqReadRec, *XTDataSeqReadPtr;
......
......@@ -1282,9 +1282,11 @@ warn:
#endif // LOCK_OPEN_HACK_REQUIRED
//------------------------------
int xt_create_table_frm(handlerton *hton, THD* thd, const char *db, const char *name, DT_FIELD_INFO *info, DT_KEY_INFO *keys __attribute__((unused)), xtBool skip_existing)
int xt_create_table_frm(handlerton *hton, THD* thd, const char *db, const char *name, DT_FIELD_INFO *info, DT_KEY_INFO *XT_UNUSED(keys), xtBool skip_existing)
{
#ifdef DRIZZLED
drizzled::message::Table table_proto;
static const char *ext = ".dfe";
static const int ext_len = 4;
#else
......@@ -1329,8 +1331,7 @@ int xt_create_table_frm(handlerton *hton, THD* thd, const char *db, const char *
info->field_flags,
COLUMN_FORMAT_TYPE_FIXED,
NULL /*default_value*/, NULL /*on_update_value*/, &comment, NULL /*change*/,
NULL /*interval_list*/, info->field_charset,
NULL /*vcol_info*/))
NULL /*interval_list*/, info->field_charset))
#else
if (add_field_to_list(thd, &field_name, info->field_type, field_length_ptr, info->field_decimal_length,
info->field_flags,
......@@ -1365,7 +1366,10 @@ int xt_create_table_frm(handlerton *hton, THD* thd, const char *db, const char *
/* Create an internal temp table */
#ifdef DRIZZLED
if (mysql_create_table_no_lock(thd, db, name, &mylex.create_info, &mylex.alter_info, 1, 0, false))
table_proto.set_name(name);
table_proto.set_type(drizzled::message::Table::STANDARD);
if (mysql_create_table_no_lock(thd, db, name, &mylex.create_info, &table_proto, &mylex.alter_info, 1, 0, false))
goto error;
#else
if (mysql_create_table_no_lock(thd, db, name, &mylex.create_info, &mylex.alter_info, 1, 0))
......
This diff is collapsed.
......@@ -76,13 +76,60 @@ xtBool xt_fs_rename(struct XTThread *self, char *from_path, char *to_path);
#define XT_NULL_FD (-1)
#endif
/* Note, this lock must be re-entrant,
* The only lock that satifies this is
* FILE_MAP_USE_RWMUTEX!
*
* 20.05.2009: This problem should be fixed now with mf_slock_count!
*
* The lock need no longer be re-entrant
*/
#ifdef XT_NO_ATOMICS
#define FILE_MAP_USE_PTHREAD_RW
#else
//#define FILE_MAP_USE_RWMUTEX
//#define FILE_MAP_USE_PTHREAD_RW
//#define IDX_USE_SPINXSLOCK
#define FILE_MAP_USE_XSMUTEX
#endif
#ifdef FILE_MAP_USE_XSMUTEX
#define FILE_MAP_LOCK_TYPE XTXSMutexRec
#define FILE_MAP_INIT_LOCK(s, i) xt_xsmutex_init_with_autoname(s, i)
#define FILE_MAP_FREE_LOCK(s, i) xt_xsmutex_free(s, i)
#define FILE_MAP_READ_LOCK(i, o) xt_xsmutex_slock(i, o)
#define FILE_MAP_WRITE_LOCK(i, o) xt_xsmutex_xlock(i, o)
#define FILE_MAP_UNLOCK(i, o) xt_xsmutex_unlock(i, o)
#elif defined(FILE_MAP_USE_PTHREAD_RW)
#define FILE_MAP_LOCK_TYPE xt_rwlock_type
#define FILE_MAP_INIT_LOCK(s, i) xt_init_rwlock(s, i)
#define FILE_MAP_FREE_LOCK(s, i) xt_free_rwlock(i)
#define FILE_MAP_READ_LOCK(i, o) xt_slock_rwlock_ns(i)
#define FILE_MAP_WRITE_LOCK(i, o) xt_xlock_rwlock_ns(i)
#define FILE_MAP_UNLOCK(i, o) xt_unlock_rwlock_ns(i)
#elif defined(FILE_MAP_USE_RWMUTEX)
#define FILE_MAP_LOCK_TYPE XTRWMutexRec
#define FILE_MAP_INIT_LOCK(s, i) xt_rwmutex_init_with_autoname(s, i)
#define FILE_MAP_FREE_LOCK(s, i) xt_rwmutex_free(s, i)
#define FILE_MAP_READ_LOCK(i, o) xt_rwmutex_slock(i, o)
#define FILE_MAP_WRITE_LOCK(i, o) xt_rwmutex_xlock(i, o)
#define FILE_MAP_UNLOCK(i, o) xt_rwmutex_unlock(i, o)
#elif defined(FILE_MAP_USE_SPINXSLOCK)
#define FILE_MAP_LOCK_TYPE XTSpinXSLockRec
#define FILE_MAP_INIT_LOCK(s, i) xt_spinxslock_init_with_autoname(s, i)
#define FILE_MAP_FREE_LOCK(s, i) xt_spinxslock_free(s, i)
#define FILE_MAP_READ_LOCK(i, o) xt_spinxslock_slock(i, o)
#define FILE_MAP_WRITE_LOCK(i, o) xt_spinxslock_xlock(i, o)
#define FILE_MAP_UNLOCK(i, o) xt_spinxslock_unlock(i, o)
#endif
typedef struct XTFileMemMap {
xtWord1 *mm_start; /* The in-memory start of the map. */
#ifdef XT_WIN
HANDLE mm_mapdes;
#endif
off_t mm_length; /* The length of the file map. */
XTRWMutexRec mm_lock; /* The file map R/W lock. */
FILE_MAP_LOCK_TYPE mm_lock; /* The file map R/W lock. */
size_t mm_grow_size; /* The amount by which the map file is increased. */
} XTFileMemMapRec, *XTFileMemMapPtr;
......@@ -127,6 +174,9 @@ xtBool xt_pwrite_file(XTOpenFilePtr of, off_t offset, size_t size, void *data,
xtBool xt_pread_file(XTOpenFilePtr of, off_t offset, size_t size, size_t min_size, void *data, size_t *red_size, struct XTIOStats *timer, struct XTThread *thread);
xtBool xt_flush_file(XTOpenFilePtr of, struct XTIOStats *timer, struct XTThread *thread);
xtBool xt_lock_file_ptr(XTOpenFilePtr of, xtWord1 **data, off_t offset, size_t size, struct XTIOStats *timer, struct XTThread *thread);
void xt_unlock_file_ptr(XTOpenFilePtr of, xtWord1 *data, struct XTThread *thread);
typedef struct XTOpenDir {
char *od_path;
#ifdef XT_WIN
......@@ -134,8 +184,14 @@ typedef struct XTOpenDir {
WIN32_FIND_DATA od_data;
#else
char *od_filter;
struct dirent od_entry;
DIR *od_dir;
/* WARNING: Solaris requires od_entry.d_name member to have size at least as returned
* by pathconf() function on per-directory basis. This makes it impossible to statically
* pre-set the size. So xt_dir_open on Solaris dynamically allocates space as needed.
*
* This also means that the od_entry member should always be last in the XTOpenDir structure.
*/
struct dirent od_entry;
#endif
} XTOpenDirRec, *XTOpenDirPtr;
......@@ -147,6 +203,7 @@ xtBool xt_dir_is_file(struct XTThread *self, XTOpenDirPtr od);
off_t xt_dir_file_size(struct XTThread *self, XTOpenDirPtr od);
typedef struct XTMapFile : public XTFileRef {
u_int mf_slock_count;
XTFileMemMapPtr mf_memmap;
} XTMapFileRec, *XTMapFilePtr;
......
This diff is collapsed.
......@@ -28,7 +28,7 @@
#ifdef DRIZZLED
#include <drizzled/common.h>
#include <drizzled/handler.h>
#include <drizzled/handlerton.h>
#include <drizzled/plugin/storage_engine.h>
#include <mysys/thr_lock.h>
#else
#include "mysql_priv.h"
......@@ -51,6 +51,25 @@
class ha_pbxt;
#ifdef DRIZZLED
class PBXTStorageEngine : public StorageEngine {
public:
PBXTStorageEngine(std::string name_arg)
: StorageEngine(name_arg, HTON_NO_FLAGS) {}
/* override */ int close_connection(Session *);
/* override */ int commit(Session *, bool);
/* override */ int rollback(Session *, bool);
/* override */ handler *create(TABLE_SHARE *, MEM_ROOT *);
/* override */ void drop_database(char *);
/* override */ bool show_status(Session *, stat_print_fn *, enum ha_stat_type);
};
typedef PBXTStorageEngine handlerton;
#endif
extern handlerton *pbxt_hton;
/*
......
......@@ -75,7 +75,7 @@ const char **ha_xtsys::bas_ext() const
return ha_pbms_exts;
}
int ha_xtsys::open(const char *table_path, int mode __attribute__((unused)), uint test_if_locked __attribute__((unused)))
int ha_xtsys::open(const char *table_path, int XT_UNUSED(mode), uint XT_UNUSED(test_if_locked))
{
THD *thd = current_thd;
XTExceptionRec e;
......@@ -141,7 +141,7 @@ int ha_xtsys::close(void)
return err;
}
int ha_xtsys::rnd_init(bool scan __attribute__((unused)))
int ha_xtsys::rnd_init(bool XT_UNUSED(scan))
{
int err = 0;
......@@ -185,7 +185,7 @@ int ha_xtsys::rnd_pos(byte * buf, byte *pos)
return err;
}
int ha_xtsys::info(uint flag __attribute__((unused)))
int ha_xtsys::info(uint XT_UNUSED(flag))
{
return 0;
}
......@@ -211,7 +211,7 @@ int ha_xtsys::external_lock(THD *thd, int lock_type)
return err;
}
THR_LOCK_DATA **ha_xtsys::store_lock(THD *thd __attribute__((unused)), THR_LOCK_DATA **to, enum thr_lock_type lock_type)
THR_LOCK_DATA **ha_xtsys::store_lock(THD *XT_UNUSED(thd), THR_LOCK_DATA **to, enum thr_lock_type lock_type)
{
if (lock_type != TL_IGNORE && ha_lock.type == TL_UNLOCK)
ha_lock.type = lock_type;
......@@ -220,13 +220,13 @@ THR_LOCK_DATA **ha_xtsys::store_lock(THD *thd __attribute__((unused)), THR_LOCK_
}
/* Note: ha_pbxt::delete_system_table is called instead. */
int ha_xtsys::delete_table(const char *table_path __attribute__((unused)))
int ha_xtsys::delete_table(const char *XT_UNUSED(table_path))
{
/* Should never be called */
return 0;
}
int ha_xtsys::create(const char *name __attribute__((unused)), TABLE *table_arg __attribute__((unused)), HA_CREATE_INFO *create_info __attribute__((unused)))
int ha_xtsys::create(const char *XT_UNUSED(name), TABLE *XT_UNUSED(table_arg), HA_CREATE_INFO *XT_UNUSED(create_info))
{
/* Allow the table to be created.
* This is required after a dump is restored.
......@@ -234,7 +234,7 @@ int ha_xtsys::create(const char *name __attribute__((unused)), TABLE *table_arg
return 0;
}
bool ha_xtsys::get_error_message(int error __attribute__((unused)), String *buf)
bool ha_xtsys::get_error_message(int XT_UNUSED(error), String *buf)
{
THD *thd = current_thd;
XTExceptionRec e;
......
......@@ -59,7 +59,7 @@ public:
const char *table_type() const { return "PBXT"; }
const char *index_type(uint inx __attribute__((unused))) {
const char *index_type(uint XT_UNUSED(inx)) {
return "NONE";
}
......@@ -69,7 +69,7 @@ public:
return HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE;
}
MX_ULONG_T index_flags(uint inx __attribute__((unused)), uint part __attribute__((unused)), bool all_parts __attribute__((unused))) const {
MX_ULONG_T index_flags(uint XT_UNUSED(inx), uint XT_UNUSED(part), bool XT_UNUSED(all_parts)) const {
return (HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | HA_KEYREAD_ONLY);
}
uint max_supported_keys() const { return 512; }
......
......@@ -115,7 +115,7 @@ xtPublic void xt_ht_put(XTThreadPtr self, XTHashTabPtr ht, void *data)
popr_();
}
xtPublic void *xt_ht_get(XTThreadPtr self __attribute__((unused)), XTHashTabPtr ht, void *key)
xtPublic void *xt_ht_get(XTThreadPtr XT_UNUSED(self), XTHashTabPtr ht, void *key)
{
XTHashItemPtr item;
xtHashValue h;
......@@ -239,14 +239,14 @@ xtPublic void xt_ht_signal(XTThreadPtr self, XTHashTabPtr ht)
xt_signal_cond(self, ht->ht_cond);
}
xtPublic void xt_ht_enum(struct XTThread *self __attribute__((unused)), XTHashTabPtr ht, XTHashEnumPtr en)
xtPublic void xt_ht_enum(struct XTThread *XT_UNUSED(self), XTHashTabPtr ht, XTHashEnumPtr en)
{
en->he_i = 0;
en->he_item = NULL;
en->he_ht = ht;
}
xtPublic void *xt_ht_next(struct XTThread *self __attribute__((unused)), XTHashEnumPtr en)
xtPublic void *xt_ht_next(struct XTThread *XT_UNUSED(self), XTHashEnumPtr en)
{
if (en->he_item) {
en->he_item = en->he_item->hi_next;
......
......@@ -31,7 +31,7 @@
#undef xt_heap_new
#endif
#ifdef DEBUG
#ifdef DEBUG_MEMORY
xtPublic XTHeapPtr xt_mm_heap_new(XTThreadPtr self, size_t size, XTFinalizeFunc finalize, u_int line, c_char *file, xtBool track)
#else
xtPublic XTHeapPtr xt_heap_new(XTThreadPtr self, size_t size, XTFinalizeFunc finalize)
......@@ -39,7 +39,7 @@ xtPublic XTHeapPtr xt_heap_new(XTThreadPtr self, size_t size, XTFinalizeFunc fin
{
volatile XTHeapPtr hp;
#ifdef DEBUG
#ifdef DEBUG_MEMORY
hp = (XTHeapPtr) xt_mm_calloc(self, size, line, file);
hp->h_track = track;
if (track)
......@@ -65,21 +65,21 @@ xtPublic XTHeapPtr xt_heap_new(XTThreadPtr self, size_t size, XTFinalizeFunc fin
return hp;
}
xtPublic void xt_check_heap(XTThreadPtr self __attribute__((unused)), XTHeapPtr hp __attribute__((unused)))
xtPublic void xt_check_heap(XTThreadPtr XT_NDEBUG_UNUSED(self), XTHeapPtr XT_NDEBUG_UNUSED(hp))
{
#ifdef DEBUG
#ifdef DEBUG_MEMORY
xt_mm_malloc_size(self, hp);
#endif
}
#ifdef DEBUG
#ifdef DEBUG_MEMORY
xtPublic void xt_mm_heap_reference(XTThreadPtr self, XTHeapPtr hp, u_int line, c_char *file)
#else
xtPublic void xt_heap_reference(XTThreadPtr, XTHeapPtr hp)
#endif
{
xt_spinlock_lock(&hp->h_lock);
#ifdef DEBUG
#ifdef DEBUG_MEMORY
if (hp->h_track)
printf("HEAP: +1 %d->%d %s:%d\n", (int) hp->h_ref_count, (int) hp->h_ref_count+1, file, (int) line);
#endif
......@@ -91,7 +91,7 @@ xtPublic void xt_heap_release(XTThreadPtr self, XTHeapPtr hp)
{
if (!hp)
return;
#ifdef DEBUG
#ifdef DEBUG_MEMORY
xt_spinlock_lock(&hp->h_lock);
ASSERT(hp->h_ref_count != 0);
xt_spinlock_unlock(&hp->h_lock);
......@@ -100,7 +100,7 @@ xtPublic void xt_heap_release(XTThreadPtr self, XTHeapPtr hp)
if (hp->h_onrelease)
(*hp->h_onrelease)(self, hp);
if (hp->h_ref_count > 0) {
#ifdef DEBUG
#ifdef DEBUG_MEMORY
if (hp->h_track)
printf("HEAP: -1 %d->%d\n", (int) hp->h_ref_count, (int) hp->h_ref_count-1);
#endif
......@@ -116,12 +116,12 @@ xtPublic void xt_heap_release(XTThreadPtr self, XTHeapPtr hp)
xt_spinlock_unlock(&hp->h_lock);
}
xtPublic void xt_heap_set_release_callback(XTThreadPtr self __attribute__((unused)), XTHeapPtr hp, XTFinalizeFunc onrelease)
xtPublic void xt_heap_set_release_callback(XTThreadPtr XT_UNUSED(self), XTHeapPtr hp, XTFinalizeFunc onrelease)
{
hp->h_onrelease = onrelease;
}
xtPublic u_int xt_heap_get_ref_count(struct XTThread *self __attribute__((unused)), XTHeapPtr hp)
xtPublic u_int xt_heap_get_ref_count(struct XTThread *XT_UNUSED(self), XTHeapPtr hp)
{
return hp->h_ref_count;
}
......
......@@ -25,6 +25,7 @@
#include "xt_defs.h"
#include "lock_xt.h"
#include "memory_xt.h"
struct XTThread;
......@@ -59,7 +60,7 @@ u_int xt_heap_get_ref_count(struct XTThread *self, XTHeapPtr mem);
void xt_check_heap(struct XTThread *self, XTHeapPtr mem);
#ifdef DEBUG
#ifdef DEBUG_MEMORY
#define xt_heap_new(t, s, f) xt_mm_heap_new(t, s, f, __LINE__, __FILE__, FALSE)
#define xt_heap_new_track(t, s, f) xt_mm_heap_new(t, s, f, __LINE__, __FILE__, TRUE)
#define xt_heap_reference(t, s) xt_mm_heap_reference(t, s, __LINE__, __FILE__)
......
This diff is collapsed.
......@@ -24,6 +24,7 @@
#define __xt_index_h__
#ifdef DRIZZLED
#include <drizzled/definitions.h>
#include <mysys/my_bitmap.h>
#else
#include <mysql_version.h>
......@@ -34,7 +35,6 @@
#include "linklist_xt.h"
#include "datalog_xt.h"
#include "datadic_xt.h"
//#include "cache_xt.h"
#ifndef MYSQL_VERSION_ID
#error MYSQL_VERSION_ID must be defined!
......@@ -109,7 +109,7 @@ class Field;
#define XT_MAX_RECORD_REF_SIZE 8
#define XT_INDEX_PAGE_DATA_SIZE XT_INDEX_PAGE_SIZE - 2 /* NOTE: 2 == offsetof(XTIdxBranchDRec, tb_data) */
#define XT_INDEX_PAGE_DATA_SIZE (XT_INDEX_PAGE_SIZE - 2) /* NOTE: 2 == offsetof(XTIdxBranchDRec, tb_data) */
#define XT_MAKE_LEAF_SIZE(x) ((x) + offsetof(XTIdxBranchDRec, tb_data))
......@@ -218,7 +218,7 @@ typedef struct XTIndFreeList {
* in 32 threads on smalltab: runTest(SMALL_INSERT_TEST, 32, dbUrl)
*/
/*
* XT_INDEX_USE_RW_MUTEX:
* XT_INDEX_USE_RWMUTEX:
* But the RW mutex is a close second, if not just as fast.
* If it is at least as fast, then it is better because read lock
* overhead is then zero.
......@@ -240,17 +240,24 @@ typedef struct XTIndFreeList {
* Latest test show that RW mutex is slightly faster:
* 127460 to 123574 payment transactions.
*/
#define XT_INDEX_USE_RW_MUTEX
#ifdef XT_NO_ATOMICS
#define XT_INDEX_USE_PTHREAD_RW
#else
//#define XT_INDEX_USE_RWMUTEX
//#define XT_INDEX_USE_PTHREAD_RW
//#define XT_INDEX_SPINXSLOCK
#define XT_TAB_ROW_USE_XSMUTEX
#endif
#ifdef XT_INDEX_USE_FASTWRLOCK
#define XT_INDEX_LOCK_TYPE XTFastRWLockRec
#define XT_INDEX_INIT_LOCK(s, i) xt_fastrwlock_init(s, &(i)->mi_rwlock)
#define XT_INDEX_FREE_LOCK(s, i) xt_fastrwlock_free(s, &(i)->mi_rwlock)
#define XT_INDEX_READ_LOCK(i, o) xt_fastrwlock_slock(&(i)->mi_rwlock, (o)->ot_thread)
#define XT_INDEX_WRITE_LOCK(i, o) xt_fastrwlock_xlock(&(i)->mi_rwlock, (o)->ot_thread)
#define XT_INDEX_UNLOCK(i, o) xt_fastrwlock_unlock(&(i)->mi_rwlock, (o)->ot_thread)
#define XT_INDEX_HAVE_XLOCK(i, o) TRUE
#ifdef XT_TAB_ROW_USE_XSMUTEX
#define XT_INDEX_LOCK_TYPE XTXSMutexRec
#define XT_INDEX_INIT_LOCK(s, i) xt_xsmutex_init_with_autoname(s, &(i)->mi_rwlock)
#define XT_INDEX_FREE_LOCK(s, i) xt_xsmutex_free(s, &(i)->mi_rwlock)
#define XT_INDEX_READ_LOCK(i, o) xt_xsmutex_slock(&(i)->mi_rwlock, (o)->ot_thread->t_id)
#define XT_INDEX_WRITE_LOCK(i, o) xt_xsmutex_xlock(&(i)->mi_rwlock, (o)->ot_thread->t_id)
#define XT_INDEX_UNLOCK(i, o) xt_xsmutex_unlock(&(i)->mi_rwlock, (o)->ot_thread->t_id)
#define XT_INDEX_HAVE_XLOCK(i, o) ((i)->sxs_xlocker == (o)->ot_thread->t_id)
#elif defined(XT_INDEX_USE_PTHREAD_RW)
#define XT_INDEX_LOCK_TYPE xt_rwlock_type
#define XT_INDEX_INIT_LOCK(s, i) xt_init_rwlock_with_autoname(s, &(i)->mi_rwlock)
......@@ -259,7 +266,15 @@ typedef struct XTIndFreeList {
#define XT_INDEX_WRITE_LOCK(i, o) xt_xlock_rwlock_ns(&(i)->mi_rwlock)
#define XT_INDEX_UNLOCK(i, o) xt_unlock_rwlock_ns(&(i)->mi_rwlock)
#define XT_INDEX_HAVE_XLOCK(i, o) TRUE
#else // XT_INDEX_USE_RW_MUTEX
#elif defined(XT_INDEX_SPINXSLOCK)
#define XT_INDEX_LOCK_TYPE XTSpinXSLockRec
#define XT_INDEX_INIT_LOCK(s, i) xt_spinxslock_init_with_autoname(s, &(i)->mi_rwlock)
#define XT_INDEX_FREE_LOCK(s, i) xt_spinxslock_free(s, &(i)->mi_rwlock)
#define XT_INDEX_READ_LOCK(i, o) xt_spinxslock_slock(&(i)->mi_rwlock, (o)->ot_thread->t_id)
#define XT_INDEX_WRITE_LOCK(i, o) xt_spinxslock_xlock(&(i)->mi_rwlock, (o)->ot_thread->t_id)
#define XT_INDEX_UNLOCK(i, o) xt_spinxslock_unlock(&(i)->mi_rwlock, (o)->ot_thread->t_id)
#define XT_INDEX_HAVE_XLOCK(i, o) ((i)->mi_rwlock.nrw_xlocker == (o)->ot_thread->t_id)
#else // XT_INDEX_USE_RWMUTEX
#define XT_INDEX_LOCK_TYPE XTRWMutexRec
#define XT_INDEX_INIT_LOCK(s, i) xt_rwmutex_init_with_autoname(s, &(i)->mi_rwlock)
#define XT_INDEX_FREE_LOCK(s, i) xt_rwmutex_free(s, &(i)->mi_rwlock)
......@@ -289,22 +304,24 @@ typedef struct XTIndex {
XTIndFreeListPtr mi_free_list; /* List of free pages for this index. */
/* Protected by the mi_dirty_lock: */
XTSpinLockRec mi_dirty_lock; /* Spin lock protecting the dirty & free lists. */
XTSpinLockRec mi_dirty_lock; /* Spin lock protecting the dirty & free lists. */
struct XTIndBlock *mi_dirty_list; /* List of dirty pages for this index. */
u_int mi_dirty_blocks; /* Count of the dirty blocks. */
/* Index contants: */
u_int mi_flags;
u_int mi_key_size;
u_int mi_max_items; /* The maximum number of items that can fit in a leaf node. */
xtBool mi_low_byte_first;
xtBool mi_fix_key;
xtBool mi_lazy_delete; /* TRUE if index entries are "lazy deleted". */
u_int mi_single_type; /* Used when the index contains a single field. */
u_int mi_select_total;
XTScanBranchFunc mi_scan_branch;
XTPrevItemFunc mi_prev_item;
XTLastItemFunc mi_last_item;
XTSimpleCompFunc mi_simple_comp_key;
MY_BITMAP mi_col_map; /* Bit-map of columns in the index. */
MX_BITMAP mi_col_map; /* Bit-map of columns in the index. */
u_int mi_subset_of; /* Indicates if this index is a complete subset of someother index. */
u_int mi_seg_count;
XTIndexSegRec mi_seg[200];
......@@ -344,6 +361,7 @@ typedef struct XTDictionary {
Field **dic_blob_cols;
/* MySQL related information. NULL when no tables are open from MySQL side! */
xtBool dic_no_lazy_delete; /* FALSE if lazy delete is OK. */
u_int dic_disable_index; /* Non-zero if the index cannot be used. */
u_int dic_index_ver; /* The version of the index. */
u_int dic_key_count;
......@@ -462,6 +480,8 @@ xtBool xt_idx_prev(register struct XTOpenTable *ot, register struct XTIndex *ind
xtBool xt_idx_read(struct XTOpenTable *ot, struct XTIndex *ind, xtWord1 *rec_buf);
void xt_ind_set_index_selectivity(XTThreadPtr self, struct XTOpenTable *ot);
void xt_check_indices(struct XTOpenTable *ot);
void xt_load_indices(XTThreadPtr self, struct XTOpenTable *ot);
void xt_ind_count_deleted_items(struct XTTable *ot, struct XTIndex *ind, struct XTIndBlock *block);
xtBool xt_flush_indices(struct XTOpenTable *ot, off_t *bytes_flushed, xtBool have_table_lock);
void xt_ind_track_dump_block(struct XTTable *tab, xtIndexNodeID address);
......@@ -482,6 +502,7 @@ void xt_prev_branch_item_var(struct XTTable *tab, XTIndexPtr ind, XTIdxBranchDPt
void xt_last_branch_item_fix(struct XTTable *tab, XTIndexPtr ind, XTIdxBranchDPtr branch, register XTIdxResultPtr result);
void xt_last_branch_item_var(struct XTTable *tab, XTIndexPtr ind, XTIdxBranchDPtr branch, register XTIdxResultPtr result);
xtBool xt_idx_lazy_delete_on_leaf(XTIndexPtr ind, struct XTIndBlock *block, xtWord2 branch_size);
//#define TRACK_ACTIVITY
#ifdef TRACK_ACTIVITY
......
This diff is collapsed.
This diff is collapsed.
......@@ -59,13 +59,13 @@ void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, xt_rwlock_struct *lock)
ptr->li_lock_type = XTThreadLockInfo::RW_LOCK;
}
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTFastRWLock *lock)
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTXSMutexLock *lock)
{
ptr->li_fast_rwlock = lock;
ptr->li_lock_type = XTThreadLockInfo::FAST_RW_LOCK;
}
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTSpinRWLock *lock)
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTSpinXSLock *lock)
{
ptr->li_spin_rwlock = lock;
ptr->li_lock_type = XTThreadLockInfo::SPIN_RW_LOCK;
......@@ -77,6 +77,12 @@ void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTAtomicRWLock *lock)
ptr->li_lock_type = XTThreadLockInfo::ATOMIC_RW_LOCK;
}
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTSkewRWLock *lock)
{
ptr->li_skew_rwlock = lock;
ptr->li_lock_type = XTThreadLockInfo::SKEW_RW_LOCK;
}
void xt_thread_lock_info_free(XTThreadLockInfoPtr ptr)
{
/* TODO: check to see if it's present in a thread's list */
......@@ -163,12 +169,12 @@ void xt_trace_thread_locks(XTThread *self)
lock_name = li->li_fast_lock->fal_name;
break;
case XTThreadLockInfo::FAST_RW_LOCK:
lock_type = "XTFastRWLock";
lock_name = li->li_fast_rwlock->frw_name;
lock_type = "XTXSMutexLock";
lock_name = li->li_fast_rwlock->xsm_name;
break;
case XTThreadLockInfo::SPIN_RW_LOCK:
lock_type = "XTSpinRWLock";
lock_name = li->li_spin_rwlock->srw_name;
lock_name = li->li_spin_rwlock->sxs_name;
break;
case XTThreadLockInfo::ATOMIC_RW_LOCK:
lock_type = "XTAtomicRWLock";
......
......@@ -25,7 +25,7 @@
#define __xt_locklist_h__
#ifdef DEBUG
//#define XT_THREAD_LOCK_INFO
#define XT_THREAD_LOCK_INFO
#ifndef XT_WIN
/* We need DEBUG_LOCKING in order to enable pthread function wrappers */
#define DEBUG_LOCKING
......@@ -40,9 +40,10 @@ struct XTRWMutex;
struct xt_mutex_struct;
struct xt_rwlock_struct;
struct XTFastLock;
struct XTFastRWLock;
struct XTSpinRWLock;
struct XTXSMutexLock;
struct XTSpinXSLock;
struct XTAtomicRWLock;
struct XTSkewRWLock;
#ifdef XT_THREAD_LOCK_INFO
......@@ -61,7 +62,7 @@ struct XTAtomicRWLock;
*/
typedef struct XTThreadLockInfo {
enum LockType { SPIN_LOCK, RW_MUTEX, MUTEX, RW_LOCK, FAST_LOCK, FAST_RW_LOCK, SPIN_RW_LOCK, ATOMIC_RW_LOCK };
enum LockType { SPIN_LOCK, RW_MUTEX, MUTEX, RW_LOCK, FAST_LOCK, FAST_RW_LOCK, SPIN_RW_LOCK, ATOMIC_RW_LOCK, SKEW_RW_LOCK };
LockType li_lock_type;
......@@ -69,11 +70,12 @@ typedef struct XTThreadLockInfo {
XTSpinLock *li_spin_lock; // SPIN_LOCK
XTRWMutex *li_rw_mutex; // RW_MUTEX
XTFastLock *li_fast_lock; // FAST_LOCK
XTFastRWLock *li_fast_rwlock; // FAST_RW_LOCK
XTSpinRWLock *li_spin_rwlock; // SPIN_RW_LOCK
XTXSMutexLock *li_fast_rwlock; // FAST_RW_LOCK
XTSpinXSLock *li_spin_rwlock; // SPIN_RW_LOCK
XTAtomicRWLock *li_atomic_rwlock; // ATOMIC_RW_LOCK
xt_mutex_struct *li_mutex; // MUTEX
xt_rwlock_struct *li_rwlock; // RW_LOCK
XTSkewRWLock *li_skew_rwlock; // SKEW_RW_LOCK
};
}
XTThreadLockInfoRec, *XTThreadLockInfoPtr;
......@@ -81,11 +83,12 @@ XTThreadLockInfoRec, *XTThreadLockInfoPtr;
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTSpinLock *lock);
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTRWMutex *lock);
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTFastLock *lock);
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTFastRWLock *lock);
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTSpinRWLock *lock);
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTXSMutexLock *lock);
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTSpinXSLock *lock);
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTAtomicRWLock *lock);
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, xt_mutex_struct *lock);
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, xt_rwlock_struct *lock);
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTSkewRWLock *lock);
void xt_thread_lock_info_free(XTThreadLockInfoPtr ptr);
void xt_thread_lock_info_add_owner (XTThreadLockInfoPtr ptr);
......
......@@ -117,7 +117,7 @@ xtPublic xtBool xt_realloc(XTThreadPtr self, void **ptr, size_t size)
return OK;
}
xtPublic void xt_free(XTThreadPtr self __attribute__((unused)), void *ptr)
xtPublic void xt_free(XTThreadPtr XT_UNUSED(self), void *ptr)
{
free(ptr);
}
......@@ -186,7 +186,7 @@ xtPublic void xt_free_ns(void *ptr)
free(ptr);
}
#ifdef DEBUG
#ifdef DEBUG_MEMORY
/*
* -----------------------------------------------------------------------
......@@ -678,7 +678,7 @@ void xt_mm_memset(void *block, void *dest, int value, size_t size)
memset(dest, value, size);
}
void *xt_mm_malloc(XTThreadPtr self, size_t size, u_int line __attribute__((unused)), c_char *file __attribute__((unused)))
void *xt_mm_malloc(XTThreadPtr self, size_t size, u_int line, c_char *file)
{
unsigned char *p;
......@@ -695,6 +695,8 @@ void *xt_mm_malloc(XTThreadPtr self, size_t size, u_int line __attribute__((unus
*(p + size + MEM_DEBUG_HDR_SIZE) = MEM_TRAILER_BYTE;
*(p + size + MEM_DEBUG_HDR_SIZE + 1L) = MEM_TRAILER_BYTE;
(void) line;
(void) file;
#ifdef RECORD_MM
xt_lock_mutex(self, &mm_mutex);
mm_add_core_ptr(self, p + MEM_DEBUG_HDR_SIZE, 0, line, file);
......@@ -704,7 +706,7 @@ void *xt_mm_malloc(XTThreadPtr self, size_t size, u_int line __attribute__((unus
return p + MEM_DEBUG_HDR_SIZE;
}
void *xt_mm_calloc(XTThreadPtr self, size_t size, u_int line __attribute__((unused)), c_char *file __attribute__((unused)))
void *xt_mm_calloc(XTThreadPtr self, size_t size, u_int line, c_char *file)
{
unsigned char *p;
......@@ -719,6 +721,8 @@ void *xt_mm_calloc(XTThreadPtr self, size_t size, u_int line __attribute__((unus
*(p + size + MEM_DEBUG_HDR_SIZE) = MEM_TRAILER_BYTE;
*(p + size + MEM_DEBUG_HDR_SIZE + 1L) = MEM_TRAILER_BYTE;
(void) line;
(void) file;
#ifdef RECORD_MM
xt_lock_mutex(self, &mm_mutex);
mm_add_core_ptr(self, p + MEM_DEBUG_HDR_SIZE, 0, line, file);
......@@ -849,7 +853,7 @@ void xt_mm_check_ptr(XTThreadPtr self, void *ptr)
xtPublic xtBool xt_init_memory(void)
{
#ifdef DEBUG
#ifdef DEBUG_MEMORY
XTThreadPtr self = NULL;
if (!xt_init_mutex_with_autoname(NULL, &mm_mutex))
......@@ -875,7 +879,7 @@ xtPublic void debug_ik_sum(void);
xtPublic void xt_exit_memory(void)
{
#ifdef DEBUG
#ifdef DEBUG_MEMORY
long mm;
int i;
......@@ -919,7 +923,7 @@ xtPublic void xt_exit_memory(void)
* MEMORY ALLOCATION UTILITIES
*/
#ifdef DEBUG
#ifdef DEBUG_MEMORY
char *xt_mm_dup_string(XTThreadPtr self, c_char *str, u_int line, c_char *file)
#else
char *xt_dup_string(XTThreadPtr self, c_char *str)
......@@ -931,7 +935,7 @@ char *xt_dup_string(XTThreadPtr self, c_char *str)
if (!str)
return NULL;
len = strlen(str);
#ifdef DEBUG
#ifdef DEBUG_MEMORY
new_str = (char *) xt_mm_malloc(self, len + 1, line, file);
#else
new_str = (char *) xt_malloc(self, len + 1);
......@@ -1020,7 +1024,7 @@ xtPublic xtBool xt_realloc(XTThreadPtr self, void **ptr, size_t size)
return *ptr != NULL;
}
xtPublic void xt_free(XTThreadPtr self __attribute__((unused)), void *ptr)
xtPublic void xt_free(XTThreadPtr XT_UNUSED(self), void *ptr)
{
char *old_ptr;
xtWord4 size;
......
......@@ -30,6 +30,10 @@
struct XTThread;
#ifdef DEBUG
#define DEBUG_MEMORY
#endif
#ifdef DEBUG_MEMORY
#define XT_MM_STACK_TRACE 200
#define XT_MM_TRACE_DEPTH 4
......@@ -109,7 +113,7 @@ void xt_free_ns(void *ptr);
#endif
#ifdef DEBUG
#ifdef DEBUG_MEMORY
#define xt_dup_string(t, s) xt_mm_dup_string(t, s, __LINE__, __FILE__)
char *xt_mm_dup_string(struct XTThread *self, const char *path, u_int line, const char *file);
......
This diff is collapsed.
......@@ -70,6 +70,7 @@ XTDDTable *myxt_create_table_from_table(XTThreadPtr self, STRUCT_TABLE *my_tab);
void myxt_static_convert_identifier(XTThreadPtr self, struct charset_info_st *cs, char *from, char *to, size_t to_len);
char *myxt_convert_identifier(XTThreadPtr self, struct charset_info_st *cs, char *from);
void myxt_static_convert_table_name(XTThreadPtr self, char *from, char *to, size_t to_len);
void myxt_static_convert_file_name(char *from, char *to, size_t to_len);
char *myxt_convert_table_name(XTThreadPtr self, char *from);
int myxt_strcasecmp(char * a, char *b);
int myxt_isspace(struct charset_info_st *cs, char a);
......@@ -78,13 +79,6 @@ int myxt_isdigit(struct charset_info_st *cs, char a);
struct charset_info_st *myxt_getcharset(bool convert);
#ifdef XT_STREAMING
xtBool myxt_use_blobs(XTOpenTablePtr ot, void **ret_pbms_table, xtWord1 *rec_buf);
void myxt_unuse_blobs(XTOpenTablePtr ot, void *pbms_table);
xtBool myxt_retain_blobs(XTOpenTablePtr ot, void *pbms_table, xtRecordID record);
void myxt_release_blobs(XTOpenTablePtr ot, xtWord1 *rec_buf, xtRecordID record);
#endif
void *myxt_create_thread();
void myxt_destroy_thread(void *thread, xtBool end_threads);
XTThreadPtr myxt_get_self();
......@@ -92,9 +86,6 @@ XTThreadPtr myxt_get_self();
int myxt_statistics_fill_table(XTThreadPtr self, void *th, void *ta, void *co, MX_CONST void *ch);
void myxt_get_status(XTThreadPtr self, XTStringBufferPtr strbuf);
void myxt_bitmap_init(XTThreadPtr self, MY_BITMAP *map, u_int n_bits);
void myxt_bitmap_free(XTThreadPtr self, MY_BITMAP *map);
class XTDDColumnFactory
{
public:
......
This diff is collapsed.
/* Copyright (c) 2009 PrimeBase Technologies GmbH, Germany
*
* PrimeBase Media Stream for MySQL
*
* 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
*
* Barry Leslie
*
* 2009-07-16
*
* H&G2JCtL
*
* PBMS interface used to enable engines for use with the PBMS engine.
*
* For an example on how to build this into an engine have a look at the PBXT engine
* in file ha_pbxt.cc. Search for 'PBMS_ENABLED'.
*
*/
#define PBMS_API pbms_enabled_api
#include "pbms_enabled.h"
#ifdef DRIZZLED
#include <sys/stat.h>
#include <drizzled/common_includes.h>
#include <drizzled/plugin.h>
#else
#include "mysql_priv.h"
#include <mysql/plugin.h>
#define session_alloc(sess, size) thd_alloc(sess, size);
#define current_session current_thd
#endif
#define GET_BLOB_FIELD(t, i) (Field_blob *)(t->field[t->s->blob_field[i]])
#define DB_NAME(f) (f->table->s->db.str)
#define TAB_NAME(f) (*(f->table_name))
static PBMS_API pbms_api;
PBMSEngineRec enabled_engine = {
MS_ENGINE_VERSION
};
//====================
bool pbms_initialize(const char *engine_name, bool isServer, PBMSResultPtr result)
{
int err;
strncpy(enabled_engine.ms_engine_name, engine_name, 32);
enabled_engine.ms_internal = isServer;
enabled_engine.ms_engine_name[31] = 0;
err = pbms_api.registerEngine(&enabled_engine, result);
return (err == 0);
}
//====================
void pbms_finalize()
{
pbms_api.deregisterEngine(&enabled_engine);
}
//====================
int pbms_write_row_blobs(TABLE *table, uchar *row_buffer, PBMSResultPtr result)
{
Field_blob *field;
char *blob_rec, *blob;
size_t packlength, i, org_length, length;
char blob_url_buffer[PBMS_BLOB_URL_SIZE];
int err;
String type_name;
if (table->s->blob_fields == 0)
return 0;
for (i= 0; i < table->s->blob_fields; i++) {
field = GET_BLOB_FIELD(table, i);
// Note: field->type() always returns MYSQL_TYPE_BLOB regardless of the type of BLOB
field->sql_type(type_name);
if (strcasecmp(type_name.c_ptr(), "LongBlob"))
continue;
// Get the blob record:
blob_rec = (char *)row_buffer + field->offset(field->table->record[0]);
packlength = field->pack_length() - field->table->s->blob_ptr_size;
memcpy(&blob, blob_rec +packlength, sizeof(char*));
org_length = field->get_length((uchar *)blob_rec);
// Signal PBMS to record a new reference to the BLOB.
// If 'blob' is not a BLOB URL then it will be stored in the repositor as a new BLOB
// and a reference to it will be created.
err = pbms_api.retainBlob(DB_NAME(field), TAB_NAME(field), blob_url_buffer, blob, org_length, field->field_index, result);
if (err)
return err;
// If the BLOB length changed reset it.
// This will happen if the BLOB data was replaced with a BLOB reference.
length = strlen(blob_url_buffer) +1;
if ((length != org_length) || memcmp(blob_url_buffer, blob, length)) {
if (length != org_length) {
field->store_length((uchar *)blob_rec, packlength, length);
}
if (length > org_length) {
// This can only happen if the BLOB URL is actually larger than the BLOB itself.
blob = (char *) session_alloc(current_session, length);
memcpy(blob_rec+packlength, &blob, sizeof(char*));
}
memcpy(blob, blob_url_buffer, length);
}
}
return 0;
}
//====================
int pbms_delete_row_blobs(TABLE *table, const uchar *row_buffer, PBMSResultPtr result)
{
Field_blob *field;
const char *blob_rec;
char *blob;
size_t packlength, i, length;
int err;
String type_name;
if (table->s->blob_fields == 0)
return 0;
for (i= 0; i < table->s->blob_fields; i++) {
field = GET_BLOB_FIELD(table, i);
// Note: field->type() always returns MYSQL_TYPE_BLOB regardless of the type of BLOB
field->sql_type(type_name);
if (strcasecmp(type_name.c_ptr(), "LongBlob"))
continue;
// Get the blob record:
blob_rec = (char *)row_buffer + field->offset(field->table->record[0]);
packlength = field->pack_length() - field->table->s->blob_ptr_size;
length = field->get_length((uchar *)blob_rec);
memcpy(&blob, blob_rec +packlength, sizeof(char*));
// Signal PBMS to delete the reference to the BLOB.
err = pbms_api.releaseBlob(DB_NAME(field), TAB_NAME(field), blob, length, result);
if (err)
return err;
}
return 0;
}
#define MAX_NAME_SIZE 64
static void parse_table_path(const char *path, char *db_name, char *tab_name)
{
const char *ptr = path + strlen(path) -1, *eptr;
int len;
*db_name = *tab_name = 0;
while ((ptr > path) && (*ptr != '/'))ptr --;
if (*ptr != '/')
return;
strncpy(tab_name, ptr+1, MAX_NAME_SIZE);
tab_name[MAX_NAME_SIZE-1] = 0;
eptr = ptr;
ptr--;
while ((ptr > path) && (*ptr != '/'))ptr --;
if (*ptr != '/')
return;
ptr++;
len = eptr - ptr;
if (len >= MAX_NAME_SIZE)
len = MAX_NAME_SIZE-1;
memcpy(db_name, ptr, len);
db_name[len] = 0;
}
//====================
int pbms_rename_table_with_blobs(const char *old_table_path, const char *new_table_path, PBMSResultPtr result)
{
char o_db_name[MAX_NAME_SIZE], n_db_name[MAX_NAME_SIZE], o_tab_name[MAX_NAME_SIZE], n_tab_name[MAX_NAME_SIZE];
parse_table_path(old_table_path, o_db_name, o_tab_name);
parse_table_path(new_table_path, n_db_name, n_tab_name);
if (strcmp(o_db_name, n_db_name)) {
result->mr_code = MS_ERR_INVALID_OPERATION;
strcpy(result->mr_message, "PBMS does not support renaming tables across databases.");
strcpy(result->mr_stack, "pbms_rename_table_with_blobs()");
return MS_ERR_INVALID_OPERATION;
}
return pbms_api.renameTable(o_db_name, o_tab_name, n_tab_name, result);
}
//====================
int pbms_delete_table_with_blobs(const char *table_path, PBMSResultPtr result)
{
char db_name[MAX_NAME_SIZE], tab_name[MAX_NAME_SIZE];
parse_table_path(table_path, db_name, tab_name);
return pbms_api.dropTable(db_name, tab_name, result);
}
//====================
void pbms_completed(TABLE *table, bool ok)
{
if ((!table) || (table->s->blob_fields != 0))
pbms_api.completed(ok) ;
return ;
}
This diff is collapsed.
......@@ -395,20 +395,31 @@ int xt_p_cond_timedwait(xt_cond_type *cond, xt_mutex_type *mt, struct timespec *
int xt_p_join(pthread_t thread, void **value)
{
switch (WaitForSingleObject(thread, INFINITE)) {
case WAIT_OBJECT_0:
case WAIT_TIMEOUT:
/* Don't do this! According to the Win docs:
* _endthread automatically closes the thread handle
* (whereas _endthreadex does not). Therefore, when using
* _beginthread and _endthread, do not explicitly close the
* thread handle by calling the Win32 CloseHandle API.
CloseHandle(thread);
*/
break;
case WAIT_FAILED:
return GetLastError();
DWORD exitcode;
while(1) {
switch (WaitForSingleObject(thread, 10000)) {
case WAIT_OBJECT_0:
return 0;
case WAIT_TIMEOUT:
/* Don't do this! According to the Win docs:
* _endthread automatically closes the thread handle
* (whereas _endthreadex does not). Therefore, when using
* _beginthread and _endthread, do not explicitly close the
* thread handle by calling the Win32 CloseHandle API.
CloseHandle(thread);
*/
/* This is done so that if the thread was not [yet] in the running
* state when this function was called we won't deadlock here.
*/
if (GetExitCodeThread(thread, &exitcode) && (exitcode == STILL_ACTIVE))
break;
return 0;
case WAIT_FAILED:
return GetLastError();
}
}
return 0;
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment