[作者:技术者高健@博客园 mail: luckyjackgao@gmail.com ]
参考这个例子:
http://www.postgresql.org/docs/9.1/static/spi-examples.html
如果我们在 src/backend/executor/spi.c 的 SPI_finish 函数处进行调试(增加打印 SPI_finish called)可以发现,
如果不在SPI 程序中调用 SPI_finish,其实会有问题。
启动PostgreSQL:
[root@localhost ~]# su - postgres [postgres@localhost ~]$ cd /usr/local/pgsql/bin [postgres@localhost bin]$ ./postgres -D /usr/local/pgsql/data LOG: database system was shut down at 2012-10-29 09:27:55 CST LOG: autovacuum launcher started LOG: database system is ready to accept connections
调用 execq函数:
postgres=# create or replace function execq(text,integer) returns integer as '/usr/local/pgsql/lib/execq.so','execq' language c strict; CREATE FUNCTION postgres=# select execq('select * from testtab',10); INFO: EXECQ: 1 | 12345 WARNING: transaction left non-empty SPI stack HINT: Check for missing "SPI_finish" calls. execq ------- 1 (1 row) postgres=#
[作者:技术者高健@博客园 mail: luckyjackgao@gmail.com ]
结束