The following bug has been logged on the website:
Bug reference: 13776
Logged by: Joshua Yanovski
Email address: pythonesque@gmail.com
PostgreSQL version: 9.4.5
Operating system: Mac OS X 10.10.2
Description:
The below instructions provide a reproducible testcase. Essentially, the
view definition is invalid SQL, so when you try to restore from a dump with
a view like this you get an error and can't proceed. Currently I'm working
around it by using ROW(ROW(foo.*)) instead, but it seems to me that the
semantics there are slightly different since adding a column to foo won't
automatically add it to the view (though maybe this is desirable).
---
# CREATE TABLE foo ();
# CREATE TYPE bar AS (x foo);
# CREATE VIEW baz AS SELECT ROW(foo)::bar FROM foo;
# \d+ baz
View definition:
SELECT ROW(foo.*)::bar AS "row"
FROM foo;
# SELECT ROW(foo.*)::bar AS "row"
FROM foo;
ERROR: cannot cast type record to bar
LINE 1: SELECT ROW(foo.*)::bar AS "row"
^
DETAIL: Input has too few columns.