Re: Static variable inside PL/pgSQL (or) native C function

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: athinivas <athinivas(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Static variable inside PL/pgSQL (or) native C function
Date: 2017-09-29 14:04:15
Message-ID: CAKFQuwbg1efML7CeSTrg8WZ_qOQfmVCYbVWdUXvmbWAsjnmADw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Sep 29, 2017 at 6:46 AM, athinivas <athinivas(at)gmail(dot)com> 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​

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message athinivas 2017-10-03 17:15:03 Re: Static variable inside PL/pgSQL (or) native C function
Previous Message Pavel Stehule 2017-09-29 14:03:39 Re: Static variable inside PL/pgSQL (or) native C function