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
efb8b990
Commit
efb8b990
authored
Apr 13, 2006
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The check for recursive view definitions added. (BUG#14308)
parent
df69944e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
1 deletion
+75
-1
mysql-test/r/view.result
mysql-test/r/view.result
+23
-0
mysql-test/t/view.test
mysql-test/t/view.test
+31
-0
sql/share/errmsg.txt
sql/share/errmsg.txt
+2
-0
sql/sql_view.cc
sql/sql_view.cc
+19
-1
No files found.
mysql-test/r/view.result
View file @
efb8b990
...
...
@@ -2600,3 +2600,26 @@ id td
5 2005-01-04
DROP VIEW v1;
DROP TABLE t1;
create table t1 (a int);
create view v1 as select * from t1;
create view v2 as select * from v1;
drop table t1;
rename table v2 to t1;
select * from v1;
ERROR HY000: `test`.`v1` contain view recursion
drop view t1, v1;
create table t1 (a int);
create function f1() returns int
begin
declare mx int;
select max(a) from t1 into mx;
return mx;
end//
create view v1 as select f1() as a;
create view v2 as select * from v1;
drop table t1;
rename table v2 to t1;
select * from v1;
ERROR HY000: Recursive stored functions and triggers are not allowed.
drop function f1;
drop view t1, v1;
mysql-test/t/view.test
View file @
efb8b990
...
...
@@ -2454,3 +2454,34 @@ SELECT * FROM v1 WHERE td BETWEEN '2005.01.02' AND '2005.01.04';
DROP
VIEW
v1
;
DROP
TABLE
t1
;
#
# BUG#14308: Recursive view definitions
#
# using view only
create
table
t1
(
a
int
);
create
view
v1
as
select
*
from
t1
;
create
view
v2
as
select
*
from
v1
;
drop
table
t1
;
rename
table
v2
to
t1
;
--
error
ER_VIEW_RECURSIVE
select
*
from
v1
;
drop
view
t1
,
v1
;
# using SP function
create
table
t1
(
a
int
);
delimiter
//;
create
function
f1
()
returns
int
begin
declare
mx
int
;
select
max
(
a
)
from
t1
into
mx
;
return
mx
;
end
//
delimiter
;
//
create
view
v1
as
select
f1
()
as
a
;
create
view
v2
as
select
*
from
v1
;
drop
table
t1
;
rename
table
v2
to
t1
;
--
error
ER_SP_NO_RECURSION
select
*
from
v1
;
drop
function
f1
;
drop
view
t1
,
v1
;
sql/share/errmsg.txt
View file @
efb8b990
...
...
@@ -5613,3 +5613,5 @@ ER_SP_NO_AGGREGATE 42000
eng "AGGREGATE is not supported for stored functions"
ER_MAX_PREPARED_STMT_COUNT_REACHED 42000
eng "Can't create more than max_prepared_stmt_count statements (current value: %lu)"
ER_VIEW_RECURSIVE
eng "`%-.64s`.`%-.64s` contain view recursion"
sql/sql_view.cc
View file @
efb8b990
...
...
@@ -771,6 +771,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table)
SELECT_LEX
*
end
,
*
view_select
;
LEX
*
old_lex
,
*
lex
;
Query_arena
*
arena
,
backup
;
TABLE_LIST
*
top_view
=
table
->
top_table
();
int
res
;
bool
result
;
DBUG_ENTER
(
"mysql_make_view"
);
...
...
@@ -798,6 +799,24 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table)
DBUG_RETURN
(
0
);
}
/* check loop via view definition */
for
(
TABLE_LIST
*
precedent
=
table
->
referencing_view
;
precedent
;
precedent
=
precedent
->
referencing_view
)
{
if
(
precedent
->
view_name
.
length
==
table
->
table_name_length
&&
precedent
->
view_db
.
length
==
table
->
db_length
&&
my_strcasecmp
(
system_charset_info
,
precedent
->
view_name
.
str
,
table
->
table_name
)
==
0
&&
my_strcasecmp
(
system_charset_info
,
precedent
->
view_db
.
str
,
table
->
db
)
==
0
)
{
my_error
(
ER_VIEW_RECURSIVE
,
MYF
(
0
),
top_view
->
view_db
.
str
,
top_view
->
view_name
.
str
);
DBUG_RETURN
(
TRUE
);
}
}
/*
For now we assume that tables will not be changed during PS life (it
will be TRUE as far as we make new table cache).
...
...
@@ -896,7 +915,6 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table)
}
if
(
!
res
&&
!
thd
->
is_fatal_error
)
{
TABLE_LIST
*
top_view
=
table
->
top_table
();
TABLE_LIST
*
view_tables
=
lex
->
query_tables
;
TABLE_LIST
*
view_tables_tail
=
0
;
TABLE_LIST
*
tbl
;
...
...
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