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
94bfede7
Commit
94bfede7
authored
Aug 24, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new method to detect commands where all VIEWs should be temporary tables (BUG#4803)
parent
7e778e11
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
2 deletions
+49
-2
mysql-test/r/view.result
mysql-test/r/view.result
+9
-0
mysql-test/t/view.test
mysql-test/t/view.test
+11
-0
sql/sql_lex.cc
sql/sql_lex.cc
+24
-1
sql/sql_lex.h
sql/sql_lex.h
+1
-0
sql/sql_view.cc
sql/sql_view.cc
+4
-1
No files found.
mysql-test/r/view.result
View file @
94bfede7
...
@@ -1083,3 +1083,12 @@ count(*)
...
@@ -1083,3 +1083,12 @@ count(*)
2
2
drop view v1;
drop view v1;
drop table t1;
drop table t1;
create table t1 (a int);
create table t2 (a int);
create view v1 as select a from t1;
create view v2 as select a from t2 where a in (select a from v1);
show create view v2;
Table Create Table
v2 CREATE VIEW test.v2 AS select `test`.`t2`.`a` AS `a` from `test`.`t2` where `a` in (select `v1`.`a` AS `a` from `test`.`v1`)
drop view v2, v1;
drop table t1, t2;
mysql-test/t/view.test
View file @
94bfede7
...
@@ -1027,3 +1027,14 @@ insert into t1 values (null);
...
@@ -1027,3 +1027,14 @@ insert into t1 values (null);
select
*
from
v1
;
select
*
from
v1
;
drop
view
v1
;
drop
view
v1
;
drop
table
t1
;
drop
table
t1
;
#
# Showing VIEW with VIEWs in subquery
#
create
table
t1
(
a
int
);
create
table
t2
(
a
int
);
create
view
v1
as
select
a
from
t1
;
create
view
v2
as
select
a
from
t2
where
a
in
(
select
a
from
v1
);
show
create
view
v2
;
drop
view
v2
,
v1
;
drop
table
t1
,
t2
;
sql/sql_lex.cc
View file @
94bfede7
...
@@ -1546,7 +1546,7 @@ bool st_lex::can_be_merged()
...
@@ -1546,7 +1546,7 @@ bool st_lex::can_be_merged()
}
}
/*
/*
check if command can use VIEW with MERGE algorithm
check if command can use VIEW with MERGE algorithm
(for top VIEWs)
SYNOPSIS
SYNOPSIS
st_lex::can_use_merged()
st_lex::can_use_merged()
...
@@ -1576,6 +1576,29 @@ bool st_lex::can_use_merged()
...
@@ -1576,6 +1576,29 @@ bool st_lex::can_use_merged()
}
}
}
}
/*
check if command can't use merged views in any part of command
SYNOPSIS
st_lex::can_not_use_merged()
RETURN
FALSE - command can't use merged VIEWs
TRUE - VIEWs with MERGE algorithms can be used
*/
bool
st_lex
::
can_not_use_merged
()
{
switch
(
sql_command
)
{
case
SQLCOM_CREATE_VIEW
:
case
SQLCOM_SHOW_CREATE
:
return
TRUE
;
default:
return
FALSE
;
}
}
/*
/*
Detect that we need only table structure of derived table/view
Detect that we need only table structure of derived table/view
...
...
sql/sql_lex.h
View file @
94bfede7
...
@@ -749,6 +749,7 @@ typedef struct st_lex
...
@@ -749,6 +749,7 @@ typedef struct st_lex
bool
can_be_merged
();
bool
can_be_merged
();
bool
can_use_merged
();
bool
can_use_merged
();
bool
can_not_use_merged
();
bool
only_view_structure
();
bool
only_view_structure
();
}
LEX
;
}
LEX
;
...
...
sql/sql_view.cc
View file @
94bfede7
...
@@ -659,7 +659,8 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -659,7 +659,8 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
if
(
table
->
algorithm
!=
VIEW_ALGORITHM_TMEPTABLE
&&
if
(
table
->
algorithm
!=
VIEW_ALGORITHM_TMEPTABLE
&&
lex
->
can_be_merged
()
&&
lex
->
can_be_merged
()
&&
(
table
->
select_lex
->
master_unit
()
!=
&
old_lex
->
unit
||
(
table
->
select_lex
->
master_unit
()
!=
&
old_lex
->
unit
||
old_lex
->
can_use_merged
()))
old_lex
->
can_use_merged
())
&&
!
old_lex
->
can_not_use_merged
())
{
{
/*
/*
TODO: support multi tables substitutions
TODO: support multi tables substitutions
...
@@ -672,6 +673,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -672,6 +673,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
DBUG_ASSERT
(
view_table
!=
0
);
DBUG_ASSERT
(
view_table
!=
0
);
table
->
effective_algorithm
=
VIEW_ALGORITHM_MERGE
;
table
->
effective_algorithm
=
VIEW_ALGORITHM_MERGE
;
DBUG_PRINT
(
"info"
,
(
"algorithm: MERGE"
));
table
->
updatable
=
(
table
->
updatable_view
!=
0
);
table
->
updatable
=
(
table
->
updatable_view
!=
0
);
if
(
old_next
)
if
(
old_next
)
...
@@ -701,6 +703,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -701,6 +703,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
}
}
table
->
effective_algorithm
=
VIEW_ALGORITHM_TMEPTABLE
;
table
->
effective_algorithm
=
VIEW_ALGORITHM_TMEPTABLE
;
DBUG_PRINT
(
"info"
,
(
"algorithm: TEMPORARY TABLE"
));
lex
->
select_lex
.
linkage
=
DERIVED_TABLE_TYPE
;
lex
->
select_lex
.
linkage
=
DERIVED_TABLE_TYPE
;
table
->
updatable
=
0
;
table
->
updatable
=
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