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
c9497e23
Commit
c9497e23
authored
Nov 21, 2004
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
post merge
parent
3bc1fcd4
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
97 additions
and
56 deletions
+97
-56
sql/item.cc
sql/item.cc
+0
-5
sql/mysql_priv.h
sql/mysql_priv.h
+3
-3
sql/sql_acl.cc
sql/sql_acl.cc
+1
-1
sql/sql_base.cc
sql/sql_base.cc
+18
-16
sql/sql_insert.cc
sql/sql_insert.cc
+1
-1
sql/sql_lex.cc
sql/sql_lex.cc
+1
-1
sql/sql_lex.h
sql/sql_lex.h
+1
-0
sql/sql_load.cc
sql/sql_load.cc
+5
-2
sql/sql_parse.cc
sql/sql_parse.cc
+2
-6
sql/sql_update.cc
sql/sql_update.cc
+55
-13
sql/table.cc
sql/table.cc
+10
-8
No files found.
sql/item.cc
View file @
c9497e23
...
@@ -2670,11 +2670,6 @@ void Item_ref::cleanup()
...
@@ -2670,11 +2670,6 @@ void Item_ref::cleanup()
DBUG_ENTER
(
"Item_ref::cleanup"
);
DBUG_ENTER
(
"Item_ref::cleanup"
);
Item_ident
::
cleanup
();
Item_ident
::
cleanup
();
result_field
=
0
;
result_field
=
0
;
DBUG_PRINT
(
"info"
,
(
"hook: 0x%lx(0x%lx) original item: 0x%lx"
,
(
ulong
)
hook_ptr
,
(
ulong
)(
hook_ptr
?*
hook_ptr
:
0
),
(
ulong
)
orig_item
));
if
(
hook_ptr
)
*
hook_ptr
=
orig_item
;
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
...
...
sql/mysql_priv.h
View file @
c9497e23
...
@@ -619,8 +619,7 @@ int mysql_multi_update(THD *thd, TABLE_LIST *table_list,
...
@@ -619,8 +619,7 @@ int mysql_multi_update(THD *thd, TABLE_LIST *table_list,
List
<
Item
>
*
fields
,
List
<
Item
>
*
values
,
List
<
Item
>
*
fields
,
List
<
Item
>
*
values
,
COND
*
conds
,
ulong
options
,
COND
*
conds
,
ulong
options
,
enum
enum_duplicates
handle_duplicates
,
enum
enum_duplicates
handle_duplicates
,
SELECT_LEX_UNIT
*
unit
,
SELECT_LEX
*
select_lex
,
SELECT_LEX_UNIT
*
unit
,
SELECT_LEX
*
select_lex
);
bool
converted
);
int
mysql_prepare_insert
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
TABLE
*
table
,
int
mysql_prepare_insert
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
TABLE
*
table
,
List
<
Item
>
&
fields
,
List_item
*
values
,
List
<
Item
>
&
fields
,
List_item
*
values
,
List
<
Item
>
&
update_fields
,
List
<
Item
>
&
update_fields
,
...
@@ -661,7 +660,8 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
...
@@ -661,7 +660,8 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
uint
length
,
Item
**
ref
,
uint
length
,
Item
**
ref
,
bool
check_grants_table
,
bool
check_grants_view
,
bool
check_grants_table
,
bool
check_grants_view
,
bool
allow_rowid
,
bool
allow_rowid
,
uint
*
cached_field_index_ptr
);
uint
*
cached_field_index_ptr
,
bool
register_tree_change
);
Field
*
Field
*
find_field_in_real_table
(
THD
*
thd
,
TABLE
*
table
,
const
char
*
name
,
find_field_in_real_table
(
THD
*
thd
,
TABLE
*
table
,
const
char
*
name
,
uint
length
,
bool
check_grants
,
bool
allow_rowid
,
uint
length
,
bool
check_grants
,
bool
allow_rowid
,
...
...
sql/sql_acl.cc
View file @
c9497e23
...
@@ -2360,7 +2360,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
...
@@ -2360,7 +2360,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
if
(
!
find_field_in_table
(
thd
,
table_list
,
column
->
column
.
ptr
(),
if
(
!
find_field_in_table
(
thd
,
table_list
,
column
->
column
.
ptr
(),
column
->
column
.
ptr
(),
column
->
column
.
ptr
(),
column
->
column
.
length
(),
0
,
0
,
0
,
0
,
column
->
column
.
length
(),
0
,
0
,
0
,
0
,
&
unused_field_idx
))
&
unused_field_idx
,
FALSE
))
{
{
my_error
(
ER_BAD_FIELD_ERROR
,
MYF
(
0
),
my_error
(
ER_BAD_FIELD_ERROR
,
MYF
(
0
),
column
->
column
.
c_ptr
(),
table_list
->
alias
);
column
->
column
.
c_ptr
(),
table_list
->
alias
);
...
...
sql/sql_base.cc
View file @
c9497e23
...
@@ -2069,6 +2069,8 @@ const Field *view_ref_found= (Field*) 0x2;
...
@@ -2069,6 +2069,8 @@ const Field *view_ref_found= (Field*) 0x2;
allow_rowid do allow finding of "_rowid" field?
allow_rowid do allow finding of "_rowid" field?
cached_field_index_ptr cached position in field list (used to
cached_field_index_ptr cached position in field list (used to
speedup prepared tables field finding)
speedup prepared tables field finding)
register_tree_change TRUE if ref is not stack variable and we
need register changes in item tree
RETURN
RETURN
0 field is not found
0 field is not found
...
@@ -2082,7 +2084,8 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
...
@@ -2082,7 +2084,8 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
uint
length
,
Item
**
ref
,
uint
length
,
Item
**
ref
,
bool
check_grants_table
,
bool
check_grants_view
,
bool
check_grants_table
,
bool
check_grants_view
,
bool
allow_rowid
,
bool
allow_rowid
,
uint
*
cached_field_index_ptr
)
uint
*
cached_field_index_ptr
,
bool
register_tree_change
)
{
{
DBUG_ENTER
(
"find_field_in_table"
);
DBUG_ENTER
(
"find_field_in_table"
);
DBUG_PRINT
(
"enter"
,
(
"table:%s name: %s item name %s, ref 0x%lx"
,
DBUG_PRINT
(
"enter"
,
(
"table:%s name: %s item name %s, ref 0x%lx"
,
...
@@ -2109,10 +2112,11 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
...
@@ -2109,10 +2112,11 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
*
ref
=
trans
[
i
].
item
;
*
ref
=
trans
[
i
].
item
;
else
else
{
{
Item_ref
*
item_ref
=
new
Item_ref
(
trans
[
i
].
item
,
table_list
->
view_name
.
str
,
Item_ref
*
item_ref
=
new
Item_ref
(
&
trans
[
i
].
item
,
table_list
->
view_name
.
str
,
item_name
);
item_name
);
/* as far as Item_ref have defined reference it do not need tables */
/* as far as Item_ref have defined reference it do not need tables */
if
(
item_ref
)
if
(
register_tree_change
&&
item_ref
)
{
{
thd
->
change_item_tree
(
ref
,
item_ref
);
thd
->
change_item_tree
(
ref
,
item_ref
);
(
*
ref
)
->
fix_fields
(
thd
,
0
,
ref
);
(
*
ref
)
->
fix_fields
(
thd
,
0
,
ref
);
...
@@ -2288,7 +2292,8 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
...
@@ -2288,7 +2292,8 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
check_privileges
),
check_privileges
),
(
test
(
table
->
grant
.
want_privilege
)
&&
(
test
(
table
->
grant
.
want_privilege
)
&&
check_privileges
),
check_privileges
),
1
,
&
(
item
->
cached_field_index
));
1
,
&
(
item
->
cached_field_index
),
TRUE
);
}
}
if
(
found
)
if
(
found
)
{
{
...
@@ -2327,7 +2332,8 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
...
@@ -2327,7 +2332,8 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
check_privileges
),
check_privileges
),
(
test
(
tables
->
grant
.
want_privilege
)
&&
(
test
(
tables
->
grant
.
want_privilege
)
&&
check_privileges
),
check_privileges
),
1
,
&
(
item
->
cached_field_index
));
1
,
&
(
item
->
cached_field_index
),
TRUE
);
if
(
find
)
if
(
find
)
{
{
item
->
cached_table
=
tables
;
item
->
cached_table
=
tables
;
...
@@ -2392,7 +2398,9 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
...
@@ -2392,7 +2398,9 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
check_privileges
),
check_privileges
),
(
test
(
tables
->
grant
.
want_privilege
)
&&
(
test
(
tables
->
grant
.
want_privilege
)
&&
check_privileges
),
check_privileges
),
allow_rowid
,
&
(
item
->
cached_field_index
));
allow_rowid
,
&
(
item
->
cached_field_index
),
TRUE
);
if
(
field
)
if
(
field
)
{
{
if
(
field
==
WRONG_GRANT
)
if
(
field
==
WRONG_GRANT
)
...
@@ -3028,7 +3036,7 @@ insert_fields(THD *thd, TABLE_LIST *tables, const char *db_name,
...
@@ -3028,7 +3036,7 @@ insert_fields(THD *thd, TABLE_LIST *tables, const char *db_name,
!
find_field_in_table
(
thd
,
natural_join_table
,
field_name
,
!
find_field_in_table
(
thd
,
natural_join_table
,
field_name
,
field_name
,
field_name
,
strlen
(
field_name
),
&
not_used_item
,
0
,
0
,
0
,
strlen
(
field_name
),
&
not_used_item
,
0
,
0
,
0
,
&
not_used_field_index
))
&
not_used_field_index
,
TRUE
))
{
{
Item
*
item
=
iterator
->
item
(
thd
);
Item
*
item
=
iterator
->
item
(
thd
);
if
(
!
found
++
)
if
(
!
found
++
)
...
@@ -3037,7 +3045,7 @@ insert_fields(THD *thd, TABLE_LIST *tables, const char *db_name,
...
@@ -3037,7 +3045,7 @@ insert_fields(THD *thd, TABLE_LIST *tables, const char *db_name,
it
->
after
(
item
);
it
->
after
(
item
);
if
(
view
&&
!
thd
->
lex
->
current_select
->
no_wrap_view_item
)
if
(
view
&&
!
thd
->
lex
->
current_select
->
no_wrap_view_item
)
{
{
item
=
new
Item_ref
(
it
->
ref
(),
NULL
,
tables
->
view_name
.
str
,
item
=
new
Item_ref
(
it
->
ref
(),
tables
->
view_name
.
str
,
field_name
);
field_name
);
}
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
#ifndef NO_EMBEDDED_ACCESS_CHECKS
...
@@ -3252,7 +3260,8 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, COND **conds)
...
@@ -3252,7 +3260,8 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, COND **conds)
t1_field_name
,
t1_field_name
,
strlen
(
t1_field_name
),
&
item_t2
,
strlen
(
t1_field_name
),
&
item_t2
,
0
,
0
,
0
,
0
,
0
,
0
,
&
not_used_field_index
)))
&
not_used_field_index
,
FALSE
)))
{
{
if
(
t2_field
!=
view_ref_found
)
if
(
t2_field
!=
view_ref_found
)
{
{
...
@@ -3262,13 +3271,6 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, COND **conds)
...
@@ -3262,13 +3271,6 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, COND **conds)
t2_field
->
query_id
=
thd
->
query_id
;
t2_field
->
query_id
=
thd
->
query_id
;
t2
->
used_keys
.
intersect
(
t2_field
->
part_of_key
);
t2
->
used_keys
.
intersect
(
t2_field
->
part_of_key
);
}
}
else
{
DBUG_ASSERT
(
t2_field
==
view_ref_found
&&
item_t2
->
type
()
==
Item
::
REF_ITEM
);
/* remove hooking to stack variable */
((
Item_ref
*
)
item_t2
)
->
hook_ptr
=
0
;
}
if
((
t1_field
=
iterator
->
field
()))
if
((
t1_field
=
iterator
->
field
()))
{
{
/* Mark field used for table cache */
/* Mark field used for table cache */
...
...
sql/sql_insert.cc
View file @
c9497e23
...
@@ -1781,7 +1781,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
...
@@ -1781,7 +1781,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
query
query
*/
*/
if
(
!
(
thd
->
lex
->
current_select
->
options
&
OPTION_BUFFER_RESULT
)
&&
if
(
!
(
thd
->
lex
->
current_select
->
options
&
OPTION_BUFFER_RESULT
)
&&
unique_table
(
table_list
,
table_list
->
next_
independent
()
))
unique_table
(
table_list
,
table_list
->
next_
global
))
{
{
/* Using same table for INSERT and SELECT */
/* Using same table for INSERT and SELECT */
thd
->
lex
->
current_select
->
options
|=
OPTION_BUFFER_RESULT
;
thd
->
lex
->
current_select
->
options
|=
OPTION_BUFFER_RESULT
;
...
...
sql/sql_lex.cc
View file @
c9497e23
...
@@ -150,7 +150,7 @@ void lex_start(THD *thd, uchar *buf,uint length)
...
@@ -150,7 +150,7 @@ void lex_start(THD *thd, uchar *buf,uint length)
lex
->
found_colon
=
0
;
lex
->
found_colon
=
0
;
lex
->
safe_to_cache_query
=
1
;
lex
->
safe_to_cache_query
=
1
;
lex
->
time_zone_tables_used
=
0
;
lex
->
time_zone_tables_used
=
0
;
lex
->
proc_table
=
lex
->
query_tables
=
0
;
lex
->
leaf_tables_insert
=
lex
->
proc_table
=
lex
->
query_tables
=
0
;
lex
->
query_tables_last
=
&
lex
->
query_tables
;
lex
->
query_tables_last
=
&
lex
->
query_tables
;
lex
->
variables_used
=
0
;
lex
->
variables_used
=
0
;
lex
->
select_lex
.
parent_lex
=
lex
;
lex
->
select_lex
.
parent_lex
=
lex
;
...
...
sql/sql_lex.h
View file @
c9497e23
...
@@ -710,6 +710,7 @@ typedef struct st_lex
...
@@ -710,6 +710,7 @@ typedef struct st_lex
uint
grant
,
grant_tot_col
,
which_columns
;
uint
grant
,
grant_tot_col
,
which_columns
;
uint
fk_delete_opt
,
fk_update_opt
,
fk_match_option
;
uint
fk_delete_opt
,
fk_update_opt
,
fk_match_option
;
uint
slave_thd_opt
;
uint
slave_thd_opt
;
uint
table_count
;
/* used when usual update transformed in multiupdate */
uint8
describe
;
uint8
describe
;
uint8
derived_tables
;
uint8
derived_tables
;
uint8
create_view_algorithm
;
uint8
create_view_algorithm
;
...
...
sql/sql_load.cc
View file @
c9497e23
...
@@ -121,9 +121,12 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
...
@@ -121,9 +121,12 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
table_list
->
lock_type
=
lock_type
;
table_list
->
lock_type
=
lock_type
;
if
((
res
=
open_and_lock_tables
(
thd
,
table_list
)))
if
((
res
=
open_and_lock_tables
(
thd
,
table_list
)))
DBUG_RETURN
(
res
);
DBUG_RETURN
(
res
);
if
(
setup_tables
(
thd
,
table_list
,
&
unused_conds
))
if
(
setup_tables
(
thd
,
table_list
,
&
unused_conds
,
&
thd
->
lex
->
select_lex
.
leaf_tables
,
0
))
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
if
(
!
table_list
->
updatable
||
check_key_in_view
(
thd
,
table_list
))
if
(
!
table_list
->
table
||
// do not suport join view
!
table_list
->
updatable
||
// and derived tables
check_key_in_view
(
thd
,
table_list
))
{
{
my_error
(
ER_NON_UPDATABLE_TABLE
,
MYF
(
0
),
table_list
->
alias
,
"LOAD"
);
my_error
(
ER_NON_UPDATABLE_TABLE
,
MYF
(
0
),
table_list
->
alias
,
"LOAD"
);
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
...
...
sql/sql_parse.cc
View file @
c9497e23
...
@@ -2801,7 +2801,6 @@ unsent_create_error:
...
@@ -2801,7 +2801,6 @@ unsent_create_error:
break
;
break
;
case
SQLCOM_UPDATE_MULTI
:
case
SQLCOM_UPDATE_MULTI
:
{
{
bool
converted
=
0
;
DBUG_ASSERT
(
first_table
==
all_tables
&&
first_table
!=
0
);
DBUG_ASSERT
(
first_table
==
all_tables
&&
first_table
!=
0
);
if
(
res
!=
2
)
if
(
res
!=
2
)
{
{
...
@@ -2809,17 +2808,14 @@ unsent_create_error:
...
@@ -2809,17 +2808,14 @@ unsent_create_error:
break
;
break
;
}
}
else
else
{
res
=
0
;
res
=
0
;
converted
=
1
;
}
res
=
mysql_multi_update
(
thd
,
all_tables
,
res
=
mysql_multi_update
(
thd
,
all_tables
,
&
select_lex
->
item_list
,
&
select_lex
->
item_list
,
&
lex
->
value_list
,
&
lex
->
value_list
,
select_lex
->
where
,
select_lex
->
where
,
select_lex
->
options
,
select_lex
->
options
,
lex
->
duplicates
,
unit
,
select_lex
,
lex
->
duplicates
,
unit
,
select_lex
);
converted
);
break
;
break
;
}
}
case
SQLCOM_REPLACE
:
case
SQLCOM_REPLACE
:
...
...
sql/sql_update.cc
View file @
c9497e23
...
@@ -127,6 +127,7 @@ int mysql_update(THD *thd,
...
@@ -127,6 +127,7 @@ int mysql_update(THD *thd,
#ifndef NO_EMBEDDED_ACCESS_CHECKS
#ifndef NO_EMBEDDED_ACCESS_CHECKS
uint
want_privilege
;
uint
want_privilege
;
#endif
#endif
uint
table_count
=
0
;
ulong
query_id
=
thd
->
query_id
,
timestamp_query_id
;
ulong
query_id
=
thd
->
query_id
,
timestamp_query_id
;
ha_rows
updated
,
found
;
ha_rows
updated
,
found
;
key_map
old_used_keys
;
key_map
old_used_keys
;
...
@@ -138,17 +139,26 @@ int mysql_update(THD *thd,
...
@@ -138,17 +139,26 @@ int mysql_update(THD *thd,
LINT_INIT
(
used_index
);
LINT_INIT
(
used_index
);
LINT_INIT
(
timestamp_query_id
);
LINT_INIT
(
timestamp_query_id
);
if
(
(
error
=
open_and_lock_tables
(
thd
,
table_list
)
))
if
(
open_tables
(
thd
,
table_list
,
&
table_count
))
DBUG_RETURN
(
error
);
DBUG_RETURN
(
thd
->
net
.
report_error
?
-
1
:
1
);
if
(
table_list
->
table
==
0
)
if
(
table_list
->
table
==
0
)
{
{
DBUG_ASSERT
(
table_list
->
view
&&
DBUG_ASSERT
(
table_list
->
view
&&
table_list
->
ancestor
&&
table_list
->
ancestor
->
next_local
);
table_list
->
ancestor
&&
table_list
->
ancestor
->
next_local
);
DBUG_PRINT
(
"info"
,
(
"Switch to multi-update"
));
DBUG_PRINT
(
"info"
,
(
"Switch to multi-update"
));
/* pass counter value */
thd
->
lex
->
table_count
=
table_count
;
/* convert to multiupdate */
/* convert to multiupdate */
return
2
;
return
2
;
}
}
if
(
lock_tables
(
thd
,
table_list
,
table_count
)
||
mysql_handle_derived
(
thd
->
lex
,
&
mysql_derived_prepare
)
||
(
thd
->
fill_derived_tables
()
&&
mysql_handle_derived
(
thd
->
lex
,
&
mysql_derived_filling
)))
DBUG_RETURN
(
thd
->
net
.
report_error
?
-
1
:
1
);
thd
->
proc_info
=
"init"
;
thd
->
proc_info
=
"init"
;
table
=
table_list
->
table
;
table
=
table_list
->
table
;
table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
);
table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
);
...
@@ -614,14 +624,25 @@ int mysql_multi_update_prepare(THD *thd)
...
@@ -614,14 +624,25 @@ int mysql_multi_update_prepare(THD *thd)
table_map
tables_for_update
;
table_map
tables_for_update
;
int
res
;
int
res
;
bool
update_view
=
0
;
bool
update_view
=
0
;
uint
table_count
;
/*
if this multi-update was converted from usual update, here is table
counter else junk will be assigned here, but then replaced with real
count in open_tables()
*/
uint
table_count
=
lex
->
table_count
;
const
bool
using_lock_tables
=
thd
->
locked_tables
!=
0
;
const
bool
using_lock_tables
=
thd
->
locked_tables
!=
0
;
bool
original_multiupdate
=
(
thd
->
lex
->
sql_command
==
SQLCOM_UPDATE_MULTI
);
DBUG_ENTER
(
"mysql_multi_update_prepare"
);
DBUG_ENTER
(
"mysql_multi_update_prepare"
);
/* open tables and create derived ones, but do not lock and fill them */
/* open tables and create derived ones, but do not lock and fill them */
if
(
open_tables
(
thd
,
table_list
,
&
table_count
)
||
if
(
(
original_multiupdate
&&
open_tables
(
thd
,
table_list
,
&
table_count
)
)
||
mysql_handle_derived
(
lex
,
&
mysql_derived_prepare
))
mysql_handle_derived
(
lex
,
&
mysql_derived_prepare
))
DBUG_RETURN
(
thd
->
net
.
report_error
?
-
1
:
1
);
DBUG_RETURN
(
thd
->
net
.
report_error
?
-
1
:
1
);
/*
setup_tables() need for VIEWs. JOIN::prepare() will call setup_tables()
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
,
&
lex
->
select_lex
.
leaf_tables
,
0
))
&
lex
->
select_lex
.
leaf_tables
,
0
))
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
...
@@ -644,11 +665,6 @@ int mysql_multi_update_prepare(THD *thd)
...
@@ -644,11 +665,6 @@ int mysql_multi_update_prepare(THD *thd)
(
UPDATE_ACL
&
~
table
->
grant
.
privilege
);
(
UPDATE_ACL
&
~
table
->
grant
.
privilege
);
}
}
/*
setup_tables() need for VIEWs. JOIN::prepare() will call setup_tables()
second time, but this call will do nothing (there are check for second
call in setup_tables()).
*/
if
((
lex
->
select_lex
.
no_wrap_view_item
=
1
,
if
((
lex
->
select_lex
.
no_wrap_view_item
=
1
,
res
=
setup_fields
(
thd
,
0
,
table_list
,
*
fields
,
1
,
0
,
0
),
res
=
setup_fields
(
thd
,
0
,
table_list
,
*
fields
,
1
,
0
,
0
),
lex
->
select_lex
.
no_wrap_view_item
=
0
,
lex
->
select_lex
.
no_wrap_view_item
=
0
,
...
@@ -675,7 +691,16 @@ int mysql_multi_update_prepare(THD *thd)
...
@@ -675,7 +691,16 @@ int mysql_multi_update_prepare(THD *thd)
Setup timestamp handling and locking mode
Setup timestamp handling and locking mode
*/
*/
for
(
tl
=
leaves
;
tl
;
tl
=
tl
->
next_leaf
)
for
(
tl
=
leaves
;
tl
;
tl
=
tl
->
next_leaf
)
{
TABLE
*
table
=
tl
->
table
;
TABLE_LIST
*
tlist
=
tl
->
belong_to_view
?
tl
->
belong_to_view
:
tl
;
/* We only need SELECT privilege for columns in the values list */
tlist
->
grant
.
want_privilege
=
table
->
grant
.
want_privilege
=
(
SELECT_ACL
&
~
table
->
grant
.
privilege
);
/* Only set timestamp column if this is not modified */
if
(
table
->
timestamp_field
&&
table
->
timestamp_field
->
query_id
==
thd
->
query_id
)
table
->
timestamp_field_type
=
TIMESTAMP_NO_AUTO_SET
;
table
->
timestamp_field_type
=
TIMESTAMP_NO_AUTO_SET
;
/* if table will be updated then check that it is unique */
/* if table will be updated then check that it is unique */
...
@@ -711,6 +736,23 @@ int mysql_multi_update_prepare(THD *thd)
...
@@ -711,6 +736,23 @@ int mysql_multi_update_prepare(THD *thd)
tl
->
table
->
reginfo
.
lock_type
=
tl
->
lock_type
;
tl
->
table
->
reginfo
.
lock_type
=
tl
->
lock_type
;
}
}
/* check single table update for view compound from several tables */
for
(
tl
=
table_list
;
tl
;
tl
=
tl
->
next_local
)
{
if
(
tl
->
table
==
0
)
{
DBUG_ASSERT
(
tl
->
view
&&
tl
->
ancestor
&&
tl
->
ancestor
->
next_local
);
TABLE_LIST
*
for_update
=
0
;
if
(
tl
->
check_single_table
(
&
for_update
,
tables_for_update
))
{
my_error
(
ER_VIEW_MULTIUPDATE
,
MYF
(
0
),
tl
->
view_db
.
str
,
tl
->
view_name
.
str
);
DBUG_RETURN
(
-
1
);
}
}
}
opened_tables
=
thd
->
status_var
.
opened_tables
;
opened_tables
=
thd
->
status_var
.
opened_tables
;
/* now lock and fill tables */
/* now lock and fill tables */
if
(
lock_tables
(
thd
,
table_list
,
table_count
))
if
(
lock_tables
(
thd
,
table_list
,
table_count
))
...
@@ -740,7 +782,8 @@ int mysql_multi_update_prepare(THD *thd)
...
@@ -740,7 +782,8 @@ int mysql_multi_update_prepare(THD *thd)
/* undone setup_tables() */
/* undone setup_tables() */
table_list
->
setup_is_done
=
0
;
table_list
->
setup_is_done
=
0
;
if
(
setup_tables
(
thd
,
table_list
,
&
lex
->
select_lex
.
where
)
||
if
(
setup_tables
(
thd
,
table_list
,
&
lex
->
select_lex
.
where
,
&
lex
->
select_lex
.
leaf_tables
,
0
)
||
(
lex
->
select_lex
.
no_wrap_view_item
=
1
,
(
lex
->
select_lex
.
no_wrap_view_item
=
1
,
res
=
setup_fields
(
thd
,
0
,
table_list
,
*
fields
,
1
,
0
,
0
),
res
=
setup_fields
(
thd
,
0
,
table_list
,
*
fields
,
1
,
0
,
0
),
lex
->
select_lex
.
no_wrap_view_item
=
0
,
lex
->
select_lex
.
no_wrap_view_item
=
0
,
...
@@ -765,8 +808,7 @@ int mysql_multi_update(THD *thd,
...
@@ -765,8 +808,7 @@ int mysql_multi_update(THD *thd,
COND
*
conds
,
COND
*
conds
,
ulong
options
,
ulong
options
,
enum
enum_duplicates
handle_duplicates
,
enum
enum_duplicates
handle_duplicates
,
SELECT_LEX_UNIT
*
unit
,
SELECT_LEX
*
select_lex
,
SELECT_LEX_UNIT
*
unit
,
SELECT_LEX
*
select_lex
)
bool
converted
)
{
{
int
res
=
0
;
int
res
=
0
;
multi_update
*
result
;
multi_update
*
result
;
...
...
sql/table.cc
View file @
c9497e23
...
@@ -1841,9 +1841,10 @@ void st_table_list::cleanup_items()
...
@@ -1841,9 +1841,10 @@ void st_table_list::cleanup_items()
if
(
!
field_translation
)
if
(
!
field_translation
)
return
;
return
;
Item
**
end
=
field_translation
+
view
->
select_lex
.
item_list
.
elements
;
Field_translator
*
end
=
(
field_translation
+
for
(
Item
**
item
=
field_translation
;
item
<
end
;
item
++
)
view
->
select_lex
.
item_list
.
elements
);
(
*
item
)
->
walk
(
&
Item
::
cleanup_processor
,
0
);
for
(
Field_translator
*
transl
=
field_translation
;
transl
<
end
;
transl
++
)
transl
->
item
->
walk
(
&
Item
::
cleanup_processor
,
0
);
}
}
...
@@ -1883,7 +1884,7 @@ int st_table_list::view_check_option(THD *thd, bool ignore_failure)
...
@@ -1883,7 +1884,7 @@ int st_table_list::view_check_option(THD *thd, bool ignore_failure)
/*
/*
Find table in underlaying tables by mask and check that only this
Find table in underlaying tables by mask and check that only this
table
s
belong to given mask
table belong to given mask
SYNOPSIS
SYNOPSIS
st_table_list::check_single_table()
st_table_list::check_single_table()
...
@@ -1893,8 +1894,8 @@ int st_table_list::view_check_option(THD *thd, bool ignore_failure)
...
@@ -1893,8 +1894,8 @@ int st_table_list::view_check_option(THD *thd, bool ignore_failure)
map bit mask of tables
map bit mask of tables
RETURN
RETURN
0
table not found or found only one
FALSE
table not found or found only one
1
found several tables
TRUE
found several tables
*/
*/
bool
st_table_list
::
check_single_table
(
st_table_list
**
table
,
table_map
map
)
bool
st_table_list
::
check_single_table
(
st_table_list
**
table
,
table_map
map
)
...
@@ -1906,15 +1907,16 @@ bool st_table_list::check_single_table(st_table_list **table, table_map map)
...
@@ -1906,15 +1907,16 @@ bool st_table_list::check_single_table(st_table_list **table, table_map map)
if
(
tbl
->
table
->
map
&
map
)
if
(
tbl
->
table
->
map
&
map
)
{
{
if
(
*
table
)
if
(
*
table
)
return
1
;
return
TRUE
;
else
else
*
table
=
tbl
;
*
table
=
tbl
;
}
}
}
}
else
else
if
(
tbl
->
check_single_table
(
table
,
map
))
if
(
tbl
->
check_single_table
(
table
,
map
))
return
1
;
return
TRUE
;
}
}
return
FALSE
;
}
}
...
...
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