The following bug has been logged on the website:
Bug reference: 13751
Logged by: Stefan Stefanov
Email address: stefanov.sm@abv.bg
PostgreSQL version: 9.5beta1
Operating system: Windows 7 x64
Description:
Define this function:
CREATE OR REPLACE FUNCTION demi.order_stat() RETURNS SETOF
demi.order_status_type AS
$BODY$
SELECT mr.id AS "ÐаÑÑида", mr.name AS "ÐÑÑпа клиенÑи",
COUNT(*) FILTER (WHERE sl.value = 0) AS "ÐепÑеÑеглени",
COUNT(*) AS "ÐÑиÑки"
FROM demi.master mr INNER JOIN demi.slave sl ON mr.id = sl.master_id
WHERE mr.ready = 0
GROUP BY mr.id, mr.name;
$BODY$
LANGUAGE sql STABLE;
When you select the function in Object browser or rightclick-Scripts-Create
scrit then the script has an extra SETOF:
-- Function: demi.order_stat()
-- DROP FUNCTION demi.order_stat();
CREATE OR REPLACE FUNCTION demi.order_stat()
RETURNS SETOF SETOF demi.order_status_type AS
$BODY$
SELECT mr.id AS "ÐаÑÑида", mr.name AS "ÐÑÑпа клиенÑи",
COUNT(*) FILTER (WHERE sl.value = 0) AS "ÐепÑеÑеглени",
COUNT(*) AS "ÐÑиÑки"
FROM demi.master mr INNER JOIN demi.slave sl ON mr.id = sl.master_id
WHERE mr.ready = 0
GROUP BY mr.id, mr.name;
$BODY$
LANGUAGE sql STABLE
COST 100
ROWS 1000;
ALTER FUNCTION demi.order_stat()
OWNER TO postgres;