From 05ec05c4cb4f3e28ac258190f02dd8b98c49ddb6 Mon Sep 17 00:00:00 2001 From: Lele Gaifax Date: Tue, 24 Jul 2018 17:47:35 +0200 Subject: Adapt the query used to get functions metadata to PG11 This fixes #919. --- changelog.rst | 1 + pgcli/pgexecute.py | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/changelog.rst b/changelog.rst index 043c069f..f2dc938f 100644 --- a/changelog.rst +++ b/changelog.rst @@ -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 ====== diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index 0d55ab01..8bcc5c63 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -618,7 +618,25 @@ class PGExecute(object): 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, -- cgit v1.2.3