K8SPG-571 public schema access fix #1201
Merged
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.
CHANGE DESCRIPTION
Problem:
The logs show the following error message: "stderr": "psql::5: ERROR: role "username" does not exist
This occurred in this part of the method:
GRANT ALL PRIVILEGES ON SCHEMA public TO :"username";
The problem is with using :"username" in the SQL. This kind of placeholder works for values, but not for names like roles, or users.
Names (called identifiers) must be written directly in the SQL. Placeholders don’t work for them.
In our case:
GRANT ALL PRIVILEGES ON SCHEMA public TO :"username";
PostgreSQL looks for a role literally named "username", instead of using the actual value. Since that role doesn’t exist, we get an error.
Cause:
Short explanation of the root cause of the issue if applicable.
Solution:
Instead of using a placeholder like :"username" in the SQL, we insert the actual username directly into the SQL string.
CHECKLIST
Jira
Needs Doc
) and QA (Needs QA
)?Tests
Config/Logging/Testability