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
e9ad2183
Commit
e9ad2183
authored
May 29, 2006
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
manual merge
parent
3ff39504
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
43 deletions
+76
-43
client/mysqldump.c
client/mysqldump.c
+24
-40
mysql-test/r/mysqldump.result
mysql-test/r/mysqldump.result
+39
-1
mysql-test/t/mysqldump.test
mysql-test/t/mysqldump.test
+13
-2
No files found.
client/mysqldump.c
View file @
e9ad2183
...
@@ -2785,14 +2785,13 @@ static my_bool dump_all_views_in_db(char *database)
...
@@ -2785,14 +2785,13 @@ static my_bool dump_all_views_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
*
table_res
;
MYSQL_RES
*
table_res
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
char
query
[
50
+
2
*
NAME_LEN
];
char
query
[
50
+
2
*
NAME_LEN
];
...
@@ -2809,8 +2808,6 @@ static int get_actual_table_name(const char *old_table_name,
...
@@ -2809,8 +2808,6 @@ static int get_actual_table_name(const char *old_table_name,
safe_exit
(
EX_MYSQLERR
);
safe_exit
(
EX_MYSQLERR
);
}
}
retval
=
1
;
if
((
table_res
=
mysql_store_result
(
sock
)))
if
((
table_res
=
mysql_store_result
(
sock
)))
{
{
my_ulonglong
num_rows
=
mysql_num_rows
(
table_res
);
my_ulonglong
num_rows
=
mysql_num_rows
(
table_res
);
...
@@ -2821,54 +2818,44 @@ static int get_actual_table_name(const char *old_table_name,
...
@@ -2821,54 +2818,44 @@ static int get_actual_table_name(const char *old_table_name,
TODO: Return all matching rows
TODO: Return all matching rows
*/
*/
row
=
mysql_fetch_row
(
table_res
);
row
=
mysql_fetch_row
(
table_res
);
strmake
(
new_table_name
,
row
[
0
],
buf_size
-
1
);
ulong
*
lengths
=
mysql_fetch_lengths
(
table_res
);
retval
=
0
;
name
=
strmake_root
(
root
,
row
[
0
],
lengths
[
0
])
;
}
}
mysql_free_result
(
table_res
);
mysql_free_result
(
table_res
);
}
}
return
retval
;
DBUG_PRINT
(
"exit"
,
(
"new_table_name: %s"
,
name
));
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
i
;
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
*
table_name
;
char
*
*
dump_tables
,
**
pos
,
**
end
;
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
);
for
(;
tables
>
0
;
tables
--
,
table_names
++
)
for
(;
tables
>
0
;
tables
--
,
table_names
++
)
{
{
/* 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
(
*
pos
,
table_buff
,
1
));
quote_name
(
new_table_name
,
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
{
{
...
@@ -2878,6 +2865,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
...
@@ -2878,6 +2865,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
/* We shall countinue here, if --force was given */
/* We shall countinue here, if --force was given */
}
}
}
}
end
=
pos
;
if
(
lock_tables
)
if
(
lock_tables
)
{
{
...
@@ -2897,24 +2885,20 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
...
@@ -2897,24 +2885,20 @@ 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
(
pos
=
dump_tables
;
pos
<
end
;
pos
++
)
{
{
table_name
=
hash_element
(
&
dump_tables
,
i
);
DBUG_PRINT
(
"info"
,(
"Dumping table %s"
,
*
pos
));
DBUG_PRINT
(
"info"
,(
"Dumping table %s"
,
table_name
));
dump_table
(
*
pos
,
db
);
dump_table
(
table_name
,
db
);
if
(
opt_dump_triggers
&&
if
(
opt_dump_triggers
&&
mysql_get_server_version
(
sock
)
>=
50009
)
mysql_get_server_version
(
sock
)
>=
50009
)
dump_triggers_for_table
(
table_name
,
db
);
dump_triggers_for_table
(
*
pos
,
db
);
}
}
/* Dump each selected view */
/* Dump each selected view */
if
(
was_views
)
if
(
was_views
)
{
{
for
(
i
=
0
;
i
<
dump_tables
.
records
;
i
++
)
for
(
pos
=
dump_tables
;
pos
<
end
;
pos
++
)
{
get_view_structure
(
*
pos
,
db
);
table_name
=
hash_element
(
&
dump_tables
,
i
);
get_view_structure
(
table_name
,
db
);
}
}
}
/* obtain dump of routines (procs/functions) */
/* obtain dump of routines (procs/functions) */
if
(
opt_routines
&&
!
opt_xml
&&
if
(
opt_routines
&&
!
opt_xml
&&
...
@@ -2923,7 +2907,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
...
@@ -2923,7 +2907,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
DBUG_PRINT
(
"info"
,
(
"Dumping routines for database %s"
,
db
));
DBUG_PRINT
(
"info"
,
(
"Dumping routines for database %s"
,
db
));
dump_routines_for_db
(
db
);
dump_routines_for_db
(
db
);
}
}
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 @
e9ad2183
DROP TABLE IF EXISTS t1, `"t"1`, t1aa, t2, t2aa;
DROP TABLE IF EXISTS t1, `"t"1`, t1aa, t2, t2aa
, t3
;
drop database if exists mysqldump_test_db;
drop database if exists mysqldump_test_db;
drop database if exists db1;
drop database if exists db1;
drop database if exists db2;
drop database if exists db2;
...
@@ -2669,6 +2669,44 @@ UNLOCK TABLES;
...
@@ -2669,6 +2669,44 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
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 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!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;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!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
create table t1 (a int);
create table t1 (a int);
insert into t1 values (289), (298), (234), (456), (789);
insert into t1 values (289), (298), (234), (456), (789);
create definer = CURRENT_USER view v1 as select * from t1;
create definer = CURRENT_USER view v1 as select * from t1;
...
...
mysql-test/t/mysqldump.test
View file @
e9ad2183
...
@@ -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`
,
t1aa
,
t2
,
t2aa
;
DROP
TABLE
IF
EXISTS
t1
,
`"t"1`
,
t1aa
,
t2
,
t2aa
,
t3
;
drop
database
if
exists
mysqldump_test_db
;
drop
database
if
exists
mysqldump_test_db
;
drop
database
if
exists
db1
;
drop
database
if
exists
db1
;
drop
database
if
exists
db2
;
drop
database
if
exists
db2
;
...
@@ -1065,7 +1065,18 @@ insert into t1 values ('','');
...
@@ -1065,7 +1065,18 @@ insert into t1 values ('','');
--
exec
$MYSQL_DUMP
--
skip
-
comments
--
hex
-
blob
test
t1
--
exec
$MYSQL_DUMP
--
skip
-
comments
--
hex
-
blob
test
t1
drop
table
t1
;
drop
table
t1
;
# End of 4.1 tests
#
# 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
#
#
# Bug 14871 Invalid view dump output
# Bug 14871 Invalid view dump output
...
...
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