From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: kes-kes@yandex.ru, "pgsql-bugs@postgresql.org" <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14164: Postgres allow to insert more data into field than this field allow
Date: Mon, 30 May 2016 15:01:14 -0400
Message-ID: <21416.1464634874@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwZvhOUNTiUa2VYfidFKPcibj7Jd6TmfhEsSAgcidn6d3w@mail.gmail.com>
References: <20160530085041.19432.93208@wrigleys.postgresql.org>
<13914.1464628209@sss.pgh.pa.us>
<CAKFQuwZvhOUNTiUa2VYfidFKPcibj7Jd6TmfhEsSAgcidn6d3w@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Mon, May 30, 2016 at 1:10 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I would say this is a bug in mysql_fdw, not Postgres proper. In general
>> it's the responsibility of an FDW to ensure that data it passes back
>> meets the constraints of the foreign table declaration.
> At some point in this SELECT->INSERT process there has to be a recognition
> that the data we are seeing is external and needs to be validated against
> the rules and assumptions of PostgreSQL. It's not our fault that mysql_fdw
> is broken but it is our fault that we allowed its brokenness to result is
> non-conforming persisted data.
> Either the SELECT should fail because a PostgreSQL varchar(255) cannot hold
> longer data (probably this) or the INSERT should fail so that at least the
> impact of the broken varchar is limited to an active query and doesn't make
> it onto disk.
Indeed, the SELECT should have failed, and it's mysql_fdw that should have
issued the error. We cannot expect to protect users against every sort of
malfeasance or misfeasance that might occur in extension C code. Consider
for example that the Datum mysql_fdw is handing back and claiming to be
varchar(255) might not be textual at all, or it might be in the wrong
encoding, etc etc. It wouldn't even be possible for the core code to
detect some of those cases, and it certainly would impose a lot of
overhead to add checking that should be redundant.
(BTW, I checked this and verified that an equivalent case in postgres_fdw
does throw an error; so it's *possible* for an FDW to get this right.
mysql_fdw simply doesn't.)
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
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: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com
Subject: Re: BUG #14164: Postgres allow to insert more data into field than this field allow
In-Reply-To: <21416.1464634874@sss.pgh.pa.us>
References: <20160530085041.19432.93208@wrigleys.postgresql.org> <13914.1464628209@sss.pgh.pa.us> <CAKFQuwZvhOUNTiUa2VYfidFKPcibj7Jd6TmfhEsSAgcidn6d3w@mail.gmail.com> <21416.1464634874@sss.pgh.pa.us>
* 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