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

From: athinivas <athinivas(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Static variable inside PL/pgSQL (or) native C function
Date: 2017-09-29 13:46:19
Message-ID: 1506692779631-0.post@n3.nabble.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

Thanks,
Athi

--
Sent from: http://www.postgresql-archive.org/PostgreSQL-sql-f2142323.html

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Pavel Stehule 2017-09-29 14:03:39 Re: Static variable inside PL/pgSQL (or) native C function
Previous Message Feike Steenbergen 2017-09-27 12:07:12 Re: Single SQL to find if any record exists across several tables