Unable to create table of view row type

From: Isaac Morland <isaac(dot)morland(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Unable to create table of view row type
Date: 2023-02-21 16:12:42
Message-ID: CAMsGm5fdArGBaWVPx1=VbvuDsF11o=+gVLYB4_8DmKWMfWxLZw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I thought I should be able to do this:

=> create view testv as values (1, 'a'), (2, 'b'), (3, 'c');
CREATE VIEW
=> create table testt of testv;
ERROR: type testv is not a composite type

But as you can see I can’t. pg_type seems to think the type is composite:

ijmorlan=> select typtype from pg_type where typname = 'testv';
typtype
─────────
c
(1 row)

I’m guessing there are good reasons this isn’t supported, so I’m thinking
to provide a documentation patch for CREATE TABLE and ALTER TABLE to
specify that the type given for OF type_name must be a
non-relation-row-type composite type.

Am I missing something?

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2023-02-21 16:17:17 Commitfest Manager
Previous Message Heikki Linnakangas 2023-02-21 15:40:31 Re: refactoring relation extension and BufferAlloc(), faster COPY