Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDENTITY column with explicit START WITH or INCREMENT BY starts with wrong value [CORE6376] #6615

Closed
firebird-issue-importer opened this issue Aug 1, 2020 · 6 comments

Comments

@firebird-issue-importer
Copy link

@firebird-issue-importer firebird-issue-importer commented Aug 1, 2020

Submitted by: @mrotteveel

Is related to CORE6084

When using an identity column with an explicit START WITH clause, it starts with the wrong value:

SQL> create database 'localhost:e:/db/fb4/identity_test.fdb' user sysdba password 'masterkey';
SQL> create table identity_test (id bigint generated always as identity (start with 1 increment by 10));
SQL> insert into identity_test default values;
SQL> select * from identity_test;

               ID

=====================
11

expected result is 1.

SQL> create table identity_test2 (id bigint generated always as identity (start with 1));
SQL> insert into identity_test2 default values;
SQL> select * from identity_test2;

               ID

=====================
2

expected result is 1

This is also the case for only INCREMENT BY:

SQL> create table identity_test3 (id bigint generated always as identity (increment by 10));
SQL> insert into identity_test3 default values;
SQL> select * from identity_test3;

               ID

=====================
10

Expected result is 1

As I also pointed out in CORE6084, there are additional problems with negative increments: there the first generated value should be 2^63 -1 (for BIGINT), 2^31 -1 (for INTEGER) or 2^15 -1 (for SMALLINT) if the START WITH clause is absent.

This is related to CORE6084.

Commits: 44660f8 4d1ce73 23dc0c6

====== Test Details ======

See test for CORE6084.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Aug 1, 2020

Modified by: @mrotteveel

Link: This issue is related to CORE6084 [ CORE6084 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Aug 1, 2020

Modified by: @mrotteveel

description: When using an identity column with an explicit START WITH clause, it starts with the wrong value:

SQL> create database 'localhost:e:/db/fb4/identity_test.fdb' user sysdba password 'masterkey';
SQL> create table identity_test (id bigint generated always as identity (start with 1 increment by 10));
SQL> insert into identity_test default values;
SQL> select * from identity_test;

               ID

=====================
11

expected result is 1.

SQL> create table identity_test2 (id bigint generated always as identity (start with 1));
SQL> insert into identity_test2 default values;
SQL> select * from identity_test2;

               ID

=====================
2

expected result is 1

This is also the case for only INCREMENT BY:

SQL> create table identity_test3 (id bigint generated always as identity (increment by 10));
SQL> insert into identity_test3 default values;
SQL> select * from identity_test3;

               ID

=====================
10

Expected result is 1

This is related to CORE6084.

=>

When using an identity column with an explicit START WITH clause, it starts with the wrong value:

SQL> create database 'localhost:e:/db/fb4/identity_test.fdb' user sysdba password 'masterkey';
SQL> create table identity_test (id bigint generated always as identity (start with 1 increment by 10));
SQL> insert into identity_test default values;
SQL> select * from identity_test;

               ID

=====================
11

expected result is 1.

SQL> create table identity_test2 (id bigint generated always as identity (start with 1));
SQL> insert into identity_test2 default values;
SQL> select * from identity_test2;

               ID

=====================
2

expected result is 1

This is also the case for only INCREMENT BY:

SQL> create table identity_test3 (id bigint generated always as identity (increment by 10));
SQL> insert into identity_test3 default values;
SQL> select * from identity_test3;

               ID

=====================
10

Expected result is 1

As I also pointed out in CORE6084, there are additional problems with negative increments: there the first generated value should be 2^63 -1 (for BIGINT), 2^31 -1 (for INTEGER) or 2^15 -1 (for SMALLINT) if the START WITH clause is absent.

This is related to CORE6084.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Aug 5, 2020

Modified by: @asfernandes

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Aug 5, 2020

Modified by: @asfernandes

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 4.0 RC 1 [ 10930 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Aug 6, 2020

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: No test => Covered by another test(s)

Test Details: See test for CORE6084.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Aug 6, 2020

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants