From: ff <ff-@uol.com.br>
To: pgsql-interfaces@postgresql.org
Subject: persistent variables between cross-calls in C functions
Date: Fri, 21 Mar 2003 16:53:45 -0300
Message-ID: <HC479L$IV_LImy4TIWPigNNbAWviUDKTgWo@uol.com.br> (raw)
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/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: ff-@uol.com.br
Subject: Re: persistent variables between cross-calls in C functions
In-Reply-To: <HC479L$IV_LImy4TIWPigNNbAWviUDKTgWo@uol.com.br>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox