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
27815b9c
Commit
27815b9c
authored
Jul 23, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
76c0154e
bc98f214
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
16 deletions
+54
-16
mysql-test/r/view.result
mysql-test/r/view.result
+16
-0
mysql-test/t/view.test
mysql-test/t/view.test
+22
-0
sql/sql_acl.cc
sql/sql_acl.cc
+2
-2
sql/sql_base.cc
sql/sql_base.cc
+1
-1
sql/sql_view.cc
sql/sql_view.cc
+7
-11
sql/sql_yacc.yy
sql/sql_yacc.yy
+4
-1
sql/table.h
sql/table.h
+2
-1
No files found.
mysql-test/r/view.result
View file @
27815b9c
...
...
@@ -977,6 +977,22 @@ ERROR HY000: View 'test.v1' references invalid table(s) or column(s)
drop view v1;
create view v1 (a,a) as select 'a','a';
ERROR 42S21: Duplicate column name 'a'
create procedure p1 () begin declare v int; create view v1 as select v; end;//
Warnings:
Warning 1310 Referring to uninitialized variable v
call p1();
ERROR HY000: View's SELECT contains a variable or parameter
drop procedure p1;
create table t1 (col1 int,col2 char(22));
insert into t1 values(5,'Hello, world of views');
create view v1 as select * from t1;
create view v2 as select * from v1;
update v2 set col2='Hello, view world';
select * from t1;
col1 col2
5 Hello, view world
drop view v2, v1;
drop table t1;
create table t1 (a int, b int);
create view v1 as select a, sum(b) from t1 group by a;
select b from v1 use index (some_index) where b=1;
...
...
mysql-test/t/view.test
View file @
27815b9c
...
...
@@ -901,6 +901,28 @@ drop view v1;
--
error
1060
create
view
v1
(
a
,
a
)
as
select
'a'
,
'a'
;
#
# SP variables inside view test
#
delimiter
//;
create
procedure
p1
()
begin
declare
v
int
;
create
view
v1
as
select
v
;
end
;
//
delimiter
;
//
--
error
1350
call
p1
();
drop
procedure
p1
;
#
# updateablity should be transitive
#
create
table
t1
(
col1
int
,
col2
char
(
22
));
insert
into
t1
values
(
5
,
'Hello, world of views'
);
create
view
v1
as
select
*
from
t1
;
create
view
v2
as
select
*
from
v1
;
update
v2
set
col2
=
'Hello, view world'
;
select
*
from
t1
;
drop
view
v2
,
v1
;
drop
table
t1
;
#
# check 'use index' on view with temporary table
#
...
...
sql/sql_acl.cc
View file @
27815b9c
...
...
@@ -3856,19 +3856,19 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant,
/* db privileges */
grant
->
privilege
|=
acl_get
(
thd
->
host
,
thd
->
ip
,
thd
->
priv_user
,
db
,
0
);
/* table privileges */
rw_rdlock
(
&
LOCK_grant
);
if
(
grant
->
version
!=
grant_version
)
{
rw_rdlock
(
&
LOCK_grant
);
grant
->
grant_table
=
table_hash_search
(
thd
->
host
,
thd
->
ip
,
db
,
thd
->
priv_user
,
table
,
0
);
/* purecov: inspected */
grant
->
version
=
grant_version
;
/* purecov: inspected */
rw_unlock
(
&
LOCK_grant
);
}
if
(
grant
->
grant_table
!=
0
)
{
grant
->
privilege
|=
grant
->
grant_table
->
privs
;
}
rw_unlock
(
&
LOCK_grant
);
}
#endif
sql/sql_base.cc
View file @
27815b9c
...
...
@@ -1760,7 +1760,7 @@ int open_and_lock_tables(THD *thd, TABLE_LIST *tables)
DBUG_ENTER
(
"open_and_lock_tables"
);
uint
counter
;
if
(
open_tables
(
thd
,
tables
,
&
counter
)
||
lock_tables
(
thd
,
tables
,
counter
))
DBUG_RETURN
(
-
1
);
/* purecov: inspected */
DBUG_RETURN
(
thd
->
net
.
report_error
?
-
1
:
1
);
/* purecov: inspected */
DBUG_RETURN
(
mysql_handle_derived
(
thd
->
lex
));
}
...
...
sql/sql_view.cc
View file @
27815b9c
...
...
@@ -330,7 +330,7 @@ static File_option view_parameters[]=
FILE_OPTIONS_STRING
},
{{
view_field_names
[
1
],
3
},
offsetof
(
TABLE_LIST
,
md5
),
FILE_OPTIONS_STRING
},
{{
view_field_names
[
2
],
9
},
offsetof
(
TABLE_LIST
,
updatable
),
{{
view_field_names
[
2
],
9
},
offsetof
(
TABLE_LIST
,
updatable
_view
),
FILE_OPTIONS_ULONGLONG
},
{{
view_field_names
[
3
],
9
},
offsetof
(
TABLE_LIST
,
algorithm
),
FILE_OPTIONS_ULONGLONG
},
...
...
@@ -472,17 +472,17 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
thd
->
lex
->
create_view_algorithm
=
VIEW_ALGORITHM_UNDEFINED
;
}
view
->
algorithm
=
thd
->
lex
->
create_view_algorithm
;
if
((
view
->
updatable
=
(
can_be_merged
&&
view
->
algorithm
!=
VIEW_ALGORITHM_TMEPTABLE
)))
if
((
view
->
updatable
_view
=
(
can_be_merged
&&
view
->
algorithm
!=
VIEW_ALGORITHM_TMEPTABLE
)))
{
// TODO: change here when we will support UNIONs
for
(
TABLE_LIST
*
tbl
=
(
TABLE_LIST
*
)
thd
->
lex
->
select_lex
.
table_list
.
first
;
tbl
;
tbl
=
tbl
->
next_local
)
{
if
(
tbl
->
view
!=
0
&&
!
tbl
->
updatable
)
if
(
tbl
->
view
!=
0
&&
!
tbl
->
updatable
_view
)
{
view
->
updatable
=
0
;
view
->
updatable
_view
=
0
;
break
;
}
}
...
...
@@ -663,6 +663,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
DBUG_ASSERT
(
view_table
!=
0
);
table
->
effective_algorithm
=
VIEW_ALGORITHM_MERGE
;
table
->
updatable
=
(
table
->
updatable_view
!=
0
);
if
(
old_next
)
{
...
...
@@ -692,12 +693,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
table
->
effective_algorithm
=
VIEW_ALGORITHM_TMEPTABLE
;
lex
->
select_lex
.
linkage
=
DERIVED_TABLE_TYPE
;
if
(
table
->
updatable
)
{
//TOTO: warning: can't be updateable, .frm edited by hand. version
//downgrade?
table
->
updatable
=
0
;
}
table
->
updatable
=
0
;
/* SELECT tree link */
lex
->
unit
.
include_down
(
table
->
select_lex
);
...
...
sql/sql_yacc.yy
View file @
27815b9c
...
...
@@ -1987,7 +1987,8 @@ sp_elseifs:
sp_case:
expr THEN_SYM
{
sp_head *sp= Lex->sphead;
LEX *lex= Lex;
sp_head *sp= lex->sphead;
sp_pcontext *ctx= Lex->spcont;
uint ip= sp->instructions();
sp_instr_jump_if_not *i;
...
...
@@ -2005,6 +2006,7 @@ sp_case:
Item *expr= new Item_func_eq(var, $1);
i= new sp_instr_jump_if_not(ip, expr);
lex->variables_used= 1;
}
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
sp->add_instr(i);
...
...
@@ -6170,6 +6172,7 @@ simple_ident:
$1.str);
}
$$ = (Item*) new Item_splocal($1, spv->offset);
lex->variables_used= 1;
}
else
{
...
...
sql/table.h
View file @
27815b9c
...
...
@@ -215,8 +215,8 @@ typedef struct st_table_list
LEX_STRING
view_name
;
/* save view name */
LEX_STRING
timestamp
;
/* GMT time stamp of last operation */
ulonglong
file_version
;
/* version of file's field set */
ulonglong
updatable_view
;
/* VIEW can be updated */
ulonglong
revision
;
/* revision control number */
ulonglong
updatable
;
/* Is VIEW updateable */
ulonglong
algorithm
;
/* 0 any, 1 tmp tables , 2 merging */
uint
effective_algorithm
;
/* which algorithm was really used */
GRANT_INFO
grant
;
...
...
@@ -224,6 +224,7 @@ typedef struct st_table_list
uint
outer_join
;
/* Which join type */
uint
shared
;
/* Used in multi-upd */
uint32
db_length
,
real_name_length
;
bool
updatable
;
/* VIEW/TABLE can be updated now */
bool
straight
;
/* optimize with prev table */
bool
updating
;
/* for replicate-do/ignore table */
bool
force_index
;
/* prefer index over table scan */
...
...
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