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
3b5bc194
Commit
3b5bc194
authored
Oct 20, 2009
by
Evgeny Potemkin
Browse files
Options
Browse Files
Download
Plain Diff
Auto-merged fix for the bug#41760.
parents
b1f765a9
c4cf9fc0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
21 deletions
+43
-21
mysql-test/r/delayed.result
mysql-test/r/delayed.result
+1
-1
mysql-test/r/insert.result
mysql-test/r/insert.result
+2
-2
mysql-test/t/delayed.test
mysql-test/t/delayed.test
+1
-1
mysql-test/t/insert.test
mysql-test/t/insert.test
+2
-0
sql/sql_insert.cc
sql/sql_insert.cc
+37
-17
No files found.
mysql-test/r/delayed.result
View file @
3b5bc194
...
...
@@ -252,7 +252,7 @@ HEX(a)
DROP TABLE t1;
CREATE TABLE t1 (a INT);
INSERT DELAYED INTO t1 SET b= b();
ERROR 42
S22: Unknown column 'b' in 'field list'
ERROR 42
000: FUNCTION test.b does not exist
DROP TABLE t1;
End of 5.0 tests
DROP TABLE IF EXISTS t1,t2;
...
...
mysql-test/r/insert.result
View file @
3b5bc194
...
...
@@ -355,17 +355,17 @@ insert into t2 values (1,12), (2,24);
insert into v1 (f1) values (3) on duplicate key update f3= f3 + 10;
ERROR HY000: Can not modify more than one base table through a join view 'test.v1'
insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
ERROR HY000: Can not modify more than one base table through a join view 'test.v1'
select * from t1;
f1 f2
1 11
2 22
3 NULL
insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
ERROR HY000: Can not modify more than one base table through a join view 'test.v1'
select * from t1;
f1 f2
1 11
2 22
12 NULL
drop view v1;
drop table t1,t2;
create table t1 (id int primary key auto_increment, data int, unique(data));
...
...
mysql-test/t/delayed.test
View file @
3b5bc194
...
...
@@ -247,7 +247,7 @@ DROP TABLE t1;
# Bug #32676: insert delayed crash with wrong column and function specified
#
CREATE
TABLE
t1
(
a
INT
);
--
error
ER_BAD_FIELD_ERROR
--
error
1305
INSERT
DELAYED
INTO
t1
SET
b
=
b
();
DROP
TABLE
t1
;
...
...
mysql-test/t/insert.test
View file @
3b5bc194
...
...
@@ -235,8 +235,10 @@ insert into t1 values (1,11), (2,22);
insert
into
t2
values
(
1
,
12
),
(
2
,
24
);
--
error
1393
insert
into
v1
(
f1
)
values
(
3
)
on
duplicate
key
update
f3
=
f3
+
10
;
--
error
1393
insert
into
v1
(
f1
)
values
(
3
)
on
duplicate
key
update
f1
=
f3
+
10
;
select
*
from
t1
;
--
error
1393
insert
into
v1
(
f1
)
values
(
3
)
on
duplicate
key
update
f1
=
f3
+
10
;
select
*
from
t1
;
drop
view
v1
;
...
...
sql/sql_insert.cc
View file @
3b5bc194
...
...
@@ -107,8 +107,8 @@ static bool check_view_insertability(THD *thd, TABLE_LIST *view);
1 Error
*/
bool
check_view_single_update
(
List
<
Item
>
&
fields
,
TABLE_LIST
*
view
,
table_map
*
map
)
bool
check_view_single_update
(
List
<
Item
>
&
fields
,
List
<
Item
>
*
values
,
TABLE_LIST
*
view
,
table_map
*
map
)
{
/* it is join view => we need to find the table for update */
List_iterator_fast
<
Item
>
it
(
fields
);
...
...
@@ -119,6 +119,17 @@ bool check_view_single_update(List<Item> &fields, TABLE_LIST *view,
while
((
item
=
it
++
))
tables
|=
item
->
used_tables
();
if
(
values
)
{
it
.
init
(
*
values
);
while
((
item
=
it
++
))
tables
|=
item
->
used_tables
();
}
/* Convert to real table bits */
tables
&=
~
PSEUDO_TABLE_BITS
;
/* Check found map against provided map */
if
(
*
map
)
{
...
...
@@ -165,7 +176,9 @@ bool check_view_single_update(List<Item> &fields, TABLE_LIST *view,
static
int
check_insert_fields
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
List
<
Item
>
&
fields
,
List
<
Item
>
&
values
,
bool
check_unique
,
table_map
*
map
)
bool
check_unique
,
bool
fields_and_values_from_different_maps
,
table_map
*
map
)
{
TABLE
*
table
=
table_list
->
table
;
...
...
@@ -238,7 +251,10 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
if
(
table_list
->
effective_algorithm
==
VIEW_ALGORITHM_MERGE
)
{
if
(
check_view_single_update
(
fields
,
table_list
,
map
))
if
(
check_view_single_update
(
fields
,
fields_and_values_from_different_maps
?
(
List
<
Item
>*
)
0
:
&
values
,
table_list
,
map
))
return
-
1
;
table
=
table_list
->
table
;
}
...
...
@@ -298,7 +314,8 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
*/
static
int
check_update_fields
(
THD
*
thd
,
TABLE_LIST
*
insert_table_list
,
List
<
Item
>
&
update_fields
,
table_map
*
map
)
List
<
Item
>
&
update_fields
,
List
<
Item
>
&
update_values
,
table_map
*
map
)
{
TABLE
*
table
=
insert_table_list
->
table
;
my_bool
timestamp_mark
=
0
;
...
...
@@ -318,7 +335,8 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
return
-
1
;
if
(
insert_table_list
->
effective_algorithm
==
VIEW_ALGORITHM_MERGE
&&
check_view_single_update
(
update_fields
,
insert_table_list
,
map
))
check_view_single_update
(
update_fields
,
&
update_values
,
insert_table_list
,
map
))
return
-
1
;
if
(
table
->
timestamp_field
)
...
...
@@ -1242,9 +1260,9 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
table_list
->
next_local
=
0
;
context
->
resolve_in_table_list_only
(
table_list
);
res
=
check_insert_fields
(
thd
,
context
->
table_list
,
fields
,
*
values
,
!
insert_into_view
,
&
map
)
||
setup_fields
(
thd
,
0
,
*
values
,
MARK_COLUMNS_READ
,
0
,
0
);
res
=
(
setup_fields
(
thd
,
0
,
*
values
,
MARK_COLUMNS_READ
,
0
,
0
)
||
check_insert_fields
(
thd
,
context
->
table_list
,
fields
,
*
values
,
!
insert_into_view
,
0
,
&
map
)
);
if
(
!
res
&&
check_fields
)
{
...
...
@@ -1257,18 +1275,19 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
thd
->
abort_on_warning
=
saved_abort_on_warning
;
}
if
(
!
res
)
res
=
setup_fields
(
thd
,
0
,
update_values
,
MARK_COLUMNS_READ
,
0
,
0
);
if
(
!
res
&&
duplic
==
DUP_UPDATE
)
{
select_lex
->
no_wrap_view_item
=
TRUE
;
res
=
check_update_fields
(
thd
,
context
->
table_list
,
update_fields
,
&
map
);
res
=
check_update_fields
(
thd
,
context
->
table_list
,
update_fields
,
update_values
,
&
map
);
select_lex
->
no_wrap_view_item
=
FALSE
;
}
/* Restore the current context. */
ctx_state
.
restore_state
(
context
,
table_list
);
if
(
!
res
)
res
=
setup_fields
(
thd
,
0
,
update_values
,
MARK_COLUMNS_READ
,
0
,
0
);
}
if
(
res
)
...
...
@@ -2931,9 +2950,9 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
we are fixing fields from insert list.
*/
lex
->
current_select
=
&
lex
->
select_lex
;
res
=
check_insert_fields
(
thd
,
table_list
,
*
fields
,
values
,
!
insert_into_view
,
&
map
)
||
setup_fields
(
thd
,
0
,
values
,
MARK_COLUMNS_READ
,
0
,
0
);
res
=
(
setup_fields
(
thd
,
0
,
values
,
MARK_COLUMNS_READ
,
0
,
0
)
||
check_insert_fields
(
thd
,
table_list
,
*
fields
,
values
,
!
insert_into_view
,
1
,
&
map
)
);
if
(
!
res
&&
fields
->
elements
)
{
...
...
@@ -2960,7 +2979,8 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
lex
->
select_lex
.
no_wrap_view_item
=
TRUE
;
res
=
res
||
check_update_fields
(
thd
,
context
->
table_list
,
*
info
.
update_fields
,
&
map
);
*
info
.
update_fields
,
*
info
.
update_values
,
&
map
);
lex
->
select_lex
.
no_wrap_view_item
=
FALSE
;
/*
When we are not using GROUP BY and there are no ungrouped aggregate functions
...
...
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