From 5594d14696f916e4aad14a3a12a4c15d2e7123bc Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 28 Jun 2011 16:07:23 +0300 Subject: [PATCH] Add composite-type attributes to information_schema.element_types view --- doc/src/sgml/information_schema.sgml | 10 ++++++---- src/backend/catalog/information_schema.sql | 7 ++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/src/sgml/information_schema.sgml b/doc/src/sgml/information_schema.sgml index ab9ce2aa4a..396d3e7636 100644 --- a/doc/src/sgml/information_schema.sgml +++ b/doc/src/sgml/information_schema.sgml @@ -2147,7 +2147,7 @@ The view element_types 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 be of an array type, the respective information schema view only contains ARRAY in the column @@ -2212,9 +2212,11 @@ ORDER BY c.ordinal_position; The type of the object that uses the array being described: one of TABLE (the array is used by a column of - that table), DOMAIN (the array is used by - that domain), ROUTINE (the array is used by - a parameter or the return data type of that function). + that table), USER-DEFINED TYPE (the array is + used by an attribute of that composite type), + DOMAIN (the array is used by that domain), + ROUTINE (the array is used by a parameter or + the return data type of that function). diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql index 9334c7654d..c7ccea3331 100644 --- a/src/backend/catalog/information_schema.sql +++ b/src/backend/catalog/information_schema.sql @@ -2467,12 +2467,13 @@ CREATE VIEW element_types AS 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), - '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 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 UNION ALL -- 2.40.0