I have a composite type like
CREATE TYPE example AS (id integer, some_stuff integer[]);
我希望我可以使用这种类型的数组作为函数的参数。唯一的问题是我找不到一种方法来构建该类型的数组字面量...如果我试图从PostgreSQL中获取它:
WITH elements AS (
SELECT (12, '{1,2}')::example AS e UNION
SELECT (3, '{3,1}')::example
)
SELECT array_agg(e) FROM elements;
我收到了以下内容:
{"(3,\"{3,1}\")","(12,\"{1,2}\")"}
但是看:
SELECT E'{"(3,\"{3,1}\")","(12,\"{1,2}\")"}'::example[];
ERROR: malformed array literal: "{"(3,"{3,1}")","(12,"{1,2}")"}"
LINE 1: select E'{"(3,\"{3,1}\")","(12,\"{1,2}\")"}'::example[]
有没有一种方法可以做到这一点?