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
6bc7b3a6
Commit
6bc7b3a6
authored
Jun 30, 2003
by
monty@mashka.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LAST_INSERT_ID() should not be set if we couldn't generate an auto_increment id.
parent
dbebed97
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
3 deletions
+29
-3
mysql-test/r/auto_increment.result
mysql-test/r/auto_increment.result
+6
-1
mysql-test/t/auto_increment.test
mysql-test/t/auto_increment.test
+4
-0
sql/handler.cc
sql/handler.cc
+2
-0
sql/sql_class.h
sql/sql_class.h
+17
-2
No files found.
mysql-test/r/auto_increment.result
View file @
6bc7b3a6
...
...
@@ -111,11 +111,16 @@ insert into t1 set i = null;
select last_insert_id();
last_insert_id()
255
insert into t1 set i = 254;
ERROR 23000: Duplicate entry '254' for key 1
select last_insert_id();
last_insert_id()
255
insert into t1 set i = null;
ERROR 23000: Duplicate entry '255' for key 1
select last_insert_id();
last_insert_id()
255
0
drop table t1;
create table t1 (i tinyint unsigned not null auto_increment, key (i));
insert into t1 set i = 254;
...
...
mysql-test/t/auto_increment.test
View file @
6bc7b3a6
...
...
@@ -80,6 +80,9 @@ insert into t1 set i = 254;
insert
into
t1
set
i
=
null
;
select
last_insert_id
();
--
error
1062
insert
into
t1
set
i
=
254
;
select
last_insert_id
();
--
error
1062
insert
into
t1
set
i
=
null
;
select
last_insert_id
();
drop
table
t1
;
...
...
@@ -100,5 +103,6 @@ select last_insert_id();
--
error
1062
insert
into
t1
values
(
NULL
,
10
);
select
last_insert_id
();
drop
table
t1
;
sql/handler.cc
View file @
6bc7b3a6
...
...
@@ -709,6 +709,8 @@ void handler::update_auto_increment()
nr
=
get_auto_increment
();
if
(
!
table
->
next_number_field
->
store
(
nr
))
thd
->
insert_id
((
ulonglong
)
nr
);
else
thd
->
insert_id
(
table
->
next_number_field
->
val_int
());
auto_increment_column_changed
=
1
;
DBUG_VOID_RETURN
;
}
...
...
sql/sql_class.h
View file @
6bc7b3a6
...
...
@@ -503,8 +503,23 @@ public:
#ifdef SIGNAL_WITH_VIO_CLOSE
Vio
*
active_vio
;
#endif
ulonglong
next_insert_id
,
last_insert_id
,
current_insert_id
,
limit_found_rows
;
/*
next_insert_id is set on SET INSERT_ID= #. This is used as the next
generated auto_increment value in handler.cc
*/
ulonglong
next_insert_id
;
/*
The insert_id used for the last statement or set by SET LAST_INSERT_ID=#
or SELECT LAST_INSERT_ID(#). Used for binary log and returned by
LAST_INSERT_ID()
*/
ulonglong
last_insert_id
;
/*
Set to the first value that LAST_INSERT_ID() returned for the last
statement. When this is set, last_insert_id_used is set to true.
*/
ulonglong
current_insert_id
;
ulonglong
limit_found_rows
;
ha_rows
select_limit
,
offset_limit
,
cuted_fields
,
sent_row_count
,
examined_row_count
;
table_map
used_tables
;
...
...
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