Allows to create multiple aggregates for the same Rust type#2078
Merged
eeeebbbbrrrr merged 8 commits intopgcentralfoundation:developfrom Jun 28, 2025
Merged
Allows to create multiple aggregates for the same Rust type#2078eeeebbbbrrrr merged 8 commits intopgcentralfoundation:developfrom
eeeebbbbrrrr merged 8 commits intopgcentralfoundation:developfrom
Conversation
eeeebbbbrrrr
approved these changes
May 31, 2025
Contributor
eeeebbbbrrrr
left a comment
There was a problem hiding this comment.
Thanks.
As soon as you have a chance to resolve the conflicts (likely caused by recent PRs) I'll be happy to merge.
Contributor
|
@eeeebbbbrrrr let's see if CI passes now? Seems @if0ne did some work for it. |
eeeebbbbrrrr
added a commit
that referenced
this pull request
Jun 28, 2025
Welcome to pgrx v0.15.0. This begins a new series for pgrx that includes support for Postgres 18. As of this release, that means Postgres 18beta1. This release does contain a few breaking API changes but they're largely mechanical. Don't worry, the compiler will let you know! As always, please install our CI tool with `cargo install cargo-pgrx --version 0.15.0 --locked` and then run `cargo pgrx upgrade` in all of your extension crates. If you want to start working with Postgres 18beta1, you'll also need to re-init your pgrx environment with `cargo pgrx init`. That will automatically detect all the latest Postgres versions, including 18beta1. At the top here, I'd like to thank @silver-ymz for the 18beta1 support. It was a pleasant surprise to see that work come from the community -- it's no easy task to add a new Postgres version to pgrx! That said, as Postgres 18 is currently beta, you should consider pgrx' support for it as beta too. Please report any problems with 18beta1 (or discrepancies with other versions) as GitHub issues. Also, this release requires rust v1.88.0 or greater. `if-let` chains are now a thing and we're not afraid to use them. # What's Changed ## Postgres 18beta1 Support * Support Postgres 18beta1 by @silver-ymz in #2056 * pg18 support: add header and implement `#define` by @eeeebbbbrrrr in #2094 * improve pg_magic_func by @usamoi in #2088 ## More Headers * Added `catalog/heap.h` binding by @ccleve in #2072 * include `utils/pg_status.h` by @eeeebbbbrrrr in #2091 ## `cargo-pgrx` improvements * Pass `LLVM_*` variables to `--runas` command by @theory in #2083 * `does_db_exist()`: fix `psql` argument order by @eeeebbbbrrrr in #2093 * `cargo pgrx regress` output is no longer fully buffered by @eeeebbbbrrrr in #2095 * Detect `pgrx_embed` name from lib name by @YohDeadfall in #2035 * Fixed error message if no artifact found by @YohDeadfall in #2034 * `cargo-pgrx`: use system certificate store for HTTPS validation by @charmitro in #2074 * Decoding command output in Windows by @if0ne in #2084 ## Breaking Changes * fix GUC by @usamoi in #2064 * refactor GUC by @usamoi in #2066 ## New Stuff * Added `pg_binary_protocol` attribute to derive send and receive functions for `PostgresType` by @LucaCappelletti94 in #2068 * Expose guc hooks by @thesuhas in #2075 * Allows to create multiple aggregates for the same Rust type by @if0ne in #2078 ## General Code Cleanup * `cargo clippy --fix` by @eeeebbbbrrrr in #2092 * Use `if-let` to unpack Options by @stuhood in #2089 * docs: fix typo in `rust_byte_slice_to_bytea()` docs by @burmecia in #2071 * Added a missing `#[doc(hidden)]` by @LucaCappelletti94 in #2079 ## Administrative * Updated Fedora to latest in CI by @YohDeadfall in #2085 * fix ci on beta rust (1.89) by @usamoi in #2087 ## New Contributors Much thanks to our new contributors! Your work is sincerely appreciated! * @charmitro made their first contribution in #2074 * @thesuhas made their first contribution in #2075 * @if0ne made their first contribution in #2084 * @stuhood made their first contribution in #2089 **Full Changelog**: v0.14.3...v0.15.0
daamien
pushed a commit
to daamien/pgrx
that referenced
this pull request
Dec 15, 2025
…lfoundation#2078) Closes pgcentralfoundation#2077 Unfortunately, the rust doesn't allow using `&'static str` in const generic yet. This would allow simply moving an associative constant to a generic trait. Therefore an auxiliary trait `ToAggregateName` with associative constant `NAME` was added. This allows `Aggregate` to be implemented multiple times for the same type with different names. This change introduces a bit of boilerplate. In order to simplify the use of this trait, a derive macro `AggregateName` has been developed, which automatically implements this trait. In this case, `NAME` becomes equal to the name of the structure for which this macro is used. To change the name of the name you should use attribute `#[aggregate_name = “custom_name”]`. Example: ```rust #[derive(Copy, Clone, Default, Debug, PostgresType, Serialize, Deserialize)] pub struct DemoOps { count: i32, } struct DemoSumName; // Using derive macro #[derive(AggregateName)] #[aggregate_name = "demo_sub"] struct DemoSubName; // Explicit trait implementation impl ToAggregateName for DemoSumName { const NAME: &'static str = "demo_sum"; } // The first aggregate: #[pg_aggregate] impl Aggregate<DemoSumName> for DemoOps { /* implementation */ } // The second aggregate: #[pg_aggregate] impl Aggregate<DemoSubName> for DemoOps { /* implementation */ } ``` **BREAKING CHANGES**: Now for the `Aggregate` trait you need to specify a generic parameter that implements the `ToAggregateName` trait. I tried to leave backwards compatibility, but decided to break it after all so that developers using `pgrx` would see that the semantics of the `Aggregate` trait had changed.
daamien
pushed a commit
to daamien/pgrx
that referenced
this pull request
Dec 15, 2025
Welcome to pgrx v0.15.0. This begins a new series for pgrx that includes support for Postgres 18. As of this release, that means Postgres 18beta1. This release does contain a few breaking API changes but they're largely mechanical. Don't worry, the compiler will let you know! As always, please install our CI tool with `cargo install cargo-pgrx --version 0.15.0 --locked` and then run `cargo pgrx upgrade` in all of your extension crates. If you want to start working with Postgres 18beta1, you'll also need to re-init your pgrx environment with `cargo pgrx init`. That will automatically detect all the latest Postgres versions, including 18beta1. At the top here, I'd like to thank @silver-ymz for the 18beta1 support. It was a pleasant surprise to see that work come from the community -- it's no easy task to add a new Postgres version to pgrx! That said, as Postgres 18 is currently beta, you should consider pgrx' support for it as beta too. Please report any problems with 18beta1 (or discrepancies with other versions) as GitHub issues. Also, this release requires rust v1.88.0 or greater. `if-let` chains are now a thing and we're not afraid to use them. # What's Changed ## Postgres 18beta1 Support * Support Postgres 18beta1 by @silver-ymz in pgcentralfoundation#2056 * pg18 support: add header and implement `#define` by @eeeebbbbrrrr in pgcentralfoundation#2094 * improve pg_magic_func by @usamoi in pgcentralfoundation#2088 ## More Headers * Added `catalog/heap.h` binding by @ccleve in pgcentralfoundation#2072 * include `utils/pg_status.h` by @eeeebbbbrrrr in pgcentralfoundation#2091 ## `cargo-pgrx` improvements * Pass `LLVM_*` variables to `--runas` command by @theory in pgcentralfoundation#2083 * `does_db_exist()`: fix `psql` argument order by @eeeebbbbrrrr in pgcentralfoundation#2093 * `cargo pgrx regress` output is no longer fully buffered by @eeeebbbbrrrr in pgcentralfoundation#2095 * Detect `pgrx_embed` name from lib name by @YohDeadfall in pgcentralfoundation#2035 * Fixed error message if no artifact found by @YohDeadfall in pgcentralfoundation#2034 * `cargo-pgrx`: use system certificate store for HTTPS validation by @charmitro in pgcentralfoundation#2074 * Decoding command output in Windows by @if0ne in pgcentralfoundation#2084 ## Breaking Changes * fix GUC by @usamoi in pgcentralfoundation#2064 * refactor GUC by @usamoi in pgcentralfoundation#2066 ## New Stuff * Added `pg_binary_protocol` attribute to derive send and receive functions for `PostgresType` by @LucaCappelletti94 in pgcentralfoundation#2068 * Expose guc hooks by @thesuhas in pgcentralfoundation#2075 * Allows to create multiple aggregates for the same Rust type by @if0ne in pgcentralfoundation#2078 ## General Code Cleanup * `cargo clippy --fix` by @eeeebbbbrrrr in pgcentralfoundation#2092 * Use `if-let` to unpack Options by @stuhood in pgcentralfoundation#2089 * docs: fix typo in `rust_byte_slice_to_bytea()` docs by @burmecia in pgcentralfoundation#2071 * Added a missing `#[doc(hidden)]` by @LucaCappelletti94 in pgcentralfoundation#2079 ## Administrative * Updated Fedora to latest in CI by @YohDeadfall in pgcentralfoundation#2085 * fix ci on beta rust (1.89) by @usamoi in pgcentralfoundation#2087 ## New Contributors Much thanks to our new contributors! Your work is sincerely appreciated! * @charmitro made their first contribution in pgcentralfoundation#2074 * @thesuhas made their first contribution in pgcentralfoundation#2075 * @if0ne made their first contribution in pgcentralfoundation#2084 * @stuhood made their first contribution in pgcentralfoundation#2089 **Full Changelog**: pgcentralfoundation/pgrx@v0.14.3...v0.15.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2077
Unfortunately, the rust doesn't allow using
&'static strin const generic yet. This would allow simply moving an associative constant to a generic trait. Therefore an auxiliary traitToAggregateNamewith associative constantNAMEwas added. This allowsAggregateto be implemented multiple times for the same type with different names.This change introduces a bit of boilerplate. In order to simplify the use of this trait, a derive macro
AggregateNamehas been developed, which automatically implements this trait. In this case,NAMEbecomes equal to the name of the structure for which this macro is used. To change the name of the name you should use attribute#[aggregate_name = “custom_name”].Example:
BREAKING CHANGES: Now for the
Aggregatetrait you need to specify a generic parameter that implements theToAggregateNametrait. I tried to leave backwards compatibility, but decided to break it after all so that developers usingpgrxwould see that the semantics of theAggregatetrait had changed.