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

Server crash when using query parameter #160

Open
pludov opened this issue Jun 3, 2022 · 1 comment
Open

Server crash when using query parameter #160

pludov opened this issue Jun 3, 2022 · 1 comment

Comments

@pludov
Copy link

pludov commented Jun 3, 2022

I get consistent server crash when running a query from plpgsql with an inequality condition that refers to a variable.
The crash happens exactly on the 6th execution of the request...

It does not occur if I change the inequality to an equality, or if I use a constant rather than a variable.

Versions:

  • postgres: 13.2
  • Mongo FDW: 5.4.0
  • Mongo: 4.2.18

Reproduction script:

CREATE FOREIGN TABLE test ( importeddate text )
    SERVER whatever
    OPTIONS (database 'test', collection 'test');

-- perform a query from with inequality and variable
create or replace procedure gogogo() as $$
declare val text;
begin
        val := 'ZZZ';
        perform from test where importeddate > val  ;
end
$$ LANGUAGE plpgsql;

-- Now do 6 call...
call crash(); call crash(); call crash(); call crash(); call crash(); call crash();
@vaibhavdalvi93
Copy link

Thanks, @pludov for reporting an issue.

This issue is reproducible at my end as well.
This is a bug and this is due to missed handling of Param node
in case of comparison operator while preparing query filter.

You can apply attached patch to fix this issue.

We will try to commit these changes as soon as possible.
Fix-crash-v1.txt

jeevanchalke added a commit that referenced this issue Jul 19, 2022
While preparing a query filter in mongo_query_document(), we have
missed considering the Param node in a comparison expression.  And
thus, was not preparing the query correctly, leading to the server
crash.  We do have this handling for the equality operator, though.
Fix the same.

Reported on GitHub through issue #160 by pludov.

FDW-529, Vaibhav Dalvi, reviewed and further revised by Jeevan Chalke.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants