Releases: pgcentralfoundation/pgrx
v0.3.2
v0.3.1
v0.3.0
Upgrading
Please make sure to run cargo install cargo-pgx and update all the pgx extension Cargo.toml's pgx*versions to 0.3.0.
We do not expect users to require additional actions on upgrade, but we recommend any usage of the pgxsql be converted to use the new sql = "some string" available on the macros. We expect pgxsql support to be removed in the future, before 1.0.0.
Features
- Aggregates are now supported. Explore the Rustdocs of
pgx::Aggregateandpgx::pg_aggregate, or theaggregateexample to learn more. (#230, #406, #418, #428) cargo pgxhas a new coat of paint as Clap was upgraded to 3.0. (#368)cargo pgxwill now do some validation that it is being run on a crate which uses a compatiblepgxversion. (#389)cargo pgxand thesql-generatorhave more observability and improved error handling. Try exploring--verbose! (#372)cargo pgxrelated commands now treat thepgversionas optional if somepgversionis part of the extension'sdefaultfeatures. (#402)- You can now have extensions which are
#[no_std]. Whilepgxstill usesstd, this can be a partial measure to limiting what an extension (or, for exampleplrust) might be able to do on a system. (#385) pgx::Internalhas an expanded API likeget_or_insert_default(). (#419)- Most
pgxrelated attribute macros now supportsql = false,sql = "string", orsql = some::func::pathto configure how they generate SQL. (#410, #422) - Nix users will find
lib.buildPgxExtensionin theflake.nix. (#358, #360, #361)
Other changes
PgBoxacquirednew()andnew_in_context()functions. (#421)- The
pg_sys::TimestampTztype alias now has an SQL mapping. (#400) pgx::memcxt::PgMemoryContextsrelated closures now take aFnOnce, this makes them considerably more flexible as they can capture their environment. (#390)pgx-pg-sysshould hopefully be able to build on Docs.rs! (#386)default!()macros can now handle negative values. (63f5e6e)- The new
cargo pgx schema --skip-buildflag uses existing artifacts. (#255) @CARGO_VERSION@in the.controlfile is now supported in the SQL generation. (#409)- Fixed some help text in
cargo pgx init. (https://github.com/zombodb/pgx/pull/415)\ - For users who already have
PGUSERset, it was previously possible to encounter some issues duringcargo pgxuse. (#380) - For
x86_64-unknown-linux-muslandaarch64-unknown-linux-muslusers, schema generation is now supported. (#362, #365) - For Nix users,
debuganddoCheckare now supported. (#349, #401) - For Mac Nix users,
glibcwas broken, it's no longer include it on Mac. (#335) - For Mac ARM users,
cargo pgxwill now handle removing libraries when needed due to code-signing. (#333, #420) - For CentOS 7 or other older-distro users, some problems were noted with GCC 4. (#387)
- General dependency updates and lint fixing. (#339, #364, #405, #414)
Thanks!
Thanks to @JamesGuthrie (from @timescale), @bitwalker (from @timescale), @robins , and @volks73 for their contributions!
v0.2.6
v0.2.5
pgx v0.2.5 fixes an issue where Spi::get_one_with_args() would cause Postgres to segfault if one of the query arguments is NULL (None). It also improves our Nix support.
Thanks
Thanks to @bbigras for finding the SPI issue and also for the Nix support improvements!
What's Changed
- nix template: hoverbear -> zombodb by @bbigras in #296
- nix: use the registry by @bbigras in #301
- nix template: bump pgx by @bbigras in #302
- nix template: nmattia -> nix-community by @bbigras in #298
- fix crashes with NULL Datums in
SPI::get_one_with_args()-> b2820a1
New Contributors
Full Changelog: v0.2.4...v0.2.5
v0.2.4
This is pgx v0.2.4. It resolves (as best as possible) a compilation performance regression (#287) by only compiling the sql-generator binary when it's required. It also adds a few more Postgres headers for additional bindings around time/date and non-UTF8 encodings (PR #289).
Please make sure to run cargo install cargo-pgx along with updating your extension's Cargo.toml dependencies to point to this version.
v0.2.3
This is pgx v0.2.3. It is a minor bugfix release that fixes an issue with doing "special token" replacements in the generated (and copied) .sql files.
v0.2.2
This is pgx v0.2.2. It fixes an issue where #[pg_extern] functions that return a (rust) tuple would forget their attribute values.
v0.2.1
v0.2.0
This is pgx v0.2.0. It represents months of work on new tooling around automatic SQL schema generation, Postgres 14 support, various safety improvements, and some user-facing (breaking) API changes.
We thank everyone that helped test the betas and are excited to finally release v0.2.0!
Upgrading
Please make sure to run cargo install cargo-pgx and update all pgx extension Cargo.toml file "pgx*" dependency versions to 0.2.0.
Features
- PostgreSQL v14 support (#245)
- The
pgxSQL 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
uuidtype is now supported! (#172) cargo pgx testnow accepts an optional testname.cargo pgx test specific::pathworks just likecargo test! (#186)pgx-pg-sysnow suggests you installrustfmtif you don't have it. (#193)cargo pgx schemawill now emit informational messages if extensionCargo.tomlsettings are not what is expected. (#209)cargo pgx testnow has a--workspaceargument matching the equivalent oncargo 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 aboutpgx. (#198) - Document our MSRV (#157)
- Fixed an accidental circular dependency in 0.2.0-beta.0 (unpublished).
- Resolve undefined behavior around exported function symbols (#241)
- As a result there is now
pgx::direct_function_call()andpgx::direct_pg_extern_function_call()for dynamically calling internal Postgres functions and functions you declare as#[pg_extern].
- As a result there is now
- Fix up Darwin linking issues (#244)
- Resolve issues with sql entity graph generation (#236, #260)
#[pg_extern]functions with lifetimes no longer cause compiler errors (#268)- Add a
--no-schemaflag tocargo pgx run/test/installwhich avoids generating the schema again. This can help speed up the development cycle if you haven't made any code changes that would affect the SQL schema (#262) #[pg_extern]no longer fails with return types with lifetimes inside Option<...> (#270)PgBoxhas been rewritten to be the size of a single pointer (usize). Its user-facing API is the same, but you may need to add declare an associated type ofAllocatedByPostgresorAllocatedByRustdepending on usage context- The
Internaltype is no longer generic, and its API has been changed to provide typed getter functions. It is also documented.
Migration Guide
-
Update your
cargo-pgx:cargo install --force cargo-pgx --version 0.2.0-beta.0 -
In your
Cargo.toml, setcrate-typeto include"rlib"andprofile.dev.ltoto be"thin":[lib] crate-type = ["cdylib", "rlib"] [profile.dev] lto = "thin"
-
Tell
cargo-pgxto force update your.cargo/andsrc/binfiles it needs:cargo pgx schema -f -
Remove any
sql/*.generated.sqlfiles, as well as theload-order.txt. -
For each
sql/*.sqlremaining, insertextension_sql_file!("../sql/that_file.sql");into yoursrc/lib.rs -
If the files depend on entities which already exist, you might need to set a
requiresattribute:extension_sql_file!("../sql/that_file.sql", requires = [ dogs::parts::Floof, some_fn, ]);
-
For any
mod floof { fn boop() { todo!() } }style blocks you were using to infer schema name (making that functionfloof.boop), decorate the schema with#[pg_schema]:#[pg_schema] mod floof { fn boop() { todo!() } }
-
For any functions have a custom
sqlblock for (like below), update that to usepgxsqlnow:/// ```sql <-- Change this to `pgxsql` /// CREATE OR REPLACE FUNCTION .... /// ``` #[pg_extern] fn dot_dot_dot() { todo!() }
-
Run
cargo pgx schemaagain!
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.