mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Merge pull request #33305 from nvartolomei/nv/test-odbc
Add test for broken connection
This commit is contained in:
commit
376709b249
@ -91,6 +91,25 @@ T execute(nanodbc::ConnectionHolderPtr connection_holder, std::function<T(nanodb
|
||||
connection_holder->updateConnection();
|
||||
return query_func(connection_holder->get());
|
||||
}
|
||||
|
||||
/// psqlodbc driver error handling is incomplete and under some scenarious
|
||||
/// it doesn't propagate correct errors to the caller.
|
||||
/// As a quick workaround we run a quick "ping" query over the connection
|
||||
/// on generic errors.
|
||||
/// If "ping" fails, recycle the connection and try the query once more.
|
||||
if (e.state().starts_with("HY00"))
|
||||
{
|
||||
try
|
||||
{
|
||||
just_execute(connection_holder->get(), "SELECT 1");
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
connection_holder->updateConnection();
|
||||
return query_func(connection_holder->get());
|
||||
}
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
@ -338,6 +338,8 @@ def test_postgres_odbc_hashed_dictionary_with_schema(started_cluster):
|
||||
cursor.execute("truncate table clickhouse.test_table")
|
||||
cursor.execute("insert into clickhouse.test_table values(1, 1, 'hello'),(2, 2, 'world')")
|
||||
node1.query("SYSTEM RELOAD DICTIONARY postgres_odbc_hashed")
|
||||
node1.exec_in_container(["ss", "-K", "dport", "postgresql"], privileged=True, user='root')
|
||||
node1.query("SYSTEM RELOAD DICTIONARY postgres_odbc_hashed")
|
||||
assert_eq_with_retry(node1, "select dictGetString('postgres_odbc_hashed', 'column2', toUInt64(1))", "hello")
|
||||
assert_eq_with_retry(node1, "select dictGetString('postgres_odbc_hashed', 'column2', toUInt64(2))", "world")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user