I wish libpq add get_unresolv_host() and set_unresolv_host_ip() function

Поиск
Список
Период
Сортировка
От 32686647
Тема I wish libpq add get_unresolv_host() and set_unresolv_host_ip() function
Дата
Msg-id tencent_3A0AC5A22E9F0522BDA357FFC46FAB4FBB06@qq.com
обсуждение исходный текст
Список pgsql-hackers
I want to resolve the domain name asynchronously before connecting to the target;
one way is parse sql connect parameters string; like 
if ("host=" in conn_params) and ("hostaddr=" not in conn_params):
   get_domain_name_and_resolv_and_add_hostaddr_to_conn_params_string()

Another way is to add it  to libq;
I write a simple example:
    https://github.com/gamefunc/Aiolibpq_simple
I added the code to libq the build for use:
    https://github.com/gamefunc/Aiolibpq_simple/blob/main/Modify_Libpq_Source_Code.py
and use it in(awaitable<int> Aiolibpq::connect()):
    https://github.com/gamefunc/Aiolibpq_simple/blob/main/Aiolibpq_simple.cpp

    const char* host_name = nullptr;
    while((host_name = PQgetUnresolvHost(conn)) != nullptr){
        tcp::resolver resolver(loop);
        tcp::resolver::iterator ep_iter = 
            co_await resolver.async_resolve(
                host_name, "", use_awaitable);
        tcp::endpoint ep = *ep_iter;
        PQSetUnresolvHost(
            conn, host_name,
            ep.address().to_string().data(),
            ep.address().to_string().size());
    }// while()

Of course, there will be many situations in this code, 
for example, when one of the domain names fails to resolve the ip, it will boom;








В списке pgsql-hackers по дате отправления:

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: File descriptors in exec'd subprocesses
Следующее
От: Nazir Bilal Yavuz
Дата:
Сообщение: Re: meson: Non-feature feature options