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
a13efc7d
Commit
a13efc7d
authored
Jan 19, 2005
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
efd7420d
1affa4df
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
156 additions
and
4 deletions
+156
-4
mysql-test/r/rpl_view.result
mysql-test/r/rpl_view.result
+44
-0
mysql-test/r/view.result
mysql-test/r/view.result
+20
-0
mysql-test/t/rpl_view.test
mysql-test/t/rpl_view.test
+44
-0
mysql-test/t/view.test
mysql-test/t/view.test
+18
-0
sql/sql_acl.cc
sql/sql_acl.cc
+3
-0
sql/sql_parse.cc
sql/sql_parse.cc
+12
-2
sql/table.cc
sql/table.cc
+15
-2
No files found.
mysql-test/r/rpl_view.result
0 → 100644
View file @
a13efc7d
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
drop table if exists t1,v1;
drop view if exists t1,v1;
create table t1 (a int);
insert into t1 values (1);
create view v1 as select a from t1;
insert into v1 values (2);
select * from v1 order by a;
a
1
2
select * from v1 order by a;
a
1
2
update v1 set a=3 where a=1;
select * from v1 order by a;
a
2
3
select * from v1 order by a;
a
2
3
delete from v1 where a=2;
select * from v1 order by a;
a
3
select * from v1 order by a;
a
3
alter view v1 as select a as b from t1;
select * from v1 order by 1;
b
3
drop view v1;
select * from v1 order by a;
ERROR 42S02: Table 'test.v1' doesn't exist
drop table t1;
mysql-test/r/view.result
View file @
a13efc7d
...
@@ -1730,3 +1730,23 @@ select * from v1 where F1 = 1;
...
@@ -1730,3 +1730,23 @@ select * from v1 where F1 = 1;
f1
f1
drop view v1;
drop view v1;
drop table t1;
drop table t1;
create table t1(c1 int);
create table t2(c2 int);
insert into t1 values (1),(2),(3);
insert into t2 values (1);
SELECT c1 FROM t1 WHERE c1 IN (SELECT c2 FROM t2);
c1
1
SELECT c1 FROM t1 WHERE EXISTS (SELECT c2 FROM t2 WHERE c2 = c1);
c1
1
create view v1 as SELECT c1 FROM t1 WHERE c1 IN (SELECT c2 FROM t2);
create view v2 as SELECT c1 FROM t1 WHERE EXISTS (SELECT c2 FROM t2 WHERE c2 = c1);
select * from v1;
c1
1
select * from v2;
c1
1
drop view v2, v1;
drop table t1, t2;
mysql-test/t/rpl_view.test
0 → 100644
View file @
a13efc7d
source
include
/
master
-
slave
.
inc
;
--
disable_warnings
drop
table
if
exists
t1
,
v1
;
drop
view
if
exists
t1
,
v1
;
sync_slave_with_master
;
--
enable_warnings
#
# Check that createion drop of view is replicated, also check replication of
# updating of view
#
connection
master
;
create
table
t1
(
a
int
);
insert
into
t1
values
(
1
);
create
view
v1
as
select
a
from
t1
;
insert
into
v1
values
(
2
);
select
*
from
v1
order
by
a
;
sync_slave_with_master
;
# view already have to be on slave
select
*
from
v1
order
by
a
;
connection
master
;
update
v1
set
a
=
3
where
a
=
1
;
select
*
from
v1
order
by
a
;
sync_slave_with_master
;
select
*
from
v1
order
by
a
;
connection
master
;
delete
from
v1
where
a
=
2
;
select
*
from
v1
order
by
a
;
sync_slave_with_master
;
select
*
from
v1
order
by
a
;
connection
master
;
# 'alter view' internally maped to creation, but still check that it works
alter
view
v1
as
select
a
as
b
from
t1
;
sync_slave_with_master
;
select
*
from
v1
order
by
1
;
connection
master
;
drop
view
v1
;
sync_slave_with_master
;
#error, because view have to be removed from slave
--
error
1146
select
*
from
v1
order
by
a
;
connection
master
;
drop
table
t1
;
sync_slave_with_master
;
mysql-test/t/view.test
View file @
a13efc7d
...
@@ -1655,9 +1655,27 @@ select * from v3;
...
@@ -1655,9 +1655,27 @@ select * from v3;
drop
view
v3
;
drop
view
v3
;
drop
tables
t1
,
t2
;
drop
tables
t1
,
t2
;
#
# View field names should be case insensitive
# View field names should be case insensitive
#
create
table
t1
(
f1
int
);
create
table
t1
(
f1
int
);
create
view
v1
as
select
f1
from
t1
;
create
view
v1
as
select
f1
from
t1
;
select
*
from
v1
where
F1
=
1
;
select
*
from
v1
where
F1
=
1
;
drop
view
v1
;
drop
view
v1
;
drop
table
t1
;
drop
table
t1
;
#
# Resolving view fields in subqueries in VIEW (Bug #6394)
#
create
table
t1
(
c1
int
);
create
table
t2
(
c2
int
);
insert
into
t1
values
(
1
),(
2
),(
3
);
insert
into
t2
values
(
1
);
SELECT
c1
FROM
t1
WHERE
c1
IN
(
SELECT
c2
FROM
t2
);
SELECT
c1
FROM
t1
WHERE
EXISTS
(
SELECT
c2
FROM
t2
WHERE
c2
=
c1
);
create
view
v1
as
SELECT
c1
FROM
t1
WHERE
c1
IN
(
SELECT
c2
FROM
t2
);
create
view
v2
as
SELECT
c1
FROM
t1
WHERE
EXISTS
(
SELECT
c2
FROM
t2
WHERE
c2
=
c1
);
select
*
from
v1
;
select
*
from
v2
;
drop
view
v2
,
v1
;
drop
table
t1
,
t2
;
sql/sql_acl.cc
View file @
a13efc7d
...
@@ -5516,6 +5516,9 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant,
...
@@ -5516,6 +5516,9 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant,
/* global privileges */
/* global privileges */
grant
->
privilege
=
thd
->
master_access
;
grant
->
privilege
=
thd
->
master_access
;
if
(
!
thd
->
priv_user
)
return
;
// it is slave
/* db privileges */
/* db privileges */
grant
->
privilege
|=
acl_get
(
thd
->
host
,
thd
->
ip
,
thd
->
priv_user
,
db
,
0
);
grant
->
privilege
|=
acl_get
(
thd
->
host
,
thd
->
ip
,
thd
->
priv_user
,
db
,
0
);
...
...
sql/sql_parse.cc
View file @
a13efc7d
...
@@ -4059,7 +4059,12 @@ mysql_execute_command(THD *thd)
...
@@ -4059,7 +4059,12 @@ mysql_execute_command(THD *thd)
}
}
case
SQLCOM_CREATE_VIEW
:
case
SQLCOM_CREATE_VIEW
:
{
{
res
=
mysql_create_view
(
thd
,
thd
->
lex
->
create_view_mode
);
if
(
!
(
res
=
mysql_create_view
(
thd
,
thd
->
lex
->
create_view_mode
))
&&
mysql_bin_log
.
is_open
())
{
Query_log_event
qinfo
(
thd
,
thd
->
query
,
thd
->
query_length
,
0
,
FALSE
);
mysql_bin_log
.
write
(
&
qinfo
);
}
break
;
break
;
}
}
case
SQLCOM_DROP_VIEW
:
case
SQLCOM_DROP_VIEW
:
...
@@ -4067,7 +4072,12 @@ mysql_execute_command(THD *thd)
...
@@ -4067,7 +4072,12 @@ mysql_execute_command(THD *thd)
if
(
check_table_access
(
thd
,
DROP_ACL
,
all_tables
,
0
)
||
if
(
check_table_access
(
thd
,
DROP_ACL
,
all_tables
,
0
)
||
end_active_trans
(
thd
))
end_active_trans
(
thd
))
goto
error
;
goto
error
;
res
=
mysql_drop_view
(
thd
,
first_table
,
thd
->
lex
->
drop_mode
);
if
(
!
(
res
=
mysql_drop_view
(
thd
,
first_table
,
thd
->
lex
->
drop_mode
))
&&
mysql_bin_log
.
is_open
())
{
Query_log_event
qinfo
(
thd
,
thd
->
query
,
thd
->
query_length
,
0
,
FALSE
);
mysql_bin_log
.
write
(
&
qinfo
);
}
break
;
break
;
}
}
case
SQLCOM_CREATE_TRIGGER
:
case
SQLCOM_CREATE_TRIGGER
:
...
...
sql/table.cc
View file @
a13efc7d
...
@@ -1695,6 +1695,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
...
@@ -1695,6 +1695,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
Field_translator
*
transl
;
Field_translator
*
transl
;
SELECT_LEX
*
select
=
&
view
->
select_lex
;
SELECT_LEX
*
select
=
&
view
->
select_lex
;
SELECT_LEX
*
current_select_save
=
thd
->
lex
->
current_select
;
SELECT_LEX
*
current_select_save
=
thd
->
lex
->
current_select
;
byte
*
main_table_list_save
=
thd
->
lex
->
select_lex
.
table_list
.
first
;
Item
*
item
;
Item
*
item
;
TABLE_LIST
*
tbl
;
TABLE_LIST
*
tbl
;
List_iterator_fast
<
Item
>
it
(
select
->
item_list
);
List_iterator_fast
<
Item
>
it
(
select
->
item_list
);
...
@@ -1717,8 +1718,13 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
...
@@ -1717,8 +1718,13 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
if
(
field_translation
)
if
(
field_translation
)
{
{
DBUG_PRINT
(
"info"
,
(
"there are already translation table"
));
DBUG_PRINT
(
"info"
,
(
"there are already translation table"
));
/* prevent look up in SELECTs tree */
/*
prevent look up in SELECTs tree, and emulate main table list by
ancestor table list for subquery processing
*/
thd
->
lex
->
current_select
=
&
thd
->
lex
->
select_lex
;
thd
->
lex
->
current_select
=
&
thd
->
lex
->
select_lex
;
thd
->
lex
->
select_lex
.
table_list
.
first
=
(
byte
*
)
ancestor
;
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
1
;
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
1
;
thd
->
set_query_id
=
1
;
thd
->
set_query_id
=
1
;
/* this view was prepared already on previous PS/SP execution */
/* this view was prepared already on previous PS/SP execution */
...
@@ -1763,8 +1769,13 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
...
@@ -1763,8 +1769,13 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
/* prevent look up in SELECTs tree */
/*
prevent look up in SELECTs tree, and emulate main table list by ancestor
table list for subquery processing
*/
thd
->
lex
->
current_select
=
&
thd
->
lex
->
select_lex
;
thd
->
lex
->
current_select
=
&
thd
->
lex
->
select_lex
;
thd
->
lex
->
select_lex
.
table_list
.
first
=
(
byte
*
)
ancestor
;
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
1
;
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
1
;
/*
/*
...
@@ -1909,6 +1920,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
...
@@ -1909,6 +1920,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
ok:
ok:
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
save_wrapper
;
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
save_wrapper
;
thd
->
lex
->
current_select
=
current_select_save
;
thd
->
lex
->
current_select
=
current_select_save
;
thd
->
lex
->
select_lex
.
table_list
.
first
=
main_table_list_save
;
thd
->
set_query_id
=
save_set_query_id
;
thd
->
set_query_id
=
save_set_query_id
;
thd
->
allow_sum_func
=
save_allow_sum_func
;
thd
->
allow_sum_func
=
save_allow_sum_func
;
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
...
@@ -1923,6 +1935,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
...
@@ -1923,6 +1935,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
}
}
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
save_wrapper
;
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
save_wrapper
;
thd
->
lex
->
current_select
=
current_select_save
;
thd
->
lex
->
current_select
=
current_select_save
;
thd
->
lex
->
select_lex
.
table_list
.
first
=
main_table_list_save
;
thd
->
set_query_id
=
save_set_query_id
;
thd
->
set_query_id
=
save_set_query_id
;
thd
->
allow_sum_func
=
save_allow_sum_func
;
thd
->
allow_sum_func
=
save_allow_sum_func
;
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
...
...
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