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
54963c2e
Commit
54963c2e
authored
May 17, 2006
by
pekka@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ndb - bug#14509 [related] re-do auto-incr error handling
parent
fc732046
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
145 additions
and
105 deletions
+145
-105
ndb/include/ndbapi/Ndb.hpp
ndb/include/ndbapi/Ndb.hpp
+20
-15
ndb/src/ndbapi/Ndb.cpp
ndb/src/ndbapi/Ndb.cpp
+90
-68
ndb/src/ndbapi/NdbDictionaryImpl.cpp
ndb/src/ndbapi/NdbDictionaryImpl.cpp
+1
-1
ndb/test/ndbapi/testDict.cpp
ndb/test/ndbapi/testDict.cpp
+7
-3
ndb/tools/restore/consumer_restore.cpp
ndb/tools/restore/consumer_restore.cpp
+6
-3
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.cc
+21
-15
No files found.
ndb/include/ndbapi/Ndb.hpp
View file @
54963c2e
...
@@ -1432,23 +1432,28 @@ public:
...
@@ -1432,23 +1432,28 @@ public:
*
*
* @param cacheSize number of values to cache in this Ndb object
* @param cacheSize number of values to cache in this Ndb object
*
*
* @return
tuple id or ~(Uint64)0 on error.
* @return
0 or -1 on error, and tupleId in out parameter
*/
*/
Uint64
getAutoIncrementValue
(
const
char
*
aTableName
,
int
getAutoIncrementValue
(
const
char
*
aTableName
,
Uint32
cacheSize
=
1
);
Uint64
&
tupleId
,
Uint32
cacheSize
);
Uint64
getAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
int
getAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint32
cacheSize
=
1
);
Uint64
&
tupleId
,
Uint32
cacheSize
);
Uint64
readAutoIncrementValue
(
const
char
*
aTableName
);
int
readAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
readAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
);
Uint64
&
tupleId
);
Uint64
setAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
val
,
int
readAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
bool
increase
=
false
);
Uint64
&
tupleId
);
Uint64
setAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint64
val
,
int
setAutoIncrementValue
(
const
char
*
aTableName
,
bool
increase
=
false
);
Uint64
tupleId
,
bool
increase
);
int
setAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint64
tupleId
,
bool
increase
);
private:
private:
Uint64
getTupleIdFromNdb
(
Ndb_local_table_info
*
info
,
Uint32
cacheSize
);
int
getTupleIdFromNdb
(
Ndb_local_table_info
*
info
,
Uint64
readTupleIdFromNdb
(
Ndb_local_table_info
*
info
);
Uint64
&
tupleId
,
Uint32
cacheSize
);
Uint64
setTupleIdInNdb
(
Ndb_local_table_info
*
info
,
Uint64
val
,
bool
increase
);
int
readTupleIdFromNdb
(
Ndb_local_table_info
*
info
,
Uint64
opTupleIdOnNdb
(
Ndb_local_table_info
*
info
,
Uint64
opValue
,
Uint32
op
);
Uint64
&
tupleId
);
int
setTupleIdInNdb
(
Ndb_local_table_info
*
info
,
Uint64
tupleId
,
bool
increase
);
int
opTupleIdOnNdb
(
Ndb_local_table_info
*
info
,
Uint64
&
opValue
,
Uint32
op
);
public:
public:
/**
/**
...
...
ndb/src/ndbapi/Ndb.cpp
View file @
54963c2e
...
@@ -760,27 +760,30 @@ Remark: Returns a new TupleId to the application.
...
@@ -760,27 +760,30 @@ Remark: Returns a new TupleId to the application.
The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId.
The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId.
It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp.
It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp.
****************************************************************************/
****************************************************************************/
Uint64
int
Ndb
::
getAutoIncrementValue
(
const
char
*
aTableName
,
Uint32
cacheSize
)
Ndb
::
getAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
&
tupleId
,
Uint32
cacheSize
)
{
{
DBUG_ENTER
(
"getAutoIncrementValue"
);
DBUG_ENTER
(
"
Ndb::
getAutoIncrementValue"
);
BaseString
internal_tabname
(
internalize_table_name
(
aTableName
));
BaseString
internal_tabname
(
internalize_table_name
(
aTableName
));
Ndb_local_table_info
*
info
=
Ndb_local_table_info
*
info
=
theDictionary
->
get_local_table_info
(
internal_tabname
,
false
);
theDictionary
->
get_local_table_info
(
internal_tabname
,
false
);
if
(
info
==
0
)
{
if
(
info
==
0
)
{
theError
.
code
=
theDictionary
->
getNdbError
().
code
;
theError
.
code
=
theDictionary
->
getNdbError
().
code
;
DBUG_RETURN
(
~
(
Uint64
)
0
);
DBUG_RETURN
(
-
1
);
}
}
Uint64
tupleId
=
getTupleIdFromNdb
(
info
,
cacheSize
);
if
(
getTupleIdFromNdb
(
info
,
tupleId
,
cacheSize
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_PRINT
(
"info"
,
(
"value %llu"
,
(
ulonglong
)
tupleId
));
DBUG_PRINT
(
"info"
,
(
"value %llu"
,
(
ulonglong
)
tupleId
));
DBUG_RETURN
(
tupleId
);
DBUG_RETURN
(
0
);
}
}
Uint64
int
Ndb
::
getAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint32
cacheSize
)
Ndb
::
getAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint64
&
tupleId
,
Uint32
cacheSize
)
{
{
DBUG_ENTER
(
"getAutoIncrementValue"
);
DBUG_ENTER
(
"
Ndb::
getAutoIncrementValue"
);
assert
(
aTable
!=
0
);
assert
(
aTable
!=
0
);
const
NdbTableImpl
*
table
=
&
NdbTableImpl
::
getImpl
(
*
aTable
);
const
NdbTableImpl
*
table
=
&
NdbTableImpl
::
getImpl
(
*
aTable
);
const
BaseString
&
internal_tabname
=
table
->
m_internalName
;
const
BaseString
&
internal_tabname
=
table
->
m_internalName
;
...
@@ -789,18 +792,19 @@ Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable, Uint32 cacheSize
...
@@ -789,18 +792,19 @@ Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable, Uint32 cacheSize
theDictionary
->
get_local_table_info
(
internal_tabname
,
false
);
theDictionary
->
get_local_table_info
(
internal_tabname
,
false
);
if
(
info
==
0
)
{
if
(
info
==
0
)
{
theError
.
code
=
theDictionary
->
getNdbError
().
code
;
theError
.
code
=
theDictionary
->
getNdbError
().
code
;
DBUG_RETURN
(
~
(
Uint64
)
0
);
DBUG_RETURN
(
-
1
);
}
}
Uint64
tupleId
=
getTupleIdFromNdb
(
info
,
cacheSize
);
if
(
getTupleIdFromNdb
(
info
,
tupleId
,
cacheSize
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_PRINT
(
"info"
,
(
"value %llu"
,
(
ulonglong
)
tupleId
));
DBUG_PRINT
(
"info"
,
(
"value %llu"
,
(
ulonglong
)
tupleId
));
DBUG_RETURN
(
tupleId
);
DBUG_RETURN
(
0
);
}
}
Uint64
int
Ndb
::
getTupleIdFromNdb
(
Ndb_local_table_info
*
info
,
Uint32
cacheSize
)
Ndb
::
getTupleIdFromNdb
(
Ndb_local_table_info
*
info
,
Uint64
&
tupleId
,
Uint32
cacheSize
)
{
{
DBUG_ENTER
(
"getTupleIdFromNdb"
);
DBUG_ENTER
(
"Ndb::getTupleIdFromNdb"
);
Uint64
tupleId
;
if
(
info
->
m_first_tuple_id
!=
info
->
m_last_tuple_id
)
if
(
info
->
m_first_tuple_id
!=
info
->
m_last_tuple_id
)
{
{
assert
(
info
->
m_first_tuple_id
<
info
->
m_last_tuple_id
);
assert
(
info
->
m_first_tuple_id
<
info
->
m_last_tuple_id
);
...
@@ -816,32 +820,38 @@ Ndb::getTupleIdFromNdb(Ndb_local_table_info* info, Uint32 cacheSize)
...
@@ -816,32 +820,38 @@ Ndb::getTupleIdFromNdb(Ndb_local_table_info* info, Uint32 cacheSize)
* reserve next cacheSize entries in db. adds cacheSize to NEXTID
* reserve next cacheSize entries in db. adds cacheSize to NEXTID
* and returns first tupleId in the new range.
* and returns first tupleId in the new range.
*/
*/
tupleId
=
opTupleIdOnNdb
(
info
,
cacheSize
,
0
);
Uint64
opValue
=
cacheSize
;
if
(
opTupleIdOnNdb
(
info
,
opValue
,
0
)
==
-
1
)
DBUG_RETURN
(
-
1
);
tupleId
=
opValue
;
}
}
DBUG_RETURN
(
tupleId
);
DBUG_RETURN
(
0
);
}
}
Uint64
int
Ndb
::
readAutoIncrementValue
(
const
char
*
aTableName
)
Ndb
::
readAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
&
tupleId
)
{
{
DBUG_ENTER
(
"readAutoIncrementValue"
);
DBUG_ENTER
(
"
Ndb::
readAutoIncrementValue"
);
BaseString
internal_tabname
(
internalize_table_name
(
aTableName
));
BaseString
internal_tabname
(
internalize_table_name
(
aTableName
));
Ndb_local_table_info
*
info
=
Ndb_local_table_info
*
info
=
theDictionary
->
get_local_table_info
(
internal_tabname
,
false
);
theDictionary
->
get_local_table_info
(
internal_tabname
,
false
);
if
(
info
==
0
)
{
if
(
info
==
0
)
{
theError
.
code
=
theDictionary
->
getNdbError
().
code
;
theError
.
code
=
theDictionary
->
getNdbError
().
code
;
DBUG_RETURN
(
~
(
Uint64
)
0
);
DBUG_RETURN
(
-
1
);
}
}
Uint64
tupleId
=
readTupleIdFromNdb
(
info
);
if
(
readTupleIdFromNdb
(
info
,
tupleId
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_PRINT
(
"info"
,
(
"value %llu"
,
(
ulonglong
)
tupleId
));
DBUG_PRINT
(
"info"
,
(
"value %llu"
,
(
ulonglong
)
tupleId
));
DBUG_RETURN
(
tupleId
);
DBUG_RETURN
(
0
);
}
}
Uint64
int
Ndb
::
readAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
)
Ndb
::
readAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint64
&
tupleId
)
{
{
DBUG_ENTER
(
"readAutoIncrementValue"
);
DBUG_ENTER
(
"
Ndb::
readAutoIncrementValue"
);
assert
(
aTable
!=
0
);
assert
(
aTable
!=
0
);
const
NdbTableImpl
*
table
=
&
NdbTableImpl
::
getImpl
(
*
aTable
);
const
NdbTableImpl
*
table
=
&
NdbTableImpl
::
getImpl
(
*
aTable
);
const
BaseString
&
internal_tabname
=
table
->
m_internalName
;
const
BaseString
&
internal_tabname
=
table
->
m_internalName
;
...
@@ -850,18 +860,19 @@ Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable)
...
@@ -850,18 +860,19 @@ Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable)
theDictionary
->
get_local_table_info
(
internal_tabname
,
false
);
theDictionary
->
get_local_table_info
(
internal_tabname
,
false
);
if
(
info
==
0
)
{
if
(
info
==
0
)
{
theError
.
code
=
theDictionary
->
getNdbError
().
code
;
theError
.
code
=
theDictionary
->
getNdbError
().
code
;
DBUG_RETURN
(
~
(
Uint64
)
0
);
DBUG_RETURN
(
-
1
);
}
}
Uint64
tupleId
=
readTupleIdFromNdb
(
info
);
if
(
readTupleIdFromNdb
(
info
,
tupleId
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_PRINT
(
"info"
,
(
"value %llu"
,
(
ulonglong
)
tupleId
));
DBUG_PRINT
(
"info"
,
(
"value %llu"
,
(
ulonglong
)
tupleId
));
DBUG_RETURN
(
tupleId
);
DBUG_RETURN
(
0
);
}
}
Uint64
int
Ndb
::
readTupleIdFromNdb
(
Ndb_local_table_info
*
info
)
Ndb
::
readTupleIdFromNdb
(
Ndb_local_table_info
*
info
,
Uint64
&
tupleId
)
{
{
DBUG_ENTER
(
"Ndb::readTupleIdFromNdb"
);
DBUG_ENTER
(
"Ndb::readTupleIdFromNdb"
);
Uint64
tupleId
;
if
(
info
->
m_first_tuple_id
!=
info
->
m_last_tuple_id
)
if
(
info
->
m_first_tuple_id
!=
info
->
m_last_tuple_id
)
{
{
assert
(
info
->
m_first_tuple_id
<
info
->
m_last_tuple_id
);
assert
(
info
->
m_first_tuple_id
<
info
->
m_last_tuple_id
);
...
@@ -873,30 +884,37 @@ Ndb::readTupleIdFromNdb(Ndb_local_table_info* info)
...
@@ -873,30 +884,37 @@ Ndb::readTupleIdFromNdb(Ndb_local_table_info* info)
* peek at NEXTID. does not reserve it so the value is valid
* peek at NEXTID. does not reserve it so the value is valid
* only if no other transactions are allowed.
* only if no other transactions are allowed.
*/
*/
tupleId
=
opTupleIdOnNdb
(
info
,
0
,
3
);
Uint64
opValue
=
0
;
if
(
opTupleIdOnNdb
(
info
,
opValue
,
3
)
==
-
1
)
DBUG_RETURN
(
-
1
);
tupleId
=
opValue
;
}
}
DBUG_RETURN
(
tupleId
);
DBUG_RETURN
(
0
);
}
}
Uint64
int
Ndb
::
setAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
val
,
bool
increase
)
Ndb
::
setAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
tupleId
,
bool
increase
)
{
{
DBUG_ENTER
(
"setAutoIncrementValue"
);
DBUG_ENTER
(
"
Ndb::
setAutoIncrementValue"
);
BaseString
internal_tabname
(
internalize_table_name
(
aTableName
));
BaseString
internal_tabname
(
internalize_table_name
(
aTableName
));
Ndb_local_table_info
*
info
=
Ndb_local_table_info
*
info
=
theDictionary
->
get_local_table_info
(
internal_tabname
,
false
);
theDictionary
->
get_local_table_info
(
internal_tabname
,
false
);
if
(
info
==
0
)
{
if
(
info
==
0
)
{
theError
.
code
=
theDictionary
->
getNdbError
().
code
;
theError
.
code
=
theDictionary
->
getNdbError
().
code
;
DBUG_RETURN
(
~
(
Uint64
)
0
);
DBUG_RETURN
(
-
1
);
}
}
DBUG_RETURN
(
setTupleIdInNdb
(
info
,
val
,
increase
));
if
(
setTupleIdInNdb
(
info
,
tupleId
,
increase
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
0
);
}
}
Uint64
int
Ndb
::
setAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint64
val
,
bool
increase
)
Ndb
::
setAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint64
tupleId
,
bool
increase
)
{
{
DBUG_ENTER
(
"setAutoIncrementValue"
);
DBUG_ENTER
(
"
Ndb::
setAutoIncrementValue"
);
assert
(
aTable
!=
0
);
assert
(
aTable
!=
0
);
const
NdbTableImpl
*
table
=
&
NdbTableImpl
::
getImpl
(
*
aTable
);
const
NdbTableImpl
*
table
=
&
NdbTableImpl
::
getImpl
(
*
aTable
);
const
BaseString
&
internal_tabname
=
table
->
m_internalName
;
const
BaseString
&
internal_tabname
=
table
->
m_internalName
;
...
@@ -905,46 +923,54 @@ Ndb::setAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 val, bool
...
@@ -905,46 +923,54 @@ Ndb::setAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 val, bool
theDictionary
->
get_local_table_info
(
internal_tabname
,
false
);
theDictionary
->
get_local_table_info
(
internal_tabname
,
false
);
if
(
info
==
0
)
{
if
(
info
==
0
)
{
theError
.
code
=
theDictionary
->
getNdbError
().
code
;
theError
.
code
=
theDictionary
->
getNdbError
().
code
;
DBUG_RETURN
(
~
(
Uint64
)
0
);
DBUG_RETURN
(
-
1
);
}
}
DBUG_RETURN
(
setTupleIdInNdb
(
info
,
val
,
increase
));
if
(
setTupleIdInNdb
(
info
,
tupleId
,
increase
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
0
);
}
}
Uint64
int
Ndb
::
setTupleIdInNdb
(
Ndb_local_table_info
*
info
,
Uint64
val
,
bool
increase
)
Ndb
::
setTupleIdInNdb
(
Ndb_local_table_info
*
info
,
Uint64
tupleId
,
bool
increase
)
{
{
DBUG_ENTER
(
"setTupleIdInNdb"
);
DBUG_ENTER
(
"
Ndb::
setTupleIdInNdb"
);
if
(
increase
)
if
(
increase
)
{
{
if
(
info
->
m_first_tuple_id
!=
info
->
m_last_tuple_id
)
if
(
info
->
m_first_tuple_id
!=
info
->
m_last_tuple_id
)
{
{
assert
(
info
->
m_first_tuple_id
<
info
->
m_last_tuple_id
);
assert
(
info
->
m_first_tuple_id
<
info
->
m_last_tuple_id
);
if
(
val
<=
info
->
m_first_tuple_id
+
1
)
if
(
tupleId
<=
info
->
m_first_tuple_id
+
1
)
DBUG_RETURN
(
val
);
DBUG_RETURN
(
0
);
if
(
val
<=
info
->
m_last_tuple_id
)
if
(
tupleId
<=
info
->
m_last_tuple_id
)
{
{
info
->
m_first_tuple_id
=
val
-
1
;
info
->
m_first_tuple_id
=
tupleId
-
1
;
DBUG_PRINT
(
"info"
,
DBUG_PRINT
(
"info"
,
(
"Setting next auto increment cached value to %llu"
,
(
"Setting next auto increment cached value to %llu"
,
(
ulonglong
)
val
));
(
ulonglong
)
tupleId
));
DBUG_RETURN
(
val
);
DBUG_RETURN
(
0
);
}
}
}
}
/*
/*
* if
value
<= NEXTID, do nothing. otherwise update NEXTID to
* if
tupleId
<= NEXTID, do nothing. otherwise update NEXTID to
*
value and set cached range to first = last = value
- 1.
*
tupleId and set cached range to first = last = tupleId
- 1.
*/
*/
DBUG_RETURN
((
opTupleIdOnNdb
(
info
,
val
,
2
)));
if
(
opTupleIdOnNdb
(
info
,
tupleId
,
2
)
==
-
1
)
DBUG_RETURN
(
-
1
);
}
}
else
else
{
/*
/*
* update NEXTID to given value. reset cached range.
* update NEXTID to given value. reset cached range.
*/
*/
DBUG_RETURN
((
opTupleIdOnNdb
(
info
,
val
,
1
)));
if
(
opTupleIdOnNdb
(
info
,
tupleId
,
1
)
==
-
1
)
DBUG_RETURN
(
-
1
);
}
DBUG_RETURN
(
0
);
}
}
Uint64
int
Ndb
::
opTupleIdOnNdb
(
Ndb_local_table_info
*
info
,
Uint64
opValue
,
Uint32
op
)
Ndb
::
opTupleIdOnNdb
(
Ndb_local_table_info
*
info
,
Uint64
&
opValue
,
Uint32
op
)
{
{
DBUG_ENTER
(
"Ndb::opTupleIdOnNdb"
);
DBUG_ENTER
(
"Ndb::opTupleIdOnNdb"
);
Uint32
aTableId
=
info
->
m_table_impl
->
m_tableId
;
Uint32
aTableId
=
info
->
m_table_impl
->
m_tableId
;
...
@@ -954,7 +980,6 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
...
@@ -954,7 +980,6 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
NdbOperation
*
tOperation
=
0
;
// Compiler warning if not initialized
NdbOperation
*
tOperation
=
0
;
// Compiler warning if not initialized
Uint64
tValue
;
Uint64
tValue
;
NdbRecAttr
*
tRecAttrResult
;
NdbRecAttr
*
tRecAttrResult
;
Uint64
ret
=
~
(
Uint64
)
0
;
CHECK_STATUS_MACRO_ZERO
;
CHECK_STATUS_MACRO_ZERO
;
...
@@ -989,7 +1014,7 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
...
@@ -989,7 +1014,7 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
info
->
m_first_tuple_id
=
tValue
-
opValue
;
info
->
m_first_tuple_id
=
tValue
-
opValue
;
info
->
m_last_tuple_id
=
tValue
-
1
;
info
->
m_last_tuple_id
=
tValue
-
1
;
ret
=
info
->
m_first_tuple_id
;
opValue
=
info
->
m_first_tuple_id
;
// out
break
;
break
;
case
1
:
case
1
:
// create on first use
// create on first use
...
@@ -1002,7 +1027,6 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
...
@@ -1002,7 +1027,6 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
info
->
m_first_tuple_id
=
~
(
Uint64
)
0
;
info
->
m_first_tuple_id
=
~
(
Uint64
)
0
;
info
->
m_last_tuple_id
=
~
(
Uint64
)
0
;
info
->
m_last_tuple_id
=
~
(
Uint64
)
0
;
ret
=
opValue
;
break
;
break
;
case
2
:
case
2
:
tOperation
->
interpretedUpdateTuple
();
tOperation
->
interpretedUpdateTuple
();
...
@@ -1020,7 +1044,6 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
...
@@ -1020,7 +1044,6 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
{
{
if
(
tConnection
->
theError
.
code
!=
9999
)
if
(
tConnection
->
theError
.
code
!=
9999
)
goto
error_handler
;
goto
error_handler
;
ret
=
opValue
;
}
}
else
else
{
{
...
@@ -1028,7 +1051,6 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
...
@@ -1028,7 +1051,6 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
(
"Setting next auto increment value (db) to %llu"
,
(
"Setting next auto increment value (db) to %llu"
,
(
ulonglong
)
opValue
));
(
ulonglong
)
opValue
));
info
->
m_first_tuple_id
=
info
->
m_last_tuple_id
=
opValue
-
1
;
info
->
m_first_tuple_id
=
info
->
m_last_tuple_id
=
opValue
-
1
;
ret
=
opValue
;
}
}
break
;
break
;
case
3
:
case
3
:
...
@@ -1037,7 +1059,7 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
...
@@ -1037,7 +1059,7 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
tRecAttrResult
=
tOperation
->
getValue
(
"NEXTID"
);
tRecAttrResult
=
tOperation
->
getValue
(
"NEXTID"
);
if
(
tConnection
->
execute
(
Commit
)
==
-
1
)
if
(
tConnection
->
execute
(
Commit
)
==
-
1
)
goto
error_handler
;
goto
error_handler
;
ret
=
tRecAttrResult
->
u_64_value
();
opValue
=
tRecAttrResult
->
u_64_value
();
// out
break
;
break
;
default:
default:
goto
error_handler
;
goto
error_handler
;
...
@@ -1049,7 +1071,7 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
...
@@ -1049,7 +1071,7 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
setDatabaseName
(
currentDb
.
c_str
());
setDatabaseName
(
currentDb
.
c_str
());
setDatabaseSchemaName
(
currentSchema
.
c_str
());
setDatabaseSchemaName
(
currentSchema
.
c_str
());
DBUG_RETURN
(
ret
);
DBUG_RETURN
(
0
);
error_handler:
error_handler:
theError
.
code
=
tConnection
->
theError
.
code
;
theError
.
code
=
tConnection
->
theError
.
code
;
...
@@ -1063,7 +1085,7 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
...
@@ -1063,7 +1085,7 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op)
theError
.
code
,
theError
.
code
,
tConnection
?
tConnection
->
theError
.
code
:
-
1
,
tConnection
?
tConnection
->
theError
.
code
:
-
1
,
tOperation
?
tOperation
->
theError
.
code
:
-
1
));
tOperation
?
tOperation
->
theError
.
code
:
-
1
));
DBUG_RETURN
(
~
(
Uint64
)
0
);
DBUG_RETURN
(
-
1
);
}
}
Uint32
Uint32
...
...
ndb/src/ndbapi/NdbDictionaryImpl.cpp
View file @
54963c2e
...
@@ -1743,7 +1743,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
...
@@ -1743,7 +1743,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
if
(
haveAutoIncrement
)
{
if
(
haveAutoIncrement
)
{
if
(
ndb
.
setAutoIncrementValue
(
impl
.
m_externalName
.
c_str
(),
if
(
ndb
.
setAutoIncrementValue
(
impl
.
m_externalName
.
c_str
(),
autoIncrementValue
)
==
~
(
Uint64
)
0
)
{
autoIncrementValue
,
false
)
==
-
1
)
{
DBUG_ASSERT
(
ndb
.
theError
.
code
!=
0
);
DBUG_ASSERT
(
ndb
.
theError
.
code
!=
0
);
m_error
=
ndb
.
theError
;
m_error
=
ndb
.
theError
;
ret
=
-
1
;
ret
=
-
1
;
...
...
ndb/test/ndbapi/testDict.cpp
View file @
54963c2e
...
@@ -1139,9 +1139,13 @@ runCreateAutoincrementTable(NDBT_Context* ctx, NDBT_Step* step){
...
@@ -1139,9 +1139,13 @@ runCreateAutoincrementTable(NDBT_Context* ctx, NDBT_Step* step){
for
(
int
i
=
0
;
i
<
16
;
i
++
)
{
for
(
int
i
=
0
;
i
<
16
;
i
++
)
{
Uint64
value
=
myNdb
->
getAutoIncrementValue
(
tabname
,
1
);
Uint64
value
;
if
(
myNdb
->
getAutoIncrementValue
(
tabname
,
value
,
1
)
==
-
1
)
{
if
(
value
!=
(
startvalue
+
i
))
{
g_err
<<
"getAutoIncrementValue failed on "
<<
tabname
<<
endl
;
APIERROR
(
myNdb
->
getNdbError
());
return
NDBT_FAILED
;
}
else
if
(
value
!=
(
startvalue
+
i
))
{
g_err
<<
"value = "
<<
value
<<
" expected "
<<
startvalue
+
i
<<
endl
;;
g_err
<<
"value = "
<<
value
<<
" expected "
<<
startvalue
+
i
<<
endl
;;
APIERROR
(
myNdb
->
getNdbError
());
APIERROR
(
myNdb
->
getNdbError
());
// ret = NDBT_FAILED;
// ret = NDBT_FAILED;
...
...
ndb/tools/restore/consumer_restore.cpp
View file @
54963c2e
...
@@ -148,9 +148,12 @@ BackupRestore::finalize_table(const TableS & table){
...
@@ -148,9 +148,12 @@ BackupRestore::finalize_table(const TableS & table){
if
(
table
.
have_auto_inc
())
if
(
table
.
have_auto_inc
())
{
{
Uint64
max_val
=
table
.
get_max_auto_val
();
Uint64
max_val
=
table
.
get_max_auto_val
();
Uint64
auto_val
=
m_ndb
->
readAutoIncrementValue
(
get_table
(
table
.
m_dictTable
));
Uint64
auto_val
;
if
(
max_val
+
1
>
auto_val
||
auto_val
==
~
(
Uint64
)
0
)
int
r
=
m_ndb
->
readAutoIncrementValue
(
get_table
(
table
.
m_dictTable
),
auto_val
);
ret
=
m_ndb
->
setAutoIncrementValue
(
get_table
(
table
.
m_dictTable
),
max_val
+
1
,
false
)
!=
~
(
Uint64
)
0
;
if
(
r
==
-
1
&&
m_ndb
->
getNdbError
().
code
!=
626
)
ret
=
false
;
else
if
(
r
==
-
1
||
max_val
+
1
>
auto_val
)
ret
=
m_ndb
->
setAutoIncrementValue
(
get_table
(
table
.
m_dictTable
),
max_val
+
1
,
false
)
!=
-
1
;
}
}
return
ret
;
return
ret
;
}
}
...
...
sql/ha_ndbcluster.cc
View file @
54963c2e
...
@@ -73,7 +73,6 @@ handlerton ndbcluster_hton = {
...
@@ -73,7 +73,6 @@ handlerton ndbcluster_hton = {
HTON_NO_FLAGS
HTON_NO_FLAGS
};
};
#define NDB_FAILED_AUTO_INCREMENT ~(Uint64)0
#define NDB_AUTO_INCREMENT_RETRIES 10
#define NDB_AUTO_INCREMENT_RETRIES 10
#define NDB_INVALID_SCHEMA_OBJECT 241
#define NDB_INVALID_SCHEMA_OBJECT 241
...
@@ -2112,14 +2111,15 @@ int ha_ndbcluster::write_row(byte *record)
...
@@ -2112,14 +2111,15 @@ int ha_ndbcluster::write_row(byte *record)
{
{
// Table has hidden primary key
// Table has hidden primary key
Ndb
*
ndb
=
get_ndb
();
Ndb
*
ndb
=
get_ndb
();
Uint64
auto_value
=
NDB_FAILED_AUTO_INCREMENT
;
int
ret
;
Uint64
auto_value
;
uint
retries
=
NDB_AUTO_INCREMENT_RETRIES
;
uint
retries
=
NDB_AUTO_INCREMENT_RETRIES
;
do
{
do
{
auto_value
=
ndb
->
getAutoIncrementValue
((
const
NDBTAB
*
)
m_table
);
ret
=
ndb
->
getAutoIncrementValue
((
const
NDBTAB
*
)
m_table
,
auto_value
,
1
);
}
while
(
auto_value
==
NDB_FAILED_AUTO_INCREMENT
&&
}
while
(
ret
==
-
1
&&
--
retries
&&
--
retries
&&
ndb
->
getNdbError
().
status
==
NdbError
::
TemporaryError
);
ndb
->
getNdbError
().
status
==
NdbError
::
TemporaryError
);
if
(
auto_value
==
NDB_FAILED_AUTO_INCREMENT
)
if
(
ret
==
-
1
)
ERR_RETURN
(
ndb
->
getNdbError
());
ERR_RETURN
(
ndb
->
getNdbError
());
if
(
set_hidden_key
(
op
,
table
->
s
->
fields
,
(
const
byte
*
)
&
auto_value
))
if
(
set_hidden_key
(
op
,
table
->
s
->
fields
,
(
const
byte
*
)
&
auto_value
))
ERR_RETURN
(
op
->
getNdbError
());
ERR_RETURN
(
op
->
getNdbError
());
...
@@ -2200,7 +2200,7 @@ int ha_ndbcluster::write_row(byte *record)
...
@@ -2200,7 +2200,7 @@ int ha_ndbcluster::write_row(byte *record)
(
"Trying to set next auto increment value to %llu"
,
(
"Trying to set next auto increment value to %llu"
,
(
ulonglong
)
next_val
));
(
ulonglong
)
next_val
));
if
(
ndb
->
setAutoIncrementValue
((
const
NDBTAB
*
)
m_table
,
next_val
,
TRUE
)
if
(
ndb
->
setAutoIncrementValue
((
const
NDBTAB
*
)
m_table
,
next_val
,
TRUE
)
==
~
(
Uint64
)
0
)
==
-
1
)
ERR_RETURN
(
ndb
->
getNdbError
());
ERR_RETURN
(
ndb
->
getNdbError
());
}
}
m_skip_auto_increment
=
TRUE
;
m_skip_auto_increment
=
TRUE
;
...
@@ -3047,8 +3047,14 @@ void ha_ndbcluster::info(uint flag)
...
@@ -3047,8 +3047,14 @@ void ha_ndbcluster::info(uint flag)
{
{
Ndb
*
ndb
=
get_ndb
();
Ndb
*
ndb
=
get_ndb
();
auto_increment_value
=
if
(
ndb
->
readAutoIncrementValue
((
const
NDBTAB
*
)
m_table
,
ndb
->
readAutoIncrementValue
((
const
NDBTAB
*
)
m_table
);
auto_increment_value
)
==
-
1
)
{
const
NdbError
err
=
ndb
->
getNdbError
();
sql_print_error
(
"Error %lu in readAutoIncrementValue(): %s"
,
(
ulong
)
err
.
code
,
err
.
message
);
auto_increment_value
=
~
(
Uint64
)
0
;
}
}
}
}
}
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
...
@@ -4360,17 +4366,17 @@ ulonglong ha_ndbcluster::get_auto_increment()
...
@@ -4360,17 +4366,17 @@ ulonglong ha_ndbcluster::get_auto_increment()
m_rows_to_insert
-
m_rows_inserted
:
m_rows_to_insert
-
m_rows_inserted
:
((
m_rows_to_insert
>
m_autoincrement_prefetch
)
?
((
m_rows_to_insert
>
m_autoincrement_prefetch
)
?
m_rows_to_insert
:
m_autoincrement_prefetch
));
m_rows_to_insert
:
m_autoincrement_prefetch
));
auto_value
=
NDB_FAILED_AUTO_INCREMENT
;
int
ret
;
uint
retries
=
NDB_AUTO_INCREMENT_RETRIES
;
uint
retries
=
NDB_AUTO_INCREMENT_RETRIES
;
do
{
do
{
auto_value
=
ret
=
(
m_skip_auto_increment
)
?
m_skip_auto_increment
?
ndb
->
readAutoIncrementValue
((
const
NDBTAB
*
)
m_table
)
ndb
->
readAutoIncrementValue
((
const
NDBTAB
*
)
m_table
,
auto_value
)
:
:
ndb
->
getAutoIncrementValue
((
const
NDBTAB
*
)
m_tabl
e
,
cache_size
);
ndb
->
getAutoIncrementValue
((
const
NDBTAB
*
)
m_table
,
auto_valu
e
,
cache_size
);
}
while
(
auto_value
==
NDB_FAILED_AUTO_INCREMENT
&&
}
while
(
ret
==
-
1
&&
--
retries
&&
--
retries
&&
ndb
->
getNdbError
().
status
==
NdbError
::
TemporaryError
);
ndb
->
getNdbError
().
status
==
NdbError
::
TemporaryError
);
if
(
auto_value
==
NDB_FAILED_AUTO_INCREMENT
)
if
(
ret
==
-
1
)
{
{
const
NdbError
err
=
ndb
->
getNdbError
();
const
NdbError
err
=
ndb
->
getNdbError
();
sql_print_error
(
"Error %lu in ::get_auto_increment(): %s"
,
sql_print_error
(
"Error %lu in ::get_auto_increment(): %s"
,
...
...
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