alitrack / duckdb_fdw

DuckDB Foreign Data Wrapper for PostgreSQL
MIT License
272 stars 18 forks source link

Error when loading extension with duckdb 0.6.x: undefined symbol: sqlite3_bind_int64 #12

Closed elysabethpc closed 1 year ago

elysabethpc commented 1 year ago

Hello,

When I build duckdb_fdw with duckdb version 0.6.0 or 0.6.1, everything is fine. But when I try to load the extension, with create extension duckdb_fdw, I get the following error:

ERROR: could not load library "/usr/pgsql-14/lib/duckdb_fdw.so":
 /usr/pgsql-14/lib/duckdb_fdw.so: undefined symbol: sqlite3_bind_int64

I am using fedora 37, postgresql 14.6.

When I use it with the duckdb v0.5.1 tag, everything comes out OK.

I have noticed that when I do ldd duckdb_fdw.so, is not linked with the duckdb libraries:

This is the output I get for vesion 0.6.1:

        linux-vdso.so.1 (0x00007ffcd909e000)
    libc.so.6 => /lib64/libc.so.6 (0x00007fca80144000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fca80357000)

And this one for version 0.5.1:

        linux-vdso.so.1 (0x00007fff74edf000)
    libsqlite3_api_wrapper.so => /lib64/libsqlite3_api_wrapper.so (0x00007f81f3478000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f81f329b000)
    libduckdb.so => /root/duckdb6/duckdb/build/release/src/libduckdb.so (0x00007f81f1c00000)
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f81f1800000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f81f1b20000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f81f3279000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f81f34ca000)

Thank you for your work

alitrack commented 1 year ago

I am still working on it.

elysabethpc commented 1 year ago

Hello,

I tried myaniu's solution, but it doesn't work for me. I can load the extension and create server but failed when I try to read from duckdb file with "unable to open database file":

db1=# create extension duckdb_fdw;
CREATE EXTENSION
db1=# \dx
                   List of installed extensions
    Name    | Version |   Schema   |         Description          
------------+---------+------------+------------------------------
 duckdb_fdw | 1.1     | public     | DuckDB Foreign Data Wrapper
 plpgsql    | 1.0     | pg_catalog | PL/pgSQL procedural language
(2 rows)

db1=# create server duckdb_srv foreign data wrapper duckdb_fdw options (database '/tmp/db1.duckdb', read_only 'true');
CREATE SERVER
db1=# 

db1=# import foreign schema public from server duckdb_srv into public;
ERROR:  SQL error during prepare: unable to open database file SELECT name FROM sqlite_master WHERE type in('table', 'view') AND name NOT LIKE 'sqlite_%'

I also tried the myaniu's dockfile on issue thread "duckdb_fdw.so: undefined symbol: sqlite3_limit", but failed.

Thank you

alitrack commented 1 year ago

fixed, from DuckDB 0.6, sqlite3_api_wrapper has an extra include, so I have to include it too.

#include "duckdb_shell_wrapper.h"
alitrack commented 1 year ago

btw,please refer this to simplify the job.

https://github.com/alitrack/duckdb_fdw_docker

elysabethpc commented 1 year ago

It works ok. Thank you