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

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: [SQL] Static variable inside PL/pgSQL (or) native C function
Дата
Msg-id CAFj8pRBq7DvMQY1JiXKMfXLcUHLEbUHNYdCTzpx4R3-M=7gw5Q@mail.gmail.com
обсуждение исходный текст
Ответ на [SQL] Static variable inside PL/pgSQL (or) native C function  (athinivas <athinivas@gmail.com>)
Список pgsql-sql
Hi

2017-09-29 15:46 GMT+02:00 athinivas <athinivas@gmail.com>:
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.

no, there are no similar feature. More it should not work as you are expecting, because PostgreSQL is process based, not thread based.

For this purpose, you can write some simple extension designed over shared memory.

Regards

Pavel

Thanks,
Athi



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


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

В списке pgsql-sql по дате отправления:

Предыдущее
От: athinivas
Дата:
Сообщение: [SQL] Static variable inside PL/pgSQL (or) native C function
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: [SQL] Static variable inside PL/pgSQL (or) native C function