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

Allow GRANTs to PUBLIC #61

Closed
craigmaclachlan opened this issue Mar 11, 2022 · 1 comment · Fixed by #106
Closed

Allow GRANTs to PUBLIC #61

craigmaclachlan opened this issue Mar 11, 2022 · 1 comment · Fixed by #106
Labels
enhancement New feature or request

Comments

@craigmaclachlan
Copy link

I just started using the provider and ran into an issue. I tried to grant permissions on a new schema to public, but this caused an error and broke my state file. Setting the user to be "public" results in an error like this during plan:

Error: failed to get user ID: sql: no rows in result set

I think the issue is when trying to check the state, the code runs a query filtering for the username, but public is special, so it isn't listed.

func readSchemaGrants(db *DBConnection, d *schema.ResourceData) error {

Would it be possible to add functionality to handle public?

@farfromunique
Copy link

I can confirm that any attempt to grant or revoke permissions on the public schema will break the statefile. Specifically, when the state is refreshed, TF properly parses and handles things until it comes to the grant for public. That returns 0 rows (because public is a special schema), and TF immediately throws an error.

I can see a few ways around this:

  • Add an escape hatch to the code mentioned above, to bypass the queries if the schema name is 'public'
    • If this is used, we should also include any other schemas that have this issue
    • Documentation would need to be updated to reflect this
  • Add an additional check to the code, so that it runs a query that works properly for 'public' (and any other schemas with this issue)
  • Change the used query to give results no matter what schema is queried
  • Add an error during parsing if a GRANT is specified for the 'public' schema
    • This would also need documentation updated
  • Add a message to the documentation saying, basically, "DO NOT DO THIS!" and make it an own-risk type of thing

Personally, I'd vote for changing the query, but I don't know if there's a query that would do this.

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

Successfully merging a pull request may close this issue.

3 participants