List:Commits« Previous MessageNext Message »
From:Gopal Shankar Date:November 13 2012 12:27pm
Subject:bzr push into mysql-trunk branch (gopal.shankar:4970 to 4971) WL#6379
View as plain text  
 4971 Gopal Shankar	2012-11-13
      WL#6379 - Schema definitions for new DD
      
      Prototype 1 
      
      This patch stores table KEY and KEY_PART info in new DD, i.e.,
      
       mysql.table_keys - To store metadata of user table keys.
       mysql.table_key_parts - To store metadata of user table key parts.

    modified:
      mysql-test/r/key_cache.result
      mysql-test/r/mysqlbinlog.result
      mysql-test/r/mysqlcheck.result
      mysql-test/r/partition_explicit_prune.result
      mysql-test/r/partition_locking.result
      mysql-test/r/show_check.result
      mysql-test/suite/binlog/r/binlog_stm_row.result
      mysql-test/suite/funcs_1/r/is_columns_mysql.result
      mysql-test/suite/funcs_1/r/is_tables_mysql.result
      mysql-test/suite/perfschema/r/binlog_edge_stmt.result
      mysql-test/suite/perfschema/r/binlog_ok_mix.result
      mysql-test/suite/perfschema/r/binlog_ok_stmt.result
      mysql-test/suite/perfschema/r/no_threads.result
      mysql-test/suite/perfschema/r/one_thread_per_con.result
      mysql-test/suite/rpl/r/rpl_ignore_db_filter.result
      mysql-test/suite/rpl/r/rpl_rewrite_db_filter.result
      scripts/mysql_system_tables.sql
      sql/datadict.cc
      sql/datadict0.h
      sql/sql_table.cc
 4970 Gopal Shankar	2012-11-13
      WL6379 - Schema definitions for new DD
      
      Prototype 1
      - A bit of code reorg

    added:
      sql/datadict0.h
    modified:
      sql/datadict.cc
      sql/datadict.h
      sql/sql_table.cc
=== modified file 'mysql-test/r/key_cache.result'
--- a/mysql-test/r/key_cache.result	2012-11-07 10:05:17 +0000
+++ b/mysql-test/r/key_cache.result	2012-11-13 12:21:34 +0000
@@ -87,10 +87,10 @@ create table t1 (p int primary key, a ch
 create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a));
 show status like 'key_blocks_used';
 Variable_name	Value
-Key_blocks_used	0
+Key_blocks_used	2
 show status like 'key_blocks_unused';
 Variable_name	Value
-Key_blocks_unused	KEY_BLOCKS_UNUSED
+Key_blocks_unused	1672
 insert into t1 values (1, 'qqqq'), (11, 'yyyy');
 insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
 (3, 1, 'yyyy'), (4, 3, 'zzzz');
@@ -108,10 +108,10 @@ update t1 set p=2 where p=1;
 update t2 set i=2 where i=1;
 show status like 'key_blocks_used';
 Variable_name	Value
-Key_blocks_used	4
+Key_blocks_used	6
 show status like 'key_blocks_unused';
 Variable_name	Value
-Key_blocks_unused	KEY_BLOCKS_UNUSED
+Key_blocks_unused	1668
 cache index t1 key (`primary`) in keycache1;
 Table	Op	Msg_type	Msg_text
 test.t1	assign_to_keycache	status	OK
@@ -270,10 +270,10 @@ test.t2	assign_to_keycache	status	OK
 drop table t1,t2,t3;
 show status like 'key_blocks_used';
 Variable_name	Value
-Key_blocks_used	4
+Key_blocks_used	6
 show status like 'key_blocks_unused';
 Variable_name	Value
-Key_blocks_unused	KEY_BLOCKS_UNUSED
+Key_blocks_unused	1672
 create table t1 (a int primary key);
 cache index t1 in keycache2;
 Table	Op	Msg_type	Msg_text

=== modified file 'mysql-test/r/mysqlbinlog.result'
--- a/mysql-test/r/mysqlbinlog.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/r/mysqlbinlog.result	2012-11-13 12:21:34 +0000
@@ -874,11 +874,11 @@ FLUSH LOGS;
 include/show_binlog_events.inc
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000002	#	Query	#	#	CREATE DATABASE test1
-master-bin.000002	#	Intvar	#	#	INSERT_ID=93
+master-bin.000002	#	Intvar	#	#	INSERT_ID=94
 master-bin.000002	#	Query	#	#	use `test1`; CREATE TABLE t1(id int)
 master-bin.000002	#	Query	#	#	DROP DATABASE test1
 master-bin.000002	#	Query	#	#	CREATE DATABASE test1
-master-bin.000002	#	Intvar	#	#	INSERT_ID=94
+master-bin.000002	#	Intvar	#	#	INSERT_ID=95
 master-bin.000002	#	Query	#	#	use `test1`; CREATE TABLE t1(id int)
 master-bin.000002	#	Query	#	#	use `test1`; DROP TABLE `t1` /* generated by server */
 master-bin.000002	#	Query	#	#	DROP DATABASE test1

=== modified file 'mysql-test/r/mysqlcheck.result'
--- a/mysql-test/r/mysqlcheck.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/r/mysqlcheck.result	2012-11-13 12:21:34 +0000
@@ -151,8 +151,8 @@ note     : Table does not support optimi
 status   : OK
 mysql.slow_log
 note     : The storage engine for the table doesn't support optimize
-mysql.table_key_parts                              Table is already up to date
-mysql.table_keys                                   Table is already up to date
+mysql.table_key_parts                              OK
+mysql.table_keys                                   OK
 mysql.tables                                       OK
 mysql.tables_priv                                  Table is already up to date
 mysql.time_zone                                    Table is already up to date

=== modified file 'mysql-test/r/partition_explicit_prune.result'
--- a/mysql-test/r/partition_explicit_prune.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/r/partition_explicit_prune.result	2012-11-13 12:21:34 +0000
@@ -1173,7 +1173,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION
 WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0;
 VARIABLE_NAME	VARIABLE_VALUE
 HANDLER_COMMIT	1
-HANDLER_EXTERNAL_LOCK	18
+HANDLER_EXTERNAL_LOCK	22
 HANDLER_READ_FIRST	5
 HANDLER_READ_KEY	5
 HANDLER_READ_NEXT	7

=== modified file 'mysql-test/r/partition_locking.result'
--- a/mysql-test/r/partition_locking.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/r/partition_locking.result	2012-11-13 12:21:34 +0000
@@ -3378,7 +3378,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION
 WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0;
 VARIABLE_NAME	VARIABLE_VALUE
 HANDLER_COMMIT	1
-HANDLER_EXTERNAL_LOCK	14
+HANDLER_EXTERNAL_LOCK	18
 HANDLER_READ_FIRST	3
 HANDLER_READ_KEY	3
 HANDLER_READ_NEXT	12
@@ -3396,7 +3396,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION
 WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0;
 VARIABLE_NAME	VARIABLE_VALUE
 HANDLER_COMMIT	1
-HANDLER_EXTERNAL_LOCK	34
+HANDLER_EXTERNAL_LOCK	38
 HANDLER_READ_KEY	13
 HANDLER_READ_NEXT	5
 HANDLER_WRITE	25
@@ -5303,7 +5303,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION
 WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0;
 VARIABLE_NAME	VARIABLE_VALUE
 HANDLER_COMMIT	1
-HANDLER_EXTERNAL_LOCK	12
+HANDLER_EXTERNAL_LOCK	16
 HANDLER_READ_FIRST	2
 HANDLER_READ_KEY	2
 HANDLER_READ_RND_NEXT	6
@@ -5322,7 +5322,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION
 WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0;
 VARIABLE_NAME	VARIABLE_VALUE
 HANDLER_COMMIT	1
-HANDLER_EXTERNAL_LOCK	12
+HANDLER_EXTERNAL_LOCK	16
 HANDLER_READ_FIRST	2
 HANDLER_READ_KEY	2
 HANDLER_READ_RND_NEXT	6

=== modified file 'mysql-test/r/show_check.result'
--- a/mysql-test/r/show_check.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/r/show_check.result	2012-11-13 12:21:34 +0000
@@ -260,9 +260,11 @@ insert into t1 values (1);
 show open tables;
 Database	Table	In_use	Name_locked
 mysql	tables	0	0
-mysql	general_log	0	0
-test	t1	0	0
 mysql	fields	0	0
+test	t1	0	0
+mysql	table_keys	0	0
+mysql	general_log	0	0
+mysql	table_key_parts	0	0
 drop table t1;
 create table t1 (a int not null, b VARCHAR(10), INDEX (b) ) AVG_ROW_LENGTH=10 CHECKSUM=1 COMMENT="test" ENGINE=MYISAM MIN_ROWS=10 MAX_ROWS=100 PACK_KEYS=1 DELAY_KEY_WRITE=1 ROW_FORMAT=fixed;
 show create table t1;

=== modified file 'mysql-test/suite/binlog/r/binlog_stm_row.result'
--- a/mysql-test/suite/binlog/r/binlog_stm_row.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/suite/binlog/r/binlog_stm_row.result	2012-11-13 12:21:34 +0000
@@ -61,9 +61,9 @@ include/show_binlog_events.inc
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `t2` /* generated by server */
-master-bin.000001	#	Intvar	#	#	INSERT_ID=83
+master-bin.000001	#	Intvar	#	#	INSERT_ID=88
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
-master-bin.000001	#	Intvar	#	#	INSERT_ID=84
+master-bin.000001	#	Intvar	#	#	INSERT_ID=89
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t2 LIKE t1
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES(1)

=== modified file 'mysql-test/suite/funcs_1/r/is_columns_mysql.result'
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result	2012-11-13 12:21:34 +0000
@@ -248,16 +248,15 @@ def	mysql	tables_priv	Timestamp	6	CURREN
 def	mysql	tables_priv	User	3		NO	char	16	48	NULL	NULL	NULL	utf8	utf8_bin	char(16)	PRI		select,insert,update,references	
 def	mysql	table_keys	algorithm	7	NULL	YES	smallint	NULL	NULL	5	0	NULL	NULL	NULL	smallint(6)			select,insert,update,references	
 def	mysql	table_keys	block_size	8	NULL	YES	smallint	NULL	NULL	5	0	NULL	NULL	NULL	smallint(6)			select,insert,update,references	
-def	mysql	table_keys	comment	11	NULL	YES	text	65535	65535	NULL	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	table_keys	comment	10	NULL	YES	text	65535	65535	NULL	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
 def	mysql	table_keys	flags	4	NULL	YES	smallint	NULL	NULL	5	0	NULL	NULL	NULL	smallint(6)			select,insert,update,references	
 def	mysql	table_keys	id	1	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	NULL	int(10) unsigned	PRI	auto_increment	select,insert,update,references	
 def	mysql	table_keys	key_length	6	NULL	YES	smallint	NULL	NULL	5	0	NULL	NULL	NULL	smallint(6)			select,insert,update,references	
 def	mysql	table_keys	key_parts	5	NULL	YES	smallint	NULL	NULL	5	0	NULL	NULL	NULL	smallint(6)			select,insert,update,references	
 def	mysql	table_keys	name	3	NULL	YES	char	64	192	NULL	NULL	NULL	utf8	utf8_bin	char(64)			select,insert,update,references	
-def	mysql	table_keys	parser	10	NULL	YES	text	65535	65535	NULL	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	table_keys	parser	9	NULL	YES	text	65535	65535	NULL	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
 def	mysql	table_keys	table_id	2	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	NULL	int(10) unsigned			select,insert,update,references	
-def	mysql	table_keys	user_defined_key_parts	9	NULL	YES	int	NULL	NULL	10	0	NULL	NULL	NULL	int(11)			select,insert,update,references	
-def	mysql	table_key_parts	field_nr	2	NULL	NO	smallint	NULL	NULL	5	0	NULL	NULL	NULL	smallint(6)			select,insert,update,references	
+def	mysql	table_key_parts	field_nr	2	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	NULL	int(10) unsigned			select,insert,update,references	
 def	mysql	table_key_parts	key_id	1	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	NULL	int(10) unsigned			select,insert,update,references	
 def	mysql	table_key_parts	key_part_flag	6	NULL	YES	smallint	NULL	NULL	5	0	NULL	NULL	NULL	smallint(6)			select,insert,update,references	
 def	mysql	table_key_parts	key_type	5	NULL	YES	smallint	NULL	NULL	5	0	NULL	NULL	NULL	smallint(6)			select,insert,update,references	
@@ -644,11 +643,10 @@ NULL	mysql	table_keys	key_parts	smallint
 NULL	mysql	table_keys	key_length	smallint	NULL	NULL	NULL	NULL	smallint(6)
 NULL	mysql	table_keys	algorithm	smallint	NULL	NULL	NULL	NULL	smallint(6)
 NULL	mysql	table_keys	block_size	smallint	NULL	NULL	NULL	NULL	smallint(6)
-NULL	mysql	table_keys	user_defined_key_parts	int	NULL	NULL	NULL	NULL	int(11)
 1.0000	mysql	table_keys	parser	text	65535	65535	utf8	utf8_bin	text
 1.0000	mysql	table_keys	comment	text	65535	65535	utf8	utf8_bin	text
 NULL	mysql	table_key_parts	key_id	int	NULL	NULL	NULL	NULL	int(10) unsigned
-NULL	mysql	table_key_parts	field_nr	smallint	NULL	NULL	NULL	NULL	smallint(6)
+NULL	mysql	table_key_parts	field_nr	int	NULL	NULL	NULL	NULL	int(10) unsigned
 NULL	mysql	table_key_parts	length	smallint	NULL	NULL	NULL	NULL	smallint(6)
 NULL	mysql	table_key_parts	record_offset	smallint	NULL	NULL	NULL	NULL	smallint(6)
 NULL	mysql	table_key_parts	key_type	smallint	NULL	NULL	NULL	NULL	smallint(6)

=== modified file 'mysql-test/suite/funcs_1/r/is_tables_mysql.result'
--- a/mysql-test/suite/funcs_1/r/is_tables_mysql.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/suite/funcs_1/r/is_tables_mysql.result	2012-11-13 12:21:34 +0000
@@ -577,7 +577,7 @@ DATA_LENGTH	#DL#
 MAX_DATA_LENGTH	#MDL#
 INDEX_LENGTH	#IL#
 DATA_FREE	#DF#
-AUTO_INCREMENT	1
+AUTO_INCREMENT	34
 CREATE_TIME	#CRT#
 UPDATE_TIME	#UT#
 CHECK_TIME	#CT#

=== modified file 'mysql-test/suite/perfschema/r/binlog_edge_stmt.result'
--- a/mysql-test/suite/perfschema/r/binlog_edge_stmt.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/suite/perfschema/r/binlog_edge_stmt.result	2012-11-13 12:21:34 +0000
@@ -163,11 +163,11 @@ include/show_binlog_events.inc
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	drop database if exists my_replicated_db
 master-bin.000001	#	Query	#	#	create database my_replicated_db
-master-bin.000001	#	Intvar	#	#	INSERT_ID=86
+master-bin.000001	#	Intvar	#	#	INSERT_ID=83
 master-bin.000001	#	Query	#	#	use `test`; create table my_replicated_db.my_tx_table(a bigint) engine = innodb
-master-bin.000001	#	Intvar	#	#	INSERT_ID=87
+master-bin.000001	#	Intvar	#	#	INSERT_ID=84
 master-bin.000001	#	Query	#	#	use `test`; create table my_replicated_db.my_non_tx_table(a bigint) engine = myisam
-master-bin.000001	#	Intvar	#	#	INSERT_ID=88
+master-bin.000001	#	Intvar	#	#	INSERT_ID=85
 master-bin.000001	#	Query	#	#	use `test`; create table my_replicated_db.my_bh_table(a bigint) engine = blackhole
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `marker_start` /* generated by server */
 master-bin.000001	#	Query	#	#	BEGIN

=== modified file 'mysql-test/suite/perfschema/r/binlog_ok_mix.result'
--- a/mysql-test/suite/perfschema/r/binlog_ok_mix.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/suite/perfschema/r/binlog_ok_mix.result	2012-11-13 12:21:34 +0000
@@ -108,9 +108,9 @@ Note	1051	Unknown table 'test.marker_end
 drop database my_local_db;
 include/show_binlog_events.inc
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Intvar	#	#	INSERT_ID=89
+master-bin.000001	#	Intvar	#	#	INSERT_ID=86
 master-bin.000001	#	Query	#	#	use `test`; create table my_local_db.my_tx_table(a bigint) engine = innodb
-master-bin.000001	#	Intvar	#	#	INSERT_ID=90
+master-bin.000001	#	Intvar	#	#	INSERT_ID=87
 master-bin.000001	#	Query	#	#	use `test`; create table my_local_db.my_non_tx_table(a bigint) engine = myisam
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `marker_start` /* generated by server */
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `marker_truncate` /* generated by server */

=== modified file 'mysql-test/suite/perfschema/r/binlog_ok_stmt.result'
--- a/mysql-test/suite/perfschema/r/binlog_ok_stmt.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/suite/perfschema/r/binlog_ok_stmt.result	2012-11-13 12:21:34 +0000
@@ -108,9 +108,9 @@ Note	1051	Unknown table 'test.marker_end
 drop database my_local_db;
 include/show_binlog_events.inc
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Intvar	#	#	INSERT_ID=91
+master-bin.000001	#	Intvar	#	#	INSERT_ID=88
 master-bin.000001	#	Query	#	#	use `test`; create table my_local_db.my_tx_table(a bigint) engine = innodb
-master-bin.000001	#	Intvar	#	#	INSERT_ID=92
+master-bin.000001	#	Intvar	#	#	INSERT_ID=89
 master-bin.000001	#	Query	#	#	use `test`; create table my_local_db.my_non_tx_table(a bigint) engine = myisam
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `marker_start` /* generated by server */
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `marker_truncate` /* generated by server */

=== modified file 'mysql-test/suite/perfschema/r/no_threads.result'
--- a/mysql-test/suite/perfschema/r/no_threads.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/suite/perfschema/r/no_threads.result	2012-11-13 12:21:34 +0000
@@ -37,6 +37,8 @@ event_name	operation	short_source
 wait/synch/mutex/mysys/THR_LOCK_myisam	lock	mi_create.c:
 wait/synch/mutex/mysys/THR_LOCK_myisam	lock	mi_open.c:
 wait/synch/mutex/mysys/THR_LOCK_myisam	lock	mi_open.c:
+wait/synch/mutex/mysys/THR_LOCK_myisam	lock	mi_open.c:
+wait/synch/mutex/mysys/THR_LOCK_myisam	lock	mi_open.c:
 select event_name, operation,
 left(source, locate(":", source)) as short_source
 from performance_schema.events_waits_history_long;
@@ -44,5 +46,7 @@ event_name	operation	short_source
 wait/synch/mutex/mysys/THR_LOCK_myisam	lock	mi_create.c:
 wait/synch/mutex/mysys/THR_LOCK_myisam	lock	mi_open.c:
 wait/synch/mutex/mysys/THR_LOCK_myisam	lock	mi_open.c:
+wait/synch/mutex/mysys/THR_LOCK_myisam	lock	mi_open.c:
+wait/synch/mutex/mysys/THR_LOCK_myisam	lock	mi_open.c:
 update performance_schema.setup_instruments set enabled='YES';
 drop table test.t1;

=== modified file 'mysql-test/suite/perfschema/r/one_thread_per_con.result'
--- a/mysql-test/suite/perfschema/r/one_thread_per_con.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/suite/perfschema/r/one_thread_per_con.result	2012-11-13 12:21:34 +0000
@@ -19,6 +19,8 @@ event_name	short_source	operation	number
 wait/synch/mutex/mysys/THR_LOCK_myisam	mi_create.c:	lock	NULL
 wait/synch/mutex/mysys/THR_LOCK_myisam	mi_open.c:	lock	NULL
 wait/synch/mutex/mysys/THR_LOCK_myisam	mi_open.c:	lock	NULL
+wait/synch/mutex/mysys/THR_LOCK_myisam	mi_open.c:	lock	NULL
+wait/synch/mutex/mysys/THR_LOCK_myisam	mi_open.c:	lock	NULL
 execute stmt_dump_thread using @tid;
 name
 thread/sql/one_connection

=== modified file 'mysql-test/suite/rpl/r/rpl_ignore_db_filter.result'
--- a/mysql-test/suite/rpl/r/rpl_ignore_db_filter.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/suite/rpl/r/rpl_ignore_db_filter.result	2012-11-13 12:21:34 +0000
@@ -13,9 +13,9 @@ INSERT INTO t2 VALUES (1);
 include/show_binlog_events.inc
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	CREATE DATABASE mydb
-master-bin.000001	#	Intvar	#	#	INSERT_ID=85
+master-bin.000001	#	Intvar	#	#	INSERT_ID=83
 master-bin.000001	#	Query	#	#	use `mydb`; CREATE TABLE T1 (a INT) ENGINE= MYISAM
-master-bin.000001	#	Intvar	#	#	INSERT_ID=86
+master-bin.000001	#	Intvar	#	#	INSERT_ID=84
 master-bin.000001	#	Query	#	#	use `mydb`; CREATE TABLE t2 (a INT) ENGINE= MYISAM
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `mydb`; INSERT INTO T1 VALUES (1)

=== modified file 'mysql-test/suite/rpl/r/rpl_rewrite_db_filter.result'
--- a/mysql-test/suite/rpl/r/rpl_rewrite_db_filter.result	2012-11-12 08:00:23 +0000
+++ b/mysql-test/suite/rpl/r/rpl_rewrite_db_filter.result	2012-11-13 12:21:34 +0000
@@ -14,9 +14,9 @@ INSERT INTO t2 VALUES (1);
 include/show_binlog_events.inc
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	CREATE DATABASE mydb
-master-bin.000001	#	Intvar	#	#	INSERT_ID=87
+master-bin.000001	#	Intvar	#	#	INSERT_ID=85
 master-bin.000001	#	Query	#	#	use `mydb`; CREATE TABLE T1 (a INT) ENGINE= MYISAM
-master-bin.000001	#	Intvar	#	#	INSERT_ID=88
+master-bin.000001	#	Intvar	#	#	INSERT_ID=86
 master-bin.000001	#	Query	#	#	use `mydb`; CREATE TABLE t2 (a INT) ENGINE= MYISAM
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `mydb`; INSERT INTO T1 VALUES (1)
@@ -29,9 +29,9 @@ include/show_binlog_events.inc
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000001	#	Query	#	#	CREATE DATABASE rewrite
 slave-bin.000001	#	Query	#	#	CREATE DATABASE mydb
-slave-bin.000001	#	Intvar	#	#	INSERT_ID=87
+slave-bin.000001	#	Intvar	#	#	INSERT_ID=85
 slave-bin.000001	#	Query	#	#	use `rewrite`; CREATE TABLE T1 (a INT) ENGINE= MYISAM
-slave-bin.000001	#	Intvar	#	#	INSERT_ID=88
+slave-bin.000001	#	Intvar	#	#	INSERT_ID=86
 slave-bin.000001	#	Query	#	#	use `rewrite`; CREATE TABLE t2 (a INT) ENGINE= MYISAM
 slave-bin.000001	#	Query	#	#	BEGIN
 slave-bin.000001	#	Query	#	#	use `rewrite`; INSERT INTO T1 VALUES (1)

=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql	2012-11-12 08:00:23 +0000
+++ b/scripts/mysql_system_tables.sql	2012-11-13 12:21:34 +0000
@@ -24,9 +24,9 @@ CREATE TABLE IF NOT EXISTS tables (db ch
 
 CREATE TABLE IF NOT EXISTS fields (table_id INT UNSIGNED NOT NULL, name char(64) NOT NULL, type SMALLINT, field_length SMALLINT, unireg_type TINYINT(1), recpos INT, pack_flag INT, csid SMALLINT, comment text, intervals text, interval_parts SMALLINT, flags SMALLINT) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
 
-CREATE TABLE IF NOT EXISTS table_keys (id INT UNSIGNED NOT NULL auto_increment, table_id INT UNSIGNED NOT NULL, name char(64), flags SMALLINT, key_parts SMALLINT, key_length SMALLINT, algorithm SMALLINT, block_size SMALLINT, user_defined_key_parts INT, parser text, comment text, PRIMARY KEY (id)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+CREATE TABLE IF NOT EXISTS table_keys (id INT UNSIGNED NOT NULL auto_increment, table_id INT UNSIGNED NOT NULL, name char(64), flags SMALLINT, key_parts SMALLINT, key_length SMALLINT, algorithm SMALLINT, block_size SMALLINT, parser text, comment text, PRIMARY KEY (id)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
 
-CREATE TABLE IF NOT EXISTS table_key_parts (key_id INT UNSIGNED NOT NULL, field_nr SMALLINT NOT NULL, length SMALLINT, record_offset SMALLINT, key_type SMALLINT, key_part_flag SMALLINT) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+CREATE TABLE IF NOT EXISTS table_key_parts (key_id INT UNSIGNED NOT NULL, field_nr INT UNSIGNED NOT NULL, length SMALLINT, record_offset SMALLINT, key_type SMALLINT, key_part_flag SMALLINT) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
 
 CREATE TABLE IF NOT EXISTS db (   Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y'!
 ) COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges';
 

=== modified file 'sql/datadict.cc'
--- a/sql/datadict.cc	2012-11-12 18:48:23 +0000
+++ b/sql/datadict.cc	2012-11-13 12:21:34 +0000
@@ -221,6 +221,50 @@ bool Data_dictionary::is_dd_table(const
   return false;
 }
 
+int Data_dictionary::open_tables(THD *thd)
+{
+  if (open_and_lock_tables(thd, dd_tables, FALSE,
+                           MYSQL_LOCK_IGNORE_TIMEOUT))
+  {
+    my_error(ER_CANT_CREATE_TABLE, MYF(0), 
+             "todo", 1);
+    return ER_CANT_CREATE_TABLE;
+  }
+  return 0;
+}
+
+void Data_dictionary::save_state(THD *thd)
+{
+  saved_count_cuted_fields= thd->count_cuted_fields;
+  thd->count_cuted_fields= CHECK_FIELD_WARN; // TODO Required ?
+
+  saved_mode= thd->variables.sql_mode;
+  thd->variables.sql_mode= 0; // Reset during DD operations
+
+  if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+    thd->clear_current_stmt_binlog_format_row();
+
+  thd->push_internal_handler(&error_handler);
+  thd->lex->reset_n_backup_query_tables_list(&query_table_list_backup);
+  thd->reset_n_backup_open_tables_state(&open_tables_state_backup);
+}
+
+void Data_dictionary::restore_state(THD *thd)
+{
+  thd->count_cuted_fields= saved_count_cuted_fields;
+  thd->variables.sql_mode= saved_mode;
+
+  if (save_binlog_row_based)
+    thd->set_current_stmt_binlog_format_row();
+  save_binlog_row_based= 0;
+
+  // We are ignoring errors for now should propagate this UP TODO
+  thd->pop_internal_handler();
+
+  thd->lex->restore_backup_query_tables_list(&query_table_list_backup);
+  thd->restore_backup_open_tables_state(&open_tables_state_backup);
+}
+
 int Data_dictionary::add_table(THD *thd, const char *db, const char *name,
                                HA_CREATE_INFO *create_info,
                                List<Create_field> &create_fields, uint keys)
@@ -231,7 +275,7 @@ int Data_dictionary::add_table(THD *thd,
   TABLE *table;
   table= dd_tables[MYSQL_DD_TABLES].table;
 
-  // Get default values for fields
+  // Get default values for table def
   restore_record(table, s->default_values);
 
   table->next_number_field= table->found_next_number_field;
@@ -331,11 +375,14 @@ int Data_dictionary::add_table(THD *thd,
     table->field[MYSQL_DD_TABLES_FIELD_KEY_BLOCK_SIZE]->
       store(create_info->key_block_size, TRUE); 
 
-  table->field[MYSQL_DD_TABLES_FIELD_COMMENT]->set_notnull();
-  store_failed= store_failed ||
-    table->field[MYSQL_DD_TABLES_FIELD_COMMENT]->
-      store(create_info->comment.str, 
-            create_info->comment.length, system_charset_info);
+  if (create_info->comment.str)
+  {
+    table->field[MYSQL_DD_TABLES_FIELD_COMMENT]->set_notnull();
+    store_failed= store_failed ||
+      table->field[MYSQL_DD_TABLES_FIELD_COMMENT]->
+        store(create_info->comment.str, 
+              create_info->comment.length, system_charset_info);
+  }
 
   table->field[MYSQL_DD_TABLES_FIELD_FIELD_COUNT]->set_notnull();
   store_failed= store_failed ||
@@ -406,7 +453,7 @@ int Data_dictionary::add_fields(THD *thd
   List_iterator<Create_field> it(create_fields);
   while ((field=it++))
   {
-    // Get default values for fields
+    // Get default values for field def
     restore_record(table, s->default_values);
 
     table->field[MYSQL_DD_FIELDS_FIELD_TABLE_ID]->set_notnull();
@@ -449,11 +496,14 @@ int Data_dictionary::add_fields(THD *thd
       table->field[MYSQL_DD_FIELDS_FIELD_CSID]->
         store(field->charset->number, TRUE);
 
-    table->field[MYSQL_DD_FIELDS_FIELD_COMMENT]->set_notnull();
-    store_failed= store_failed ||
-      table->field[MYSQL_DD_FIELDS_FIELD_COMMENT]->
-        store(field->comment.str, field->comment.length,
-              system_charset_info);
+    if (field->comment.str)
+    {
+      table->field[MYSQL_DD_FIELDS_FIELD_COMMENT]->set_notnull();
+      store_failed= store_failed ||
+        table->field[MYSQL_DD_FIELDS_FIELD_COMMENT]->
+          store(field->comment.str, field->comment.length,
+                system_charset_info);
+    }
 
     // Write intervals
     if (field->interval)
@@ -538,46 +588,185 @@ done:
   return (error);
 }
 
-int Data_dictionary::open_tables(THD *thd)
+int Data_dictionary::add_table_keys(THD *thd, uint key_count,
+                                    KEY *keyinfo, ulong data_offset)
 {
-  if (open_and_lock_tables(thd, dd_tables, FALSE,
-                           MYSQL_LOCK_IGNORE_TIMEOUT))
+  bool error= false;
+  bool store_failed= FALSE;
+  KEY *key, *end;
+  uint latest_table_id= latest_auto_incr_id;
+
+  TABLE *table= dd_tables[MYSQL_DD_TABLE_KEYS].table;
+
+  bitmap_set_all(table->write_set);
+  bitmap_set_all(table->read_set);
+
+  table->next_number_field= table->found_next_number_field;
+  table->auto_increment_field_not_null= TRUE;
+
+  for (key=keyinfo,end=keyinfo+key_count; key != end; key++)
   {
-    my_error(ER_CANT_CREATE_TABLE, MYF(0), 
-             "todo", 1);
-    return ER_CANT_CREATE_TABLE;
+    // Get default values for keys
+    restore_record(table, s->default_values);
+
+    if (thd->auto_inc_intervals_in_cur_stmt_for_binlog.nb_elements() > 0)
+    {
+      table->field[MYSQL_DD_TABLE_KEYS_FIELD_ID]->set_notnull();
+      store_failed= store_failed ||
+        table->field[MYSQL_DD_TABLE_KEYS_FIELD_ID]->store(
+          thd->auto_inc_intervals_in_cur_stmt_for_binlog.minimum(), TRUE);
+    }
+
+    table->field[MYSQL_DD_TABLE_KEYS_FIELD_TABLE_ID]->set_notnull();
+    store_failed= table->field[MYSQL_DD_TABLE_KEYS_FIELD_TABLE_ID]->
+      store(latest_table_id, TRUE);
+
+    table->field[MYSQL_DD_TABLE_KEYS_FIELD_NAME]->set_notnull();
+    store_failed= store_failed ||
+      table->field[MYSQL_DD_TABLE_KEYS_FIELD_NAME]->
+        store(key->name, strlen(key->name),
+              system_charset_info);
+
+    table->field[MYSQL_DD_TABLE_KEYS_FIELD_FLAGS]->set_notnull();
+    store_failed= store_failed ||
+      table->field[MYSQL_DD_TABLE_KEYS_FIELD_FLAGS]->
+        store((key->flags ^ HA_NOSAME), TRUE);
+
+    table->field[MYSQL_DD_TABLE_KEYS_FIELD_KEY_PARTS]->set_notnull();
+    store_failed= store_failed ||
+      table->field[MYSQL_DD_TABLE_KEYS_FIELD_KEY_PARTS]->
+        store(key->user_defined_key_parts, TRUE);
+
+    table->field[MYSQL_DD_TABLE_KEYS_FIELD_KEY_LENGTH]->set_notnull();
+    store_failed= store_failed ||
+      table->field[MYSQL_DD_TABLE_KEYS_FIELD_KEY_LENGTH]->
+        store(key->key_length, TRUE);
+
+    table->field[MYSQL_DD_TABLE_KEYS_FIELD_ALGORITHM]->set_notnull();
+    store_failed= store_failed ||
+      table->field[MYSQL_DD_TABLE_KEYS_FIELD_ALGORITHM]->
+        store(key->algorithm, TRUE);
+
+    table->field[MYSQL_DD_TABLE_KEYS_FIELD_BLOCK_SIZE]->set_notnull();
+    store_failed= store_failed ||
+      table->field[MYSQL_DD_TABLE_KEYS_FIELD_BLOCK_SIZE]->
+        store(key->block_size, TRUE);
+
+    if (key->parser_name)
+    {
+      table->field[MYSQL_DD_TABLE_KEYS_FIELD_PARSER]->set_notnull();
+      store_failed= store_failed ||
+        table->field[MYSQL_DD_TABLE_KEYS_FIELD_PARSER]->
+          store(key->parser_name->str, key->parser_name->length,
+                system_charset_info);
+    }
+
+    if (key->comment.str)
+    {
+      table->field[MYSQL_DD_TABLE_KEYS_FIELD_COMMENT]->set_notnull();
+      store_failed= store_failed ||
+        table->field[MYSQL_DD_FIELDS_FIELD_COMMENT]->
+          store(key->comment.str, key->comment.length,
+                system_charset_info);
+    }
+
+    if (store_failed)
+    {
+        my_error(ER_CANT_CREATE_TABLE, MYF(0), key->name,
+                 store_failed);
+        error= ER_CANT_CREATE_TABLE;
+        goto done;
+    }
+
+    if (table->file->ha_write_row(table->record[0]))
+    {
+        my_error(ER_TABLE_EXISTS_ERROR, MYF(0), key->name);
+        error= ER_TABLE_EXISTS_ERROR;
+        goto done;
+    }
+
+    // Store key parts in DD
+    latest_auto_incr_id= table->file->insert_id_for_cur_row;
+    error= add_table_key_parts(thd, key->user_defined_key_parts,
+                               key->key_part, data_offset);
   }
-  return 0;
-}
+done:
+  table->auto_increment_field_not_null= FALSE;
+  table->file->ha_release_auto_increment();
+  table->next_number_field= NULL;
 
-void Data_dictionary::save_state(THD *thd)
+  return (error);
+}
+int Data_dictionary::add_table_key_parts(THD *thd, uint key_part_count,
+                                         KEY_PART_INFO *key_parts,
+                                         ulong data_offset)
 {
-  saved_count_cuted_fields= thd->count_cuted_fields;
-  thd->count_cuted_fields= CHECK_FIELD_WARN; // TODO Required ?
+  bool error= false;
+  bool store_failed= FALSE;
+  KEY_PART_INFO *key_part,*key_part_end;
+  uint latest_key_id= latest_auto_incr_id;
 
-  saved_mode= thd->variables.sql_mode;
-  thd->variables.sql_mode= 0; // Reset during DD operations
+  TABLE *table= dd_tables[MYSQL_DD_TABLE_KEY_PARTS].table;
 
-  if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
-    thd->clear_current_stmt_binlog_format_row();
+  bitmap_set_all(table->write_set);
+  bitmap_set_all(table->read_set);
 
-  thd->push_internal_handler(&error_handler);
-  thd->lex->reset_n_backup_query_tables_list(&query_table_list_backup);
-  thd->reset_n_backup_open_tables_state(&open_tables_state_backup);
-}
+  for (key_part=key_parts,
+         key_part_end= key_parts + key_part_count;
+	   key_part != key_part_end ;
+	   key_part++)
+  {
+    // Get default values for key parts
+    restore_record(table, s->default_values);
 
-void Data_dictionary::restore_state(THD *thd)
-{
-  thd->count_cuted_fields= saved_count_cuted_fields;
-  thd->variables.sql_mode= saved_mode;
+    table->field[MYSQL_DD_TABLE_KEY_PARTS_FIELD_KEY_ID]->set_notnull();
+    store_failed= store_failed ||
+      table->field[MYSQL_DD_TABLE_KEY_PARTS_FIELD_KEY_ID]->
+        store(latest_key_id, TRUE);
 
-  if (save_binlog_row_based)
-    thd->set_current_stmt_binlog_format_row();
-  save_binlog_row_based= 0;
+    table->field[MYSQL_DD_TABLE_KEY_PARTS_FIELD_FIELD_NR]->set_notnull();
+    store_failed= table->field[MYSQL_DD_TABLE_KEY_PARTS_FIELD_FIELD_NR]->
+      store(key_part->fieldnr+1+FIELD_NAME_USED, TRUE);
 
-  // We are ignoring errors for now should propagate this UP TODO
-  thd->pop_internal_handler();
+    table->field[MYSQL_DD_TABLE_KEY_PARTS_FIELD_LENGTH]->set_notnull();
+    store_failed= store_failed ||
+      table->field[MYSQL_DD_TABLE_KEY_PARTS_FIELD_LENGTH]->
+        store(key_part->length, TRUE);
 
-  thd->lex->restore_backup_query_tables_list(&query_table_list_backup);
-  thd->restore_backup_open_tables_state(&open_tables_state_backup);
+    table->field[MYSQL_DD_TABLE_KEY_PARTS_FIELD_RECORD_OFFSET]->set_notnull();
+    store_failed= store_failed ||
+      table->field[MYSQL_DD_TABLE_KEY_PARTS_FIELD_RECORD_OFFSET]->
+        store((key_part->offset + data_offset + 1), TRUE);
+
+    table->field[MYSQL_DD_TABLE_KEY_PARTS_FIELD_KEY_TYPE]->set_notnull();
+    store_failed= store_failed ||
+      table->field[MYSQL_DD_TABLE_KEY_PARTS_FIELD_KEY_TYPE]->
+        store(key_part->key_type, TRUE);
+
+    table->field[MYSQL_DD_TABLE_KEY_PARTS_FIELD_KEY_PART_FLAG]->set_notnull();
+    store_failed= store_failed ||
+      table->field[MYSQL_DD_TABLE_KEY_PARTS_FIELD_KEY_PART_FLAG]->
+        store(key_part->key_part_flag, TRUE);
+
+    if (store_failed)
+    {
+        my_error(ER_CANT_CREATE_TABLE, MYF(0), "key_parts",
+                 store_failed);
+        error= ER_CANT_CREATE_TABLE;
+        goto done;
+    }
+
+    if (table->file->ha_write_row(table->record[0]))
+    {
+        my_error(ER_TABLE_EXISTS_ERROR, MYF(0), "key_parts");
+        error= ER_TABLE_EXISTS_ERROR;
+        goto done;
+    }
+  }
+done:
+  table->auto_increment_field_not_null= FALSE;
+  table->file->ha_release_auto_increment();
+  table->next_number_field= NULL;
+
+  return (error);
 }

=== modified file 'sql/datadict0.h'
--- a/sql/datadict0.h	2012-11-12 18:48:23 +0000
+++ b/sql/datadict0.h	2012-11-13 12:21:34 +0000
@@ -110,7 +110,6 @@ enum enum_dd_table_key_parts_fields
   MYSQL_DD_TABLE_KEYS_FIELD_KEY_LENGTH,
   MYSQL_DD_TABLE_KEYS_FIELD_ALGORITHM,
   MYSQL_DD_TABLE_KEYS_FIELD_BLOCK_SIZE,
-  MYSQL_DD_TABLE_KEYS_FIELD_USER_DEFINED_KEY_PARTS,
   MYSQL_DD_TABLE_KEYS_FIELD_PARSER,
   MYSQL_DD_TABLE_KEYS_FIELD_COMMENT,
   MYSQL_DD_TABLE_KEYS_FIELD_COUNT  // Total number of fields
@@ -176,10 +175,12 @@ public:
 
   int add_fields(THD *thd, List<Create_field> &create_fields);
 
-  /*
-  add_key();
-  add_key_part();
+  int add_table_keys(THD *thd, uint key_count, KEY *keyinfo,
+                     ulong data_offset);
 
+  int add_table_key_parts(THD *thd, uint key_part_count,
+                          KEY_PART_INFO *key_parts, ulong data_offset);
+  /* TODO
   update_table();
   update_field();
   update_key();

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2012-11-12 18:48:23 +0000
+++ b/sql/sql_table.cc	2012-11-13 12:21:34 +0000
@@ -4759,7 +4759,9 @@ bool create_table_impl(THD *thd,
     datadict.open_tables(thd);
 
     error= datadict.add_table(thd, db, table_name, create_info,
-                       alter_info->create_list, *key_count);
+                              alter_info->create_list, *key_count);
+    error= datadict.add_table_keys(thd, *key_count, *key_info, 
+                                   (create_info->null_bits + 7) / 8);
     error= 0; // Intentionally ignoring errors for now
 
     datadict.close_tables(thd);

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (gopal.shankar:4970 to 4971) WL#6379Gopal Shankar14 Nov