Skip to content

Commit e42c980

Browse files
Table definition cache, part 2
The table opening process now works the following way: - Create common TABLE_SHARE object - Read the .frm file and unpack it into the TABLE_SHARE object - Create a TABLE object based on the information in the TABLE_SHARE object and open a handler to the table object Other noteworthy changes: - In TABLE_SHARE the most common strings are now LEX_STRING's - Better error message when table is not found - Variable table_cache is now renamed 'table_open_cache' - New variable 'table_definition_cache' that is the number of table defintions that will be cached - strxnmov() calls are now fixed to avoid overflows - strxnmov() will now always add one end \0 to result - engine objects are now created with a TABLE_SHARE object instead of a TABLE object. - After creating a field object one must call field->init(table) before using it - For a busy system this change will give you: - Less memory usage for table object - Faster opening of tables (if it's has been in use or is in table definition cache) - Allow you to cache many table definitions objects - Faster drop of table
1 parent b167a66 commit e42c980

100 files changed

Lines changed: 3649 additions & 2115 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

mysql-test/mysql-test-run.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,16 +1320,16 @@ start_master()
13201320

13211321
if [ x$DO_DDD = x1 ]
13221322
then
1323-
$ECHO "set args $master_args" > $GDB_MASTER_INIT
1323+
$ECHO "set args $master_args" > $GDB_MASTER_INIT$1
13241324
manager_launch master ddd -display $DISPLAY --debugger \
1325-
"gdb -x $GDB_MASTER_INIT" $MASTER_MYSQLD
1325+
"gdb -x $GDB_MASTER_INIT$1" $MASTER_MYSQLD
13261326
elif [ x$DO_GDB = x1 ]
13271327
then
13281328
if [ x$MANUAL_GDB = x1 ]
13291329
then
1330-
$ECHO "set args $master_args" > $GDB_MASTER_INIT
1330+
$ECHO "set args $master_args" > $GDB_MASTER_INIT$1
13311331
$ECHO "To start gdb for the master , type in another window:"
1332-
$ECHO "cd $CWD ; gdb -x $GDB_MASTER_INIT $MASTER_MYSQLD"
1332+
$ECHO "cd $CWD ; gdb -x $GDB_MASTER_INIT$1 $MASTER_MYSQLD"
13331333
wait_for_master=1500
13341334
else
13351335
( $ECHO set args $master_args;
@@ -1341,9 +1341,9 @@ disa 1
13411341
end
13421342
r
13431343
EOF
1344-
fi ) > $GDB_MASTER_INIT
1344+
fi ) > $GDB_MASTER_INIT$1
13451345
manager_launch master $XTERM -display $DISPLAY \
1346-
-title "Master" -e gdb -x $GDB_MASTER_INIT $MASTER_MYSQLD
1346+
-title "Master" -e gdb -x $GDB_MASTER_INIT$1 $MASTER_MYSQLD
13471347
fi
13481348
else
13491349
manager_launch master $MASTER_MYSQLD $master_args
@@ -1965,10 +1965,10 @@ then
19651965
$MYSQLADMIN --no-defaults --socket=$MASTER_MYSOCK -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
19661966
$MYSQLADMIN --no-defaults --socket=$MASTER_MYSOCK1 -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
19671967
$MYSQLADMIN --no-defaults --socket=$SLAVE_MYSOCK -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
1968-
$MYSQLADMIN --no-defaults --host=$hostname --port=$MASTER_MYPORT -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
1969-
$MYSQLADMIN --no-defaults --host=$hostname --port=`expr $MASTER_MYPORT+1` -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
1970-
$MYSQLADMIN --no-defaults --host=$hostname --port=$SLAVE_MYPORT -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
1971-
$MYSQLADMIN --no-defaults --host=$hostname --port=`expr $SLAVE_MYPORT + 1` -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
1968+
$MYSQLADMIN --no-defaults --host=$hostname --port=$MASTER_MYPORT --protocol=tcp -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
1969+
$MYSQLADMIN --no-defaults --host=$hostname --protocol=tcp --port=`expr $MASTER_MYPORT+1` -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
1970+
$MYSQLADMIN --no-defaults --host=$hostname --protocol=tcp --port=$SLAVE_MYPORT -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
1971+
$MYSQLADMIN --no-defaults --host=$hostname --protocol=tcp --port=`expr $SLAVE_MYPORT + 1` -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
19721972
sleep_until_file_deleted 0 $MASTER_MYPID
19731973
sleep_until_file_deleted 0 $MASTER_MYPID"1"
19741974
sleep_until_file_deleted 0 $SLAVE_MYPID

mysql-test/r/flush_table.result

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,37 @@ flush table t1;
66
check table t1;
77
Table Op Msg_type Msg_text
88
test.t1 check status OK
9+
unlock tables;
10+
lock table t1 read;
11+
lock table t1 read;
12+
flush table t1;
13+
select * from t1;
14+
a
15+
1
16+
unlock tables;
17+
select * from t1;
18+
a
19+
1
20+
unlock tables;
21+
lock table t1 write;
22+
lock table t1 read;
23+
flush table t1;
24+
select * from t1;
25+
a
26+
1
27+
unlock tables;
28+
unlock tables;
29+
lock table t1 read;
30+
lock table t1 write;
31+
flush table t1;
32+
select * from t1;
33+
a
34+
1
35+
unlock tables;
36+
unlock tables;
37+
select * from t1;
38+
a
39+
1
940
drop table t1;
1041
create table t1(table_id char(20) primary key);
1142
create table t2(table_id char(20) primary key);

mysql-test/r/information_schema.result

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,6 @@ select s1 from t1 where s1 in (select version from
486486
information_schema.tables) union select version from
487487
information_schema.tables;
488488
s1
489-
0
490489
10
491490
drop table t1;
492491
SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;

mysql-test/r/innodb.result

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ t2 CREATE TABLE `t2` (
16151615
) ENGINE=InnoDB DEFAULT CHARSET=latin1
16161616
drop table t2;
16171617
create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
1618-
ERROR HY000: Can't create table './test/t2' (errno: 150)
1618+
ERROR HY000: Can't create table 'test.t2' (errno: 150)
16191619
create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb;
16201620
show create table t2;
16211621
Table Create Table
@@ -2437,7 +2437,7 @@ a b
24372437
20 NULL
24382438
drop table t1;
24392439
create table t1 (v varchar(65530), key(v));
2440-
ERROR HY000: Can't create table './test/t1' (errno: 139)
2440+
ERROR HY000: Can't create table 'test.t1' (errno: 139)
24412441
create table t1 (v varchar(65536));
24422442
Warnings:
24432443
Note 1246 Converting column 'v' from VARCHAR to TEXT
@@ -2580,19 +2580,19 @@ character set = latin1 engine = innodb;
25802580
drop table t1, t2, t3, t4, t5, t6, t7, t8, t9;
25812581
create table t1 (col1 varchar(768), index (col1))
25822582
character set = latin1 engine = innodb;
2583-
ERROR HY000: Can't create table './test/t1.frm' (errno: 139)
2583+
ERROR HY000: Can't create table 'test.t1' (errno: 139)
25842584
create table t2 (col1 varchar(768) primary key)
25852585
character set = latin1 engine = innodb;
2586-
ERROR HY000: Can't create table './test/t2.frm' (errno: 139)
2586+
ERROR HY000: Can't create table 'test.t2' (errno: 139)
25872587
create table t3 (col1 varbinary(768) primary key)
25882588
character set = latin1 engine = innodb;
2589-
ERROR HY000: Can't create table './test/t3.frm' (errno: 139)
2589+
ERROR HY000: Can't create table 'test.t3' (errno: 139)
25902590
create table t4 (col1 text, index(col1(768)))
25912591
character set = latin1 engine = innodb;
2592-
ERROR HY000: Can't create table './test/t4.frm' (errno: 139)
2592+
ERROR HY000: Can't create table 'test.t4' (errno: 139)
25932593
create table t5 (col1 blob, index(col1(768)))
25942594
character set = latin1 engine = innodb;
2595-
ERROR HY000: Can't create table './test/t5.frm' (errno: 139)
2595+
ERROR HY000: Can't create table 'test.t5' (errno: 139)
25962596
CREATE TABLE t1
25972597
(
25982598
id INT PRIMARY KEY

mysql-test/r/merge.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ select * from t4;
181181
ERROR HY000: All tables in the MERGE table are not identically defined
182182
alter table t4 add column c int;
183183
ERROR HY000: All tables in the MERGE table are not identically defined
184+
flush tables;
185+
select * from t4;
186+
ERROR HY000: All tables in the MERGE table are not identically defined
184187
create database mysqltest;
185188
create table mysqltest.t6 (a int not null primary key auto_increment, message char(20));
186189
create table t5 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,mysqltest.t6);

mysql-test/r/ndb_bitfield.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,18 @@ create table t1 (
201201
pk1 bit(9) not null primary key,
202202
b int
203203
) engine=ndbcluster;
204-
ERROR HY000: Can't create table './test/t1.frm' (errno: 140)
204+
ERROR HY000: Can't create table 'test.t1' (errno: 140)
205205
show warnings;
206206
Level Code Message
207207
Error 1296 Got error 739 'Unsupported primary key length' from NDB
208-
Error 1005 Can't create table './test/t1.frm' (errno: 140)
208+
Error 1005 Can't create table 'test.t1' (errno: 140)
209209
create table t1 (
210210
pk1 int not null primary key,
211211
b bit(9),
212212
key(b)
213213
) engine=ndbcluster;
214-
ERROR HY000: Can't create table './test/t1.frm' (errno: 140)
214+
ERROR HY000: Can't create table 'test.t1' (errno: 140)
215215
show warnings;
216216
Level Code Message
217217
Error 1296 Got error 743 'Unsupported character set in table or index' from NDB
218-
Error 1005 Can't create table './test/t1.frm' (errno: 140)
218+
Error 1005 Can't create table 'test.t1' (errno: 140)

mysql-test/r/ndb_partition_error.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ partitions 3
1111
(partition x1 values less than (5) nodegroup 12,
1212
partition x2 values less than (10) nodegroup 13,
1313
partition x3 values less than (20) nodegroup 14);
14-
ERROR HY000: Can't create table './test/t1.frm' (errno: 140)
14+
ERROR HY000: Can't create table 'test.t1' (errno: 140)
1515
show warnings;
1616
Level Code Message
1717
Error 1296 Got error 771 'Given NODEGROUP doesn't exist in this cluster' from NDB
18-
Error 1005 Can't create table './test/t1.frm' (errno: 140)
18+
Error 1005 Can't create table 'test.t1' (errno: 140)
1919
CREATE TABLE t1 (
2020
a int not null,
2121
b int not null,

mysql-test/r/query_cache.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ reset query cache;
55
flush status;
66
drop table if exists t1,t2,t3,t4,t11,t21;
77
drop database if exists mysqltest;
8+
drop table if exists ```a`;
9+
drop view if exists v1;
810
create table t1 (a int not null);
911
insert into t1 values (1),(2),(3);
1012
select * from t1;

mysql-test/r/temp_table.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,14 @@ d c
135135
bar 2
136136
foo 1
137137
drop table t1, t2;
138+
create temporary table t1 (a int);
139+
insert into t1 values (4711);
140+
select * from t1;
141+
a
142+
4711
143+
truncate t1;
144+
insert into t1 values (42);
145+
select * from t1;
146+
a
147+
42
148+
drop table t1;

mysql-test/r/variables.result

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ set sql_quote_show_create=1;
376376
set sql_safe_updates=1;
377377
set sql_select_limit=1;
378378
set sql_warnings=1;
379-
set global table_cache=100;
379+
set global table_open_cache=100;
380380
set storage_engine=myisam;
381381
set global thread_cache_size=100;
382382
set timestamp=1, timestamp=default;
@@ -508,11 +508,11 @@ SET GLOBAL MYISAM_DATA_POINTER_SIZE= 7;
508508
SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
509509
Variable_name Value
510510
myisam_data_pointer_size 7
511-
SET GLOBAL table_cache=-1;
512-
SHOW VARIABLES LIKE 'table_cache';
511+
SET GLOBAL table_open_cache=-1;
512+
SHOW VARIABLES LIKE 'table_open_cache';
513513
Variable_name Value
514-
table_cache 1
515-
SET GLOBAL table_cache=DEFAULT;
514+
table_open_cache 1
515+
SET GLOBAL table_open_cache=DEFAULT;
516516
set character_set_results=NULL;
517517
select ifnull(@@character_set_results,"really null");
518518
ifnull(@@character_set_results,"really null")

0 commit comments

Comments
 (0)