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.