Unix Technical Forum

duplicate columns with COPY

This is a discussion on duplicate columns with COPY within the pgsql Hackers forums, part of the PostgreSQL category; --> Is there a reason why COPY TO STDOUT does not allow columns to be specified more than once? pei=# ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 10:38 PM
Peter Eisentraut
 
Posts: n/a
Default duplicate columns with COPY

Is there a reason why COPY TO STDOUT does not allow columns to be specified
more than once?

pei=# copy test1 (a, a) to stdout;
ERROR: 42701: column "a" specified more than once

Or is this just an overly extensive check that is actually intended for COPY
FROM STDIN?

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 10:38 PM
Andrew Dunstan
 
Posts: n/a
Default Re: duplicate columns with COPY



Peter Eisentraut wrote:
> Is there a reason why COPY TO STDOUT does not allow columns to be specified
> more than once?
>
> pei=# copy test1 (a, a) to stdout;
> ERROR: 42701: column "a" specified more than once
>
> Or is this just an overly extensive check that is actually intended for COPY
> FROM STDIN?
>
>


You should be able to get around it with:

COPY (SELECT a , a FROM test1) TO stdout;

cheers

andew

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-15-2008, 10:38 PM
NikhilS
 
Posts: n/a
Default Re: duplicate columns with COPY

Hi,

> >
> > pei=# copy test1 (a, a) to stdout;
> > ERROR: 42701: column "a" specified more than once
> >
> > Or is this just an overly extensive check that is actually intended for

> COPY
> > FROM STDIN?
> >
> >

>


This seems to be a common check in both "COPY TO" and "COPY FROM" cases
source/destination being STDIN or otherwise. While it definitely makes sense
for the FROM case maybe we could relax this for the COPY TO case.

Regards,
Nikhils
--
EnterpriseDB http://www.enterprisedb.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-15-2008, 10:38 PM
Tom Lane
 
Posts: n/a
Default Re: duplicate columns with COPY

Peter Eisentraut <peter_e@gmx.net> writes:
> Is there a reason why COPY TO STDOUT does not allow columns to be specified
> more than once?


> pei=# copy test1 (a, a) to stdout;
> ERROR: 42701: column "a" specified more than once


> Or is this just an overly extensive check that is actually intended for COPY
> FROM STDIN?


I think it's reasonable even for COPY TO, since IMHO the odds that it's
a typo, rather than intentional, are probably 100:1.

As already noted, we do have a workaround if that is truly what you
intend.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-15-2008, 10:38 PM
Peter Eisentraut
 
Posts: n/a
Default Re: duplicate columns with COPY

Am Donnerstag, 20. Dezember 2007 schrieb Tom Lane:
> I think it's reasonable even for COPY TO, since IMHO the odds that it's
> a typo, rather than intentional, are probably 100:1.


ISTM that with this line of argument we could disable thousands of valid uses
of SQL commands.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:36 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com