Re: Bug in SQL/MED?

From: 花田 茂 <hanada(at)metrosystems(dot)co(dot)jp>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bug in SQL/MED?
Date: 2011-06-30 10:00:23
Message-ID: 4E0C4937.9060406@metrosystems.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

(2011/06/29 21:23), Albe Laurenz wrote:
> If you invoke any of the SQL/MED CREATE or ALTER commands,
> the validator function is only called if an option list was given.
>
> That means that you cannot enforce required options at object creation
> time, because the validator function is not always called.
> I consider that unexpected an undesirable behaviour.
>
> Example:
> CREATE EXTENSION file_fdw;
> CREATE FOREIGN DATA WRAPPER file HANDLER file_fdw_handler VALIDATOR
> file_fdw_validator;
> CREATE SERVER file FOREIGN DATA WRAPPER file;
> CREATE FOREIGN TABLE flat (id integer) SERVER file OPTIONS (format
> 'csv');
> SELECT * FROM flat;
> ERROR: filename is required for file_fdw foreign tables
>
> Now file_fdw does not try to enforce the "filename" option, but it
> would be nice to be able to do so.
>
> The attached patch would change the behaviour so that the validator
> function
> is always called.
>
>
> If that change meets with approval, should file_fdw be changed so that
> it
> requires "filename" at table creation time?

I think this proposal is reasonable. IMHO this fix is enough trivial to
be merged into 9.1 release.

I attached a patch which fixes file_fdw to check required option
(filename) in its validator function. I think that such requirement
should be checked again in PlanForeignScan(), as it had been so far.
Note that this patch requires fdw.patch has been applied.

With this patch, file_fdw rejects commands which eliminate filename
option as result. Please see attached sample.txt for detail.

BTW, I noticed that current document says just "the validator function
is called for CREATE FDW/SERVER/FOREIGN TABLE", and doesn't mention
ALTER command or USER MAPPING. I'll post another patch for this issue
later.

Regards,
--
Shigeru Hanada

Attachment Content-Type Size
fix_file_fdw.patch text/plain 2.7 KB
sample.txt text/plain 565 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Florian Pflug 2011-06-30 10:04:39 Re: Review of patch Bugfix for XPATH() if expression returns a scalar value
Previous Message Peter Geoghegan 2011-06-30 09:47:34 Re: Latch implementation that wakes on postmaster death on both win32 and Unix