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
4cb63e6b
Commit
4cb63e6b
authored
Sep 08, 2005
by
patg@radha.local
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG #9056 Changes to patch #2 per Serg's review
parent
953dda06
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
87 deletions
+78
-87
client/mysqldump.c
client/mysqldump.c
+20
-23
mysql-test/r/mysqldump.result
mysql-test/r/mysqldump.result
+56
-28
mysql-test/t/mysqldump.test
mysql-test/t/mysqldump.test
+2
-36
No files found.
client/mysqldump.c
View file @
4cb63e6b
...
...
@@ -603,9 +603,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
MYF
(
MY_WME
))))
exit
(
1
);
break
;
case
'R'
:
opt_routines
=
1
;
break
;
case
'W'
:
#ifdef __WIN__
opt_protocol
=
MYSQL_PROTOCOL_PIPE
;
...
...
@@ -1196,15 +1193,13 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
static
uint
dump_routines_for_db
(
char
*
db
)
{
MYSQL_RES
*
routine_res
=
NULL
;
MYSQL_RES
*
routine_list_res
=
NULL
;
MYSQL_ROW
row
,
routine_list_row
;
char
query_buff
[
512
],
routine_type
[
10
];
char
db_name_buff
[
NAME_LEN
+
3
],
name_buff
[
NAME_LEN
+
3
];
char
*
routine_name
;
char
**
routine_list
;
int
i
;
FILE
*
sql_file
=
md_result_file
;
MYSQL_RES
*
routine_res
=
NULL
;
MYSQL_RES
*
routine_list_res
=
NULL
;
MYSQL_ROW
row
,
routine_list_row
;
DBUG_ENTER
(
"dump_routines_for_db"
);
...
...
@@ -1214,7 +1209,15 @@ static uint dump_routines_for_db (char *db)
/* nice comments */
if
(
opt_comments
)
fprintf
(
sql_file
,
"
\n
--
\n
-- Dumping routines for database '%s'
\n
--
\n
"
,
db
);
mysql_query
(
sock
,
"LOCK TABLES mysql.proc READ"
);
/*
not using "mysql_query_with_error_report" because of privileges
*/
if
(
opt_lock
)
mysql_query
(
sock
,
"LOCK TABLES mysql.proc READ"
);
fprintf
(
sql_file
,
"
\n
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
\n
"
);
fprintf
(
sql_file
,
"DELIMITER //
\n
"
);
/* 0, retrieve and dump functions, 1, procedures */
for
(
i
=
0
;
i
<=
1
;
i
++
)
...
...
@@ -1225,15 +1228,12 @@ static uint dump_routines_for_db (char *db)
my_snprintf
(
query_buff
,
sizeof
(
query_buff
),
"SHOW %s STATUS WHERE Db = '%s'"
,
routine_type
,
db_name_buff
);
mysql_query
(
sock
,
query_buff
);
if
(
!
(
routine_list_res
=
mysql_store_result
(
sock
)
))
if
(
mysql_query_with_error_report
(
sock
,
&
routine_list_res
,
query_buff
))
DBUG_RETURN
(
1
);
if
(
mysql_num_rows
(
routine_list_res
))
{
fprintf
(
sql_file
,
"
\n
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
\n
"
);
fprintf
(
sql_file
,
"DELIMITER //
\n
"
);
while
((
routine_list_row
=
mysql_fetch_row
(
routine_list_res
)))
{
...
...
@@ -1244,12 +1244,7 @@ static uint dump_routines_for_db (char *db)
routine_type
,
name_buff
);
if
(
mysql_query_with_error_report
(
sock
,
&
routine_res
,
query_buff
))
{
if
(
path
)
my_fclose
(
sql_file
,
MYF
(
MY_WME
));
safe_exit
(
EX_MYSQLERR
);
DBUG_RETURN
(
1
);
}
while
((
row
=
mysql_fetch_row
(
routine_res
)))
{
...
...
@@ -1272,21 +1267,23 @@ static uint dump_routines_for_db (char *db)
can't be in comments
*/
/* create proc/func body */
;
fprintf
(
sql_file
,
i
==
0
?
"%s //
\n
"
:
"/*!50003 %s */ //
\n
"
,
row
[
2
]);
fprintf
(
sql_file
,
"/*!50003 %s */ //
\n
"
,
row
[
2
]);
}
}
/* end of routine printing */
}
/* end of list of routines */
/* set the delimiter back to ';' */
fprintf
(
sql_file
,
"DELIMITER ;
\n
"
);
fprintf
(
sql_file
,
"/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;
\n
"
);
mysql_free_result
(
routine_res
);
routine_res
=
NULL
;
}
mysql_free_result
(
routine_list_res
);
routine_list_res
=
NULL
;
}
/* end of for i (0 .. 1) */
/* set the delimiter back to ';' */
fprintf
(
sql_file
,
"DELIMITER ;
\n
"
);
fprintf
(
sql_file
,
"/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;
\n
"
);
mysql_query
(
sock
,
"UNLOCK TABLES"
);
/* again, no error report due to permissions */
if
(
opt_lock
)
mysql_query
(
sock
,
"UNLOCK TABLES"
);
DBUG_RETURN
(
0
);
}
...
...
mysql-test/r/mysqldump.result
View file @
4cb63e6b
...
...
@@ -1897,37 +1897,65 @@ CREATE PROCEDURE bug9056_proc2(OUT a INT)
BEGIN
select sum(id) from t1 into a;
END //
SELECT db, name, type, definer, param_list, body
FROM mysql.proc
WHERE db = 'test';
db name type definer param_list body
test bug9056_func1 FUNCTION root@localhost a INT, b INT RETURN a+b
test bug9056_func2 FUNCTION root@localhost f1 char binary begin
set f1= concat( 'hello', f1 );
return f1;
end
test bug9056_proc1 PROCEDURE root@localhost IN a INT, IN b INT, OUT c INT BEGIN SELECT a+b INTO c; end
test bug9056_proc2 PROCEDURE root@localhost OUT a INT BEGIN
select sum(id) from t1 into a;
END
DROP PROCEDURE IF EXISTS bug9056_func1;
DROP PROCEDURE IF EXISTS bug9056_func2;
DROP PROCEDURE IF EXISTS bug9056_proc1;
DROP PROCEDURE IF EXISTS bug9056_proc2;
drop table t1;
SELECT db, name, type, definer, param_list, body
FROM mysql.proc
WHERE db = 'test';
db name type definer param_list body
test bug9056_func1 FUNCTION root@localhost a INT, b INT RETURN a+b
test bug9056_func2 FUNCTION root@localhost f1 char binary begin
/*!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 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test`;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`id` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1),(2),(3),(4),(5);
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER //
/*!50003 SET SESSION SQL_MODE=""*/ //
/*!50003 DROP FUNCTION IF EXISTS bug9056_func1 */ //
/*!50003 CREATE FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11)
RETURN a+b */ //
/*!50003 SET SESSION SQL_MODE=""*/ //
/*!50003 DROP FUNCTION IF EXISTS bug9056_func2 */ //
/*!50003 CREATE FUNCTION `bug9056_func2`(f1 char binary) RETURNS char(1)
begin
set f1= concat( 'hello', f1 );
return f1;
end
test bug9056_proc1 PROCEDURE root@localhost IN a INT, IN b INT, OUT c INT BEGIN SELECT a+b INTO c; end
test bug9056_proc2 PROCEDURE root@localhost OUT a INT BEGIN
end */ //
/*!50003 SET SESSION SQL_MODE=""*/ //
/*!50003 DROP PROCEDURE IF EXISTS bug9056_proc1 */ //
/*!50003 CREATE PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT)
BEGIN SELECT a+b INTO c; end */ //
/*!50003 SET SESSION SQL_MODE=""*/ //
/*!50003 DROP PROCEDURE IF EXISTS bug9056_proc2 */ //
/*!50003 CREATE PROCEDURE `bug9056_proc2`(OUT a INT)
BEGIN
select sum(id) from t1 into a;
END
END */ //
DELIMITER ;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;
/*!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 PROCEDURE IF EXISTS bug9056_func1;
DROP PROCEDURE IF EXISTS bug9056_func2;
DROP PROCEDURE IF EXISTS bug9056_proc1;
...
...
mysql-test/t/mysqldump.test
View file @
4cb63e6b
...
...
@@ -797,44 +797,10 @@ END //
DELIMITER
;
//
# just to see what you've created
# this will not work because of the timestamps!
# show procedure status;
#show create procedure bug9056_proc1;
#show create procedure bug9056_proc2;
#show function status;
#show create function bug9056_func1;
#show create function bug9056_func2;
SELECT
db
,
name
,
type
,
definer
,
param_list
,
body
FROM
mysql
.
proc
WHERE
db
=
'test'
;
# Dump the DB and ROUTINES
--
exec
$MYSQL_DUMP
--
skip
-
comments
--
routines
--
databases
test
>
var
/
tmp
/
mysqldump
.
sql
# ok, now blow it all away
--
disable_warnings
DROP
PROCEDURE
IF
EXISTS
bug9056_func1
;
DROP
PROCEDURE
IF
EXISTS
bug9056_func2
;
DROP
PROCEDURE
IF
EXISTS
bug9056_proc1
;
DROP
PROCEDURE
IF
EXISTS
bug9056_proc2
;
drop
table
t1
;
--
enable
-
warnings
# Now, restore
--
exec
$MYSQL
test
<
var
/
tmp
/
mysqldump
.
sql
# Check that the routines have been reloaded
# this will not work because of the timestamps!
#show procedure status;
#show create procedure bug9056_proc1;
#show create procedure bug9056_proc2;
#show function status;
#show create function bug9056_func1;
#show create function bug9056_func2;
SELECT
db
,
name
,
type
,
definer
,
param_list
,
body
FROM
mysql
.
proc
WHERE
db
=
'test'
;
--
exec
$MYSQL_DUMP
--
skip
-
comments
--
routines
--
databases
test
# ok, now blow it all away
--
disable_warnings
DROP
PROCEDURE
IF
EXISTS
bug9056_func1
;
DROP
PROCEDURE
IF
EXISTS
bug9056_func2
;
...
...
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