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
1715bb18
Commit
1715bb18
authored
Jan 25, 2008
by
mskold/marty@quadfish.(none)
Browse files
Options
Browse Files
Download
Plain Diff
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-5.1-new-ndb
into mysql.com:/home/marty/MySQL/mysql-5.1-new-ndb
parents
b16b7f87
94a05931
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
172 additions
and
82 deletions
+172
-82
mysql-test/suite/ndb/r/ndb_auto_increment.result
mysql-test/suite/ndb/r/ndb_auto_increment.result
+3
-3
mysql-test/suite/ndb/r/ndb_restore.result
mysql-test/suite/ndb/r/ndb_restore.result
+35
-15
mysql-test/suite/ndb/t/ndb_restore.test
mysql-test/suite/ndb/t/ndb_restore.test
+15
-10
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.cc
+7
-4
storage/ndb/include/ndbapi/Ndb.hpp
storage/ndb/include/ndbapi/Ndb.hpp
+16
-11
storage/ndb/src/ndbapi/Ndb.cpp
storage/ndb/src/ndbapi/Ndb.cpp
+96
-39
No files found.
mysql-test/suite/ndb/r/ndb_auto_increment.result
View file @
1715bb18
...
@@ -421,10 +421,10 @@ select * from t1 order by a;
...
@@ -421,10 +421,10 @@ select * from t1 order by a;
a
a
1
1
20
20
21
33
33
34
34
35
35
65
insert into t1 values (100);
insert into t1 values (100);
insert into t1 values (NULL);
insert into t1 values (NULL);
insert into t1 values (NULL);
insert into t1 values (NULL);
...
@@ -432,11 +432,11 @@ select * from t1 order by a;
...
@@ -432,11 +432,11 @@ select * from t1 order by a;
a
a
1
1
20
20
21
22
33
33
34
34
35
35
65
66
100
100
101
101
set auto_increment_offset = @old_auto_increment_offset;
set auto_increment_offset = @old_auto_increment_offset;
...
...
mysql-test/suite/ndb/r/ndb_restore.result
View file @
1715bb18
...
@@ -253,21 +253,41 @@ a
...
@@ -253,21 +253,41 @@ a
2000
2000
3000
3000
10000
10000
show table status like 't1_c';
select max(capgoaledatta) from t1_c;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
max(capgoaledatta)
X X X X X X X X X X 3001 X X X X X X X
3000
show table status like 't2_c';
select auto_increment from information_schema.tables
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
where table_name = 't1_c';
X X X X X X X X X X 501 X X X X X X X
auto_increment
show table status like 't4_c';
3001
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
select max(capgotod) from t2_c;
X X X X X X X X X X 290000001 X X X X X X X
max(capgotod)
show table status like 't7_c';
500
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
select auto_increment from information_schema.tables
X X X X X X X X X X 29 X X X X X X X
where table_name = 't2_c';
show table status like 't10_c';
auto_increment
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
501
X X X X X X X X X X 10001 X X X X X X X
select max(capfa) from t4_c;
max(capfa)
290000000
select auto_increment from information_schema.tables
where table_name = 't4_c';
auto_increment
290000001
select max(dardtestard) from t7_c;
max(dardtestard)
28
select auto_increment from information_schema.tables
where table_name = 't7_c';
auto_increment
29
select max(a) from t10_c;
max(a)
10000
select auto_increment from information_schema.tables
where table_name = 't10_c';
auto_increment
10001
ALTER TABLE t7_c
ALTER TABLE t7_c
PARTITION BY LINEAR KEY (`dardtestard`);
PARTITION BY LINEAR KEY (`dardtestard`);
CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
...
...
mysql-test/suite/ndb/t/ndb_restore.test
View file @
1715bb18
...
@@ -246,16 +246,21 @@ select count(*)
...
@@ -246,16 +246,21 @@ select count(*)
select
*
from
t10_c
order
by
a
;
select
*
from
t10_c
order
by
a
;
# Bug #27775 cont'd
# Bug #27775 cont'd
# - auto inc info should be correct
# - auto inc info should be correct
--
replace_column
1
X
2
X
3
X
4
X
5
X
6
X
7
X
8
X
9
X
10
X
12
X
13
X
14
X
15
X
16
X
17
X
18
X
select
max
(
capgoaledatta
)
from
t1_c
;
show
table
status
like
't1_c'
;
select
auto_increment
from
information_schema
.
tables
--
replace_column
1
X
2
X
3
X
4
X
5
X
6
X
7
X
8
X
9
X
10
X
12
X
13
X
14
X
15
X
16
X
17
X
18
X
where
table_name
=
't1_c'
;
show
table
status
like
't2_c'
;
select
max
(
capgotod
)
from
t2_c
;
--
replace_column
1
X
2
X
3
X
4
X
5
X
6
X
7
X
8
X
9
X
10
X
12
X
13
X
14
X
15
X
16
X
17
X
18
X
select
auto_increment
from
information_schema
.
tables
show
table
status
like
't4_c'
;
where
table_name
=
't2_c'
;
--
replace_column
1
X
2
X
3
X
4
X
5
X
6
X
7
X
8
X
9
X
10
X
12
X
13
X
14
X
15
X
16
X
17
X
18
X
select
max
(
capfa
)
from
t4_c
;
show
table
status
like
't7_c'
;
select
auto_increment
from
information_schema
.
tables
--
replace_column
1
X
2
X
3
X
4
X
5
X
6
X
7
X
8
X
9
X
10
X
12
X
13
X
14
X
15
X
16
X
17
X
18
X
where
table_name
=
't4_c'
;
show
table
status
like
't10_c'
;
select
max
(
dardtestard
)
from
t7_c
;
select
auto_increment
from
information_schema
.
tables
where
table_name
=
't7_c'
;
select
max
(
a
)
from
t10_c
;
select
auto_increment
from
information_schema
.
tables
where
table_name
=
't10_c'
;
#
#
# Try Partitioned tables as well
# Try Partitioned tables as well
...
...
sql/ha_ndbcluster.cc
View file @
1715bb18
...
@@ -2738,10 +2738,13 @@ ha_ndbcluster::set_auto_inc(Field *field)
...
@@ -2738,10 +2738,13 @@ ha_ndbcluster::set_auto_inc(Field *field)
(
"Trying to set next auto increment value to %s"
,
(
"Trying to set next auto increment value to %s"
,
llstr
(
next_val
,
buff
)));
llstr
(
next_val
,
buff
)));
#endif
#endif
Ndb_tuple_id_range_guard
g
(
m_share
);
if
(
ndb
->
checkUpdateAutoIncrementValue
(
m_share
->
tuple_id_range
,
next_val
))
if
(
ndb
->
setAutoIncrementValue
(
m_table
,
g
.
range
,
next_val
,
TRUE
)
{
==
-
1
)
Ndb_tuple_id_range_guard
g
(
m_share
);
ERR_RETURN
(
ndb
->
getNdbError
());
if
(
ndb
->
setAutoIncrementValue
(
m_table
,
g
.
range
,
next_val
,
TRUE
)
==
-
1
)
ERR_RETURN
(
ndb
->
getNdbError
());
}
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
...
...
storage/ndb/include/ndbapi/Ndb.hpp
View file @
1715bb18
...
@@ -1515,37 +1515,40 @@ public:
...
@@ -1515,37 +1515,40 @@ public:
TupleIdRange
()
{}
TupleIdRange
()
{}
Uint64
m_first_tuple_id
;
Uint64
m_first_tuple_id
;
Uint64
m_last_tuple_id
;
Uint64
m_last_tuple_id
;
Uint64
m_highest_seen
;
void
reset
()
{
void
reset
()
{
m_first_tuple_id
=
~
(
Uint64
)
0
;
m_first_tuple_id
=
~
(
Uint64
)
0
;
m_last_tuple_id
=
~
(
Uint64
)
0
;
m_last_tuple_id
=
~
(
Uint64
)
0
;
m_highest_seen
=
0
;
};
};
};
};
int
initAutoIncrement
();
int
initAutoIncrement
();
int
getAutoIncrementValue
(
const
char
*
aTableName
,
int
getAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
&
tupleId
,
Uint32
cacheSize
,
Uint64
&
autoValue
,
Uint32
cacheSize
,
Uint64
step
=
1
,
Uint64
start
=
1
);
Uint64
step
=
1
,
Uint64
start
=
1
);
int
getAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
int
getAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint64
&
tupleId
,
Uint32
cacheSize
,
Uint64
&
autoValue
,
Uint32
cacheSize
,
Uint64
step
=
1
,
Uint64
start
=
1
);
Uint64
step
=
1
,
Uint64
start
=
1
);
int
getAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
int
getAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
TupleIdRange
&
range
,
Uint64
&
tupleId
,
TupleIdRange
&
range
,
Uint64
&
autoValue
,
Uint32
cacheSize
,
Uint32
cacheSize
,
Uint64
step
=
1
,
Uint64
start
=
1
);
Uint64
step
=
1
,
Uint64
start
=
1
);
int
readAutoIncrementValue
(
const
char
*
aTableName
,
int
readAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
&
tupleId
);
Uint64
&
autoValue
);
int
readAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
int
readAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint64
&
tupleId
);
Uint64
&
autoValue
);
int
readAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
int
readAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
TupleIdRange
&
range
,
Uint64
&
tupleId
);
TupleIdRange
&
range
,
Uint64
&
autoValue
);
int
setAutoIncrementValue
(
const
char
*
aTableName
,
int
setAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
tupleId
,
bool
increase
);
Uint64
autoValue
,
bool
modify
);
int
setAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
int
setAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint64
tupleId
,
bool
increase
);
Uint64
autoValue
,
bool
modify
);
int
setAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
int
setAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
TupleIdRange
&
range
,
Uint64
tupleId
,
TupleIdRange
&
range
,
Uint64
autoValue
,
bool
increase
);
bool
modify
);
bool
checkUpdateAutoIncrementValue
(
TupleIdRange
&
range
,
Uint64
autoValue
);
private:
private:
int
getTupleIdFromNdb
(
const
NdbTableImpl
*
table
,
int
getTupleIdFromNdb
(
const
NdbTableImpl
*
table
,
TupleIdRange
&
range
,
Uint64
&
tupleId
,
TupleIdRange
&
range
,
Uint64
&
tupleId
,
...
@@ -1553,7 +1556,9 @@ private:
...
@@ -1553,7 +1556,9 @@ private:
int
readTupleIdFromNdb
(
const
NdbTableImpl
*
table
,
int
readTupleIdFromNdb
(
const
NdbTableImpl
*
table
,
TupleIdRange
&
range
,
Uint64
&
tupleId
);
TupleIdRange
&
range
,
Uint64
&
tupleId
);
int
setTupleIdInNdb
(
const
NdbTableImpl
*
table
,
int
setTupleIdInNdb
(
const
NdbTableImpl
*
table
,
TupleIdRange
&
range
,
Uint64
tupleId
,
bool
increase
);
TupleIdRange
&
range
,
Uint64
tupleId
,
bool
modify
);
int
checkTupleIdInNdb
(
TupleIdRange
&
range
,
Uint64
tupleId
);
int
opTupleIdOnNdb
(
const
NdbTableImpl
*
table
,
int
opTupleIdOnNdb
(
const
NdbTableImpl
*
table
,
TupleIdRange
&
range
,
Uint64
&
opValue
,
Uint32
op
);
TupleIdRange
&
range
,
Uint64
&
opValue
,
Uint32
op
);
public:
public:
...
...
storage/ndb/src/ndbapi/Ndb.cpp
View file @
1715bb18
...
@@ -942,6 +942,7 @@ Parameters: aTableName (IN) : The table name.
...
@@ -942,6 +942,7 @@ Parameters: aTableName (IN) : The table name.
step (IN) : Specifies the step between the
step (IN) : Specifies the step between the
autoincrement values.
autoincrement values.
start (IN) : Start value for first value
start (IN) : Start value for first value
Returns: 0 if succesful, -1 if error encountered
Remark: Returns a new autoincrement value to the application.
Remark: Returns a new autoincrement value to the application.
The autoincrement values can be increased by steps
The autoincrement values can be increased by steps
(default 1) and a number of values can be prefetched
(default 1) and a number of values can be prefetched
...
@@ -1072,9 +1073,18 @@ Ndb::getTupleIdFromNdb(const NdbTableImpl* table,
...
@@ -1072,9 +1073,18 @@ Ndb::getTupleIdFromNdb(const NdbTableImpl* table,
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
/****************************************************************************
int readAutoIncrementValue( const char* aTableName,
Uint64 & autoValue);
Parameters: aTableName (IN) : The table name.
autoValue (OUT) : The current autoincrement value
Returns: 0 if succesful, -1 if error encountered
Remark: Returns the current autoincrement value to the application.
****************************************************************************/
int
int
Ndb
::
readAutoIncrementValue
(
const
char
*
aTableName
,
Ndb
::
readAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
&
tupleId
)
Uint64
&
autoValue
)
{
{
DBUG_ENTER
(
"Ndb::readAutoIncrementValue"
);
DBUG_ENTER
(
"Ndb::readAutoIncrementValue"
);
ASSERT_NOT_MYSQLD
;
ASSERT_NOT_MYSQLD
;
...
@@ -1088,15 +1098,15 @@ Ndb::readAutoIncrementValue(const char* aTableName,
...
@@ -1088,15 +1098,15 @@ Ndb::readAutoIncrementValue(const char* aTableName,
}
}
const
NdbTableImpl
*
table
=
info
->
m_table_impl
;
const
NdbTableImpl
*
table
=
info
->
m_table_impl
;
TupleIdRange
&
range
=
info
->
m_tuple_id_range
;
TupleIdRange
&
range
=
info
->
m_tuple_id_range
;
if
(
readTupleIdFromNdb
(
table
,
range
,
tupleId
)
==
-
1
)
if
(
readTupleIdFromNdb
(
table
,
range
,
autoValue
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
DBUG_PRINT
(
"info"
,
(
"value %lu"
,
(
ulong
)
tupleId
));
DBUG_PRINT
(
"info"
,
(
"value %lu"
,
(
ulong
)
autoValue
));
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
int
int
Ndb
::
readAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Ndb
::
readAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint64
&
tupleId
)
Uint64
&
autoValue
)
{
{
DBUG_ENTER
(
"Ndb::readAutoIncrementValue"
);
DBUG_ENTER
(
"Ndb::readAutoIncrementValue"
);
ASSERT_NOT_MYSQLD
;
ASSERT_NOT_MYSQLD
;
...
@@ -1111,23 +1121,23 @@ Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable,
...
@@ -1111,23 +1121,23 @@ Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable,
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
}
}
TupleIdRange
&
range
=
info
->
m_tuple_id_range
;
TupleIdRange
&
range
=
info
->
m_tuple_id_range
;
if
(
readTupleIdFromNdb
(
table
,
range
,
tupleId
)
==
-
1
)
if
(
readTupleIdFromNdb
(
table
,
range
,
autoValue
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
DBUG_PRINT
(
"info"
,
(
"value %lu"
,
(
ulong
)
tupleId
));
DBUG_PRINT
(
"info"
,
(
"value %lu"
,
(
ulong
)
autoValue
));
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
int
int
Ndb
::
readAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Ndb
::
readAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
TupleIdRange
&
range
,
Uint64
&
tupleId
)
TupleIdRange
&
range
,
Uint64
&
autoValue
)
{
{
DBUG_ENTER
(
"Ndb::readAutoIncrementValue"
);
DBUG_ENTER
(
"Ndb::readAutoIncrementValue"
);
assert
(
aTable
!=
0
);
assert
(
aTable
!=
0
);
const
NdbTableImpl
*
table
=
&
NdbTableImpl
::
getImpl
(
*
aTable
);
const
NdbTableImpl
*
table
=
&
NdbTableImpl
::
getImpl
(
*
aTable
);
if
(
readTupleIdFromNdb
(
table
,
range
,
tupleId
)
==
-
1
)
if
(
readTupleIdFromNdb
(
table
,
range
,
autoValue
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
DBUG_PRINT
(
"info"
,
(
"value %lu"
,
(
ulong
)
tupleId
));
DBUG_PRINT
(
"info"
,
(
"value %lu"
,
(
ulong
)
autoValue
));
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
...
@@ -1155,9 +1165,20 @@ Ndb::readTupleIdFromNdb(const NdbTableImpl* table,
...
@@ -1155,9 +1165,20 @@ Ndb::readTupleIdFromNdb(const NdbTableImpl* table,
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
/****************************************************************************
int setAutoIncrementValue( const char* aTableName,
Uint64 autoValue,
bool modify);
Parameters: aTableName (IN) : The table name.
autoValue (IN) : The new autoincrement value
modify (IN) : Modify existing value (not initialization)
Returns: 0 if succesful, -1 if error encountered
Remark: Sets a new autoincrement value for the application.
****************************************************************************/
int
int
Ndb
::
setAutoIncrementValue
(
const
char
*
aTableName
,
Ndb
::
setAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
tupleId
,
bool
increase
)
Uint64
autoValue
,
bool
modify
)
{
{
DBUG_ENTER
(
"Ndb::setAutoIncrementValue"
);
DBUG_ENTER
(
"Ndb::setAutoIncrementValue"
);
ASSERT_NOT_MYSQLD
;
ASSERT_NOT_MYSQLD
;
...
@@ -1171,14 +1192,14 @@ Ndb::setAutoIncrementValue(const char* aTableName,
...
@@ -1171,14 +1192,14 @@ Ndb::setAutoIncrementValue(const char* aTableName,
}
}
const
NdbTableImpl
*
table
=
info
->
m_table_impl
;
const
NdbTableImpl
*
table
=
info
->
m_table_impl
;
TupleIdRange
&
range
=
info
->
m_tuple_id_range
;
TupleIdRange
&
range
=
info
->
m_tuple_id_range
;
if
(
setTupleIdInNdb
(
table
,
range
,
tupleId
,
increase
)
==
-
1
)
if
(
setTupleIdInNdb
(
table
,
range
,
autoValue
,
modify
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
int
int
Ndb
::
setAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Ndb
::
setAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint64
tupleId
,
bool
increase
)
Uint64
autoValue
,
bool
modify
)
{
{
DBUG_ENTER
(
"Ndb::setAutoIncrementValue"
);
DBUG_ENTER
(
"Ndb::setAutoIncrementValue"
);
ASSERT_NOT_MYSQLD
;
ASSERT_NOT_MYSQLD
;
...
@@ -1193,52 +1214,55 @@ Ndb::setAutoIncrementValue(const NdbDictionary::Table * aTable,
...
@@ -1193,52 +1214,55 @@ Ndb::setAutoIncrementValue(const NdbDictionary::Table * aTable,
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
}
}
TupleIdRange
&
range
=
info
->
m_tuple_id_range
;
TupleIdRange
&
range
=
info
->
m_tuple_id_range
;
if
(
setTupleIdInNdb
(
table
,
range
,
tupleId
,
increase
)
==
-
1
)
if
(
setTupleIdInNdb
(
table
,
range
,
autoValue
,
modify
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
int
int
Ndb
::
setAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Ndb
::
setAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
TupleIdRange
&
range
,
Uint64
tupleId
,
TupleIdRange
&
range
,
Uint64
autoValue
,
bool
increase
)
bool
modify
)
{
{
DBUG_ENTER
(
"Ndb::setAutoIncrementValue"
);
DBUG_ENTER
(
"Ndb::setAutoIncrementValue"
);
assert
(
aTable
!=
0
);
assert
(
aTable
!=
0
);
const
NdbTableImpl
*
table
=
&
NdbTableImpl
::
getImpl
(
*
aTable
);
const
NdbTableImpl
*
table
=
&
NdbTableImpl
::
getImpl
(
*
aTable
);
if
(
setTupleIdInNdb
(
table
,
range
,
tupleId
,
increase
)
==
-
1
)
if
(
setTupleIdInNdb
(
table
,
range
,
autoValue
,
modify
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
int
int
Ndb
::
setTupleIdInNdb
(
const
NdbTableImpl
*
table
,
Ndb
::
setTupleIdInNdb
(
const
NdbTableImpl
*
table
,
TupleIdRange
&
range
,
Uint64
tupleId
,
bool
increase
)
TupleIdRange
&
range
,
Uint64
tupleId
,
bool
modify
)
{
{
DBUG_ENTER
(
"Ndb::setTupleIdInNdb"
);
DBUG_ENTER
(
"Ndb::setTupleIdInNdb"
);
if
(
increase
)
if
(
modify
)
{
{
if
(
range
.
m_first_tuple_id
!=
range
.
m_last_tuple_id
)
if
(
checkTupleIdInNdb
(
range
,
tupleId
)
)
{
{
assert
(
range
.
m_first_tuple_id
<
range
.
m_last_tuple_id
);
if
(
range
.
m_first_tuple_id
!=
range
.
m_last_tuple_id
)
if
(
tupleId
<=
range
.
m_first_tuple_id
+
1
)
DBUG_RETURN
(
0
);
if
(
tupleId
<=
range
.
m_last_tuple_id
)
{
{
range
.
m_first_tuple_id
=
tupleId
-
1
;
assert
(
range
.
m_first_tuple_id
<
range
.
m_last_tuple_id
);
DBUG_PRINT
(
"info"
,
if
(
tupleId
<=
range
.
m_first_tuple_id
+
1
)
(
"Setting next auto increment cached value to %lu"
,
DBUG_RETURN
(
0
);
(
ulong
)
tupleId
));
if
(
tupleId
<=
range
.
m_last_tuple_id
)
DBUG_RETURN
(
0
);
{
range
.
m_first_tuple_id
=
tupleId
-
1
;
DBUG_PRINT
(
"info"
,
(
"Setting next auto increment cached value to %lu"
,
(
ulong
)
tupleId
));
DBUG_RETURN
(
0
);
}
}
}
/*
* if tupleId <= NEXTID, do nothing. otherwise update NEXTID to
* tupleId and set cached range to first = last = tupleId - 1.
*/
if
(
opTupleIdOnNdb
(
table
,
range
,
tupleId
,
2
)
==
-
1
)
DBUG_RETURN
(
-
1
);
}
}
/*
* if tupleId <= NEXTID, do nothing. otherwise update NEXTID to
* tupleId and set cached range to first = last = tupleId - 1.
*/
if
(
opTupleIdOnNdb
(
table
,
range
,
tupleId
,
2
)
==
-
1
)
DBUG_RETURN
(
-
1
);
}
}
else
else
{
{
...
@@ -1277,6 +1301,39 @@ int Ndb::initAutoIncrement()
...
@@ -1277,6 +1301,39 @@ int Ndb::initAutoIncrement()
return
0
;
return
0
;
}
}
bool
Ndb
::
checkUpdateAutoIncrementValue
(
TupleIdRange
&
range
,
Uint64
autoValue
)
{
return
(
checkTupleIdInNdb
(
range
,
autoValue
)
!=
0
);
}
int
Ndb
::
checkTupleIdInNdb
(
TupleIdRange
&
range
,
Uint64
tupleId
)
{
DBUG_ENTER
(
"Ndb::checkTupleIdIndNdb"
);
if
((
range
.
m_first_tuple_id
!=
~
(
Uint64
)
0
)
&&
(
range
.
m_first_tuple_id
>
tupleId
))
{
/*
* If we have ever cached a value in this object and this cached
* value is larger than the value we're trying to set then we
* need not check with the real value in the SYSTAB_0 table.
*/
DBUG_RETURN
(
0
);
}
if
(
range
.
m_highest_seen
>
tupleId
)
{
/*
* Although we've never cached any higher value we have read
* a higher value and again it isn't necessary to change the
* auto increment value.
*/
DBUG_RETURN
(
0
);
}
DBUG_RETURN
(
1
);
}
int
int
Ndb
::
opTupleIdOnNdb
(
const
NdbTableImpl
*
table
,
Ndb
::
opTupleIdOnNdb
(
const
NdbTableImpl
*
table
,
TupleIdRange
&
range
,
Uint64
&
opValue
,
Uint32
op
)
TupleIdRange
&
range
,
Uint64
&
opValue
,
Uint32
op
)
...
@@ -1342,15 +1399,15 @@ Ndb::opTupleIdOnNdb(const NdbTableImpl* table,
...
@@ -1342,15 +1399,15 @@ Ndb::opTupleIdOnNdb(const NdbTableImpl* table,
tOperation
->
write_attr
(
"NEXTID"
,
1
);
tOperation
->
write_attr
(
"NEXTID"
,
1
);
tOperation
->
interpret_exit_ok
();
tOperation
->
interpret_exit_ok
();
tOperation
->
def_label
(
0
);
tOperation
->
def_label
(
0
);
tOperation
->
interpret_exit_
nok
(
9999
);
tOperation
->
interpret_exit_
ok
(
);
tRecAttrResult
=
tOperation
->
getValue
(
"NEXTID"
);
if
(
tConnection
->
execute
(
NdbTransaction
::
Commit
)
==
-
1
)
if
(
tConnection
->
execute
(
NdbTransaction
::
Commit
)
==
-
1
)
{
{
if
(
tConnection
->
theError
.
code
!=
9999
)
goto
error_handler
;
goto
error_handler
;
}
}
else
else
{
{
range
.
m_highest_seen
=
tRecAttrResult
->
u_64_value
();
DBUG_PRINT
(
"info"
,
DBUG_PRINT
(
"info"
,
(
"Setting next auto increment value (db) to %lu"
,
(
"Setting next auto increment value (db) to %lu"
,
(
ulong
)
opValue
));
(
ulong
)
opValue
));
...
@@ -1363,7 +1420,7 @@ Ndb::opTupleIdOnNdb(const NdbTableImpl* table,
...
@@ -1363,7 +1420,7 @@ Ndb::opTupleIdOnNdb(const NdbTableImpl* table,
tRecAttrResult
=
tOperation
->
getValue
(
"NEXTID"
);
tRecAttrResult
=
tOperation
->
getValue
(
"NEXTID"
);
if
(
tConnection
->
execute
(
NdbTransaction
::
Commit
)
==
-
1
)
if
(
tConnection
->
execute
(
NdbTransaction
::
Commit
)
==
-
1
)
goto
error_handler
;
goto
error_handler
;
opValue
=
tRecAttrResult
->
u_64_value
();
// out
range
.
m_highest_seen
=
opValue
=
tRecAttrResult
->
u_64_value
();
// out
break
;
break
;
default:
default:
goto
error_handler
;
goto
error_handler
;
...
...
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