Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxvcY-0003OL-5P for pgsql-sql@arkaria.postgresql.org; Fri, 29 Sep 2017 13:46:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dxvcX-0000Cs-Lu for pgsql-sql@arkaria.postgresql.org; Fri, 29 Sep 2017 13:46:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dxvcX-00009a-2j for pgsql-sql@postgresql.org; Fri, 29 Sep 2017 13:46:25 +0000 Received: from n3.nabble.com ([162.255.23.22]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxvcS-00020c-VJ for pgsql-sql@postgresql.org; Fri, 29 Sep 2017 13:46:24 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 9AA58899B5B0 for ; Fri, 29 Sep 2017 06:46:19 -0700 (MST) Date: Fri, 29 Sep 2017 06:46:19 -0700 (MST) From: athinivas To: pgsql-sql@postgresql.org Message-ID: <1506692779631-0.post@n3.nabble.com> Subject: Static variable inside PL/pgSQL (or) native C function MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org 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 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql