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
768a10d0
Commit
768a10d0
authored
Oct 26, 2022
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-22200 maridb-dump add --header option
fix quoting
parent
ad7631bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
29 deletions
+30
-29
client/mysqldump.c
client/mysqldump.c
+5
-28
mysql-test/main/mysqldump-header.result
mysql-test/main/mysqldump-header.result
+12
-1
mysql-test/main/mysqldump-header.test
mysql-test/main/mysqldump-header.test
+13
-0
No files found.
client/mysqldump.c
View file @
768a10d0
...
...
@@ -2112,17 +2112,16 @@ static my_bool test_if_special_chars(const char *str)
name Unquoted string containing that which will be quoted
buff The buffer that contains the quoted value, also returned
force Flag to make it ignore 'test_if_special_chars'
quote_c Charater to use as the enclosing quote
Returns
A pointer to the quoted string, or the original string if nothing has
changed.
*/
static
char
*
quote
(
const
char
*
name
,
char
*
buff
,
my_bool
force
,
char
quote_c
)
static
char
*
quote
_name
(
const
char
*
name
,
char
*
buff
,
my_bool
force
)
{
char
*
to
=
buff
;
char
qtype
=
(
opt_compatible_mode
&
MASK_ANSI_QUOTES
)
?
'\"'
:
quote_c
;
char
qtype
=
(
opt_compatible_mode
&
MASK_ANSI_QUOTES
)
?
'\"'
:
'`'
;
if
(
!
force
&&
!
opt_quoted
&&
!
test_if_special_chars
(
name
))
return
(
char
*
)
name
;
...
...
@@ -2136,29 +2135,7 @@ static char *quote(const char *name, char *buff, my_bool force, char quote_c)
to
[
0
]
=
qtype
;
to
[
1
]
=
0
;
return
buff
;
}
/* quote */
/*
quote_name(name, buff, force)
quote() with the ` character
*/
static
char
*
quote_name
(
const
char
*
name
,
char
*
buff
,
my_bool
force
)
{
return
quote
(
name
,
buff
,
force
,
'`'
);
}
/*
quote_string(name, buff, force)
quote() with the ' character
*/
static
char
*
quote_string
(
const
char
*
name
,
char
*
buff
)
{
return
quote
(
name
,
buff
,
0
,
'\''
);
}
}
/* quote_name */
/*
...
...
@@ -3429,7 +3406,7 @@ static uint get_table_structure(const char *table, const char *db, char *table_t
quote_name
(
row
[
SHOW_FIELDNAME
],
name_buff
,
0
));
if
(
opt_header
)
dynstr_append_checked
(
&
select_field_names_for_header
,
quote_
string
(
row
[
SHOW_FIELDNAME
],
name_buff
));
quote_
for_equal
(
row
[
SHOW_FIELDNAME
],
name_buff
));
}
init
=
0
;
/*
...
...
@@ -3534,7 +3511,7 @@ static uint get_table_structure(const char *table, const char *db, char *table_t
quote_name
(
row
[
SHOW_FIELDNAME
],
name_buff
,
0
));
if
(
opt_header
)
dynstr_append_checked
(
&
select_field_names_for_header
,
quote_
string
(
row
[
SHOW_FIELDNAME
],
name_buff
));
quote_
for_equal
(
row
[
SHOW_FIELDNAME
],
name_buff
));
init
=
1
;
}
init
=
0
;
...
...
mysql-test/main/mysqldump-header.result
View file @
768a10d0
...
...
@@ -45,7 +45,18 @@ course_id name description num_years escape_çÇÁá!#%"';5 Course 1 Course Desc
# Dump header and data rows into outfile with several options above combined
#
'course_id','name','description','num_years','escape_çÇÁá!#%"\'';'5','Course 1','Course Description 1','3',\N;
'course_id','name','description','num_years','escape_çÇÁá!#%"\'';'5','Course 1','Course Description 1','3',\N;INSERT INTO `courses` VALUES (4, 'Course 2', 'Course Description 2', 4, NULL);
'course_id','name','description','num_years','escape_çÇÁá!#%"\'';'5','Course 1','Course Description 1','3',\N;
#
# --skip-quote-names
#
course_id name description num_years escape_çÇÁá!#%"'
5 Course 1 Course Description 1 3 \N
#
# --compatible=ansi
#
course_id name description num_years escape_çÇÁá!#%"'
5 Course 1 Course Description 1 3 \N
INSERT INTO `courses` VALUES (4, 'Course 2', 'Course Description 2', 4, NULL);
INSERT INTO `courses` VALUES (3, 'Course 3', 'Course Description 3', 3, NULL);
INSERT INTO `courses` VALUES (2, 'Course 4', 'Course Description 4', 5, NULL);
INSERT INTO `courses` VALUES (1, 'Course 5', 'Course Description 5', 3, NULL);
...
...
mysql-test/main/mysqldump-header.test
View file @
768a10d0
...
...
@@ -58,6 +58,19 @@ INSERT INTO `courses` VALUES (5, 'Course 1', 'Course Description 1', 3, NULL);
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --fields-terminated-by , --fields-optionally-enclosed-by \' --lines-terminated-by \; test
--cat_file $MYSQLTEST_VARDIR/courses.txt
--echo
--echo #
--echo # --skip-quote-names
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --skip-quote-names test
--cat_file $MYSQLTEST_VARDIR/courses.txt
--echo #
--echo # --compatible=ansi
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --compatible=ansi test
--cat_file $MYSQLTEST_VARDIR/courses.txt
INSERT INTO `courses` VALUES (4, '
Course
2
', '
Course
Description
2
', 4, NULL);
INSERT INTO `courses` VALUES (3, '
Course
3
', '
Course
Description
3
', 3, NULL);
INSERT INTO `courses` VALUES (2, '
Course
4
', '
Course
Description
4
', 5, NULL);
...
...
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