On Wed, Mar 14, 2012 at 8:28 AM, David Fetter <david@fetter.org> wrote:
> On Tue, Mar 13, 2012 at 08:24:47AM -0700, David Fetter wrote:
>> Folks,
>>
>> This is for 9.3, of course.
>>
>> I noticed that CREATE FOREIGN TABLE (LIKE some_table) doesn't work. I
>> believe it should, as it would:
>>
>> - Remove a POLA violation
>> - Make data loading into an extant table even easier, especially if
>> there need to be filtering or other cleanup steps
>>
>> Come to think of it, which CREATE TABLE options are inappropriate to
>> CREATE FOREIGN TABLE?
>
> Here's a WIP patch (lots of cut/paste, no docs, no tests), but it does
> work. Still to do in addition: decide whether ALTER FOREIGN TABLE
> should also handle LIKE.
I think that instead of inventing new grammar productions and a new
node type for this, you should just reuse the existing productions for
LIKE clauses and then reject invalid options during parse analysis.
INCLUDING COMMENTS would be OK, but the the rest are no good.
I'd actually like to see us allow foreign tables to have constraints.
Obviously, we can't enforce constraints on remote data, but the point
would be allow the system administrator to supply the query planner
with enough knowledge to make constraint exclusion work. The fact
that you can't make that work today is a major gap, IMV.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company