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
c55aadd5
Commit
c55aadd5
authored
Jan 08, 2014
by
Rich Prohaska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#159 set last_auto_increment from create info
parent
d22b6118
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
38 deletions
+26
-38
storage/tokudb/ha_tokudb.cc
storage/tokudb/ha_tokudb.cc
+26
-38
No files found.
storage/tokudb/ha_tokudb.cc
View file @
c55aadd5
...
...
@@ -7410,61 +7410,49 @@ cleanup:
// auto-increment field (if auto-increment field is the first field of a key).
//
void
ha_tokudb
::
init_auto_increment
()
{
DBT
key
;
DBT
value
;
int
error
;
HA_METADATA_KEY
key_val
=
hatoku_max_ai
;
memset
(
&
key
,
0
,
sizeof
(
key
));
memset
(
&
value
,
0
,
sizeof
(
value
));
key
.
data
=
&
key_val
;
key
.
size
=
sizeof
(
key_val
);
value
.
flags
=
DB_DBT_USERMEM
;
DB_TXN
*
txn
=
NULL
;
error
=
txn_begin
(
db_env
,
0
,
&
txn
,
0
,
ha_thd
());
if
(
error
)
{
share
->
last_auto_increment
=
0
;
}
else
{
//
// First retrieve hatoku_max_ai, which is max value used by auto increment
// column so far, the max value could have been auto generated (e.g. insert (NULL))
// or it could have been manually inserted by user (e.g. insert (345))
//
value
.
ulen
=
sizeof
(
share
->
last_auto_increment
);
value
.
data
=
&
share
->
last_auto_increment
;
error
=
share
->
status_block
->
get
(
share
->
status_block
,
txn
,
&
key
,
&
value
,
0
);
if
(
error
||
value
.
size
!=
sizeof
(
share
->
last_auto_increment
))
{
share
->
last_auto_increment
=
0
;
}
}
else
{
HA_METADATA_KEY
key_val
;
DBT
key
;
memset
(
&
key
,
0
,
sizeof
(
key
));
key
.
data
=
&
key_val
;
key
.
size
=
sizeof
(
key_val
);
DBT
value
;
memset
(
&
value
,
0
,
sizeof
(
value
));
value
.
flags
=
DB_DBT_USERMEM
;
//
// Now retrieve the initial auto increment value, as specified by create table
// Retrieve the initial auto increment value, as specified by create table
// so if a user does "create table t1 (a int auto_increment, primary key (a)) auto_increment=100",
// then the value 100 should be stored here
//
key_val
=
hatoku_ai_create_value
;
value
.
ulen
=
sizeof
(
share
->
auto_inc_create_value
);
value
.
data
=
&
share
->
auto_inc_create_value
;
error
=
share
->
status_block
->
get
(
share
->
status_block
,
txn
,
&
key
,
&
value
,
0
);
error
=
share
->
status_block
->
get
(
share
->
status_block
,
txn
,
&
key
,
&
value
,
0
);
if
(
error
||
value
.
size
!=
sizeof
(
share
->
auto_inc_create_value
))
{
share
->
auto_inc_create_value
=
0
;
}
// Retrieve hatoku_max_ai, which is max value used by auto increment
// column so far, the max value could have been auto generated (e.g. insert (NULL))
// or it could have been manually inserted by user (e.g. insert (345))
key_val
=
hatoku_max_ai
;
value
.
ulen
=
sizeof
(
share
->
last_auto_increment
);
value
.
data
=
&
share
->
last_auto_increment
;
error
=
share
->
status_block
->
get
(
share
->
status_block
,
txn
,
&
key
,
&
value
,
0
);
if
(
error
||
value
.
size
!=
sizeof
(
share
->
last_auto_increment
))
{
if
(
share
->
auto_inc_create_value
)
share
->
last_auto_increment
=
share
->
auto_inc_create_value
-
1
;
else
share
->
last_auto_increment
=
0
;
}
commit_txn
(
txn
,
0
);
}
if
(
tokudb_debug
&
TOKUDB_DEBUG_AUTO_INCREMENT
)
{
...
...
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