Re: Race condition with libpq

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Dietmar May" <dcmay(at)dmis(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Race condition with libpq
Date: 2003-05-26 16:30:16
Message-ID: 2072.1053966616@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

"Dietmar May" <dcmay(at)dmis(dot)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

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Dietmar May 2003-05-26 16:49:38 Re: Race condition with libpq
Previous Message Dietmar May 2003-05-26 15:47:29 Re: Race condition with libpq