Skip to content

Commit

Permalink
Adapt the query used to get functions metadata to PG11
Browse files Browse the repository at this point in the history
This fixes dbcli#919.
  • Loading branch information
lelit committed Jul 25, 2018
1 parent 6a18b6d commit 05ec05c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Bug fixes:
----------

* Fix for error retrieving version in Redshift (#922). (Thanks: `Irina Truong`_)
* Adapt the query used to get functions metadata to PG11 (#919). (Thanks: `Lele Gaifax`_).

1.10.2
======
Expand Down
20 changes: 19 additions & 1 deletion pgcli/pgexecute.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,25 @@ def foreignkeys(self):
def functions(self):
"""Yields FunctionMetadata named tuples"""

if self.conn.server_version > 90000:
if self.conn.server_version >= 110000:
query = '''
SELECT n.nspname schema_name,
p.proname func_name,
p.proargnames,
COALESCE(proallargtypes::regtype[], proargtypes::regtype[])::text[],
p.proargmodes,
prorettype::regtype::text return_type,
p.prokind = 'a' is_aggregate,
p.prokind = 'w' is_window,
p.proretset is_set_returning,
pg_get_expr(proargdefaults, 0) AS arg_defaults
FROM pg_catalog.pg_proc p
INNER JOIN pg_catalog.pg_namespace n
ON n.oid = p.pronamespace
WHERE p.prorettype::regtype != 'trigger'::regtype
ORDER BY 1, 2
'''
elif self.conn.server_version > 90000:
query = '''
SELECT n.nspname schema_name,
p.proname func_name,
Expand Down

0 comments on commit 05ec05c

Please sign in to comment.