Skip to content

Commit

Permalink
postgresql_idx: misc fixes (#50199)
Browse files Browse the repository at this point in the history
* Removed unused import
* Removed 'login_password' from exit_json call
* Removed unused db, cond variable

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
  • Loading branch information
Akasurde committed Dec 21, 2018
1 parent 064825d commit fc5ea7c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/ansible/modules/database/postgresql/postgresql_idx.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
idxname: test_gist_idx
# Create gin index gin0_idx not concurrently on column comment of table test
# (Note: pg_trgm extention must be installed for gin_trgm_ops)
# (Note: pg_trgm extension must be installed for gin_trgm_ops)
- postgresql_idx:
idxname: gin0_idx
table: test
Expand All @@ -154,7 +154,6 @@


import traceback
from hashlib import md5

try:
import psycopg2
Expand Down Expand Up @@ -217,9 +216,6 @@ def index_create(cursor, module, idxname, tblname, idxtype,
else:
condition = 'WHERE %s' % cond

if cond is not None:
cond = " WHERE %s" % cond

for column in columns.split(','):
column.strip()

Expand All @@ -240,7 +236,6 @@ def index_create(cursor, module, idxname, tblname, idxtype,
# ERROR: cannot execute ALTER ROLE in a read-only transaction
changed = False
module.fail_json(msg=e.pgerror, exception=traceback.format_exc())
return changed
else:
raise psycopg2.InternalError(e)
return changed
Expand All @@ -266,7 +261,6 @@ def index_drop(cursor, module, idxname, concurrent=True):
# ERROR: cannot execute ALTER ROLE in a read-only transaction
changed = False
module.fail_json(msg=e.pgerror, exception=traceback.format_exc())
return changed
else:
raise psycopg2.InternalError(e)
return changed
Expand Down Expand Up @@ -298,7 +292,6 @@ def main():
)

idxname = module.params["idxname"]
db = module.params["db"]
state = module.params["state"]
concurrent = module.params["concurrent"]
table = module.params["table"]
Expand Down Expand Up @@ -377,6 +370,7 @@ def main():

if state == 'present' and index_exists(cursor, idxname):
kw['changed'] = False
del kw['login_password']
module.exit_json(**kw)

changed = False
Expand Down Expand Up @@ -419,6 +413,7 @@ def main():
module.fail_json(msg="Index %s is invalid!" % idxname)

kw['changed'] = changed
del kw['login_password']
module.exit_json(**kw)


Expand Down

0 comments on commit fc5ea7c

Please sign in to comment.