Re: Race condition with libpq - Mailing list pgsql-interfaces

From Tom Lane
Subject Re: Race condition with libpq
Date
Msg-id 2072.1053966616@sss.pgh.pa.us
Whole thread Raw
In response to Race condition with libpq  ("Dietmar May" <dcmay@dmis.com>)
Responses Re: Race condition with libpq  ("Dietmar May" <dcmay@dmis.com>)
List pgsql-interfaces
"Dietmar May" <dcmay@dmis.com> writes:
> Would I be right in guessing (from your comments) that if PQexec issues a
> command that does not return a result set, that it executes it
> asynchronously?

PQexec is synchronous.  Connection closure is not, though: there is no
response from the backend (and hardly could be).

> That's the only way that I could see this could fail -- because my code
> can't issue a CREATE DATABASE until after the PQexec("DROP DATABASE") has
> returned.

You're missing the point.  It's the DROP that's failing, not the CREATE,
and it's failing because the old backend is still connected to the
victim database.

> I guess I had misread the first statement as meaning "you can drop the
> template1 database and have a cluster that doesn't contain a database called
> template1"; but this is apparently not a valid interpretation, since PGsql
> seems to use template1 for many internal operations.

It is not used for any "internal" operations.  It is conventionally
present so that clients have a standard place to connect to.
        regards, tom lane


pgsql-interfaces by date:

Previous
From: Tom Lane
Date:
Subject: Re: Race condition with libpq
Next
From: Tom Lane
Date:
Subject: Re: Race condition with libpq