mirror of
https://github.com/MariaDB/server.git
synced 2025-09-02 09:41:40 +03:00
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-5.1-ndb
into mysql.com:/windows/Linux_space/MySQL/mysql-5.1-new-ndb
This commit is contained in:
@@ -657,3 +657,172 @@ a b
|
|||||||
2 NULL
|
2 NULL
|
||||||
3 NULL
|
3 NULL
|
||||||
drop table t1;
|
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;
|
||||||
|
@@ -639,4 +639,141 @@ insert ignore into t1 values (1,0), (2,0), (2,null), (3,null);
|
|||||||
select * from t1 order by a;
|
select * from t1 order by a;
|
||||||
drop table t1;
|
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
|
# End of 4.1 tests
|
||||||
|
@@ -6059,7 +6059,7 @@ void ha_ndbcluster::get_auto_increment(ulonglong offset, ulonglong increment,
|
|||||||
Ndb_tuple_id_range_guard g(m_share);
|
Ndb_tuple_id_range_guard g(m_share);
|
||||||
if (m_skip_auto_increment &&
|
if (m_skip_auto_increment &&
|
||||||
ndb->readAutoIncrementValue(m_table, g.range, auto_value) ||
|
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 &&
|
if (--retries &&
|
||||||
ndb->getNdbError().status == NdbError::TemporaryError);
|
ndb->getNdbError().status == NdbError::TemporaryError);
|
||||||
|
@@ -1488,12 +1488,15 @@ public:
|
|||||||
int initAutoIncrement();
|
int initAutoIncrement();
|
||||||
|
|
||||||
int getAutoIncrementValue(const char* aTableName,
|
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,
|
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,
|
int getAutoIncrementValue(const NdbDictionary::Table * aTable,
|
||||||
TupleIdRange & range, Uint64 & tupleId,
|
TupleIdRange & range, Uint64 & tupleId,
|
||||||
Uint32 cacheSize);
|
Uint32 cacheSize,
|
||||||
|
Uint64 step = 1, Uint64 start = 1);
|
||||||
int readAutoIncrementValue(const char* aTableName,
|
int readAutoIncrementValue(const char* aTableName,
|
||||||
Uint64 & tupleId);
|
Uint64 & tupleId);
|
||||||
int readAutoIncrementValue(const NdbDictionary::Table * aTable,
|
int readAutoIncrementValue(const NdbDictionary::Table * aTable,
|
||||||
@@ -1510,7 +1513,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
int getTupleIdFromNdb(const NdbTableImpl* table,
|
int getTupleIdFromNdb(const NdbTableImpl* table,
|
||||||
TupleIdRange & range, Uint64 & tupleId,
|
TupleIdRange & range, Uint64 & tupleId,
|
||||||
Uint32 cacheSize);
|
Uint32 cacheSize, Uint64 step = 1, Uint64 start = 1);
|
||||||
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,
|
||||||
|
@@ -754,17 +754,27 @@ Ndb::getNodeId()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Uint64 getTupleIdFromNdb( Uint32 aTableId, Uint32 cacheSize );
|
Uint64 getAutoIncrementValue( const char* aTableName,
|
||||||
|
Uint64 & autoValue,
|
||||||
|
Uint32 cacheSize,
|
||||||
|
Uint64 step,
|
||||||
|
Uint64 start);
|
||||||
|
|
||||||
Parameters: aTableId : The TableId.
|
Parameters: aTableName (IN) : The table name.
|
||||||
cacheSize: Prefetch this many values
|
autoValue (OUT) : Returns new autoincrement value
|
||||||
Remark: Returns a new TupleId to the application.
|
cacheSize (IN) : Prefetch this many values
|
||||||
The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId.
|
step (IN) : Specifies the step between the
|
||||||
It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp.
|
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
|
int
|
||||||
Ndb::getAutoIncrementValue(const char* aTableName,
|
Ndb::getAutoIncrementValue(const char* aTableName,
|
||||||
Uint64 & tupleId, Uint32 cacheSize)
|
Uint64 & autoValue, Uint32 cacheSize,
|
||||||
|
Uint64 step, Uint64 start)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("Ndb::getAutoIncrementValue");
|
DBUG_ENTER("Ndb::getAutoIncrementValue");
|
||||||
ASSERT_NOT_MYSQLD;
|
ASSERT_NOT_MYSQLD;
|
||||||
@@ -778,15 +788,16 @@ Ndb::getAutoIncrementValue(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 (getTupleIdFromNdb(table, range, tupleId, cacheSize) == -1)
|
if (getTupleIdFromNdb(table, range, autoValue, cacheSize, step, start) == -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::getAutoIncrementValue(const NdbDictionary::Table * aTable,
|
Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable,
|
||||||
Uint64 & tupleId, Uint32 cacheSize)
|
Uint64 & autoValue, Uint32 cacheSize,
|
||||||
|
Uint64 step, Uint64 start)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("Ndb::getAutoIncrementValue");
|
DBUG_ENTER("Ndb::getAutoIncrementValue");
|
||||||
ASSERT_NOT_MYSQLD;
|
ASSERT_NOT_MYSQLD;
|
||||||
@@ -801,51 +812,86 @@ Ndb::getAutoIncrementValue(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 (getTupleIdFromNdb(table, range, tupleId, cacheSize) == -1)
|
if (getTupleIdFromNdb(table, range, autoValue, cacheSize, step, start) == -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::getAutoIncrementValue(const NdbDictionary::Table * aTable,
|
Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable,
|
||||||
TupleIdRange & range, Uint64 & tupleId,
|
TupleIdRange & range, Uint64 & autoValue,
|
||||||
Uint32 cacheSize)
|
Uint32 cacheSize, Uint64 step, Uint64 start)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("Ndb::getAutoIncrementValue");
|
DBUG_ENTER("Ndb::getAutoIncrementValue");
|
||||||
assert(aTable != 0);
|
assert(aTable != 0);
|
||||||
const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
|
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_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::getTupleIdFromNdb(const NdbTableImpl* table,
|
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");
|
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);
|
assert(range.m_first_tuple_id < range.m_last_tuple_id);
|
||||||
tupleId = ++range.m_first_tuple_id;
|
range.m_first_tuple_id += step;
|
||||||
DBUG_PRINT("info", ("next cached value %lu", (ulong)tupleId));
|
tupleId = range.m_first_tuple_id;
|
||||||
|
DBUG_PRINT("info", ("Next cached value %lu", (ulong) tupleId));
|
||||||
}
|
}
|
||||||
else
|
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)
|
if (cacheSize == 0)
|
||||||
cacheSize = 1;
|
cacheSize = 1;
|
||||||
|
|
||||||
DBUG_PRINT("info", ("reading %u values from database", (uint)cacheSize));
|
DBUG_PRINT("info", ("reading %u values from database", (uint)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. 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)
|
if (opTupleIdOnNdb(table, range, opValue, 0) == -1)
|
||||||
DBUG_RETURN(-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);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user