supabase/wrappers

I get 'undefined symbol: __pgrx_marker' while testing helloworld_fdw

lij55 opened this issue · 6 comments

lij55 commented

If I clone the source code from github and build it, it can work without any error.

I failed to run it with error 'undefined symbol: __pgrx_marker"' if I create a new project with the same code of helloworld_fdw.

below is my Cargo.toml:

[dependencies]
pgrx = "=0.11.0"
supabase-wrappers = { git = "https://github.com/supabase/wrappers.git", tag = "v0.2.0"}

I tested pgrx 0.11.0 + tag 0.2.0 and pgrx0.11.2+main branch. the results are the same.

the detailed error message are:

The application panicked (crashed).
Message:  Couldn't call __pgrx_marker: DlSym { desc: "/home/liyang/Project/random_fdw/target/debug/librandom_fdw.so: undefined symbol: __pgrx_marker" }
Location: /home/liyang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-pgrx-0.11.0/src/command/schema.rs:413

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   0: cargo_pgrx::command::schema::generate_schema with pg_version=15.5 profile=Dev test=false path=/opt/pg15/share/postgresql/extension/random_fdw--0.1.0.sql features=["pg15"]
      at /home/liyang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-pgrx-0.11.0/src/command/schema.rs:176
   1: cargo_pgrx::command::install::install_extension with pg_version=15.5 profile=Dev test=false features=["pg15"]
      at /home/liyang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-pgrx-0.11.0/src/command/install.rs:114
   2: cargo_pgrx::command::run::run with pg_version=15.5 profile=Dev
      at /home/liyang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-pgrx-0.11.0/src/command/run.rs:94
   3: cargo_pgrx::command::run::execute
      at /home/liyang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-pgrx-0.11.0/src/command/run.rs:55

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

the rust version is: rustc 1.75.0 (82e1608df 2023-12-21)

imor commented

I failed to run it

How exactly did you run it? Do you have the code somewhere in a branch repo?

lij55 commented

random_fdw.zip
attached.

cargo pgrx init --pg15=xxxx
cargo pgrx run
imor commented

The zip file is empty. Can you create a repo on GH share that?

Several points may help to resolve this issue

  • use pgrx 0.11.2, as this is the latest version of pgrx
  • use latest wrappers code from main branch
  • use command like cargo pgrx new my_project to create a project

I've tested using above points and have no issues. Below are my steps:

# install and initialise pgrx
cargo install --force --locked cargo-pgrx --version 0.11.2
cargo pgrx init --pg14 download --pg15 download

# create project
cargo pgrx new myfdw
cd myfdw

# copy helloworld_fdw.rs or create any your fdw code on src/
# and modify Cargo.toml like below

# test run
cargo pgrx run

Below is my Cargo.toml file:

[package]
name = "myfdw"
version = "0.0.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[features]
default = ["pg15"]
pg15 = ["pgrx/pg15", "pgrx-tests/pg15" ]
pg_test = []

[dependencies]
pgrx = "=0.11.2"
supabase-wrappers = { git = "https://github.com/supabase/wrappers.git", branch = "main" }

[dev-dependencies]
pgrx-tests = "=0.11.2"

[profile.dev]
panic = "unwind"

[profile.release]
panic = "unwind"
opt-level = 3
lto = "fat"
codegen-units = 1
imor commented

I think the critical step is cargo pgrx new myfdw which does the following things different than a normal cargo new myfdw:

  1. Creates Cargo.toml with the correct settings.
  2. Creates a .cargo/config.toml file with correct linker settings on macOS.
  3. Calls pgrx::pg_module_magic!(); in the lib.rs file.

Without the above, the extension won't work. I saw the exact same error when I omitted # 3.

In short, follow @burmecia's steps above and it should work.

lij55 commented

sorry that I was busy on other thing yesterday...

Without the above, the extension won't work. I saw the exact same error when I omitted # 3.

exactly! thank you @imor and @burmecia for the help! I just stupidly copy-past without check the content so missed pgrx::pg_module_magic!();