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
13baf757
Commit
13baf757
authored
May 19, 2006
by
ramil@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for bug #18536: mysqldump does not maintain table orders as per --tables option
parent
28cf1060
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
35 deletions
+68
-35
client/mysqldump.c
client/mysqldump.c
+21
-33
mysql-test/r/mysqldump.result
mysql-test/r/mysqldump.result
+35
-1
mysql-test/t/mysqldump.test
mysql-test/t/mysqldump.test
+12
-1
No files found.
client/mysqldump.c
View file @
13baf757
...
@@ -2215,14 +2215,13 @@ static int dump_all_tables_in_db(char *database)
...
@@ -2215,14 +2215,13 @@ static int dump_all_tables_in_db(char *database)
different case (e.g. T1 vs t1)
different case (e.g. T1 vs t1)
RETURN
RETURN
int - 0 if a tablename was retrieved. 1 if not
pointer to the table name
0 if error
*/
*/
static
int
get_actual_table_name
(
const
char
*
old_table_name
,
static
char
*
get_actual_table_name
(
const
char
*
old_table_name
,
MEM_ROOT
*
root
)
char
*
new_table_name
,
int
buf_size
)
{
{
int
retval
;
char
*
name
=
0
;
MYSQL_RES
*
tableRes
;
MYSQL_RES
*
tableRes
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
char
query
[
50
+
2
*
NAME_LEN
];
char
query
[
50
+
2
*
NAME_LEN
];
...
@@ -2241,40 +2240,36 @@ static int get_actual_table_name(const char *old_table_name,
...
@@ -2241,40 +2240,36 @@ static int get_actual_table_name(const char *old_table_name,
}
}
tableRes
=
mysql_store_result
(
sock
);
tableRes
=
mysql_store_result
(
sock
);
retval
=
1
;
if
(
tableRes
!=
NULL
)
if
(
tableRes
!=
NULL
)
{
{
my_ulonglong
numRows
=
mysql_num_rows
(
tableRes
);
my_ulonglong
numRows
=
mysql_num_rows
(
tableRes
);
if
(
numRows
>
0
)
if
(
numRows
>
0
)
{
{
row
=
mysql_fetch_row
(
tableRes
);
row
=
mysql_fetch_row
(
tableRes
);
strmake
(
new_table_name
,
row
[
0
],
buf_size
-
1
);
ulong
*
lengths
=
mysql_fetch_lengths
(
tableRes
);
retval
=
0
;
name
=
strmake_root
(
root
,
row
[
0
],
lengths
[
0
]);
DBUG_PRINT
(
"info"
,
(
"new_table_name: %s"
,
new_table_name
));
}
}
mysql_free_result
(
tableRes
);
mysql_free_result
(
tableRes
);
}
}
DBUG_PRINT
(
"exit"
,
(
"
retval: %d"
,
retval
));
DBUG_PRINT
(
"exit"
,
(
"
new_table_name: %s"
,
name
));
DBUG_RETURN
(
retval
);
DBUG_RETURN
(
name
);
}
}
static
int
dump_selected_tables
(
char
*
db
,
char
**
table_names
,
int
tables
)
static
int
dump_selected_tables
(
char
*
db
,
char
**
table_names
,
int
tables
)
{
{
uint
numrows
,
i
;
uint
numrows
;
char
table_buff
[
NAME_LEN
*+
3
];
char
table_buff
[
NAME_LEN
*+
3
];
char
new_table_name
[
NAME_LEN
];
DYNAMIC_STRING
lock_tables_query
;
DYNAMIC_STRING
lock_tables_query
;
HASH
dump_tables
;
MEM_ROOT
root
;
char
**
dump_tables
,
**
pos
;
DBUG_ENTER
(
"dump_selected_tables"
);
DBUG_ENTER
(
"dump_selected_tables"
);
if
(
init_dumping
(
db
))
if
(
init_dumping
(
db
))
return
1
;
return
1
;
/* Init hash table for storing the actual name of tables to dump */
init_alloc_root
(
&
root
,
8192
,
0
);
if
(
hash_init
(
&
dump_tables
,
charset_info
,
16
,
0
,
0
,
if
(
!
(
dump_tables
=
pos
=
(
char
**
)
alloc_root
(
&
root
,
tables
*
sizeof
(
char
*
))))
(
hash_get_key
)
get_table_key
,
(
hash_free_key
)
free_table_ent
,
0
))
exit
(
EX_EOM
);
exit
(
EX_EOM
);
init_dynamic_string
(
&
lock_tables_query
,
"LOCK TABLES "
,
256
,
1024
);
init_dynamic_string
(
&
lock_tables_query
,
"LOCK TABLES "
,
256
,
1024
);
...
@@ -2282,22 +2277,16 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
...
@@ -2282,22 +2277,16 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
{
{
/* the table name passed on commandline may be wrong case */
/* the table name passed on commandline may be wrong case */
if
(
!
get_actual_table_name
(
*
table_names
,
if
((
*
pos
=
get_actual_table_name
(
*
table_names
,
&
root
)))
new_table_name
,
sizeof
(
new_table_name
)
))
{
{
/* Add found table name to lock_tables_query */
/* Add found table name to lock_tables_query */
if
(
lock_tables
)
if
(
lock_tables
)
{
{
dynstr_append
(
&
lock_tables_query
,
dynstr_append
(
&
lock_tables_query
,
quote_name
(
new_table_name
,
table_buff
,
1
));
quote_name
(
*
pos
,
table_buff
,
1
));
dynstr_append
(
&
lock_tables_query
,
" READ /*!32311 LOCAL */,"
);
dynstr_append
(
&
lock_tables_query
,
" READ /*!32311 LOCAL */,"
);
}
}
pos
++
;
/* Add found table name to dump_tables list */
if
(
my_hash_insert
(
&
dump_tables
,
(
byte
*
)
my_strdup
(
new_table_name
,
MYF
(
0
))))
exit
(
EX_EOM
);
}
}
else
else
{
{
...
@@ -2326,15 +2315,14 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
...
@@ -2326,15 +2315,14 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
print_xml_tag1
(
md_result_file
,
""
,
"database name="
,
db
,
"
\n
"
);
print_xml_tag1
(
md_result_file
,
""
,
"database name="
,
db
,
"
\n
"
);
/* Dump each selected table */
/* Dump each selected table */
for
(
i
=
0
;
i
<
dump_tables
.
records
;
i
++
)
for
(
;
dump_tables
<
pos
;
dump_tables
++
)
{
{
const
char
*
table_name
=
hash_element
(
&
dump_tables
,
i
);
DBUG_PRINT
(
"info"
,(
"Dumping table %s"
,
*
dump_tables
));
DBUG_PRINT
(
"info"
,(
"Dumping table %s"
,
table_name
));
numrows
=
getTableStructure
(
*
dump_tables
,
db
);
numrows
=
getTableStructure
((
char
*
)
table_name
,
db
);
if
(
!
dFlag
&&
numrows
>
0
)
if
(
!
dFlag
&&
numrows
>
0
)
dumpTable
(
numrows
,
(
char
*
)
table_name
);
dumpTable
(
numrows
,
*
dump_tables
);
}
}
hash_free
(
&
dump_tables
);
free_root
(
&
root
,
MYF
(
0
)
);
my_free
(
order_by
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
order_by
,
MYF
(
MY_ALLOW_ZERO_PTR
));
order_by
=
0
;
order_by
=
0
;
if
(
opt_xml
)
if
(
opt_xml
)
...
...
mysql-test/r/mysqldump.result
View file @
13baf757
DROP TABLE IF EXISTS t1, `"t"1`;
DROP TABLE IF EXISTS t1, `"t"1`
, t2, t3
;
CREATE TABLE t1(a int);
CREATE TABLE t1(a int);
INSERT INTO t1 VALUES (1), (2);
INSERT INTO t1 VALUES (1), (2);
<?xml version="1.0"?>
<?xml version="1.0"?>
...
@@ -1540,4 +1540,38 @@ t1 CREATE TABLE `t1` (
...
@@ -1540,4 +1540,38 @@ t1 CREATE TABLE `t1` (
KEY `t1_name` (`t1_name`)
KEY `t1_name` (`t1_name`)
) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1
) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1
drop table `t1`;
drop table `t1`;
create table t1(a int);
create table t2(a int);
create table t3(a int);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t3`;
CREATE TABLE `t3` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop table t1, t2, t3;
End of 4.1 tests
End of 4.1 tests
mysql-test/t/mysqldump.test
View file @
13baf757
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
--
source
include
/
not_embedded
.
inc
--
source
include
/
not_embedded
.
inc
--
disable_warnings
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
,
`"t"1`
;
DROP
TABLE
IF
EXISTS
t1
,
`"t"1`
,
t2
,
t3
;
--
enable_warnings
--
enable_warnings
# XML output
# XML output
...
@@ -677,4 +677,15 @@ show create table `t1`;
...
@@ -677,4 +677,15 @@ show create table `t1`;
drop
table
`t1`
;
drop
table
`t1`
;
#
# Bug #18536: wrong table order
#
create
table
t1
(
a
int
);
create
table
t2
(
a
int
);
create
table
t3
(
a
int
);
--
error
6
--
exec
$MYSQL_DUMP
--
skip
-
comments
--
force
--
no
-
data
test
t3
t1
non_existing
t2
drop
table
t1
,
t2
,
t3
;
--
echo
End
of
4.1
tests
--
echo
End
of
4.1
tests
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