在PostgreSQL 9上用C创建触发器

在PostgreSQL 9上用C创建触发器,c,postgresql,triggers,C,Postgresql,Triggers,我在Ubuntu10.04上有一台PostgreSQL 9.0服务器,我尝试用C代码创建一个触发器,如下链接: , 目前,我的代码应该只显示记录中列的值(并返回“已编辑”的记录): 此文件与postgres.h的路径相同,并且有以下文件:executor/spi.h和commands/trigger.h。但是,当我运行命令时: cc -fpic -c trigger_test.c 我收到错误信息: In file included from postgres.h:48, from trigge

我在Ubuntu10.04上有一台PostgreSQL 9.0服务器,我尝试用C代码创建一个触发器,如下链接:

,

目前,我的代码应该只显示记录中列的值(并返回“已编辑”的记录):

此文件与postgres.h的路径相同,并且有以下文件:executor/spi.hcommands/trigger.h。但是,当我运行命令时:

cc -fpic -c trigger_test.c
我收到错误信息:

In file included from postgres.h:48,
from trigger_test.c:1:
   utils/elog.h:69:28: error: utils/errcodes.h: Not exists the file or directory
In file included from trigger_test.c:2:
  executor/spi.h:16:30: error: nodes/parsenodes.h: Not exists the file or directory
  executor/spi.h:17:26: error: utils/portal.h: Not exists the file or directory
  executor/spi.h:18:28: error: utils/relcache.h: Not exists the file or directory
  executor/spi.h:19:28: error: utils/snapshot.h: Not exists the file or directory
...
所有文件都存在,我不想更改文件中的所有包含项:elog.hspi.h等,以避免可能产生的后果。有没有人设置了这样的触发器并能告诉我哪里错了


提前感谢。

您忘了在函数中包含fmgr.h头,因此魔法块可以更有效地工作。

尝试将
-I.
添加到命令行:
cc-fpic-c-I.trigger\u test.c
。非常感谢,至少现在可以编译了。
In file included from postgres.h:48,
from trigger_test.c:1:
   utils/elog.h:69:28: error: utils/errcodes.h: Not exists the file or directory
In file included from trigger_test.c:2:
  executor/spi.h:16:30: error: nodes/parsenodes.h: Not exists the file or directory
  executor/spi.h:17:26: error: utils/portal.h: Not exists the file or directory
  executor/spi.h:18:28: error: utils/relcache.h: Not exists the file or directory
  executor/spi.h:19:28: error: utils/snapshot.h: Not exists the file or directory
...