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
fabad719
Commit
fabad719
authored
May 08, 2007
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge gleb.loc:/home/uchum/work/bk/mysql-5.0-opt
into gleb.loc:/home/uchum/work/bk/mysql-5.0-opt-27954
parents
44e54a30
35659a28
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
0 deletions
+50
-0
mysql-test/r/insert_update.result
mysql-test/r/insert_update.result
+22
-0
mysql-test/t/insert_update.test
mysql-test/t/insert_update.test
+17
-0
sql/handler.cc
sql/handler.cc
+7
-0
sql/sql_class.h
sql/sql_class.h
+4
-0
No files found.
mysql-test/r/insert_update.result
View file @
fabad719
...
...
@@ -336,3 +336,25 @@ id f1
0 test1
DROP TABLE t1;
SET SQL_MODE='';
CREATE TABLE t1 (
id INT AUTO_INCREMENT PRIMARY KEY,
c1 CHAR(1) UNIQUE KEY,
cnt INT DEFAULT 1
);
INSERT INTO t1 (c1) VALUES ('A'), ('B'), ('C');
SELECT * FROM t1;
id c1 cnt
1 A 1
2 B 1
3 C 1
INSERT INTO t1 (c1) VALUES ('A'), ('X'), ('Y'), ('Z')
ON DUPLICATE KEY UPDATE cnt=cnt+1;
SELECT * FROM t1;
id c1 cnt
1 A 2
2 B 1
3 C 1
4 X 1
5 Y 1
6 Z 1
DROP TABLE t1;
mysql-test/t/insert_update.test
View file @
fabad719
...
...
@@ -247,3 +247,20 @@ REPLACE INTO t1 VALUES (0,"test1",null);
SELECT
id
,
f1
FROM
t1
;
DROP
TABLE
t1
;
SET
SQL_MODE
=
''
;
#
# Bug#27954: multi-row INSERT ... ON DUPLICATE with duplicated
# row at the first place into table with AUTO_INCREMENT and
# additional UNIQUE key.
#
CREATE
TABLE
t1
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
c1
CHAR
(
1
)
UNIQUE
KEY
,
cnt
INT
DEFAULT
1
);
INSERT
INTO
t1
(
c1
)
VALUES
(
'A'
),
(
'B'
),
(
'C'
);
SELECT
*
FROM
t1
;
INSERT
INTO
t1
(
c1
)
VALUES
(
'A'
),
(
'X'
),
(
'Y'
),
(
'Z'
)
ON
DUPLICATE
KEY
UPDATE
cnt
=
cnt
+
1
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
sql/handler.cc
View file @
fabad719
...
...
@@ -1685,7 +1685,14 @@ void handler::restore_auto_increment()
{
THD
*
thd
=
table
->
in_use
;
if
(
thd
->
next_insert_id
)
{
thd
->
next_insert_id
=
thd
->
prev_insert_id
;
if
(
thd
->
next_insert_id
==
0
)
{
/* we didn't generate a value, engine will be called again */
thd
->
clear_next_insert_id
=
0
;
}
}
}
...
...
sql/sql_class.h
View file @
fabad719
...
...
@@ -1431,6 +1431,10 @@ class THD :public Statement,
*/
bool
insert_id_used
;
/*
clear_next_insert_id is set if engine was called at least once
for this statement to generate auto_increment value.
*/
bool
clear_next_insert_id
;
/* for IS NULL => = last_insert_id() fix in remove_eq_conds() */
bool
substitute_null_with_insert_id
;
...
...
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