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
dffac28b
Commit
dffac28b
authored
Jan 05, 2005
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed views with PS protocol
parent
4cbe3225
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
182 additions
and
171 deletions
+182
-171
mysql-test/r/view.result
mysql-test/r/view.result
+0
-101
mysql-test/r/view_query_cache.result
mysql-test/r/view_query_cache.result
+101
-0
mysql-test/t/view.test
mysql-test/t/view.test
+0
-57
mysql-test/t/view_query_cache.test
mysql-test/t/view_query_cache.test
+58
-0
sql/item_func.cc
sql/item_func.cc
+1
-1
sql/sql_base.cc
sql/sql_base.cc
+12
-7
sql/sql_yacc.yy
sql/sql_yacc.yy
+4
-1
sql/table.cc
sql/table.cc
+5
-4
sql/table.h
sql/table.h
+1
-0
No files found.
mysql-test/r/view.result
View file @
dffac28b
...
...
@@ -363,107 +363,6 @@ v4 CREATE ALGORITHM=TEMPTABLE VIEW `mysqltest`.`v4` AS select (`mysqltest`.`t2`.
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
delete from mysql.user where user='mysqltest_1';
drop database mysqltest;
set GLOBAL query_cache_size=1355776;
flush status;
create table t1 (a int, b int);
create view v1 (c,d) as select sql_no_cache a,b from t1;
create view v2 (c,d) as select a+rand(),b from t1;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
select * from v2;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
select * from v2;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
drop view v1,v2;
set query_cache_type=demand;
flush status;
create view v1 (c,d) as select sql_cache a,b from t1;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from t1;
a b
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
select * from t1;
a b
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
drop view v1;
set query_cache_type=default;
drop table t1;
set GLOBAL query_cache_size=default;
create table t1 (a int);
insert into t1 values (1), (2), (3), (1), (2), (3);
create view v1 as select distinct a from t1;
...
...
mysql-test/r/view_query_cache.result
0 → 100644
View file @
dffac28b
set GLOBAL query_cache_size=1355776;
flush status;
create table t1 (a int, b int);
create view v1 (c,d) as select sql_no_cache a,b from t1;
create view v2 (c,d) as select a+rand(),b from t1;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
select * from v2;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
select * from v2;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
drop view v1,v2;
set query_cache_type=demand;
flush status;
create view v1 (c,d) as select sql_cache a,b from t1;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from t1;
a b
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
select * from t1;
a b
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
drop view v1;
set query_cache_type=default;
drop table t1;
set GLOBAL query_cache_size=default;
mysql-test/t/view.test
View file @
dffac28b
...
...
@@ -328,63 +328,6 @@ revoke all privileges on mysqltest.* from mysqltest_1@localhost;
delete
from
mysql
.
user
where
user
=
'mysqltest_1'
;
drop
database
mysqltest
;
#
# QUERY CACHE options for VIEWs
#
set
GLOBAL
query_cache_size
=
1355776
;
flush
status
;
create
table
t1
(
a
int
,
b
int
);
# queries with following views should not be in query cache
create
view
v1
(
c
,
d
)
as
select
sql_no_cache
a
,
b
from
t1
;
create
view
v2
(
c
,
d
)
as
select
a
+
rand
(),
b
from
t1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
select
*
from
v1
;
select
*
from
v2
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
select
*
from
v1
;
select
*
from
v2
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
drop
view
v1
,
v2
;
# SQL_CACHE option
set
query_cache_type
=
demand
;
flush
status
;
# query with view will be cached, but direct acess to table will not
create
view
v1
(
c
,
d
)
as
select
sql_cache
a
,
b
from
t1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
select
*
from
v1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
select
*
from
t1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
select
*
from
v1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
select
*
from
t1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
drop
view
v1
;
set
query_cache_type
=
default
;
drop
table
t1
;
set
GLOBAL
query_cache_size
=
default
;
#
# DISTINCT option for VIEW
#
...
...
mysql-test/t/view_query_cache.test
0 → 100644
View file @
dffac28b
--
source
include
/
have_query_cache
.
inc
#
# QUERY CACHE options for VIEWs
#
set
GLOBAL
query_cache_size
=
1355776
;
flush
status
;
create
table
t1
(
a
int
,
b
int
);
# queries with following views should not be in query cache
create
view
v1
(
c
,
d
)
as
select
sql_no_cache
a
,
b
from
t1
;
create
view
v2
(
c
,
d
)
as
select
a
+
rand
(),
b
from
t1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
select
*
from
v1
;
select
*
from
v2
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
select
*
from
v1
;
select
*
from
v2
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
drop
view
v1
,
v2
;
# SQL_CACHE option
set
query_cache_type
=
demand
;
flush
status
;
# query with view will be cached, but direct acess to table will not
create
view
v1
(
c
,
d
)
as
select
sql_cache
a
,
b
from
t1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
select
*
from
v1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
select
*
from
t1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
select
*
from
v1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
select
*
from
t1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
drop
view
v1
;
set
query_cache_type
=
default
;
drop
table
t1
;
set
GLOBAL
query_cache_size
=
default
;
sql/item_func.cc
View file @
dffac28b
...
...
@@ -194,8 +194,8 @@ bool Item_func::agg_arg_charsets(DTCollation &coll,
}
if
((
*
arg
)
->
type
()
==
FIELD_ITEM
)
((
Item_field
*
)(
*
arg
))
->
no_const_subst
=
1
;
conv
->
fix_fields
(
thd
,
0
,
&
conv
);
*
arg
=
conv
;
conv
->
fix_fields
(
thd
,
0
,
arg
);
}
if
(
arena
)
thd
->
restore_backup_item_arena
(
arena
,
&
backup
);
...
...
sql/sql_base.cc
View file @
dffac28b
...
...
@@ -2262,7 +2262,7 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
field makes some prepared query ambiguous and so erroneous, but we
accept this trade off.
*/
if
(
item
->
cached_table
->
table
)
if
(
item
->
cached_table
->
table
&&
!
item
->
cached_table
->
view
)
{
found
=
find_field_in_real_table
(
thd
,
item
->
cached_table
->
table
,
name
,
length
,
...
...
@@ -3047,15 +3047,19 @@ insert_fields(THD *thd, TABLE_LIST *tables, const char *db_name,
&
not_used_field_index
,
TRUE
))
{
Item
*
item
=
iterator
->
item
(
thd
);
if
(
view
&&
!
thd
->
lex
->
current_select
->
no_wrap_view_item
)
{
/*
as far as we have view, then item point to view_iter, so we
can use it directly for this view specific operation
*/
item
=
new
Item_ref
(
view_iter
.
item_ptr
(),
tables
->
view_name
.
str
,
field_name
);
}
if
(
!
found
++
)
(
void
)
it
->
replace
(
item
);
// Replace '*'
else
it
->
after
(
item
);
if
(
view
&&
!
thd
->
lex
->
current_select
->
no_wrap_view_item
)
{
item
=
new
Item_ref
(
it
->
ref
(),
tables
->
view_name
.
str
,
field_name
);
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if
(
any_privileges
)
{
...
...
@@ -3328,7 +3332,8 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, COND **conds)
thd
->
restore_backup_item_arena
(
arena
,
&
backup
);
if
(
embedded
->
on_expr
&&
!
embedded
->
on_expr
->
fixed
)
{
if
(
embedded
->
on_expr
->
fix_fields
(
thd
,
tables
,
&
table
->
on_expr
))
if
(
embedded
->
on_expr
->
fix_fields
(
thd
,
tables
,
&
embedded
->
on_expr
))
goto
err_no_arena
;
}
}
...
...
sql/sql_yacc.yy
View file @
dffac28b
...
...
@@ -5577,6 +5577,7 @@ insert:
LEX *lex= Lex;
lex->sql_command= SQLCOM_INSERT;
lex->duplicates= DUP_ERROR;
mysql_init_select(lex);
/* for subselects */
lex->lock_option= (using_update_log) ? TL_READ_NO_INSERT : TL_READ;
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
...
...
@@ -5596,6 +5597,7 @@ replace:
LEX *lex=Lex;
lex->sql_command = SQLCOM_REPLACE;
lex->duplicates= DUP_REPLACE;
mysql_init_select(lex);
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
}
replace_lock_option insert2
...
...
@@ -5796,6 +5798,7 @@ delete:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_DELETE;
mysql_init_select(lex);
lex->lock_option= lex->thd->update_lock_default;
lex->ignore= 0;
lex->select_lex.init_order();
...
...
@@ -7124,6 +7127,7 @@ set:
{
LEX *lex=Lex;
lex->sql_command= SQLCOM_SET_OPTION;
mysql_init_select(lex);
lex->option_type=OPT_SESSION;
lex->var_list.empty();
lex->one_shot_set= 0;
...
...
@@ -7190,7 +7194,6 @@ option_value:
}
else
lex->var_list.push_back(new set_var_user(new Item_func_set_user_var($2,$4)));
}
| internal_variable_name equal set_expr_or_default
{
...
...
sql/table.cc
View file @
dffac28b
...
...
@@ -1702,6 +1702,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
if
(
field_translation
)
{
DBUG_PRINT
(
"info"
,
(
"there are already translation table"
));
/* prevent look up in SELECTs tree */
thd
->
lex
->
current_select
=
&
thd
->
lex
->
select_lex
;
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
1
;
...
...
@@ -1727,7 +1728,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
if
(
where
&&
!
where
->
fixed
&&
where
->
fix_fields
(
thd
,
ancestor
,
&
where
))
goto
err
;
if
(
check_option
&&
!
check_option
->
fixed
&&
check_option
->
fix_fields
(
thd
,
ancestor
,
&
where
))
check_option
->
fix_fields
(
thd
,
ancestor
,
&
check_option
))
goto
err
;
restore_want_privilege
();
...
...
@@ -1767,11 +1768,11 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
{
/* save original name of view column */
char
*
name
=
item
->
name
;
if
(
!
item
->
fixed
&&
item
->
fix_fields
(
thd
,
ancestor
,
&
item
))
transl
[
i
].
item
=
item
;
if
(
!
item
->
fixed
&&
item
->
fix_fields
(
thd
,
ancestor
,
&
transl
[
i
].
item
))
goto
err
;
/* set new item get in fix fields and original column name */
transl
[
i
].
name
=
name
;
transl
[
i
++
].
item
=
item
;
transl
[
i
++
].
name
=
name
;
}
field_translation
=
transl
;
/* TODO: sort this list? Use hash for big number of fields */
...
...
sql/table.h
View file @
dffac28b
...
...
@@ -428,6 +428,7 @@ class Field_iterator_view: public Field_iterator
bool
end_of_fields
()
{
return
ptr
==
array_end
;
}
const
char
*
name
();
Item
*
item
(
THD
*
thd
)
{
return
ptr
->
item
;
}
Item
**
item_ptr
()
{
return
&
ptr
->
item
;
}
Field
*
field
()
{
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