-
Notifications
You must be signed in to change notification settings - Fork 62
Use fully qualified names for functions and tables #42
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
Conversation
Context: when you grant message_store to another role that does not automatically change that roles search_path to include "message_store" In order for message-db to work in those scenarios we need to use qualified function names
Hi, @nordfjord. I'm not sure I understand what you mean by:
I'm finding the description of the problem a bit ambiguous. It might be a language barrier, or punctuation. Nevertheless, I'm struggling to parse the sentence so that I can grasp exactly the problem being pointed out. |
I'm not the OP here, but the description rang a bell for an issue we've run into. In PG, a role's name is included in its search path. So if you only connect to MessageDB as the If you create separate sets of credentials for different components that inherit from We've solved this by adding In Eventide though, unless a change were released to |
That's totally fair, reading through it again I feel the same sense of confusion 😓. let me try to clarify Let's say I have a user on postgres called grant message_store to service_user; This in turn allows the Then using that user I can run a query: select * from message_store.get_category_messages('MyCategory', 0); However because
In order to solve the error I have a few options: Alter the search path of the user for the duration of the session set search_path = message_store, public; Alter the search path of the user for the database in question alter role "service_user" in database "whatever" SET search_path TO public, message_store; Open this PR to ensure we don't need the search path at all Minimal reproduction of the issue$ DATABASE_NAME=whatever ./install.sh
$ psql -c 'create role service_user; grant message_store to service_user'
$ psql -c "set session authorization service_user; select * from message_store.get_category_messages('MyCategory', 0)" |
Thanks, @nordfjord and @juanpaco. I have a better understanding now. The intended use case is to use Postgres' search path. The current implementation is explicitly designed to allow for function overriding. Leveraging the search path allows adopters to override any of Message DB's functions additively, rather than destructively by installing the override into another schema, and giving that schema precedence in the search path. A change like the one proposed in the PR would require a great deal more consideration and scrutiny before we could proceed with it, as it implies a rather significant shift in how function overriding is expected to work. Message DB can't be allowed to take a position where it denies adopters the means to provide specializations of Message DB's functions, especially when those means are common practices in Postgres. We'll give the issue more thought as a matter of due diligence, but it's not a change that can be adopted with immediacy. |
@nordfjord out of curiosity, have you tried modifying the |
Yes, I’m currently using the “alter the default search path” workaround |
Thanks for the context, I was not aware of this being a goal of message db. I’m happy to close this issue in that light. would you consider a PR that documents the search_path altering required for using different roles instead? |
@nordfjord Per my comment on the PR on the Eventide docs, I don't really see it as appropriate to document Postgres features and capabilities in Message DB's docs. We have to assume that Message DB users have a basic fluency with Postgres. Those who go beyond the basics and pursue any kind of specializations are presumed to have the knowledge and experience to be comfortable and safe making those specializations. |
In the next major version of Message DB (ideally some time in 2023), this policy will be reversed. Here's the work item: #43 |
Thanks for taking the time to consider this @sbellware! I appreciate the thoughtfulness of your writing and feedback. |
@nordfjord Sure thing! Sorry we could be more responsive in a shorter period of time. |
Context: when you grant
message_store
to another role, that role does not automatically have it'ssearch_path
altered to includemessage_store
In order for message-db to work in those scenarios we need to use qualified function names
Edit: clarified the grammar of the context