arrow-flight-sql-postgresql
arrow-flight-sql-postgresql copied to clipboard
Broken error reporting through Python ADBC
The following query should report a division by zero:
import adbc_driver_flightsql.dbapi as flight_sql
with flight_sql.connect(uri="grpc://localhost:15432",
db_kwargs={"username": "avogelsgesang",
"adbc.flight.sql.rpc.call_header.x-flight-sql-database": "avogelsgesang"
}
) as conn:
with conn.cursor() as cur:
cur.execute("SELECT 1/0;")
However, this does not work as expected. Instead cur.execute first hangs for a couple of minutes before then reporting
Traceback (most recent call last):
File "/home/avogelsgesang/Documents/af-query.py", line 9, in <module>
cur.execute("SELECT 1/0;")
File "/home/avogelsgesang/.local/lib/python3.10/site-packages/adbc_driver_manager/dbapi.py", line 669, in execute
handle, self._rowcount = self._stmt.execute_query()
File "adbc_driver_manager/_lib.pyx", line 1106, in adbc_driver_manager._lib.AdbcStatement.execute_query
File "adbc_driver_manager/_lib.pyx", line 227, in adbc_driver_manager._lib.check_error
adbc_driver_manager.ProgrammingError: INVALID_ARGUMENT: [FlightSQL] failed to run: Action::SelectPreparedStatement: division by zero (InvalidArgument; ExecuteQuery)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/avogelsgesang/Documents/af-query.py", line 8, in <module>
with conn.cursor() as cur:
File "/home/avogelsgesang/.local/lib/python3.10/site-packages/adbc_driver_manager/dbapi.py", line 225, in __exit__
self.close()
File "/home/avogelsgesang/.local/lib/python3.10/site-packages/adbc_driver_manager/dbapi.py", line 611, in close
self._stmt.close()
File "adbc_driver_manager/_lib.pyx", line 1078, in adbc_driver_manager._lib.AdbcStatement.close
File "adbc_driver_manager/_lib.pyx", line 1084, in adbc_driver_manager._lib.AdbcStatement.close
File "adbc_driver_manager/_lib.pyx", line 227, in adbc_driver_manager._lib.check_error
adbc_driver_manager.ProgrammingError: INVALID_ARGUMENT: [FlightSQL] stolen session: 1283150246607583965 (InvalidArgument; ClosePreparedStatement)
Exception ignored in: <function Cursor.__del__ at 0x7fa517960280>
Traceback (most recent call last):
File "/home/avogelsgesang/.local/lib/python3.10/site-packages/adbc_driver_manager/dbapi.py", line 766, in __del__
File "/home/avogelsgesang/.local/lib/python3.10/site-packages/adbc_driver_manager/dbapi.py", line 611, in close
File "adbc_driver_manager/_lib.pyx", line 1077, in adbc_driver_manager._lib.AdbcStatement.close
File "adbc_driver_manager/_lib.pyx", line 293, in adbc_driver_manager._lib._AdbcHandle._close_child
File "adbc_driver_manager/_lib.pyx", line 295, in adbc_driver_manager._lib._AdbcHandle._close_child
RuntimeError: Underflow in closing this AdbcStatement