"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