Re: Building Postgresql under Windows question

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Dann Corbit <DCorbit(at)connx(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Building Postgresql under Windows question
Date: 2009-04-28 21:58:39
Message-ID: 49F77C0F.40500@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dann Corbit wrote:
>> -----Original Message-----
>> From: Andrew Dunstan [mailto:andrew(at)dunslane(dot)net]
>> Sent: Tuesday, April 28, 2009 2:27 PM
>> To: Dann Corbit
>> Cc: pgsql-hackers(at)postgresql(dot)org
>> Subject: Re: [HACKERS] Building Postgresql under Windows question
>>
>>
>>
>> Dann Corbit wrote:
>>
>>> In this function:
>>> static bool
>>> test_postmaster_connection(bool do_checkpoint)
>>>
>>> This code will never succeed:
>>> snprintf(connstr, sizeof(connstr),
>>> "dbname=postgres port=%s connect_timeout=5",
>>> portstr);
>>>
>>> for (i = 0; i < wait_seconds; i++)
>>> {
>>> if ((conn = PQconnectdb(connstr)) != NULL &&
>>> (PQstatus(conn) == CONNECTION_OK ||
>>> PQconnectionNeedsPassword(conn)))
>>> {
>>> PQfinish(conn);
>>> success = true;
>>> break;
>>> }
>>>
>>>
>>> Because pg_hba.conf has this:
>>> # TYPE DATABASE USER CIDR-ADDRESS METHOD
>>>
>>> # IPv4 local connections:
>>> host all all 127.0.0.1/32 trust
>>> # IPv6 local connections:
>>> host all all ::1/128 trust
>>>
>>> to allow connections from the local machine.
>>>
>>> (A password is not needed to connect, so the code always fails).
>>>
>>>
>>>
>> Why won't
>>
>> PQstatus(conn) == CONNECTION_OK
>>
>> be true and thus the code will succeed without requiring a password?
>>
>
> It returns the value CONNECTION_STARTED
>
> I have found a work-around for now.
>
> If I set the method to password in pg_hba.conf, the service starts and
> runs correctly.
>
> It is only when the method is set to trust that we get 100% failures.
>
>
>

Then that looks like a libpq bug :-( According to the docs:

"The status can be one of a number of values. However, only two of these
are seen outside of an asynchronous connection procedure: CONNECTION_OK
and CONNECTION_BAD."

cheers

andrew

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-04-28 21:58:51 Re: docs: mention autovacuum when ANALYZE is recommended
Previous Message Dann Corbit 2009-04-28 21:48:02 Re: Building Postgresql under Windows question