fix: fix output of RPCs returning scalar values with multiple rows

resolves #1584

BREAKING CHANGE:
Changed output of RPCs to match return type better:
* single scalar return: value (unchanged)
* setof scalar return: array of values (new; was array of objects)
* single composite return: object (new; was array of objects)
* setof composite return: array of objects (unchanged)
* void return: nothing (new; was "null")

A single OUT column is now treated as "composite" instead of "scalar",
i.e. consistent with multiple OUT columns.
This commit is contained in:
Wolfgang Walther
2020-12-10 19:55:42 +01:00
committed by Wolfgang Walther
parent 093fd3c8f6
commit 0c25f12825
8 changed files with 150 additions and 98 deletions
+6 -2
View File
@@ -226,8 +226,12 @@ procsSqlQuery = [q|
tn.nspname AS schema,
COALESCE(comp.relname, t.typname) AS name,
p.proretset AS rettype_is_setof,
-- Only pg pseudo type that is a row type is 'record'
(t.typtype = 'c' or t.typtype = 'p' and t.typname = 'record') AS rettype_is_composite,
(t.typtype = 'c'
-- Only pg pseudo type that is a row type is 'record'
or t.typtype = 'p' and t.typname = 'record'
-- if any INOUT or OUT arguments present, treat as composite
or COALESCE(proargmodes::text[] && '{b,o}', false)
) AS rettype_is_composite,
p.provolatile
FROM pg_proc p
JOIN pg_namespace pn ON pn.oid = p.pronamespace