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.2078 06/01/26 12:56:53 gluh@stripped +7 -0
WL#2257 REFERENTIAL_CONSTRAINTS view(2nd ver)
sql/table.h
1.126 06/01/26 12:56:47 gluh@stripped +3 -1
WL#2257 REFERENTIAL_CONSTRAINTS view(2nd ver)
sql/sql_show.cc
1.294 06/01/26 12:56:47 gluh@stripped +71 -0
WL#2257 REFERENTIAL_CONSTRAINTS view(2nd ver)
sql/ha_innodb.cc
1.251 06/01/26 12:56:46 gluh@stripped +35 -22
WL#2257 REFERENTIAL_CONSTRAINTS view(2nd ver)
mysql-test/t/information_schema_inno.test
1.6 06/01/26 12:56:46 gluh@stripped +23 -0
WL#2257 REFERENTIAL_CONSTRAINTS view(2nd ver)
mysql-test/r/information_schema_inno.result
1.9 06/01/26 12:56:46 gluh@stripped +21 -0
WL#2257 REFERENTIAL_CONSTRAINTS view(2nd ver)
mysql-test/r/information_schema_db.result
1.10 06/01/26 12:56:46 gluh@stripped +1 -0
WL#2257 REFERENTIAL_CONSTRAINTS view(2nd ver)
mysql-test/r/information_schema.result
1.104 06/01/26 12:56:46 gluh@stripped +3 -2
WL#2257 REFERENTIAL_CONSTRAINTS view(2nd ver)
# 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.293/sql/sql_show.cc Thu Jan 19 06:56:01 2006
+++ 1.294/sql/sql_show.cc Thu Jan 26 12:56:47 2006
@@ -3829,6 +3829,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(STRING_WITH_LEN("NONE"), 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
@@ -4634,6 +4686,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
@@ -4663,6 +4731,9 @@ ST_SCHEMA_TABLE schema_tables[]=
get_all_tables, 0, get_schema_partitions_record, 1, 2, 0},
{"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.125/sql/table.h Thu Jan 19 06:56:01 2006
+++ 1.126/sql/table.h Thu Jan 26 12:56:47 2006
@@ -321,7 +321,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;
@@ -342,6 +343,7 @@ enum enum_schema_tables
SCH_OPEN_TABLES,
SCH_PARTITIONS,
SCH_PLUGINS,
+ SCH_REFERENTIAL_CONSTRAINTS,
SCH_PROCEDURES,
SCH_SCHEMATA,
SCH_SCHEMA_PRIVILEGES,
--- 1.103/mysql-test/r/information_schema.result Thu Jan 19 06:55:59 2006
+++ 1.104/mysql-test/r/information_schema.result Thu Jan 26 12:56:46 2006
@@ -47,6 +47,7 @@ ENGINES
KEY_COLUMN_USAGE
PARTITIONS
PLUGINS
+REFERENTIAL_CONSTRAINTS
ROUTINES
SCHEMATA
SCHEMA_PRIVILEGES
@@ -734,7 +735,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(*)
-109
+110
drop view a2, a1;
drop table t_crashme;
select table_schema,table_name, column_name from
@@ -817,7 +818,7 @@ flush privileges;
SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
table_schema count(*)
cluster_replication 1
-information_schema 19
+information_schema 20
mysql 21
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 Thu Jan 26 12:56:46 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 UNIQUE_CONSTRAINT_NAME MATCH_OPTION UPDATE_RULE DELETE_RULE
+test t2 FOREIGN KEY A1 test t1 NONE CASCADE NO ACTION
+test t3 FOREIGN KEY A2 test t2 NONE 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 Thu Jan 26 12:56:46 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.9/mysql-test/r/information_schema_db.result Tue Jan 10 19:42:19 2006
+++ 1.10/mysql-test/r/information_schema_db.result Thu Jan 26 12:56:46 2006
@@ -10,6 +10,7 @@ ENGINES
KEY_COLUMN_USAGE
PARTITIONS
PLUGINS
+REFERENTIAL_CONSTRAINTS
ROUTINES
SCHEMATA
SCHEMA_PRIVILEGES
--- 1.250/sql/ha_innodb.cc Tue Jan 17 11:37:22 2006
+++ 1.251/sql/ha_innodb.cc Thu Jan 26 12:56:46 2006
@@ -5997,40 +5997,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.2078) | gluh | 26 Jan |