Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I get 'undefined symbol: __pgrx_marker' while testing helloworld_fdw #224

Closed
lij55 opened this issue Jan 17, 2024 · 6 comments
Closed

I get 'undefined symbol: __pgrx_marker' while testing helloworld_fdw #224

lij55 opened this issue Jan 17, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@lij55
Copy link

lij55 commented Jan 17, 2024

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)

@lij55 lij55 added the bug Something isn't working label Jan 17, 2024
@imor
Copy link
Contributor

imor commented Jan 17, 2024

I failed to run it

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

@lij55
Copy link
Author

lij55 commented Jan 17, 2024

random_fdw.zip
attached.

cargo pgrx init --pg15=xxxx
cargo pgrx run

@imor
Copy link
Contributor

imor commented Jan 17, 2024

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

@burmecia
Copy link
Member

burmecia commented Jan 18, 2024

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
Copy link
Contributor

imor commented Jan 18, 2024

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
Copy link
Author

lij55 commented Jan 19, 2024

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!();

@lij55 lij55 closed this as completed Jan 19, 2024
kamyshdm pushed a commit to dymium-io/supabase-wrappers that referenced this issue Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants