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
9ad3721e
Commit
9ad3721e
authored
May 28, 2007
by
mskold/marty@linux.site
Browse files
Options
Browse Files
Download
Plain Diff
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-5.1-ndb
into mysql.com:/windows/Linux_space/MySQL/mysql-5.1-new-ndb
parents
4b748502
11e98f41
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
385 additions
and
30 deletions
+385
-30
mysql-test/r/ndb_insert.result
mysql-test/r/ndb_insert.result
+169
-0
mysql-test/t/ndb_insert.test
mysql-test/t/ndb_insert.test
+137
-0
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.cc
+2
-2
storage/ndb/include/ndbapi/Ndb.hpp
storage/ndb/include/ndbapi/Ndb.hpp
+7
-4
storage/ndb/src/ndbapi/Ndb.cpp
storage/ndb/src/ndbapi/Ndb.cpp
+70
-24
No files found.
mysql-test/r/ndb_insert.result
View file @
9ad3721e
...
...
@@ -657,3 +657,172 @@ a b
2 NULL
3 NULL
drop table t1;
CREATE TABLE t1 (
pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
b INT NOT NULL,
c INT NOT NULL UNIQUE
) ENGINE=NDBCLUSTER;
CREATE TABLE t2 (
pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
b INT NOT NULL,
c INT NOT NULL UNIQUE
) ENGINE=MYISAM;
SET @@session.auto_increment_increment=10;
INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
SELECT * FROM t1 ORDER BY pk;
pk b c
1 1 0
11 2 1
21 3 2
SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
COUNT(t1.pk)
3
TRUNCATE t1;
TRUNCATE t2;
SET @@session.auto_increment_offset=5;
INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
INSERT INTO t1 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6);
INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
INSERT INTO t2 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6);
SELECT * FROM t1 ORDER BY pk;
pk b c
5 1 0
15 2 1
25 3 2
27 4 3
35 5 4
99 6 5
105 7 6
SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
COUNT(t1.pk)
7
TRUNCATE t1;
TRUNCATE t2;
SET @@session.auto_increment_increment=2;
INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
SELECT * FROM t1 ORDER BY pk;
pk b c
1 1 0
3 2 1
5 3 2
SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
COUNT(t1.pk)
3
DROP TABLE t1, t2;
CREATE TABLE t1 (
pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
b INT NOT NULL,
c INT NOT NULL UNIQUE
) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7;
CREATE TABLE t2 (
pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
b INT NOT NULL,
c INT NOT NULL UNIQUE
) ENGINE=MYISAM AUTO_INCREMENT = 7;
SET @@session.auto_increment_offset=1;
SET @@session.auto_increment_increment=1;
INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
SELECT * FROM t1 ORDER BY pk;
pk b c
7 1 0
8 2 1
9 3 2
SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
COUNT(t1.pk)
3
DROP TABLE t1, t2;
CREATE TABLE t1 (
pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
b INT NOT NULL,
c INT NOT NULL UNIQUE
) ENGINE=NDBCLUSTER AUTO_INCREMENT = 3;
CREATE TABLE t2 (
pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
b INT NOT NULL,
c INT NOT NULL UNIQUE
) ENGINE=MYISAM AUTO_INCREMENT = 3;
SET @@session.auto_increment_offset=5;
SET @@session.auto_increment_increment=10;
INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
SELECT * FROM t1 ORDER BY pk;
pk b c
5 1 0
15 2 1
25 3 2
SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
COUNT(t1.pk)
3
DROP TABLE t1, t2;
CREATE TABLE t1 (
pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
b INT NOT NULL,
c INT NOT NULL UNIQUE
) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7;
CREATE TABLE t2 (
pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
b INT NOT NULL,
c INT NOT NULL UNIQUE
) ENGINE=MYISAM AUTO_INCREMENT = 7;
SET @@session.auto_increment_offset=5;
SET @@session.auto_increment_increment=10;
INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
SELECT * FROM t1 ORDER BY pk;
pk b c
15 1 0
25 2 1
35 3 2
SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
COUNT(t1.pk)
3
DROP TABLE t1, t2;
CREATE TABLE t1 (
pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
b INT NOT NULL,
c INT NOT NULL UNIQUE
) ENGINE=NDBCLUSTER AUTO_INCREMENT = 5;
CREATE TABLE t2 (
pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
b INT NOT NULL,
c INT NOT NULL UNIQUE
) ENGINE=MYISAM AUTO_INCREMENT = 5;
SET @@session.auto_increment_offset=5;
SET @@session.auto_increment_increment=10;
INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
SELECT * FROM t1 ORDER BY pk;
pk b c
5 1 0
15 2 1
25 3 2
SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
COUNT(t1.pk)
3
DROP TABLE t1, t2;
CREATE TABLE t1 (
pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
b INT NOT NULL,
c INT NOT NULL UNIQUE
) ENGINE=NDBCLUSTER AUTO_INCREMENT = 100;
CREATE TABLE t2 (
pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
b INT NOT NULL,
c INT NOT NULL UNIQUE
) ENGINE=MYISAM AUTO_INCREMENT = 100;
SET @@session.auto_increment_offset=5;
SET @@session.auto_increment_increment=10;
INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
SELECT * FROM t1 ORDER BY pk;
pk b c
105 1 0
115 2 1
125 3 2
SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
COUNT(t1.pk)
3
DROP TABLE t1, t2;
mysql-test/t/ndb_insert.test
View file @
9ad3721e
...
...
@@ -639,4 +639,141 @@ insert ignore into t1 values (1,0), (2,0), (2,null), (3,null);
select
*
from
t1
order
by
a
;
drop
table
t1
;
# Bug#26342 auto_increment_increment AND auto_increment_offset REALLY REALLY anger NDB cluster
CREATE
TABLE
t1
(
pk
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
UNIQUE
)
ENGINE
=
NDBCLUSTER
;
CREATE
TABLE
t2
(
pk
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
UNIQUE
)
ENGINE
=
MYISAM
;
SET
@@
session
.
auto_increment_increment
=
10
;
INSERT
INTO
t1
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
INSERT
INTO
t2
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
SELECT
*
FROM
t1
ORDER
BY
pk
;
SELECT
COUNT
(
t1
.
pk
)
FROM
t1
,
t2
WHERE
t1
.
pk
=
t2
.
pk
AND
t1
.
b
=
t2
.
b
AND
t1
.
c
=
t1
.
c
;
TRUNCATE
t1
;
TRUNCATE
t2
;
SET
@@
session
.
auto_increment_offset
=
5
;
INSERT
INTO
t1
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
INSERT
INTO
t1
(
pk
,
b
,
c
)
VALUES
(
27
,
4
,
3
),(
NULL
,
5
,
4
),(
99
,
6
,
5
),(
NULL
,
7
,
6
);
INSERT
INTO
t2
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
INSERT
INTO
t2
(
pk
,
b
,
c
)
VALUES
(
27
,
4
,
3
),(
NULL
,
5
,
4
),(
99
,
6
,
5
),(
NULL
,
7
,
6
);
SELECT
*
FROM
t1
ORDER
BY
pk
;
SELECT
COUNT
(
t1
.
pk
)
FROM
t1
,
t2
WHERE
t1
.
pk
=
t2
.
pk
AND
t1
.
b
=
t2
.
b
AND
t1
.
c
=
t1
.
c
;
TRUNCATE
t1
;
TRUNCATE
t2
;
SET
@@
session
.
auto_increment_increment
=
2
;
INSERT
INTO
t1
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
INSERT
INTO
t2
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
SELECT
*
FROM
t1
ORDER
BY
pk
;
SELECT
COUNT
(
t1
.
pk
)
FROM
t1
,
t2
WHERE
t1
.
pk
=
t2
.
pk
AND
t1
.
b
=
t2
.
b
AND
t1
.
c
=
t1
.
c
;
DROP
TABLE
t1
,
t2
;
CREATE
TABLE
t1
(
pk
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
UNIQUE
)
ENGINE
=
NDBCLUSTER
AUTO_INCREMENT
=
7
;
CREATE
TABLE
t2
(
pk
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
UNIQUE
)
ENGINE
=
MYISAM
AUTO_INCREMENT
=
7
;
SET
@@
session
.
auto_increment_offset
=
1
;
SET
@@
session
.
auto_increment_increment
=
1
;
INSERT
INTO
t1
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
INSERT
INTO
t2
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
SELECT
*
FROM
t1
ORDER
BY
pk
;
SELECT
COUNT
(
t1
.
pk
)
FROM
t1
,
t2
WHERE
t1
.
pk
=
t2
.
pk
AND
t1
.
b
=
t2
.
b
AND
t1
.
c
=
t1
.
c
;
DROP
TABLE
t1
,
t2
;
CREATE
TABLE
t1
(
pk
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
UNIQUE
)
ENGINE
=
NDBCLUSTER
AUTO_INCREMENT
=
3
;
CREATE
TABLE
t2
(
pk
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
UNIQUE
)
ENGINE
=
MYISAM
AUTO_INCREMENT
=
3
;
SET
@@
session
.
auto_increment_offset
=
5
;
SET
@@
session
.
auto_increment_increment
=
10
;
INSERT
INTO
t1
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
INSERT
INTO
t2
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
SELECT
*
FROM
t1
ORDER
BY
pk
;
SELECT
COUNT
(
t1
.
pk
)
FROM
t1
,
t2
WHERE
t1
.
pk
=
t2
.
pk
AND
t1
.
b
=
t2
.
b
AND
t1
.
c
=
t1
.
c
;
DROP
TABLE
t1
,
t2
;
CREATE
TABLE
t1
(
pk
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
UNIQUE
)
ENGINE
=
NDBCLUSTER
AUTO_INCREMENT
=
7
;
CREATE
TABLE
t2
(
pk
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
UNIQUE
)
ENGINE
=
MYISAM
AUTO_INCREMENT
=
7
;
SET
@@
session
.
auto_increment_offset
=
5
;
SET
@@
session
.
auto_increment_increment
=
10
;
INSERT
INTO
t1
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
INSERT
INTO
t2
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
SELECT
*
FROM
t1
ORDER
BY
pk
;
SELECT
COUNT
(
t1
.
pk
)
FROM
t1
,
t2
WHERE
t1
.
pk
=
t2
.
pk
AND
t1
.
b
=
t2
.
b
AND
t1
.
c
=
t1
.
c
;
DROP
TABLE
t1
,
t2
;
CREATE
TABLE
t1
(
pk
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
UNIQUE
)
ENGINE
=
NDBCLUSTER
AUTO_INCREMENT
=
5
;
CREATE
TABLE
t2
(
pk
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
UNIQUE
)
ENGINE
=
MYISAM
AUTO_INCREMENT
=
5
;
SET
@@
session
.
auto_increment_offset
=
5
;
SET
@@
session
.
auto_increment_increment
=
10
;
INSERT
INTO
t1
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
INSERT
INTO
t2
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
SELECT
*
FROM
t1
ORDER
BY
pk
;
SELECT
COUNT
(
t1
.
pk
)
FROM
t1
,
t2
WHERE
t1
.
pk
=
t2
.
pk
AND
t1
.
b
=
t2
.
b
AND
t1
.
c
=
t1
.
c
;
DROP
TABLE
t1
,
t2
;
CREATE
TABLE
t1
(
pk
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
UNIQUE
)
ENGINE
=
NDBCLUSTER
AUTO_INCREMENT
=
100
;
CREATE
TABLE
t2
(
pk
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
UNIQUE
)
ENGINE
=
MYISAM
AUTO_INCREMENT
=
100
;
SET
@@
session
.
auto_increment_offset
=
5
;
SET
@@
session
.
auto_increment_increment
=
10
;
INSERT
INTO
t1
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
INSERT
INTO
t2
(
b
,
c
)
VALUES
(
1
,
0
),(
2
,
1
),(
3
,
2
);
SELECT
*
FROM
t1
ORDER
BY
pk
;
SELECT
COUNT
(
t1
.
pk
)
FROM
t1
,
t2
WHERE
t1
.
pk
=
t2
.
pk
AND
t1
.
b
=
t2
.
b
AND
t1
.
c
=
t1
.
c
;
DROP
TABLE
t1
,
t2
;
# End of 4.1 tests
sql/ha_ndbcluster.cc
View file @
9ad3721e
...
...
@@ -6035,7 +6035,7 @@ void ha_ndbcluster::get_auto_increment(ulonglong offset, ulonglong increment,
ulonglong
nb_desired_values
,
ulonglong
*
first_value
,
ulonglong
*
nb_reserved_values
)
{
{
int
cache_size
;
Uint64
auto_value
;
DBUG_ENTER
(
"get_auto_increment"
);
...
...
@@ -6059,7 +6059,7 @@ void ha_ndbcluster::get_auto_increment(ulonglong offset, ulonglong increment,
Ndb_tuple_id_range_guard
g
(
m_share
);
if
(
m_skip_auto_increment
&&
ndb
->
readAutoIncrementValue
(
m_table
,
g
.
range
,
auto_value
)
||
ndb
->
getAutoIncrementValue
(
m_table
,
g
.
range
,
auto_value
,
cache_size
))
ndb
->
getAutoIncrementValue
(
m_table
,
g
.
range
,
auto_value
,
cache_size
,
increment
,
offset
))
{
if
(
--
retries
&&
ndb
->
getNdbError
().
status
==
NdbError
::
TemporaryError
);
...
...
storage/ndb/include/ndbapi/Ndb.hpp
View file @
9ad3721e
...
...
@@ -1488,12 +1488,15 @@ public:
int
initAutoIncrement
();
int
getAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
&
tupleId
,
Uint32
cacheSize
);
Uint64
&
tupleId
,
Uint32
cacheSize
,
Uint64
step
=
1
,
Uint64
start
=
1
);
int
getAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint64
&
tupleId
,
Uint32
cacheSize
);
Uint64
&
tupleId
,
Uint32
cacheSize
,
Uint64
step
=
1
,
Uint64
start
=
1
);
int
getAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
TupleIdRange
&
range
,
Uint64
&
tupleId
,
Uint32
cacheSize
);
Uint32
cacheSize
,
Uint64
step
=
1
,
Uint64
start
=
1
);
int
readAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
&
tupleId
);
int
readAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
...
...
@@ -1510,7 +1513,7 @@ public:
private:
int
getTupleIdFromNdb
(
const
NdbTableImpl
*
table
,
TupleIdRange
&
range
,
Uint64
&
tupleId
,
Uint32
cacheSize
);
Uint32
cacheSize
,
Uint64
step
=
1
,
Uint64
start
=
1
);
int
readTupleIdFromNdb
(
const
NdbTableImpl
*
table
,
TupleIdRange
&
range
,
Uint64
&
tupleId
);
int
setTupleIdInNdb
(
const
NdbTableImpl
*
table
,
...
...
storage/ndb/src/ndbapi/Ndb.cpp
View file @
9ad3721e
...
...
@@ -754,17 +754,27 @@ Ndb::getNodeId()
}
/****************************************************************************
Uint64 getTupleIdFromNdb( Uint32 aTableId, Uint32 cacheSize );
Parameters: aTableId : The TableId.
cacheSize: Prefetch this many values
Remark: Returns a new TupleId to the application.
The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId.
It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp.
Uint64 getAutoIncrementValue( const char* aTableName,
Uint64 & autoValue,
Uint32 cacheSize,
Uint64 step,
Uint64 start);
Parameters: aTableName (IN) : The table name.
autoValue (OUT) : Returns new autoincrement value
cacheSize (IN) : Prefetch this many values
step (IN) : Specifies the step between the
autoincrement values.
start (IN) : Start value for first value
Remark: Returns a new autoincrement value to the application.
The autoincrement values can be increased by steps
(default 1) and a number of values can be prefetched
by specifying cacheSize (default 10).
****************************************************************************/
int
Ndb
::
getAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
&
tupleId
,
Uint32
cacheSize
)
Uint64
&
autoValue
,
Uint32
cacheSize
,
Uint64
step
,
Uint64
start
)
{
DBUG_ENTER
(
"Ndb::getAutoIncrementValue"
);
ASSERT_NOT_MYSQLD
;
...
...
@@ -778,15 +788,16 @@ Ndb::getAutoIncrementValue(const char* aTableName,
}
const
NdbTableImpl
*
table
=
info
->
m_table_impl
;
TupleIdRange
&
range
=
info
->
m_tuple_id_range
;
if
(
getTupleIdFromNdb
(
table
,
range
,
tupleId
,
cacheSize
)
==
-
1
)
if
(
getTupleIdFromNdb
(
table
,
range
,
autoValue
,
cacheSize
,
step
,
start
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_PRINT
(
"info"
,
(
"value %lu"
,
(
ulong
)
tupleId
));
DBUG_PRINT
(
"info"
,
(
"value %lu"
,
(
ulong
)
autoValue
));
DBUG_RETURN
(
0
);
}
int
Ndb
::
getAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
Uint64
&
tupleId
,
Uint32
cacheSize
)
Uint64
&
autoValue
,
Uint32
cacheSize
,
Uint64
step
,
Uint64
start
)
{
DBUG_ENTER
(
"Ndb::getAutoIncrementValue"
);
ASSERT_NOT_MYSQLD
;
...
...
@@ -801,51 +812,86 @@ Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable,
DBUG_RETURN
(
-
1
);
}
TupleIdRange
&
range
=
info
->
m_tuple_id_range
;
if
(
getTupleIdFromNdb
(
table
,
range
,
tupleId
,
cacheSize
)
==
-
1
)
if
(
getTupleIdFromNdb
(
table
,
range
,
autoValue
,
cacheSize
,
step
,
start
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_PRINT
(
"info"
,
(
"value %lu"
,
(
ulong
)
tupleId
));
DBUG_PRINT
(
"info"
,
(
"value %lu"
,
(
ulong
)
autoValue
));
DBUG_RETURN
(
0
);
}
int
Ndb
::
getAutoIncrementValue
(
const
NdbDictionary
::
Table
*
aTable
,
TupleIdRange
&
range
,
Uint64
&
tupleId
,
Uint32
cacheSize
)
TupleIdRange
&
range
,
Uint64
&
autoValue
,
Uint32
cacheSize
,
Uint64
step
,
Uint64
start
)
{
DBUG_ENTER
(
"Ndb::getAutoIncrementValue"
);
assert
(
aTable
!=
0
);
const
NdbTableImpl
*
table
=
&
NdbTableImpl
::
getImpl
(
*
aTable
);
if
(
getTupleIdFromNdb
(
table
,
range
,
tupleId
,
cacheSize
)
==
-
1
)
if
(
getTupleIdFromNdb
(
table
,
range
,
autoValue
,
cacheSize
,
step
,
start
)
==
-
1
)
DBUG_RETURN
(
-
1
);
DBUG_PRINT
(
"info"
,
(
"value %lu"
,
(
ulong
)
tupleId
));
DBUG_PRINT
(
"info"
,
(
"value %lu"
,
(
ulong
)
autoValue
));
DBUG_RETURN
(
0
);
}
int
Ndb
::
getTupleIdFromNdb
(
const
NdbTableImpl
*
table
,
TupleIdRange
&
range
,
Uint64
&
tupleId
,
Uint32
cacheSize
)
TupleIdRange
&
range
,
Uint64
&
tupleId
,
Uint32
cacheSize
,
Uint64
step
,
Uint64
start
)
{
/*
Returns a new TupleId to the application.
The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId.
It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp.
In most cases step= start= 1, in which case we get:
1,2,3,4,5,...
If step=10 and start=5 and first number is 1, we get:
5,15,25,35,...
*/
DBUG_ENTER
(
"Ndb::getTupleIdFromNdb"
);
if
(
range
.
m_first_tuple_id
!=
range
.
m_last_tuple_id
)
/*
Check if the next value can be taken from the pre-fetched
sequence.
*/
if
(
range
.
m_first_tuple_id
!=
range
.
m_last_tuple_id
&&
range
.
m_first_tuple_id
+
step
<=
range
.
m_last_tuple_id
)
{
assert
(
range
.
m_first_tuple_id
<
range
.
m_last_tuple_id
);
tupleId
=
++
range
.
m_first_tuple_id
;
DBUG_PRINT
(
"info"
,
(
"next cached value %lu"
,
(
ulong
)
tupleId
));
range
.
m_first_tuple_id
+=
step
;
tupleId
=
range
.
m_first_tuple_id
;
DBUG_PRINT
(
"info"
,
(
"Next cached value %lu"
,
(
ulong
)
tupleId
));
}
else
{
/*
If start value is greater than step it is ignored
*/
Uint64
offset
=
(
start
>
step
)
?
1
:
start
;
/*
Pre-fetch a number of values depending on cacheSize
*/
if
(
cacheSize
==
0
)
cacheSize
=
1
;
DBUG_PRINT
(
"info"
,
(
"reading %u values from database"
,
(
uint
)
cacheSize
));
/*
* 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. If tupleId's are
* incremented in steps then multiply the cacheSize with step size.
*/
Uint64
opValue
=
cacheSize
;
Uint64
opValue
=
cacheSize
*
step
;
if
(
opTupleIdOnNdb
(
table
,
range
,
opValue
,
0
)
==
-
1
)
DBUG_RETURN
(
-
1
);
tupleId
=
opValue
;
DBUG_PRINT
(
"info"
,
(
"Next value fetched from database %lu"
,
(
ulong
)
opValue
));
DBUG_PRINT
(
"info"
,
(
"Increasing %lu by offset %lu, increment is %lu"
,
(
ulong
)
(
ulong
)
opValue
,
(
ulong
)
offset
,
(
ulong
)
step
));
Uint64
current
,
next
;
next
=
((
Uint64
)
(
opValue
+
step
-
offset
))
/
step
;
next
=
next
*
step
+
offset
;
current
=
(
next
<
step
)
?
next
:
next
-
step
;
tupleId
=
(
opValue
<=
current
)
?
current
:
next
;
DBUG_PRINT
(
"info"
,
(
"Returning %lu"
,
(
ulong
)
tupleId
));
range
.
m_first_tuple_id
=
tupleId
;
}
DBUG_RETURN
(
0
);
}
...
...
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