[9.3] Automatically updatable views vs writable foreign tables

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: [9.3] Automatically updatable views vs writable foreign tables
Date: 2013-05-16 19:41:04
Message-ID: CAEZATCXi3yYomexaQqPapF++oBc4i-GwUD_hB4aAVbU4eGkA7Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I've just started 9.3 beta testing and I noticed that a "simple" view
defined on top of a writable foreign table is not automatically
updatable.

Given that these are both new-to-9.3 features, I think it would be a
shame if they don't work together. It's basically a 1-line patch to
make such views automatically updatable, plus a small extra code block
in relation_is_updatable() to reflect the change in the
information_schema views.

The attached patch does that and adds a couple of extra regression tests.

The tests, however, reveal a separate issue with writable foreign
tables --- the information_schema views haven't been updated to
reflect the fact that foreign tables may now be updatable.
Specifically, for foreign tables
information_schema.tables.is_insertable_into and
information_schema.columns.is_updatable always say 'NO' even if the
foreign table is writable. Fixing that would require new C functions
along the same lines as pg_view_is_insertable/updatable(), or those
functions could just be renamed and repurposed to do the check for all
relation kinds, except those known to be always/never updatable.

Regards,
Dean

Attachment Content-Type Size
writable-fdw-view.patch application/octet-stream 9.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nelson Minar 2013-05-16 20:45:49 Re: BUG #8167: false EINVAL -22 for opening a file
Previous Message Peter Geoghegan 2013-05-16 18:42:41 Re: Better handling of archive_command problems