Re: [HACKERS] COPY IN as SELECT target

2009-12-19 Thread Andrew Dunstan
Tom Lane wrote: I think that there are two likely possibilities for the result format: * "Raw" data after just the de-escaping and column separation steps. Array of text is probably the right thing here, at least for a text COPY (doesn't seem to cover the binary case though). * The data conve

Re: [HACKERS] COPY IN as SELECT target

2009-12-18 Thread Andrew Dunstan
Pavel Stehule wrote: 2009/12/17 Andrew Dunstan : Recently there was discussion about allowing a COPY statement to be a SELECT target, returning a text array, although the syntax wasn't really nailed down that I recall. I was thinking that we might have COPY RETURNING ARRAY FROM ... ins

Re: [HACKERS] COPY IN as SELECT target

2009-12-17 Thread Pavel Stehule
2009/12/17 Andrew Dunstan : > > Recently there was discussion about allowing a COPY statement to be a SELECT > target, returning a text array, although the syntax wasn't really nailed > down that I recall. I was thinking that  we might have > >   COPY RETURNING ARRAY FROM ... > > instead of > >   C

Re: [HACKERS] COPY IN as SELECT target

2009-12-17 Thread Dimitri Fontaine
Hi, Le 17 déc. 2009 à 19:39, Josh Berkus a écrit : > Mind you, returning (arbitrary expression) would be even better, but if > we can get returning TEXT[] for 8.5, I think it's worth doing on its own. Well, you already have it as soon as you have text[]: INSERT INTO destination SELECT row[0],

Re: [HACKERS] COPY IN as SELECT target

2009-12-17 Thread Robert Haas
On Thu, Dec 17, 2009 at 1:50 PM, Tom Lane wrote: > Robert Haas writes: >> You might want to specify column names as well as well as types, in >> this second case. > > Well, we could do it like VALUES: arbitrarily name the columns column1 > ... columnN and tell people to use an alias if they want

Re: [HACKERS] COPY IN as SELECT target

2009-12-17 Thread Tom Lane
Robert Haas writes: > You might want to specify column names as well as well as types, in > this second case. Well, we could do it like VALUES: arbitrarily name the columns column1 ... columnN and tell people to use an alias if they want other names. If it's convenient to fit column names into th

Re: [HACKERS] COPY IN as SELECT target

2009-12-17 Thread Robert Haas
On Thu, Dec 17, 2009 at 1:37 PM, Tom Lane wrote: > Andrew Dunstan writes: >> Tom Lane wrote: >>> The problem with COPY FROM is that it hard-wires a decision that there >>> is one and only one possible result format, which I think we pretty >>> much proved already is the wrong thing.  I'm not thri

Re: [HACKERS] COPY IN as SELECT target

2009-12-17 Thread Josh Berkus
> In answer to Heiki's argument, what I wanted was exactly to return an > array of text for each row. Whatever we have needs to be able to handle > to possibility of ragged input (see previous discussion) so we can't tie > it down too tightly. I would have *lots* of use for this feature. Mind yo

Re: [HACKERS] COPY IN as SELECT target

2009-12-17 Thread Tom Lane
Andrew Dunstan writes: > Tom Lane wrote: >> The problem with COPY FROM is that it hard-wires a decision that there >> is one and only one possible result format, which I think we pretty >> much proved already is the wrong thing. I'm not thrilled with "RETURNING >> ARRAY" either, but we need to le

Re: [HACKERS] COPY IN as SELECT target

2009-12-17 Thread Andrew Dunstan
Tom Lane wrote: Heikki Linnakangas writes: Andrew Dunstan wrote: COPY RETURNING ARRAY FROM ... It's not really returning an array, is it? It's returning a bag of rows like a (sub)query. How about just COPY FROM? The problem with COPY FROM is that it har

Re: [HACKERS] COPY IN as SELECT target

2009-12-17 Thread Tom Lane
Heikki Linnakangas writes: > Andrew Dunstan wrote: >> COPY RETURNING ARRAY FROM ... > It's not really returning an array, is it? It's returning a bag of rows > like a (sub)query. > How about just COPY FROM? The problem with COPY FROM is that it hard-wires a decision that there is one and only o

Re: [HACKERS] COPY IN as SELECT target

2009-12-17 Thread Robert Haas
On Thu, Dec 17, 2009 at 12:38 PM, David Fetter 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 >> wrote: >> > How about just COPY FROM? As in >> > >> > SELECT t[5] as a, 3*(t[3]::numeric) as b FROM (COPY FROM STDIN >> >

Re: [HACKERS] COPY IN as SELECT target

2009-12-17 Thread David Fetter
On Thu, Dec 17, 2009 at 12:28:50PM -0500, Robert Haas wrote: > On Thu, Dec 17, 2009 at 12:23 PM, Heikki Linnakangas > 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 b

Re: [HACKERS] COPY IN as SELECT target

2009-12-17 Thread Robert Haas
On Thu, Dec 17, 2009 at 12:23 PM, Heikki Linnakangas 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 C

Re: [HACKERS] COPY IN as SELECT target

2009-12-17 Thread Heikki Linnakangas
Andrew Dunstan wrote: > > Recently there was discussion about allowing a COPY statement to be a > SELECT target, returning a text array, although the syntax wasn't really > nailed down that I recall. I was thinking that we might have > >COPY RETURNING ARRAY FROM ... > > instead of > >C

[HACKERS] COPY IN as SELECT target

2009-12-17 Thread Andrew Dunstan
Recently there was discussion about allowing a COPY statement to be a SELECT target, returning a text array, although the syntax wasn't really nailed down that I recall. I was thinking that we might have COPY RETURNING ARRAY FROM ... instead of COPY tablename opt_column_list FROM ...