Below is the list of changes that have just been committed into a local
5.2 repository of gluh. When gluh does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2048 06/01/17 15:21:56 gluh@stripped +7 -0
WL#2257 REFERENTIAL_CONSTRAINTS view
sql/table.h
1.123 06/01/17 15:20:17 gluh@stripped +3 -1
WL#2257 REFERENTIAL_CONSTRAINTS view
sql/sql_show.cc
1.296 06/01/17 15:20:16 gluh@stripped +71 -0
WL#2257 REFERENTIAL_CONSTRAINTS view
sql/ha_innodb.cc
1.249 06/01/17 15:20:16 gluh@stripped +35 -22
WL#2257 REFERENTIAL_CONSTRAINTS view
mysql-test/t/information_schema_inno.test
1.6 06/01/17 15:20:16 gluh@stripped +23 -0
WL#2257 REFERENTIAL_CONSTRAINTS view
mysql-test/r/information_schema_inno.result
1.9 06/01/17 15:20:16 gluh@stripped +21 -0
WL#2257 REFERENTIAL_CONSTRAINTS view
mysql-test/r/information_schema_db.result
1.9 06/01/17 15:20:16 gluh@stripped +1 -0
WL#2257 REFERENTIAL_CONSTRAINTS view
mysql-test/r/information_schema.result
1.98 06/01/17 15:20:16 gluh@stripped +3 -2
WL#2257 REFERENTIAL_CONSTRAINTS view
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: gluh
# Host: eagle.intranet.mysql.r18.ru
# Root: /home/gluh/MySQL/Devel/5.2.2257
--- 1.295/sql/sql_show.cc Thu Jan 5 01:36:23 2006
+++ 1.296/sql/sql_show.cc Tue Jan 17 15:20:16 2006
@@ -3630,6 +3630,58 @@ int fill_status(THD *thd, TABLE_LIST *ta
}
+static int
+get_referential_constraints_record(THD *thd, struct st_table_list *tables,
+ TABLE *table, bool res, const char *base_name,
+ const char *file_name)
+{
+ CHARSET_INFO *cs= system_charset_info;
+ DBUG_ENTER("get_schema_ref_constarints_record");
+
+ if (res)
+ {
+ if (!tables->view)
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ thd->net.last_errno, thd->net.last_error);
+ thd->clear_error();
+ DBUG_RETURN(0);
+ }
+ else if (!tables->view)
+ {
+ List<FOREIGN_KEY_INFO> f_key_list;
+ TABLE *show_table= tables->table;
+ KEY *key_info=show_table->key_info;
+ show_table->file->info(HA_STATUS_VARIABLE |
+ HA_STATUS_NO_LOCK |
+ HA_STATUS_TIME);
+
+ show_table->file->get_foreign_key_list(thd, &f_key_list);
+ FOREIGN_KEY_INFO *f_key_info;
+ List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
+ while ((f_key_info= it++))
+ {
+ restore_record(table, s->default_values);
+ table->field[1]->store(base_name, strlen(base_name), cs);
+ table->field[2]->store(file_name, strlen(file_name), cs);
+ table->field[3]->store(f_key_info->forein_id->str,
+ f_key_info->forein_id->length, cs);
+ table->field[5]->store(f_key_info->referenced_db->str,
+ f_key_info->referenced_db->length, cs);
+ table->field[6]->store(f_key_info->referenced_table->str,
+ f_key_info->referenced_table->length, cs);
+ table->field[7]->store("NONE", 4, cs);
+ table->field[8]->store(f_key_info->update_method->str,
+ f_key_info->update_method->length, cs);
+ table->field[9]->store(f_key_info->delete_method->str,
+ f_key_info->delete_method->length, cs);
+ if (schema_table_store_record(thd, table))
+ DBUG_RETURN(1);
+ }
+ }
+ DBUG_RETURN(res);
+}
+
+
/*
Find schema_tables elment by name
@@ -4404,6 +4456,22 @@ ST_FIELD_INFO plugin_fields_info[]=
};
+ST_FIELD_INFO referential_constraints_fields_info[]=
+{
+ {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0},
+ {"CONSTRAINT_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"CONSTRAINT_TABLE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"CONSTRAINT_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"UNIQUE_CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0},
+ {"UNIQUE_CONSTRAINT_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"UNIQUE_CONSTRAINT_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"MATCH_OPTION", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"UPDATE_RULE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"DELETE_RULE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
+};
+
+
/*
Description of ST_FIELD_INFO in table.h
@@ -4431,6 +4499,9 @@ ST_SCHEMA_TABLE schema_tables[]=
fill_open_tables, make_old_format, 0, -1, -1, 1},
{"PLUGINS", plugin_fields_info, create_schema_table,
fill_plugins, make_old_format, 0, -1, -1, 0},
+ {"REFERENTIAL_CONSTRAINTS", referential_constraints_fields_info,
+ create_schema_table, get_all_tables, 0, get_referential_constraints_record,
+ 1, 2, 0},
{"ROUTINES", proc_fields_info, create_schema_table,
fill_schema_proc, make_proc_old_format, 0, -1, -1, 0},
{"SCHEMATA", schema_fields_info, create_schema_table,
--- 1.122/sql/table.h Mon Dec 26 15:53:41 2005
+++ 1.123/sql/table.h Tue Jan 17 15:20:17 2006
@@ -313,7 +313,8 @@ typedef struct st_foreign_key_info
LEX_STRING *forein_id;
LEX_STRING *referenced_db;
LEX_STRING *referenced_table;
- LEX_STRING *constraint_method;
+ LEX_STRING *update_method;
+ LEX_STRING *delete_method;
List<LEX_STRING> foreign_fields;
List<LEX_STRING> referenced_fields;
} FOREIGN_KEY_INFO;
@@ -333,6 +334,7 @@ enum enum_schema_tables
SCH_KEY_COLUMN_USAGE,
SCH_OPEN_TABLES,
SCH_PLUGINS,
+ SCH_REFERENTIAL_CONSTRAINTS,
SCH_PROCEDURES,
SCH_SCHEMATA,
SCH_SCHEMA_PRIVILEGES,
--- 1.97/mysql-test/r/information_schema.result Thu Jan 5 01:38:46 2006
+++ 1.98/mysql-test/r/information_schema.result Tue Jan 17 15:20:16 2006
@@ -44,6 +44,7 @@ COLUMN_PRIVILEGES
ENGINES
KEY_COLUMN_USAGE
PLUGINS
+REFERENTIAL_CONSTRAINTS
ROUTINES
SCHEMATA
SCHEMA_PRIVILEGES
@@ -725,7 +726,7 @@ CREATE TABLE t_crashme ( f1 BIGINT);
CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
count(*)
-104
+105
drop view a2, a1;
drop table t_crashme;
select table_schema,table_name, column_name from
@@ -796,7 +797,7 @@ delete from mysql.db where user='mysqlte
flush privileges;
SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
table_schema count(*)
-information_schema 18
+information_schema 19
mysql 18
create table t1 (i int, j int);
create trigger trg1 before insert on t1 for each row
--- 1.8/mysql-test/r/information_schema_inno.result Sat Oct 8 04:48:54 2005
+++ 1.9/mysql-test/r/information_schema_inno.result Tue Jan 17 15:20:16 2006
@@ -25,3 +25,24 @@ NULL test PRIMARY NULL test t3 id 1 NULL
NULL test t3_ibfk_1 NULL test t3 id 1 1 test t2 t1_id
NULL test t3_ibfk_1 NULL test t3 t2_id 2 2 test t2 id
drop table t3, t2, t1;
+CREATE TABLE t1(a1 INT NOT NULL, a2 INT NOT NULL,
+PRIMARY KEY(a1, a2)) ENGINE=INNODB;
+CREATE TABLE t2(b1 INT, b2 INT, INDEX (b1, b2),
+CONSTRAINT A1
+FOREIGN KEY (b1, b2) REFERENCES t1(a1, a2)
+ON UPDATE CASCADE ON DELETE NO ACTION) ENGINE=INNODB;
+CREATE TABLE t3(b1 INT, b2 INT, INDEX (b1, b2),
+CONSTRAINT A2
+FOREIGN KEY (b1, b2) REFERENCES t2(b1, b2)
+ON UPDATE SET NULL ON DELETE RESTRICT) ENGINE=INNODB;
+select a.CONSTRAINT_SCHEMA, CONSTRAINT_TABLE, CONSTRAINT_TYPE,
+b.CONSTRAINT_NAME, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME
+MATCH_OPTION, UPDATE_RULE, DELETE_RULE
+from information_schema.TABLE_CONSTRAINTS a,
+information_schema.REFERENTIAL_CONSTRAINTS b
+where a.CONSTRAINT_SCHEMA = 'test' and a.CONSTRAINT_SCHEMA = b.CONSTRAINT_SCHEMA and
+a.CONSTRAINT_NAME = b.CONSTRAINT_NAME;
+CONSTRAINT_SCHEMA CONSTRAINT_TABLE CONSTRAINT_TYPE CONSTRAINT_NAME UNIQUE_CONSTRAINT_SCHEMA MATCH_OPTION UPDATE_RULE DELETE_RULE
+test t2 FOREIGN KEY A1 test t1 CASCADE NO ACTION
+test t3 FOREIGN KEY A2 test t2 SET NULL RESTRICT
+drop tables t3, t2, t1;
--- 1.5/mysql-test/t/information_schema_inno.test Sat Oct 8 04:48:55 2005
+++ 1.6/mysql-test/t/information_schema_inno.test Tue Jan 17 15:20:16 2006
@@ -21,3 +21,26 @@ select * from information_schema.KEY_COL
TABLE_SCHEMA= "test";
drop table t3, t2, t1;
+
+#
+# Test for REFERENTIAL_CONSTRAINTS table
+#
+CREATE TABLE t1(a1 INT NOT NULL, a2 INT NOT NULL,
+ PRIMARY KEY(a1, a2)) ENGINE=INNODB;
+CREATE TABLE t2(b1 INT, b2 INT, INDEX (b1, b2),
+ CONSTRAINT A1
+ FOREIGN KEY (b1, b2) REFERENCES t1(a1, a2)
+ ON UPDATE CASCADE ON DELETE NO ACTION) ENGINE=INNODB;
+CREATE TABLE t3(b1 INT, b2 INT, INDEX (b1, b2),
+ CONSTRAINT A2
+ FOREIGN KEY (b1, b2) REFERENCES t2(b1, b2)
+ ON UPDATE SET NULL ON DELETE RESTRICT) ENGINE=INNODB;
+
+select a.CONSTRAINT_SCHEMA, CONSTRAINT_TABLE, CONSTRAINT_TYPE,
+ b.CONSTRAINT_NAME, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME
+ MATCH_OPTION, UPDATE_RULE, DELETE_RULE
+from information_schema.TABLE_CONSTRAINTS a,
+ information_schema.REFERENTIAL_CONSTRAINTS b
+where a.CONSTRAINT_SCHEMA = 'test' and a.CONSTRAINT_SCHEMA = b.CONSTRAINT_SCHEMA and
+a.CONSTRAINT_NAME = b.CONSTRAINT_NAME;
+drop tables t3, t2, t1;
--- 1.8/mysql-test/r/information_schema_db.result Thu Dec 22 13:12:33 2005
+++ 1.9/mysql-test/r/information_schema_db.result Tue Jan 17 15:20:16 2006
@@ -9,6 +9,7 @@ COLUMN_PRIVILEGES
ENGINES
KEY_COLUMN_USAGE
PLUGINS
+REFERENTIAL_CONSTRAINTS
ROUTINES
SCHEMATA
SCHEMA_PRIVILEGES
--- 1.248/sql/ha_innodb.cc Thu Jan 5 01:36:22 2006
+++ 1.249/sql/ha_innodb.cc Tue Jan 17 15:20:16 2006
@@ -5995,40 +5995,53 @@ ha_innobase::get_foreign_key_list(THD *t
break;
}
- ulong length= 0;
- if (foreign->type == DICT_FOREIGN_ON_DELETE_CASCADE)
+ ulong length;
+ if (foreign->type & DICT_FOREIGN_ON_DELETE_CASCADE)
{
- length=17;
- tmp_buff= "ON DELETE CASCADE";
+ length=7;
+ tmp_buff= "CASCADE";
}
- else if (foreign->type == DICT_FOREIGN_ON_DELETE_SET_NULL)
+ else if (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL)
{
- length=18;
- tmp_buff= "ON DELETE SET NULL";
+ length=8;
+ tmp_buff= "SET NULL";
}
- else if (foreign->type == DICT_FOREIGN_ON_DELETE_NO_ACTION)
+ else if (foreign->type & DICT_FOREIGN_ON_DELETE_NO_ACTION)
{
- length=19;
- tmp_buff= "ON DELETE NO ACTION";
+ length=9;
+ tmp_buff= "NO ACTION";
}
- else if (foreign->type == DICT_FOREIGN_ON_UPDATE_CASCADE)
+ else
{
- length=17;
- tmp_buff= "ON UPDATE CASCADE";
+ length=8;
+ tmp_buff= "RESTRICT";
}
- else if (foreign->type == DICT_FOREIGN_ON_UPDATE_SET_NULL)
+ f_key_info.delete_method= make_lex_string(thd, f_key_info.delete_method,
+ tmp_buff, length, 1);
+
+
+ if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE)
{
- length=18;
- tmp_buff= "ON UPDATE SET NULL";
+ length=7;
+ tmp_buff= "CASCADE";
}
- else if (foreign->type == DICT_FOREIGN_ON_UPDATE_NO_ACTION)
+ else if (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL)
{
- length=19;
- tmp_buff= "ON UPDATE NO ACTION";
+ length=8;
+ tmp_buff= "SET NULL";
}
- f_key_info.constraint_method= make_lex_string(thd,
- f_key_info.constraint_method,
- tmp_buff, length, 1);
+ else if (foreign->type & DICT_FOREIGN_ON_UPDATE_NO_ACTION)
+ {
+ length=9;
+ tmp_buff= "NO ACTION";
+ }
+ else
+ {
+ length=8;
+ tmp_buff= "RESTRICT";
+ }
+ f_key_info.update_method= make_lex_string(thd, f_key_info.update_method,
+ tmp_buff, length, 1);
FOREIGN_KEY_INFO *pf_key_info= ((FOREIGN_KEY_INFO *)
thd->memdup((gptr) &f_key_info,
| Thread |
|---|
| • bk commit into 5.2 tree (gluh:1.2048) | gluh | 17 Jan |