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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
a941e58f
Commit
a941e58f
authored
May 13, 2019
by
Robert Bindar
Committed by
Sergey Vojtovich
May 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-788 mysqlimport should support the ability to disable foreign keys
parent
47637a3d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
2 deletions
+56
-2
client/mysqlimport.c
client/mysqlimport.c
+9
-2
mysql-test/r/mysqldump.result
mysql-test/r/mysqldump.result
+18
-0
mysql-test/t/mysqldump.test
mysql-test/t/mysqldump.test
+29
-0
No files found.
client/mysqlimport.c
View file @
a941e58f
...
...
@@ -48,8 +48,8 @@ static char *add_load_option(char *ptr,const char *object,
const
char
*
statement
);
static
my_bool
verbose
=
0
,
lock_tables
=
0
,
ignore_errors
=
0
,
opt_delete
=
0
,
replace
=
0
,
silent
=
0
,
ignore
=
0
,
opt_compress
=
0
,
opt_
low_priority
=
0
,
tty_password
=
0
;
replace
,
silent
,
ignore
,
ignore_foreign_keys
,
opt_
compress
,
opt_low_priority
,
tty_password
;
static
my_bool
debug_info_flag
=
0
,
debug_check_flag
=
0
;
static
uint
opt_use_threads
=
0
,
opt_local_file
=
0
,
my_end_arg
=
0
;
static
char
*
opt_password
=
0
,
*
current_user
=
0
,
...
...
@@ -123,6 +123,10 @@ static struct my_option my_long_options[] =
&
current_host
,
0
,
GET_STR
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
"ignore"
,
'i'
,
"If duplicate unique key was found, keep old row."
,
&
ignore
,
&
ignore
,
0
,
GET_BOOL
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
"ignore-foreign-keys"
,
'k'
,
"Disable foreign key checks while importing the data."
,
&
ignore_foreign_keys
,
&
ignore_foreign_keys
,
0
,
GET_BOOL
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
"ignore-lines"
,
OPT_IGN_LINES
,
"Ignore first n lines of data infile."
,
&
opt_ignore_lines
,
&
opt_ignore_lines
,
0
,
GET_LL
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
...
...
@@ -487,6 +491,9 @@ static MYSQL *db_connect(char *host, char *database,
ignore_errors
=
0
;
db_error
(
mysql
);
}
if
(
ignore_foreign_keys
)
mysql_query
(
mysql
,
"set foreign_key_checks= 0;"
);
return
mysql
;
}
...
...
mysql-test/r/mysqldump.result
View file @
a941e58f
...
...
@@ -5610,3 +5610,21 @@ DROP FUNCTION f;
#
DROP VIEW v1;
DROP FUNCTION f;
#
# MDEV-788 New option to ignore foreign key contraints in mysqlimport
#
create table t1 (
id int primary key
) engine=InnoDB;
create table t2 (
t1_id int,
CONSTRAINT fk
FOREIGN KEY (t1_id) REFERENCES t1 (id)
) ENGINE = InnoDB;
select count(*) from t2;
count(*)
1
select count(*) from t2;
count(*)
2
drop tables t2, t1;
mysql-test/t/mysqldump.test
View file @
a941e58f
...
...
@@ -2484,6 +2484,7 @@ DROP TABLE t1;
DROP TABLE t2;
DROP DATABASE db_20772273;
USE test;
--remove_file $MYSQLTEST_VARDIR/tmp/t2.txt
--echo #
--echo # Bug #25717383: MYSQLDUMP MAY EXECUTE ANY ARBITRARY QUERY
...
...
@@ -2649,3 +2650,31 @@ DROP FUNCTION f;
--
echo
#
DROP
VIEW
v1
;
DROP
FUNCTION
f
;
--
echo
#
--
echo
# MDEV-788 New option to ignore foreign key contraints in mysqlimport
--
echo
#
create
table
t1
(
id
int
primary
key
)
engine
=
InnoDB
;
create
table
t2
(
t1_id
int
,
CONSTRAINT
fk
FOREIGN
KEY
(
t1_id
)
REFERENCES
t1
(
id
)
)
ENGINE
=
InnoDB
;
--
write_file
$MYSQLTEST_VARDIR
/
tmp
/
t2
.
txt
0
EOF
--
error
1
--
exec
$MYSQL_IMPORT
--
silent
test
$MYSQLTEST_VARDIR
/
tmp
/
t2
.
txt
--
exec
$MYSQL_IMPORT
--
silent
-
k
test
$MYSQLTEST_VARDIR
/
tmp
/
t2
.
txt
select
count
(
*
)
from
t2
;
--
exec
$MYSQL_IMPORT
--
silent
--
ignore
-
foreign
-
keys
test
$MYSQLTEST_VARDIR
/
tmp
/
t2
.
txt
select
count
(
*
)
from
t2
;
--
remove_file
$MYSQLTEST_VARDIR
/
tmp
/
t2
.
txt
drop
tables
t2
,
t1
;
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