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

Firebird 5 and 6 crash on "... RETURNING * " without INTO in PSQL #7832

Closed
AlexeyMochalov opened this issue Nov 8, 2023 · 2 comments
Closed

Comments

@AlexeyMochalov
Copy link
Contributor

Hi, colleges.
Found a server crash in PSQL which contains statement with **... RETURNING *** without INTO. It's an erroneous statement in PSQL without INTO, but it shouldn't terminate server.
Can be reproduced with such request:

set term !;
recreate table ttt (id int)!
execute block
as
begin
    delete from ttt returning *;
end!
set term ;!

I'm going to make a PR and I want to discuss it. I'm not sure that my patch would be enough to fix this issue properly. After this fix instead of crash an error will be returned with zeroes in line and and column (like in FB4 on such request).

When we "explode" **RETURNING *** to multiple fields we have no line and column from parser due to NULL node from select_list parse.y rule.

It could be fixed if create kinda dummy node with line and column set, or provide host_statement argument to Jrd::dsqlProcessReturning() (FB5,FB6) or ReturningProcessor::explode() (FB4) with whole statement line and column, not just zeroes.

Appreciate your help.

@aafemt
Copy link
Contributor

aafemt commented Nov 8, 2023

This is a parser issue and such incorrect syntax must be detected and reported by parser, not runtime.

@asfernandes
Copy link
Member

Fixed it in d5e67a2 replacing the nullptr of RETURNING * by an empty list for RETURNING, and reverting the empty list to nullptr for the SELECT * case.

In this way, we don't lose the line/column info.

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