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
56d8567a
Commit
56d8567a
authored
Sep 01, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding mysql.proc to table list if view contains stored procedures (BUG#5151)
parent
771c2998
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
13 deletions
+79
-13
mysql-test/r/view.result
mysql-test/r/view.result
+17
-2
mysql-test/t/view.test
mysql-test/t/view.test
+17
-1
sql/item_func.cc
sql/item_func.cc
+2
-1
sql/sp.cc
sql/sp.cc
+10
-4
sql/sql_lex.h
sql/sql_lex.h
+1
-0
sql/sql_parse.cc
sql/sql_parse.cc
+1
-1
sql/sql_view.cc
sql/sql_view.cc
+31
-4
No files found.
mysql-test/r/view.result
View file @
56d8567a
...
@@ -940,7 +940,7 @@ grant update,select(b) on mysqltest.t2 to mysqltest_1@localhost;
...
@@ -940,7 +940,7 @@ grant update,select(b) on mysqltest.t2 to mysqltest_1@localhost;
create view v4 as select b+1 from mysqltest.t2;
create view v4 as select b+1 from mysqltest.t2;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
drop database mysqltest;
drop database mysqltest;
drop view v1,v2;
drop view v1,v2
,v4
;
set sql_mode='ansi';
set sql_mode='ansi';
create table t1 ("a*b" int);
create table t1 ("a*b" int);
create view v1 as select "a*b" from t1;
create view v1 as select "a*b" from t1;
...
@@ -1040,7 +1040,6 @@ CREATE VIEW v02 AS SELECT * FROM DUAL;
...
@@ -1040,7 +1040,6 @@ CREATE VIEW v02 AS SELECT * FROM DUAL;
ERROR HY000: No tables used
ERROR HY000: No tables used
SHOW TABLES;
SHOW TABLES;
Tables_in_test table_type
Tables_in_test table_type
v4 VIEW
CREATE VIEW v1 AS SELECT EXISTS (SELECT 1 UNION SELECT 2);
CREATE VIEW v1 AS SELECT EXISTS (SELECT 1 UNION SELECT 2);
select * from v1;
select * from v1;
EXISTS (SELECT 1 UNION SELECT 2)
EXISTS (SELECT 1 UNION SELECT 2)
...
@@ -1202,3 +1201,19 @@ select * from v1;
...
@@ -1202,3 +1201,19 @@ select * from v1;
5
5
drop view v1;
drop view v1;
drop table t1;
drop table t1;
create function x1 () returns int return 5;
create table t1 (s1 int);
create view v1 as select x1() from t1;
drop function x1;
select * from v1;
ERROR 42000: FUNCTION test.x1 does not exist
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 9 Fixed 0 0 0 21474836479 1024 0 NULL # # NULL latin1_swedish_ci NULL
v1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL view
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 9 Fixed 0 0 0 21474836479 1024 0 NULL # # NULL latin1_swedish_ci NULL
v1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL view
drop view v1;
drop table t1;
mysql-test/t/view.test
View file @
56d8567a
...
@@ -849,7 +849,7 @@ create view v4 as select b+1 from mysqltest.t2;
...
@@ -849,7 +849,7 @@ create view v4 as select b+1 from mysqltest.t2;
connection
root
;
connection
root
;
REVOKE
ALL
PRIVILEGES
,
GRANT
OPTION
FROM
mysqltest_1
@
localhost
;
REVOKE
ALL
PRIVILEGES
,
GRANT
OPTION
FROM
mysqltest_1
@
localhost
;
drop
database
mysqltest
;
drop
database
mysqltest
;
drop
view
v1
,
v2
;
drop
view
v1
,
v2
,
v4
;
#
#
# VIEW fields quoting
# VIEW fields quoting
...
@@ -1145,3 +1145,19 @@ create view v1 as select 5 from t1 order by 1;
...
@@ -1145,3 +1145,19 @@ create view v1 as select 5 from t1 order by 1;
select
*
from
v1
;
select
*
from
v1
;
drop
view
v1
;
drop
view
v1
;
drop
table
t1
;
drop
table
t1
;
#
# VIEW over droped function
#
create
function
x1
()
returns
int
return
5
;
create
table
t1
(
s1
int
);
create
view
v1
as
select
x1
()
from
t1
;
drop
function
x1
;
--
error
1304
select
*
from
v1
;
--
replace_column
12
# 13 #
show
table
status
;
--
replace_column
12
# 13 #
show
table
status
;
drop
view
v1
;
drop
table
t1
;
sql/item_func.cc
View file @
56d8567a
...
@@ -3270,7 +3270,7 @@ Item_func_sp::Item_func_sp(sp_name *name, List<Item> &list)
...
@@ -3270,7 +3270,7 @@ Item_func_sp::Item_func_sp(sp_name *name, List<Item> &list)
const
char
*
const
char
*
Item_func_sp
::
func_name
()
const
Item_func_sp
::
func_name
()
const
{
{
THD
*
thd
=
current_thd
;
THD
*
thd
=
current_thd
;
/* Calculate length to avoud reallocation of string for sure */
/* Calculate length to avoud reallocation of string for sure */
uint
len
=
((
m_name
->
m_db
.
length
+
uint
len
=
((
m_name
->
m_db
.
length
+
m_name
->
m_name
.
length
)
*
2
+
//characters*quoting
m_name
->
m_name
.
length
)
*
2
+
//characters*quoting
...
@@ -3280,6 +3280,7 @@ Item_func_sp::func_name() const
...
@@ -3280,6 +3280,7 @@ Item_func_sp::func_name() const
ALIGN_SIZE
(
1
));
// to avoid String reallocation
ALIGN_SIZE
(
1
));
// to avoid String reallocation
String
qname
((
char
*
)
alloc_root
(
&
thd
->
mem_root
,
len
),
len
,
String
qname
((
char
*
)
alloc_root
(
&
thd
->
mem_root
,
len
),
len
,
system_charset_info
);
system_charset_info
);
qname
.
length
(
0
);
qname
.
length
(
0
);
append_identifier
(
thd
,
&
qname
,
m_name
->
m_db
.
str
,
m_name
->
m_db
.
length
);
append_identifier
(
thd
,
&
qname
,
m_name
->
m_db
.
str
,
m_name
->
m_db
.
length
);
qname
.
append
(
'.'
);
qname
.
append
(
'.'
);
...
...
sql/sp.cc
View file @
56d8567a
...
@@ -93,10 +93,15 @@ db_find_routine_aux(THD *thd, int type, sp_name *name,
...
@@ -93,10 +93,15 @@ db_find_routine_aux(THD *thd, int type, sp_name *name,
key
[
128
]
=
type
;
key
[
128
]
=
type
;
keylen
=
sizeof
(
key
);
keylen
=
sizeof
(
key
);
for
(
table
=
thd
->
open_tables
;
table
;
table
=
table
->
next
)
if
(
thd
->
lex
->
proc_table
)
if
(
strcmp
(
table
->
table_cache_key
,
"mysql"
)
==
0
&&
table
=
thd
->
lex
->
proc_table
->
table
;
strcmp
(
table
->
real_name
,
"proc"
)
==
0
)
else
break
;
{
for
(
table
=
thd
->
open_tables
;
table
;
table
=
table
->
next
)
if
(
strcmp
(
table
->
table_cache_key
,
"mysql"
)
==
0
&&
strcmp
(
table
->
real_name
,
"proc"
)
==
0
)
break
;
}
if
(
table
)
if
(
table
)
*
opened
=
FALSE
;
*
opened
=
FALSE
;
else
else
...
@@ -954,6 +959,7 @@ sp_cache_functions(THD *thd, LEX *lex)
...
@@ -954,6 +959,7 @@ sp_cache_functions(THD *thd, LEX *lex)
LEX
*
newlex
=
new
st_lex
;
LEX
*
newlex
=
new
st_lex
;
thd
->
lex
=
newlex
;
thd
->
lex
=
newlex
;
newlex
->
proc_table
=
oldlex
->
proc_table
;
// hint if mysql.oper is opened
name
.
m_name
.
str
=
strchr
(
name
.
m_qname
.
str
,
'.'
);
name
.
m_name
.
str
=
strchr
(
name
.
m_qname
.
str
,
'.'
);
name
.
m_db
.
length
=
name
.
m_name
.
str
-
name
.
m_qname
.
str
;
name
.
m_db
.
length
=
name
.
m_name
.
str
-
name
.
m_qname
.
str
;
name
.
m_db
.
str
=
strmake_root
(
&
thd
->
mem_root
,
name
.
m_db
.
str
=
strmake_root
(
&
thd
->
mem_root
,
...
...
sql/sql_lex.h
View file @
56d8567a
...
@@ -641,6 +641,7 @@ typedef struct st_lex
...
@@ -641,6 +641,7 @@ typedef struct st_lex
TABLE_LIST
*
query_tables
;
/* global list of all tables in this query */
TABLE_LIST
*
query_tables
;
/* global list of all tables in this query */
/* last element next_global of previous list */
/* last element next_global of previous list */
TABLE_LIST
**
query_tables_last
;
TABLE_LIST
**
query_tables_last
;
TABLE_LIST
*
proc_table
;
/* refer to mysql.proc if it was opened by VIEW */
List
<
key_part_spec
>
col_list
;
List
<
key_part_spec
>
col_list
;
List
<
key_part_spec
>
ref_list
;
List
<
key_part_spec
>
ref_list
;
...
...
sql/sql_parse.cc
View file @
56d8567a
...
@@ -4246,7 +4246,7 @@ mysql_init_query(THD *thd, uchar *buf, uint length, bool lexonly)
...
@@ -4246,7 +4246,7 @@ mysql_init_query(THD *thd, uchar *buf, uint length, bool lexonly)
lex
->
lock_option
=
TL_READ
;
lex
->
lock_option
=
TL_READ
;
lex
->
found_colon
=
0
;
lex
->
found_colon
=
0
;
lex
->
safe_to_cache_query
=
1
;
lex
->
safe_to_cache_query
=
1
;
lex
->
query_tables
=
0
;
lex
->
proc_table
=
lex
->
query_tables
=
0
;
lex
->
query_tables_last
=
&
lex
->
query_tables
;
lex
->
query_tables_last
=
&
lex
->
query_tables
;
lex
->
variables_used
=
0
;
lex
->
variables_used
=
0
;
lex
->
select_lex
.
parent_lex
=
lex
;
lex
->
select_lex
.
parent_lex
=
lex
;
...
...
sql/sql_view.cc
View file @
56d8567a
...
@@ -520,6 +520,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
...
@@ -520,6 +520,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
my_bool
my_bool
mysql_make_view
(
File_parser
*
parser
,
TABLE_LIST
*
table
)
mysql_make_view
(
File_parser
*
parser
,
TABLE_LIST
*
table
)
{
{
bool
include_proc_table
=
0
;
DBUG_ENTER
(
"mysql_make_view"
);
DBUG_ENTER
(
"mysql_make_view"
);
if
(
table
->
view
)
if
(
table
->
view
)
...
@@ -612,10 +613,25 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -612,10 +613,25 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
table
->
belong_to_view
:
table
->
belong_to_view
:
table
);
table
);
/* move SP to main LEX */
if
(
lex
->
spfuns
.
records
)
sp_merge_funs
(
old_lex
,
lex
);
{
if
(
lex
->
spfuns
.
array
.
buffer
)
/* move SP to main LEX */
hash_free
(
&
lex
->
spfuns
);
sp_merge_funs
(
old_lex
,
lex
);
if
(
lex
->
spfuns
.
array
.
buffer
)
hash_free
(
&
lex
->
spfuns
);
if
(
old_lex
->
proc_table
==
0
&&
(
old_lex
->
proc_table
=
(
TABLE_LIST
*
)
thd
->
calloc
(
sizeof
(
TABLE_LIST
)))
!=
0
)
{
TABLE_LIST
*
table
=
old_lex
->
proc_table
;
table
->
db
=
(
char
*
)
"mysql"
;
table
->
db_length
=
5
;
table
->
real_name
=
table
->
alias
=
(
char
*
)
"proc"
;
table
->
real_name_length
=
4
;
table
->
cacheable_table
=
1
;
include_proc_table
=
1
;
}
}
old_next
=
table
->
next_global
;
old_next
=
table
->
next_global
;
if
((
table
->
next_global
=
lex
->
query_tables
))
if
((
table
->
next_global
=
lex
->
query_tables
))
...
@@ -742,6 +758,17 @@ ok:
...
@@ -742,6 +758,17 @@ ok:
lex
->
all_selects_list
->
link_prev
=
lex
->
all_selects_list
->
link_prev
=
(
st_select_lex_node
**
)
&
old_lex
->
all_selects_list
;
(
st_select_lex_node
**
)
&
old_lex
->
all_selects_list
;
if
(
include_proc_table
)
{
TABLE_LIST
*
proc
=
old_lex
->
proc_table
;
if
((
proc
->
next_global
=
table
->
next_global
))
{
table
->
next_global
->
prev_global
=
&
proc
->
next_global
;
}
proc
->
prev_global
=
&
table
->
next_global
;
table
->
next_global
=
proc
;
}
thd
->
lex
=
old_lex
;
thd
->
lex
=
old_lex
;
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
...
...
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