PostgreSQL用户定义的C函数问题 [英] Postgresql user defined c function issues

查看:159
本文介绍了PostgreSQL用户定义的C函数问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用apt-get命令在ubuntu 14.04中安装了postgresql。.

postgresql 9.4

libpg 9.4.8


我想要添加用户定义的c函数以进行动态加载。

我已经按照规范准备好了我的c文件和sql函数文件,但是主要问题是c文件包含标题行,如..

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"

我在桌面上有我的文件夹,但是没有postgers.h或fmgr.h文件..

我不知道在系统上哪里找到源文件,但是我已经从git下载整个源并添加到同一文件夹中。.

如果我运行编译命令,它将显示< br>

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;



我不知道从哪里开始..我应该将文件放在任何位置然后在postgres目录下编译或下载源文件是正确的选择吗?如何处理错误..?请帮助。。提前致谢。



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.

推荐答案

使用PGXS通过编写简单的Makefile将您的代码作为扩展名进行编译

这将为您设置include路径,库路径等,并提供正确的编译器标志。

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

与涵盖写作的教程在同一文档中进行了讨论基本的C函数。

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

这篇关于PostgreSQL用户定义的C函数问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆