Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CORE-6084 - CREATE SEQUENCE START WITH has wrong initial value CORE-6376 - IDENTITY column with explicit START WITH or INCREMENT BY starts with wrong value
- Loading branch information
1 parent
945cec0
commit 23dc0c6
Showing
1 changed file
with
8 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5830,7 +5830,8 @@ bool CreateAlterSequenceNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch* | |
const SINT64 oldValue = !X.RDB$INITIAL_VALUE.NULL ? X.RDB$INITIAL_VALUE : 0; | ||
const SINT64 newValue = value.specified ? value.value : oldValue; | ||
|
||
transaction->getGenIdCache()->put(id, newValue); | ||
transaction->getGenIdCache()->put(id, | ||
newValue - (!X.RDB$GENERATOR_INCREMENT.NULL ? X.RDB$GENERATOR_INCREMENT : 1)); | ||
|
||
if (newValue != oldValue) | ||
{ | ||
|
@@ -5916,7 +5917,7 @@ SSHORT CreateAlterSequenceNode::store(thread_db* tdbb, jrd_tra* transaction, con | |
|
||
// The STORE above has caused the DFW item to be posted, so we just adjust the cached | ||
// generator value. | ||
transaction->getGenIdCache()->put(storedId, val); | ||
transaction->getGenIdCache()->put(storedId, val - step); | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
asfernandes
Author
Member
|
||
return storedId; | ||
} | ||
|
@@ -8137,8 +8138,11 @@ void AlterRelationNode::modifyField(thread_db* tdbb, DsqlCompilerScratch* dsqlSc | |
|
||
if (clause->identityOptions->restart) | ||
{ | ||
const SINT64 val = clause->identityOptions->startValue | ||
.orElse(!GEN.RDB$INITIAL_VALUE.NULL ? GEN.RDB$INITIAL_VALUE : 0); | ||
const SINT64 val = | ||
clause->identityOptions->startValue | ||
.orElse(!GEN.RDB$INITIAL_VALUE.NULL ? GEN.RDB$INITIAL_VALUE : 0) - | ||
clause->identityOptions->increment | ||
.orElse(!GEN.RDB$GENERATOR_INCREMENT.NULL ? GEN.RDB$GENERATOR_INCREMENT : 1); | ||
|
||
transaction->getGenIdCache()->put(id, val); | ||
} | ||
|
Does this mean that if sequence was created with e.g. INCREMENT 10, then GEN_ID(SEQ, 1) will return -9?