Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
9ed942fe
Commit
9ed942fe
authored
Sep 08, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge osalerma@bk-internal.mysql.com:/home/bk/mysql-5.0
into 127.(none):/home/osku/mysql/5.0/clean
parents
7c554639
511e8845
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
86 additions
and
47 deletions
+86
-47
innobase/dict/dict0dict.c
innobase/dict/dict0dict.c
+23
-3
innobase/include/dict0dict.h
innobase/include/dict0dict.h
+4
-1
innobase/include/row0mysql.h
innobase/include/row0mysql.h
+5
-1
innobase/row/row0mysql.c
innobase/row/row0mysql.c
+6
-2
mysql-test/r/innodb.result
mysql-test/r/innodb.result
+12
-0
mysql-test/t/innodb.test
mysql-test/t/innodb.test
+15
-0
sql/ha_innodb.cc
sql/ha_innodb.cc
+21
-40
No files found.
innobase/dict/dict0dict.c
View file @
9ed942fe
...
...
@@ -2871,8 +2871,12 @@ dict_create_foreign_constraints_low(
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 @@ loop:
}
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 @@ dict_create_foreign_constraints(
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 @@ dict_create_foreign_constraints(
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
);
...
...
innobase/include/dict0dict.h
View file @
9ed942fe
...
...
@@ -228,9 +228,12 @@ dict_create_foreign_constraints(
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. */
...
...
innobase/include/row0mysql.h
View file @
9ed942fe
...
...
@@ -355,9 +355,13 @@ row_table_add_foreign_constraints(
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
...
...
innobase/row/row0mysql.c
View file @
9ed942fe
...
...
@@ -2088,9 +2088,12 @@ row_table_add_foreign_constraints(
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 @@ row_table_add_foreign_constraints(
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 */
...
...
mysql-test/r/innodb.result
View file @
9ed942fe
...
...
@@ -2527,3 +2527,15 @@ SELECT * FROM t1;
id
1
DROP TABLE t2, t1;
CREATE TABLE t1
(
id INT PRIMARY KEY
)
ENGINE=InnoDB;
CREATE TEMPORARY TABLE t2
(
id INT NOT NULL PRIMARY KEY,
b INT,
FOREIGN KEY (b) REFERENCES test.t1(id)
)
ENGINE=InnoDB;
Got one of the listed errors
DROP TABLE t1;
mysql-test/t/innodb.test
View file @
9ed942fe
...
...
@@ -1451,3 +1451,18 @@ TRUNCATE t1;
INSERT
INTO
t1
(
id
)
VALUES
(
NULL
);
SELECT
*
FROM
t1
;
DROP
TABLE
t2
,
t1
;
--
Test
that
foreign
keys
in
temporary
tables
are
not
accepted
(
bug
#12084)
CREATE
TABLE
t1
(
id
INT
PRIMARY
KEY
)
ENGINE
=
InnoDB
;
--
error
1005
,
1005
CREATE
TEMPORARY
TABLE
t2
(
id
INT
NOT
NULL
PRIMARY
KEY
,
b
INT
,
FOREIGN
KEY
(
b
)
REFERENCES
test
.
t1
(
id
)
)
ENGINE
=
InnoDB
;
DROP
TABLE
t1
;
sql/ha_innodb.cc
View file @
9ed942fe
...
...
@@ -4687,13 +4687,7 @@ ha_innobase::create(
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 @@ ha_innobase::create(
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 @@ ha_innobase::create(
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 @@ ha_innobase::create(
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 @@ ha_innobase::create(
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 @@ ha_innobase::create(
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
);
}
/*********************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment