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
10ce8cde
Commit
10ce8cde
authored
Jul 20, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed quoting of identifiers in VIEWs (BUG#4613)
parent
054cdbe7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
38 deletions
+56
-38
mysql-test/r/view.result
mysql-test/r/view.result
+11
-2
mysql-test/t/view.test
mysql-test/t/view.test
+12
-2
sql/item.cc
sql/item.cc
+15
-16
sql/sql_select.cc
sql/sql_select.cc
+12
-17
sql/sql_view.cc
sql/sql_view.cc
+6
-1
No files found.
mysql-test/r/view.result
View file @
10ce8cde
drop table if exists t1,t2,v1,v2,v3,v4,v5,v6;
drop view if exists t1,t2,v1,v2,v3,v4,v5,v6;
drop table if exists t1,t2,
`t1a``b`,
v1,v2,v3,v4,v5,v6;
drop view if exists t1,t2,
`t1a``b`,
v1,v2,v3,v4,v5,v6;
drop database if exists mysqltest;
use test;
create view v1 (c,d) as select a,b from t1;
...
...
@@ -956,3 +956,12 @@ select * from v1, t1;
a t_column
drop view v1;
drop table t1;
create table `t1a``b` (col1 char(2));
create view v1 as select * from `t1a``b`;
select * from v1;
col1
describe v1;
Field Type Null Key Default Extra
col1 char(2) YES NULL
drop view v1;
drop table `t1a``b`;
mysql-test/t/view.test
View file @
10ce8cde
--
disable_warnings
drop
table
if
exists
t1
,
t2
,
v1
,
v2
,
v3
,
v4
,
v5
,
v6
;
drop
view
if
exists
t1
,
t2
,
v1
,
v2
,
v3
,
v4
,
v5
,
v6
;
drop
table
if
exists
t1
,
t2
,
`t1a``b`
,
v1
,
v2
,
v3
,
v4
,
v5
,
v6
;
drop
view
if
exists
t1
,
t2
,
`t1a``b`
,
v1
,
v2
,
v3
,
v4
,
v5
,
v6
;
drop
database
if
exists
mysqltest
;
--
enable_warnings
use
test
;
...
...
@@ -870,3 +870,13 @@ create view v1 as select 'a';
select
*
from
v1
,
t1
;
drop
view
v1
;
drop
table
t1
;
#
# quote mark inside table name
#
create
table
`t1a``b`
(
col1
char
(
2
));
create
view
v1
as
select
*
from
`t1a``b`
;
select
*
from
v1
;
describe
v1
;
drop
view
v1
;
drop
table
`t1a``b`
;
sql/item.cc
View file @
10ce8cde
...
...
@@ -98,9 +98,9 @@ void Item::print_item_w_name(String *str)
print
(
str
);
if
(
name
)
{
str
->
append
(
" AS `"
,
5
)
;
str
->
append
(
name
);
str
->
append
(
'`'
);
THD
*
thd
=
current_thd
;
str
->
append
(
" AS "
,
4
);
append_identifier
(
thd
,
str
,
name
,
strlen
(
name
)
);
}
}
...
...
@@ -420,33 +420,32 @@ const char *Item_ident::full_name() const
void
Item_ident
::
print
(
String
*
str
)
{
str
->
append
(
'`'
)
;
THD
*
thd
=
current_thd
;
if
(
!
table_name
||
!
field_name
)
{
str
->
append
(
field_name
?
field_name
:
name
?
name
:
"tmp_field"
)
;
str
->
append
(
'`'
);
const
char
*
nm
=
field_name
?
field_name
:
name
?
name
:
"tmp_field"
;
append_identifier
(
thd
,
str
,
nm
,
strlen
(
nm
)
);
return
;
}
if
(
db_name
&&
db_name
[
0
])
{
str
->
append
(
db_name
);
str
->
append
(
"`.`"
,
3
);
str
->
append
(
table_name
);
str
->
append
(
"`.`"
,
3
);
str
->
append
(
field_name
);
append_identifier
(
thd
,
str
,
db_name
,
strlen
(
db_name
)
);
str
->
append
(
'.'
);
append_identifier
(
thd
,
str
,
table_name
,
strlen
(
table_name
)
);
str
->
append
(
'.'
);
append_identifier
(
thd
,
str
,
field_name
,
strlen
(
field_name
)
);
}
else
{
if
(
table_name
[
0
])
{
str
->
append
(
table_name
);
str
->
append
(
"`.`"
,
3
);
str
->
append
(
field_name
);
append_identifier
(
thd
,
str
,
table_name
,
strlen
(
table_name
)
);
str
->
append
(
'.'
);
append_identifier
(
thd
,
str
,
field_name
,
strlen
(
field_name
)
);
}
else
str
->
append
(
field_name
);
append_identifier
(
thd
,
str
,
field_name
,
strlen
(
field_name
)
);
}
str
->
append
(
'`'
);
}
/* ARGSUSED */
...
...
sql/sql_select.cc
View file @
10ce8cde
...
...
@@ -11250,37 +11250,32 @@ void st_table_list::print(THD *thd, String *str)
}
else
if
(
view_name
.
str
)
{
str
->
append
(
'`'
);
str
->
append
(
view_db
.
str
,
view_db
.
length
);
str
->
append
(
"`.`"
,
3
);
str
->
append
(
view_name
.
str
,
view_name
.
length
);
append_identifier
(
thd
,
str
,
view_db
.
str
,
view_db
.
length
);
str
->
append
(
'.'
);
append_identifier
(
thd
,
str
,
view_name
.
str
,
view_name
.
length
);
if
(
my_strcasecmp
(
table_alias_charset
,
view_name
.
str
,
alias
))
{
str
->
append
(
"` `"
,
3
);
str
->
append
(
alias
);
str
->
append
(
' '
);
append_identifier
(
thd
,
str
,
alias
,
strlen
(
alias
)
);
}
str
->
append
(
'`'
);
}
else
if
(
derived
)
{
str
->
append
(
'('
);
derived
->
print
(
str
);
str
->
append
(
") `"
,
3
);
str
->
append
(
alias
);
str
->
append
(
'`'
);
str
->
append
(
") "
,
2
);
append_identifier
(
thd
,
str
,
alias
,
strlen
(
alias
));
}
else
{
str
->
append
(
'`'
);
str
->
append
(
db
);
str
->
append
(
"`.`"
,
3
);
str
->
append
(
real_name
);
append_identifier
(
thd
,
str
,
db
,
db_length
);
str
->
append
(
'.'
);
append_identifier
(
thd
,
str
,
real_name
,
real_name_length
);
if
(
my_strcasecmp
(
table_alias_charset
,
real_name
,
alias
))
{
str
->
append
(
"` `"
,
3
);
str
->
append
(
alias
);
str
->
append
(
' '
);
append_identifier
(
thd
,
str
,
alias
,
strlen
(
alias
)
);
}
str
->
append
(
'`'
);
}
}
...
...
sql/sql_view.cc
View file @
10ce8cde
...
...
@@ -356,7 +356,12 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
// print query
str
.
length
(
0
);
thd
->
lex
->
unit
.
print
(
&
str
);
{
ulong
sql_mode
=
thd
->
variables
.
sql_mode
&
MODE_ANSI_QUOTES
;
thd
->
variables
.
sql_mode
&=
~
MODE_ANSI_QUOTES
;
thd
->
lex
->
unit
.
print
(
&
str
);
thd
->
variables
.
sql_mode
|=
sql_mode
;
}
str
.
append
(
'\0'
);
DBUG_PRINT
(
"VIEW"
,
(
"View: %s"
,
str
.
ptr
()));
...
...
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