Re: libpq CREATE DATABASE operation from multiple treads

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: p(dot)sun(dot)fun(at)gmail(dot)com
Cc: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Re: libpq CREATE DATABASE operation from multiple treads
Date: 2020-10-08 19:57:03
Message-ID: 2623291.1602187023@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

p(dot)sun(dot)fun(at)gmail(dot)com writes:
> I run this function using only one thread and everything works great.
> If I use two threads, the PQresultStatus(res) != PGRES_COMMAND_OK.

Are you trying to use the same PGconn from multiple threads? That
will not work --- at least not without interlocks that libpq on
its own does not provide.

> Can the server handle CREATE DATABASE requests in parallel?

Sure. But they have to be issued over different connections.
Any given connection can only do one thing at a time.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message p.sun.fun 2020-10-08 20:04:24 Re: libpq CREATE DATABASE operation from multiple treads
Previous Message p.sun.fun 2020-10-08 19:46:24 libpq CREATE DATABASE operation from multiple treads