From: taylor.reece@zuerchertech.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14177: ARRAYs in VIEWs are inconsistently cast
Date: Fri, 03 Jun 2016 22:17:05 +0000
Message-ID: <20160603221705.9932.64085@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 14177
Logged by: Taylor Reece
Email address: taylor.reece@zuerchertech.com
PostgreSQL version: 9.5.3
Operating system: Ubuntu Server 14.04 and 16.04
Description:
This is an issue I've noticed throughout 9.3.*, and now in 9.5.*. If I
define a VIEW ('v1', below), and then use that VIEW's compiled definition to
create a second VIEW ('v2', below), the two VIEWs have different compiled
definitions.
I first discovered this inconsistency when I ran pg_dump on a database and
restored the backup to another server. The servers' schemas were not
completely consistent with one another, despite running identical versions
of psql.
I recognize that the differences in VIEW definitions are cosmetic -- they're
functionally equivalent. One casts an ARRAY of VARCHAR to ::text[] while
the other casts the elements individually to VARCHAR and then TEXT. In an
effort to keep database schema completely identical, though, it would be
nice if a pg_dump into a pg_restore resulted in exactly identical schema.
An example of how to replicate the issue follows. Thank you in advance for
your expertise, and for such an awesome DB product!
-Taylor
...
user@server:/tmp# psql d1
psql (9.5.3)
Type "help" for help.
d1=# CREATE TABLE t (a CHARACTER VARYING);
CREATE TABLE
d1=# CREATE VIEW v1 AS SELECT a FROM t WHERE t.a IN ('b','c');
CREATE VIEW
d1=# \d+ v1
View "public.v1"
Column | Type | Modifiers | Storage | Description
--------+-------------------+-----------+----------+-------------
a | character varying | | extended |
View definition:
SELECT t.a
FROM t
WHERE t.a::text = ANY (ARRAY['b'::character varying, 'c'::character
varying]::text[]);
d1=# CREATE VIEW v2 AS SELECT t.a
d1-# FROM t
d1-# WHERE t.a::text = ANY (ARRAY['b'::character varying, 'c'::character
varying]::text[]);
CREATE VIEW
d1=# \d+ v2
View "public.v2"
Column | Type | Modifiers | Storage | Description
--------+-------------------+-----------+----------+-------------
a | character varying | | extended |
View definition:
SELECT t.a
FROM t
WHERE t.a::text = ANY (ARRAY['b'::character varying::text, 'c'::character
varying::text]);
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: taylor.reece@zuerchertech.com
Subject: Re: BUG #14177: ARRAYs in VIEWs are inconsistently cast
In-Reply-To: <20160603221705.9932.64085@wrigleys.postgresql.org>
References: <20160603221705.9932.64085@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox