X-Original-To: pgsql-interfaces@postgresql.org Received: from shrek3.uol.com.br (shrek3.uol.com.br [200.221.29.18]) by postgresql.org (Postfix) with ESMTP id 121C947611A for ; Fri, 21 Mar 2003 14:54:08 -0500 (EST) Received: from mtauol11.mail.sys.intranet (172.26.5.67) by shrek3.uol.com.br (5.1.071) id 3E51384B0044590A for pgsql-interfaces@postgresql.org; Fri, 21 Mar 2003 16:54:08 -0300 Received: from uol.com.br (172.26.5.45) by mtauol11.mail.sys.intranet (5.1.071) id 3E5BDC0F0076018A for pgsql-interfaces@postgresql.org; Fri, 21 Mar 2003 16:54:07 -0300 Date: Fri, 21 Mar 2003 16:53:45 -0300 Message-Id: Subject: persistent variables between cross-calls in C functions MIME-Version: 1.0 Content-Type: text/plain;charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable From: "ff" To: pgsql-interfaces@postgresql.org X-XaM3-API-Version: 2.4 R3 ( B4 ) X-SenderIP: 200.170.46.14 X-Archive-Number: 200303/123 X-Sequence-Number: 3872 Dear all: I could not find any way to store a value in a C function between calls. For example, the following function doesn't work as expected: #include "postgres.h" #include "fmgr.h" PG_FUNCTION_INFO_V1(next_value); Datum next_value(PG_FUNCTION_ARGS) { static int n; PG_RETURN_INT32(n); n++; } select next_value(); will always return 0; even if I declare n as a global variable outside the fucntion. Thanks a lot. Fabio Furia Silva --- UOL, o melhor da Internet http://www.uol.com.br/