Postgresql user defined c function issues

匆匆过客 提交于 2019-12-12 05:14:40

问题


I have installed postgresql in my ubuntu 14.04 with apt-get command..
postgresql 9.4
libpg 9.4.8

I want to add a user defined c function for dynamic loading.
I have my c file and sql function file ready as per specification but main problem is that c file contain header lines like..


    #include "postgres.h"
    #include <string.h>
    #include "fmgr.h"

i have my folder on Desktop but there is no postgers.h or fmgr.h file..
I dont know where to find source file on my system but i have downloaded whole source from git and added in same folder..
If i run compiling command it shows

postgres_ext.h:47:9: error: unknown type name 'PG_INT64_TYPE'<br>
 typedef PG_INT64_TYPE pg_int64;



i dont know where to start.. should i place my file in any postgres directory and then compile or downloading the source file is right option? What to do with the error..? Please help.. Many thanks in advance.


回答1:


Use PGXS to compile your code as an extension by writing a simple Makefile.

This will set up the include path, library path, etc for you and supply the correct compiler flags.

It's discussed in the same documentation as the tutorials that cover writing basic C functions.



来源:https://stackoverflow.com/questions/44491217/postgresql-user-defined-c-function-issues

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!