On Thu, Dec 17, 2009 at 12:38 PM, David Fetter <david@fetter.org> wrote:
> On Thu, Dec 17, 2009 at 12:28:50PM -0500, Robert Haas wrote:
>> On Thu, Dec 17, 2009 at 12:23 PM, Heikki Linnakangas
>> <heikki.linnakangas@enterprisedb.com> wrote:
>> > How about just COPY FROM? As in
>> >
>> > SELECT t[5] as a, 3*(t[3]::numeric) as b FROM (COPY FROM STDIN
>> > CSV) as t
>>
>> I had the same thought. Though it would also be nice to allow
>> something like:
>>
>> COPY (type1, type2, type3, type4) FROM STDIN CSV
>>
>> ...which is obviously going to create a horrible parser problem if
>> you actually tried to use that syntax.
>
> How about using the CTE syntax?
I'm not sure what you're suggesting exactly, but the problem with the
syntax I suggested is that COPY (...) TO <whatever> expects the "..."
part to be a subselect. You can't make COPY (...) FROM have something
in there other than a subselect, because the parser can't fast-forward
and look at the word FROM and then go back and decide how to parse the
parenthesized stuff. That's almost magic in the general case. You'd
have to stick a keyword in there before the opening parentheses.
...Robert