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

Functions require schema prefix #49

Open
tqwewe opened this issue Nov 28, 2022 · 2 comments
Open

Functions require schema prefix #49

tqwewe opened this issue Nov 28, 2022 · 2 comments

Comments

@tqwewe
Copy link
Contributor

tqwewe commented Nov 28, 2022

When calling functions, it seems like I need to prefix with message_store., otherwise I get an error saying the function does not exist.

Though, even when executing a function with the prefix, it fails since the body of the function itself calls another function but doesn't include the schema prefix.

SELECT * FROM message_store.get_stream_messages('someStream-123', 0, 1000, condition => 'messages.time::time >= current_time');
ERROR:  function is_category(character varying) does not exist
LINE 1: is_category(get_stream_messages.stream_name)
        ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
QUERY:  is_category(get_stream_messages.stream_name)
CONTEXT:  PL/pgSQL function message_store.get_stream_messages(character varying,bigint,bigint,character varying) line 6 at IF
SQL state: 42883

I believe the is_category function should be message_store.is_category in this snippet:
https://github.com/message-db/message-db/blob/master/database/functions/get-stream-messages.sql#L13

Its possible this prefix might need to be added to other functions, I just haven't done much testing.


Also, is there any reason why I'm forced to use the schema prefix? It seems like other people don't have this problem?

@nordfjord
Copy link

nordfjord commented Nov 28, 2022

#42

There was discussion on this in the above PR. By default Postgres will add the role’s name to its search path and MessageDB is intended to be used in tandem with a search path that includes message_store. If you’re not using the provided role you’ll need to alter the search path of your role. A few methods for doing that were described in the above PR

#43 (comment)
This issue indicates this’ll not be a problem in the next major version

@tqwewe
Copy link
Contributor Author

tqwewe commented Apr 17, 2024

Here's fun little workaround for anyone in the future needing to get around this.
You can modify the search path in the connection string directly:
?options=-c%20search_path%3Dmessage_store

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

No branches or pull requests

2 participants