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
3ef0b19c
Commit
3ef0b19c
authored
Oct 07, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed & added comments (according to Igor's review and a bit more)
parent
a9b759af
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
150 additions
and
107 deletions
+150
-107
sql/item_strfunc.h
sql/item_strfunc.h
+1
-1
sql/parse_file.cc
sql/parse_file.cc
+5
-5
sql/parse_file.h
sql/parse_file.h
+1
-1
sql/password.c
sql/password.c
+2
-2
sql/sql_acl.cc
sql/sql_acl.cc
+11
-11
sql/sql_lex.cc
sql/sql_lex.cc
+35
-17
sql/sql_parse.cc
sql/sql_parse.cc
+15
-15
sql/sql_show.cc
sql/sql_show.cc
+3
-3
sql/sql_update.cc
sql/sql_update.cc
+4
-3
sql/sql_view.cc
sql/sql_view.cc
+45
-23
sql/sql_yacc.yy
sql/sql_yacc.yy
+4
-4
sql/table.cc
sql/table.cc
+17
-15
sql/table.h
sql/table.h
+7
-7
No files found.
sql/item_strfunc.h
View file @
3ef0b19c
...
@@ -261,7 +261,7 @@ public:
...
@@ -261,7 +261,7 @@ public:
Returns strcat('*', octet2hex(sha1(sha1(password)))). '*' stands for new
Returns strcat('*', octet2hex(sha1(sha1(password)))). '*' stands for new
password format, sha1(sha1(password) is so-called hash_stage2 value.
password format, sha1(sha1(password) is so-called hash_stage2 value.
Length of returned string is always 41 byte. To find out how entire
Length of returned string is always 41 byte. To find out how entire
authenti
fi
cation procedure works, see comments in password.c.
authentication procedure works, see comments in password.c.
*/
*/
class
Item_func_password
:
public
Item_str_func
class
Item_func_password
:
public
Item_str_func
...
...
sql/parse_file.cc
View file @
3ef0b19c
...
@@ -57,11 +57,11 @@ write_escaped_string(IO_CACHE *file, LEX_STRING *val_s)
...
@@ -57,11 +57,11 @@ write_escaped_string(IO_CACHE *file, LEX_STRING *val_s)
if
(
my_b_append
(
file
,
(
const
byte
*
)
"
\\
n"
,
2
))
if
(
my_b_append
(
file
,
(
const
byte
*
)
"
\\
n"
,
2
))
return
TRUE
;
return
TRUE
;
break
;
break
;
case
'\0'
:
// problem for some string processing utilites
case
'\0'
:
// problem for some string processing utilit
i
es
if
(
my_b_append
(
file
,
(
const
byte
*
)
"
\\
0"
,
2
))
if
(
my_b_append
(
file
,
(
const
byte
*
)
"
\\
0"
,
2
))
return
TRUE
;
return
TRUE
;
break
;
break
;
case
26
:
// problem for windows utilites (Ctrl-Z)
case
26
:
// problem for windows utilit
i
es (Ctrl-Z)
if
(
my_b_append
(
file
,
(
const
byte
*
)
"
\\
z"
,
2
))
if
(
my_b_append
(
file
,
(
const
byte
*
)
"
\\
z"
,
2
))
return
TRUE
;
return
TRUE
;
break
;
break
;
...
@@ -253,7 +253,7 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
...
@@ -253,7 +253,7 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
{
{
if
(
old_version
!=
ULONGLONG_MAX
&&
max_versions
!=
0
)
if
(
old_version
!=
ULONGLONG_MAX
&&
max_versions
!=
0
)
{
{
// save b
u
ckup
// save b
a
ckup
char
path_arc
[
FN_REFLEN
];
char
path_arc
[
FN_REFLEN
];
// backup old version
// backup old version
char
path_to
[
FN_REFLEN
];
char
path_to
[
FN_REFLEN
];
...
@@ -383,9 +383,9 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root,
...
@@ -383,9 +383,9 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root,
}
}
end
=
parser
->
end
=
parser
->
buff
+
len
;
end
=
parser
->
end
=
parser
->
buff
+
len
;
*
end
=
'\0'
;
// barri
a
er for more simple parsing
*
end
=
'\0'
;
// barrier for more simple parsing
// 7 = 5 (TYPE=) + 1 (leter at least of type name) + 1 ('\n')
// 7 = 5 (TYPE=) + 1 (let
t
er at least of type name) + 1 ('\n')
if
(
len
<
7
||
if
(
len
<
7
||
parser
->
buff
[
0
]
!=
'T'
||
parser
->
buff
[
0
]
!=
'T'
||
parser
->
buff
[
1
]
!=
'Y'
||
parser
->
buff
[
1
]
!=
'Y'
||
...
...
sql/parse_file.h
View file @
3ef0b19c
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
enum
file_opt_type
{
enum
file_opt_type
{
FILE_OPTIONS_STRING
,
/* String (LEX_STRING) */
FILE_OPTIONS_STRING
,
/* String (LEX_STRING) */
FILE_OPTIONS_ESTRING
,
/* Escaped string (LEX_STRING) */
FILE_OPTIONS_ESTRING
,
/* Escaped string (LEX_STRING) */
FILE_OPTIONS_ULONGLONG
,
/* ulonglong para
p
eter (ulonglong) */
FILE_OPTIONS_ULONGLONG
,
/* ulonglong para
m
eter (ulonglong) */
FILE_OPTIONS_REV
,
/* Revision version number (ulonglong) */
FILE_OPTIONS_REV
,
/* Revision version number (ulonglong) */
FILE_OPTIONS_TIMESTAMP
,
/* timestamp (LEX_STRING have to be
FILE_OPTIONS_TIMESTAMP
,
/* timestamp (LEX_STRING have to be
allocated with length 20 (19+1) */
allocated with length 20 (19+1) */
...
...
sql/password.c
View file @
3ef0b19c
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
#include <sha1.h>
#include <sha1.h>
#include "mysql.h"
#include "mysql.h"
/************ MySQL 3.23-4.0 authenti
fi
cation routines: untouched ***********/
/************ MySQL 3.23-4.0 authentication routines: untouched ***********/
/*
/*
New (MySQL 3.21+) random generation structure initialization
New (MySQL 3.21+) random generation structure initialization
...
@@ -280,7 +280,7 @@ void make_password_from_salt_323(char *to, const ulong *salt)
...
@@ -280,7 +280,7 @@ void make_password_from_salt_323(char *to, const ulong *salt)
/*
/*
**************** MySQL 4.1.1 authenti
fi
cation routines *************
**************** MySQL 4.1.1 authentication routines *************
*/
*/
/*
/*
...
...
sql/sql_acl.cc
View file @
3ef0b19c
...
@@ -17,8 +17,8 @@
...
@@ -17,8 +17,8 @@
/*
/*
The privileges are saved in the following tables:
The privileges are saved in the following tables:
mysql/user ; super user who are allowed to do almo
u
st anything
mysql/user ; super user who are allowed to do almost anything
mysql/host ; host privil
i
ges. This is used if host is empty in mysql/db.
mysql/host ; host privil
e
ges. This is used if host is empty in mysql/db.
mysql/db ; database privileges / user
mysql/db ; database privileges / user
data in tables is sorted according to how many not-wild-cards there is
data in tables is sorted according to how many not-wild-cards there is
...
@@ -597,7 +597,7 @@ static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b)
...
@@ -597,7 +597,7 @@ static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b)
thd->host, thd->ip, thd->user are used for checks.
thd->host, thd->ip, thd->user are used for checks.
mqh user resources; on success mqh is reset, else
mqh user resources; on success mqh is reset, else
unchanged
unchanged
passwd scrambled & crypted password, rec
ie
ved from client
passwd scrambled & crypted password, rec
ei
ved from client
(to check): thd->scramble or thd->scramble_323 is
(to check): thd->scramble or thd->scramble_323 is
used to decrypt passwd, so they must contain
used to decrypt passwd, so they must contain
original random string,
original random string,
...
@@ -608,7 +608,7 @@ static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b)
...
@@ -608,7 +608,7 @@ static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b)
RETURN VALUE
RETURN VALUE
0 success: thd->priv_user, thd->priv_host, thd->master_access, mqh are
0 success: thd->priv_user, thd->priv_host, thd->master_access, mqh are
updated
updated
1 user not found or authenti
fi
cation failure
1 user not found or authentication failure
2 user found, has long (4.1.1) salt, but passwd is in old (3.23) format.
2 user found, has long (4.1.1) salt, but passwd is in old (3.23) format.
-1 user found, has short (3.23) salt, but passwd is in new (4.1.1) format.
-1 user found, has short (3.23) salt, but passwd is in new (4.1.1) format.
*/
*/
...
@@ -748,7 +748,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh,
...
@@ -748,7 +748,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh,
break
;
break
;
}
}
DBUG_PRINT
(
"info"
,(
"checkpoint 2"
));
DBUG_PRINT
(
"info"
,(
"checkpoint 2"
));
/* If X509 issuer is speified, we check it... */
/* If X509 issuer is spe
c
ified, we check it... */
if
(
acl_user
->
x509_issuer
)
if
(
acl_user
->
x509_issuer
)
{
{
DBUG_PRINT
(
"info"
,(
"checkpoint 3"
));
DBUG_PRINT
(
"info"
,(
"checkpoint 3"
));
...
@@ -810,7 +810,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh,
...
@@ -810,7 +810,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh,
/*
/*
* This is like acl_getroot() above, but it doesn't check password,
* This is like acl_getroot() above, but it doesn't check password,
* and we don't care about the user resources.
* and we don't care about the user resources.
* Used to get access rights for SQL SECURITY DEFINER invo
k
ation of
* Used to get access rights for SQL SECURITY DEFINER invo
c
ation of
* stored procedures.
* stored procedures.
*/
*/
int
acl_getroot_no_password
(
THD
*
thd
)
int
acl_getroot_no_password
(
THD
*
thd
)
...
@@ -1831,7 +1831,7 @@ GRANT_TABLE::GRANT_TABLE(const char *h, const char *d,const char *u,
...
@@ -1831,7 +1831,7 @@ GRANT_TABLE::GRANT_TABLE(const char *h, const char *d,const char *u,
{
{
/* Host given by user */
/* Host given by user */
orig_host
=
strdup_root
(
&
memex
,
h
);
orig_host
=
strdup_root
(
&
memex
,
h
);
/* Convert empty hostname to '%' for easy comparis
i
on */
/* Convert empty hostname to '%' for easy comparison */
host
=
orig_host
[
0
]
?
orig_host
:
(
char
*
)
"%"
;
host
=
orig_host
[
0
]
?
orig_host
:
(
char
*
)
"%"
;
db
=
strdup_root
(
&
memex
,
d
);
db
=
strdup_root
(
&
memex
,
d
);
user
=
strdup_root
(
&
memex
,
u
);
user
=
strdup_root
(
&
memex
,
u
);
...
@@ -2778,7 +2778,7 @@ void grant_reload(THD *thd)
...
@@ -2778,7 +2778,7 @@ void grant_reload(THD *thd)
/****************************************************************************
/****************************************************************************
Check table level grants
Check table level grants
SYN
PO
SIS
SYN
OP
SIS
bool check_grant()
bool check_grant()
thd Thread handler
thd Thread handler
want_access Bits of privileges user needs to have
want_access Bits of privileges user needs to have
...
@@ -2792,7 +2792,7 @@ void grant_reload(THD *thd)
...
@@ -2792,7 +2792,7 @@ void grant_reload(THD *thd)
RETURN
RETURN
0 ok
0 ok
1 Error: User did not have the requested privi
el
ges
1 Error: User did not have the requested privi
le
ges
****************************************************************************/
****************************************************************************/
bool
check_grant
(
THD
*
thd
,
ulong
want_access
,
TABLE_LIST
*
tables
,
bool
check_grant
(
THD
*
thd
,
ulong
want_access
,
TABLE_LIST
*
tables
,
...
@@ -3870,8 +3870,8 @@ int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr)
...
@@ -3870,8 +3870,8 @@ int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr)
fill effective privileges for table
fill effective privileges for table
SYNOPSIS
SYNOPSIS
get_effectlig
e_privileges()
fill_effective_tabl
e_privileges()
thd thread handle
g
thd thread handle
r
grant grants table descriptor
grant grants table descriptor
db db name
db db name
table table name
table table name
...
...
sql/sql_lex.cc
View file @
3ef0b19c
...
@@ -1537,11 +1537,17 @@ void st_select_lex::print_limit(THD *thd, String *str)
...
@@ -1537,11 +1537,17 @@ void st_select_lex::print_limit(THD *thd, String *str)
/*
/*
Check
is
merging algorithm can be used on this VIEW
Check
whether the
merging algorithm can be used on this VIEW
SYNOPSIS
SYNOPSIS
st_lex::can_be_merged()
st_lex::can_be_merged()
DESCRIPTION
We can apply merge algorithm if it is single SELECT view (we do not
count SELECTs of underlying views) and we have not grpouping, ordering,
HAVING clause, aggregate functions, DISTINCT clause, LIMIT clause and
several underlying tables.
RETURN
RETURN
FALSE - only temporary table algorithm can be used
FALSE - only temporary table algorithm can be used
TRUE - merge algorithm can be used
TRUE - merge algorithm can be used
...
@@ -1569,12 +1575,18 @@ bool st_lex::can_be_merged()
...
@@ -1569,12 +1575,18 @@ bool st_lex::can_be_merged()
select_lex
.
select_limit
==
HA_POS_ERROR
);
select_lex
.
select_limit
==
HA_POS_ERROR
);
}
}
/*
/*
check if command can use VIEW with MERGE algorithm (for top VIEWs)
check if command can use VIEW with MERGE algorithm (for top VIEWs)
SYNOPSIS
SYNOPSIS
st_lex::can_use_merged()
st_lex::can_use_merged()
DESCRIPTION
Only listed here commands can use merge algorithm in top level
SELECT_LEX (for subqueries will be used merge algorithm if
st_lex::can_not_use_merged() is not TRUE).
RETURN
RETURN
FALSE - command can't use merged VIEWs
FALSE - command can't use merged VIEWs
TRUE - VIEWs with MERGE algorithms can be used
TRUE - VIEWs with MERGE algorithms can be used
...
@@ -1601,11 +1613,15 @@ bool st_lex::can_use_merged()
...
@@ -1601,11 +1613,15 @@ bool st_lex::can_use_merged()
}
}
/*
/*
c
heck if command can't use merged views in any part of command
C
heck if command can't use merged views in any part of command
SYNOPSIS
SYNOPSIS
st_lex::can_not_use_merged()
st_lex::can_not_use_merged()
DESCRIPTION
Temporary table algorithm will be used on all SELECT levels for queries
listed here (see also st_lex::can_use_merged()).
RETURN
RETURN
FALSE - command can't use merged VIEWs
FALSE - command can't use merged VIEWs
TRUE - VIEWs with MERGE algorithms can be used
TRUE - VIEWs with MERGE algorithms can be used
...
@@ -1673,16 +1689,16 @@ void st_select_lex_unit::set_limit(SELECT_LEX *values,
...
@@ -1673,16 +1689,16 @@ void st_select_lex_unit::set_limit(SELECT_LEX *values,
/*
/*
Unlink
first table from global table list and first table from outer select
Unlink
the first table from the global table list and the first table from
list (lex->select_lex)
outer select (lex->select_lex) local list
SYNOPSIS
SYNOPSIS
unlink_first_table()
unlink_first_table()
link_to_local Set to 1 if caller should link this table to local
link_to_local Set to 1 if caller should link this table to local
list
NOTES
NOTES
We
rely on fact that first table in both list are same or local list
We
assume that first tables in both lists is the same table or the local
is empty
list is empty.
RETURN
RETURN
0 If 'query_tables' == 0
0 If 'query_tables' == 0
...
@@ -1711,8 +1727,8 @@ TABLE_LIST *st_lex::unlink_first_table(bool *link_to_local)
...
@@ -1711,8 +1727,8 @@ TABLE_LIST *st_lex::unlink_first_table(bool *link_to_local)
select_lex
.
table_list
.
elements
--
;
//safety
select_lex
.
table_list
.
elements
--
;
//safety
first
->
next_local
=
0
;
first
->
next_local
=
0
;
/*
/*
reorder global list to keep first tables the same in both lists
Ensure that the global list has the same first table as the local
(if it is need)
list.
*/
*/
first_lists_tables_same
();
first_lists_tables_same
();
}
}
...
@@ -1729,11 +1745,12 @@ TABLE_LIST *st_lex::unlink_first_table(bool *link_to_local)
...
@@ -1729,11 +1745,12 @@ TABLE_LIST *st_lex::unlink_first_table(bool *link_to_local)
st_lex::first_lists_tables_same()
st_lex::first_lists_tables_same()
NOTES
NOTES
In many cases first table of main SELECT_LEX have special meaning =>
In many cases (for example, usual INSERT/DELETE/...) the first table of
check that it is first table in global list and relink it first in
main SELECT_LEX have special meaning => check that it is the first table
queries_tables list if it is necessary (we need such relinking only
in global list and re-link to be first in the global list if it is
for queries with subqueries in select list, in this case tables of
necessary. We need such re-linking only for queries with sub-queries in
subqueries will go to global list first)
the select list, as only in this case tables of sub-queries will go to
the global list first.
*/
*/
void
st_lex
::
first_lists_tables_same
()
void
st_lex
::
first_lists_tables_same
()
...
@@ -1750,8 +1767,9 @@ void st_lex::first_lists_tables_same()
...
@@ -1750,8 +1767,9 @@ void st_lex::first_lists_tables_same()
/* include in new place */
/* include in new place */
first_table
->
next_global
=
query_tables
;
first_table
->
next_global
=
query_tables
;
/*
/*
we are sure that above is not 0, because first_table was not
We are sure that query_tables is not 0, because first_table was not
first table in global list => we can do following without check
first table in the global list => we can use
query_tables->prev_global without check of query_tables
*/
*/
query_tables
->
prev_global
=
&
first_table
->
next_global
;
query_tables
->
prev_global
=
&
first_table
->
next_global
;
first_table
->
prev_global
=
&
query_tables
;
first_table
->
prev_global
=
&
query_tables
;
...
...
sql/sql_parse.cc
View file @
3ef0b19c
...
@@ -108,7 +108,7 @@ static void unlock_locked_tables(THD *thd)
...
@@ -108,7 +108,7 @@ static void unlock_locked_tables(THD *thd)
if
(
thd
->
locked_tables
)
if
(
thd
->
locked_tables
)
{
{
thd
->
lock
=
thd
->
locked_tables
;
thd
->
lock
=
thd
->
locked_tables
;
thd
->
locked_tables
=
0
;
// Will be automaticly closed
thd
->
locked_tables
=
0
;
// Will be automatic
al
ly closed
close_thread_tables
(
thd
);
// Free tables
close_thread_tables
(
thd
);
// Free tables
}
}
}
}
...
@@ -205,13 +205,13 @@ end:
...
@@ -205,13 +205,13 @@ end:
command originator of the check: now check_user is called
command originator of the check: now check_user is called
during connect and change user procedures; used for
during connect and change user procedures; used for
logging.
logging.
passwd scrambled password rec
ie
ved from client
passwd scrambled password rec
ei
ved from client
passwd_len length of scrambled password
passwd_len length of scrambled password
db database name to connect to, may be NULL
db database name to connect to, may be NULL
check_count dont know exactly
check_count dont know exactly
Note, that host, user and passwd may point to communication buffer.
Note, that host, user and passwd may point to communication buffer.
Current implementation does not depen
e
d on that, but future changes
Current implementation does not depend on that, but future changes
should be done with this in mind; 'thd' is INOUT, all other params
should be done with this in mind; 'thd' is INOUT, all other params
are 'IN'.
are 'IN'.
...
@@ -269,7 +269,7 @@ int check_user(THD *thd, enum enum_server_command command,
...
@@ -269,7 +269,7 @@ int check_user(THD *thd, enum enum_server_command command,
/*
/*
Clear thd->db as it points to something, that will be freed when
Clear thd->db as it points to something, that will be freed when
connection is closed. We don't want to accidently free a wrong pointer
connection is closed. We don't want to accident
al
ly free a wrong pointer
if connect failed. Also in case of 'CHANGE USER' failure, current
if connect failed. Also in case of 'CHANGE USER' failure, current
database will be switched to 'no database selected'.
database will be switched to 'no database selected'.
*/
*/
...
@@ -311,7 +311,7 @@ int check_user(THD *thd, enum enum_server_command command,
...
@@ -311,7 +311,7 @@ int check_user(THD *thd, enum enum_server_command command,
/* here res is always >= 0 */
/* here res is always >= 0 */
if
(
res
==
0
)
if
(
res
==
0
)
{
{
if
(
!
(
thd
->
master_access
&
NO_ACCESS
))
// authenti
fi
cation is OK
if
(
!
(
thd
->
master_access
&
NO_ACCESS
))
// authentication is OK
{
{
DBUG_PRINT
(
"info"
,
DBUG_PRINT
(
"info"
,
(
"Capabilities: %d packet_length: %ld Host: '%s' "
(
"Capabilities: %d packet_length: %ld Host: '%s' "
...
@@ -731,7 +731,7 @@ static int check_connection(THD *thd)
...
@@ -731,7 +731,7 @@ static int check_connection(THD *thd)
#endif
/* HAVE_COMPRESS */
#endif
/* HAVE_COMPRESS */
#ifdef HAVE_OPENSSL
#ifdef HAVE_OPENSSL
if
(
ssl_acceptor_fd
)
if
(
ssl_acceptor_fd
)
client_flags
|=
CLIENT_SSL
;
/* Wow, SSL is ava
lai
ble! */
client_flags
|=
CLIENT_SSL
;
/* Wow, SSL is ava
ila
ble! */
#endif
/* HAVE_OPENSSL */
#endif
/* HAVE_OPENSSL */
end
=
strnmov
(
buff
,
server_version
,
SERVER_VERSION_LENGTH
)
+
1
;
end
=
strnmov
(
buff
,
server_version
,
SERVER_VERSION_LENGTH
)
+
1
;
...
@@ -1393,7 +1393,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
...
@@ -1393,7 +1393,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
*
passwd
++
:
strlen
(
passwd
);
*
passwd
++
:
strlen
(
passwd
);
db
+=
passwd_len
+
1
;
db
+=
passwd_len
+
1
;
#ifndef EMBEDDED_LIBRARY
#ifndef EMBEDDED_LIBRARY
/* Small check for incom
m
ing packet */
/* Small check for incoming packet */
if
((
uint
)
((
uchar
*
)
db
-
net
->
read_pos
)
>
packet_length
)
if
((
uint
)
((
uchar
*
)
db
-
net
->
read_pos
)
>
packet_length
)
{
{
send_error
(
thd
,
ER_UNKNOWN_COM_ERROR
);
send_error
(
thd
,
ER_UNKNOWN_COM_ERROR
);
...
@@ -1428,7 +1428,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
...
@@ -1428,7 +1428,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if
(
res
)
if
(
res
)
{
{
/* authenti
fi
cation failure, we shall restore old user */
/* authentication failure, we shall restore old user */
if
(
res
>
0
)
if
(
res
>
0
)
send_error
(
thd
,
ER_UNKNOWN_COM_ERROR
);
send_error
(
thd
,
ER_UNKNOWN_COM_ERROR
);
x_free
(
thd
->
user
);
x_free
(
thd
->
user
);
...
@@ -2397,7 +2397,7 @@ mysql_execute_command(THD *thd)
...
@@ -2397,7 +2397,7 @@ mysql_execute_command(THD *thd)
}
}
#endif
#endif
/*
/*
If we are using SET CHARSET without DEFAULT, add an implicit
e
If we are using SET CHARSET without DEFAULT, add an implicit
DEFAULT to not confuse old users. (This may change).
DEFAULT to not confuse old users. (This may change).
*/
*/
if
((
lex
->
create_info
.
used_fields
&
if
((
lex
->
create_info
.
used_fields
&
...
@@ -3537,7 +3537,7 @@ purposes internal to the MySQL server", MYF(0));
...
@@ -3537,7 +3537,7 @@ purposes internal to the MySQL server", MYF(0));
if
(
thd
->
locked_tables
)
if
(
thd
->
locked_tables
)
{
{
thd
->
lock
=
thd
->
locked_tables
;
thd
->
lock
=
thd
->
locked_tables
;
thd
->
locked_tables
=
0
;
// Will be automaticly closed
thd
->
locked_tables
=
0
;
// Will be automatic
al
ly closed
close_thread_tables
(
thd
);
// Free tables
close_thread_tables
(
thd
);
// Free tables
}
}
if
(
end_active_trans
(
thd
))
if
(
end_active_trans
(
thd
))
...
@@ -3984,7 +3984,7 @@ error:
...
@@ -3984,7 +3984,7 @@ error:
SYNOPSIS
SYNOPSIS
check_one_table_access()
check_one_table_access()
thd Thread handler
thd Thread handler
privilege requested priv
ela
ge
privilege requested priv
ile
ge
all_tables global table list of query
all_tables global table list of query
RETURN
RETURN
...
@@ -4126,7 +4126,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
...
@@ -4126,7 +4126,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
want_access Use should have any of these global rights
want_access Use should have any of these global rights
WARNING
WARNING
One gets access rig
th
if one has ANY of the rights in want_access
One gets access rig
ht
if one has ANY of the rights in want_access
This is useful as one in most cases only need one global right,
This is useful as one in most cases only need one global right,
but in some case we want to check if the user has SUPER or
but in some case we want to check if the user has SUPER or
REPL_CLIENT_ACL rights.
REPL_CLIENT_ACL rights.
...
@@ -4888,7 +4888,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
...
@@ -4888,7 +4888,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
/*
/*
We are setting TIMESTAMP_OLD_FIELD here only temporary, we will
We are setting TIMESTAMP_OLD_FIELD here only temporary, we will
replace this value by TIMESTAMP_DNUN_FIELD or NONE later when
replace this value by TIMESTAMP_DNUN_FIELD or NONE later when
information about all TIMESTAMP fields in table will be avail
i
able.
information about all TIMESTAMP fields in table will be available.
*/
*/
new_field
->
unireg_check
=
on_update_value
?
Field
::
TIMESTAMP_UN_FIELD
:
new_field
->
unireg_check
=
on_update_value
?
Field
::
TIMESTAMP_UN_FIELD
:
Field
::
TIMESTAMP_OLD_FIELD
;
Field
::
TIMESTAMP_OLD_FIELD
;
...
@@ -5315,7 +5315,7 @@ TABLE_LIST *st_select_lex::nest_last_join(THD *thd)
...
@@ -5315,7 +5315,7 @@ TABLE_LIST *st_select_lex::nest_last_join(THD *thd)
/*
/*
Save names for a join with using clase
Save names for a join with using cla
u
se
SYNOPSIS
SYNOPSIS
save_names_for_using_list
save_names_for_using_list
...
@@ -6168,7 +6168,7 @@ int create_table_precheck(THD *thd, TABLE_LIST *tables,
...
@@ -6168,7 +6168,7 @@ int create_table_precheck(THD *thd, TABLE_LIST *tables,
SYNOPSIS
SYNOPSIS
negate_expression()
negate_expression()
thd th
er
ad handler
thd th
re
ad handler
expr expression for negation
expr expression for negation
RETURN
RETURN
...
...
sql/sql_show.cc
View file @
3ef0b19c
...
@@ -762,7 +762,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
...
@@ -762,7 +762,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
protocol
->
store
(
field
->
has_charset
()
?
field
->
charset
()
->
name
:
"NULL"
,
protocol
->
store
(
field
->
has_charset
()
?
field
->
charset
()
->
name
:
"NULL"
,
system_charset_info
);
system_charset_info
);
/*
/*
Altough TIMESTAMP fields can't contain NULL as its value they
Alt
h
ough TIMESTAMP fields can't contain NULL as its value they
will accept NULL if you will try to insert such value and will
will accept NULL if you will try to insert such value and will
convert it to current TIMESTAMP. So YES here means that NULL
convert it to current TIMESTAMP. So YES here means that NULL
is allowed for assignment but can't be returned.
is allowed for assignment but can't be returned.
...
@@ -781,7 +781,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
...
@@ -781,7 +781,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
{
{
/*
/*
We have NOW() as default value but we use CURRENT_TIMESTAMP form
We have NOW() as default value but we use CURRENT_TIMESTAMP form
because it is more SQL standard comatible
because it is more SQL standard com
p
atible
*/
*/
protocol
->
store
(
"CURRENT_TIMESTAMP"
,
system_charset_info
);
protocol
->
store
(
"CURRENT_TIMESTAMP"
,
system_charset_info
);
}
}
...
@@ -1213,7 +1213,7 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd)
...
@@ -1213,7 +1213,7 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd)
/*
/*
Go through all character combinations and ensure that sql_lex.cc can
Go through all character combinations and ensure that sql_lex.cc can
parse it as an identifer.
parse it as an identif
i
er.
SYNOPSIS
SYNOPSIS
require_quotes()
require_quotes()
...
...
sql/sql_update.cc
View file @
3ef0b19c
...
@@ -72,7 +72,7 @@ static bool check_fields(THD *thd, List<Item> &items)
...
@@ -72,7 +72,7 @@ static bool check_fields(THD *thd, List<Item> &items)
{
{
if
(
!
(
field
=
item
->
filed_for_view_update
()))
if
(
!
(
field
=
item
->
filed_for_view_update
()))
{
{
/*
as far as item comes from VIEW select list it has name
*/
/*
item has name, because it comes from VIEW SELECT list
*/
my_error
(
ER_NONUPDATEABLE_COLUMN
,
MYF
(
0
),
item
->
name
);
my_error
(
ER_NONUPDATEABLE_COLUMN
,
MYF
(
0
),
item
->
name
);
return
TRUE
;
return
TRUE
;
}
}
...
@@ -589,8 +589,9 @@ int mysql_multi_update_prepare(THD *thd)
...
@@ -589,8 +589,9 @@ int mysql_multi_update_prepare(THD *thd)
}
}
/*
/*
setup_tables() need for VIEWs. JOIN::prepare() will not do it second
setup_tables() need for VIEWs. JOIN::prepare() will call setup_tables()
time.
second time, but this call will do nothing (there are check for second
call in setup_tables()).
*/
*/
if
(
setup_tables
(
thd
,
table_list
,
&
lex
->
select_lex
.
where
)
||
if
(
setup_tables
(
thd
,
table_list
,
&
lex
->
select_lex
.
where
)
||
(
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
1
,
(
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
1
,
...
...
sql/sql_view.cc
View file @
3ef0b19c
...
@@ -80,6 +80,18 @@ int mysql_create_view(THD *thd,
...
@@ -80,6 +80,18 @@ int mysql_create_view(THD *thd,
}
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
#ifndef NO_EMBEDDED_ACCESS_CHECKS
/*
Privilege check for view creation:
- user have CREATE VIEW privilege on view table
- have some (SELECT/UPDATE/INSERT/DELETE) privileges on columns of
underlying tables used on top of SELECT list (because it can be
(theoretically) updated, so it is enough to have UPDATE privilege on
them, for example)
- have SELECT privilege on columns used in expressions of VIEW select
- for columns of underly tables used on top of SELECT list also will be
checked that we have not more privileges on correspondent column of view
table (i.e. user will not get some privileges by view creation)
*/
if
(
check_access
(
thd
,
CREATE_VIEW_ACL
,
view
->
db
,
&
view
->
grant
.
privilege
,
if
(
check_access
(
thd
,
CREATE_VIEW_ACL
,
view
->
db
,
&
view
->
grant
.
privilege
,
0
,
0
)
||
0
,
0
)
||
grant_option
&&
check_grant
(
thd
,
CREATE_VIEW_ACL
,
view
,
0
,
1
,
0
))
grant_option
&&
check_grant
(
thd
,
CREATE_VIEW_ACL
,
view
,
0
,
1
,
0
))
...
@@ -89,7 +101,7 @@ int mysql_create_view(THD *thd,
...
@@ -89,7 +101,7 @@ int mysql_create_view(THD *thd,
for
(
tbl
=
sl
->
get_table_list
();
tbl
;
tbl
=
tbl
->
next_local
)
for
(
tbl
=
sl
->
get_table_list
();
tbl
;
tbl
=
tbl
->
next_local
)
{
{
/*
/*
Ensure that we have some privil
age
on this table, more strict check
Ensure that we have some privil
eges
on this table, more strict check
will be done on column level after preparation,
will be done on column level after preparation,
*/
*/
if
(
check_some_access
(
thd
,
VIEW_ANY_ACL
,
tbl
))
if
(
check_some_access
(
thd
,
VIEW_ANY_ACL
,
tbl
))
...
@@ -103,16 +115,20 @@ int mysql_create_view(THD *thd,
...
@@ -103,16 +115,20 @@ int mysql_create_view(THD *thd,
tbl
->
real_name
);
tbl
->
real_name
);
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
}
}
/* mark this table as table which will be checked after preparation */
/*
Mark this table as a table which will be checked after the prepare
phase
*/
tbl
->
table_in_first_from_clause
=
1
;
tbl
->
table_in_first_from_clause
=
1
;
/*
/*
We need to check only SELECT_ACL for all normal fields, fields
We need to check only SELECT_ACL for all normal fields, fields for
where we need any privilege will be marked later
which we need "any" (SELECT/UPDATE/INSERT/DELETE) privilege will be
checked later
*/
*/
tbl
->
grant
.
want_privilege
=
SELECT_ACL
;
tbl
->
grant
.
want_privilege
=
SELECT_ACL
;
/*
/*
Make sure that all rights are loaded to t
able 'grant'
field.
Make sure that all rights are loaded to t
he TABLE::grant
field.
tbl->real_name will be correct name of table because VIEWs are
tbl->real_name will be correct name of table because VIEWs are
not opened yet.
not opened yet.
...
@@ -140,7 +156,7 @@ int mysql_create_view(THD *thd,
...
@@ -140,7 +156,7 @@ int mysql_create_view(THD *thd,
}
}
}
}
/*
/*
Mark fields for special privilege check (
any
privilege)
Mark fields for special privilege check (
"any"
privilege)
*/
*/
for
(
sl
=
select_lex
;
sl
;
sl
=
sl
->
next_select
())
for
(
sl
=
select_lex
;
sl
;
sl
=
sl
->
next_select
())
{
{
...
@@ -169,14 +185,14 @@ int mysql_create_view(THD *thd,
...
@@ -169,14 +185,14 @@ int mysql_create_view(THD *thd,
}
}
/*
/*
Copy
privileges of underlaying VIEWs which was
filled by
Copy
the privileges of the underlying VIEWs which were
filled by
fill_effective_table_privileges
fill_effective_table_privileges
(they w
as not copied in
derived tables processing)
(they w
ere not copied at
derived tables processing)
*/
*/
tbl
->
table
->
grant
.
privilege
=
tbl
->
grant
.
privilege
;
tbl
->
table
->
grant
.
privilege
=
tbl
->
grant
.
privilege
;
}
}
/
/ prepare select to resolve all fields
/
* prepare select to resolve all fields */
lex
->
view_prepare_mode
=
1
;
lex
->
view_prepare_mode
=
1
;
if
(
unit
->
prepare
(
thd
,
0
,
0
))
if
(
unit
->
prepare
(
thd
,
0
,
0
))
{
{
...
@@ -227,7 +243,7 @@ int mysql_create_view(THD *thd,
...
@@ -227,7 +243,7 @@ int mysql_create_view(THD *thd,
#ifndef NO_EMBEDDED_ACCESS_CHECKS
#ifndef NO_EMBEDDED_ACCESS_CHECKS
/*
/*
Compare/check grants on view with grants of underl
a
ying tables
Compare/check grants on view with grants of underlying tables
*/
*/
for
(
sl
=
select_lex
;
sl
;
sl
=
sl
->
next_select
())
for
(
sl
=
select_lex
;
sl
;
sl
=
sl
->
next_select
())
{
{
...
@@ -245,7 +261,7 @@ int mysql_create_view(THD *thd,
...
@@ -245,7 +261,7 @@ int mysql_create_view(THD *thd,
if
((
fld
=
item
->
filed_for_view_update
()))
if
((
fld
=
item
->
filed_for_view_update
()))
{
{
/*
/*
Do we have more privileges
on view field then underlying table field
Do we have more privileges
on view field then underlying table field?
*/
*/
if
((
~
fld
->
have_privileges
&
priv
))
if
((
~
fld
->
have_privileges
&
priv
))
{
{
...
@@ -354,7 +370,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
...
@@ -354,7 +370,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
LEX_STRING
dir
,
file
;
LEX_STRING
dir
,
file
;
DBUG_ENTER
(
"mysql_register_view"
);
DBUG_ENTER
(
"mysql_register_view"
);
/
/ print query
/
* print query */
str
.
length
(
0
);
str
.
length
(
0
);
{
{
ulong
sql_mode
=
thd
->
variables
.
sql_mode
&
MODE_ANSI_QUOTES
;
ulong
sql_mode
=
thd
->
variables
.
sql_mode
&
MODE_ANSI_QUOTES
;
...
@@ -365,7 +381,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
...
@@ -365,7 +381,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
str
.
append
(
'\0'
);
str
.
append
(
'\0'
);
DBUG_PRINT
(
"VIEW"
,
(
"View: %s"
,
str
.
ptr
()));
DBUG_PRINT
(
"VIEW"
,
(
"View: %s"
,
str
.
ptr
()));
/
/ print file name
/
* print file name */
(
void
)
my_snprintf
(
dir_buff
,
FN_REFLEN
,
"%s/%s/"
,
(
void
)
my_snprintf
(
dir_buff
,
FN_REFLEN
,
"%s/%s/"
,
mysql_data_home
,
view
->
db
);
mysql_data_home
,
view
->
db
);
unpack_filename
(
dir_buff
,
dir_buff
);
unpack_filename
(
dir_buff
,
dir_buff
);
...
@@ -379,7 +395,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
...
@@ -379,7 +395,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
if
(
!
view
->
timestamp
.
str
)
if
(
!
view
->
timestamp
.
str
)
view
->
timestamp
.
str
=
view
->
timestamp_buffer
;
view
->
timestamp
.
str
=
view
->
timestamp_buffer
;
/
/ check old .frm
/
* check old .frm */
{
{
char
path_buff
[
FN_REFLEN
];
char
path_buff
[
FN_REFLEN
];
LEX_STRING
path
;
LEX_STRING
path
;
...
@@ -411,7 +427,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
...
@@ -411,7 +427,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
/*
/*
read revision number
read revision number
TODO: read dependen
s
e list, too, to process cascade/restrict
TODO: read dependen
c
e list, too, to process cascade/restrict
TODO: special cascade/restrict procedure for alter?
TODO: special cascade/restrict procedure for alter?
*/
*/
if
(
parser
->
parse
((
gptr
)
view
,
&
thd
->
mem_root
,
if
(
parser
->
parse
((
gptr
)
view
,
&
thd
->
mem_root
,
...
@@ -429,7 +445,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
...
@@ -429,7 +445,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
}
}
}
}
}
}
/
/ fill structure
/
* fill structure */
view
->
query
.
str
=
(
char
*
)
str
.
ptr
();
view
->
query
.
str
=
(
char
*
)
str
.
ptr
();
view
->
query
.
length
=
str
.
length
()
-
1
;
// we do not need last \0
view
->
query
.
length
=
str
.
length
()
-
1
;
// we do not need last \0
view
->
source
.
str
=
thd
->
query
;
view
->
source
.
str
=
thd
->
query
;
...
@@ -451,7 +467,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
...
@@ -451,7 +467,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
if
((
view
->
updatable_view
=
(
can_be_merged
&&
if
((
view
->
updatable_view
=
(
can_be_merged
&&
view
->
algorithm
!=
VIEW_ALGORITHM_TMPTABLE
)))
view
->
algorithm
!=
VIEW_ALGORITHM_TMPTABLE
)))
{
{
/
/ TODO: change here when we will support UNIONs
/
* TODO: change here when we will support UNIONs */
for
(
TABLE_LIST
*
tbl
=
(
TABLE_LIST
*
)
thd
->
lex
->
select_lex
.
table_list
.
first
;
for
(
TABLE_LIST
*
tbl
=
(
TABLE_LIST
*
)
thd
->
lex
->
select_lex
.
table_list
.
first
;
tbl
;
tbl
;
tbl
=
tbl
->
next_local
)
tbl
=
tbl
->
next_local
)
...
@@ -491,7 +507,6 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
...
@@ -491,7 +507,6 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
RETURN
RETURN
0 ok
0 ok
1 error
1 error
*/
*/
my_bool
my_bool
...
@@ -632,7 +647,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -632,7 +647,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
/*
/*
check rights to run commands (EXPLAIN SELECT & SHOW CREATE) which show
check rights to run commands (EXPLAIN SELECT & SHOW CREATE) which show
underl
a
ying tables
underlying tables
*/
*/
if
((
old_lex
->
sql_command
==
SQLCOM_SELECT
&&
old_lex
->
describe
))
if
((
old_lex
->
sql_command
==
SQLCOM_SELECT
&&
old_lex
->
describe
))
{
{
...
@@ -682,7 +697,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -682,7 +697,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
/*
/*
check MERGE algorithm ability
check MERGE algorithm ability
- algorithm is not explicit TEMPORARY TABLE
- algorithm is not explicit TEMPORARY TABLE
- VIEW SELECT allow m
a
rging
- VIEW SELECT allow m
e
rging
- VIEW used in subquery or command support MERGE algorithm
- VIEW used in subquery or command support MERGE algorithm
*/
*/
if
(
table
->
algorithm
!=
VIEW_ALGORITHM_TMPTABLE
&&
if
(
table
->
algorithm
!=
VIEW_ALGORITHM_TMPTABLE
&&
...
@@ -705,7 +720,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -705,7 +720,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
/*
/*
next table should include SELECT_LEX under this table SELECT_LEX
next table should include SELECT_LEX under this table SELECT_LEX
TODO:
e
here should be loop for multi tables substitution
TODO: here should be loop for multi tables substitution
*/
*/
table
->
ancestor
->
select_lex
=
table
->
select_lex
;
table
->
ancestor
->
select_lex
=
table
->
select_lex
;
/*
/*
...
@@ -714,7 +729,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -714,7 +729,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
*/
*/
view_tables
->
lock_type
=
table
->
lock_type
;
view_tables
->
lock_type
=
table
->
lock_type
;
/* Store WHERE clause for postprocessing in setup_ancestor */
/* Store WHERE clause for post
-
processing in setup_ancestor */
table
->
where
=
lex
->
select_lex
.
where
;
table
->
where
=
lex
->
select_lex
.
where
;
/*
/*
...
@@ -866,6 +881,13 @@ frm_type_enum mysql_frm_type(char *path)
...
@@ -866,6 +881,13 @@ frm_type_enum mysql_frm_type(char *path)
thd thread handler
thd thread handler
view view for check with opened table
view view for check with opened table
DESCRIPTION
check that undertlaying table of viey contain one of following:
1) primary key of underlying table
2) unique key underlying table with fields for which NULL value is
impossible
3) all fields of underlying table
RETURN
RETURN
FALSE OK
FALSE OK
TRUE view do not contain key or all fields
TRUE view do not contain key or all fields
...
@@ -935,7 +957,7 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view)
...
@@ -935,7 +957,7 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view)
0 == NO ; Don't give any errors
0 == NO ; Don't give any errors
1 == YES ; Give always an error
1 == YES ; Give always an error
2 == LIMIT1 ; Give an error if this is used with LIMIT 1
2 == LIMIT1 ; Give an error if this is used with LIMIT 1
This is used to protect against
gui
programs that
This is used to protect against
GUI
programs that
uses LIMIT 1 to update just the current row. This
uses LIMIT 1 to update just the current row. This
doesn't work reliable if the view doesn't have a
doesn't work reliable if the view doesn't have a
unique key or if the view doesn't use all fields in
unique key or if the view doesn't use all fields in
...
...
sql/sql_yacc.yy
View file @
3ef0b19c
...
@@ -2423,8 +2423,8 @@ create_select:
...
@@ -2423,8 +2423,8 @@ create_select:
else if (lex->sql_command == SQLCOM_REPLACE)
else if (lex->sql_command == SQLCOM_REPLACE)
lex->sql_command= SQLCOM_REPLACE_SELECT;
lex->sql_command= SQLCOM_REPLACE_SELECT;
/*
/*
following work only with local list, global list is
The following work only with the local list, the global list
created correctly in this case
is
created correctly in this case
*/
*/
lex->current_select->table_list.save_and_clear(&lex->save_list);
lex->current_select->table_list.save_and_clear(&lex->save_list);
mysql_init_select(lex);
mysql_init_select(lex);
...
@@ -2437,8 +2437,8 @@ create_select:
...
@@ -2437,8 +2437,8 @@ create_select:
opt_select_from
opt_select_from
{
{
/*
/*
following work only with local list, global list is
The following work only with the local list, the global list
created correctly in this case
is
created correctly in this case
*/
*/
Lex->current_select->table_list.push_front(&Lex->save_list);
Lex->current_select->table_list.push_front(&Lex->save_list);
}
}
...
...
sql/table.cc
View file @
3ef0b19c
...
@@ -169,7 +169,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
...
@@ -169,7 +169,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
outparam
->
db_record_offset
=
1
;
outparam
->
db_record_offset
=
1
;
if
(
db_create_options
&
HA_OPTION_LONG_BLOB_PTR
)
if
(
db_create_options
&
HA_OPTION_LONG_BLOB_PTR
)
outparam
->
blob_ptr_size
=
portable_sizeof_char_ptr
;
outparam
->
blob_ptr_size
=
portable_sizeof_char_ptr
;
/* Set temporar
y
ly a good value for db_low_byte_first */
/* Set temporar
i
ly a good value for db_low_byte_first */
outparam
->
db_low_byte_first
=
test
(
outparam
->
db_type
!=
DB_TYPE_ISAM
);
outparam
->
db_low_byte_first
=
test
(
outparam
->
db_type
!=
DB_TYPE_ISAM
);
error
=
4
;
error
=
4
;
outparam
->
max_rows
=
uint4korr
(
head
+
18
);
outparam
->
max_rows
=
uint4korr
(
head
+
18
);
...
@@ -710,7 +710,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
...
@@ -710,7 +710,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
outparam
->
blob_field
=
outparam
->
blob_field
=
(
Field_blob
**
)
(
outparam
->
field
+
outparam
->
fields
);
// Point at null ptr
(
Field_blob
**
)
(
outparam
->
field
+
outparam
->
fields
);
// Point at null ptr
/* The table struct is now initialzed; Open the table */
/* The table struct is now initial
i
zed; Open the table */
error
=
2
;
error
=
2
;
if
(
db_stat
)
if
(
db_stat
)
{
{
...
@@ -759,7 +759,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
...
@@ -759,7 +759,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
my_pthread_setspecific_ptr
(
THR_MALLOC
,
old_root
);
my_pthread_setspecific_ptr
(
THR_MALLOC
,
old_root
);
frm_error
(
error
,
outparam
,
name
,
ME_ERROR
+
ME_WAITTANG
);
frm_error
(
error
,
outparam
,
name
,
ME_ERROR
+
ME_WAITTANG
);
delete
outparam
->
file
;
delete
outparam
->
file
;
outparam
->
file
=
0
;
// For eas
y
er errorchecking
outparam
->
file
=
0
;
// For eas
i
er errorchecking
outparam
->
db_stat
=
0
;
outparam
->
db_stat
=
0
;
hash_free
(
&
outparam
->
name_hash
);
hash_free
(
&
outparam
->
name_hash
);
free_root
(
&
outparam
->
mem_root
,
MYF
(
0
));
free_root
(
&
outparam
->
mem_root
,
MYF
(
0
));
...
@@ -788,7 +788,7 @@ int closefrm(register TABLE *table)
...
@@ -788,7 +788,7 @@ int closefrm(register TABLE *table)
table
->
fields
=
0
;
table
->
fields
=
0
;
}
}
delete
table
->
file
;
delete
table
->
file
;
table
->
file
=
0
;
/* For eas
y
er errorchecking */
table
->
file
=
0
;
/* For eas
i
er errorchecking */
hash_free
(
&
table
->
name_hash
);
hash_free
(
&
table
->
name_hash
);
free_root
(
&
table
->
mem_root
,
MYF
(
0
));
free_root
(
&
table
->
mem_root
,
MYF
(
0
));
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
...
@@ -985,7 +985,7 @@ static void frm_error(int error, TABLE *form, const char *name, myf errortype)
...
@@ -985,7 +985,7 @@ static void frm_error(int error, TABLE *form, const char *name, myf errortype)
/*
/*
** fix a str_type to a array type
** fix a str_type to a array type
** typeparts sep
e
arated with some char. differents types are separated
** typeparts separated with some char. differents types are separated
** with a '\0'
** with a '\0'
*/
*/
...
@@ -1072,7 +1072,7 @@ static uint find_field(TABLE *form,uint start,uint length)
...
@@ -1072,7 +1072,7 @@ static uint find_field(TABLE *form,uint start,uint length)
}
}
/* Check that the integer is in the intern
val
l */
/* Check that the integer is in the intern
a
l */
int
set_zone
(
register
int
nr
,
int
min_zone
,
int
max_zone
)
int
set_zone
(
register
int
nr
,
int
min_zone
,
int
max_zone
)
{
{
...
@@ -1136,7 +1136,7 @@ void append_unescaped(String *res, const char *pos, uint length)
...
@@ -1136,7 +1136,7 @@ void append_unescaped(String *res, const char *pos, uint length)
res
->
append
(
'n'
);
res
->
append
(
'n'
);
break
;
break
;
case
'\r'
:
case
'\r'
:
res
->
append
(
'\\'
);
/* This gives better readbility */
res
->
append
(
'\\'
);
/* This gives better read
a
bility */
res
->
append
(
'r'
);
res
->
append
(
'r'
);
break
;
break
;
case
'\\'
:
case
'\\'
:
...
@@ -1500,15 +1500,17 @@ void st_table_list::set_ancestor()
...
@@ -1500,15 +1500,17 @@ void st_table_list::set_ancestor()
thd - thread handler
thd - thread handler
conds - condition of this JOIN
conds - condition of this JOIN
DESCRIPTION
It is:
- preparing translation table for view columns (fix_fields() for every
call and creation for first call)
- preparing WHERE, ON and CHECK OPTION condition (fix_fields() for every
call and merging for first call).
If there are underlying view(s) procedure first will be called for them.
RETURN
RETURN
0 - OK
0 - OK
1 - error
1 - error
TODO: for several substituted table last set up table (or maybe subtree,
it depends on future join implementation) will contain all fields of VIEW
(to be able call fix_fields() for them. All other will looks like empty
(without fields) for name resolving, but substituted expressions will
return correct used tables mask.
*/
*/
bool
st_table_list
::
setup_ancestor
(
THD
*
thd
,
Item
**
conds
)
bool
st_table_list
::
setup_ancestor
(
THD
*
thd
,
Item
**
conds
)
...
@@ -1619,7 +1621,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
...
@@ -1619,7 +1621,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
{
{
/*
/*
Store WHERE condition to ON expression for outer join, because
Store WHERE condition to ON expression for outer join, because
we can't use WHERE to correctly execute
j
eft joins on VIEWs and
we can't use WHERE to correctly execute
l
eft joins on VIEWs and
this expression will not be moved to WHERE condition (i.e. will
this expression will not be moved to WHERE condition (i.e. will
be clean correctly for PS/SP)
be clean correctly for PS/SP)
*/
*/
...
@@ -1633,7 +1635,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
...
@@ -1633,7 +1635,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
{
{
/*
/*
Store WHERE condition to ON expression for outer join, because
Store WHERE condition to ON expression for outer join, because
we can't use WHERE to correctly execute
j
eft joins on VIEWs and
we can't use WHERE to correctly execute
l
eft joins on VIEWs and
this expression will not be moved to WHERE condition (i.e. will
this expression will not be moved to WHERE condition (i.e. will
be clean correctly for PS/SP)
be clean correctly for PS/SP)
*/
*/
...
...
sql/table.h
View file @
3ef0b19c
...
@@ -34,7 +34,7 @@ typedef struct st_order {
...
@@ -34,7 +34,7 @@ typedef struct st_order {
bool
asc
;
/* true if ascending */
bool
asc
;
/* true if ascending */
bool
free_me
;
/* true if item isn't shared */
bool
free_me
;
/* true if item isn't shared */
bool
in_field_list
;
/* true if in select field list */
bool
in_field_list
;
/* true if in select field list */
bool
counter_used
;
/* para
p
eter was counter of columns */
bool
counter_used
;
/* para
m
eter was counter of columns */
Field
*
field
;
/* If tmp-table group */
Field
*
field
;
/* If tmp-table group */
char
*
buff
;
/* If tmp-table group */
char
*
buff
;
/* If tmp-table group */
table_map
used
,
depend_map
;
table_map
used
,
depend_map
;
...
@@ -116,7 +116,7 @@ struct st_table {
...
@@ -116,7 +116,7 @@ struct st_table {
These two members hold offset in record + 1 for TIMESTAMP field
These two members hold offset in record + 1 for TIMESTAMP field
with NOW() as default value or/and with ON UPDATE NOW() option.
with NOW() as default value or/and with ON UPDATE NOW() option.
If 0 then such field is absent in this table or auto-set for default
If 0 then such field is absent in this table or auto-set for default
or/and on update should be temporaly disabled for some reason.
or/and on update should be temporal
l
y disabled for some reason.
These values is setup to offset value for each statement in open_table()
These values is setup to offset value for each statement in open_table()
and turned off in statement processing code (see mysql_update as example).
and turned off in statement processing code (see mysql_update as example).
*/
*/
...
@@ -235,10 +235,10 @@ typedef struct st_table_list
...
@@ -235,10 +235,10 @@ typedef struct st_table_list
Item
*
where
;
/* VIEW WHERE clause condition */
Item
*
where
;
/* VIEW WHERE clause condition */
Item
*
check_option
;
/* WITH CHECK OPTION condition */
Item
*
check_option
;
/* WITH CHECK OPTION condition */
LEX_STRING
query
;
/* text of (CRETE/SELECT) statement */
LEX_STRING
query
;
/* text of (CRETE/SELECT) statement */
LEX_STRING
md5
;
/* md5 of query te
s
xt */
LEX_STRING
md5
;
/* md5 of query text */
LEX_STRING
source
;
/* source of CREATE VIEW */
LEX_STRING
source
;
/* source of CREATE VIEW */
LEX_STRING
view_db
;
/* save view database */
LEX_STRING
view_db
;
/* save
d
view database */
LEX_STRING
view_name
;
/* save view name */
LEX_STRING
view_name
;
/* save
d
view name */
LEX_STRING
timestamp
;
/* GMT time stamp of last operation */
LEX_STRING
timestamp
;
/* GMT time stamp of last operation */
ulonglong
file_version
;
/* version of file's field set */
ulonglong
file_version
;
/* version of file's field set */
ulonglong
updatable_view
;
/* VIEW can be updated */
ulonglong
updatable_view
;
/* VIEW can be updated */
...
@@ -263,11 +263,11 @@ typedef struct st_table_list
...
@@ -263,11 +263,11 @@ typedef struct st_table_list
st_table_list
*
embedding
;
/* nested join containing the table */
st_table_list
*
embedding
;
/* nested join containing the table */
List
<
struct
st_table_list
>
*
join_list
;
/* join list the table belongs to */
List
<
struct
st_table_list
>
*
join_list
;
/* join list the table belongs to */
bool
cacheable_table
;
/* stop PS caching */
bool
cacheable_table
;
/* stop PS caching */
/* used in multi-upd/views priv
e
lege check */
/* used in multi-upd/views priv
i
lege check */
bool
table_in_first_from_clause
;
bool
table_in_first_from_clause
;
bool
skip_temporary
;
/* this table shouldn't be temporary */
bool
skip_temporary
;
/* this table shouldn't be temporary */
bool
setup_is_done
;
/* setup_tables() is done */
bool
setup_is_done
;
/* setup_tables() is done */
/*
do
view contain auto_increment field */
/*
TRUE if this merged
view contain auto_increment field */
bool
contain_auto_increment
;
bool
contain_auto_increment
;
/* FRMTYPE_ERROR if any type is acceptable */
/* FRMTYPE_ERROR if any type is acceptable */
enum
frm_type_enum
required_type
;
enum
frm_type_enum
required_type
;
...
...
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