Re: create trigger (can't compile example, problem with include files)

From: Sandeep Joshi <sjoshi(at)Zambeel(dot)com>
To: "Robert B(dot) Easter" <reaster(at)comptechnews(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: create trigger (can't compile example, problem with include files)
Date: 2000-12-15 00:27:45
Message-ID: 3A396581.C7E0D6B0@zambeel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Robert,
I am insert_username.* in contrib directory for reference. So far so good.

Sandeep
"Robert B. Easter" wrote:

> On Thursday 14 December 2000 18:54, Robert B. Easter wrote:
> > Trigger functions, no matter what language, have be RETURNS OPAQUE.
> >
> > Here is an example (in the PostgreSQL docs):
> > http://www.comptechnews.com/~reaster/postgres/triggers20290.htm
> >
> > Sorry I can't help more as I've never actually used C triggers, just
> > PL/pgSQL ones.
> >
>
> Admitting I have not tried using C triggers, I decided to try the example at
> the url above. I saved the example C trigger to a file called ttest.c and
> compile it with:
>
> gcc -shared -I/usr/local/pgsql/include ttest.c -o ttest.o
>
> (I hope that is the right command), then I got this:
>
> reaster(at)comptechnews:~/prog/triggers$ gcc -shared -I/usr/local/pgsql/include
> ttest.c -o ttest.o
> In file included from ttest.c:1:
> /usr/local/pgsql/include/executor/spi.h:17: nodes/primnodes.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:18: nodes/relation.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:19: nodes/execnodes.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:20: nodes/plannodes.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:21: catalog/pg_proc.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:22: catalog/pg_type.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:23: tcop/pquery.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:24: tcop/tcopprot.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:25: tcop/utility.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:26: tcop/dest.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:27: nodes/params.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:28: utils/fcache.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:29: utils/datum.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:30: utils/syscache.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:31: utils/portal.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:32: utils/builtins.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:33: catalog/pg_language.h: No such
> file or directory
> /usr/local/pgsql/include/executor/spi.h:34: access/heapam.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:35: access/xact.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:36: executor/executor.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:37: executor/execdefs.h: No such file
> or directory
> In file included from ttest.c:2:
> /usr/local/pgsql/include/commands/trigger.h:16: nodes/execnodes.h: No such
> file or directory
> /usr/local/pgsql/include/commands/trigger.h:17: nodes/parsenodes.h: No such
> file or directory
> reaster(at)comptechnews:~/prog/triggers$
>
> I compared /usr/local/pgsql/include with
> /usr/src/postgresql-7.0.3/src/include and found that the src has more include
> files so that I tried:
>
> reaster(at)comptechnews:~/prog/triggers$ gcc -shared -I/usr/local/pgsql/include
> -I/usr/src/postgresql-7.0.3/src/include ttest.c -o ttest.o
> ttest.c: In function `trigf':
> ttest.c:17: `WARN' undeclared (first use in this function)
> ttest.c:17: (Each undeclared identifier is reported only once
> ttest.c:17: for each function it appears in.)
>
>
> Anyhow, can someone help me here with these include files and the missing
> WARN define?
>
> > On Thursday 14 December 2000 18:04, Sandeep Joshi wrote:
> > > I am trying to use "triggers". I get an error after "create trigger".
> > > Does anybody know why?
> > >
> > > create function insert_into_db2 RETURNS int AS
> > > '/work/posgresql/lib/libpq.so' language 'C';
> > >
> > > create trigger trial before insert or update on db1user for each row
> > > execute procedure insert_into_db2();
> > >
> > > ERROR: CreateTrigger: function insert_into_db2() must return OPAQUE
> > >
> > > Does anybody know why?
> > >
> > > Also, if a function is enforced to return OPAQUE then what is the
> > > "RETURNS" clause?
> > >
> > >
> > > One more question,
> > > If a trigger does not succeed then I want to ABORT transaction, is
> > > it possible? how?
> > >
> > >
> > > - Sandeep
>
> --
> -------- Robert B. Easter reaster(at)comptechnews(dot)com ---------
> - CompTechNews Message Board http://www.comptechnews.com/ -
> - CompTechServ Tech Services http://www.comptechserv.com/ -
> ---------- http://www.comptechnews.com/~reaster/ ------------

> On Thursday 14 December 2000 18:54, Robert B. Easter wrote:
> > Trigger functions, no matter what language, have be RETURNS OPAQUE.
> >
> > Here is an example (in the PostgreSQL docs):
> > http://www.comptechnews.com/~reaster/postgres/triggers20290.htm
> >
> > Sorry I can't help more as I've never actually used C triggers, just
> > PL/pgSQL ones.
> >
>
> Admitting I have not tried using C triggers, I decided to try the example at
> the url above. I saved the example C trigger to a file called ttest.c and
> compile it with:
>
> gcc -shared -I/usr/local/pgsql/include ttest.c -o ttest.o
>
> (I hope that is the right command), then I got this:
>
> reaster(at)comptechnews:~/prog/triggers$ gcc -shared -I/usr/local/pgsql/include
> ttest.c -o ttest.o
> In file included from ttest.c:1:
> /usr/local/pgsql/include/executor/spi.h:17: nodes/primnodes.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:18: nodes/relation.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:19: nodes/execnodes.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:20: nodes/plannodes.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:21: catalog/pg_proc.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:22: catalog/pg_type.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:23: tcop/pquery.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:24: tcop/tcopprot.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:25: tcop/utility.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:26: tcop/dest.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:27: nodes/params.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:28: utils/fcache.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:29: utils/datum.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:30: utils/syscache.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:31: utils/portal.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:32: utils/builtins.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:33: catalog/pg_language.h: No such
> file or directory
> /usr/local/pgsql/include/executor/spi.h:34: access/heapam.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:35: access/xact.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:36: executor/executor.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:37: executor/execdefs.h: No such file
> or directory
> In file included from ttest.c:2:
> /usr/local/pgsql/include/commands/trigger.h:16: nodes/execnodes.h: No such
> file or directory
> /usr/local/pgsql/include/commands/trigger.h:17: nodes/parsenodes.h: No such
> file or directory
> reaster(at)comptechnews:~/prog/triggers$
>
> I compared /usr/local/pgsql/include with
> /usr/src/postgresql-7.0.3/src/include and found that the src has more include
> files so that I tried:
>
> reaster(at)comptechnews:~/prog/triggers$ gcc -shared -I/usr/local/pgsql/include
> -I/usr/src/postgresql-7.0.3/src/include ttest.c -o ttest.o
> ttest.c: In function `trigf':
> ttest.c:17: `WARN' undeclared (first use in this function)
> ttest.c:17: (Each undeclared identifier is reported only once
> ttest.c:17: for each function it appears in.)
>
>
> Anyhow, can someone help me here with these include files and the missing
> WARN define?
>
> > On Thursday 14 December 2000 18:04, Sandeep Joshi wrote:
> > > I am trying to use "triggers". I get an error after "create trigger".
> > > Does anybody know why?
> > >
> > > create function insert_into_db2 RETURNS int AS
> > > '/work/posgresql/lib/libpq.so' language 'C';
> > >
> > > create trigger trial before insert or update on db1user for each row
> > > execute procedure insert_into_db2();
> > >
> > > ERROR: CreateTrigger: function insert_into_db2() must return OPAQUE
> > >
> > > Does anybody know why?
> > >
> > > Also, if a function is enforced to return OPAQUE then what is the
> > > "RETURNS" clause?
> > >
> > >
> > > One more question,
> > > If a trigger does not succeed then I want to ABORT transaction, is
> > > it possible? how?
> > >
> > >
> > > - Sandeep
>
> --
> -------- Robert B. Easter reaster(at)comptechnews(dot)com ---------
> - CompTechNews Message Board http://www.comptechnews.com/ -
> - CompTechServ Tech Services http://www.comptechserv.com/ -
> ---------- http://www.comptechnews.com/~reaster/ ------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert B. Easter 2000-12-15 00:29:41 Re: create trigger (can't compile example, problem with include files)
Previous Message Sandeep Joshi 2000-12-15 00:08:20 Re: create trigger