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
1b39262a
Commit
1b39262a
authored
20 years ago
by
joerg@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/M40/mysql-4.0 into mysql.com:/M40/push-4.0
parents
b7f35f00
91e8afac
No related merge requests found
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
169 additions
and
34 deletions
+169
-34
include/config-win.h
include/config-win.h
+7
-1
include/my_global.h
include/my_global.h
+7
-1
mysql-test/r/lock_multi.result
mysql-test/r/lock_multi.result
+12
-0
mysql-test/r/multi_update.result
mysql-test/r/multi_update.result
+0
-1
mysql-test/t/lock_multi.test
mysql-test/t/lock_multi.test
+24
-0
mysql-test/t/multi_update.test
mysql-test/t/multi_update.test
+0
-2
sql/records.cc
sql/records.cc
+2
-1
sql/sql_parse.cc
sql/sql_parse.cc
+17
-12
sql/sql_update.cc
sql/sql_update.cc
+90
-14
sql/sql_yacc.yy
sql/sql_yacc.yy
+10
-2
No files found.
include/config-win.h
View file @
1b39262a
...
@@ -218,7 +218,13 @@ inline double ulonglong2double(ulonglong value)
...
@@ -218,7 +218,13 @@ inline double ulonglong2double(ulonglong value)
((uint32) (uchar) (A)[0])))
((uint32) (uchar) (A)[0])))
#define sint4korr(A) (*((long *) (A)))
#define sint4korr(A) (*((long *) (A)))
#define uint2korr(A) (*((uint16 *) (A)))
#define uint2korr(A) (*((uint16 *) (A)))
#define uint3korr(A) (long) (*((unsigned long *) (A)) & 0xFFFFFF)
/*
ATTENTION !
Please, note, uint3korr reads 4 bytes (not 3) !
It means, that you have to provide enough allocated space !
*/
#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF)
#define uint4korr(A) (*((unsigned long *) (A)))
#define uint4korr(A) (*((unsigned long *) (A)))
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[1])) << 8) +\
...
...
This diff is collapsed.
Click to expand it.
include/my_global.h
View file @
1b39262a
...
@@ -898,7 +898,13 @@ typedef char bool; /* Ordinary boolean values 0 1 */
...
@@ -898,7 +898,13 @@ typedef char bool; /* Ordinary boolean values 0 1 */
(((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16))
(((uint32) ((uchar) (A)[2])) << 16))
#else
#else
#define uint3korr(A) (long) (*((unsigned long *) (A)) & 0xFFFFFF)
/*
ATTENTION !
Please, note, uint3korr reads 4 bytes (not 3) !
It means, that you have to provide enough allocated space !
*/
#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF)
#endif
#endif
#define uint4korr(A) (*((unsigned long *) (A)))
#define uint4korr(A) (*((unsigned long *) (A)))
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
...
...
This diff is collapsed.
Click to expand it.
mysql-test/r/lock_multi.result
View file @
1b39262a
...
@@ -17,6 +17,18 @@ unlock tables;
...
@@ -17,6 +17,18 @@ unlock tables;
n
n
1
1
drop table t1;
drop table t1;
create table t1 (a int, b int);
create table t2 (c int, d int);
insert into t1 values(1,1);
insert into t1 values(2,2);
insert into t2 values(1,2);
lock table t1 read;
update t1,t2 set c=a where b=d;
select c from t2;
c
2
drop table t1;
drop table t2;
create table t1 (a int);
create table t1 (a int);
create table t2 (a int);
create table t2 (a int);
lock table t1 write, t2 write;
lock table t1 write, t2 write;
...
...
This diff is collapsed.
Click to expand it.
mysql-test/r/multi_update.result
View file @
1b39262a
...
@@ -151,7 +151,6 @@ Table 't2' was locked with a READ lock and can't be updated
...
@@ -151,7 +151,6 @@ Table 't2' was locked with a READ lock and can't be updated
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
Table 't2' was locked with a READ lock and can't be updated
Table 't2' was locked with a READ lock and can't be updated
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
Table 't2' was locked with a READ lock and can't be updated
unlock tables;
unlock tables;
LOCK TABLES t1 write, t2 write;
LOCK TABLES t1 write, t2 write;
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
...
...
This diff is collapsed.
Click to expand it.
mysql-test/t/lock_multi.test
View file @
1b39262a
...
@@ -50,6 +50,30 @@ connection reader;
...
@@ -50,6 +50,30 @@ connection reader;
reap
;
reap
;
drop
table
t1
;
drop
table
t1
;
#
# Test problem when using locks with multi-updates
# It should not block when multi-update is reading on a read-locked table
#
connection
locker
;
create
table
t1
(
a
int
,
b
int
);
create
table
t2
(
c
int
,
d
int
);
insert
into
t1
values
(
1
,
1
);
insert
into
t1
values
(
2
,
2
);
insert
into
t2
values
(
1
,
2
);
lock
table
t1
read
;
connection
writer
;
--
sleep
2
send
update
t1
,
t2
set
c
=
a
where
b
=
d
;
connection
reader
;
--
sleep
2
select
c
from
t2
;
connection
writer
;
reap
;
connection
locker
;
drop
table
t1
;
drop
table
t2
;
#
#
# Test problem when using locks on many tables and droping a table that
# Test problem when using locks on many tables and droping a table that
# is to-be-locked by another thread
# is to-be-locked by another thread
...
...
This diff is collapsed.
Click to expand it.
mysql-test/t/multi_update.test
View file @
1b39262a
...
@@ -151,8 +151,6 @@ LOCK TABLES t1 write, t2 read;
...
@@ -151,8 +151,6 @@ LOCK TABLES t1 write, t2 read;
DELETE
t1
.*
,
t2
.*
FROM
t1
,
t2
where
t1
.
n
=
t2
.
n
;
DELETE
t1
.*
,
t2
.*
FROM
t1
,
t2
where
t1
.
n
=
t2
.
n
;
--
error
1099
--
error
1099
UPDATE
t1
,
t2
SET
t1
.
d
=
t2
.
d
,
t2
.
d
=
30
WHERE
t1
.
n
=
t2
.
n
;
UPDATE
t1
,
t2
SET
t1
.
d
=
t2
.
d
,
t2
.
d
=
30
WHERE
t1
.
n
=
t2
.
n
;
# The following should be fixed to not give an error
--
error
1099
UPDATE
t1
,
t2
SET
t1
.
d
=
t2
.
d
WHERE
t1
.
n
=
t2
.
n
;
UPDATE
t1
,
t2
SET
t1
.
d
=
t2
.
d
WHERE
t1
.
n
=
t2
.
n
;
unlock
tables
;
unlock
tables
;
LOCK
TABLES
t1
write
,
t2
write
;
LOCK
TABLES
t1
write
,
t2
write
;
...
...
This diff is collapsed.
Click to expand it.
sql/records.cc
View file @
1b39262a
...
@@ -249,9 +249,10 @@ static int init_rr_cache(READ_RECORD *info)
...
@@ -249,9 +249,10 @@ static int init_rr_cache(READ_RECORD *info)
rec_cache_size
=
info
->
cache_records
*
info
->
reclength
;
rec_cache_size
=
info
->
cache_records
*
info
->
reclength
;
info
->
rec_cache_size
=
info
->
cache_records
*
info
->
ref_length
;
info
->
rec_cache_size
=
info
->
cache_records
*
info
->
ref_length
;
// We have to allocate one more byte to use uint3korr (see comments for it)
if
(
info
->
cache_records
<=
2
||
if
(
info
->
cache_records
<=
2
||
!
(
info
->
cache
=
(
byte
*
)
my_malloc_lock
(
rec_cache_size
+
info
->
cache_records
*
!
(
info
->
cache
=
(
byte
*
)
my_malloc_lock
(
rec_cache_size
+
info
->
cache_records
*
info
->
struct_length
,
info
->
struct_length
+
1
,
MYF
(
0
))))
MYF
(
0
))))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
#ifdef HAVE_purify
#ifdef HAVE_purify
...
...
This diff is collapsed.
Click to expand it.
sql/sql_parse.cc
View file @
1b39262a
...
@@ -1927,21 +1927,26 @@ mysql_execute_command(void)
...
@@ -1927,21 +1927,26 @@ mysql_execute_command(void)
send_error
(
&
thd
->
net
,
ER_WRONG_VALUE_COUNT
);
send_error
(
&
thd
->
net
,
ER_WRONG_VALUE_COUNT
);
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
if
(
select_lex
->
table_list
.
elements
==
1
)
if
(
check_one_table_access
(
thd
,
UPDATE_ACL
,
tables
,
0
))
{
goto
error
;
/* purecov: inspected */
if
(
check_one_table_access
(
thd
,
UPDATE_ACL
,
tables
,
0
))
goto
error
;
/* purecov: inspected */
res
=
mysql_update
(
thd
,
tables
,
res
=
mysql_update
(
thd
,
tables
,
select_lex
->
item_list
,
select_lex
->
item_list
,
lex
->
value_list
,
lex
->
value_list
,
select_lex
->
where
,
select_lex
->
where
,
(
ORDER
*
)
select_lex
->
order_list
.
first
,
(
ORDER
*
)
select_lex
->
order_list
.
first
,
select_lex
->
select_limit
,
select_lex
->
select_limit
,
lex
->
duplicates
);
lex
->
duplicates
);
break
;
case
SQLCOM_MULTI_UPDATE
:
if
(
check_db_used
(
thd
,
tables
))
goto
error
;
if
(
select_lex
->
item_list
.
elements
!=
lex
->
value_list
.
elements
)
{
send_error
(
&
thd
->
net
,
ER_WRONG_VALUE_COUNT
);
DBUG_VOID_RETURN
;
}
}
else
{
{
const
char
*
msg
=
0
;
const
char
*
msg
=
0
;
TABLE_LIST
*
table
;
TABLE_LIST
*
table
;
...
...
This diff is collapsed.
Click to expand it.
sql/sql_update.cc
View file @
1b39262a
...
@@ -401,25 +401,101 @@ int mysql_multi_update(THD *thd,
...
@@ -401,25 +401,101 @@ int mysql_multi_update(THD *thd,
int
res
;
int
res
;
multi_update
*
result
;
multi_update
*
result
;
TABLE_LIST
*
tl
;
TABLE_LIST
*
tl
;
const
bool
locked
=
!
(
thd
->
locked_tables
);
DBUG_ENTER
(
"mysql_multi_update"
);
DBUG_ENTER
(
"mysql_multi_update"
);
if
((
res
=
open_and_lock_tables
(
thd
,
table_list
)))
for
(;;)
DBUG_RETURN
(
res
);
{
table_map
update_map
=
0
;
int
tnr
=
0
;
if
((
res
=
open_tables
(
thd
,
table_list
)))
DBUG_RETURN
(
res
);
thd
->
select_limit
=
HA_POS_ERROR
;
/*
Only need to call lock_tables if (thd->locked_tables == NULL)
*/
if
(
locked
&&
((
res
=
lock_tables
(
thd
,
table_list
))))
DBUG_RETURN
(
res
);
/*
thd
->
select_limit
=
HA_POS_ERROR
;
Ensure that we have update privilege for all tables and columns in the
SET part
*/
for
(
tl
=
table_list
;
tl
;
tl
=
tl
->
next
)
{
TABLE
*
table
=
tl
->
table
;
table
->
grant
.
want_privilege
=
(
UPDATE_ACL
&
~
table
->
grant
.
privilege
);
}
if
(
setup_fields
(
thd
,
table_list
,
*
fields
,
1
,
0
,
0
))
/*
DBUG_RETURN
(
-
1
);
Ensure that we have update privilege for all tables and columns in the
SET part
While we are here, initialize the table->map field.
*/
for
(
tl
=
table_list
;
tl
;
tl
=
tl
->
next
)
{
TABLE
*
table
=
tl
->
table
;
table
->
grant
.
want_privilege
=
(
UPDATE_ACL
&
~
table
->
grant
.
privilege
);
table
->
map
=
(
table_map
)
1
<<
(
tnr
++
);
}
if
(
!
setup_fields
(
thd
,
table_list
,
*
fields
,
1
,
0
,
0
))
{
List_iterator_fast
<
Item
>
field_it
(
*
fields
);
Item_field
*
item
;
while
((
item
=
(
Item_field
*
)
field_it
++
))
update_map
|=
item
->
used_tables
();
DBUG_PRINT
(
"info"
,(
"update_map=0x%08x"
,
update_map
));
}
else
DBUG_RETURN
(
-
1
);
/*
Unlock the tables in preparation for relocking
*/
if
(
locked
)
{
pthread_mutex_lock
(
&
LOCK_open
);
mysql_unlock_tables
(
thd
,
thd
->
lock
);
thd
->
lock
=
0
;
pthread_mutex_unlock
(
&
LOCK_open
);
}
/*
Set the table locking strategy according to the update map
*/
for
(
tl
=
table_list
;
tl
;
tl
=
tl
->
next
)
{
TABLE
*
table
=
tl
->
table
;
if
(
update_map
&
table
->
map
)
{
DBUG_PRINT
(
"info"
,(
"setting table `%s` for update"
,
tl
->
alias
));
tl
->
lock_type
=
thd
->
lex
.
lock_option
;
tl
->
updating
=
1
;
}
else
{
DBUG_PRINT
(
"info"
,(
"setting table `%s` for read-only"
,
tl
->
alias
));
tl
->
lock_type
=
TL_READ
;
tl
->
updating
=
0
;
}
if
(
locked
)
tl
->
table
->
reginfo
.
lock_type
=
tl
->
lock_type
;
}
/*
Relock the tables
*/
if
(
!
(
res
=
lock_tables
(
thd
,
table_list
)))
break
;
if
(
!
locked
)
DBUG_RETURN
(
res
);
List_iterator_fast
<
Item
>
field_it
(
*
fields
);
Item_field
*
item
;
while
((
item
=
(
Item_field
*
)
field_it
++
))
/* item->cleanup(); XXX Use this instead in MySQL 4.1+ */
item
->
field
=
item
->
result_field
=
0
;
close_thread_tables
(
thd
);
}
/*
/*
Count tables and setup timestamp handling
Count tables and setup timestamp handling
...
...
This diff is collapsed.
Click to expand it.
sql/sql_yacc.yy
View file @
1b39262a
...
@@ -2751,10 +2751,18 @@ update:
...
@@ -2751,10 +2751,18 @@ update:
lex->select->order_list.next= (byte**) &lex->select->order_list.first;
lex->select->order_list.next= (byte**) &lex->select->order_list.first;
}
}
opt_low_priority opt_ignore join_table_list
opt_low_priority opt_ignore join_table_list
SET update_list
where_clause opt_order_clause delete_limit_clause
SET update_list
{
{
set_lock_for_tables($3);
if (Lex->select->table_list.elements > 1)
{
LEX *lex=Lex;
lex->sql_command= SQLCOM_MULTI_UPDATE;
lex->lock_option= $3;
}
else
set_lock_for_tables($3);
}
}
where_clause opt_order_clause delete_limit_clause {}
;
;
update_list:
update_list:
...
...
This diff is collapsed.
Click to expand it.
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