From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | athinivas <athinivas(at)gmail(dot)com> |
Cc: | postgres list <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Static variable inside PL/pgSQL (or) native C function |
Date: | 2017-10-03 17:25:56 |
Message-ID: | CAFj8pRBt5nMc1gAttcjaoje+RxZxCxVBndbF6bmbxM4aq96xUA@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
2017-10-03 19:15 GMT+02:00 athinivas <athinivas(at)gmail(dot)com>:
> David G Johnston wrote
> > On Fri, Sep 29, 2017 at 6:46 AM, athinivas <
>
> > athinivas@
>
> > > wrote:
> >
> >> Hi,
> >>
> >> Is it possible to have static variable inside pgSQL C functions (or)
> >> PL/pgSQL?? I'm having a use case where I need to update a counter inside
> >> the
> >> function & it should be thread-safe.
> >>
> >> I've tried using static variable inside the C function along with
> >> pthread_mutex_lock/pthread_mutex_unlock. And found functions are not
> >> shared
> >> among each other.
> >>
> >>
> > Don't know what's possible in C; pretty sure no in pl/pgsql.
> >
> > Why not just use a table and SQL locking features?
> >
> > Dave
>
> Sadly, I'm doing it in slave server, so not able to use any table
> INSERT/UPDATE. Does current_Setting() can be used to access any global
> variables??
>
No, it is not possible
Regards
Pavel
> thanks,
> Athi
>
>
>
> --
> Sent from: http://www.postgresql-archive.org/PostgreSQL-sql-f2142323.html
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
From | Date | Subject | |
---|---|---|---|
Next Message | Feike Steenbergen | 2017-10-05 06:01:45 | Re: Re: Query is executing but giving error when using with shell scripting |
Previous Message | athinivas | 2017-10-03 17:15:03 | Re: Static variable inside PL/pgSQL (or) native C function |