Re: What happens if I create new threads from within a postgresql function? - Mailing list pgsql-general

From Atri Sharma
Subject Re: What happens if I create new threads from within a postgresql function?
Date
Msg-id E37C5FF4-5E5F-4FA7-848A-82DBE48515ED@gmail.com
Whole thread Raw
In response to Re: What happens if I create new threads from within a postgresql function?  (Bruce Momjian <bruce@momjian.us>)
List pgsql-general
Sent from my iPad

On 18-Feb-2013, at 23:39, Bruce Momjian <bruce@momjian.us> wrote:

> On Mon, Feb 18, 2013 at 11:25:44PM +0530, Atri Sharma wrote:
>>>>>> Is there any way to locally synchronise the threads in my code,and
>>>>>> send the requests to the PostgreSQL backend one at a time? Like a wai=
ting
>>>>>> queue in my code?
>>>>>=20
>>>>> Is this from the client code?  That is easy from libpq using
>>>>> asynchronous queries.
>>>>>=20
>>>>>=20
>>>>=20
>>>> Actually, I haven't yet faced any such scenario.I was just thinking of a=
ll the possibilities that can happen in this case.Hehehe
>>>>=20
>>>> If we want to do this from a function in PostgreSQL itself, would a loc=
al synchronisation mechanism work?
>>>=20
>>> So your server-side function wants to start a new backend --- yeah, that=

>>> works.   /contrib/dblink does exactly that.  Calling it from threads
>>> should have the same limitations you would normally have from libpq.
>>>=20
>>>=20
>>=20
>> Got that,thanks a ton!
>>=20
>> I will see the dblink code.
>>=20
>> BTW, is there no way to introduce a general synchronisation mechanism for=
 server side code? A kind of construct which would be the standard way to ma=
nage synchronisation ? I was thinking of something on the lines of a monitor=
.
>=20
> You would use the standard methods, semaphores for processes, thread
> locks for threads.
>=20

I will try it out.Thanks a ton!

Regards,

Atri=

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: What happens if I create new threads from within a postgresql function?
Next
From: David Kerr
Date:
Subject: Re: PG9.2.3. Query hanging: SELECT count(*) FROM pg_catalog.pg_class...