Skip to content

Conversation

@YohDeadfall
Copy link
Contributor

No description provided.

@YohDeadfall YohDeadfall changed the title Addex mapping for xid Added mapping for xid Mar 17, 2025
@eeeebbbbrrrr
Copy link
Contributor

@YohDeadfall I think this looks good, outside of the one minor change. I think #2014 is going to force a pgrx v0.14.0, so now is a great time to go ahead and get this finished and committed.

}

#[inline]
pub const fn to_u32(self) -> u32 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really fine? I would like to avoid any further name bikeshading as it's a little disaster even if another method added and this marked as deprecated. Shouldn't it be into_u32?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly, we should call this into_inner(self) and then do the same over on pg_sys::Oid and close #2011.

And there's also no need for this from_u32(xid: u32) function either, because of impl From<u32> for TransactionId down below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from_u32 is for const only since traits cannot have that modifier on the functions. It can be removed, but then it won't be possible to use during compiler time.

If there's no need in const fns then I see no reason in from_smthg and into_smthg at all as there are from and into. Makes sense?

}

#[inline]
pub const fn to_u32(self) -> u32 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly, we should call this into_inner(self) and then do the same over on pg_sys::Oid and close #2011.

And there's also no need for this from_u32(xid: u32) function either, because of impl From<u32> for TransactionId down below.


/// An `xid` type from PostgreSQL
#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also want to impl Display too. Have it just be the u32 value. It's not uncommon to want to convert a transaction id into a string for logging purposes

Copy link
Contributor

@eeeebbbbrrrr eeeebbbbrrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your diligence on this one, @YohDeadfall !

@eeeebbbbrrrr eeeebbbbrrrr merged commit e675e7d into pgcentralfoundation:develop Apr 11, 2025
16 checks passed
@YohDeadfall YohDeadfall deleted the xid branch April 18, 2025 16:03
KenjiBrown pushed a commit to SoftwareLibreMx/pgrx that referenced this pull request May 27, 2025
daamien pushed a commit to daamien/pgrx that referenced this pull request Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants