summaryrefslogtreecommitdiff
path: root/innobase/row
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2004-02-02 00:10:45 +0200
committerunknown <heikki@hundin.mysql.fi>2004-02-02 00:10:45 +0200
commit08177508f5db7c003ebbe1fe16e17dd02fff49b0 (patch)
treec00e983defe37f950e64718fcfe3a3ca0daabadc /innobase/row
parent7eefcb75db0707dbc8044808390f047b60484454 (diff)
downloadmariadb-git-08177508f5db7c003ebbe1fe16e17dd02fff49b0.tar.gz
dict0dict.c:
Remove redundant code; parse both the database name and the table name in a FOREIGN KEY constraint with quotes in mind row0mysql.c, ha_innodb.cc, sql_table.cc: Return error message Cannot delete or update a parent row... if we try to drop a table which is referenced by a FOREIGN KEY constraint, and the user has not set foreign_key_checks=0 sql/sql_table.cc: Return error message Cannot delete or update a parent row... if we try to drop a table which is referenced by a FOREIGN KEY constraint, and the user has not set foreign_key_checks=0 sql/ha_innodb.cc: Return error message Cannot delete or update a parent row... if we try to drop a table which is referenced by a FOREIGN KEY constraint, and the user has not set foreign_key_checks=0 innobase/row/row0mysql.c: Return error message Cannot delete or update a parent row... if we try to drop a table which is referenced by a FOREIGN KEY constraint, and the user has not set foreign_key_checks=0 innobase/dict/dict0dict.c: Remove redundant code; parse both the database name and the table name in a FOREIGN KEY constraint with quotes in mind
Diffstat (limited to 'innobase/row')
-rw-r--r--innobase/row/row0mysql.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c
index 468404268f4..257756ff8aa 100644
--- a/innobase/row/row0mysql.c
+++ b/innobase/row/row0mysql.c
@@ -1804,6 +1804,7 @@ row_drop_table_for_mysql(
char* name, /* in: table name */
trx_t* trx) /* in: transaction handle */
{
+ dict_foreign_t* foreign;
dict_table_t* table;
que_thr_t* thr;
que_t* graph;
@@ -1996,6 +1997,31 @@ row_drop_table_for_mysql(
goto funct_exit;
}
+ foreign = UT_LIST_GET_FIRST(table->referenced_list);
+
+ if (foreign && trx->check_foreigns) {
+ char* buf = dict_foreign_err_buf;
+
+ /* We only allow dropping a referenced table if
+ FOREIGN_KEY_CHECKS is set to 0 */
+
+ err = DB_CANNOT_DROP_CONSTRAINT;
+
+ mutex_enter(&dict_foreign_err_mutex);
+ ut_sprintf_timestamp(buf);
+
+ sprintf(buf + strlen(buf),
+ " Cannot drop table %.500s\n", name);
+ sprintf(buf + strlen(buf),
+"because it is referenced by %.500s\n", foreign->foreign_table_name);
+
+ ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
+
+ mutex_exit(&dict_foreign_err_mutex);
+
+ goto funct_exit;
+ }
+
if (table->n_mysql_handles_opened > 0) {
ut_print_timestamp(stderr);