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
44ef4989
Commit
44ef4989
authored
Dec 27, 2005
by
ingo@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/home/mydev/mysql-4.1
into mysql.com:/home/mydev/mysql-4.1-bug5390
parents
7b049bf2
693625ea
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
169 additions
and
32 deletions
+169
-32
libmysqld/ha_blackhole.cc
libmysqld/ha_blackhole.cc
+0
-0
mysql-test/r/create.result
mysql-test/r/create.result
+0
-15
mysql-test/r/merge.result
mysql-test/r/merge.result
+49
-0
mysql-test/t/create.test
mysql-test/t/create.test
+0
-7
mysql-test/t/merge.test
mysql-test/t/merge.test
+26
-0
sql/lock.cc
sql/lock.cc
+86
-3
sql/mysql_priv.h
sql/mysql_priv.h
+1
-0
sql/sql_parse.cc
sql/sql_parse.cc
+6
-5
sql/sql_update.cc
sql/sql_update.cc
+1
-2
No files found.
libmysqld/ha_blackhole.cc
0 → 100755
View file @
44ef4989
mysql-test/r/create.result
View file @
44ef4989
...
...
@@ -247,21 +247,6 @@ select * from t1;
0 1 2
0 0 1
drop table t1;
create table t1 select 1,2,3;
create table if not exists t1 select 1,2;
Warnings:
Note 1050 Table 't1' already exists
create table if not exists t1 select 1,2,3,4;
ERROR 21S01: Column count doesn't match value count at row 1
create table if not exists t1 select 1;
Warnings:
Note 1050 Table 't1' already exists
select * from t1;
1 2 3
1 2 3
0 1 2
0 0 1
drop table t1;
create table t1 (a int not null, b int, primary key (a));
insert into t1 values (1,1);
create table if not exists t1 select 2;
...
...
mysql-test/r/merge.result
View file @
44ef4989
...
...
@@ -717,3 +717,52 @@ SELECT b FROM t2;
b
3
DROP TABLE t1, t2;
create table t1(a int);
create table t2(a int);
insert into t1 values (1);
insert into t2 values (2);
create table t3 (a int) engine=merge union=(t1, t2) insert_method=first;
select * from t3;
a
1
2
insert t2 select * from t2;
select * from t2;
a
2
2
insert t3 select * from t1;
select * from t3;
a
1
1
2
2
insert t1 select * from t3;
select * from t1;
a
1
1
1
1
2
2
select * from t2;
a
2
2
select * from t3;
a
1
1
1
1
2
2
2
2
check table t1, t2;
Table Op Msg_type Msg_text
test.t1 check status OK
test.t2 check status OK
drop table t1, t2, t3;
mysql-test/t/create.test
View file @
44ef4989
...
...
@@ -200,13 +200,6 @@ drop table t1;
# bug #1434
#
create
table
t1
select
1
,
2
,
3
;
create
table
if
not
exists
t1
select
1
,
2
;
--
error
1136
create
table
if
not
exists
t1
select
1
,
2
,
3
,
4
;
create
table
if
not
exists
t1
select
1
;
select
*
from
t1
;
drop
table
t1
;
create
table
t1
select
1
,
2
,
3
;
create
table
if
not
exists
t1
select
1
,
2
;
--
error
1136
...
...
mysql-test/t/merge.test
View file @
44ef4989
...
...
@@ -350,4 +350,30 @@ INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=3;
SELECT
b
FROM
t2
;
DROP
TABLE
t1
,
t2
;
#
# BUG#5390 - problems with merge tables
# Problem #1: INSERT...SELECT
#
#drop table if exists t1, t2, t3;
create
table
t1
(
a
int
);
create
table
t2
(
a
int
);
insert
into
t1
values
(
1
);
insert
into
t2
values
(
2
);
create
table
t3
(
a
int
)
engine
=
merge
union
=
(
t1
,
t2
)
insert_method
=
first
;
select
*
from
t3
;
#
insert
t2
select
*
from
t2
;
select
*
from
t2
;
#
insert
t3
select
*
from
t1
;
select
*
from
t3
;
#
insert
t1
select
*
from
t3
;
select
*
from
t1
;
select
*
from
t2
;
select
*
from
t3
;
check
table
t1
,
t2
;
drop
table
t1
,
t2
,
t3
;
# End of 4.1 tests
sql/lock.cc
View file @
44ef4989
...
...
@@ -394,6 +394,88 @@ MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b)
}
/*
Find duplicate lock in tables.
SYNOPSIS
mysql_lock_have_duplicate()
thd The current thread.
table The table to check for duplicate lock.
tables The list of tables to search for the dup lock.
NOTE
This is mainly meant for MERGE tables in INSERT ... SELECT
situations. The 'real', underlying tables can be found only after
the table is opened. The easier way is to check this after the
tables are locked.
RETURN
1 A table from 'tables' matches a lock on 'table'.
0 No duplicate lock is present.
-1 Error.
*/
int
mysql_lock_have_duplicate
(
THD
*
thd
,
TABLE
*
table
,
TABLE_LIST
*
tables
)
{
uint
count
;
MYSQL_LOCK
*
sql_lock1
;
MYSQL_LOCK
*
sql_lock2
;
TABLE
**
tables1
=
&
table
;
TABLE
**
tables2
;
TABLE
**
table_ptr
;
TABLE_LIST
*
tablist2
;
TABLE
*
write_lock_used
;
THR_LOCK_DATA
**
lock_data1
;
THR_LOCK_DATA
**
end_data1
;
THR_LOCK_DATA
**
lock_data2
;
THR_LOCK_DATA
**
end_data2
;
THR_LOCK
*
lock1
;
DBUG_ENTER
(
"mysql_lock_have_duplicate"
);
if
(
!
(
sql_lock1
=
get_lock_data
(
thd
,
tables1
,
1
,
1
,
&
write_lock_used
)))
goto
err0
;
count
=
0
;
for
(
tablist2
=
tables
;
tablist2
;
tablist2
=
tablist2
->
next
)
count
++
;
if
(
!
(
tables2
=
(
TABLE
**
)
sql_alloc
(
sizeof
(
TABLE
*
)
*
count
)))
goto
err1
;
table_ptr
=
tables2
;
for
(
tablist2
=
tables
;
tablist2
;
tablist2
=
tablist2
->
next
)
*
(
table_ptr
++
)
=
tablist2
->
table
;
if
(
!
(
sql_lock2
=
get_lock_data
(
thd
,
tables2
,
count
,
1
,
&
write_lock_used
)))
goto
err1
;
count
=
1
;
for
(
lock_data1
=
sql_lock1
->
locks
,
end_data1
=
lock_data1
+
sql_lock1
->
lock_count
;
lock_data1
<
end_data1
;
lock_data1
++
)
{
lock1
=
(
*
lock_data1
)
->
lock
;
for
(
lock_data2
=
sql_lock2
->
locks
,
end_data2
=
lock_data2
+
sql_lock2
->
lock_count
;
lock_data2
<
end_data2
;
lock_data2
++
)
{
if
((
*
lock_data2
)
->
lock
==
lock1
)
goto
end
;
}
}
count
=
0
;
end:
my_free
((
gptr
)
sql_lock2
,
MYF
(
0
));
my_free
((
gptr
)
sql_lock1
,
MYF
(
0
));
DBUG_RETURN
(
count
);
err1:
my_free
((
gptr
)
sql_lock1
,
MYF
(
0
));
err0:
DBUG_RETURN
(
-
1
);
}
/* unlock a set of external */
static
int
unlock_external
(
THD
*
thd
,
TABLE
**
table
,
uint
count
)
...
...
@@ -430,6 +512,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
MYSQL_LOCK
*
sql_lock
;
THR_LOCK_DATA
**
locks
;
TABLE
**
to
;
DBUG_ENTER
(
"get_lock_data"
);
*
write_lock_used
=
0
;
for
(
i
=
tables
=
lock_count
=
0
;
i
<
count
;
i
++
)
...
...
@@ -445,7 +528,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
my_malloc
(
sizeof
(
*
sql_lock
)
+
sizeof
(
THR_LOCK_DATA
*
)
*
tables
+
sizeof
(
table_ptr
)
*
lock_count
,
MYF
(
0
))))
return
0
;
DBUG_RETURN
(
0
)
;
locks
=
sql_lock
->
locks
=
(
THR_LOCK_DATA
**
)
(
sql_lock
+
1
);
to
=
sql_lock
->
table
=
(
TABLE
**
)
(
locks
+
tables
);
sql_lock
->
table_count
=
lock_count
;
...
...
@@ -465,7 +548,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
{
my_error
(
ER_OPEN_AS_READONLY
,
MYF
(
0
),
table
->
table_name
);
my_free
((
gptr
)
sql_lock
,
MYF
(
0
));
return
0
;
DBUG_RETURN
(
0
)
;
}
}
THR_LOCK_DATA
**
org_locks
=
locks
;
...
...
@@ -475,7 +558,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
for
(
;
org_locks
!=
locks
;
org_locks
++
)
(
*
org_locks
)
->
debug_print_param
=
(
void
*
)
table
;
}
return
sql_lock
;
DBUG_RETURN
(
sql_lock
)
;
}
...
...
sql/mysql_priv.h
View file @
44ef4989
...
...
@@ -1022,6 +1022,7 @@ void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table);
void
mysql_lock_abort
(
THD
*
thd
,
TABLE
*
table
);
bool
mysql_lock_abort_for_thread
(
THD
*
thd
,
TABLE
*
table
);
MYSQL_LOCK
*
mysql_lock_merge
(
MYSQL_LOCK
*
a
,
MYSQL_LOCK
*
b
);
int
mysql_lock_have_duplicate
(
THD
*
thd
,
TABLE
*
table
,
TABLE_LIST
*
tables
);
bool
lock_global_read_lock
(
THD
*
thd
);
void
unlock_global_read_lock
(
THD
*
thd
);
bool
wait_if_global_read_lock
(
THD
*
thd
,
bool
abort_on_refresh
,
bool
is_not_commit
);
...
...
sql/sql_parse.cc
View file @
44ef4989
...
...
@@ -2897,16 +2897,17 @@ unsent_create_error:
if
(
unit
->
select_limit_cnt
<
select_lex
->
select_limit
)
unit
->
select_limit_cnt
=
HA_POS_ERROR
;
// No limit
if
(
find_real_table_in_list
(
tables
->
next
,
tables
->
db
,
tables
->
real_name
))
if
((
res
=
open_and_lock_tables
(
thd
,
tables
)))
break
;
insert_table
=
tables
->
table
;
/* MERGE sub-tables can only be detected after open. */
if
(
mysql_lock_have_duplicate
(
thd
,
insert_table
,
tables
->
next
))
{
/* Using same table for INSERT and SELECT */
select_lex
->
options
|=
OPTION_BUFFER_RESULT
;
}
if
((
res
=
open_and_lock_tables
(
thd
,
tables
)))
break
;
insert_table
=
tables
->
table
;
/* Skip first table, which is the table we are inserting in */
select_lex
->
table_list
.
first
=
(
byte
*
)
first_local_table
->
next
;
tables
=
(
TABLE_LIST
*
)
select_lex
->
table_list
.
first
;
...
...
sql/sql_update.cc
View file @
44ef4989
...
...
@@ -854,8 +854,7 @@ int multi_update::prepare(List<Item> ¬_used_values,
{
TABLE
*
table
=
table_ref
->
table
;
if
(
!
(
tables_to_update
&
table
->
map
)
&&
find_real_table_in_list
(
update_tables
,
table_ref
->
db
,
table_ref
->
real_name
))
mysql_lock_have_duplicate
(
thd
,
table
,
update_tables
))
table
->
no_cache
=
1
;
// Disable row cache
}
DBUG_RETURN
(
thd
->
is_fatal_error
!=
0
);
...
...
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