Commit 5594d146 authored by Peter Eisentraut's avatar Peter Eisentraut

Add composite-type attributes to information_schema.element_types view

parent c533c147
...@@ -2147,7 +2147,7 @@ ...@@ -2147,7 +2147,7 @@
<para> <para>
The view <literal>element_types</literal> contains the data type The view <literal>element_types</literal> contains the data type
descriptors of the elements of arrays. When a table column, descriptors of the elements of arrays. When a table column, composite-type attribute,
domain, function parameter, or function return value is defined to domain, function parameter, or function return value is defined to
be of an array type, the respective information schema view only be of an array type, the respective information schema view only
contains <literal>ARRAY</literal> in the column contains <literal>ARRAY</literal> in the column
...@@ -2212,9 +2212,11 @@ ORDER BY c.ordinal_position; ...@@ -2212,9 +2212,11 @@ ORDER BY c.ordinal_position;
<entry> <entry>
The type of the object that uses the array being described: one The type of the object that uses the array being described: one
of <literal>TABLE</literal> (the array is used by a column of of <literal>TABLE</literal> (the array is used by a column of
that table), <literal>DOMAIN</literal> (the array is used by that table), <literal>USER-DEFINED TYPE</literal> (the array is
that domain), <literal>ROUTINE</literal> (the array is used by used by an attribute of that composite type),
a parameter or the return data type of that function). <literal>DOMAIN</literal> (the array is used by that domain),
<literal>ROUTINE</literal> (the array is used by a parameter or
the return data type of that function).
</entry> </entry>
</row> </row>
......
...@@ -2467,12 +2467,13 @@ CREATE VIEW element_types AS ...@@ -2467,12 +2467,13 @@ CREATE VIEW element_types AS
FROM pg_namespace n, pg_type at, pg_namespace nbt, pg_type bt, FROM pg_namespace n, pg_type at, pg_namespace nbt, pg_type bt,
( (
/* columns */ /* columns, attributes */
SELECT c.relnamespace, CAST(c.relname AS sql_identifier), SELECT c.relnamespace, CAST(c.relname AS sql_identifier),
'TABLE'::text, a.attnum, a.atttypid CASE WHEN c.relkind = 'c' THEN 'USER-DEFINED TYPE'::text ELSE 'TABLE'::text END,
a.attnum, a.atttypid
FROM pg_class c, pg_attribute a FROM pg_class c, pg_attribute a
WHERE c.oid = a.attrelid WHERE c.oid = a.attrelid
AND c.relkind IN ('r', 'v', 'f') AND c.relkind IN ('r', 'v', 'f', 'c')
AND attnum > 0 AND NOT attisdropped AND attnum > 0 AND NOT attisdropped
UNION ALL UNION ALL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment