Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a Regclass type #1773

Open
workingjubilee opened this issue Jul 10, 2024 · 3 comments
Open

Adding a Regclass type #1773

workingjubilee opened this issue Jul 10, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@workingjubilee
Copy link
Member

workingjubilee commented Jul 10, 2024

In pgrx 0.11, if someone passes a regclass (which is an OID... so, a u32, really) to a function, we automatically take a lock on relevant relation and do some things that Postgres hints are maybe not sound because we aren't really checking. This is because we are synthesizing the PgRelation type from that OID.

Previous issue

Is this behavior

  • sound? are the checks Postgres is referencing actually optional in reality? is it okay if we call SPI and pass essentially-random integers into such functions?
  • desirable? implicitly taking a lock without the ability to specify a LOCKMODE seems like it could be prone to being very "that's not what I wanted"?

The absence of its ArgAbi impl was reported as a bug in #1769. Omitting it was not intentional, but I attempted to do a cursory review of the implications of taking the type as an argument and found it surprising.

We've determined this is probably okay despite the comment, but that it's not necessarily desirable. We've selected this implicit LOCKMODE argument which may be okay for many uses but is not really a selection we should be making for you, and there are other reasons for wanting a Regclass that don't have to do with "immediately lock it".

@eeeebbbbrrrr
Copy link
Contributor

It’s useful, that’s for sure.

Perhaps we can extend PgRelation with a ZST to denote the desired lock mode?

that probably requires some attention.

@workingjubilee
Copy link
Member Author

Hm. That certainly sounds plausible!

@workingjubilee
Copy link
Member Author

There was an extended conversation which got into the deep philosophy of how pgrx should handle arguments. It is... mostly out of scope for this issue. However, we kind of think the answer is that our current implementation is useful but not necessarily desirable because of its implicitness. There's other reasons to want a regclass (which is basically an OID, as discussed), and the only reason PgRelation is our current translation for it is that previously there was an assumption that you would always want to take a lock on the relation if you had it as an argument.

So we're going to drop support for PgRelation for now. This issue will remain open as we are going to want to add a semi-proper Regclass type.

@workingjubilee workingjubilee added the enhancement New feature or request label Jul 11, 2024
@workingjubilee workingjubilee changed the title PgRelation as an argument: sound or desirable? Adding a Regclass type Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants