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
afe5fa0e
Commit
afe5fa0e
authored
Aug 06, 2002
by
Sinisa@sinisa.nasamreza.org
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
3a2f5774
e679540c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
12 deletions
+96
-12
Docs/manual.texi
Docs/manual.texi
+6
-0
mysql-test/r/multi_update.result
mysql-test/r/multi_update.result
+35
-0
mysql-test/t/multi_update.test
mysql-test/t/multi_update.test
+35
-0
sql/sql_update.cc
sql/sql_update.cc
+20
-12
No files found.
Docs/manual.texi
View file @
afe5fa0e
...
@@ -50132,6 +50132,12 @@ each individual 4.0.x release.
...
@@ -50132,6 +50132,12 @@ each individual 4.0.x release.
@itemize @bullet
@itemize @bullet
@item
@item
Fixed bug in multi-table update when updating a table confused do_select
in reading records from a cache
@item
Fixed bug in multi-table update when several fields are referenced
from a single table
@item
Fixed bug in @code{REVOKE} that caused user resources to be randomly set.
Fixed bug in @code{REVOKE} that caused user resources to be randomly set.
@item
@item
Fixed bug in @code{GRANT} for the new @code{CREATE TEMPORARY TABLE} privilege.
Fixed bug in @code{GRANT} for the new @code{CREATE TEMPORARY TABLE} privilege.
mysql-test/r/multi_update.result
View file @
afe5fa0e
...
@@ -100,3 +100,38 @@ id mydate
...
@@ -100,3 +100,38 @@ id mydate
6 2002-06-22 00:00:00
6 2002-06-22 00:00:00
7 2002-07-22 00:00:00
7 2002-07-22 00:00:00
DROP TABLE IF EXISTS a,b,c;
DROP TABLE IF EXISTS a,b,c;
drop table if exists parent, child;
CREATE TABLE IF NOT EXISTS `parent` (
`id` int(11) NOT NULL auto_increment,
`tst` text,
`tst1` text,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
CREATE TABLE IF NOT EXISTS `child` (
`ID` int(11) NOT NULL auto_increment,
`ParId` int(11) default NULL,
`tst` text,
`tst1` text,
PRIMARY KEY (`ID`),
KEY `IX_ParId_child` (`ParId`),
FOREIGN KEY (`ParId`) REFERENCES `test.parent` (`id`)
) TYPE=MyISAM;
INSERT INTO parent(tst,tst1)
VALUES("MySQL","MySQL AB"), ("MSSQL","Microsoft"), ("ORACLE","ORACLE");
INSERT INTO child(ParId)
VALUES(1), (2), (3);
select * from child;
ID ParId tst tst1
1 1 NULL NULL
2 2 NULL NULL
3 3 NULL NULL
UPDATE child, parent
SET child.tst = parent.tst,
child.tst1 = parent.tst1
WHERE child.ParId = parent.Id;
select * from child;
ID ParId tst tst1
1 1 MySQL MySQL AB
2 2 MSSQL Microsoft
3 3 ORACLE ORACLE
drop table parent, child;
mysql-test/t/multi_update.test
View file @
afe5fa0e
...
@@ -105,3 +105,38 @@ where to_days(now())-to_days(c.mydate)>=30
...
@@ -105,3 +105,38 @@ where to_days(now())-to_days(c.mydate)>=30
and
c
.
id
=
a
.
id
and
c
.
id
=
b
.
id
;
and
c
.
id
=
a
.
id
and
c
.
id
=
b
.
id
;
select
*
from
c
;
select
*
from
c
;
DROP
TABLE
IF
EXISTS
a
,
b
,
c
;
DROP
TABLE
IF
EXISTS
a
,
b
,
c
;
drop
table
if
exists
parent
,
child
;
CREATE
TABLE
IF
NOT
EXISTS
`parent`
(
`id`
int
(
11
)
NOT
NULL
auto_increment
,
`tst`
text
,
`tst1`
text
,
PRIMARY
KEY
(
`id`
)
)
TYPE
=
MyISAM
;
CREATE
TABLE
IF
NOT
EXISTS
`child`
(
`ID`
int
(
11
)
NOT
NULL
auto_increment
,
`ParId`
int
(
11
)
default
NULL
,
`tst`
text
,
`tst1`
text
,
PRIMARY
KEY
(
`ID`
),
KEY
`IX_ParId_child`
(
`ParId`
),
FOREIGN
KEY
(
`ParId`
)
REFERENCES
`test.parent`
(
`id`
)
)
TYPE
=
MyISAM
;
INSERT
INTO
parent
(
tst
,
tst1
)
VALUES
(
"MySQL"
,
"MySQL AB"
),
(
"MSSQL"
,
"Microsoft"
),
(
"ORACLE"
,
"ORACLE"
);
INSERT
INTO
child
(
ParId
)
VALUES
(
1
),
(
2
),
(
3
);
select
*
from
child
;
UPDATE
child
,
parent
SET
child
.
tst
=
parent
.
tst
,
child
.
tst1
=
parent
.
tst1
WHERE
child
.
ParId
=
parent
.
Id
;
select
*
from
child
;
drop
table
parent
,
child
;
\ No newline at end of file
sql/sql_update.cc
View file @
afe5fa0e
...
@@ -419,14 +419,19 @@ multi_update::prepare(List<Item> &values)
...
@@ -419,14 +419,19 @@ multi_update::prepare(List<Item> &values)
for
(
table_ref
=
update_tables
;
table_ref
;
for
(
table_ref
=
update_tables
;
table_ref
;
table_ref
=
table_ref
->
next
,
counter
++
)
table_ref
=
table_ref
->
next
,
counter
++
)
{
{
if
(
table_ref
->
table
==
item
->
field
->
table
&&
!
table_ref
->
shared
)
if
(
table_ref
->
table
==
item
->
field
->
table
)
{
{
if
(
!
table_ref
->
shared
)
{
TABLE
*
tbl
=
table_ref
->
table
;
num_updated
++
;
num_updated
++
;
table_ref
->
shared
=
1
;
table_ref
->
shared
=
1
;
if
(
!
not_trans_safe
&&
!
table_ref
->
table
->
file
->
has_transactions
())
if
(
!
not_trans_safe
&&
!
table_ref
->
table
->
file
->
has_transactions
())
not_trans_safe
=
true
;
not_trans_safe
=
true
;
// to be moved if initialize_tables has to be used
// to be moved if initialize_tables has to be used
table_ref
->
table
->
no_keyread
=
1
;
tbl
->
no_keyread
=
1
;
tbl
->
used_keys
=
0
;
}
break
;
break
;
}
}
}
}
...
@@ -440,7 +445,7 @@ multi_update::prepare(List<Item> &values)
...
@@ -440,7 +445,7 @@ multi_update::prepare(List<Item> &values)
}
}
if
(
!
num_updated
)
if
(
!
num_updated
)
{
{
error
=
1
;
// A proper error message is due here
net_printf
(
&
thd
->
net
,
ER_NOT_SUPPORTED_YET
,
"SET CLAUSE MUST CONTAIN TABLE.FIELD REFERENCE"
);
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
...
@@ -498,6 +503,7 @@ multi_update::prepare(List<Item> &values)
...
@@ -498,6 +503,7 @@ multi_update::prepare(List<Item> &values)
counter
++
;
counter
++
;
}
}
}
}
init_ftfuncs
(
thd
,
1
);
error
=
0
;
// Timestamps do not need to be restored, so far ...
error
=
0
;
// Timestamps do not need to be restored, so far ...
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
...
@@ -520,7 +526,7 @@ multi_update::initialize_tables(JOIN *join)
...
@@ -520,7 +526,7 @@ multi_update::initialize_tables(JOIN *join)
{
{
if
(
tab
->
table
->
map
&
tables_to_update_from
)
if
(
tab
->
table
->
map
&
tables_to_update_from
)
{
{
We
are
going
to
update
from
this
table
//
We are going to update from this table
TABLE
*
tbl
=
walk
->
table
=
tab
->
table
;
TABLE
*
tbl
=
walk
->
table
=
tab
->
table
;
/* Don't use KEYREAD optimization on this table */
/* Don't use KEYREAD optimization on this table */
tbl
->
no_keyread
=
1
;
tbl
->
no_keyread
=
1
;
...
@@ -578,6 +584,7 @@ bool multi_update::send_data(List<Item> &values)
...
@@ -578,6 +584,7 @@ bool multi_update::send_data(List<Item> &values)
if
(
/* compare_record(table, query_id) && */
if
(
/* compare_record(table, query_id) && */
!
(
error
=
table
->
file
->
update_row
(
table
->
record
[
1
],
table
->
record
[
0
])))
!
(
error
=
table
->
file
->
update_row
(
table
->
record
[
1
],
table
->
record
[
0
])))
updated
++
;
updated
++
;
table
->
file
->
extra
(
HA_EXTRA_NO_CACHE
);
return
error
;
return
error
;
}
}
}
}
...
@@ -615,7 +622,10 @@ bool multi_update::send_data(List<Item> &values)
...
@@ -615,7 +622,10 @@ bool multi_update::send_data(List<Item> &values)
found
++
;
found
++
;
if
(
/*compare_record(table, query_id) && */
if
(
/*compare_record(table, query_id) && */
!
(
error
=
table
->
file
->
update_row
(
table
->
record
[
1
],
table
->
record
[
0
])))
!
(
error
=
table
->
file
->
update_row
(
table
->
record
[
1
],
table
->
record
[
0
])))
{
updated
++
;
updated
++
;
table
->
file
->
extra
(
HA_EXTRA_NO_CACHE
);
}
else
else
{
{
table
->
file
->
print_error
(
error
,
MYF
(
0
));
table
->
file
->
print_error
(
error
,
MYF
(
0
));
...
@@ -670,7 +680,7 @@ void multi_update::send_error(uint errcode,const char *err)
...
@@ -670,7 +680,7 @@ void multi_update::send_error(uint errcode,const char *err)
if
((
table_being_updated
->
table
->
file
->
has_transactions
()
&&
if
((
table_being_updated
->
table
->
file
->
has_transactions
()
&&
table_being_updated
==
update_tables
)
||
!
not_trans_safe
)
table_being_updated
==
update_tables
)
||
!
not_trans_safe
)
ha_rollback_stmt
(
thd
);
ha_rollback_stmt
(
thd
);
else
if
(
do_update
)
else
if
(
do_update
&&
num_updated
>
1
)
VOID
(
do_updates
(
true
));
VOID
(
do_updates
(
true
));
}
}
...
@@ -679,8 +689,6 @@ int multi_update::do_updates (bool from_send_error)
...
@@ -679,8 +689,6 @@ int multi_update::do_updates (bool from_send_error)
{
{
int
error
=
0
,
counter
=
0
;
int
error
=
0
,
counter
=
0
;
if
(
num_updated
==
1
)
return
0
;
if
(
from_send_error
)
if
(
from_send_error
)
{
{
/* Found out table number for 'table_being_updated' */
/* Found out table number for 'table_being_updated' */
...
...
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