在PostgreSQL中创建函数时获取“未定义符号:Float8GetDatum”

时间:2019-08-29 02:26:25

标签: postgresql

我在redhat linux 7.3中使用了postgresql 11.5。 在sql脚本中,函数创建如下:

create or replace function alpine_miner_float_array_sum_accum(state float[], ind float[])
returns float[]
AS 'alpine_miner', 'alpine_miner_float_array_sum_accum'
language C immutable;

但是会出现以下错误:

ERROR:  could not load library "/usr/pgsql-11/lib/alpine_miner.so": /usr/pgsql-11/lib/alpine_miner.so: undefined symbol: Float8GetDatum
SQL state: XX000

我发现/usr/pgsql-11/lib/alpine_miner.so确实存在,并且ld命令的输出是

linux-vdso.so.1 =>  (0x00007ffda65d6000)
libc.so.6 => /lib64/libc.so.6 (0x00007eff25a67000)
/lib64/ld-linux-x86-64.so.2 (0x00007eff26051000)

ldd命令:

ld: warning: cannot find entry symbol _start; not setting start address
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `construct_md_array'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `get_call_result_type'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `ArrayGetNItems'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `logf'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `deconstruct_array'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `CurrentMemoryContext'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `acosf'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `GetAttributeByName'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `elog_finish'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `errstart'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `pg_detoast_datum'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `exp'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `sqrtf'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `MemoryContextAllocZero'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `elog_start'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `errmsg'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `BlessTupleDesc'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `get_typlenbyvalalign'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `Float8GetDatum'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `log'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `pow'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `errdetail'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `DatumGetFloat8'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `errfinish'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `sqrt'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `heap_form_tuple'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `format_procedure'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `construct_array'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `MemoryContextAlloc'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `pfree'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `errcode'

有什么想法吗?预先感谢。

1 个答案:

答案 0 :(得分:0)

构建alpine_miner.so时,是根据PostgreSQL安装进行构建的,该安装的配置与尝试使用它的安装不同。

在标题问题的情况下,alpine_miner.so的构建中未定义USE_FLOAT8_BYVAL,但是您的PostgreSQL已定义了它:

#ifdef USE_FLOAT8_BYVAL
static inline Datum
Float8GetDatum(float8 X)
{
        union
        {
                float8          value;
                int64           retval;
        }                       myunion;

        myunion.value = X;
        return Int64GetDatum(myunion.retval);
}
#else
extern Datum Float8GetDatum(float8 X);
#endif

但是未定义的链接器引用列表也表明您正在尝试将共享库加载到古老的或已修改的PostgreSQL中:

例如,BlessTupleDesc自2004年4月提交375369acd1c以来一直在服务器中。

要获得更多帮助,您必须披露PostgreSQL的确切品牌和版本以及alpine_miner.so的确切生成过程。