Re: What happens if I create new threads from within a postgresql function?

From: Atri Sharma <atri(dot)jiit(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, Seref Arikan <serefarikan(at)kurumsalteknoloji(dot)com>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: What happens if I create new threads from within a postgresql function?
Date: 2013-02-18 18:22:21
Message-ID: E37C5FF4-5E5F-4FA7-848A-82DBE48515ED@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sent from my iPad

On 18-Feb-2013, at 23:39, Bruce Momjian <bruce(at)momjian(dot)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 waiting
>>>>>> queue in my code?
>>>>>
>>>>> Is this from the client code? That is easy from libpq using
>>>>> asynchronous queries.
>>>>>
>>>>>
>>>>
>>>> Actually, I haven't yet faced any such scenario.I was just thinking of all the possibilities that can happen in this case.Hehehe
>>>>
>>>> If we want to do this from a function in PostgreSQL itself, would a local synchronisation mechanism work?
>>>
>>> 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.
>>>
>>>
>>
>> Got that,thanks a ton!
>>
>> I will see the dblink code.
>>
>> 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 manage synchronisation ? I was thinking of something on the lines of a monitor.
>
> You would use the standard methods, semaphores for processes, thread
> locks for threads.
>

I will try it out.Thanks a ton!

Regards,

Atri

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Kerr 2013-02-18 19:34:57 Re: PG9.2.3. Query hanging: SELECT count(*) FROM pg_catalog.pg_class...
Previous Message Bruce Momjian 2013-02-18 18:09:42 Re: What happens if I create new threads from within a postgresql function?