Commit 780f80be authored by aivanov@mysql.com's avatar aivanov@mysql.com

Applied innodb-5.1-ss475 snapshot.

* Fix BUG#15650: "DELETE with LEFT JOIN crashes server with innodb_locks_unsafe_for binlog"
* Fix BUG#17134: "Partitions: uncommitted changes are visible"
* Fix BUG#17992: "Partitions: InnoDB, somehow rotten table after UPDATE"
  row0ins.c: MySQL's partitioned table code does not set preduilt->sql_stat_start right
  if it does an insert in the same statement after doing a search first in the same
  partition table. We now write trx id always to the buffer, not just when flag
  sql_stat_start is on. This will waste CPU time very sightly.
* Fix BUG#18077: "InnoDB uses full explicit table locks in stored FUNCTION"
* Fix BUG#18238: "When locks exhaust the buffer pool, InnoDB does not roll back the trx"
* Fix BUG#18252" "Disk space leak in updates of InnoDB BLOB rows in 5.0 and 5.1"
* Fix BUG#18283: "When InnoDB returns error 'lock table full', MySQL can write to binlog too much"
* Fix BUG#18350: "Use consistent read in CREATE ... SELECT ... if innodb_locks_unsafe_for_binlog"
* Fix BUG#18384: "InnoDB memory leak on duplicate key errors in 5.0 if row has many columns"
* Fix BUG#18934: "InnoDB crashes when table uses column names like DB_ROW_ID"
  Refuse tables that use reserved column names.
* InnoDB's SQL parser:
  - Add support for UNSIGNED types, EXIT keyword, quoted identifiers, user-function callbacks
    for processing results of FETCH statements, bound literals, DATA_VARCHAR for bound literals.
  - Allow bound literals of type non-INTEGER to be of length 0.
  - Add make_flex.sh and update lexer/parser generation documentation.
  - Add comment clarifying the difference between 'alias' and 'indirection' fields in sym_node_t.
  - Remove never reached duplicate code in pars_set_dfield_type().
  - Rewrite pars_info datatypes and APIs, add a few helper functions.
  - Since the functions definitions in pars_info_t are accessed after pars_sql() returns
    in the query graph execution stage, we can't free pars_info_t in pars_sql(). Instead,
    make pars_sql() transfer ownership of pars_info_t to the created query graph, and
    make que_graph_free() free it if needed.
  - Allow access to system columns like DB_ROW_ID.
* Use bound literals in row_truncate_table_for_mysql, row_drop_table_for_mysql,
  row_discard_tablespace_for_mysql, and row_rename_table_for_mysql.
* Setting an isolation level of the transaction to read committed weakens the locks for
  this session similarly like the option innodb_locks_unsafe_for binlog. This patch removes
  alnost all gap locking (used in next-key locking) and makes MySQL to release the row locks
  on the rows which does not belong to result set. Additionally, nonlocking selects on
  INSERT INTO SELECT, UPDATE ... (SELECT ...), and CREATE ... SELECT ... use a nonlocking
  consistent read. If a binlog is used, then binlog format should be set to row based
  binloging to make the execution of the complex SQL statements.
* Disable the statistic variables btr_search_n_hash_fail and n_hash_succ, n_hash_fail,
  n_patt_succ, and n_searches of btr_search_t in builds without #ifdef UNIV_SEARCH_PERF_STAT.
* Make innodb.test faster. Group all consistent read test cases to a one test case and
  wait their lock timeout after all have been send to the server. Decrease amount of rows
  inserted in a certain test - this has no effect on the effectiveness of the test and
  reduces the running time by ~10 sec. Remove temporary work-arounds from innodb.result
  now that ALTER TABLE DROP FOREIGN KEY works once again.
* Make innodb_unsafe_binlog.test faster. Grout all consistent read test cases to a one
  test case amd wait their lock timeout after all have been sent to the server. Remove
  unnecessary option --loose_innodb_lock_wait_timeout.
* Print dictionary memory size in SHOW INNODB STATUS.
* Fix memory leaks in row_create_table_for_mysql() in rare corner cases.
* Remove code related to clustered tables. They were never implemented, and the
  implementation would be challenging with ROW_FORMAT=COMPACT. Remove the table types
  DICT_TABLE_CLUSTER_MEMBER and DICT_TABLE_CLUSTER and all related tests and functions.
  dict_table_t: Remove mix_id, mix_len, mix_id_len, mix_id_buf, and cluster_name.
  plan_t: Remove mixed_index.
  dict_create_sys_tables_tuple(): Set MIX_ID=0, MIX_LEN=0, CLUSTER_NAME=NULL when
  inserting into SYS_TABLES.
  dict_tree_check_search_tuple(): Enclose in #ifdef UNIV_DEBUG.
* Move calling of thr_local_free() from trx_free_for_mysql() to
  innobase_close_connection().
parent b56f5055
...@@ -1295,22 +1295,14 @@ insert into t2 (a) select b from t1; ...@@ -1295,22 +1295,14 @@ insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2; insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1; insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2; insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
select count(*) from t1; select count(*) from t1;
count(*) count(*)
29267 623
explain select * from t1 where c between 1 and 10000; explain select * from t1 where c between 1 and 2500;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL # Using where 1 SIMPLE t1 range c c 5 NULL # Using where
update t1 set c=a; update t1 set c=a;
explain select * from t1 where c between 1 and 10000; explain select * from t1 where c between 1 and 2500;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL # Using where 1 SIMPLE t1 ALL c NULL NULL NULL # Using where
drop table t1,t2; drop table t1,t2;
...@@ -1775,21 +1767,6 @@ select count(*) from t1 where x = 18446744073709551601; ...@@ -1775,21 +1767,6 @@ select count(*) from t1 where x = 18446744073709551601;
count(*) count(*)
1 1
drop table t1; drop table t1;
show status like "Innodb_buffer_pool_pages_total";
Variable_name Value
Innodb_buffer_pool_pages_total 512
show status like "Innodb_page_size";
Variable_name Value
Innodb_page_size 16384
show status like "Innodb_rows_deleted";
Variable_name Value
Innodb_rows_deleted 2070
show status like "Innodb_rows_inserted";
Variable_name Value
Innodb_rows_inserted 31727
show status like "Innodb_rows_updated";
Variable_name Value
Innodb_rows_updated 29530
show status like "Innodb_row_lock_waits"; show status like "Innodb_row_lock_waits";
Variable_name Value Variable_name Value
Innodb_row_lock_waits 0 Innodb_row_lock_waits 0
...@@ -3291,3 +3268,132 @@ where t2.a between t1.a - interval 2 day and t1.a + interval 2 day; ...@@ -3291,3 +3268,132 @@ where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
a a a a
2005-10-01 2005-10-01 2005-10-01 2005-10-01
drop table t1, t2; drop table t1, t2;
create table t1 (id int not null, f_id int not null, f int not null,
primary key(f_id, id)) engine=innodb;
create table t2 (id int not null,s_id int not null,s varchar(200),
primary key(id)) engine=innodb;
INSERT INTO t1 VALUES (8, 1, 3);
INSERT INTO t1 VALUES (1, 2, 1);
INSERT INTO t2 VALUES (1, 0, '');
INSERT INTO t2 VALUES (8, 1, '');
commit;
DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
WHERE mm.id IS NULL;
select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
where mm.id is null lock in share mode;
id f_id f
drop table t1,t2;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
commit;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
update t1 set b = 5 where b = 1;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
select * from t1 where a = 7 and b = 3 for update;
a b
7 3
commit;
commit;
drop table t1;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
commit;
set autocommit = 0;
select * from t1 lock in share mode;
a b
1 1
2 2
3 1
4 2
5 1
6 2
update t1 set b = 5 where b = 1;
set autocommit = 0;
select * from t1 where a = 2 and b = 2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
commit;
drop table t1;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values (1,2),(5,3),(4,2);
create table t2(d int not null, e int, primary key(d)) engine=innodb;
insert into t2 values (8,6),(12,1),(3,1);
commit;
set autocommit = 0;
select * from t2 for update;
d e
3 1
8 6
12 1
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
insert into t1 select * from t2;
update t1 set b = (select e from t2 where a = d);
create table t3(d int not null, e int, primary key(d)) engine=innodb
select * from t2;
commit;
commit;
drop table t1, t2, t3;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values (1,2),(5,3),(4,2);
create table t2(a int not null, b int, primary key(a)) engine=innodb;
insert into t2 values (8,6),(12,1),(3,1);
create table t3(d int not null, b int, primary key(d)) engine=innodb;
insert into t3 values (8,6),(12,1),(3,1);
create table t5(a int not null, b int, primary key(a)) engine=innodb;
insert into t5 values (1,2),(5,3),(4,2);
create table t6(d int not null, e int, primary key(d)) engine=innodb;
insert into t6 values (8,6),(12,1),(3,1);
create table t8(a int not null, b int, primary key(a)) engine=innodb;
insert into t8 values (1,2),(5,3),(4,2);
create table t9(d int not null, e int, primary key(d)) engine=innodb;
insert into t9 values (8,6),(12,1),(3,1);
commit;
set autocommit = 0;
select * from t2 for update;
a b
3 1
8 6
12 1
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
insert into t1 select * from t2;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
update t3 set b = (select b from t2 where a = d);
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
insert into t5 (select * from t2 lock in share mode);
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
update t6 set e = (select b from t2 where a = d lock in share mode);
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
insert into t8 (select * from t2 for update);
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
update t9 set e = (select b from t2 where a = d for update);
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
drop table t1, t2, t3, t5, t6, t8, t9;
CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
ERROR HY000: Can't create table 'test.t1' (errno: -1)
...@@ -15,7 +15,7 @@ where mm.id is null lock in share mode; ...@@ -15,7 +15,7 @@ where mm.id is null lock in share mode;
id f_id f id f_id f
drop table t1,t2; drop table t1,t2;
create table t1(a int not null, b int, primary key(a)) engine=innodb; create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2); insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
commit; commit;
set autocommit = 0; set autocommit = 0;
select * from t1 lock in share mode; select * from t1 lock in share mode;
...@@ -26,6 +26,7 @@ a b ...@@ -26,6 +26,7 @@ a b
4 2 4 2
5 1 5 1
6 2 6 2
7 3
update t1 set b = 5 where b = 1; update t1 set b = 5 where b = 1;
set autocommit = 0; set autocommit = 0;
select * from t1 where a = 2 and b = 2 for update; select * from t1 where a = 2 and b = 2 for update;
...@@ -33,3 +34,87 @@ ERROR HY000: Lock wait timeout exceeded; try restarting transaction ...@@ -33,3 +34,87 @@ ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit; commit;
commit; commit;
drop table t1; drop table t1;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
commit;
set autocommit = 0;
update t1 set b = 5 where b = 1;
set autocommit = 0;
select * from t1 where a = 7 and b = 3 for update;
a b
7 3
commit;
commit;
drop table t1;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values (1,2),(5,3),(4,2);
create table t2(d int not null, e int, primary key(d)) engine=innodb;
insert into t2 values (8,6),(12,1),(3,1);
commit;
set autocommit = 0;
select * from t2 for update;
d e
3 1
8 6
12 1
set autocommit = 0;
insert into t1 select * from t2;
update t1 set b = (select e from t2 where a = d);
create table t3(d int not null, e int, primary key(d)) engine=innodb
select * from t2;
commit;
commit;
drop table t1, t2, t3;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values (1,2),(5,3),(4,2);
create table t2(a int not null, b int, primary key(a)) engine=innodb;
insert into t2 values (8,6),(12,1),(3,1);
create table t3(d int not null, b int, primary key(d)) engine=innodb;
insert into t3 values (8,6),(12,1),(3,1);
create table t5(a int not null, b int, primary key(a)) engine=innodb;
insert into t5 values (1,2),(5,3),(4,2);
create table t6(d int not null, e int, primary key(d)) engine=innodb;
insert into t6 values (8,6),(12,1),(3,1);
create table t8(a int not null, b int, primary key(a)) engine=innodb;
insert into t8 values (1,2),(5,3),(4,2);
create table t9(d int not null, e int, primary key(d)) engine=innodb;
insert into t9 values (8,6),(12,1),(3,1);
commit;
set autocommit = 0;
select * from t2 for update;
a b
3 1
8 6
12 1
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
insert into t1 select * from t2;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
update t3 set b = (select b from t2 where a = d);
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
set autocommit = 0;
insert into t5 (select * from t2 lock in share mode);
set autocommit = 0;
update t6 set e = (select b from t2 where a = d lock in share mode);
set autocommit = 0;
create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
set autocommit = 0;
insert into t8 (select * from t2 for update);
set autocommit = 0;
update t9 set e = (select b from t2 where a = d for update);
set autocommit = 0;
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
drop table t1, t2, t3, t5, t6, t8, t9;
--binlog_cache_size=32768 --binlog_cache_size=32768 --innodb_lock_wait_timeout=1
...@@ -891,20 +891,12 @@ insert into t2 (a) select b from t1; ...@@ -891,20 +891,12 @@ insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2; insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1; insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2; insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
select count(*) from t1; select count(*) from t1;
--replace_column 9 # --replace_column 9 #
explain select * from t1 where c between 1 and 10000; explain select * from t1 where c between 1 and 2500;
update t1 set c=a; update t1 set c=a;
--replace_column 9 # --replace_column 9 #
explain select * from t1 where c between 1 and 10000; explain select * from t1 where c between 1 and 2500;
drop table t1,t2; drop table t1,t2;
# #
...@@ -1290,15 +1282,6 @@ select * from t1 where x > -16; ...@@ -1290,15 +1282,6 @@ select * from t1 where x > -16;
select count(*) from t1 where x = 18446744073709551601; select count(*) from t1 where x = 18446744073709551601;
drop table t1; drop table t1;
# Test for testable InnoDB status variables. This test
# uses previous ones(pages_created, rows_deleted, ...).
show status like "Innodb_buffer_pool_pages_total";
show status like "Innodb_page_size";
show status like "Innodb_rows_deleted";
show status like "Innodb_rows_inserted";
show status like "Innodb_rows_updated";
# Test for row locks InnoDB status variables. # Test for row locks InnoDB status variables.
show status like "Innodb_row_lock_waits"; show status like "Innodb_row_lock_waits";
show status like "Innodb_row_lock_current_waits"; show status like "Innodb_row_lock_current_waits";
...@@ -2182,7 +2165,6 @@ show create table t1; ...@@ -2182,7 +2165,6 @@ show create table t1;
# #
drop table t1, t2; drop table t1, t2;
# #
# Bug #14360: problem with intervals # Bug #14360: problem with intervals
# #
...@@ -2194,3 +2176,257 @@ insert into t2 values('2005-10-01'); ...@@ -2194,3 +2176,257 @@ insert into t2 values('2005-10-01');
select * from t1, t2 select * from t1, t2
where t2.a between t1.a - interval 2 day and t1.a + interval 2 day; where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
drop table t1, t2; drop table t1, t2;
create table t1 (id int not null, f_id int not null, f int not null,
primary key(f_id, id)) engine=innodb;
create table t2 (id int not null,s_id int not null,s varchar(200),
primary key(id)) engine=innodb;
INSERT INTO t1 VALUES (8, 1, 3);
INSERT INTO t1 VALUES (1, 2, 1);
INSERT INTO t2 VALUES (1, 0, '');
INSERT INTO t2 VALUES (8, 1, '');
commit;
DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
WHERE mm.id IS NULL;
select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
where mm.id is null lock in share mode;
drop table t1,t2;
#
# Test case where X-locks on unused rows should be released in a
# update (because READ COMMITTED isolation level)
#
connect (a,localhost,root,,);
connect (b,localhost,root,,);
connection a;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
commit;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
update t1 set b = 5 where b = 1;
connection b;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
#
# X-lock to record (7,3) should be released in a update
#
select * from t1 where a = 7 and b = 3 for update;
connection a;
commit;
connection b;
commit;
drop table t1;
connection default;
disconnect a;
disconnect b;
#
# Test case where no locks should be released (because we are not
# using READ COMMITTED isolation level)
#
connect (a,localhost,root,,);
connect (b,localhost,root,,);
connection a;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
commit;
set autocommit = 0;
select * from t1 lock in share mode;
update t1 set b = 5 where b = 1;
connection b;
set autocommit = 0;
#
# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update
#
--error 1205
select * from t1 where a = 2 and b = 2 for update;
#
# X-lock to record (1,1),(3,1),(5,1) should not be released in a update
#
--error 1205
connection a;
commit;
connection b;
commit;
connection default;
disconnect a;
disconnect b;
drop table t1;
#
# Consistent read should be used in following selects
#
# 1) INSERT INTO ... SELECT
# 2) UPDATE ... = ( SELECT ...)
# 3) CREATE ... SELECT
connect (a,localhost,root,,);
connect (b,localhost,root,,);
connection a;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values (1,2),(5,3),(4,2);
create table t2(d int not null, e int, primary key(d)) engine=innodb;
insert into t2 values (8,6),(12,1),(3,1);
commit;
set autocommit = 0;
select * from t2 for update;
connection b;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
insert into t1 select * from t2;
update t1 set b = (select e from t2 where a = d);
create table t3(d int not null, e int, primary key(d)) engine=innodb
select * from t2;
commit;
connection a;
commit;
connection default;
disconnect a;
disconnect b;
drop table t1, t2, t3;
#
# Consistent read should not be used if
#
# (a) isolation level is serializable OR
# (b) select ... lock in share mode OR
# (c) select ... for update
#
# in following queries:
#
# 1) INSERT INTO ... SELECT
# 2) UPDATE ... = ( SELECT ...)
# 3) CREATE ... SELECT
connect (a,localhost,root,,);
connect (b,localhost,root,,);
connect (c,localhost,root,,);
connect (d,localhost,root,,);
connect (e,localhost,root,,);
connect (f,localhost,root,,);
connect (g,localhost,root,,);
connect (h,localhost,root,,);
connect (i,localhost,root,,);
connect (j,localhost,root,,);
connection a;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values (1,2),(5,3),(4,2);
create table t2(a int not null, b int, primary key(a)) engine=innodb;
insert into t2 values (8,6),(12,1),(3,1);
create table t3(d int not null, b int, primary key(d)) engine=innodb;
insert into t3 values (8,6),(12,1),(3,1);
create table t5(a int not null, b int, primary key(a)) engine=innodb;
insert into t5 values (1,2),(5,3),(4,2);
create table t6(d int not null, e int, primary key(d)) engine=innodb;
insert into t6 values (8,6),(12,1),(3,1);
create table t8(a int not null, b int, primary key(a)) engine=innodb;
insert into t8 values (1,2),(5,3),(4,2);
create table t9(d int not null, e int, primary key(d)) engine=innodb;
insert into t9 values (8,6),(12,1),(3,1);
commit;
set autocommit = 0;
select * from t2 for update;
connection b;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
--send
insert into t1 select * from t2;
connection c;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
--send
update t3 set b = (select b from t2 where a = d);
connection d;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
--send
create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
connection e;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
--send
insert into t5 (select * from t2 lock in share mode);
connection f;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
--send
update t6 set e = (select b from t2 where a = d lock in share mode);
connection g;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
--send
create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
connection h;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
--send
insert into t8 (select * from t2 for update);
connection i;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
--send
update t9 set e = (select b from t2 where a = d for update);
connection j;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
--send
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
connection b;
--error 1205
reap;
connection c;
--error 1205
reap;
connection d;
--error 1205
reap;
connection e;
--error 1205
reap;
connection f;
--error 1205
reap;
connection g;
--error 1205
reap;
connection h;
--error 1205
reap;
connection i;
--error 1205
reap;
connection j;
--error 1205
reap;
connection a;
commit;
connection default;
disconnect a;
disconnect b;
disconnect c;
disconnect d;
disconnect e;
disconnect f;
disconnect g;
disconnect h;
disconnect i;
disconnect j;
drop table t1, t2, t3, t5, t6, t8, t9;
# bug 18934, "InnoDB crashes when table uses column names like DB_ROW_ID"
--error 1005
CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
--innodb_locks_unsafe_for_binlog=true --innodb_locks_unsafe_for_binlog=true --innodb_lock_wait_timeout=1
-- source include/have_innodb.inc -- source include/have_innodb.inc
# #
# Note that these tests uses a innodb_locks_unsafe_for_binlog option. # Note that these tests uses options
# # innodb_locks_unsafe_for_binlog = true
# innodb_lock_timeout = 5
# #
# Test cases for a bug #15650 # Test cases for a bug #15650
# #
...@@ -33,7 +35,7 @@ connect (a,localhost,root,,); ...@@ -33,7 +35,7 @@ connect (a,localhost,root,,);
connect (b,localhost,root,,); connect (b,localhost,root,,);
connection a; connection a;
create table t1(a int not null, b int, primary key(a)) engine=innodb; create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2); insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
commit; commit;
set autocommit = 0; set autocommit = 0;
select * from t1 lock in share mode; select * from t1 lock in share mode;
...@@ -50,6 +52,197 @@ commit; ...@@ -50,6 +52,197 @@ commit;
connection b; connection b;
commit; commit;
drop table t1; drop table t1;
connection default;
disconnect a;
disconnect b;
#
# unlock row test
#
connect (a,localhost,root,,);
connect (b,localhost,root,,);
connection a;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
commit;
set autocommit = 0;
update t1 set b = 5 where b = 1;
connection b;
set autocommit = 0;
#
# X-lock to record (7,3) should be released in a update
#
select * from t1 where a = 7 and b = 3 for update;
commit;
connection a;
commit;
drop table t1;
connection default;
disconnect a;
disconnect b;
#
# Consistent read should be used in following selects
#
# 1) INSERT INTO ... SELECT
# 2) UPDATE ... = ( SELECT ...)
# 3) CREATE ... SELECT
connect (a,localhost,root,,);
connect (b,localhost,root,,);
connection a;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values (1,2),(5,3),(4,2);
create table t2(d int not null, e int, primary key(d)) engine=innodb;
insert into t2 values (8,6),(12,1),(3,1);
commit;
set autocommit = 0;
select * from t2 for update;
connection b;
set autocommit = 0;
insert into t1 select * from t2;
update t1 set b = (select e from t2 where a = d);
create table t3(d int not null, e int, primary key(d)) engine=innodb
select * from t2;
commit;
connection a;
commit;
connection default;
disconnect a; disconnect a;
disconnect b; disconnect b;
drop table t1, t2, t3;
#
# Consistent read should not be used if
#
# (a) isolation level is serializable OR
# (b) select ... lock in share mode OR
# (c) select ... for update
#
# in following queries:
#
# 1) INSERT INTO ... SELECT
# 2) UPDATE ... = ( SELECT ...)
# 3) CREATE ... SELECT
connect (a,localhost,root,,);
connect (b,localhost,root,,);
connect (c,localhost,root,,);
connect (d,localhost,root,,);
connect (e,localhost,root,,);
connect (f,localhost,root,,);
connect (g,localhost,root,,);
connect (h,localhost,root,,);
connect (i,localhost,root,,);
connect (j,localhost,root,,);
connection a;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
insert into t1 values (1,2),(5,3),(4,2);
create table t2(a int not null, b int, primary key(a)) engine=innodb;
insert into t2 values (8,6),(12,1),(3,1);
create table t3(d int not null, b int, primary key(d)) engine=innodb;
insert into t3 values (8,6),(12,1),(3,1);
create table t5(a int not null, b int, primary key(a)) engine=innodb;
insert into t5 values (1,2),(5,3),(4,2);
create table t6(d int not null, e int, primary key(d)) engine=innodb;
insert into t6 values (8,6),(12,1),(3,1);
create table t8(a int not null, b int, primary key(a)) engine=innodb;
insert into t8 values (1,2),(5,3),(4,2);
create table t9(d int not null, e int, primary key(d)) engine=innodb;
insert into t9 values (8,6),(12,1),(3,1);
commit;
set autocommit = 0;
select * from t2 for update;
connection b;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
--send
insert into t1 select * from t2;
connection c;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
--send
update t3 set b = (select b from t2 where a = d);
connection d;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
--send
create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
connection e;
set autocommit = 0;
--send
insert into t5 (select * from t2 lock in share mode);
connection f;
set autocommit = 0;
--send
update t6 set e = (select b from t2 where a = d lock in share mode);
connection g;
set autocommit = 0;
--send
create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
connection h;
set autocommit = 0;
--send
insert into t8 (select * from t2 for update);
connection i;
set autocommit = 0;
--send
update t9 set e = (select b from t2 where a = d for update);
connection j;
set autocommit = 0;
--send
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
connection b;
--error 1205
reap;
connection c;
--error 1205
reap;
connection d;
--error 1205
reap;
connection e;
--error 1205
reap;
connection f;
--error 1205
reap;
connection g;
--error 1205
reap;
connection h;
--error 1205
reap;
connection i;
--error 1205
reap;
connection j;
--error 1205
reap;
connection a;
commit;
connection default;
disconnect a;
disconnect b;
disconnect c;
disconnect d;
disconnect e;
disconnect f;
disconnect g;
disconnect h;
disconnect i;
disconnect j;
drop table t1, t2, t3, t5, t6, t8, t9;
...@@ -132,6 +132,7 @@ extern "C" { ...@@ -132,6 +132,7 @@ extern "C" {
#include "../storage/innobase/include/sync0sync.h" #include "../storage/innobase/include/sync0sync.h"
#include "../storage/innobase/include/fil0fil.h" #include "../storage/innobase/include/fil0fil.h"
#include "../storage/innobase/include/trx0xa.h" #include "../storage/innobase/include/trx0xa.h"
#include "../storage/innobase/include/thr0loc.h"
} }
#define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */ #define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */
...@@ -1014,7 +1015,6 @@ innobase_query_caching_of_table_permitted( ...@@ -1014,7 +1015,6 @@ innobase_query_caching_of_table_permitted(
mutex_enter_noninline(&kernel_mutex); mutex_enter_noninline(&kernel_mutex);
trx_print(stderr, trx, 1024); trx_print(stderr, trx, 1024);
mutex_exit_noninline(&kernel_mutex); mutex_exit_noninline(&kernel_mutex);
ut_error;
} }
innobase_release_stat_resources(trx); innobase_release_stat_resources(trx);
...@@ -1970,7 +1970,6 @@ try_again: ...@@ -1970,7 +1970,6 @@ try_again:
return(0); return(0);
} }
/********************************************************************* /*********************************************************************
Rolls back a transaction or the latest SQL statement. */ Rolls back a transaction or the latest SQL statement. */
...@@ -2196,6 +2195,7 @@ innobase_close_connection( ...@@ -2196,6 +2195,7 @@ innobase_close_connection(
innobase_rollback_trx(trx); innobase_rollback_trx(trx);
thr_local_free(trx->mysql_thread_id);
trx_free_for_mysql(trx); trx_free_for_mysql(trx);
return(0); return(0);
...@@ -2216,7 +2216,7 @@ ha_innobase::get_row_type() const ...@@ -2216,7 +2216,7 @@ ha_innobase::get_row_type() const
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
if (prebuilt && prebuilt->table) { if (prebuilt && prebuilt->table) {
if (innodb_dict_table_is_comp(prebuilt->table)) { if (dict_table_is_comp_noninline(prebuilt->table)) {
return(ROW_TYPE_COMPACT); return(ROW_TYPE_COMPACT);
} else { } else {
return(ROW_TYPE_REDUNDANT); return(ROW_TYPE_REDUNDANT);
...@@ -3609,7 +3609,8 @@ calc_row_difference( ...@@ -3609,7 +3609,8 @@ calc_row_difference(
TRUE, TRUE,
new_mysql_row_col, new_mysql_row_col,
col_pack_len, col_pack_len,
innodb_dict_table_is_comp(prebuilt->table)); dict_table_is_comp_noninline(
prebuilt->table));
ufield->new_val.data = dfield.data; ufield->new_val.data = dfield.data;
ufield->new_val.len = dfield.len; ufield->new_val.len = dfield.len;
} else { } else {
...@@ -3769,9 +3770,17 @@ ha_innobase::unlock_row(void) ...@@ -3769,9 +3770,17 @@ ha_innobase::unlock_row(void)
ut_error; ut_error;
} }
/* Consistent read does not take any locks, thus there is
nothing to unlock. */
if (prebuilt->select_lock_type == LOCK_NONE) {
DBUG_VOID_RETURN;
}
switch (prebuilt->row_read_type) { switch (prebuilt->row_read_type) {
case ROW_READ_WITH_LOCKS: case ROW_READ_WITH_LOCKS:
if (!srv_locks_unsafe_for_binlog) { if (!srv_locks_unsafe_for_binlog
|| prebuilt->trx->isolation_level == TRX_ISO_READ_COMMITTED) {
break; break;
} }
/* fall through */ /* fall through */
...@@ -3803,7 +3812,13 @@ ha_innobase::try_semi_consistent_read(bool yes) ...@@ -3803,7 +3812,13 @@ ha_innobase::try_semi_consistent_read(bool yes)
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
if (yes && srv_locks_unsafe_for_binlog) { /* Row read type is set to semi consistent read if this was
requested by the MySQL and either innodb_locks_unsafe_for_binlog
option is used or this session is using READ COMMITTED isolation
level. */
if (yes && (srv_locks_unsafe_for_binlog
|| prebuilt->trx->isolation_level == TRX_ISO_READ_COMMITTED)) {
prebuilt->row_read_type = ROW_READ_TRY_SEMI_CONSISTENT; prebuilt->row_read_type = ROW_READ_TRY_SEMI_CONSISTENT;
} else { } else {
prebuilt->row_read_type = ROW_READ_WITH_LOCKS; prebuilt->row_read_type = ROW_READ_WITH_LOCKS;
...@@ -6286,12 +6301,6 @@ ha_innobase::external_lock( ...@@ -6286,12 +6301,6 @@ ha_innobase::external_lock(
trx->n_mysql_tables_in_use++; trx->n_mysql_tables_in_use++;
prebuilt->mysql_has_locked = TRUE; prebuilt->mysql_has_locked = TRUE;
if (trx->n_mysql_tables_in_use == 1) {
trx->isolation_level = innobase_map_isolation_level(
(enum_tx_isolation)
thd->variables.tx_isolation);
}
if (trx->isolation_level == TRX_ISO_SERIALIZABLE if (trx->isolation_level == TRX_ISO_SERIALIZABLE
&& prebuilt->select_lock_type == LOCK_NONE && prebuilt->select_lock_type == LOCK_NONE
&& (thd->options && (thd->options
...@@ -6765,11 +6774,22 @@ ha_innobase::store_lock( ...@@ -6765,11 +6774,22 @@ ha_innobase::store_lock(
TL_IGNORE */ TL_IGNORE */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx = prebuilt->trx;
/* NOTE: MySQL can call this function with lock 'type' TL_IGNORE! /* NOTE: MySQL can call this function with lock 'type' TL_IGNORE!
Be careful to ignore TL_IGNORE if we are going to do something with Be careful to ignore TL_IGNORE if we are going to do something with
only 'real' locks! */ only 'real' locks! */
/* If no MySQL tables is use we need to set isolation level
of the transaction. */
if (lock_type != TL_IGNORE
&& trx->n_mysql_tables_in_use == 0) {
trx->isolation_level = innobase_map_isolation_level(
(enum_tx_isolation)
thd->variables.tx_isolation);
}
if ((lock_type == TL_READ && thd->in_lock_tables) || if ((lock_type == TL_READ && thd->in_lock_tables) ||
(lock_type == TL_READ_HIGH_PRIORITY && thd->in_lock_tables) || (lock_type == TL_READ_HIGH_PRIORITY && thd->in_lock_tables) ||
lock_type == TL_READ_WITH_SHARED_LOCKS || lock_type == TL_READ_WITH_SHARED_LOCKS ||
...@@ -6794,18 +6814,26 @@ ha_innobase::store_lock( ...@@ -6794,18 +6814,26 @@ ha_innobase::store_lock(
unexpected if an obsolete consistent read view would be unexpected if an obsolete consistent read view would be
used. */ used. */
if (srv_locks_unsafe_for_binlog && ulint isolation_level;
prebuilt->trx->isolation_level != TRX_ISO_SERIALIZABLE &&
(lock_type == TL_READ || lock_type == TL_READ_NO_INSERT) && isolation_level = trx->isolation_level;
(thd->lex->sql_command == SQLCOM_INSERT_SELECT ||
thd->lex->sql_command == SQLCOM_UPDATE)) { if ((srv_locks_unsafe_for_binlog
|| isolation_level == TRX_ISO_READ_COMMITTED)
&& isolation_level != TRX_ISO_SERIALIZABLE
&& (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT)
&& (thd->lex->sql_command == SQLCOM_INSERT_SELECT
|| thd->lex->sql_command == SQLCOM_UPDATE
|| thd->lex->sql_command == SQLCOM_CREATE_TABLE)) {
/* In case we have innobase_locks_unsafe_for_binlog /* If we either have innobase_locks_unsafe_for_binlog
option set and isolation level of the transaction option set or this session is using READ COMMITTED
isolation level and isolation level of the transaction
is not set to serializable and MySQL is doing is not set to serializable and MySQL is doing
INSERT INTO...SELECT or UPDATE ... = (SELECT ...) INSERT INTO...SELECT or UPDATE ... = (SELECT ...) or
without FOR UPDATE or IN SHARE MODE in select, then CREATE ... SELECT... without FOR UPDATE or
we use consistent read for select. */ IN SHARE MODE in select, then we use consistent
read for select. */
prebuilt->select_lock_type = LOCK_NONE; prebuilt->select_lock_type = LOCK_NONE;
prebuilt->stored_select_lock_type = LOCK_NONE; prebuilt->stored_select_lock_type = LOCK_NONE;
...@@ -6859,8 +6887,9 @@ ha_innobase::store_lock( ...@@ -6859,8 +6887,9 @@ ha_innobase::store_lock(
< TL_WRITE_CONCURRENT_INSERT. < TL_WRITE_CONCURRENT_INSERT.
We especially allow multiple writers if MySQL is at the We especially allow multiple writers if MySQL is at the
start of a stored procedure call (SQLCOM_CALL) start of a stored procedure call (SQLCOM_CALL) or a
(MySQL does have thd->in_lock_tables TRUE there). */ stored function call (MySQL does have thd->in_lock_tables
TRUE there). */
if ((lock_type >= TL_WRITE_CONCURRENT_INSERT if ((lock_type >= TL_WRITE_CONCURRENT_INSERT
&& lock_type <= TL_WRITE) && lock_type <= TL_WRITE)
......
...@@ -76,8 +76,7 @@ EXTRA_DIST = include/btr0btr.h include/btr0btr.ic include/btr0cur.h include/btr ...@@ -76,8 +76,7 @@ EXTRA_DIST = include/btr0btr.h include/btr0btr.ic include/btr0cur.h include/btr
include/univ.i include/usr0sess.h include/usr0sess.ic include/usr0types.h \ include/univ.i include/usr0sess.h include/usr0sess.ic include/usr0types.h \
include/ut0byte.h include/ut0byte.ic include/ut0dbg.h include/ut0lst.h \ include/ut0byte.h include/ut0byte.ic include/ut0dbg.h include/ut0lst.h \
include/ut0mem.h include/ut0mem.ic include/ut0rnd.h include/ut0rnd.ic \ include/ut0mem.h include/ut0mem.ic include/ut0rnd.h include/ut0rnd.ic \
include/ut0sort.h include/ut0ut.h include/ut0ut.ic \ include/ut0sort.h include/ut0ut.h include/ut0ut.ic include/ut0vec.h include/ut0vec.ic
cmakelists.txt
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
%::SCCS/s.% %::SCCS/s.%
...@@ -144,7 +144,7 @@ btr_root_get( ...@@ -144,7 +144,7 @@ btr_root_get(
root = btr_page_get(space, root_page_no, RW_X_LATCH, mtr); root = btr_page_get(space, root_page_no, RW_X_LATCH, mtr);
ut_a((ibool)!!page_is_comp(root) == ut_a((ibool)!!page_is_comp(root) ==
dict_table_is_comp(UT_LIST_GET_FIRST(tree->tree_indexes)->table)); dict_table_is_comp(tree->tree_index->table));
return(root); return(root);
} }
...@@ -259,7 +259,7 @@ btr_page_create( ...@@ -259,7 +259,7 @@ btr_page_create(
ut_ad(mtr_memo_contains(mtr, buf_block_align(page), ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
page_create(page, mtr, page_create(page, mtr,
dict_table_is_comp(UT_LIST_GET_FIRST(tree->tree_indexes)->table)); dict_table_is_comp(tree->tree_index->table));
buf_block_align(page)->check_index_page_at_flush = TRUE; buf_block_align(page)->check_index_page_at_flush = TRUE;
btr_page_set_index_id(page, tree->id, mtr); btr_page_set_index_id(page, tree->id, mtr);
...@@ -574,7 +574,7 @@ btr_page_get_father_for_rec( ...@@ -574,7 +574,7 @@ btr_page_get_father_for_rec(
tuple = dict_tree_build_node_ptr(tree, user_rec, 0, heap, tuple = dict_tree_build_node_ptr(tree, user_rec, 0, heap,
btr_page_get_level(page, mtr)); btr_page_get_level(page, mtr));
index = UT_LIST_GET_FIRST(tree->tree_indexes); index = tree->tree_index;
/* In the following, we choose just any index from the tree as the /* In the following, we choose just any index from the tree as the
first parameter for btr_cur_search_to_nth_level. */ first parameter for btr_cur_search_to_nth_level. */
...@@ -1073,8 +1073,7 @@ btr_root_raise_and_insert( ...@@ -1073,8 +1073,7 @@ btr_root_raise_and_insert(
/* fprintf(stderr, "Root raise new page no %lu\n", /* fprintf(stderr, "Root raise new page no %lu\n",
buf_frame_get_page_no(new_page)); */ buf_frame_get_page_no(new_page)); */
ibuf_reset_free_bits(UT_LIST_GET_FIRST(tree->tree_indexes), ibuf_reset_free_bits(tree->tree_index, new_page);
new_page);
/* Reposition the cursor to the child node */ /* Reposition the cursor to the child node */
page_cur_search(new_page, cursor->index, tuple, page_cur_search(new_page, cursor->index, tuple,
PAGE_CUR_LE, page_cursor); PAGE_CUR_LE, page_cursor);
...@@ -1415,7 +1414,7 @@ btr_insert_on_non_leaf_level( ...@@ -1415,7 +1414,7 @@ btr_insert_on_non_leaf_level(
/* In the following, choose just any index from the tree as the /* In the following, choose just any index from the tree as the
first parameter for btr_cur_search_to_nth_level. */ first parameter for btr_cur_search_to_nth_level. */
btr_cur_search_to_nth_level(UT_LIST_GET_FIRST(tree->tree_indexes), btr_cur_search_to_nth_level(tree->tree_index,
level, tuple, PAGE_CUR_LE, BTR_CONT_MODIFY_TREE, level, tuple, PAGE_CUR_LE, BTR_CONT_MODIFY_TREE,
&cursor, 0, mtr); &cursor, 0, mtr);
...@@ -1479,7 +1478,7 @@ btr_attach_half_pages( ...@@ -1479,7 +1478,7 @@ btr_attach_half_pages(
btr_node_ptr_set_child_page_no(node_ptr, btr_node_ptr_set_child_page_no(node_ptr,
rec_get_offsets(node_ptr, rec_get_offsets(node_ptr,
UT_LIST_GET_FIRST(tree->tree_indexes), tree->tree_index,
NULL, ULINT_UNDEFINED, &heap), NULL, ULINT_UNDEFINED, &heap),
lower_page_no, mtr); lower_page_no, mtr);
mem_heap_empty(heap); mem_heap_empty(heap);
...@@ -1768,8 +1767,8 @@ func_start: ...@@ -1768,8 +1767,8 @@ func_start:
buf_frame_get_page_no(left_page), buf_frame_get_page_no(left_page),
buf_frame_get_page_no(right_page)); */ buf_frame_get_page_no(right_page)); */
ut_ad(page_validate(left_page, UT_LIST_GET_FIRST(tree->tree_indexes))); ut_ad(page_validate(left_page, tree->tree_index));
ut_ad(page_validate(right_page, UT_LIST_GET_FIRST(tree->tree_indexes))); ut_ad(page_validate(right_page, tree->tree_index));
mem_heap_free(heap); mem_heap_free(heap);
return(rec); return(rec);
...@@ -1910,8 +1909,7 @@ btr_node_ptr_delete( ...@@ -1910,8 +1909,7 @@ btr_node_ptr_delete(
node_ptr = btr_page_get_father_node_ptr(tree, page, mtr); node_ptr = btr_page_get_father_node_ptr(tree, page, mtr);
btr_cur_position(UT_LIST_GET_FIRST(tree->tree_indexes), node_ptr, btr_cur_position(tree->tree_index, node_ptr, &cursor);
&cursor);
compressed = btr_cur_pessimistic_delete(&err, TRUE, &cursor, FALSE, compressed = btr_cur_pessimistic_delete(&err, TRUE, &cursor, FALSE,
mtr); mtr);
ut_a(err == DB_SUCCESS); ut_a(err == DB_SUCCESS);
...@@ -1947,7 +1945,7 @@ btr_lift_page_up( ...@@ -1947,7 +1945,7 @@ btr_lift_page_up(
btr_page_get_father_node_ptr(tree, page, mtr)); btr_page_get_father_node_ptr(tree, page, mtr));
page_level = btr_page_get_level(page, mtr); page_level = btr_page_get_level(page, mtr);
index = UT_LIST_GET_FIRST(tree->tree_indexes); index = tree->tree_index;
btr_search_drop_page_hash_index(page); btr_search_drop_page_hash_index(page);
...@@ -2180,8 +2178,7 @@ btr_discard_only_page_on_level( ...@@ -2180,8 +2178,7 @@ btr_discard_only_page_on_level(
btr_page_empty(father_page, mtr); btr_page_empty(father_page, mtr);
/* We play safe and reset the free bits for the father */ /* We play safe and reset the free bits for the father */
ibuf_reset_free_bits(UT_LIST_GET_FIRST(tree->tree_indexes), ibuf_reset_free_bits(tree->tree_index, father_page);
father_page);
} else { } else {
ut_ad(page_get_n_recs(father_page) == 1); ut_ad(page_get_n_recs(father_page) == 1);
...@@ -2449,7 +2446,7 @@ btr_check_node_ptr( ...@@ -2449,7 +2446,7 @@ btr_check_node_ptr(
ut_a(cmp_dtuple_rec(node_ptr_tuple, node_ptr, ut_a(cmp_dtuple_rec(node_ptr_tuple, node_ptr,
rec_get_offsets(node_ptr, rec_get_offsets(node_ptr,
dict_tree_find_index(tree, node_ptr), tree->tree_index,
NULL, ULINT_UNDEFINED, &heap)) == 0); NULL, ULINT_UNDEFINED, &heap)) == 0);
mem_heap_free(heap); mem_heap_free(heap);
...@@ -2692,7 +2689,7 @@ btr_validate_level( ...@@ -2692,7 +2689,7 @@ btr_validate_level(
space = buf_frame_get_space_id(page); space = buf_frame_get_space_id(page);
index = UT_LIST_GET_FIRST(tree->tree_indexes); index = tree->tree_index;
while (level != btr_page_get_level(page, &mtr)) { while (level != btr_page_get_level(page, &mtr)) {
......
...@@ -1606,7 +1606,7 @@ btr_cur_optimistic_update( ...@@ -1606,7 +1606,7 @@ btr_cur_optimistic_update(
new_entry = row_rec_to_index_entry(ROW_COPY_DATA, index, rec, heap); new_entry = row_rec_to_index_entry(ROW_COPY_DATA, index, rec, heap);
row_upd_index_replace_new_col_vals_index_pos(new_entry, index, update, row_upd_index_replace_new_col_vals_index_pos(new_entry, index, update,
NULL); FALSE, NULL);
old_rec_size = rec_offs_size(offsets); old_rec_size = rec_offs_size(offsets);
new_rec_size = rec_get_converted_size(index, new_entry); new_rec_size = rec_get_converted_size(index, new_entry);
...@@ -1846,7 +1846,7 @@ btr_cur_pessimistic_update( ...@@ -1846,7 +1846,7 @@ btr_cur_pessimistic_update(
new_entry = row_rec_to_index_entry(ROW_COPY_DATA, index, rec, heap); new_entry = row_rec_to_index_entry(ROW_COPY_DATA, index, rec, heap);
row_upd_index_replace_new_col_vals_index_pos(new_entry, index, update, row_upd_index_replace_new_col_vals_index_pos(new_entry, index, update,
heap); FALSE, heap);
if (!(flags & BTR_KEEP_SYS_FLAG)) { if (!(flags & BTR_KEEP_SYS_FLAG)) {
row_upd_index_entry_sys_field(new_entry, index, DATA_ROLL_PTR, row_upd_index_entry_sys_field(new_entry, index, DATA_ROLL_PTR,
roll_ptr); roll_ptr);
...@@ -1915,13 +1915,13 @@ btr_cur_pessimistic_update( ...@@ -1915,13 +1915,13 @@ btr_cur_pessimistic_update(
ut_a(rec || optim_err != DB_UNDERFLOW); ut_a(rec || optim_err != DB_UNDERFLOW);
if (rec) { if (rec) {
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
lock_rec_restore_from_page_infimum(rec, page); lock_rec_restore_from_page_infimum(rec, page);
rec_set_field_extern_bits(rec, index, rec_set_field_extern_bits(rec, index,
ext_vect, n_ext_vect, mtr); ext_vect, n_ext_vect, mtr);
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
if (!rec_get_deleted_flag(rec, rec_offs_comp(offsets))) { if (!rec_get_deleted_flag(rec, rec_offs_comp(offsets))) {
/* The new inserted record owns its possible externally /* The new inserted record owns its possible externally
stored fields */ stored fields */
...@@ -2371,8 +2371,7 @@ btr_cur_compress( ...@@ -2371,8 +2371,7 @@ btr_cur_compress(
ut_ad(mtr_memo_contains(mtr, ut_ad(mtr_memo_contains(mtr,
dict_tree_get_lock(btr_cur_get_tree(cursor)), dict_tree_get_lock(btr_cur_get_tree(cursor)),
MTR_MEMO_X_LOCK)); MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, buf_block_align( ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_rec(cursor)),
btr_cur_get_page(cursor)),
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
ut_ad(btr_page_get_level(btr_cur_get_page(cursor), mtr) == 0); ut_ad(btr_page_get_level(btr_cur_get_page(cursor), mtr) == 0);
...@@ -2398,8 +2397,7 @@ btr_cur_compress_if_useful( ...@@ -2398,8 +2397,7 @@ btr_cur_compress_if_useful(
ut_ad(mtr_memo_contains(mtr, ut_ad(mtr_memo_contains(mtr,
dict_tree_get_lock(btr_cur_get_tree(cursor)), dict_tree_get_lock(btr_cur_get_tree(cursor)),
MTR_MEMO_X_LOCK)); MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, buf_block_align( ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_rec(cursor)),
btr_cur_get_page(cursor)),
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
if (btr_cur_compress_recommendation(cursor, mtr)) { if (btr_cur_compress_recommendation(cursor, mtr)) {
...@@ -2437,7 +2435,7 @@ btr_cur_optimistic_delete( ...@@ -2437,7 +2435,7 @@ btr_cur_optimistic_delete(
ibool no_compress_needed; ibool no_compress_needed;
*offsets_ = (sizeof offsets_) / sizeof *offsets_; *offsets_ = (sizeof offsets_) / sizeof *offsets_;
ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_page(cursor)), ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_rec(cursor)),
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
/* This is intended only for leaf page deletions */ /* This is intended only for leaf page deletions */
...@@ -3330,7 +3328,10 @@ btr_store_big_rec_extern_fields( ...@@ -3330,7 +3328,10 @@ btr_store_big_rec_extern_fields(
dict_index_t* index, /* in: index of rec; the index tree dict_index_t* index, /* in: index of rec; the index tree
MUST be X-latched */ MUST be X-latched */
rec_t* rec, /* in: record */ rec_t* rec, /* in: record */
const ulint* offsets, /* in: rec_get_offsets(rec, index) */ const ulint* offsets, /* in: rec_get_offsets(rec, index);
the "external storage" flags in offsets
will not correspond to rec when
this function returns */
big_rec_t* big_rec_vec, /* in: vector containing fields big_rec_t* big_rec_vec, /* in: vector containing fields
to be stored externally */ to be stored externally */
mtr_t* local_mtr __attribute__((unused))) /* in: mtr mtr_t* local_mtr __attribute__((unused))) /* in: mtr
......
...@@ -259,10 +259,7 @@ btr_pcur_restore_position( ...@@ -259,10 +259,7 @@ btr_pcur_restore_position(
cursor->latch_mode = latch_mode; cursor->latch_mode = latch_mode;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
rec = btr_pcur_get_rec(cursor); rec = btr_pcur_get_rec(cursor);
index = dict_tree_find_index( index = btr_pcur_get_btr_cur(cursor)->index;
btr_cur_get_tree(
btr_pcur_get_btr_cur(cursor)),
rec);
heap = mem_heap_create(256); heap = mem_heap_create(256);
offsets1 = rec_get_offsets(cursor->old_rec, offsets1 = rec_get_offsets(cursor->old_rec,
......
...@@ -24,8 +24,8 @@ ulint btr_search_this_is_zero = 0; /* A dummy variable to fool the ...@@ -24,8 +24,8 @@ ulint btr_search_this_is_zero = 0; /* A dummy variable to fool the
#ifdef UNIV_SEARCH_PERF_STAT #ifdef UNIV_SEARCH_PERF_STAT
ulint btr_search_n_succ = 0; ulint btr_search_n_succ = 0;
#endif /* UNIV_SEARCH_PERF_STAT */
ulint btr_search_n_hash_fail = 0; ulint btr_search_n_hash_fail = 0;
#endif /* UNIV_SEARCH_PERF_STAT */
byte btr_sea_pad1[64]; /* padding to prevent other memory update byte btr_sea_pad1[64]; /* padding to prevent other memory update
hotspots from residing on the same memory hotspots from residing on the same memory
...@@ -59,9 +59,6 @@ before hash index building is started */ ...@@ -59,9 +59,6 @@ before hash index building is started */
#define BTR_SEARCH_BUILD_LIMIT 100 #define BTR_SEARCH_BUILD_LIMIT 100
/* How many cells to check before temporarily releasing btr_search_latch */
#define BTR_CHUNK_SIZE 10000
/************************************************************************ /************************************************************************
Builds a hash index on a page with the given parameters. If the page already Builds a hash index on a page with the given parameters. If the page already
has a hash index with different parameters, the old hash index is removed. has a hash index with different parameters, the old hash index is removed.
...@@ -172,10 +169,12 @@ btr_search_info_create( ...@@ -172,10 +169,12 @@ btr_search_info_create(
info->last_hash_succ = FALSE; info->last_hash_succ = FALSE;
#ifdef UNIV_SEARCH_PERF_STAT
info->n_hash_succ = 0; info->n_hash_succ = 0;
info->n_hash_fail = 0; info->n_hash_fail = 0;
info->n_patt_succ = 0; info->n_patt_succ = 0;
info->n_searches = 0; info->n_searches = 0;
#endif /* UNIV_SEARCH_PERF_STAT */
/* Set some sensible values */ /* Set some sensible values */
info->n_fields = 1; info->n_fields = 1;
...@@ -487,7 +486,9 @@ btr_search_info_update_slow( ...@@ -487,7 +486,9 @@ btr_search_info_update_slow(
if (cursor->flag == BTR_CUR_HASH_FAIL) { if (cursor->flag == BTR_CUR_HASH_FAIL) {
/* Update the hash node reference, if appropriate */ /* Update the hash node reference, if appropriate */
#ifdef UNIV_SEARCH_PERF_STAT
btr_search_n_hash_fail++; btr_search_n_hash_fail++;
#endif /* UNIV_SEARCH_PERF_STAT */
rw_lock_x_lock(&btr_search_latch); rw_lock_x_lock(&btr_search_latch);
...@@ -872,11 +873,11 @@ failure_unlock: ...@@ -872,11 +873,11 @@ failure_unlock:
rw_lock_s_unlock(&btr_search_latch); rw_lock_s_unlock(&btr_search_latch);
} }
failure: failure:
info->n_hash_fail++;
cursor->flag = BTR_CUR_HASH_FAIL; cursor->flag = BTR_CUR_HASH_FAIL;
#ifdef UNIV_SEARCH_PERF_STAT #ifdef UNIV_SEARCH_PERF_STAT
info->n_hash_fail++;
if (info->n_hash_succ > 0) { if (info->n_hash_succ > 0) {
info->n_hash_succ--; info->n_hash_succ--;
} }
...@@ -1607,6 +1608,11 @@ btr_search_validate(void) ...@@ -1607,6 +1608,11 @@ btr_search_validate(void)
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_; ulint* offsets = offsets_;
/* How many cells to check before temporarily releasing
btr_search_latch. */
ulint chunk_size = 10000;
*offsets_ = (sizeof offsets_) / sizeof *offsets_; *offsets_ = (sizeof offsets_) / sizeof *offsets_;
rw_lock_x_lock(&btr_search_latch); rw_lock_x_lock(&btr_search_latch);
...@@ -1616,7 +1622,7 @@ btr_search_validate(void) ...@@ -1616,7 +1622,7 @@ btr_search_validate(void)
for (i = 0; i < cell_count; i++) { for (i = 0; i < cell_count; i++) {
/* We release btr_search_latch every once in a while to /* We release btr_search_latch every once in a while to
give other queries a chance to run. */ give other queries a chance to run. */
if ((i != 0) && ((i % BTR_CHUNK_SIZE) == 0)) { if ((i != 0) && ((i % chunk_size) == 0)) {
rw_lock_x_unlock(&btr_search_latch); rw_lock_x_unlock(&btr_search_latch);
os_thread_yield(); os_thread_yield();
rw_lock_x_lock(&btr_search_latch); rw_lock_x_lock(&btr_search_latch);
...@@ -1675,8 +1681,8 @@ btr_search_validate(void) ...@@ -1675,8 +1681,8 @@ btr_search_validate(void)
} }
} }
for (i = 0; i < cell_count; i += BTR_CHUNK_SIZE) { for (i = 0; i < cell_count; i += chunk_size) {
ulint end_index = ut_min(i + BTR_CHUNK_SIZE - 1, cell_count - 1); ulint end_index = ut_min(i + chunk_size - 1, cell_count - 1);
/* We release btr_search_latch every once in a while to /* We release btr_search_latch every once in a while to
give other queries a chance to run. */ give other queries a chance to run. */
......
...@@ -294,14 +294,14 @@ buf_LRU_try_free_flushed_blocks(void) ...@@ -294,14 +294,14 @@ buf_LRU_try_free_flushed_blocks(void)
} }
/********************************************************************** /**********************************************************************
Returns TRUE if less than 15 % of the buffer pool is available. This can be Returns TRUE if less than 25 % of the buffer pool is available. This can be
used in heuristics to prevent huge transactions eating up the whole buffer used in heuristics to prevent huge transactions eating up the whole buffer
pool for their locks. */ pool for their locks. */
ibool ibool
buf_LRU_buf_pool_running_out(void) buf_LRU_buf_pool_running_out(void)
/*==============================*/ /*==============================*/
/* out: TRUE if less than 15 % of buffer pool /* out: TRUE if less than 25 % of buffer pool
left */ left */
{ {
ibool ret = FALSE; ibool ret = FALSE;
...@@ -309,7 +309,7 @@ buf_LRU_buf_pool_running_out(void) ...@@ -309,7 +309,7 @@ buf_LRU_buf_pool_running_out(void)
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 7) { + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) {
ret = TRUE; ret = TRUE;
} }
...@@ -340,11 +340,11 @@ loop: ...@@ -340,11 +340,11 @@ loop:
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 10) { + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: ERROR: over 9 / 10 of the buffer pool is occupied by\n" " InnoDB: ERROR: over 95 percent of the buffer pool is occupied by\n"
"InnoDB: lock heaps or the adaptive hash index! Check that your\n" "InnoDB: lock heaps or the adaptive hash index! Check that your\n"
"InnoDB: transactions do not set too many row locks.\n" "InnoDB: transactions do not set too many row locks.\n"
"InnoDB: Your buffer pool size is %lu MB. Maybe you should make\n" "InnoDB: Your buffer pool size is %lu MB. Maybe you should make\n"
...@@ -356,17 +356,17 @@ loop: ...@@ -356,17 +356,17 @@ loop:
ut_error; ut_error;
} else if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) } else if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 5) { + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 3) {
if (!buf_lru_switched_on_innodb_mon) { if (!buf_lru_switched_on_innodb_mon) {
/* Over 80 % of the buffer pool is occupied by lock /* Over 67 % of the buffer pool is occupied by lock
heaps or the adaptive hash index. This may be a memory heaps or the adaptive hash index. This may be a memory
leak! */ leak! */
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: WARNING: over 4 / 5 of the buffer pool is occupied by\n" " InnoDB: WARNING: over 67 percent of the buffer pool is occupied by\n"
"InnoDB: lock heaps or the adaptive hash index! Check that your\n" "InnoDB: lock heaps or the adaptive hash index! Check that your\n"
"InnoDB: transactions do not set too many row locks.\n" "InnoDB: transactions do not set too many row locks.\n"
"InnoDB: Your buffer pool size is %lu MB. Maybe you should make\n" "InnoDB: Your buffer pool size is %lu MB. Maybe you should make\n"
...@@ -881,10 +881,10 @@ buf_LRU_block_remove_hashed_page( ...@@ -881,10 +881,10 @@ buf_LRU_block_remove_hashed_page(
if (buf_page_hash_get(block->space, block->offset)) { if (buf_page_hash_get(block->space, block->offset)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: From hash table we find block %p of %lu %lu which is not %p\n", "InnoDB: From hash table we find block %p of %lu %lu which is not %p\n",
buf_page_hash_get(block->space, block->offset), (void*) buf_page_hash_get(block->space, block->offset),
(ulong) buf_page_hash_get(block->space, block->offset)->space, (ulong) buf_page_hash_get(block->space, block->offset)->space,
(ulong) buf_page_hash_get(block->space, block->offset)->offset, (ulong) buf_page_hash_get(block->space, block->offset)->offset,
block); (void*) block);
} }
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
......
...@@ -32,4 +32,4 @@ ADD_LIBRARY(innobase btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c ...@@ -32,4 +32,4 @@ ADD_LIBRARY(innobase btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c
thr/thr0loc.c thr/thr0loc.c
trx/trx0purge.c trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c trx/trx0purge.c trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c
usr/usr0sess.c usr/usr0sess.c
ut/ut0byte.c ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c) ut/ut0byte.c ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c ut/ut0vec.c)
...@@ -89,6 +89,25 @@ else ...@@ -89,6 +89,25 @@ else
CXXFLAGS="$OPTIMIZE_CXXFLAGS -DDBUG_OFF $CXXFLAGS -DDEBUG_OFF" CXXFLAGS="$OPTIMIZE_CXXFLAGS -DDBUG_OFF $CXXFLAGS -DDEBUG_OFF"
fi fi
# NOTE: The flags below are disabled by default since we can't easily get
# rid of the "string over 509 characters in length" warnings, and thus can't
# add -Werror. But it's a good idea to enable these for a test compile
# before shipping a new snapshot to MySQL to catch errors that could make
# the compile fail on non-C99 compilers.
# If using gcc, disallow usage of C99 features to avoid accidentally
# introducing problems on compilers that only implement C89.
#if test "$ac_cv_prog_gcc" = "yes"
#then
# CFLAGS="$CFLAGS -std=c89 -ansi -pedantic -Wno-long-long"
#fi
# If using gcc, add some extra warning flags.
if test "$ac_cv_prog_gcc" = "yes"
then
CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
fi
case "$target_os" in case "$target_os" in
lin*) lin*)
CFLAGS="$CFLAGS -DUNIV_LINUX";; CFLAGS="$CFLAGS -DUNIV_LINUX";;
......
...@@ -216,20 +216,43 @@ dtype_print( ...@@ -216,20 +216,43 @@ dtype_print(
mtype = type->mtype; mtype = type->mtype;
prtype = type->prtype; prtype = type->prtype;
if (mtype == DATA_VARCHAR) {
switch (mtype) {
case DATA_VARCHAR:
fputs("DATA_VARCHAR", stderr); fputs("DATA_VARCHAR", stderr);
} else if (mtype == DATA_CHAR) { break;
case DATA_CHAR:
fputs("DATA_CHAR", stderr); fputs("DATA_CHAR", stderr);
} else if (mtype == DATA_BINARY) { break;
case DATA_BINARY:
fputs("DATA_BINARY", stderr); fputs("DATA_BINARY", stderr);
} else if (mtype == DATA_INT) { break;
case DATA_FIXBINARY:
fputs("DATA_FIXBINARY", stderr);
break;
case DATA_BLOB:
fputs("DATA_BLOB", stderr);
break;
case DATA_INT:
fputs("DATA_INT", stderr); fputs("DATA_INT", stderr);
} else if (mtype == DATA_MYSQL) { break;
case DATA_MYSQL:
fputs("DATA_MYSQL", stderr); fputs("DATA_MYSQL", stderr);
} else if (mtype == DATA_SYS) { break;
case DATA_SYS:
fputs("DATA_SYS", stderr); fputs("DATA_SYS", stderr);
} else { break;
default:
fprintf(stderr, "type %lu", (ulong) mtype); fprintf(stderr, "type %lu", (ulong) mtype);
break;
} }
len = type->len; len = type->len;
...@@ -254,6 +277,18 @@ dtype_print( ...@@ -254,6 +277,18 @@ dtype_print(
} else { } else {
fprintf(stderr, "prtype %lu", (ulong) prtype); fprintf(stderr, "prtype %lu", (ulong) prtype);
} }
} else {
if (prtype & DATA_UNSIGNED) {
fputs(" DATA_UNSIGNED", stderr);
}
if (prtype & DATA_BINARY_TYPE) {
fputs(" DATA_BINARY_TYPE", stderr);
}
if (prtype & DATA_NOT_NULL) {
fputs(" DATA_NOT_NULL", stderr);
}
} }
fprintf(stderr, " len %lu prec %lu", (ulong) len, (ulong) type->prec); fprintf(stderr, " len %lu prec %lu", (ulong) len, (ulong) type->prec);
......
This diff is collapsed.
This diff is collapsed.
...@@ -768,7 +768,7 @@ dict_load_table( ...@@ -768,7 +768,7 @@ dict_load_table(
if (!btr_pcur_is_on_user_rec(&pcur, &mtr) if (!btr_pcur_is_on_user_rec(&pcur, &mtr)
|| rec_get_deleted_flag(rec, 0)) { || rec_get_deleted_flag(rec, 0)) {
/* Not found */ /* Not found */
err_exit:
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
mem_heap_free(heap); mem_heap_free(heap);
...@@ -780,11 +780,8 @@ dict_load_table( ...@@ -780,11 +780,8 @@ dict_load_table(
/* Check if the table name in record is the searched one */ /* Check if the table name in record is the searched one */
if (len != ut_strlen(name) || ut_memcmp(name, field, len) != 0) { if (len != ut_strlen(name) || ut_memcmp(name, field, len) != 0) {
btr_pcur_close(&pcur);
mtr_commit(&mtr);
mem_heap_free(heap);
return(NULL); goto err_exit;
} }
ut_a(0 == ut_strcmp("SPACE", ut_a(0 == ut_strcmp("SPACE",
...@@ -848,36 +845,17 @@ dict_load_table( ...@@ -848,36 +845,17 @@ dict_load_table(
table->id = mach_read_from_8(field); table->id = mach_read_from_8(field);
field = rec_get_nth_field_old(rec, 5, &len); field = rec_get_nth_field_old(rec, 5, &len);
table->type = mach_read_from_4(field); if (UNIV_UNLIKELY(mach_read_from_4(field) != DICT_TABLE_ORDINARY)) {
ut_print_timestamp(stderr);
if (table->type == DICT_TABLE_CLUSTER_MEMBER) { fprintf(stderr,
ut_error; " InnoDB: table %s: unknown table type %lu\n",
#if 0 /* clustered tables have not been implemented yet */ name, (ulong) mach_read_from_4(field));
field = rec_get_nth_field_old(rec, 6, &len); goto err_exit;
table->mix_id = mach_read_from_8(field);
field = rec_get_nth_field_old(rec, 8, &len);
table->cluster_name = mem_heap_strdupl(heap, (char*) field, len);
#endif
}
if ((table->type == DICT_TABLE_CLUSTER)
|| (table->type == DICT_TABLE_CLUSTER_MEMBER)) {
field = rec_get_nth_field_old(rec, 7, &len);
ut_a(len == 4);
table->mix_len = mach_read_from_4(field);
} }
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
if (table->type == DICT_TABLE_CLUSTER_MEMBER) {
/* Load the cluster table definition if not yet in
memory cache */
dict_table_get_low(table->cluster_name);
}
dict_load_columns(table, heap); dict_load_columns(table, heap);
dict_table_add_to_cache(table); dict_table_add_to_cache(table);
......
...@@ -50,7 +50,6 @@ dict_mem_table_create( ...@@ -50,7 +50,6 @@ dict_mem_table_create(
table->heap = heap; table->heap = heap;
table->type = DICT_TABLE_ORDINARY;
table->flags = flags; table->flags = flags;
table->name = mem_heap_strdup(heap, name); table->name = mem_heap_strdup(heap, name);
table->dir_path_of_temp_table = NULL; table->dir_path_of_temp_table = NULL;
...@@ -66,9 +65,6 @@ dict_mem_table_create( ...@@ -66,9 +65,6 @@ dict_mem_table_create(
table->cached = FALSE; table->cached = FALSE;
table->mix_id = ut_dulint_zero;
table->mix_len = 0;
table->cols = mem_heap_alloc(heap, (n_cols + DATA_N_SYS_COLS) table->cols = mem_heap_alloc(heap, (n_cols + DATA_N_SYS_COLS)
* sizeof(dict_col_t)); * sizeof(dict_col_t));
UT_LIST_INIT(table->indexes); UT_LIST_INIT(table->indexes);
...@@ -97,42 +93,19 @@ dict_mem_table_create( ...@@ -97,42 +93,19 @@ dict_mem_table_create(
return(table); return(table);
} }
/************************************************************************** /********************************************************************
Creates a cluster memory object. */ Free a table memory object. */
dict_table_t*
dict_mem_cluster_create(
/*====================*/
/* out, own: cluster object */
const char* name, /* in: cluster name */
ulint space, /* in: space where the clustered indexes
of the member tables are placed */
ulint n_cols, /* in: number of columns */
ulint mix_len)/* in: length of the common key prefix in the
cluster */
{
dict_table_t* cluster;
/* Clustered tables cannot work with the compact record format. */
cluster = dict_mem_table_create(name, space, n_cols, 0);
cluster->type = DICT_TABLE_CLUSTER;
cluster->mix_len = mix_len;
return(cluster);
}
/**************************************************************************
Declares a non-published table as a member in a cluster. */
void void
dict_mem_table_make_cluster_member( dict_mem_table_free(
/*===============================*/ /*================*/
dict_table_t* table, /* in: non-published table */ dict_table_t* table) /* in: table */
const char* cluster_name) /* in: cluster name */
{ {
table->type = DICT_TABLE_CLUSTER_MEMBER; ut_ad(table);
table->cluster_name = cluster_name; ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
mutex_free(&(table->autoinc_mutex));
mem_heap_free(table->heap);
} }
/************************************************************************** /**************************************************************************
...@@ -286,5 +259,8 @@ dict_mem_index_free( ...@@ -286,5 +259,8 @@ dict_mem_index_free(
/*================*/ /*================*/
dict_index_t* index) /* in: index */ dict_index_t* index) /* in: index */
{ {
ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
mem_heap_free(index->heap); mem_heap_free(index->heap);
} }
...@@ -212,6 +212,38 @@ for_step( ...@@ -212,6 +212,38 @@ for_step(
return(thr); return(thr);
} }
/**************************************************************************
Performs an execution step of an exit statement node. */
que_thr_t*
exit_step(
/*======*/
/* out: query thread to run next or NULL */
que_thr_t* thr) /* in: query thread */
{
exit_node_t* node;
que_node_t* loop_node;
ut_ad(thr);
node = thr->run_node;
ut_ad(que_node_get_type(node) == QUE_NODE_EXIT);
/* Loops exit by setting thr->run_node as the loop node's parent, so
find our containing loop node and get its parent. */
loop_node = que_node_get_containing_loop_node(node);
/* If someone uses an EXIT statement outside of a loop, this will
trigger. */
ut_a(loop_node);
thr->run_node = que_node_get_parent(loop_node);
return(thr);
}
/************************************************************************** /**************************************************************************
Performs an execution step of a return-statement node. */ Performs an execution step of a return-statement node. */
......
...@@ -1170,9 +1170,9 @@ ibuf_dummy_index_free( ...@@ -1170,9 +1170,9 @@ ibuf_dummy_index_free(
dict_index_t* index) /* in: dummy index */ dict_index_t* index) /* in: dummy index */
{ {
dict_table_t* table = index->table; dict_table_t* table = index->table;
mem_heap_free(index->heap);
mutex_free(&(table->autoinc_mutex)); dict_mem_index_free(index);
mem_heap_free(table->heap); dict_mem_table_free(table);
} }
/************************************************************************* /*************************************************************************
......
...@@ -459,7 +459,10 @@ btr_store_big_rec_extern_fields( ...@@ -459,7 +459,10 @@ btr_store_big_rec_extern_fields(
dict_index_t* index, /* in: index of rec; the index tree dict_index_t* index, /* in: index of rec; the index tree
MUST be X-latched */ MUST be X-latched */
rec_t* rec, /* in: record */ rec_t* rec, /* in: record */
const ulint* offsets, /* in: rec_get_offsets(rec, index) */ const ulint* offsets, /* in: rec_get_offsets(rec, index);
the "external storage" flags in offsets
will not correspond to rec when
this function returns */
big_rec_t* big_rec_vec, /* in: vector containing fields big_rec_t* big_rec_vec, /* in: vector containing fields
to be stored externally */ to be stored externally */
mtr_t* local_mtr); /* in: mtr containing the latch to mtr_t* local_mtr); /* in: mtr containing the latch to
......
...@@ -98,8 +98,7 @@ btr_cur_compress_recommendation( ...@@ -98,8 +98,7 @@ btr_cur_compress_recommendation(
{ {
page_t* page; page_t* page;
ut_ad(mtr_memo_contains(mtr, buf_block_align( ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_rec(cursor)),
btr_cur_get_page(cursor)),
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
page = btr_cur_get_page(cursor); page = btr_cur_get_page(cursor);
...@@ -142,8 +141,7 @@ btr_cur_can_delete_without_compress( ...@@ -142,8 +141,7 @@ btr_cur_can_delete_without_compress(
{ {
page_t* page; page_t* page;
ut_ad(mtr_memo_contains(mtr, buf_block_align( ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_rec(cursor)),
btr_cur_get_page(cursor)),
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
page = btr_cur_get_page(cursor); page = btr_cur_get_page(cursor);
......
...@@ -180,12 +180,14 @@ struct btr_search_struct{ ...@@ -180,12 +180,14 @@ struct btr_search_struct{
the same prefix should be indexed in the the same prefix should be indexed in the
hash index */ hash index */
/*----------------------*/ /*----------------------*/
#ifdef UNIV_SEARCH_PERF_STAT
ulint n_hash_succ; /* number of successful hash searches thus ulint n_hash_succ; /* number of successful hash searches thus
far */ far */
ulint n_hash_fail; /* number of failed hash searches */ ulint n_hash_fail; /* number of failed hash searches */
ulint n_patt_succ; /* number of successful pattern searches thus ulint n_patt_succ; /* number of successful pattern searches thus
far */ far */
ulint n_searches; /* number of searches */ ulint n_searches; /* number of searches */
#endif /* UNIV_SEARCH_PERF_STAT */
}; };
#define BTR_SEARCH_MAGIC_N 1112765 #define BTR_SEARCH_MAGIC_N 1112765
...@@ -218,8 +220,8 @@ extern rw_lock_t* btr_search_latch_temp; ...@@ -218,8 +220,8 @@ extern rw_lock_t* btr_search_latch_temp;
#ifdef UNIV_SEARCH_PERF_STAT #ifdef UNIV_SEARCH_PERF_STAT
extern ulint btr_search_n_succ; extern ulint btr_search_n_succ;
#endif /* UNIV_SEARCH_PERF_STAT */
extern ulint btr_search_n_hash_fail; extern ulint btr_search_n_hash_fail;
#endif /* UNIV_SEARCH_PERF_STAT */
/* After change in n_fields or n_bytes in info, this many rounds are waited /* After change in n_fields or n_bytes in info, this many rounds are waited
before starting the hash analysis again: this is to save CPU time when there before starting the hash analysis again: this is to save CPU time when there
......
...@@ -26,14 +26,14 @@ void ...@@ -26,14 +26,14 @@ void
buf_LRU_try_free_flushed_blocks(void); buf_LRU_try_free_flushed_blocks(void);
/*==================================*/ /*==================================*/
/********************************************************************** /**********************************************************************
Returns TRUE if less than 15 % of the buffer pool is available. This can be Returns TRUE if less than 25 % of the buffer pool is available. This can be
used in heuristics to prevent huge transactions eating up the whole buffer used in heuristics to prevent huge transactions eating up the whole buffer
pool for their locks. */ pool for their locks. */
ibool ibool
buf_LRU_buf_pool_running_out(void); buf_LRU_buf_pool_running_out(void);
/*==============================*/ /*==============================*/
/* out: TRUE if less than 15 % of buffer pool /* out: TRUE if less than 25 % of buffer pool
left */ left */
/*####################################################################### /*#######################################################################
......
...@@ -100,6 +100,15 @@ ulint ...@@ -100,6 +100,15 @@ ulint
dict_col_get_clust_pos( dict_col_get_clust_pos(
/*===================*/ /*===================*/
dict_col_t* col); dict_col_t* col);
/********************************************************************
If the given column name is reserved for InnoDB system columns, return
TRUE. */
ibool
dict_col_name_is_reserved(
/*======================*/
/* out: TRUE if name is reserved */
const char* name); /* in: column name */
/************************************************************************ /************************************************************************
Initializes the autoinc counter. It is not an error to initialize an already Initializes the autoinc counter. It is not an error to initialize an already
initialized counter. */ initialized counter. */
...@@ -321,6 +330,14 @@ dict_table_get_low( ...@@ -321,6 +330,14 @@ dict_table_get_low(
/* out: table, NULL if not found */ /* out: table, NULL if not found */
const char* table_name); /* in: table name */ const char* table_name); /* in: table name */
/************************************************************************** /**************************************************************************
A noninlined version of dict_table_get_low. */
dict_table_t*
dict_table_get_low_noninlined(
/*==========================*/
/* out: table, NULL if not found */
const char* table_name); /* in: table name */
/**************************************************************************
Returns an index object. */ Returns an index object. */
UNIV_INLINE UNIV_INLINE
dict_index_t* dict_index_t*
...@@ -496,10 +513,11 @@ dict_table_is_comp( ...@@ -496,10 +513,11 @@ dict_table_is_comp(
compact page format */ compact page format */
const dict_table_t* table); /* in: table */ const dict_table_t* table); /* in: table */
/************************************************************************ /************************************************************************
Non inlined version of 'dict_table_is_comp' above. */ Check whether the table uses the compact page format. */
ibool ibool
innodb_dict_table_is_comp( dict_table_is_comp_noninline(
/*===============*/ /*=========================*/
/* out: TRUE if table uses the /* out: TRUE if table uses the
compact page format */ compact page format */
const dict_table_t* table); /* in: table */ const dict_table_t* table); /* in: table */
...@@ -725,33 +743,6 @@ dict_tree_free( ...@@ -725,33 +743,6 @@ dict_tree_free(
/************************************************************************** /**************************************************************************
In an index tree, finds the index corresponding to a record in the tree. */ In an index tree, finds the index corresponding to a record in the tree. */
dict_index_t*
dict_tree_find_index(
/*=================*/
/* out: index */
dict_tree_t* tree, /* in: index tree */
rec_t* rec); /* in: record for which to find correct index */
/**************************************************************************
In an index tree, finds the index corresponding to a dtuple which is used
in a search to a tree. */
dict_index_t*
dict_tree_find_index_for_tuple(
/*===========================*/
/* out: index; NULL if the tuple does not
contain the mix id field in a mixed tree */
dict_tree_t* tree, /* in: index tree */
dtuple_t* tuple); /* in: tuple for which to find index */
/***********************************************************************
Checks if a table which is a mixed cluster member owns a record. */
ibool
dict_is_mixed_table_rec(
/*====================*/
/* out: TRUE if the record belongs to this
table */
dict_table_t* table, /* in: table in a mixed cluster */
rec_t* rec); /* in: user record in the clustered index */
/************************************************************************** /**************************************************************************
Returns an index object if it is found in the dictionary cache. */ Returns an index object if it is found in the dictionary cache. */
...@@ -760,6 +751,7 @@ dict_index_get_if_in_cache( ...@@ -760,6 +751,7 @@ dict_index_get_if_in_cache(
/*=======================*/ /*=======================*/
/* out: index, NULL if not found */ /* out: index, NULL if not found */
dulint index_id); /* in: index id */ dulint index_id); /* in: index id */
#ifdef UNIV_DEBUG
/************************************************************************** /**************************************************************************
Checks that a tuple has n_fields_cmp value in a sensible range, so that Checks that a tuple has n_fields_cmp value in a sensible range, so that
no comparison can occur with the page number field in a node pointer. */ no comparison can occur with the page number field in a node pointer. */
...@@ -770,6 +762,7 @@ dict_tree_check_search_tuple( ...@@ -770,6 +762,7 @@ dict_tree_check_search_tuple(
/* out: TRUE if ok */ /* out: TRUE if ok */
dict_tree_t* tree, /* in: index tree */ dict_tree_t* tree, /* in: index tree */
dtuple_t* tuple); /* in: tuple used in a search */ dtuple_t* tuple); /* in: tuple used in a search */
#endif /* UNIV_DEBUG */
/************************************************************************** /**************************************************************************
Builds a node pointer out of a physical record and a page number. */ Builds a node pointer out of a physical record and a page number. */
...@@ -916,7 +909,6 @@ dict_tables_have_same_db( ...@@ -916,7 +909,6 @@ dict_tables_have_same_db(
dbname '/' tablename */ dbname '/' tablename */
const char* name2); /* in: table name in the form const char* name2); /* in: table name in the form
dbname '/' tablename */ dbname '/' tablename */
/************************************************************************* /*************************************************************************
Scans from pointer onwards. Stops if is at the start of a copy of Scans from pointer onwards. Stops if is at the start of a copy of
'string' where characters are compared without case sensitivity. Stops 'string' where characters are compared without case sensitivity. Stops
...@@ -928,7 +920,6 @@ dict_scan_to( ...@@ -928,7 +920,6 @@ dict_scan_to(
/* out: scanned up to this */ /* out: scanned up to this */
const char* ptr, /* in: scan from */ const char* ptr, /* in: scan from */
const char* string);/* in: look for this */ const char* string);/* in: look for this */
/* Buffers for storing detailed information about the latest foreign key /* Buffers for storing detailed information about the latest foreign key
and unique key errors */ and unique key errors */
extern FILE* dict_foreign_err_file; extern FILE* dict_foreign_err_file;
......
...@@ -92,7 +92,6 @@ dict_table_get_n_user_cols( ...@@ -92,7 +92,6 @@ dict_table_get_n_user_cols(
{ {
ut_ad(table); ut_ad(table);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
ut_ad(table->cached);
return(table->n_cols - DATA_N_SYS_COLS); return(table->n_cols - DATA_N_SYS_COLS);
} }
...@@ -126,7 +125,6 @@ dict_table_get_n_cols( ...@@ -126,7 +125,6 @@ dict_table_get_n_cols(
{ {
ut_ad(table); ut_ad(table);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
ut_ad(table->cached);
return(table->n_cols); return(table->n_cols);
} }
......
...@@ -35,9 +35,11 @@ combination of types */ ...@@ -35,9 +35,11 @@ combination of types */
/* Types for a table object */ /* Types for a table object */
#define DICT_TABLE_ORDINARY 1 #define DICT_TABLE_ORDINARY 1
#if 0 /* not implemented */
#define DICT_TABLE_CLUSTER_MEMBER 2 #define DICT_TABLE_CLUSTER_MEMBER 2
#define DICT_TABLE_CLUSTER 3 /* this means that the table is #define DICT_TABLE_CLUSTER 3 /* this means that the table is
really a cluster definition */ really a cluster definition */
#endif
/* Table flags */ /* Table flags */
#define DICT_TF_COMPACT 1 /* compact page format */ #define DICT_TF_COMPACT 1 /* compact page format */
...@@ -56,29 +58,13 @@ dict_mem_table_create( ...@@ -56,29 +58,13 @@ dict_mem_table_create(
a member of a cluster */ a member of a cluster */
ulint n_cols, /* in: number of columns */ ulint n_cols, /* in: number of columns */
ulint flags); /* in: table flags */ ulint flags); /* in: table flags */
/************************************************************************** /********************************************************************
Creates a cluster memory object. */ Free a table memory object. */
dict_cluster_t*
dict_mem_cluster_create(
/*====================*/
/* out, own: cluster object (where the
type dict_cluster_t == dict_table_t) */
const char* name, /* in: cluster name */
ulint space, /* in: space where the clustered
indexes of the member tables are
placed */
ulint n_cols, /* in: number of columns */
ulint mix_len); /* in: length of the common key prefix
in the cluster */
/**************************************************************************
Declares a non-published table as a member in a cluster. */
void void
dict_mem_table_make_cluster_member( dict_mem_table_free(
/*===============================*/ /*================*/
dict_table_t* table, /* in: non-published table */ dict_table_t* table); /* in: table */
const char* cluster_name); /* in: cluster name */
/************************************************************************** /**************************************************************************
Adds a column definition to a table. */ Adds a column definition to a table. */
...@@ -176,9 +162,7 @@ struct dict_field_struct{ ...@@ -176,9 +162,7 @@ struct dict_field_struct{
/* Data structure for an index tree */ /* Data structure for an index tree */
struct dict_tree_struct{ struct dict_tree_struct{
ulint type; /* tree type */ ulint type; /* tree type */
dulint id; /* id of the index stored in the tree, in the dulint id; /* id of the index stored in the tree */
case of a mixed index, the id of the clustered
index of the cluster table */
ulint space; /* space of index tree */ ulint space; /* space of index tree */
ulint page; /* index tree root page number */ ulint page; /* index tree root page number */
byte pad[64];/* Padding to prevent other memory hotspots on byte pad[64];/* Padding to prevent other memory hotspots on
...@@ -189,13 +173,8 @@ struct dict_tree_struct{ ...@@ -189,13 +173,8 @@ struct dict_tree_struct{
struct has been memoryfixed (by mini- struct has been memoryfixed (by mini-
transactions wanting to access the index transactions wanting to access the index
tree) */ tree) */
UT_LIST_BASE_NODE_T(dict_index_t) dict_index_t* tree_index; /* the index stored in the
tree_indexes; /* list of indexes stored in the index tree */
index tree: if the tree is not of the
mixed type there is only one index in
the list; if the tree is of the mixed
type, the first index in the list is the
index of the cluster which owns the tree */
ulint magic_n;/* magic number */ ulint magic_n;/* magic number */
}; };
...@@ -301,8 +280,7 @@ a foreign key constraint is enforced, therefore RESTRICT just means no flag */ ...@@ -301,8 +280,7 @@ a foreign key constraint is enforced, therefore RESTRICT just means no flag */
/* Data structure for a database table */ /* Data structure for a database table */
struct dict_table_struct{ struct dict_table_struct{
dulint id; /* id of the table or cluster */ dulint id; /* id of the table */
ulint type; /* DICT_TABLE_ORDINARY, ... */
ulint flags; /* DICT_TF_COMPACT, ... */ ulint flags; /* DICT_TF_COMPACT, ... */
mem_heap_t* heap; /* memory heap */ mem_heap_t* heap; /* memory heap */
const char* name; /* table name */ const char* name; /* table name */
...@@ -371,17 +349,6 @@ struct dict_table_struct{ ...@@ -371,17 +349,6 @@ struct dict_table_struct{
UT_LIST_BASE_NODE_T(lock_t) UT_LIST_BASE_NODE_T(lock_t)
locks; /* list of locks on the table */ locks; /* list of locks on the table */
/*----------------------*/ /*----------------------*/
dulint mix_id; /* if the table is a member in a cluster,
this is its mix id */
ulint mix_len;/* if the table is a cluster or a member
this is the common key prefix lenght */
ulint mix_id_len;/* mix id length in a compressed form */
byte mix_id_buf[12];
/* mix id of a mixed table written in
a compressed form */
const char* cluster_name; /* if the table is a member in a
cluster, this is the name of the cluster */
/*----------------------*/
ibool does_not_fit_in_memory; ibool does_not_fit_in_memory;
/* this field is used to specify in simulations /* this field is used to specify in simulations
tables which are so big that disk should be tables which are so big that disk should be
......
...@@ -63,6 +63,14 @@ proc_eval_step( ...@@ -63,6 +63,14 @@ proc_eval_step(
/* out: query thread to run next or NULL */ /* out: query thread to run next or NULL */
que_thr_t* thr); /* in: query thread */ que_thr_t* thr); /* in: query thread */
/************************************************************************** /**************************************************************************
Performs an execution step of an exit statement node. */
que_thr_t*
exit_step(
/*======*/
/* out: query thread to run next or NULL */
que_thr_t* thr); /* in: query thread */
/**************************************************************************
Performs an execution step of a return-statement node. */ Performs an execution step of a return-statement node. */
que_thr_t* que_thr_t*
......
...@@ -222,6 +222,32 @@ do {\ ...@@ -222,6 +222,32 @@ do {\
mem_heap_free_top(hash_get_heap(TABLE, fold111), sizeof(TYPE));\ mem_heap_free_top(hash_get_heap(TABLE, fold111), sizeof(TYPE));\
} while (0) } while (0)
/********************************************************************
Move all hash table entries from OLD_TABLE to NEW_TABLE.*/
#define HASH_MIGRATE(OLD_TABLE, NEW_TABLE, NODE_TYPE, PTR_NAME, FOLD_FUNC) \
do {\
ulint i2222;\
ulint cell_count2222;\
\
cell_count2222 = hash_get_n_cells(OLD_TABLE);\
\
for (i2222 = 0; i2222 < cell_count2222; i2222++) {\
NODE_TYPE* node2222 = HASH_GET_FIRST((OLD_TABLE), i2222);\
\
while (node2222) {\
NODE_TYPE* next2222 = node2222->PTR_NAME;\
ulint fold2222 = FOLD_FUNC(node2222);\
\
HASH_INSERT(NODE_TYPE, PTR_NAME, (NEW_TABLE),\
fold2222, node2222);\
\
node2222 = next2222;\
}\
}\
} while (0)
/**************************************************************** /****************************************************************
Gets the mutex index for a fold value in a hash table. */ Gets the mutex index for a fold value in a hash table. */
UNIV_INLINE UNIV_INLINE
......
...@@ -595,6 +595,15 @@ ibool ...@@ -595,6 +595,15 @@ ibool
lock_validate(void); lock_validate(void);
/*===============*/ /*===============*/
/* out: TRUE if ok */ /* out: TRUE if ok */
/*************************************************************************
Return approximate number or record locks (bits set in the bitmap) for
this transaction. Since delete-marked records ma ybe removed, the
record count will not be precise. */
ulint
lock_number_of_rows_locked(
/*=======================*/
trx_t* trx); /* in: transaction */
/* The lock system */ /* The lock system */
extern lock_sys_t* lock_sys; extern lock_sys_t* lock_sys;
......
...@@ -311,6 +311,17 @@ mem_heap_strdupl( ...@@ -311,6 +311,17 @@ mem_heap_strdupl(
const char* str, /* in: string to be copied */ const char* str, /* in: string to be copied */
ulint len); /* in: length of str, in bytes */ ulint len); /* in: length of str, in bytes */
/**************************************************************************
Concatenate two strings and return the result, using a memory heap. */
char*
mem_heap_strcat(
/*============*/
/* out, own: the result */
mem_heap_t* heap, /* in: memory heap where string is allocated */
const char* s1, /* in: string 1 */
const char* s2); /* in: string 2 */
#ifdef MEM_PERIODIC_CHECK #ifdef MEM_PERIODIC_CHECK
/********************************************************************** /**********************************************************************
Goes through the list of all allocated mem blocks, checks their magic Goes through the list of all allocated mem blocks, checks their magic
......
...@@ -175,19 +175,6 @@ page_rec_is_comp( ...@@ -175,19 +175,6 @@ page_rec_is_comp(
/* out: nonzero if in compact format */ /* out: nonzero if in compact format */
const rec_t* rec) /* in: record */ const rec_t* rec) /* in: record */
{ {
#ifdef UNIV_RELEASE_NOT_YET_STABLE
if (UNIV_UNLIKELY((ulint)rec < (ulint)(buf_pool->frame_zero))
|| UNIV_UNLIKELY((ulint)rec >= (ulint)(buf_pool->high_end))) {
ut_print_timestamp(stderr);
fprintf(stderr,
"InnoDB: Error: trying to read a stray page rec %p\n"
"InnoDB: buf pool start is at %p, end at %p\n",
rec, buf_pool->frame_zero,
buf_pool->high_end);
ut_error;
}
#endif
return(page_is_comp(ut_align_down((rec_t*) rec, UNIV_PAGE_SIZE))); return(page_is_comp(ut_align_down((rec_t*) rec, UNIV_PAGE_SIZE)));
} }
......
This diff is collapsed.
...@@ -15,6 +15,13 @@ Created 11/19/1996 Heikki Tuuri ...@@ -15,6 +15,13 @@ Created 11/19/1996 Heikki Tuuri
#include "pars0types.h" #include "pars0types.h"
#include "row0types.h" #include "row0types.h"
#include "trx0types.h" #include "trx0types.h"
#include "ut0vec.h"
/* Type of the user functions. The first argument is always InnoDB-supplied
and varies in type, while 'user_arg' is a user-supplied argument. The
meaning of the return type also varies. See the individual use cases, e.g.
the FETCH statement, for details on them. */
typedef void* (*pars_user_func_cb_t)(void* arg, void* user_arg);
extern int yydebug; extern int yydebug;
...@@ -77,6 +84,7 @@ que_t* ...@@ -77,6 +84,7 @@ que_t*
pars_sql( pars_sql(
/*=====*/ /*=====*/
/* out, own: the query graph */ /* out, own: the query graph */
pars_info_t* info, /* in: extra information, or NULL */
const char* str); /* in: SQL string */ const char* str); /* in: SQL string */
/***************************************************************** /*****************************************************************
Retrieves characters to the lexical analyzer. */ Retrieves characters to the lexical analyzer. */
...@@ -157,6 +165,15 @@ pars_cursor_declaration( ...@@ -157,6 +165,15 @@ pars_cursor_declaration(
table */ table */
sel_node_t* select_node); /* in: select node */ sel_node_t* select_node); /* in: select node */
/************************************************************************* /*************************************************************************
Parses a function declaration. */
que_node_t*
pars_function_declaration(
/*======================*/
/* out: sym_node */
sym_node_t* sym_node); /* in: function id node in the symbol
table */
/*************************************************************************
Parses a select statement. */ Parses a select statement. */
sel_node_t* sel_node_t*
...@@ -269,6 +286,13 @@ pars_while_statement( ...@@ -269,6 +286,13 @@ pars_while_statement(
que_node_t* cond, /* in: while-condition */ que_node_t* cond, /* in: while-condition */
que_node_t* stat_list); /* in: statement list */ que_node_t* stat_list); /* in: statement list */
/************************************************************************* /*************************************************************************
Parses an exit statement. */
exit_node_t*
pars_exit_statement(void);
/*=====================*/
/* out: exit statement node */
/*************************************************************************
Parses a return-statement. */ Parses a return-statement. */
return_node_t* return_node_t*
...@@ -294,14 +318,16 @@ pars_assignment_statement( ...@@ -294,14 +318,16 @@ pars_assignment_statement(
sym_node_t* var, /* in: variable to assign */ sym_node_t* var, /* in: variable to assign */
que_node_t* val); /* in: value to assign */ que_node_t* val); /* in: value to assign */
/************************************************************************* /*************************************************************************
Parses a fetch statement. */ Parses a fetch statement. into_list or user_func (but not both) must be
non-NULL. */
fetch_node_t* fetch_node_t*
pars_fetch_statement( pars_fetch_statement(
/*=================*/ /*=================*/
/* out: fetch statement node */ /* out: fetch statement node */
sym_node_t* cursor, /* in: cursor node */ sym_node_t* cursor, /* in: cursor node */
sym_node_t* into_list); /* in: variables to set */ sym_node_t* into_list, /* in: variables to set, or NULL */
sym_node_t* user_func); /* in: user function name, or NULL */
/************************************************************************* /*************************************************************************
Parses an open or close cursor statement. */ Parses an open or close cursor statement. */
...@@ -345,6 +371,8 @@ pars_column_def( ...@@ -345,6 +371,8 @@ pars_column_def(
pars_res_word_t* type, /* in: data type */ pars_res_word_t* type, /* in: data type */
sym_node_t* len, /* in: length of column, or sym_node_t* len, /* in: length of column, or
NULL */ NULL */
void* is_unsigned, /* in: if not NULL, column
is of type UNSIGNED. */
void* is_not_null); /* in: if not NULL, column void* is_not_null); /* in: if not NULL, column
is of type NOT NULL. */ is of type NOT NULL. */
/************************************************************************* /*************************************************************************
...@@ -418,6 +446,142 @@ pars_complete_graph_for_exec( ...@@ -418,6 +446,142 @@ pars_complete_graph_for_exec(
trx_t* trx, /* in: transaction handle */ trx_t* trx, /* in: transaction handle */
mem_heap_t* heap); /* in: memory heap from which allocated */ mem_heap_t* heap); /* in: memory heap from which allocated */
/********************************************************************
Create parser info struct.*/
pars_info_t*
pars_info_create(void);
/*==================*/
/* out, own: info struct */
/********************************************************************
Free info struct and everything it contains.*/
void
pars_info_free(
/*===========*/
pars_info_t* info); /* in: info struct */
/********************************************************************
Add bound literal. */
void
pars_info_add_literal(
/*==================*/
pars_info_t* info, /* in: info struct */
const char* name, /* in: name */
const void* address, /* in: address */
ulint length, /* in: length of data */
ulint type, /* in: type, e.g. DATA_FIXBINARY */
ulint prtype); /* in: precise type, e.g.
DATA_UNSIGNED */
/********************************************************************
Equivalent to pars_info_add_literal(info, name, str, strlen(str),
DATA_VARCHAR, DATA_ENGLISH). */
void
pars_info_add_str_literal(
/*======================*/
pars_info_t* info, /* in: info struct */
const char* name, /* in: name */
const char* str); /* in: string */
/********************************************************************
Equivalent to:
char buf[4];
mach_write_to_4(buf, val);
pars_info_add_literal(info, name, buf, 4, DATA_INT, 0);
except that the buffer is dynamically allocated from the info struct's
heap. */
void
pars_info_add_int4_literal(
/*=======================*/
pars_info_t* info, /* in: info struct */
const char* name, /* in: name */
lint val); /* in: value */
/********************************************************************
Equivalent to:
char buf[8];
mach_write_to_8(buf, val);
pars_info_add_literal(info, name, buf, 8, DATA_BINARY, 0);
except that the buffer is dynamically allocated from the info struct's
heap. */
void
pars_info_add_dulint_literal(
/*=========================*/
pars_info_t* info, /* in: info struct */
const char* name, /* in: name */
dulint val); /* in: value */
/********************************************************************
Add user function. */
void
pars_info_add_function(
/*===================*/
pars_info_t* info, /* in: info struct */
const char* name, /* in: function name */
pars_user_func_cb_t func, /* in: function address */
void* arg); /* in: user-supplied argument */
/********************************************************************
Get user function with the given name.*/
pars_user_func_t*
pars_info_get_user_func(
/*====================*/
/* out: user func, or NULL if not
found */
pars_info_t* info, /* in: info struct */
const char* name); /* in: function name to find*/
/********************************************************************
Get bound literal with the given name.*/
pars_bound_lit_t*
pars_info_get_bound_lit(
/*====================*/
/* out: bound literal, or NULL if
not found */
pars_info_t* info, /* in: info struct */
const char* name); /* in: bound literal name to find */
/* Extra information supplied for pars_sql(). */
struct pars_info_struct {
mem_heap_t* heap; /* our own memory heap */
ib_vector_t* funcs; /* user functions, or NUll
(pars_user_func_t*) */
ib_vector_t* bound_lits; /* bound literals, or NULL
(pars_bound_lit_t*) */
ibool graph_owns_us; /* if TRUE (which is the default),
que_graph_free() will free us */
};
/* User-supplied function and argument. */
struct pars_user_func_struct {
const char* name; /* function name */
pars_user_func_cb_t func; /* function address */
void* arg; /* user-supplied argument */
};
/* Bound literal. */
struct pars_bound_lit_struct {
const char* name; /* name */
const void* address; /* address */
ulint length; /* length of data */
ulint type; /* type, e.g. DATA_FIXBINARY */
ulint prtype; /* precise type, e.g. DATA_UNSIGNED */
};
/* Struct used to denote a reserved word in a parsing tree */ /* Struct used to denote a reserved word in a parsing tree */
struct pars_res_word_struct{ struct pars_res_word_struct{
...@@ -498,6 +662,11 @@ struct for_node_struct{ ...@@ -498,6 +662,11 @@ struct for_node_struct{
que_node_t* stat_list; /* statement list */ que_node_t* stat_list; /* statement list */
}; };
/* exit statement node */
struct exit_node_struct{
que_common_t common; /* type: QUE_NODE_EXIT */
};
/* return-statement node */ /* return-statement node */
struct return_node_struct{ struct return_node_struct{
que_common_t common; /* type: QUE_NODE_RETURN */ que_common_t common; /* type: QUE_NODE_RETURN */
......
...@@ -54,6 +54,16 @@ sym_tab_add_str_lit( ...@@ -54,6 +54,16 @@ sym_tab_add_str_lit(
it */ it */
ulint len); /* in: string length */ ulint len); /* in: string length */
/********************************************************************** /**********************************************************************
Add a bound literal to a symbol table. */
sym_node_t*
sym_tab_add_bound_lit(
/*==================*/
/* out: symbol table node */
sym_tab_t* sym_tab, /* in: symbol table */
const char* name, /* in: name of bound literal */
ulint* lit_type); /* out: type of literal (PARS_*_LIT) */
/**********************************************************************
Adds an SQL null literal to a symbol table. */ Adds an SQL null literal to a symbol table. */
sym_node_t* sym_node_t*
...@@ -83,6 +93,19 @@ struct sym_node_struct{ ...@@ -83,6 +93,19 @@ struct sym_node_struct{
been allocated from dynamic memory and it should be freed when the been allocated from dynamic memory and it should be freed when the
symbol table is discarded */ symbol table is discarded */
/* 'alias' and 'indirection' are almost the same, but not quite.
'alias' always points to the primary instance of the variable, while
'indirection' does the same only if we should use the primary
instance's values for the node's data. This is usually the case, but
when initializing a cursor (e.g., "DECLARE CURSOR c IS SELECT * FROM
t WHERE id = x;"), we copy the values from the primary instance to
the cursor's instance so that they are fixed for the duration of the
cursor, and set 'indirection' to NULL. If we did not, the value of
'x' could change between fetches and things would break horribly.
TODO: It would be cleaner to make 'indirection' a boolean field and
always use 'alias' to refer to the primary node. */
sym_node_t* indirection; /* pointer to sym_node_t* indirection; /* pointer to
another symbol table another symbol table
node which contains node which contains
...@@ -158,6 +181,7 @@ struct sym_tab_struct{ ...@@ -158,6 +181,7 @@ struct sym_tab_struct{
/* position of the next character in /* position of the next character in
sql_string to give to the lexical sql_string to give to the lexical
analyzer */ analyzer */
pars_info_t* info; /* extra information, or NULL */
sym_node_list_t sym_list; sym_node_list_t sym_list;
/* list of symbol nodes in the symbol /* list of symbol nodes in the symbol
table */ table */
...@@ -180,6 +204,7 @@ struct sym_tab_struct{ ...@@ -180,6 +204,7 @@ struct sym_tab_struct{
#define SYM_CURSOR 96 /* named cursor */ #define SYM_CURSOR 96 /* named cursor */
#define SYM_PROCEDURE_NAME 97 /* stored procedure name */ #define SYM_PROCEDURE_NAME 97 /* stored procedure name */
#define SYM_INDEX 98 /* database index name */ #define SYM_INDEX 98 /* database index name */
#define SYM_FUNCTION 99 /* user function name */
#ifndef UNIV_NONINL #ifndef UNIV_NONINL
#include "pars0sym.ic" #include "pars0sym.ic"
......
...@@ -9,6 +9,9 @@ Created 1/11/1998 Heikki Tuuri ...@@ -9,6 +9,9 @@ Created 1/11/1998 Heikki Tuuri
#ifndef pars0types_h #ifndef pars0types_h
#define pars0types_h #define pars0types_h
typedef struct pars_info_struct pars_info_t;
typedef struct pars_user_func_struct pars_user_func_t;
typedef struct pars_bound_lit_struct pars_bound_lit_t;
typedef struct sym_node_struct sym_node_t; typedef struct sym_node_struct sym_node_t;
typedef struct sym_tab_struct sym_tab_t; typedef struct sym_tab_struct sym_tab_t;
typedef struct pars_res_word_struct pars_res_word_t; typedef struct pars_res_word_struct pars_res_word_t;
...@@ -19,6 +22,7 @@ typedef struct elsif_node_struct elsif_node_t; ...@@ -19,6 +22,7 @@ typedef struct elsif_node_struct elsif_node_t;
typedef struct if_node_struct if_node_t; typedef struct if_node_struct if_node_t;
typedef struct while_node_struct while_node_t; typedef struct while_node_struct while_node_t;
typedef struct for_node_struct for_node_t; typedef struct for_node_struct for_node_t;
typedef struct exit_node_struct exit_node_t;
typedef struct return_node_struct return_node_t; typedef struct return_node_struct return_node_t;
typedef struct assign_node_struct assign_node_t; typedef struct assign_node_struct assign_node_t;
typedef struct col_assign_node_struct col_assign_node_t; typedef struct col_assign_node_struct col_assign_node_t;
......
...@@ -277,6 +277,15 @@ que_node_get_parent( ...@@ -277,6 +277,15 @@ que_node_get_parent(
/*================*/ /*================*/
/* out: parent node or NULL */ /* out: parent node or NULL */
que_node_t* node); /* in: node */ que_node_t* node); /* in: node */
/********************************************************************
Get the first containing loop node (e.g. while_node_t or for_node_t) for the
given node, or NULL if the node is not within a loop. */
que_node_t*
que_node_get_containing_loop_node(
/*==============================*/
/* out: containing loop node, or NULL. */
que_node_t* node); /* in: node */
/************************************************************************* /*************************************************************************
Catenates a query graph node to a list of them, possible empty list. */ Catenates a query graph node to a list of them, possible empty list. */
UNIV_INLINE UNIV_INLINE
...@@ -322,8 +331,15 @@ void ...@@ -322,8 +331,15 @@ void
que_node_print_info( que_node_print_info(
/*================*/ /*================*/
que_node_t* node); /* in: query graph node */ que_node_t* node); /* in: query graph node */
/*************************************************************************
Evaluate the given SQL */
ulint
que_eval_sql(
/*=========*/
pars_info_t* info, /* out: error code or DB_SUCCESS */
const char* sql, /* in: info struct, or NULL */
trx_t* trx); /* in: trx */
/* Query graph query thread node: the fields are protected by the kernel /* Query graph query thread node: the fields are protected by the kernel
mutex with the exceptions named below */ mutex with the exceptions named below */
...@@ -388,6 +404,7 @@ struct que_fork_struct{ ...@@ -388,6 +404,7 @@ struct que_fork_struct{
sym_tab_t* sym_tab; /* symbol table of the query, sym_tab_t* sym_tab; /* symbol table of the query,
generated by the parser, or NULL generated by the parser, or NULL
if the graph was created 'by hand' */ if the graph was created 'by hand' */
pars_info_t* info; /* in: info struct, or NULL */
/* The following cur_... fields are relevant only in a select graph */ /* The following cur_... fields are relevant only in a select graph */
ulint cur_end; /* QUE_CUR_NOT_DEFINED, QUE_CUR_START, ulint cur_end; /* QUE_CUR_NOT_DEFINED, QUE_CUR_START,
...@@ -469,6 +486,7 @@ struct que_fork_struct{ ...@@ -469,6 +486,7 @@ struct que_fork_struct{
#define QUE_NODE_ROW_PRINTF 29 #define QUE_NODE_ROW_PRINTF 29
#define QUE_NODE_ELSIF 30 #define QUE_NODE_ELSIF 30
#define QUE_NODE_CALL 31 #define QUE_NODE_CALL 31
#define QUE_NODE_EXIT 32
/* Query thread states */ /* Query thread states */
#define QUE_THR_RUNNING 1 #define QUE_THR_RUNNING 1
......
...@@ -244,7 +244,8 @@ row_update_for_mysql( ...@@ -244,7 +244,8 @@ row_update_for_mysql(
row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL
handle */ handle */
/************************************************************************* /*************************************************************************
This can only be used when srv_locks_unsafe_for_binlog is TRUE. Before This can only be used when srv_locks_unsafe_for_binlog is TRUE or
session is using a READ COMMITTED isolation level. Before
calling this function we must use trx_reset_new_rec_lock_info() and calling this function we must use trx_reset_new_rec_lock_info() and
trx_register_new_rec_lock() to store the information which new record locks trx_register_new_rec_lock() to store the information which new record locks
really were set. This function removes a newly set lock under prebuilt->pcur, really were set. This function removes a newly set lock under prebuilt->pcur,
......
...@@ -78,6 +78,26 @@ fetch_step( ...@@ -78,6 +78,26 @@ fetch_step(
/*=======*/ /*=======*/
/* out: query thread to run next or NULL */ /* out: query thread to run next or NULL */
que_thr_t* thr); /* in: query thread */ que_thr_t* thr); /* in: query thread */
/********************************************************************
Sample callback function for fetch that prints each row.*/
void*
row_fetch_print(
/*============*/
/* out: always returns non-NULL */
void* row, /* in: sel_node_t* */
void* user_arg); /* in: not used */
/********************************************************************
Callback function for fetch that stores an unsigned 4 byte integer to the
location pointed. The column's type must be DATA_INT, DATA_UNSIGNED, length
= 4. */
void*
row_fetch_store_uint4(
/*==================*/
/* out: always returns NULL */
void* row, /* in: sel_node_t* */
void* user_arg); /* in: data pointer */
/*************************************************************** /***************************************************************
Prints a row in a select result. */ Prints a row in a select result. */
...@@ -204,8 +224,6 @@ struct plan_struct{ ...@@ -204,8 +224,6 @@ struct plan_struct{
ulint first_prefetched;/* index of the first cached row in ulint first_prefetched;/* index of the first cached row in
select buffer arrays for each column */ select buffer arrays for each column */
ibool no_prefetch; /* no prefetch for this table */ ibool no_prefetch; /* no prefetch for this table */
ibool mixed_index; /* TRUE if index is a clustered index
in a mixed cluster */
sym_node_list_t columns; /* symbol table nodes for the columns sym_node_list_t columns; /* symbol table nodes for the columns
to retrieve from the table */ to retrieve from the table */
UT_LIST_BASE_NODE_T(func_node_t) UT_LIST_BASE_NODE_T(func_node_t)
...@@ -311,6 +329,20 @@ struct fetch_node_struct{ ...@@ -311,6 +329,20 @@ struct fetch_node_struct{
que_common_t common; /* type: QUE_NODE_FETCH */ que_common_t common; /* type: QUE_NODE_FETCH */
sel_node_t* cursor_def; /* cursor definition */ sel_node_t* cursor_def; /* cursor definition */
sym_node_t* into_list; /* variables to set */ sym_node_t* into_list; /* variables to set */
pars_user_func_t*
func; /* User callback function or NULL.
The first argument to the function
is a sel_node_t*, containing the
results of the SELECT operation for
one row. If the function returns
NULL, it is not interested in
further rows and the cursor is
modified so (cursor % NOTFOUND) is
true. If it returns not-NULL,
continue normally. See
row_fetch_print() for an example
(and a useful debugging tool). */
}; };
/* Open or close cursor statement node */ /* Open or close cursor statement node */
......
...@@ -185,6 +185,10 @@ row_upd_index_replace_new_col_vals_index_pos( ...@@ -185,6 +185,10 @@ row_upd_index_replace_new_col_vals_index_pos(
upd_t* update, /* in: an update vector built for the index so upd_t* update, /* in: an update vector built for the index so
that the field number in an upd_field is the that the field number in an upd_field is the
index position */ index position */
ibool order_only,
/* in: if TRUE, limit the replacement to
ordering fields of index; note that this
does not work for non-clustered indexes. */
mem_heap_t* heap); /* in: memory heap to which we allocate and mem_heap_t* heap); /* in: memory heap to which we allocate and
copy the new values, set this as NULL if you copy the new values, set this as NULL if you
do not want allocation */ do not want allocation */
......
...@@ -544,7 +544,9 @@ struct trx_struct{ ...@@ -544,7 +544,9 @@ struct trx_struct{
the transaction; note that it is also the transaction; note that it is also
in the lock list trx_locks */ in the lock list trx_locks */
dict_index_t* new_rec_locks[2];/* these are normally NULL; if dict_index_t* new_rec_locks[2];/* these are normally NULL; if
srv_locks_unsafe_for_binlog is TRUE, srv_locks_unsafe_for_binlog is TRUE
or session is using READ COMMITTED
isolation level,
in a cursor search, if we set a new in a cursor search, if we set a new
record lock on an index, this is set record lock on an index, this is set
to point to the index; this is to point to the index; this is
......
...@@ -82,10 +82,6 @@ memory is read outside the allocated blocks. */ ...@@ -82,10 +82,6 @@ memory is read outside the allocated blocks. */
/* Make a non-inline debug version */ /* Make a non-inline debug version */
/* You can remove this define when the release is stable. This define adds
some consistency checks to code. They use a little CPU time. */
#define UNIV_RELEASE_NOT_YET_STABLE
/* /*
#define UNIV_DEBUG #define UNIV_DEBUG
#define UNIV_MEM_DEBUG #define UNIV_MEM_DEBUG
...@@ -128,7 +124,7 @@ by one. */ ...@@ -128,7 +124,7 @@ by one. */
#ifdef __WIN__ #ifdef __WIN__
#define UNIV_INLINE __inline #define UNIV_INLINE __inline
#else #else
#define UNIV_INLINE static inline #define UNIV_INLINE static __inline__
#endif #endif
#else #else
...@@ -178,6 +174,16 @@ management to ensure correct alignment for doubles etc. */ ...@@ -178,6 +174,16 @@ management to ensure correct alignment for doubles etc. */
/* Note that inside MySQL 'byte' is defined as char on Linux! */ /* Note that inside MySQL 'byte' is defined as char on Linux! */
#define byte unsigned char #define byte unsigned char
/* Define an unsigned integer type that is exactly 32 bits. */
#if SIZEOF_INT == 4
typedef unsigned int ib_uint32_t;
#elif SIZEOF_LONG == 4
typedef unsigned long ib_uint32_t;
#else
#error "Neither int or long is 4 bytes"
#endif
/* Another basic type we use is unsigned long integer which should be equal to /* Another basic type we use is unsigned long integer which should be equal to
the word size of the machine, that is on a 32-bit platform 32 bits, and on a the word size of the machine, that is on a 32-bit platform 32 bits, and on a
64-bit platform 64 bits. We also give the printf format for the type as a 64-bit platform 64 bits. We also give the printf format for the type as a
...@@ -205,9 +211,6 @@ typedef longlong ib_longlong; ...@@ -205,9 +211,6 @@ typedef longlong ib_longlong;
#endif #endif
#endif #endif
/* The following type should be at least a 64-bit floating point number */
typedef double utfloat;
/* The 'undefined' value for a ulint */ /* The 'undefined' value for a ulint */
#define ULINT_UNDEFINED ((ulint)(-1)) #define ULINT_UNDEFINED ((ulint)(-1))
......
...@@ -181,6 +181,30 @@ ut_memcpyq( ...@@ -181,6 +181,30 @@ ut_memcpyq(
const char* src, /* in: string to be quoted */ const char* src, /* in: string to be quoted */
ulint len); /* in: length of src */ ulint len); /* in: length of src */
/**************************************************************************
Return the number of times s2 occurs in s1. Overlapping instances of s2
are only counted once. */
ulint
ut_strcount(
/*========*/
/* out: the number of times s2 occurs in s1 */
const char* s1, /* in: string to search in */
const char* s2); /* in: string to search for */
/**************************************************************************
Replace every occurrence of s1 in str with s2. Overlapping instances of s1
are only replaced once. */
char *
ut_strreplace(
/*==========*/
/* out, own: modified string, must be
freed with mem_free() */
const char* str, /* in: string to operate on */
const char* s1, /* in: string to replace */
const char* s2); /* in: string to replace s1 with */
#ifndef UNIV_NONINL #ifndef UNIV_NONINL
#include "ut0mem.ic" #include "ut0mem.ic"
#endif #endif
......
#ifndef IB_VECTOR_H
#define IB_VECTOR_H
#include "univ.i"
#include "mem0mem.h"
typedef struct ib_vector_struct ib_vector_t;
/* An automatically resizing vector datatype with the following properties:
-Contains void* items.
-The items are owned by the caller.
-All memory allocation is done through a heap owned by the caller, who is
responsible for freeing it when done with the vector.
-When the vector is resized, the old memory area is left allocated since it
uses the same heap as the new memory area, so this is best used for
relatively small or short-lived uses.
*/
/********************************************************************
Create a new vector with the given initial size. */
ib_vector_t*
ib_vector_create(
/*=============*/
/* out: vector */
mem_heap_t* heap, /* in: heap */
ulint size); /* in: initial size */
/********************************************************************
Push a new element to the vector, increasing its size if necessary. */
void
ib_vector_push(
/*===========*/
ib_vector_t* vec, /* in: vector */
void* elem); /* in: data element */
/********************************************************************
Get the number of elements in the vector. */
UNIV_INLINE
ulint
ib_vector_size(
/*===========*/
/* out: number of elements in vector */
ib_vector_t* vec); /* in: vector */
/********************************************************************
Get the n'th element. */
UNIV_INLINE
void*
ib_vector_get(
/*==========*/
/* out: n'th element */
ib_vector_t* vec, /* in: vector */
ulint n); /* in: element index to get */
/* See comment at beginning of file. */
struct ib_vector_struct {
mem_heap_t* heap; /* heap */
void** data; /* data elements */
ulint used; /* number of elements currently used */
ulint total; /* number of elements allocated */
};
#ifndef UNIV_NONINL
#include "ut0vec.ic"
#endif
#endif
/********************************************************************
Get number of elements in vector. */
UNIV_INLINE
ulint
ib_vector_size(
/*===========*/
/* out: number of elements in vector */
ib_vector_t* vec) /* in: vector */
{
return(vec->used);
}
/********************************************************************
Get n'th element. */
UNIV_INLINE
void*
ib_vector_get(
/*==========*/
/* out: n'th element */
ib_vector_t* vec, /* in: vector */
ulint n) /* in: element index to get */
{
ut_a(n < vec->used);
return(vec->data[n]);
}
...@@ -1698,6 +1698,40 @@ lock_sec_rec_some_has_impl_off_kernel( ...@@ -1698,6 +1698,40 @@ lock_sec_rec_some_has_impl_off_kernel(
return(row_vers_impl_x_locked_off_kernel(rec, index, offsets)); return(row_vers_impl_x_locked_off_kernel(rec, index, offsets));
} }
/*************************************************************************
Return approximate number or record locks (bits set in the bitmap) for
this transaction. Since delete-marked records may be removed, the
record count will not be precise. */
ulint
lock_number_of_rows_locked(
/*=======================*/
trx_t* trx) /* in: transaction */
{
lock_t* lock;
ulint n_records = 0;
ulint n_bits;
ulint n_bit;
lock = UT_LIST_GET_FIRST(trx->trx_locks);
while (lock) {
if (lock_get_type(lock) == LOCK_REC) {
n_bits = lock_rec_get_n_bits(lock);
for (n_bit = 0; n_bit < n_bits; n_bit++) {
if (lock_rec_get_nth_bit(lock, n_bit)) {
n_records++;
}
}
}
lock = UT_LIST_GET_NEXT(trx_locks, lock);
}
return (n_records);
}
/*============== RECORD LOCK CREATION AND QUEUE MANAGEMENT =============*/ /*============== RECORD LOCK CREATION AND QUEUE MANAGEMENT =============*/
/************************************************************************* /*************************************************************************
...@@ -2001,7 +2035,8 @@ lock_rec_lock_fast( ...@@ -2001,7 +2035,8 @@ lock_rec_lock_fast(
if (!impl) { if (!impl) {
lock_rec_create(mode, rec, index, trx); lock_rec_create(mode, rec, index, trx);
if (srv_locks_unsafe_for_binlog) { if (srv_locks_unsafe_for_binlog
|| trx->isolation_level == TRX_ISO_READ_COMMITTED) {
trx_register_new_rec_lock(trx, index); trx_register_new_rec_lock(trx, index);
} }
} }
...@@ -2027,7 +2062,8 @@ lock_rec_lock_fast( ...@@ -2027,7 +2062,8 @@ lock_rec_lock_fast(
if (!lock_rec_get_nth_bit(lock, heap_no)) { if (!lock_rec_get_nth_bit(lock, heap_no)) {
lock_rec_set_nth_bit(lock, heap_no); lock_rec_set_nth_bit(lock, heap_no);
if (srv_locks_unsafe_for_binlog) { if (srv_locks_unsafe_for_binlog
|| trx->isolation_level == TRX_ISO_READ_COMMITTED) {
trx_register_new_rec_lock(trx, index); trx_register_new_rec_lock(trx, index);
} }
} }
...@@ -2087,7 +2123,8 @@ lock_rec_lock_slow( ...@@ -2087,7 +2123,8 @@ lock_rec_lock_slow(
err = lock_rec_enqueue_waiting(mode, rec, index, thr); err = lock_rec_enqueue_waiting(mode, rec, index, thr);
if (srv_locks_unsafe_for_binlog) { if (srv_locks_unsafe_for_binlog
|| trx->isolation_level == TRX_ISO_READ_COMMITTED) {
trx_register_new_rec_lock(trx, index); trx_register_new_rec_lock(trx, index);
} }
} else { } else {
...@@ -2096,7 +2133,8 @@ lock_rec_lock_slow( ...@@ -2096,7 +2133,8 @@ lock_rec_lock_slow(
lock_rec_add_to_queue(LOCK_REC | mode, rec, index, lock_rec_add_to_queue(LOCK_REC | mode, rec, index,
trx); trx);
if (srv_locks_unsafe_for_binlog) { if (srv_locks_unsafe_for_binlog
|| trx->isolation_level == TRX_ISO_READ_COMMITTED) {
trx_register_new_rec_lock(trx, index); trx_register_new_rec_lock(trx, index);
} }
} }
...@@ -2436,14 +2474,17 @@ lock_rec_inherit_to_gap( ...@@ -2436,14 +2474,17 @@ lock_rec_inherit_to_gap(
lock = lock_rec_get_first(rec); lock = lock_rec_get_first(rec);
/* If srv_locks_unsafe_for_binlog is TRUE, we do not want locks set /* If srv_locks_unsafe_for_binlog is TRUE or session is using
READ COMMITTED isolation level, we do not want locks set
by an UPDATE or a DELETE to be inherited as gap type locks. But we by an UPDATE or a DELETE to be inherited as gap type locks. But we
DO want S-locks set by a consistency constraint to be inherited also DO want S-locks set by a consistency constraint to be inherited also
then. */ then. */
while (lock != NULL) { while (lock != NULL) {
if (!lock_rec_get_insert_intention(lock) if (!lock_rec_get_insert_intention(lock)
&& !(srv_locks_unsafe_for_binlog && !((srv_locks_unsafe_for_binlog
|| lock->trx->isolation_level ==
TRX_ISO_READ_COMMITTED)
&& lock_get_mode(lock) == LOCK_X)) { && lock_get_mode(lock) == LOCK_X)) {
lock_rec_add_to_queue(LOCK_REC | lock_get_mode(lock) lock_rec_add_to_queue(LOCK_REC | lock_get_mode(lock)
...@@ -4320,6 +4361,10 @@ loop: ...@@ -4320,6 +4361,10 @@ loop:
(ulong) ut_dulint_get_low(trx->read_view->up_limit_id)); (ulong) ut_dulint_get_low(trx->read_view->up_limit_id));
} }
fprintf(file,
"Trx has approximately %lu row locks\n",
(ulong) lock_number_of_rows_locked(trx));
if (trx->que_state == TRX_QUE_LOCK_WAIT) { if (trx->que_state == TRX_QUE_LOCK_WAIT) {
fprintf(file, fprintf(file,
"------- TRX HAS BEEN WAITING %lu SEC FOR THIS LOCK TO BE GRANTED:\n", "------- TRX HAS BEEN WAITING %lu SEC FOR THIS LOCK TO BE GRANTED:\n",
...@@ -5167,3 +5212,4 @@ lock_clust_rec_read_check_and_lock_alt( ...@@ -5167,3 +5212,4 @@ lock_clust_rec_read_check_and_lock_alt(
} }
return(ret); return(ret);
} }
...@@ -897,9 +897,9 @@ recv_parse_or_apply_log_rec_body( ...@@ -897,9 +897,9 @@ recv_parse_or_apply_log_rec_body(
ut_ad(!page || ptr); ut_ad(!page || ptr);
if (index) { if (index) {
dict_table_t* table = index->table; dict_table_t* table = index->table;
mem_heap_free(index->heap);
mutex_free(&(table->autoinc_mutex)); dict_mem_index_free(index);
mem_heap_free(table->heap); dict_mem_table_free(table);
} }
return(ptr); return(ptr);
......
...@@ -445,7 +445,7 @@ mem_heap_validate_or_print( ...@@ -445,7 +445,7 @@ mem_heap_validate_or_print(
&& (mem_block_get_len(block) > UNIV_PAGE_SIZE)) { && (mem_block_get_len(block) > UNIV_PAGE_SIZE)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: mem block %p length %lu > UNIV_PAGE_SIZE\n", block, "InnoDB: Error: mem block %p length %lu > UNIV_PAGE_SIZE\n", (void*) block,
(ulong) mem_block_get_len(block)); (ulong) mem_block_get_len(block));
/* error */ /* error */
......
...@@ -114,6 +114,31 @@ mem_heap_strdup( ...@@ -114,6 +114,31 @@ mem_heap_strdup(
return(memcpy(mem_heap_alloc(heap, len), str, len)); return(memcpy(mem_heap_alloc(heap, len), str, len));
} }
/**************************************************************************
Concatenate two strings and return the result, using a memory heap. */
char*
mem_heap_strcat(
/*============*/
/* out, own: the result */
mem_heap_t* heap, /* in: memory heap where string is allocated */
const char* s1, /* in: string 1 */
const char* s2) /* in: string 2 */
{
char* s;
ulint s1_len = strlen(s1);
ulint s2_len = strlen(s2);
s = mem_heap_alloc(heap, s1_len + s2_len + 1);
memcpy(s, s1, s1_len);
memcpy(s + s1_len, s2, s2_len);
s[s1_len + s2_len] = '\0';
return(s);
}
/******************************************************************* /*******************************************************************
Creates a memory heap block where data can be allocated. */ Creates a memory heap block where data can be allocated. */
......
...@@ -641,7 +641,7 @@ os_fast_mutex_free( ...@@ -641,7 +641,7 @@ os_fast_mutex_free(
" InnoDB: error: return value %lu when calling\n" " InnoDB: error: return value %lu when calling\n"
"InnoDB: pthread_mutex_destroy().\n", (ulint)ret); "InnoDB: pthread_mutex_destroy().\n", (ulint)ret);
fprintf(stderr, fprintf(stderr,
"InnoDB: Byte contents of the pthread mutex at %p:\n", fast_mutex); "InnoDB: Byte contents of the pthread mutex at %p:\n", (void*) fast_mutex);
ut_print_buf(stderr, fast_mutex, sizeof(os_fast_mutex_t)); ut_print_buf(stderr, fast_mutex, sizeof(os_fast_mutex_t));
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
......
This diff is collapsed.
#!/bin/bash #!/bin/bash
# #
# regenerate parser from bison input files as documented at the top of # generate parser files from bison input files.
# pars0lex.l.
set -eu set -eu
......
#!/bin/bash
#
# generate lexer files from flex input files.
set -eu
TMPFILE=_flex_tmp.c
OUTFILE=lexyy.c
flex -o $TMPFILE pars0lex.l
# AIX needs its includes done in a certain order, so include "univ.i" first
# to be sure we get it right.
echo '#include "univ.i"' > $OUTFILE
# flex assigns a pointer to an int in one place without a cast, resulting in
# a warning on Win64. this adds the cast.
sed -e 's/int offset = (yy_c_buf_p) - (yytext_ptr);/int offset = (int)((yy_c_buf_p) - (yytext_ptr));/;' < $TMPFILE >> $OUTFILE
rm $TMPFILE
This diff is collapsed.
This diff is collapsed.
...@@ -33,6 +33,8 @@ yylex(void); ...@@ -33,6 +33,8 @@ yylex(void);
%token PARS_INT_LIT %token PARS_INT_LIT
%token PARS_FLOAT_LIT %token PARS_FLOAT_LIT
%token PARS_STR_LIT %token PARS_STR_LIT
%token PARS_FIXBINARY_LIT
%token PARS_BLOB_LIT
%token PARS_NULL_LIT %token PARS_NULL_LIT
%token PARS_ID_TOKEN %token PARS_ID_TOKEN
%token PARS_AND_TOKEN %token PARS_AND_TOKEN
...@@ -115,6 +117,9 @@ yylex(void); ...@@ -115,6 +117,9 @@ yylex(void);
%token PARS_COMMIT_TOKEN %token PARS_COMMIT_TOKEN
%token PARS_ROLLBACK_TOKEN %token PARS_ROLLBACK_TOKEN
%token PARS_WORK_TOKEN %token PARS_WORK_TOKEN
%token PARS_UNSIGNED_TOKEN
%token PARS_EXIT_TOKEN
%token PARS_FUNCTION_TOKEN
%left PARS_AND_TOKEN PARS_OR_TOKEN %left PARS_AND_TOKEN PARS_OR_TOKEN
%left PARS_NOT_TOKEN %left PARS_NOT_TOKEN
...@@ -133,6 +138,7 @@ statement: ...@@ -133,6 +138,7 @@ statement:
| predefined_procedure_call ';' | predefined_procedure_call ';'
| while_statement ';' | while_statement ';'
| for_statement ';' | for_statement ';'
| exit_statement ';'
| if_statement ';' | if_statement ';'
| return_statement ';' | return_statement ';'
| assignment_statement ';' | assignment_statement ';'
...@@ -165,6 +171,8 @@ exp: ...@@ -165,6 +171,8 @@ exp:
| PARS_INT_LIT { $$ = $1;} | PARS_INT_LIT { $$ = $1;}
| PARS_FLOAT_LIT { $$ = $1;} | PARS_FLOAT_LIT { $$ = $1;}
| PARS_STR_LIT { $$ = $1;} | PARS_STR_LIT { $$ = $1;}
| PARS_FIXBINARY_LIT { $$ = $1;}
| PARS_BLOB_LIT { $$ = $1;}
| PARS_NULL_LIT { $$ = $1;} | PARS_NULL_LIT { $$ = $1;}
| PARS_SQL_TOKEN { $$ = $1;} | PARS_SQL_TOKEN { $$ = $1;}
| exp '+' exp { $$ = pars_op('+', $1, $3); } | exp '+' exp { $$ = pars_op('+', $1, $3); }
...@@ -225,6 +233,10 @@ predefined_procedure_name: ...@@ -225,6 +233,10 @@ predefined_procedure_name:
| PARS_ASSERT_TOKEN { $$ = &pars_assert_token; } | PARS_ASSERT_TOKEN { $$ = &pars_assert_token; }
; ;
user_function_call:
PARS_ID_TOKEN '(' ')' { $$ = $1; }
;
table_list: table_list:
PARS_ID_TOKEN { $$ = que_node_list_add_last(NULL, $1); } PARS_ID_TOKEN { $$ = que_node_list_add_last(NULL, $1); }
| table_list ',' PARS_ID_TOKEN | table_list ',' PARS_ID_TOKEN
...@@ -428,6 +440,10 @@ for_statement: ...@@ -428,6 +440,10 @@ for_statement:
{ $$ = pars_for_statement($2, $4, $6, $8); } { $$ = pars_for_statement($2, $4, $6, $8); }
; ;
exit_statement:
PARS_EXIT_TOKEN { $$ = pars_exit_statement(); }
;
return_statement: return_statement:
PARS_RETURN_TOKEN { $$ = pars_return_statement(); } PARS_RETURN_TOKEN { $$ = pars_return_statement(); }
; ;
...@@ -446,12 +462,14 @@ close_cursor_statement: ...@@ -446,12 +462,14 @@ close_cursor_statement:
fetch_statement: fetch_statement:
PARS_FETCH_TOKEN PARS_ID_TOKEN PARS_INTO_TOKEN variable_list PARS_FETCH_TOKEN PARS_ID_TOKEN PARS_INTO_TOKEN variable_list
{ $$ = pars_fetch_statement($2, $4); } { $$ = pars_fetch_statement($2, $4, NULL); }
| PARS_FETCH_TOKEN PARS_ID_TOKEN PARS_INTO_TOKEN user_function_call
{ $$ = pars_fetch_statement($2, NULL, $4); }
; ;
column_def: column_def:
PARS_ID_TOKEN type_name opt_column_len opt_not_null PARS_ID_TOKEN type_name opt_column_len opt_unsigned opt_not_null
{ $$ = pars_column_def($1, $2, $3, $4); } { $$ = pars_column_def($1, $2, $3, $4, $5); }
; ;
column_def_list: column_def_list:
...@@ -466,6 +484,13 @@ opt_column_len: ...@@ -466,6 +484,13 @@ opt_column_len:
{ $$ = $2; } { $$ = $2; }
; ;
opt_unsigned:
/* Nothing */ { $$ = NULL; }
| PARS_UNSIGNED_TOKEN
{ $$ = &pars_int_token;
/* pass any non-NULL pointer */ }
;
opt_not_null: opt_not_null:
/* Nothing */ { $$ = NULL; } /* Nothing */ { $$ = NULL; }
| PARS_NOT_TOKEN PARS_NULL_LIT | PARS_NOT_TOKEN PARS_NULL_LIT
...@@ -561,10 +586,20 @@ cursor_declaration: ...@@ -561,10 +586,20 @@ cursor_declaration:
{ $$ = pars_cursor_declaration($3, $5); } { $$ = pars_cursor_declaration($3, $5); }
; ;
function_declaration:
PARS_DECLARE_TOKEN PARS_FUNCTION_TOKEN PARS_ID_TOKEN ';'
{ $$ = pars_function_declaration($3); }
;
declaration:
cursor_declaration
| function_declaration
;
declaration_list: declaration_list:
/* Nothing */ /* Nothing */
| cursor_declaration | declaration
| declaration_list cursor_declaration | declaration_list declaration
; ;
procedure_definition: procedure_definition:
......
...@@ -12,27 +12,11 @@ not automatically generate them from pars0grm.y and pars0lex.l. ...@@ -12,27 +12,11 @@ not automatically generate them from pars0grm.y and pars0lex.l.
How to make the InnoDB parser and lexer C files: How to make the InnoDB parser and lexer C files:
1. First do 1. Run ./make_flex.sh to generate lexer files.
bison -d pars0grm.y
That generates pars0grm.tab.c and pars0grm.tab.h.
2. Rename pars0grm.tab.c to pars0grm.c and pars0grm.tab.h to pars0grm.h. 2. Run ./make_bison.sh to generate parser files.
3. Copy pars0grm.h also to /innobase/include These instructions seem to work at least with bison-1.875d and flex-2.5.31 on
4. Do
flex pars0lex.l
That generates lex.yy.c.
5. Rename lex.yy.c to lexyy.c.
6. Add '#include "univ.i"' before #include <stdio.h> in lexyy.c
(Needed for AIX)
7. Add a type cast to int to the assignment below the comment
'need more input.' (Removes a warning on Win64)
These instructions seem to work at least with bison-1.28 and flex-2.5.4 on
Linux. Linux.
*******************************************************/ *******************************************************/
...@@ -99,8 +83,11 @@ string_append( ...@@ -99,8 +83,11 @@ string_append(
DIGIT [0-9] DIGIT [0-9]
ID [a-z_A-Z][a-z_A-Z0-9]* ID [a-z_A-Z][a-z_A-Z0-9]*
BOUND_LIT \:[a-z_A-Z0-9]+
%x comment %x comment
%x quoted %x quoted
%x id
%% %%
{DIGIT}+ { {DIGIT}+ {
...@@ -115,6 +102,15 @@ ID [a-z_A-Z][a-z_A-Z0-9]* ...@@ -115,6 +102,15 @@ ID [a-z_A-Z][a-z_A-Z0-9]*
return(PARS_FLOAT_LIT); return(PARS_FLOAT_LIT);
} }
{BOUND_LIT} {
ulint type;
yylval = sym_tab_add_bound_lit(pars_sym_tab_global,
yytext + 1, &type);
return(type);
}
"'" { "'" {
/* Quoted character string literals are handled in an explicit /* Quoted character string literals are handled in an explicit
start state 'quoted'. This state is entered and the buffer for start state 'quoted'. This state is entered and the buffer for
...@@ -153,6 +149,45 @@ In the state 'quoted', only two actions are possible (defined below). */ ...@@ -153,6 +149,45 @@ In the state 'quoted', only two actions are possible (defined below). */
} }
} }
\" {
/* Quoted identifiers are handled in an explicit start state 'id'.
This state is entered and the buffer for the scanned string is emptied
upon encountering a starting quote.
In the state 'id', only two actions are possible (defined below). */
BEGIN(id);
stringbuf_len = 0;
}
<id>[^\"]+ {
/* Got a sequence of characters other than '"':
append to string buffer */
string_append(yytext, yyleng);
}
<id>\"+ {
/* Got a sequence of '"' characters:
append half of them to string buffer,
as '""' represents a single '"'.
We apply truncating division,
so that '"""' will result in '"'. */
string_append(yytext, yyleng / 2);
/* If we got an odd number of quotes, then the
last quote we got is the terminating quote.
At the end of the string, we return to the
initial start state and report the scanned
identifier. */
if (yyleng % 2) {
BEGIN(INITIAL);
yylval = sym_tab_add_id(
pars_sym_tab_global,
(byte*) stringbuf, stringbuf_len);
return(PARS_ID_TOKEN);
}
}
"NULL" { "NULL" {
yylval = sym_tab_add_null_lit(pars_sym_tab_global); yylval = sym_tab_add_null_lit(pars_sym_tab_global);
...@@ -462,6 +497,18 @@ In the state 'quoted', only two actions are possible (defined below). */ ...@@ -462,6 +497,18 @@ In the state 'quoted', only two actions are possible (defined below). */
return(PARS_WORK_TOKEN); return(PARS_WORK_TOKEN);
} }
"UNSIGNED" {
return(PARS_UNSIGNED_TOKEN);
}
"EXIT" {
return(PARS_EXIT_TOKEN);
}
"FUNCTION" {
return(PARS_FUNCTION_TOKEN);
}
{ID} { {ID} {
yylval = sym_tab_add_id(pars_sym_tab_global, yylval = sym_tab_add_id(pars_sym_tab_global,
(byte*)yytext, (byte*)yytext,
......
...@@ -313,7 +313,6 @@ opt_calc_index_goodness( ...@@ -313,7 +313,6 @@ opt_calc_index_goodness(
ulint goodness; ulint goodness;
ulint n_fields; ulint n_fields;
ulint col_no; ulint col_no;
ulint mix_id_col_no;
ulint op; ulint op;
ulint j; ulint j;
...@@ -326,8 +325,6 @@ opt_calc_index_goodness( ...@@ -326,8 +325,6 @@ opt_calc_index_goodness(
n_fields = dict_index_get_n_unique_in_tree(index); n_fields = dict_index_get_n_unique_in_tree(index);
mix_id_col_no = dict_table_get_sys_col_no(index->table, DATA_MIX_ID);
for (j = 0; j < n_fields; j++) { for (j = 0; j < n_fields; j++) {
col_no = dict_index_get_nth_col_no(index, j); col_no = dict_index_get_nth_col_no(index, j);
...@@ -335,13 +332,7 @@ opt_calc_index_goodness( ...@@ -335,13 +332,7 @@ opt_calc_index_goodness(
exp = opt_look_for_col_in_cond_before(OPT_EQUAL, col_no, exp = opt_look_for_col_in_cond_before(OPT_EQUAL, col_no,
sel_node->search_cond, sel_node->search_cond,
sel_node, nth_table, &op); sel_node, nth_table, &op);
if (col_no == mix_id_col_no) { if (exp) {
ut_ad(exp == NULL);
index_plan[j] = NULL;
*last_op = '=';
goodness += 4;
} else if (exp) {
/* The value for this column is exactly known already /* The value for this column is exactly known already
at this stage of the join */ at this stage of the join */
...@@ -531,7 +522,6 @@ opt_search_plan_for_table( ...@@ -531,7 +522,6 @@ opt_search_plan_for_table(
warning */ warning */
ulint best_goodness; ulint best_goodness;
ulint best_last_op = 0; /* remove warning */ ulint best_last_op = 0; /* remove warning */
ulint mix_id_pos;
que_node_t* index_plan[256]; que_node_t* index_plan[256];
que_node_t* best_index_plan[256]; que_node_t* best_index_plan[256];
...@@ -601,26 +591,6 @@ opt_search_plan_for_table( ...@@ -601,26 +591,6 @@ opt_search_plan_for_table(
plan->unique_search = FALSE; plan->unique_search = FALSE;
} }
if ((table->type != DICT_TABLE_ORDINARY)
&& (best_index->type & DICT_CLUSTERED)) {
plan->mixed_index = TRUE;
mix_id_pos = table->mix_len;
if (mix_id_pos < n_fields) {
/* We have to add the mix id as a (string) literal
expression to the tuple_exps */
plan->tuple_exps[mix_id_pos] =
sym_tab_add_str_lit(pars_sym_tab_global,
table->mix_id_buf,
table->mix_id_len);
}
} else {
plan->mixed_index = FALSE;
}
plan->old_vers_heap = NULL; plan->old_vers_heap = NULL;
btr_pcur_init(&(plan->pcur)); btr_pcur_init(&(plan->pcur));
...@@ -1055,7 +1025,6 @@ opt_clust_access( ...@@ -1055,7 +1025,6 @@ opt_clust_access(
dict_table_t* table; dict_table_t* table;
dict_index_t* clust_index; dict_index_t* clust_index;
dict_index_t* index; dict_index_t* index;
dfield_t* dfield;
mem_heap_t* heap; mem_heap_t* heap;
ulint n_fields; ulint n_fields;
ulint pos; ulint pos;
...@@ -1109,22 +1078,7 @@ opt_clust_access( ...@@ -1109,22 +1078,7 @@ opt_clust_access(
*(plan->clust_map + i) = pos; *(plan->clust_map + i) = pos;
ut_ad((pos != ULINT_UNDEFINED) ut_ad(pos != ULINT_UNDEFINED);
|| ((table->type == DICT_TABLE_CLUSTER_MEMBER)
&& (i == table->mix_len)));
}
if (table->type == DICT_TABLE_CLUSTER_MEMBER) {
/* Preset the mix id field to the mix id constant */
dfield = dtuple_get_nth_field(plan->clust_ref, table->mix_len);
dfield_set_data(dfield, mem_heap_alloc(heap,
table->mix_id_len),
table->mix_id_len);
ut_memcpy(dfield_get_data(dfield), table->mix_id_buf,
table->mix_id_len);
} }
} }
......
This diff is collapsed.
...@@ -15,6 +15,7 @@ Created 12/15/1997 Heikki Tuuri ...@@ -15,6 +15,7 @@ Created 12/15/1997 Heikki Tuuri
#include "mem0mem.h" #include "mem0mem.h"
#include "data0type.h" #include "data0type.h"
#include "data0data.h" #include "data0data.h"
#include "pars0grm.h"
#include "pars0pars.h" #include "pars0pars.h"
#include "que0que.h" #include "que0que.h"
#include "eval0eval.h" #include "eval0eval.h"
...@@ -165,6 +166,74 @@ sym_tab_add_str_lit( ...@@ -165,6 +166,74 @@ sym_tab_add_str_lit(
return(node); return(node);
} }
/**********************************************************************
Add a bound literal to a symbol table. */
sym_node_t*
sym_tab_add_bound_lit(
/*==================*/
/* out: symbol table node */
sym_tab_t* sym_tab, /* in: symbol table */
const char* name, /* in: name of bound literal */
ulint* lit_type) /* out: type of literal (PARS_*_LIT) */
{
sym_node_t* node;
pars_bound_lit_t* blit;
ulint len = 0;
blit = pars_info_get_bound_lit(sym_tab->info, name);
ut_a(blit);
node = mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t));
node->common.type = QUE_NODE_SYMBOL;
node->resolved = TRUE;
node->token_type = SYM_LIT;
node->indirection = NULL;
switch (blit->type) {
case DATA_FIXBINARY:
len = blit->length;
*lit_type = PARS_FIXBINARY_LIT;
break;
case DATA_BLOB:
*lit_type = PARS_BLOB_LIT;
break;
case DATA_VARCHAR:
*lit_type = PARS_STR_LIT;
break;
case DATA_INT:
ut_a(blit->length > 0);
ut_a(blit->length <= 8);
len = blit->length;
*lit_type = PARS_INT_LIT;
break;
default:
ut_error;
}
dtype_set(&(node->common.val.type), blit->type, blit->prtype, len, 0);
dfield_set_data(&(node->common.val), blit->address, blit->length);
node->common.val_buf_size = 0;
node->prefetch_buf = NULL;
node->cursor_def = NULL;
UT_LIST_ADD_LAST(sym_list, sym_tab->sym_list, node);
node->sym_table = sym_tab;
return(node);
}
/********************************************************************** /**********************************************************************
Adds an SQL null literal to a symbol table. */ Adds an SQL null literal to a symbol table. */
...@@ -220,7 +289,7 @@ sym_tab_add_id( ...@@ -220,7 +289,7 @@ sym_tab_add_id(
node->resolved = FALSE; node->resolved = FALSE;
node->indirection = NULL; node->indirection = NULL;
node->name = mem_heap_strdupl(sym_tab->heap, (char*) name, len + 1); node->name = mem_heap_strdupl(sym_tab->heap, (char*) name, len);
node->name_len = len; node->name_len = len;
UT_LIST_ADD_LAST(sym_list, sym_tab->sym_list, node); UT_LIST_ADD_LAST(sym_list, sym_tab->sym_list, node);
......
...@@ -25,6 +25,7 @@ Created 5/27/1996 Heikki Tuuri ...@@ -25,6 +25,7 @@ Created 5/27/1996 Heikki Tuuri
#include "log0log.h" #include "log0log.h"
#include "eval0proc.h" #include "eval0proc.h"
#include "eval0eval.h" #include "eval0eval.h"
#include "pars0types.h"
#define QUE_PARALLELIZE_LIMIT (64 * 256 * 256 * 256) #define QUE_PARALLELIZE_LIMIT (64 * 256 * 256 * 256)
#define QUE_ROUND_ROBIN_LIMIT (64 * 256 * 256 * 256) #define QUE_ROUND_ROBIN_LIMIT (64 * 256 * 256 * 256)
...@@ -36,6 +37,50 @@ ibool que_trace_on = FALSE; ...@@ -36,6 +37,50 @@ ibool que_trace_on = FALSE;
ibool que_always_false = FALSE; ibool que_always_false = FALSE;
/* Short introduction to query graphs
==================================
A query graph consists of nodes linked to each other in various ways. The
execution starts at que_run_threads() which takes a que_thr_t parameter.
que_thr_t contains two fields that control query graph execution: run_node
and prev_node. run_node is the next node to execute and prev_node is the
last node executed.
Each node has a pointer to a 'next' statement, i.e., its brother, and a
pointer to its parent node. The next pointer is NULL in the last statement
of a block.
Loop nodes contain a link to the first statement of the enclosed statement
list. While the loop runs, que_thr_step() checks if execution to the loop
node came from its parent or from one of the statement nodes in the loop. If
it came from the parent of the loop node it starts executing the first
statement node in the loop. If it came from one of the statement nodes in
the loop, then it checks if the statement node has another statement node
following it, and runs it if so.
To signify loop ending, the loop statements (see e.g. while_step()) set
que_thr_t->run_node to the loop node's parent node. This is noticed on the
next call of que_thr_step() and execution proceeds to the node pointed to by
the loop node's 'next' pointer.
For example, the code:
X := 1;
WHILE X < 5 LOOP
X := X + 1;
X := X + 1;
X := 5
will result in the following node hierarchy, with the X-axis indicating
'next' links and the Y-axis indicating parent/child links:
A - W - A
|
|
A - A
A = assign_node_t, W = while_node_t. */
/* How a stored procedure containing COMMIT or ROLLBACK commands /* How a stored procedure containing COMMIT or ROLLBACK commands
is executed? is executed?
...@@ -128,6 +173,7 @@ que_fork_create( ...@@ -128,6 +173,7 @@ que_fork_create(
UT_LIST_INIT(fork->thrs); UT_LIST_INIT(fork->thrs);
fork->sym_tab = NULL; fork->sym_tab = NULL;
fork->info = NULL;
fork->heap = heap; fork->heap = heap;
...@@ -583,6 +629,7 @@ que_graph_free_recursive( ...@@ -583,6 +629,7 @@ que_graph_free_recursive(
break; break;
case QUE_NODE_ASSIGNMENT: case QUE_NODE_ASSIGNMENT:
case QUE_NODE_EXIT:
case QUE_NODE_RETURN: case QUE_NODE_RETURN:
case QUE_NODE_COMMIT: case QUE_NODE_COMMIT:
case QUE_NODE_ROLLBACK: case QUE_NODE_ROLLBACK:
...@@ -626,6 +673,10 @@ que_graph_free( ...@@ -626,6 +673,10 @@ que_graph_free(
sym_tab_free_private(graph->sym_tab); sym_tab_free_private(graph->sym_tab);
} }
if (graph->info && graph->info->graph_owns_us) {
pars_info_free(graph->info);
}
que_graph_free_recursive(graph); que_graph_free_recursive(graph);
mem_heap_free(graph->heap); mem_heap_free(graph->heap);
...@@ -1040,6 +1091,37 @@ que_thr_stop_for_mysql_no_error( ...@@ -1040,6 +1091,37 @@ que_thr_stop_for_mysql_no_error(
trx->n_active_thrs--; trx->n_active_thrs--;
} }
/********************************************************************
Get the first containing loop node (e.g. while_node_t or for_node_t) for the
given node, or NULL if the node is not within a loop. */
que_node_t*
que_node_get_containing_loop_node(
/*==============================*/
/* out: containing loop node, or NULL. */
que_node_t* node) /* in: node */
{
ut_ad(node);
for (;;) {
ulint type;
node = que_node_get_parent(node);
if (!node) {
break;
}
type = que_node_get_type(node);
if ((type == QUE_NODE_FOR) || (type == QUE_NODE_WHILE)) {
break;
}
}
return(node);
}
/************************************************************************** /**************************************************************************
Prints info of an SQL query graph node. */ Prints info of an SQL query graph node. */
...@@ -1093,6 +1175,8 @@ que_node_print_info( ...@@ -1093,6 +1175,8 @@ que_node_print_info(
str = "FOR LOOP"; str = "FOR LOOP";
} else if (type == QUE_NODE_RETURN) { } else if (type == QUE_NODE_RETURN) {
str = "RETURN"; str = "RETURN";
} else if (type == QUE_NODE_EXIT) {
str = "EXIT";
} else { } else {
str = "UNKNOWN NODE TYPE"; str = "UNKNOWN NODE TYPE";
} }
...@@ -1120,8 +1204,8 @@ que_thr_step( ...@@ -1120,8 +1204,8 @@ que_thr_step(
thr->resource++; thr->resource++;
type = que_node_get_type(thr->run_node);
node = thr->run_node; node = thr->run_node;
type = que_node_get_type(node);
old_thr = thr; old_thr = thr;
...@@ -1160,6 +1244,8 @@ que_thr_step( ...@@ -1160,6 +1244,8 @@ que_thr_step(
proc_step(thr); proc_step(thr);
} else if (type == QUE_NODE_WHILE) { } else if (type == QUE_NODE_WHILE) {
while_step(thr); while_step(thr);
} else {
ut_error;
} }
} else if (type == QUE_NODE_ASSIGNMENT) { } else if (type == QUE_NODE_ASSIGNMENT) {
assign_step(thr); assign_step(thr);
...@@ -1192,6 +1278,8 @@ que_thr_step( ...@@ -1192,6 +1278,8 @@ que_thr_step(
thr = row_purge_step(thr); thr = row_purge_step(thr);
} else if (type == QUE_NODE_RETURN) { } else if (type == QUE_NODE_RETURN) {
thr = return_step(thr); thr = return_step(thr);
} else if (type == QUE_NODE_EXIT) {
thr = exit_step(thr);
} else if (type == QUE_NODE_ROLLBACK) { } else if (type == QUE_NODE_ROLLBACK) {
thr = trx_rollback_step(thr); thr = trx_rollback_step(thr);
} else if (type == QUE_NODE_CREATE_TABLE) { } else if (type == QUE_NODE_CREATE_TABLE) {
...@@ -1204,7 +1292,11 @@ que_thr_step( ...@@ -1204,7 +1292,11 @@ que_thr_step(
ut_error; ut_error;
} }
if (type == QUE_NODE_EXIT) {
old_thr->prev_node = que_node_get_containing_loop_node(node);
} else {
old_thr->prev_node = node; old_thr->prev_node = node;
}
return(thr); return(thr);
} }
...@@ -1274,3 +1366,33 @@ loop: ...@@ -1274,3 +1366,33 @@ loop:
goto loop; goto loop;
} }
/*************************************************************************
Evaluate the given SQL */
ulint
que_eval_sql(
/*=========*/
pars_info_t* info, /* out: error code or DB_SUCCESS */
const char* sql, /* in: info struct, or NULL */
trx_t* trx) /* in: trx */
{
que_thr_t* thr;
que_t* graph;
graph = pars_sql(info, sql);
ut_a(graph);
graph->trx = trx;
trx->graph = NULL;
graph->fork_type = QUE_FORK_MYSQL_INTERFACE;
ut_a(thr = que_fork_start_command(graph));
que_run_threads(thr);
que_graph_free(graph);
return(trx->error_state);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -28,6 +28,7 @@ Created 12/27/1996 Heikki Tuuri ...@@ -28,6 +28,7 @@ Created 12/27/1996 Heikki Tuuri
#include "log0log.h" #include "log0log.h"
#include "pars0sym.h" #include "pars0sym.h"
#include "eval0eval.h" #include "eval0eval.h"
#include "buf0lru.h"
/* What kind of latch and lock can we assume when the control comes to /* What kind of latch and lock can we assume when the control comes to
...@@ -869,6 +870,10 @@ row_upd_index_replace_new_col_vals_index_pos( ...@@ -869,6 +870,10 @@ row_upd_index_replace_new_col_vals_index_pos(
upd_t* update, /* in: an update vector built for the index so upd_t* update, /* in: an update vector built for the index so
that the field number in an upd_field is the that the field number in an upd_field is the
index position */ index position */
ibool order_only,
/* in: if TRUE, limit the replacement to
ordering fields of index; note that this
does not work for non-clustered indexes. */
mem_heap_t* heap) /* in: memory heap to which we allocate and mem_heap_t* heap) /* in: memory heap to which we allocate and
copy the new values, set this as NULL if you copy the new values, set this as NULL if you
do not want allocation */ do not want allocation */
...@@ -879,13 +884,20 @@ row_upd_index_replace_new_col_vals_index_pos( ...@@ -879,13 +884,20 @@ row_upd_index_replace_new_col_vals_index_pos(
dfield_t* new_val; dfield_t* new_val;
ulint j; ulint j;
ulint i; ulint i;
ulint n_fields;
dtype_t* cur_type; dtype_t* cur_type;
ut_ad(index); ut_ad(index);
dtuple_set_info_bits(entry, update->info_bits); dtuple_set_info_bits(entry, update->info_bits);
for (j = 0; j < dict_index_get_n_fields(index); j++) { if (order_only) {
n_fields = dict_index_get_n_unique(index);
} else {
n_fields = dict_index_get_n_fields(index);
}
for (j = 0; j < n_fields; j++) {
field = dict_index_get_nth_field(index, j); field = dict_index_get_nth_field(index, j);
...@@ -1530,6 +1542,10 @@ row_upd_clust_rec( ...@@ -1530,6 +1542,10 @@ row_upd_clust_rec(
return(err); return(err);
} }
if (buf_LRU_buf_pool_running_out()) {
return(DB_LOCK_TABLE_FULL);
}
/* We may have to modify the tree structure: do a pessimistic descent /* We may have to modify the tree structure: do a pessimistic descent
down the index tree */ down the index tree */
......
...@@ -1713,6 +1713,8 @@ srv_printf_innodb_monitor( ...@@ -1713,6 +1713,8 @@ srv_printf_innodb_monitor(
"; in additional pool allocated " ULINTPF "\n", "; in additional pool allocated " ULINTPF "\n",
ut_total_allocated_memory, ut_total_allocated_memory,
mem_pool_get_reserved(mem_comm_pool)); mem_pool_get_reserved(mem_comm_pool));
fprintf(file, "Dictionary memory allocated " ULINTPF "\n",
dict_sys->size);
if (srv_use_awe) { if (srv_use_awe) {
fprintf(file, fprintf(file,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -366,8 +366,6 @@ trx_free_for_mysql( ...@@ -366,8 +366,6 @@ trx_free_for_mysql(
/*===============*/ /*===============*/
trx_t* trx) /* in, own: trx object */ trx_t* trx) /* in, own: trx object */
{ {
thr_local_free(trx->mysql_thread_id);
mutex_enter(&kernel_mutex); mutex_enter(&kernel_mutex);
UT_LIST_REMOVE(mysql_trx_list, trx_sys->mysql_trx_list, trx); UT_LIST_REMOVE(mysql_trx_list, trx_sys->mysql_trx_list, trx);
...@@ -1770,6 +1768,9 @@ trx_print( ...@@ -1770,6 +1768,9 @@ trx_print(
fprintf(f, "%lu lock struct(s), heap size %lu", fprintf(f, "%lu lock struct(s), heap size %lu",
(ulong) UT_LIST_GET_LEN(trx->trx_locks), (ulong) UT_LIST_GET_LEN(trx->trx_locks),
(ulong) mem_heap_get_size(trx->lock_heap)); (ulong) mem_heap_get_size(trx->lock_heap));
fprintf(f, "%lu row lock(s)",
(ulong) lock_number_of_rows_locked(trx));
} }
if (trx->has_search_latch) { if (trx->has_search_latch) {
......
...@@ -19,6 +19,6 @@ include ../include/Makefile.i ...@@ -19,6 +19,6 @@ include ../include/Makefile.i
noinst_LIBRARIES = libut.a noinst_LIBRARIES = libut.a
libut_a_SOURCES = ut0byte.c ut0dbg.c ut0mem.c ut0rnd.c ut0ut.c libut_a_SOURCES = ut0byte.c ut0dbg.c ut0mem.c ut0rnd.c ut0ut.c ut0vec.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
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