Could you please provide a comment concerning the following situation?
I created a simple ODBC program which calls "SELECT pg_is_in_recovery()" on the remote PostgreSQL server using ODBC API. It works good with this ODBC configuration. But as soon as I turn off network interface after SQLConnect call and before SQLExecDirect, it leads to SQLExecDirect hanging.
I tried to use statement_timeout and idle_in_transaction_session_timeout postgresql configuration parameters but they were not suitable for network issue case. These parameters define server-side behaviour but a client considers that the connection is ok and it is hanging.
As far as I know SQL_ATTR_CONNECTION_TIMEOUT ODBC attribute could handle this situation. Another ODBC driver for another database in case of similar situation returns HYT01 ODBC error (Connection timeout expired) . But I guess SQL_ATTR_CONNECTION_TIMEOUT is not supported by psqlodbc. Am I right?
How about calling SQLSetStmtAttr() with the attribute parameter SQL_ATTR_QUERY_TIMEOUT?
PostgreSQL JDBC driver provides socketTimeout property which helps a client to be informed about network problems and to avoid an infinite hanging. In my tests it returned 08006 sqlstate (connection_failure ).
So I have a question. Is there any psqlodbc or native PostgreSQL mechanism or configuration parameter which helps a client to be informed about network problem? Is there any mechanism which helps to avoid this infinite hanging for SQL query in this case?