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
68cb444c
Commit
68cb444c
authored
May 04, 2004
by
Sinisa@sinisa.nasamreza.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for a multi table updates when one of the tables is not updated
but used in a nested query.
parent
b5812768
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
5 deletions
+11
-5
mysql-test/r/multi_update.result
mysql-test/r/multi_update.result
+1
-0
mysql-test/t/multi_update.test
mysql-test/t/multi_update.test
+4
-0
sql/sql_update.cc
sql/sql_update.cc
+6
-5
No files found.
mysql-test/r/multi_update.result
View file @
68cb444c
...
@@ -324,6 +324,7 @@ a b
...
@@ -324,6 +324,7 @@ a b
7 7
7 7
8 8
8 8
9 9
9 9
update t1,t2 set t1.b=t2.b, t1.a=t2.a where t1.a=t2.a and not exists (select * from t2 where t2.a > 10);
drop table t1,t2;
drop table t1,t2;
CREATE TABLE t3 ( KEY1 varchar(50) NOT NULL default '', PARAM_CORR_DISTANCE_RUSH double default NULL, PARAM_CORR_DISTANCE_GEM double default NULL, PARAM_AVG_TARE double default NULL, PARAM_AVG_NB_DAYS double default NULL, PARAM_DEFAULT_PROP_GEM_SRVC varchar(50) default NULL, PARAM_DEFAULT_PROP_GEM_NO_ETIK varchar(50) default NULL, PARAM_SCENARIO_COSTS varchar(50) default NULL, PARAM_DEFAULT_WAGON_COST double default NULL, tmp int(11) default NULL, PRIMARY KEY (KEY1)) ENGINE=MyISAM;
CREATE TABLE t3 ( KEY1 varchar(50) NOT NULL default '', PARAM_CORR_DISTANCE_RUSH double default NULL, PARAM_CORR_DISTANCE_GEM double default NULL, PARAM_AVG_TARE double default NULL, PARAM_AVG_NB_DAYS double default NULL, PARAM_DEFAULT_PROP_GEM_SRVC varchar(50) default NULL, PARAM_DEFAULT_PROP_GEM_NO_ETIK varchar(50) default NULL, PARAM_SCENARIO_COSTS varchar(50) default NULL, PARAM_DEFAULT_WAGON_COST double default NULL, tmp int(11) default NULL, PRIMARY KEY (KEY1)) ENGINE=MyISAM;
INSERT INTO t3 VALUES ('A',1,1,22,3.2,'R','R','BASE2',0.24,NULL);
INSERT INTO t3 VALUES ('A',1,1,22,3.2,'R','R','BASE2',0.24,NULL);
...
...
mysql-test/t/multi_update.test
View file @
68cb444c
...
@@ -260,6 +260,10 @@ update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t2.a=t1
...
@@ -260,6 +260,10 @@ update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t2.a=t1
select
*
from
t1
;
select
*
from
t1
;
select
*
from
t2
;
select
*
from
t2
;
# test for non-updating table which is also used in sub-select
update
t1
,
t2
set
t1
.
b
=
t2
.
b
,
t1
.
a
=
t2
.
a
where
t1
.
a
=
t2
.
a
and
not
exists
(
select
*
from
t2
where
t2
.
a
>
10
);
drop
table
t1
,
t2
;
drop
table
t1
,
t2
;
CREATE
TABLE
t3
(
KEY1
varchar
(
50
)
NOT
NULL
default
''
,
PARAM_CORR_DISTANCE_RUSH
double
default
NULL
,
PARAM_CORR_DISTANCE_GEM
double
default
NULL
,
PARAM_AVG_TARE
double
default
NULL
,
PARAM_AVG_NB_DAYS
double
default
NULL
,
PARAM_DEFAULT_PROP_GEM_SRVC
varchar
(
50
)
default
NULL
,
PARAM_DEFAULT_PROP_GEM_NO_ETIK
varchar
(
50
)
default
NULL
,
PARAM_SCENARIO_COSTS
varchar
(
50
)
default
NULL
,
PARAM_DEFAULT_WAGON_COST
double
default
NULL
,
tmp
int
(
11
)
default
NULL
,
PRIMARY
KEY
(
KEY1
))
ENGINE
=
MyISAM
;
CREATE
TABLE
t3
(
KEY1
varchar
(
50
)
NOT
NULL
default
''
,
PARAM_CORR_DISTANCE_RUSH
double
default
NULL
,
PARAM_CORR_DISTANCE_GEM
double
default
NULL
,
PARAM_AVG_TARE
double
default
NULL
,
PARAM_AVG_NB_DAYS
double
default
NULL
,
PARAM_DEFAULT_PROP_GEM_SRVC
varchar
(
50
)
default
NULL
,
PARAM_DEFAULT_PROP_GEM_NO_ETIK
varchar
(
50
)
default
NULL
,
PARAM_SCENARIO_COSTS
varchar
(
50
)
default
NULL
,
PARAM_DEFAULT_WAGON_COST
double
default
NULL
,
tmp
int
(
11
)
default
NULL
,
PRIMARY
KEY
(
KEY1
))
ENGINE
=
MyISAM
;
INSERT
INTO
t3
VALUES
(
'A'
,
1
,
1
,
22
,
3.2
,
'R'
,
'R'
,
'BASE2'
,
0.24
,
NULL
);
INSERT
INTO
t3
VALUES
(
'A'
,
1
,
1
,
22
,
3.2
,
'R'
,
'R'
,
'BASE2'
,
0.24
,
NULL
);
...
...
sql/sql_update.cc
View file @
68cb444c
...
@@ -578,7 +578,7 @@ multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list,
...
@@ -578,7 +578,7 @@ multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list,
int
multi_update
::
prepare
(
List
<
Item
>
&
not_used_values
,
int
multi_update
::
prepare
(
List
<
Item
>
&
not_used_values
,
SELECT_LEX_UNIT
*
lex_unit
)
SELECT_LEX_UNIT
*
lex_unit
)
{
{
TABLE_LIST
*
table_ref
;
TABLE_LIST
*
table_ref
,
*
tables
;
SQL_LIST
update
;
SQL_LIST
update
;
table_map
tables_to_update
=
0
;
table_map
tables_to_update
=
0
;
Item_field
*
item
;
Item_field
*
item
;
...
@@ -604,8 +604,9 @@ int multi_update::prepare(List<Item> ¬_used_values,
...
@@ -604,8 +604,9 @@ int multi_update::prepare(List<Item> ¬_used_values,
We have to check values after setup_tables to get used_keys right in
We have to check values after setup_tables to get used_keys right in
reference tables
reference tables
*/
*/
tables
=
thd
->
lex
->
select_lex
.
get_table_list
();
if
(
setup_fields
(
thd
,
0
,
all_
tables
,
*
values
,
1
,
0
,
0
))
if
(
setup_fields
(
thd
,
0
,
tables
,
*
values
,
1
,
0
,
0
))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
/*
/*
...
@@ -615,7 +616,7 @@ int multi_update::prepare(List<Item> ¬_used_values,
...
@@ -615,7 +616,7 @@ int multi_update::prepare(List<Item> ¬_used_values,
*/
*/
update
.
empty
();
update
.
empty
();
for
(
table_ref
=
all_
tables
;
table_ref
;
table_ref
=
table_ref
->
next
)
for
(
table_ref
=
tables
;
table_ref
;
table_ref
=
table_ref
->
next
)
{
{
TABLE
*
table
=
table_ref
->
table
;
TABLE
*
table
=
table_ref
->
table
;
if
(
tables_to_update
&
table
->
map
)
if
(
tables_to_update
&
table
->
map
)
...
@@ -684,10 +685,10 @@ int multi_update::prepare(List<Item> ¬_used_values,
...
@@ -684,10 +685,10 @@ int multi_update::prepare(List<Item> ¬_used_values,
which will cause an error when reading a row.
which will cause an error when reading a row.
(This issue is mostly relevent for MyISAM tables)
(This issue is mostly relevent for MyISAM tables)
*/
*/
for
(
table_ref
=
all_
tables
;
table_ref
;
table_ref
=
table_ref
->
next
)
for
(
table_ref
=
tables
;
table_ref
;
table_ref
=
table_ref
->
next
)
{
{
TABLE
*
table
=
table_ref
->
table
;
TABLE
*
table
=
table_ref
->
table
;
if
(
!
(
tables_to_update
&
table
->
map
)
&&
if
(
!
(
tables_to_update
&
table
->
map
)
||
!
table
->
no_keyread
&&
find_real_table_in_list
(
update_tables
,
table_ref
->
db
,
find_real_table_in_list
(
update_tables
,
table_ref
->
db
,
table_ref
->
real_name
))
table_ref
->
real_name
))
table
->
no_cache
=
1
;
// Disable row cache
table
->
no_cache
=
1
;
// Disable row cache
...
...
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