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

Error in selecting rows with compound index [CORE3971] #4304

Closed
firebird-automations opened this issue Nov 1, 2012 · 11 comments
Closed

Error in selecting rows with compound index [CORE3971] #4304

firebird-automations opened this issue Nov 1, 2012 · 11 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Jesus Angel Garcia Zarco (cointec)

Duplicates CORE1188

I have observed an strange behaviour in Firebird 2.5.2 and in recent snapshots of 2.5.3. I think is a bug related to some changes introduced in recent builds that solves other bugs related to index corruptions.

I have one table with a compound index smallint+varchar.

CREATE TABLE NEW_TABLE (
FIELD_ID INTEGER NOT NULL,
FIELD_DESC VARCHAR(10) NOT NULL,
FIELD_SEL SMALLINT NOT NULL
);

CREATE INDEX NEW_TABLE_IDX1 ON NEW_TABLE (FIELD_ID, FIELD_DESC);
CREATE INDEX NEW_TABLE_IDX2 ON NEW_TABLE (FIELD_SEL, FIELD_DESC);

INSERT INTO NEW_TABLE (FIELD_ID, FIELD_DESC, FIELD_SEL)
VALUES (1, '', 1);
INSERT INTO NEW_TABLE (FIELD_ID, FIELD_DESC, FIELD_SEL)
VALUES (2, '', 1);
INSERT INTO NEW_TABLE (FIELD_ID, FIELD_DESC, FIELD_SEL)
VALUES (3, 'B', 1);

If I execute the next statement, all runs fine and returns all rows.

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL = 1 and FIELD_DESC starting with ''

1 '' 1
2 '' 1
3 'B' 1

If i execute the same query, but parametrized, i get two rows:

Search = ''

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL = 1 and FIELD_DESC starting with :Search

1 '' 1
2 '' 1

The interesting thing, is that if I now execute the next update

update NEW_TABLE
set FIELD_DESC = 'A'
where FIELD_ID = 2

and then execute again

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL = 1 and FIELD_DESC starting with :Search

I get

1 '' 1
2 'A' 1

and allways if i execute

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL = 1 and FIELD_DESC starting with ''

or

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_DESC starting with :Search

returns all rows.

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

See test for core-1188

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Did you perform backup/restore or at least rebuild indices during migration to 2.5.2 / 2.5.3? If not, try that and report back.

Also, what version did you run before trying those recent builds? Some earlier snapshot of 2.5.2, I guess? What build number?

@firebird-automations
Copy link
Collaborator Author

Commented by: Jesus Angel Garcia Zarco (cointec)

This test is done creating that table in firebird 2.5.3.
I have this problem in one customer where is installed Firebird 2.5.3.26544. In that customer, I backed up and restored the database using Firebird 2.5.3.
I'm testing one customer with Firebird 2.5.2.26392, from 1 december 2011, and has the same bug.

I have tested again in my laptop with version 2.5.2.26469, and has the same bug. I have not backed up and restored, but I have set the index Inactive and active.

The first time I tested it, instead of run

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL = 1 and FIELD_DESC starting with :Search

I runned

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL > 0 and FIELD_DESC starting with :Search

The latter runs fine.

I do change the description and instead of latest 2.5.2 write 2.5.2.

@firebird-automations
Copy link
Collaborator Author

Modified by: Jesus Angel Garcia Zarco (cointec)

description: I have observed an strange behaviour in the latest snapshots of Firebird 2.5.2 and in recent snapshots of 2.5.3. I think is a bug related to some changes introduced in recent builds that solves other bugs related to index corruptions.

I have one table with a compound index smallint+varchar.

CREATE TABLE NEW_TABLE (
FIELD_ID INTEGER NOT NULL,
FIELD_DESC VARCHAR(10) NOT NULL,
FIELD_SEL SMALLINT NOT NULL
);

CREATE INDEX NEW_TABLE_IDX1 ON NEW_TABLE (FIELD_ID, FIELD_DESC);
CREATE INDEX NEW_TABLE_IDX2 ON NEW_TABLE (FIELD_SEL, FIELD_DESC);

INSERT INTO NEW_TABLE (FIELD_ID, FIELD_DESC, FIELD_SEL)
VALUES (1, '', 1);
INSERT INTO NEW_TABLE (FIELD_ID, FIELD_DESC, FIELD_SEL)
VALUES (2, '', 1);
INSERT INTO NEW_TABLE (FIELD_ID, FIELD_DESC, FIELD_SEL)
VALUES (3, 'B', 1);

If I execute the next statement, all runs fine and returns all rows.

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL = 1 and FIELD_DESC starting with ''

1 '' 1
2 '' 1
3 'B' 1

If i execute the same query, but parametrized, i get two rows:

Search = ''

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL = 1 and FIELD_DESC starting with :Search

1 '' 1
2 '' 1

The interesting thing, is that if I now execute the next update

update NEW_TABLE
set FIELD_DESC = 'A'
where FIELD_ID = 2

and then execute again

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL = 1 and FIELD_DESC starting with :Search

I get

1 '' 1
2 'A' 1

and allways if i execute

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL = 1 and FIELD_DESC starting with ''

or

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_DESC starting with :Search

returns all rows.

=>

I have observed an strange behaviour in Firebird 2.5.2 and in recent snapshots of 2.5.3. I think is a bug related to some changes introduced in recent builds that solves other bugs related to index corruptions.

I have one table with a compound index smallint+varchar.

CREATE TABLE NEW_TABLE (
FIELD_ID INTEGER NOT NULL,
FIELD_DESC VARCHAR(10) NOT NULL,
FIELD_SEL SMALLINT NOT NULL
);

CREATE INDEX NEW_TABLE_IDX1 ON NEW_TABLE (FIELD_ID, FIELD_DESC);
CREATE INDEX NEW_TABLE_IDX2 ON NEW_TABLE (FIELD_SEL, FIELD_DESC);

INSERT INTO NEW_TABLE (FIELD_ID, FIELD_DESC, FIELD_SEL)
VALUES (1, '', 1);
INSERT INTO NEW_TABLE (FIELD_ID, FIELD_DESC, FIELD_SEL)
VALUES (2, '', 1);
INSERT INTO NEW_TABLE (FIELD_ID, FIELD_DESC, FIELD_SEL)
VALUES (3, 'B', 1);

If I execute the next statement, all runs fine and returns all rows.

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL = 1 and FIELD_DESC starting with ''

1 '' 1
2 '' 1
3 'B' 1

If i execute the same query, but parametrized, i get two rows:

Search = ''

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL = 1 and FIELD_DESC starting with :Search

1 '' 1
2 '' 1

The interesting thing, is that if I now execute the next update

update NEW_TABLE
set FIELD_DESC = 'A'
where FIELD_ID = 2

and then execute again

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL = 1 and FIELD_DESC starting with :Search

I get

1 '' 1
2 'A' 1

and allways if i execute

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_SEL = 1 and FIELD_DESC starting with ''

or

select FIELD_ID, FIELD_DESC, FIELD_SEL
from new_table
where FIELD_DESC starting with :Search

returns all rows.

@firebird-automations
Copy link
Collaborator Author

Commented by: Jesus Angel Garcia Zarco (cointec)

I'm testing with version 2.5.2.26466 and 2.5.2.26387 and does not runs fine

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

It looks like a duplicate CORE1188, i.e. it's an old issue. It should exist in all released FB versions, provided that you test it on a fresh database created on that particular server version.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Link: This issue duplicates CORE1188 [ CORE1188 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

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

resolution: Duplicate [ 3 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

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

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

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

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

Test Details: See test for core-1188

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

No branches or pull requests

1 participant