persistent variables between cross-calls in C functions

From: "ff" <ff-(at)uol(dot)com(dot)br>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: persistent variables between cross-calls in C functions
Date: 2003-03-21 19:53:45
Message-ID: HC479L$IV_LImy4TIWPigNNbAWviUDKTgWo@uol.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

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/

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Barry Lind 2003-03-21 21:32:29 Re: [INTERFACES] Roadmap for FE/BE protocol redesign
Previous Message Tom Lane 2003-03-21 18:33:08 Re: [INTERFACES] Roadmap for FE/BE protocol redesign