Обсуждение: Rewrite view?

Поиск
Список
Период
Сортировка

Rewrite view?

От
Hao Wu
Дата:
Hi hackers,

When I define a view relevant with `char varying`, it shows the type is casted to text. See,

gpadmin=# CREATE TABLE foobar (a character varying);
CREATE TABLE
gpadmin=# CREATE VIEW fooview AS SELECT * FROM foobar WHERE a::character varying = ANY(ARRAY['foo'::character varying, 'bar'::character varying]);
CREATE VIEW
gpadmin=# \d+ fooview
                                View "public.fooview"
 Column |       Type        | Collation | Nullable | Default | Storage  | Description
--------+-------------------+-----------+----------+---------+----------+-------------
 a      | character varying |           |          |         | extended |
View definition:
 SELECT foobar.a
   FROM foobar
  WHERE foobar.a::text = ANY (ARRAY['foo'::character varying, 'bar'::character varying]::text[]);

gpadmin=# create view barview as select * from foobar where a=any(array['foo','bar']);
CREATE VIEW
gpadmin=# \d+ barview
                                View "public.barview"
 Column |       Type        | Collation | Nullable | Default | Storage  | Description
--------+-------------------+-----------+----------+---------+----------+-------------
 a      | character varying |           |          |         | extended |
View definition:
 SELECT foobar.a
   FROM foobar
  WHERE foobar.a::text = ANY (ARRAY['foo'::text, 'bar'::text]);


My question is that is it an expected behavior or not?
Thank you.

Regards,
Hao Wu