bk commit into 5.0 tree (osku:1.1960) BUG#12084 -
09-06-2005
, 06:38 AM
Below is the list of changes that have just been committed into a local
5.0 repository of osku. When osku 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/in...urce-tree.html
ChangeSet
1.1960 05/09/06 14:38:21 osku (AT) 127 (DOT) (none) +5 -0
InnoDB: Reject foreign keys in temporary tables. Closes bug #12084.
sql/ha_innodb.cc
1.255 05/09/06 14:38:17 osku (AT) 127 (DOT) (none) +21 -40
In create, pass correct reject_fks argument to
row_table_add_foreign_constraints depending on whether we're creating a
temporary table or not. Also move duplicated cleanup code to a single
place.
innobase/row/row0mysql.c
1.113 05/09/06 14:38:17 osku (AT) 127 (DOT) (none) +6 -2
Add reject_fks parameter to row_table_add_foreign_constraints.
innobase/include/row0mysql.h
1.44 05/09/06 14:38:17 osku (AT) 127 (DOT) (none) +5 -1
Add reject_fks parameter to row_table_add_foreign_constraints.
innobase/include/dict0dict.h
1.34 05/09/06 14:38:17 osku (AT) 127 (DOT) (none) +4 -1
Add reject_fks parameter to dict_create_foreign_constraints.
innobase/dict/dict0dict.c
1.66 05/09/06 14:38:17 osku (AT) 127 (DOT) (none) +23 -3
Add reject_fks parameter to dict_create_foreign_constraints_low and
dict_create_foreign_constraints.
# 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: osku
# Host: 127.(none)
# Root: /home/osku/mysql/5.0/12084
--- 1.65/innobase/dict/dict0dict.c 2005-06-21 07:36:01 +03:00
+++ 1.66/innobase/dict/dict0dict.c 2005-09-06 14:38:17 +03:00
@@ -2871,8 +2871,12 @@
table2 can be written also with the database
name before it: test.table2; the default
database is the database of parameter name */
- const char* name) /* in: table full name in the normalized form
+ const char* name, /* in: table full name in the normalized form
database_name/table_name */
+ ibool reject_fks)
+ /* in: if TRUE, fail with error code
+ DB_CANNOT_ADD_CONSTRAINT if any foreign
+ keys are found. */
{
dict_table_t* table;
dict_table_t* referenced_table;
@@ -2994,6 +2998,18 @@
}
if (*ptr == '\0') {
+ /* The proper way to reject foreign keys for temporary
+ tables would be to split the lexing and syntactical
+ analysis of foreign key clauses from the actual adding
+ of them, so that ha_innodb.cc could first parse the SQL
+ command, determine if there are any foreign keys, and
+ if so, immediately reject the command if the table is a
+ temporary one. For now, this kludge will work. */
+ if (reject_fks && (UT_LIST_GET_LEN(table->foreign_list) > 0))
+ {
+ return DB_CANNOT_ADD_CONSTRAINT;
+ }
+
/************************************************** ********/
/* The following call adds the foreign key constraints
to the data dictionary system tables on disk */
@@ -3417,9 +3433,12 @@
name before it: test.table2; the
default database id the database of
parameter name */
- const char* name) /* in: table full name in the
+ const char* name, /* in: table full name in the
normalized form
database_name/table_name */
+ ibool reject_fks) /* in: if TRUE, fail with error
+ code DB_CANNOT_ADD_CONSTRAINT if
+ any foreign keys are found. */
{
char* str;
ulint err;
@@ -3428,7 +3447,8 @@
str = dict_strip_comments(sql_string);
heap = mem_heap_create(10000);
- err = dict_create_foreign_constraints_low(trx, heap, str, name);
+ err = dict_create_foreign_constraints_low(trx, heap, str, name,
+ reject_fks);
mem_heap_free(heap);
mem_free(str);
--- 1.33/innobase/include/dict0dict.h 2005-04-27 03:02:14 +03:00
+++ 1.34/innobase/include/dict0dict.h 2005-09-06 14:38:17 +03:00
@@ -228,9 +228,12 @@
name before it: test.table2; the
default database id the database of
parameter name */
- const char* name); /* in: table full name in the
+ const char* name, /* in: table full name in the
normalized form
database_name/table_name */
+ ibool reject_fks); /* in: if TRUE, fail with error
+ code DB_CANNOT_ADD_CONSTRAINT if
+ any foreign keys are found. */
/************************************************** ************************
Parses the CONSTRAINT id's to be dropped in an ALTER TABLE statement. */
--- 1.43/innobase/include/row0mysql.h 2005-07-01 20:41:44 +03:00
+++ 1.44/innobase/include/row0mysql.h 2005-09-06 14:38:17 +03:00
@@ -355,9 +355,13 @@
FOREIGN KEY (a, b) REFERENCES table2(c, d),
table2 can be written also with the
database name before it: test.table2 */
- const char* name); /* in: table full name in the
+ const char* name, /* in: table full name in the
normalized form
database_name/table_name */
+ ibool reject_fks); /* in: if TRUE, fail with error
+ code DB_CANNOT_ADD_CONSTRAINT if
+ any foreign keys are found. */
+
/************************************************** ***********************
The master thread in srv0srv.c calls this regularly to drop tables which
we must drop in background after queries to them have ended. Such lazy
--- 1.112/innobase/row/row0mysql.c 2005-09-05 01:13:05 +03:00
+++ 1.113/innobase/row/row0mysql.c 2005-09-06 14:38:17 +03:00
@@ -2088,9 +2088,12 @@
FOREIGN KEY (a, b) REFERENCES table2(c, d),
table2 can be written also with the
database name before it: test.table2 */
- const char* name) /* in: table full name in the
+ const char* name, /* in: table full name in the
normalized form
database_name/table_name */
+ ibool reject_fks) /* in: if TRUE, fail with error
+ code DB_CANNOT_ADD_CONSTRAINT if
+ any foreign keys are found. */
{
ulint err;
@@ -2111,7 +2114,8 @@
trx->dict_operation = TRUE;
- err = dict_create_foreign_constraints(trx, sql_string, name);
+ err = dict_create_foreign_constraints(trx, sql_string, name,
+ reject_fks);
if (err == DB_SUCCESS) {
/* Check that also referencing constraints are ok */
--- 1.254/sql/ha_innodb.cc 2005-09-05 01:12:53 +03:00
+++ 1.255/sql/ha_innodb.cc 2005-09-06 14:38:17 +03:00
@@ -4687,13 +4687,7 @@
form->s->row_type != ROW_TYPE_REDUNDANT);
if (error) {
- innobase_commit_low(trx);
-
- row_mysql_unlock_data_dictionary(trx);
-
- trx_free_for_mysql(trx);
-
- DBUG_RETURN(error);
+ goto cleanup;
}
/* Look for a primary key */
@@ -4717,13 +4711,7 @@
error = create_clustered_index_when_no_primary(trx,
norm_name);
if (error) {
- innobase_commit_low(trx);
-
- row_mysql_unlock_data_dictionary(trx);
-
- trx_free_for_mysql(trx);
-
- DBUG_RETURN(error);
+ goto cleanup;
}
}
@@ -4732,13 +4720,7 @@
first */
if ((error = create_index(trx, form, norm_name,
(uint) primary_key_no))) {
- innobase_commit_low(trx);
-
- row_mysql_unlock_data_dictionary(trx);
-
- trx_free_for_mysql(trx);
-
- DBUG_RETURN(error);
+ goto cleanup;
}
}
@@ -4747,14 +4729,7 @@
if (i != (uint) primary_key_no) {
if ((error = create_index(trx, form, norm_name, i))) {
-
- innobase_commit_low(trx);
-
- row_mysql_unlock_data_dictionary(trx);
-
- trx_free_for_mysql(trx);
-
- DBUG_RETURN(error);
+ goto cleanup;
}
}
}
@@ -4767,21 +4742,18 @@
current_thd->query_length,
current_thd->charset())) {
error = HA_ERR_OUT_OF_MEM;
- } else {
- error = row_table_add_foreign_constraints(trx,
- q.str, norm_name);
-
- error = convert_error_code_to_mysql(error, NULL);
+
+ goto cleanup;
}
- if (error) {
- innobase_commit_low(trx);
-
- row_mysql_unlock_data_dictionary(trx);
+ error = row_table_add_foreign_constraints(trx,
+ q.str, norm_name,
+ create_info->options & HA_LEX_CREATE_TMP_TABLE);
- trx_free_for_mysql(trx);
+ error = convert_error_code_to_mysql(error, NULL);
- DBUG_RETURN(error);
+ if (error) {
+ goto cleanup;
}
}
@@ -4821,6 +4793,15 @@
trx_free_for_mysql(trx);
DBUG_RETURN(0);
+
+cleanup:
+ innobase_commit_low(trx);
+
+ row_mysql_unlock_data_dictionary(trx);
+
+ trx_free_for_mysql(trx);
+
+ DBUG_RETURN(error);
}
/************************************************** *******************
--
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe: http://lists.mysql.com/internals?uns...ie.nctu.edu.tw |