日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

对PostgreSQL SPI例子的学习

發布時間:2023/12/2 数据库 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 对PostgreSQL SPI例子的学习 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

[作者:技術者高健@博客園 ?mail:?luckyjackgao@gmail.com?]

http://www.postgresql.org/docs/9.1/static/spi-examples.html

?

SPI 的例子里面沒有說,是如何編譯和部署的,我這里補充下:

編譯與部署:

[root@localhost soft]# export LD_LIBRARY_PATH=/usr/local/pgsql/lib [root@localhost soft]# echo $LD_LIBRARY_PATH /usr/local/pgsql/lib[root@localhost test]# cc -fpic -I/usr/local/pgsql/include/server/ -shared -o execq.so execq.c [root@localhost test]# ls execq.c execq.so [root@localhost test]# [root@localhost test]# cp execq.so /usr/local/pgsql/lib [root@localhost test]#

運行:

postgres=# create function execq(text,integer) returns integer as '/usr/local/pgsql/lib/execq.so','execq' language c strict; CREATE FUNCTION postgres=# postgres=# select execq('create table abc(id integer)',0);execq ------- 0 (1 row)postgres=# postgres=# insert into abc values( execq('insert into abc values(0)',0)); INSERT 0 1 postgres=# postgres=# insert into abc values( execq('insert into abc values(0)',0)); INSERT 0 1 postgres=# select * from abc;id ---- 0 1 (2 rows)postgres=# postgres=# select execq('select * from abc',0); INFO: EXECQ: 0 INFO: EXECQ: 1 execq ------- 2 (1 row)postgres=# postgres=# select execq('insert into abc select id+2 from abc',1);execq ------- 2 (1 row)postgres=# select * from abc;id ---- 0 1 2 3 (4 rows)postgres=# postgres=# select execq('select * from abc', 10); INFO: EXECQ: 0 INFO: EXECQ: 1 INFO: EXECQ: 2 INFO: EXECQ: 3 execq ------- 4 (1 row)postgres=#

[作者:技術者高健@博客園 ?mail:?luckyjackgao@gmail.com?]

?

轉載于:https://www.cnblogs.com/gaojian/archive/2012/10/29/2744195.html

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的对PostgreSQL SPI例子的学习的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。