我想创建修改版的C函数,该函数位于。作为开端,我认为可以编译并将作为用户定义函数加载。
我的操作步骤如下:
1. 将添加到中(如此处所述); 2. 在中将重命名为; 3. 按照文档中的说明编译(无错误、无警告)(
当我尝试运行
当我调用该函数时,我在
我的操作步骤如下:
1. 将添加到中(如此处所述); 2. 在中将重命名为; 3. 按照文档中的说明编译(无错误、无警告)(
cc -fpic -I
pg_config --includedir-server-c numeric.c
,然后cc -shared -o numeric.so numeric.o
);
4. 在PostgreSQL中创建一个函数:create or replace function int2_avg_accum2(bigint[], smallint)
returns bigint[] as
'/usr/lib/postgresql/9.1/lib/numeric', 'int2_avg_accum2'
language c
cost 1;
alter function int2_avg_accum2(bigint[], smallint)
owner to postgres;
当我尝试运行
select int2_avg_accum2(array[1::bigint,1],1::smallint);
时,在pgAdmin中只收到消息:"Do you want to attempt to reconnect to the database?"。没有其他消息或错误。当我调用该函数时,我在
/var/log/postgresql/postgresql-9.1-main.log
中看到以下内容:2013-12-03 09:52:02 CET LOG: server process (PID 3366) was terminated by signal 11: Segmentation fault
2013-12-03 09:52:02 CET LOG: terminating any other active server processes
2013-12-03 09:52:02 CET WARNING: terminating connection because of crash of another server process
2013-12-03 09:52:02 CET DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2013-12-03 09:52:02 CET HINT: In a moment you should be able to reconnect to the database and repeat your command.
2013-12-03 09:52:02 CET LOG: all server processes terminated; reinitializing
2013-12-03 09:52:02 CET LOG: database system was interrupted; last known up at 2013-12-03 09:50:53 CET
2013-12-03 09:52:02 CET LOG: database system was not properly shut down; automatic recovery in progress
2013-12-03 09:52:02 CET LOG: record with zero length at 0/B483EA0
2013-12-03 09:52:02 CET LOG: redo is not required
2013-12-03 09:52:03 CET LOG: autovacuum launcher started
2013-12-03 09:52:03 CET LOG: database system is ready to accept connections
我需要做些什么才能获得 int2_avg_accum
的工作副本?
numeric.c
。你是正确的,后端正在发生段错误。我添加了日志详细信息。还有其他提示吗? - Tomas Greif