github pgcentralfoundation/pgrx v0.2.0-beta.1

latest releases: v0.12.8, v0.12.7, v0.12.6...
pre-release3 years ago

Features

  • The pgx SQL generation system has been rewritten! It now uses the proc macro system and has several breaking changes. Please refer to the migration guide below. (#165, #197)
  • The PostgreSQL uuid type is now supported! (#172)
  • cargo pgx test now accepts an optional testname. cargo pgx test specific::path works just like cargo test! (#186)
  • pgx-pg-sys now suggests you install rustfmt if you don't have it. (#193)
  • cargo pgx schema will now emit informational messages if extension Cargo.toml settings are not what is expected. (#209)
  • cargo pgx test now has a --workspace argument matching the equivalent on cargo test. (#169)

Other changes

  • fix: Marked several functions as unsafe as they had undefined behavior when passed invalid pointers. (#210, #216, #217, #223, #224, #226)
  • Type oids don't need to be looked up in functions that don't use them. (#168)
  • Added an aggregate example. (#187)
  • Updated many of our dependencies. (#191)
  • More documentation has been added to several macros and SQL generation related types. (#192, #158, #219)
  • An articles/ directory now exists in the repo and includes links to different articles written about pgx. (#198)
  • Document our MSRV (#157)
  • Fixed an accidental circular dependency in 0.2.0-beta.0 (unpublished).

Migration Guide

  1. Update your cargo-pgx: cargo install --force cargo-pgx --version 0.2.0-beta.0

  2. In your Cargo.toml, set crate-type to include "rlib" and profile.dev.lto to be "thin":

    [lib]
    crate-type = ["cdylib", "rlib"]
    
    [profile.dev]
    lto = "thin"
  3. Tell cargo-pgx to force update your .cargo/ and src/bin files it needs: cargo pgx schema -f

  4. Remove any sql/*.generated.sql files, as well as the load-order.txt.

  5. For each sql/*.sql remaining, insert extension_sql_file!("../sql/that_file.sql"); into your src/lib.rs

  6. If the files depend on entities which already exist, you might need to set a requires attribute:

    extension_sql_file!("../sql/that_file.sql", requires = [ dogs::parts::Floof, some_fn, ]);
  7. For any mod floof { fn boop() { todo!() } } style blocks you were using to infer schema name (making that function floof.boop), decorate the schema with #[pg_schema]:

    #[pg_schema]
    mod floof {
        fn boop() {
            todo!()
        }
    }
  8. For any functions have a custom sql block for (like below), update that to use pgxsql now:

    /// ```sql <-- Change this to `pgxsql`
    /// CREATE OR REPLACE FUNCTION  ....
    /// ```
    #[pg_extern]
    fn dot_dot_dot() { todo!() }
  9. Run cargo pgx schema again!

If you have any trouble, try running cargo pgx schema -v and investigating the output. We made sure to update the cargo doc output of pgx with updated usage for the various macros and derives, they might have some advice, too.

You can ask us questions via issues here or Discord if you get stuck.

Thanks!

Thanks to @JLockerman (from @timescale) & @kpumuk for contributions! Also thanks to our early testers @rustprooflabs and @comdiv.

Don't miss a new pgrx release

NewReleases is sending notifications on new releases.