tds-fdw / tds_fdw

A PostgreSQL foreign data wrapper to connect to TDS databases (Sybase and Microsoft SQL Server)
Other
377 stars 101 forks source link

Fix tdsReScanForeignScan to actually work #283

Closed laurenz closed 3 years ago

laurenz commented 3 years ago

The implementation of that function was left empty, but that can lead to wrong query results: If the foreign scan is on the inner side of a nested loop join, the order of function calls is as follows:

tdsBeginForeignScan tdsIterateForeignScan (until done) tdsReScanForeignScan (prepare for second loop iteration) tdsIterateForeignScan (until done) ... (repeat the last two for each loop) tdsEndForeignScan

Since "tdsReScanForeignScan" didn't do anything, the second and all following scans will not return any rows, since the result set is already exhausted.

This leads to wrong query results.

To fix, consume any remaining rows and reset the state.

jenkins-juliogonzalez commented 3 years ago

Can one of the admins verify this patch?

juliogonzalez commented 3 years ago

Test this, please

jenkins-juliogonzalez commented 3 years ago

Test PASSed.

juliogonzalez commented 3 years ago

Retest this, please

jenkins-juliogonzalez commented 3 years ago

Test PASSed.

GeoffMontee commented 3 years ago

This has been merged. Thanks for another great contribution!