Skip to content

Commit fd52baf

Browse files
fix connection drain
Signed-off-by: Aykut Bozkurt <aykut.bozkurt@snowflake.com>
1 parent f4a7307 commit fd52baf

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

pg_lake_spatial/tests/pytests/test_gdal.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,7 @@ def test_gdal_zip_gml(
203203
# Querying is currently not supported because WKB is converted by DuckDB
204204
# Error messages reflect different DuckDB spatial versions
205205
error = run_query("SELECT shape FROM test_gdal.fdw", user_conn, raise_error=False)
206-
assert (
207-
"Geometry type 10 not supported" in error
208-
or "'MULTICURVE' is not supported" in error
209-
or "Unsupported geometry type in WKB" in error
210-
)
206+
assert "Unsupported geometry type in WKB" in error
211207

212208
user_conn.rollback()
213209

pg_lake_table/src/fdw/pg_lake_table.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3394,6 +3394,19 @@ fetch_more_data(ForeignScanState *node)
33943394
fsstate->eof_reached = true;
33953395
else if (PQresultStatus(res) != PGRES_SINGLE_TUPLE)
33963396
{
3397+
/*
3398+
* Drain remaining results so the connection processes
3399+
* ReadyForQuery and reaches idle state before the error
3400+
* unwinds the stack. Without this, transaction abort cleanup
3401+
* sees a busy connection and reports a spurious "lost
3402+
* connection to query engine" error.
3403+
*/
3404+
PGresult *remaining = WaitForLastResult(fsstate->conn);
3405+
3406+
if (remaining != NULL)
3407+
PQclear(remaining);
3408+
fsstate->eof_reached = true;
3409+
33973410
ThrowIfPGDuckResultHasError(fsstate->conn, res);
33983411
}
33993412
}

0 commit comments

Comments
 (0)