From: | p(dot)sun(dot)fun(at)gmail(dot)com |
---|---|
To: | pgsql-sql(at)lists(dot)postgresql(dot)org |
Subject: | Re: libpq CREATE DATABASE operation from multiple treads |
Date: | 2020-10-08 20:52:22 |
Message-ID: | cf26fe0aca8ce2769334ac4781a01eba89311b0e.camel@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, 2020-10-08 at 16:36 -0400, Tom Lane wrote:
> p(dot)sun(dot)fun(at)gmail(dot)com writes:
> > Indeed, this is a FATAL_ERROR. From two threads I got:
> > // Thread #1
> > FATAL_ERROR: ERROR: source database "template1" is being accessed
> > by
> > other users
> > DETAIL: There is 1 other session using the database.
>
> You'd be better off to connect to some other database than template1;
What would be the best strategy to create a database from user
standpoint of view? If we have an API to create a database on a server.
The user doesn't know about database(s) yet. The possible option would
be: to check the result status and if is not COMMAND_OK, probably
connection should be dropped and established again.
May be not so elegant but at least safe and stable.
> not only just for this purpose, but in general. If you are issuing
> random commands in template1, there's a risk of modifying that
> database
> unexpectedly and thereby changing the contents of databases created
> in future.
>
> regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-10-08 20:56:28 | Re: libpq CREATE DATABASE operation from multiple treads |
Previous Message | Rob Sargent | 2020-10-08 20:50:31 | Re: libpq CREATE DATABASE operation from multiple treads |