BUG #13776: Views with nested composite attributes can break pg_dump
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.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
pythonesque@gmail.com writes:
# 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;
Fixed, thanks for the report!
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
I actually found another place that it also affects (RowCompareExpr)
but that should be a two-line fix with the new function.
On Sun, Nov 15, 2015 at 11:42 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
pythonesque@gmail.com writes:
# 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;Fixed, thanks for the report!
regards, tom lane
--
Josh
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs