Re: question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Robert B(dot) Easter" <reaster(at)comptechnews(dot)com>
Cc: Sandeep Joshi <sjoshi(at)Zambeel(dot)com>, Alfred Perlstein <bright(at)wintelcom(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: question
Date: 2000-12-16 17:10:41
Message-ID: 15846.976986641@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Robert B. Easter" <reaster(at)comptechnews(dot)com> writes:
> If you or anyone reading this can put together a working C trigger example
> with a test table and compile and trigger load procedure, I'd like to have it
> to play with! I've been trying to use the examples in the docs and the ones
> in contrib/spi, but with no luck. I'm using 7.0.3. I notice that the delev
> docs have a different C trigger example than the 7.0 docs.

The C-level trigger interface changed for 7.1 (as part of the big
function manager rewrite). The info at
http://www.postgresql.org/devel-corner/docs/postgres/triggers.htm
is correct for 7.1 but not for earlier versions. The critical
difference is that the TriggerData parameter structure is now passed
in the 'fcinfo->context' optional argument, not via a global variable.
This means you *must* use the new-style function interface, else you'll
have no way to get at TriggerData.

The user docs aren't yet updated for the new fmgr (mea culpa, hope to
do it soon) but you can read about it in src/backend/utils/fmgr/README.

I believe that the current docs examples and the current-sources contrib
triggers are OK, but I can't claim to have tested them carefully. The
contrib/spi/refint.c and contrib/spi/autoinc.c examples definitely work,
because they are tested by the regression tests. Bit-rot could have set
in elsewhere --- if you find problems please send details.

> I don't know what
> the differences are, one returns a HeapTuple and the other a Datum (a
> unsigned long)?

Same thing, different declaration. You're supposed to explicitly cast
the HeapTuple (a pointer) to Datum with PointerGetDatum().

> Anyhow, some more detailed, up-to-date, docs on some of this would be nice.

If you don't like the docs we have, improvements are gladly accepted...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2000-12-16 20:15:26 Generating HISTORY file
Previous Message Michael Meskes 2000-12-16 16:32:59 Re: Great Bridge PostgreSQL products and services