postgresql_ext: use query_params (#64994)
* postgresql_ext: use query_params * added changelog
This commit is contained in:
parent
c53b8030ab
commit
0cadb952f9
3 changed files with 23 additions and 10 deletions
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- postgresql_ext - use query parameters with cursor object (https://github.com/ansible/ansible/pull/64994).
|
|
@ -228,7 +228,9 @@ def ext_update_version(cursor, ext, version):
|
|||
version (str) -- extension version
|
||||
"""
|
||||
if version != 'latest':
|
||||
query = ("ALTER EXTENSION \"%s\" UPDATE TO '%s'" % (ext, version))
|
||||
query = ("ALTER EXTENSION \"%s\"" % ext)
|
||||
cursor.execute(query + " UPDATE TO %(ver)s", {'ver': version})
|
||||
executed_queries.append(cursor.mogrify(query + " UPDATE TO %(ver)s", {'ver': version}))
|
||||
else:
|
||||
query = ("ALTER EXTENSION \"%s\" UPDATE" % ext)
|
||||
cursor.execute(query)
|
||||
|
@ -241,9 +243,14 @@ def ext_create(cursor, ext, schema, cascade, version):
|
|||
if schema:
|
||||
query += " WITH SCHEMA \"%s\"" % schema
|
||||
if version:
|
||||
query += " VERSION '%s'" % version
|
||||
query += " VERSION %(ver)s"
|
||||
if cascade:
|
||||
query += " CASCADE"
|
||||
|
||||
if version:
|
||||
cursor.execute(query, {'ver': version})
|
||||
executed_queries.append(cursor.mogrify(query, {'ver': version}))
|
||||
else:
|
||||
cursor.execute(query)
|
||||
executed_queries.append(query)
|
||||
return True
|
||||
|
@ -267,18 +274,18 @@ def ext_get_versions(cursor, ext):
|
|||
|
||||
# 1. Get the current extension version:
|
||||
query = ("SELECT extversion FROM pg_catalog.pg_extension "
|
||||
"WHERE extname = '%s'" % ext)
|
||||
"WHERE extname = %(ext)s")
|
||||
|
||||
current_version = '0'
|
||||
cursor.execute(query)
|
||||
cursor.execute(query, {'ext': ext})
|
||||
res = cursor.fetchone()
|
||||
if res:
|
||||
current_version = res[0]
|
||||
|
||||
# 2. Get available versions:
|
||||
query = ("SELECT version FROM pg_available_extension_versions "
|
||||
"WHERE name = '%s'" % ext)
|
||||
cursor.execute(query)
|
||||
"WHERE name = %(ext)s")
|
||||
cursor.execute(query, {'ext': ext})
|
||||
res = cursor.fetchall()
|
||||
|
||||
available_versions = []
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
destructive
|
||||
shippable/posix/group4
|
||||
skip/osx
|
||||
skip/centos
|
||||
skip/redhat
|
||||
skip/freebsd
|
||||
skip/opensuse
|
||||
|
|
Loading…
Reference in a new issue