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
3b759050
Commit
3b759050
authored
Mar 16, 2004
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-4.1
into gw.mysql.r18.ru:/usr/home/ram/work/4.1.b2885
parents
20896a31
59dda607
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
16 deletions
+85
-16
client/mysqltest.c
client/mysqltest.c
+10
-4
mysql-test/r/insert_update.result
mysql-test/r/insert_update.result
+38
-0
mysql-test/t/insert_update.test
mysql-test/t/insert_update.test
+22
-0
sql/sql_class.h
sql/sql_class.h
+1
-0
sql/sql_insert.cc
sql/sql_insert.cc
+14
-12
No files found.
client/mysqltest.c
View file @
3b759050
...
...
@@ -2331,11 +2331,17 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
mysql_free_result
(
warn_res
);
}
}
if
(
!
disable_info
&&
mysql_info
(
mysql
)
)
if
(
!
disable_info
)
{
dynstr_append
(
ds
,
"info: "
);
dynstr_append
(
ds
,
mysql_info
(
mysql
));
dynstr_append_mem
(
ds
,
"
\n
"
,
1
);
char
buf
[
40
];
sprintf
(
buf
,
"affected rows: %ld
\n
"
,
mysql_affected_rows
(
mysql
));
dynstr_append
(
ds
,
buf
);
if
(
mysql_info
(
mysql
))
{
dynstr_append
(
ds
,
"info: "
);
dynstr_append
(
ds
,
mysql_info
(
mysql
));
dynstr_append_mem
(
ds
,
"
\n
"
,
1
);
}
}
}
...
...
mysql-test/r/insert_update.result
View file @
3b759050
...
...
@@ -67,3 +67,41 @@ id select_type table type possible_keys key key_len ref rows Extra
Warnings:
Note 1003 select high_priority test.t1.a AS `a`,test.t1.b AS `b`,test.t1.c AS `c` from test.t1
DROP TABLE t1;
create table t1(a int primary key, b int);
insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5);
select * from t1;
a b
1 1
2 2
3 3
4 4
5 5
insert into t1 values(4,14),(5,15),(6,16),(7,17),(8,18)
on duplicate key update b=b+10;
affected rows: 7
info: Records: 5 Duplicates: 2 Warnings: 0
select * from t1;
a b
1 1
2 2
3 3
4 14
5 15
6 16
7 17
8 18
replace into t1 values(5,25),(6,26),(7,27),(8,28),(9,29);
affected rows: 9
info: Records: 5 Duplicates: 4 Warnings: 0
select * from t1;
a b
1 1
2 2
3 3
4 14
5 25
6 26
7 27
8 28
9 29
drop table t1;
mysql-test/t/insert_update.test
View file @
3b759050
...
...
@@ -26,3 +26,25 @@ SELECT *, VALUES(a) FROM t1;
explain
extended
SELECT
*
,
VALUES
(
a
)
FROM
t1
;
explain
extended
select
*
from
t1
where
values
(
a
);
DROP
TABLE
t1
;
#
# test for Bug #2709 "Affected Rows for ON DUPL.KEY undocumented,
# perhaps illogical"
#
create
table
t1
(
a
int
primary
key
,
b
int
);
insert
into
t1
values
(
1
,
1
),(
2
,
2
),(
3
,
3
),(
4
,
4
),(
5
,
5
);
select
*
from
t1
;
enable_info
;
insert
into
t1
values
(
4
,
14
),(
5
,
15
),(
6
,
16
),(
7
,
17
),(
8
,
18
)
on
duplicate
key
update
b
=
b
+
10
;
disable_info
;
select
*
from
t1
;
enable_info
;
replace
into
t1
values
(
5
,
25
),(
6
,
26
),(
7
,
27
),(
8
,
28
),(
9
,
29
);
disable_info
;
select
*
from
t1
;
drop
table
t1
;
sql/sql_class.h
View file @
3b759050
...
...
@@ -194,6 +194,7 @@ class MYSQL_LOG
typedef
struct
st_copy_info
{
ha_rows
records
;
ha_rows
deleted
;
ha_rows
updated
;
ha_rows
copied
;
ha_rows
error_count
;
enum
enum_duplicates
handle_duplicates
;
...
...
sql/sql_insert.cc
View file @
3b759050
...
...
@@ -236,7 +236,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
Fill in the given fields and dump it to the table file
*/
info
.
records
=
info
.
deleted
=
info
.
copied
=
0
;
info
.
records
=
info
.
deleted
=
info
.
copied
=
info
.
updated
=
0
;
info
.
handle_duplicates
=
duplic
;
info
.
update_fields
=&
update_fields
;
info
.
update_values
=&
update_values
;
...
...
@@ -369,13 +369,14 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
For the transactional algorithm to work the invalidation must be
before binlog writing and ha_autocommit_...
*/
if
(
info
.
copied
||
info
.
deleted
)
if
(
info
.
copied
||
info
.
deleted
||
info
.
updated
)
query_cache_invalidate3
(
thd
,
table_list
,
1
);
transactional_table
=
table
->
file
->
has_transactions
();
log_delayed
=
(
transactional_table
||
table
->
tmp_table
);
if
((
info
.
copied
||
info
.
deleted
)
&&
(
error
<=
0
||
!
transactional_table
))
if
((
info
.
copied
||
info
.
deleted
||
info
.
updated
)
&&
(
error
<=
0
||
!
transactional_table
))
{
mysql_update_log
.
write
(
thd
,
thd
->
query
,
thd
->
query_length
);
if
(
mysql_bin_log
.
is_open
())
...
...
@@ -416,7 +417,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
goto
abort
;
if
(
values_list
.
elements
==
1
&&
(
!
(
thd
->
options
&
OPTION_WARNINGS
)
||
!
thd
->
cuted_fields
))
send_ok
(
thd
,
info
.
copied
+
info
.
deleted
,
id
);
send_ok
(
thd
,
info
.
copied
+
info
.
deleted
+
info
.
updated
,
id
);
else
{
char
buff
[
160
];
...
...
@@ -426,8 +427,8 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
(
ulong
)
(
info
.
records
-
info
.
copied
),
(
ulong
)
thd
->
cuted_fields
);
else
sprintf
(
buff
,
ER
(
ER_INSERT_INFO
),
(
ulong
)
info
.
records
,
(
ulong
)
info
.
deleted
,
(
ulong
)
thd
->
cuted_fields
);
::
send_ok
(
thd
,
info
.
copied
+
info
.
deleted
,(
ulonglong
)
id
,
buff
);
(
ulong
)
info
.
deleted
+
info
.
updated
,
(
ulong
)
thd
->
cuted_fields
);
::
send_ok
(
thd
,
info
.
copied
+
info
.
deleted
+
info
.
updated
,(
ulonglong
)
id
,
buff
);
}
free_underlaid_joins
(
thd
,
&
thd
->
lex
->
select_lex
);
table
->
insert_values
=
0
;
...
...
@@ -529,7 +530,7 @@ int write_record(TABLE *table,COPY_INFO *info)
goto
err
;
if
((
error
=
table
->
file
->
update_row
(
table
->
record
[
1
],
table
->
record
[
0
])))
goto
err
;
info
->
dele
ted
++
;
info
->
upda
ted
++
;
break
;
}
else
/* DUP_REPLACE */
...
...
@@ -1474,7 +1475,8 @@ void select_insert::send_error(uint errcode,const char *err)
error while inserting into a MyISAM table) we must write to the binlog (and
the error code will make the slave stop).
*/
if
((
info
.
copied
||
info
.
deleted
)
&&
!
table
->
file
->
has_transactions
())
if
((
info
.
copied
||
info
.
deleted
||
info
.
updated
)
&&
!
table
->
file
->
has_transactions
())
{
if
(
last_insert_id
)
thd
->
insert_id
(
last_insert_id
);
// For binary log
...
...
@@ -1488,7 +1490,7 @@ void select_insert::send_error(uint errcode,const char *err)
if
(
!
table
->
tmp_table
)
thd
->
options
|=
OPTION_STATUS_NO_TRANS_UPDATE
;
}
if
(
info
.
copied
||
info
.
deleted
)
if
(
info
.
copied
||
info
.
deleted
||
info
.
updated
)
query_cache_invalidate3
(
thd
,
table
,
1
);
ha_rollback_stmt
(
thd
);
DBUG_VOID_RETURN
;
...
...
@@ -1509,7 +1511,7 @@ bool select_insert::send_eof()
and ha_autocommit_...
*/
if
(
info
.
copied
||
info
.
deleted
)
if
(
info
.
copied
||
info
.
deleted
||
info
.
updated
)
{
query_cache_invalidate3
(
thd
,
table
,
1
);
if
(
!
(
table
->
file
->
has_transactions
()
||
table
->
tmp_table
))
...
...
@@ -1543,8 +1545,8 @@ bool select_insert::send_eof()
(
ulong
)
(
info
.
records
-
info
.
copied
),
(
ulong
)
thd
->
cuted_fields
);
else
sprintf
(
buff
,
ER
(
ER_INSERT_INFO
),
(
ulong
)
info
.
records
,
(
ulong
)
info
.
deleted
,
(
ulong
)
thd
->
cuted_fields
);
::
send_ok
(
thd
,
info
.
copied
+
info
.
deleted
,
last_insert_id
,
buff
);
(
ulong
)
info
.
deleted
+
info
.
updated
,
(
ulong
)
thd
->
cuted_fields
);
::
send_ok
(
thd
,
info
.
copied
+
info
.
deleted
+
info
.
updated
,
last_insert_id
,
buff
);
DBUG_RETURN
(
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