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
62d2511d
Commit
62d2511d
authored
Feb 06, 2006
by
pem@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/extern/mysql/bk/mysql-5.0
into mysql.com:/extern/mysql/work/bug16303/mysql-5.0
parents
810cbaf1
c5abd52a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
23 deletions
+74
-23
mysql-test/r/sp-destruct.result
mysql-test/r/sp-destruct.result
+7
-1
mysql-test/t/sp-destruct.test
mysql-test/t/sp-destruct.test
+10
-1
sql/sp.cc
sql/sp.cc
+45
-8
sql/sp.h
sql/sp.h
+4
-1
sql/sql_acl.cc
sql/sql_acl.cc
+1
-1
sql/sql_parse.cc
sql/sql_parse.cc
+7
-11
No files found.
mysql-test/r/sp-destruct.result
View file @
62d2511d
...
@@ -72,6 +72,12 @@ drop trigger t1_ai;
...
@@ -72,6 +72,12 @@ drop trigger t1_ai;
create trigger t1_ai after insert on t1 for each row call bug14233_3();
create trigger t1_ai after insert on t1 for each row call bug14233_3();
insert into t1 values (0);
insert into t1 values (0);
ERROR HY000: Failed to load routine test.bug14233_3. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
ERROR HY000: Failed to load routine test.bug14233_3. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
delete from mysql.proc where name like 'bug14233%';
drop trigger t1_ai;
drop trigger t1_ai;
drop table t1;
drop table t1;
drop function bug14233_1;
drop function bug14233_2;
drop procedure bug14233_3;
show procedure status;
Db Name Type Definer Modified Created Security_type Comment
show function status;
Db Name Type Definer Modified Created Security_type Comment
mysql-test/t/sp-destruct.test
View file @
62d2511d
...
@@ -119,6 +119,15 @@ create trigger t1_ai after insert on t1 for each row call bug14233_3();
...
@@ -119,6 +119,15 @@ create trigger t1_ai after insert on t1 for each row call bug14233_3();
insert
into
t1
values
(
0
);
insert
into
t1
values
(
0
);
# Clean-up
# Clean-up
delete
from
mysql
.
proc
where
name
like
'bug14233%'
;
drop
trigger
t1_ai
;
drop
trigger
t1_ai
;
drop
table
t1
;
drop
table
t1
;
#
# BUG#16303: erroneus stored procedures and functions should be droppable
#
drop
function
bug14233_1
;
drop
function
bug14233_2
;
drop
procedure
bug14233_3
;
# Assert: These should show nothing.
show
procedure
status
;
show
function
status
;
sql/sp.cc
View file @
62d2511d
...
@@ -1002,22 +1002,26 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp,
...
@@ -1002,22 +1002,26 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp,
}
}
/*
This is used by sql_acl.cc:mysql_routine_grant() and is used to find
the routines in 'routines'.
*/
int
int
sp_exist
s_routine
(
THD
*
thd
,
TABLE_LIST
*
tabl
es
,
bool
any
,
bool
no_error
)
sp_exist
_routines
(
THD
*
thd
,
TABLE_LIST
*
routin
es
,
bool
any
,
bool
no_error
)
{
{
TABLE_LIST
*
tabl
e
;
TABLE_LIST
*
routin
e
;
bool
result
=
0
;
bool
result
=
0
;
DBUG_ENTER
(
"sp_exists_routine"
);
DBUG_ENTER
(
"sp_exists_routine"
);
for
(
table
=
tables
;
table
;
table
=
tabl
e
->
next_global
)
for
(
routine
=
routines
;
routine
;
routine
=
routin
e
->
next_global
)
{
{
sp_name
*
name
;
sp_name
*
name
;
LEX_STRING
lex_db
;
LEX_STRING
lex_db
;
LEX_STRING
lex_name
;
LEX_STRING
lex_name
;
lex_db
.
length
=
strlen
(
tabl
e
->
db
);
lex_db
.
length
=
strlen
(
routin
e
->
db
);
lex_name
.
length
=
strlen
(
tabl
e
->
table_name
);
lex_name
.
length
=
strlen
(
routin
e
->
table_name
);
lex_db
.
str
=
thd
->
strmake
(
tabl
e
->
db
,
lex_db
.
length
);
lex_db
.
str
=
thd
->
strmake
(
routin
e
->
db
,
lex_db
.
length
);
lex_name
.
str
=
thd
->
strmake
(
tabl
e
->
table_name
,
lex_name
.
length
);
lex_name
.
str
=
thd
->
strmake
(
routin
e
->
table_name
,
lex_name
.
length
);
name
=
new
sp_name
(
lex_db
,
lex_name
);
name
=
new
sp_name
(
lex_db
,
lex_name
);
name
->
init_qname
(
thd
);
name
->
init_qname
(
thd
);
if
(
sp_find_routine
(
thd
,
TYPE_ENUM_PROCEDURE
,
name
,
if
(
sp_find_routine
(
thd
,
TYPE_ENUM_PROCEDURE
,
name
,
...
@@ -1034,7 +1038,7 @@ sp_exists_routine(THD *thd, TABLE_LIST *tables, bool any, bool no_error)
...
@@ -1034,7 +1038,7 @@ sp_exists_routine(THD *thd, TABLE_LIST *tables, bool any, bool no_error)
if
(
!
no_error
)
if
(
!
no_error
)
{
{
my_error
(
ER_SP_DOES_NOT_EXIST
,
MYF
(
0
),
"FUNCTION or PROCEDURE"
,
my_error
(
ER_SP_DOES_NOT_EXIST
,
MYF
(
0
),
"FUNCTION or PROCEDURE"
,
tabl
e
->
table_name
);
routin
e
->
table_name
);
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
}
}
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
...
@@ -1044,6 +1048,39 @@ sp_exists_routine(THD *thd, TABLE_LIST *tables, bool any, bool no_error)
...
@@ -1044,6 +1048,39 @@ sp_exists_routine(THD *thd, TABLE_LIST *tables, bool any, bool no_error)
}
}
/*
Check if a routine exists in the mysql.proc table, without actually
parsing the definition. (Used for dropping)
SYNOPSIS
sp_routine_exists_in_table()
thd - thread context
name - name of procedure
RETURN VALUE
0 - Success
non-0 - Error; SP_OPEN_TABLE_FAILED or SP_KEY_NOT_FOUND
*/
int
sp_routine_exists_in_table
(
THD
*
thd
,
int
type
,
sp_name
*
name
)
{
TABLE
*
table
;
int
ret
;
Open_tables_state
open_tables_state_backup
;
if
(
!
(
table
=
open_proc_table_for_read
(
thd
,
&
open_tables_state_backup
)))
ret
=
SP_OPEN_TABLE_FAILED
;
else
{
if
((
ret
=
db_find_routine_aux
(
thd
,
type
,
name
,
table
))
!=
SP_OK
)
ret
=
SP_KEY_NOT_FOUND
;
close_proc_table
(
thd
,
&
open_tables_state_backup
);
}
return
ret
;
}
int
int
sp_create_procedure
(
THD
*
thd
,
sp_head
*
sp
)
sp_create_procedure
(
THD
*
thd
,
sp_head
*
sp
)
{
{
...
...
sql/sp.h
View file @
62d2511d
...
@@ -40,7 +40,10 @@ sp_find_routine(THD *thd, int type, sp_name *name,
...
@@ -40,7 +40,10 @@ sp_find_routine(THD *thd, int type, sp_name *name,
sp_cache
**
cp
,
bool
cache_only
);
sp_cache
**
cp
,
bool
cache_only
);
int
int
sp_exists_routine
(
THD
*
thd
,
TABLE_LIST
*
procs
,
bool
any
,
bool
no_error
);
sp_exist_routines
(
THD
*
thd
,
TABLE_LIST
*
procs
,
bool
any
,
bool
no_error
);
int
sp_routine_exists_in_table
(
THD
*
thd
,
int
type
,
sp_name
*
name
);
int
int
sp_create_procedure
(
THD
*
thd
,
sp_head
*
sp
);
sp_create_procedure
(
THD
*
thd
,
sp_head
*
sp
);
...
...
sql/sql_acl.cc
View file @
62d2511d
...
@@ -3030,7 +3030,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
...
@@ -3030,7 +3030,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
if
(
!
revoke_grant
)
if
(
!
revoke_grant
)
{
{
if
(
sp_exist
s_routine
(
thd
,
table_list
,
is_proc
,
no_error
)
<
0
)
if
(
sp_exist
_routines
(
thd
,
table_list
,
is_proc
,
no_error
)
<
0
)
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
}
}
...
...
sql/sql_parse.cc
View file @
62d2511d
...
@@ -4445,21 +4445,17 @@ mysql_execute_command(THD *thd)
...
@@ -4445,21 +4445,17 @@ mysql_execute_command(THD *thd)
case
SQLCOM_DROP_PROCEDURE
:
case
SQLCOM_DROP_PROCEDURE
:
case
SQLCOM_DROP_FUNCTION
:
case
SQLCOM_DROP_FUNCTION
:
{
{
sp_head
*
sp
;
int
result
;
int
result
;
char
*
db
,
*
name
;
int
type
=
(
lex
->
sql_command
==
SQLCOM_DROP_PROCEDURE
?
TYPE_ENUM_PROCEDURE
:
TYPE_ENUM_FUNCTION
);
if
(
lex
->
sql_command
==
SQLCOM_DROP_PROCEDURE
)
result
=
sp_routine_exists_in_table
(
thd
,
type
,
lex
->
spname
);
sp
=
sp_find_routine
(
thd
,
TYPE_ENUM_PROCEDURE
,
lex
->
spname
,
&
thd
->
sp_proc_cache
,
FALSE
);
else
sp
=
sp_find_routine
(
thd
,
TYPE_ENUM_FUNCTION
,
lex
->
spname
,
&
thd
->
sp_func_cache
,
FALSE
);
mysql_reset_errors
(
thd
,
0
);
mysql_reset_errors
(
thd
,
0
);
if
(
sp
)
if
(
result
==
SP_OK
)
{
{
db
=
thd
->
strdup
(
sp
->
m_db
.
str
);
char
*
db
=
lex
->
spname
->
m_db
.
str
;
name
=
thd
->
strdup
(
sp
->
m_name
.
str
);
char
*
name
=
lex
->
spname
->
m_name
.
str
;
if
(
check_routine_access
(
thd
,
ALTER_PROC_ACL
,
db
,
name
,
if
(
check_routine_access
(
thd
,
ALTER_PROC_ACL
,
db
,
name
,
lex
->
sql_command
==
SQLCOM_DROP_PROCEDURE
,
0
))
lex
->
sql_command
==
SQLCOM_DROP_PROCEDURE
,
0
))
goto
error
;
goto
error
;
...
...
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