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

Query using VIEW with UNION causes crash [CORE165] #494

Closed
firebird-automations opened this issue Nov 20, 2001 · 5 comments
Closed

Query using VIEW with UNION causes crash [CORE165] #494

firebird-automations opened this issue Nov 20, 2001 · 5 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: creynolds (creynolds)

SFID: 483795#⁠
Submitted By: creynolds

Given the following table and view definition:

CREATE TABLE table1 (
keyfield INTEGER NOT NULL,
field1 INTEGER NOT NULL);

CREATE TABLE table2 (
keyfield INTEGER NOT NULL,
field2 INTEGER NOT NULL);

CREATE VIEW test1 ( keyfield, field1 ) AS
SELECT keyfield, field1
FROM table1
UNION
SELECT keyfield, field1
FROM table1;

CREATE VIEW test2 ( keyfield, field2 ) AS
SELECT keyfield, field2
FROM table2
UNION
SELECT keyfield, field2
FROM table2;

the following statement crashes the server:

SELECT *
FROM test1 i, test2 j
WHERE i.keyfield = j.keyfield
AND j.field2 = (SELECT MAX(x.field2) FROM test2 x)

Claudio's comments on this bug:

Finally I got to the right place. The problem happens
in the optimizer, in the routine gen_sort_merge(),
when it calls a routine named computable() during the
prepare phase. After that routine calls itself 4 times
recursively, it finds a null pointer and game over,
take your bags and go to home. A node pointer with the
value 0xb is no fun for the operating system, that
kills the process:

for (end = ptr + node->nod_count; ptr < end; ptr++)
if (!computable (csb, *ptr, stream, idx_use))
return FALSE;

ptr is okay, but *ptr is 0xb, hence it enter a new
recursive call with "node" argument being 0xb, and the
first line does DEV_BLKCHK (node, type_nod); that will
check node->nod_type == type_nod. Of course, 0xb is
not a valid address to be dereferenced, hence goodbye.

It seems that the server didn't like the total absence
of indices.
:-)

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

Original test:
https://github.com/FirebirdSQL/fbtcs/blob/master/GTCS/tests/CF_ISQL_24.script

@firebird-automations
Copy link
Collaborator Author

Commented by: Alice F. Bird (firebirds)

Date: 2004-04-26 19:48
Sender: brodsom
Logged In: YES
user_id=546439

The bug don't exist in 2.0 HEAD (verified with new fbtcs test)

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Workflow: jira [ 10189 ] => Firebird [ 14406 ]

@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 => Done successfully

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

Test Details: Original test:
https://github.com/FirebirdSQL/fbtcs/blob/master/GTCS/tests/CF_ISQL_24.script

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