Re: pqlib in c++: PQconnectStart PQconnectPoll

From: "madhtr" <madhtr(at)schif(dot)org>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: pqlib in c++: PQconnectStart PQconnectPoll
Date: 2007-02-15 02:33:18
Message-ID: 000f01c750a9$a6ffb720$6401a8c0@useronewin2klt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


----- Original Message -----
From: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "madhtr" <madhtr(at)schif(dot)org>
Cc: <pgsql-general(at)postgresql(dot)org>
Sent: Tuesday, August 14, 2007 18:50
Subject: Re: [GENERAL] pqlib in c++: PQconnectStart PQconnectPoll

> "madhtr" <madhtr(at)schif(dot)org> writes:
>> cleary I am going to have to study this documentation more carefully ...
>> So
>> ... for simplicity's sake, If I just do the following, how do I get back
>> "database does not exist" ?
>
> [ shrug... ] Your program works perfectly for me:
>
> $ ./testit
> PQerrorMessage(lpcn) returns:
>
> FATAL: database "nonexistantdb" does not exist
>
>
> PQstatus(lpcn)
> returns 1
> $
>
> ... although it takes a good long while (several seconds) because of the
> "sleep(1)" in the interaction with the postmaster.

hmm ... TY, must be my version or something like you state further down.

Sleep(1) should be only 1/1000 of a second. I do that so I don't hammer the
processor with my while loop when i am not using a select().

>
> Maybe your problem is not with the program, but with the postmaster
> you're trying to connect to? Does psql work?
>

yep, good thought. psql command line works fine, its sycnhronous tho.

>> source: http://www.postgresql.org/docs/7.3/static/libpq-connect.html
>
> Another line of thought, given the reading-between-the-lines conclusion
> that you are trying to use PG 7.3 libraries on Windows, is that there
> was something broken in the async-connect code back then on that
> platform. If you really are trying to do that, do yourself a favor and
> move to 8.0 or later. Nobody's going to be very interested in fixing
> 7.3. (I did try your program with 7.3 on Unix, though, and it seemed
> fine except the error message was spelled a bit differently.)
>

Ty, I'll check that ... :)

>> I was also under the assumption that I would not need to perform my own
>> selects on the underlying socket, and that whatever I got back would be
>> either a null pointer, a successful connection pointer, or a broken
>> connection pointer with an error indication.
>
> You don't *have* to perform selects on the underlying socket, but if you
> are not multiplexing this activity with some other I/O, I have to wonder
> why you are bothering with an asynchronous connect at all. What you've
> got at the moment is a poorly-implemented equivalent of PQconnectdb().

yep, the little simplified program is fairly pointless... but in RL, i will
pass a pointer to a cancel flag ...

void connect(bool* lpcancel){
while (!*lpcancel && trying2connect){
// yadda yadda yadda
};
};

so that the user can click the "connect" button, start a thread, and then
click the "cancel" button instead giving my app the three finger salute if
they grow impatient, heh;)

In any case, I very much appreciate your help and time, I'll let you know
what I figure out. I bet you're right about the version. Hopefully I can
contribute something back to the list at some point. Again, sry for the
sloppy code at the beginning :)

madhtr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message marcelo Cortez 2007-02-15 04:18:25 Re: PGSQL 8.2.3 Installation problem
Previous Message rloefgren 2007-02-15 01:51:47 Re: Proper escaping for char(3) string, or PHP at fault, or me at fault?