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

postgresql_idx: consider schema name when checking #693

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/693-idx-consider-schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- postgresql_idx - consider schema name when checking for index (https://github.com/ansible-collections/community.postgresql/issues/692). Index names are only unique within a schema. This allows using the same index name in multiple schemas.
5 changes: 3 additions & 2 deletions plugins/modules/postgresql_idx.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,10 @@ def __exists_in_db(self):
"ON i.indexname = c.relname "
"JOIN pg_catalog.pg_index AS pi "
"ON c.oid = pi.indexrelid "
"WHERE i.indexname = %(name)s")
"WHERE i.schemaname = %(schema)s "
"AND i.indexname = %(name)s")

res = exec_sql(self, query, query_params={'name': self.name}, add_to_executed=False)
res = exec_sql(self, query, query_params={'schema': self.schema, 'name': self.name}, add_to_executed=False)
if res:
self.exists = True
self.info = dict(
Expand Down