Skip to content


Choose a tag to compare
@Hoverbear Hoverbear released this 16 Mar 18:23
· 433 commits to master since this release

This release reworks the SQL generation process present in 0.2.x and 0.3.x, resulting in approximately 50% faster linking times for most commands.

The usability of #[pgx(sql = some_func)] has also improved, as we are now invoking these functions from the shared object itself, instead of some separate binary.


This release requires some manual intervention for all users, as we have updated the SQL generation process. We discovered a new (significantly faster and more safe) way to generate SQL that doesn't require the sql-generator binary or linker scripts.

Additionally, only users of #[pg_extern(sql = some_func)] (and thus using the pgx::datum::sql_entity_graph) should be aware that pgx::datum::sql_entity_graph was merged with pgx_utils::sql_entity_graph and is available at pgx::utils::sql_entity_graph now.

Steps to upgrade:

Please make sure to run cargo install cargo-pgx --version 0.4.0 and update all the pgx extension Cargo.toml's pgx* versions to 0.4.0.


  • Remove .cargo/, src/bin/
    rm .cargo/ src/bin/
  • Replace .cargo/config with:
    # Postgres symbols won't be available until runtime
    rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup"]
  • In your Cargo.toml:
    + crate-type = ["cdylib"]
    - crate-type = ["cdylib", "rlib"]

What's Changed

  • cargo pgx schema now: (#441, #446, #465, #478, #471, #480, #441)
    1. Uses --message-format=json on some cargo invocations and captures that output.
    2. Generates a 'stub' of the relevant postmaster binary (found via pg_config).
    3. dlopens that 'stub'.
    4. dlopens the extension.
    5. Calls the pgx_utils::sql_entity_graph::PgxSql builders as the sql-generator used to.
  • Most cargo pgx commands now support the --package arg matching cargo's.
    Please note unlike cargo, cargo pgx does not support multiple --package args at this time. (#475 )
  • pgx::datum::sql_entity_graph and pgx_utils::sql_entity_graph are merged and present in pgx_utils::sql_entity_graph together. (#441)
  • cargo pgx schema now outputs to /dev/stdout by default, use --out to specify a destination, or pipe the stdout. (#465 )
  • pgx_utils is now exported from at pgx::utils, this is primarily to expose pgx_utils::sql_entity_graph without requiring users have pgx_utils in their Cargo.toml. (#441)
  • The sql-generator binary, .cargo/ and related .cargo/config settings are no longer needed. The old .cargo/config from 0.1.2x is back. (#441)
  • pgx_graph_magic!() now expands with __pgx_source_only_sql_mappings and __pgx_typeid_sql_mappings symbols, allowing cargo-pgx to get the appropriate SQL mappings. (#441)
  • cargo pgx test and cargo pgx install had several changes to make them more appropriately and cleanly capture and pass build data for this new process. (#441)
  • Most sql_graph_entity related functions got a #[doc(hidden)] attribute to clean up their docs. (#441)
  • RUST_LOG env vars get correctly passed in pgx test. (#441)
  • Some unnecessary dependencies and features were pruned. (#436)
  • pgx-pg-sys now only generates bindings it needs, instead of bindings for all postgres verisons. (#455)
  • Readme improvements. (#460, #463, #471)
  • The development workspace has changed. The pgx-parent crate was removed, the pgx-examples directory members are now workspace members, and the workspaces uses resolver = "2". (#456)
  • The pgx-examples no longer point outside the pgx directory then traverse back in. (#462)
  • Several new headers are exposed via pgx_pg_sys:
    • tsearch/ts_public.h and tssearch/ts_utils.h (#464)
    • buffile.h (#476)
    • optimizer/appendinfo.h (#479)
  • Improved the error messages if a user is missing initdb or tar (#484)
  • Improved our Nix support to allow singleStep = false, improving rebuild speed, we also tweaked the Nix CI samples. (#474, #485)
  • Fixed pgx-tests failing on (#468)