Re: [HACKERS] psql copy help

2003-10-28 Thread Tom Lane
Steve Crawford <[EMAIL PROTECTED]> writes:
> The psql help for copy (version=7.3.2 and several others) appears 
> incorrect (or perhaps the command parser is at fault - in any case 
> the help doesn't match reality):

You seem to be confusing the SQL command COPY with the psql command \copy.
They are not the same.

Possibly we should try to converge \copy's syntax with COPY's a little
better... I'm not sure they could be made exactly alike though.

regards, tom lane

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


[HACKERS] psql copy help

2003-10-28 Thread Steve Crawford
The psql help for copy (version=7.3.2 and several others) appears 
incorrect (or perhaps the command parser is at fault - in any case 
the help doesn't match reality):

steve=# \h copy
Command: COPY
Description: copy data between files and tables
Syntax:
COPY table [ ( column [, ...] ) ]
FROM { 'filename' | stdin }
[ [ WITH ]
  [ BINARY ]
  [ OIDS ]
  [ DELIMITER [ AS ] 'delimiter' ]
  [ NULL [ AS ] 'null string' ] ]
...

I interpret this as meaning that you can optionally specify a 
delimiter, null etc. and if you do then you can optionally include 
the "with" and the "as" for readability. While I can omit the "as" I 
cannot omit the "with":

Works with both:
steve=# \copy foo from 'footest' with delimiter as ','
\.

Works with "with" only:
steve=# \copy foo from 'footest' with delimiter ','
\.

Does not work without "with"
steve=# \copy foo from 'footest' delimiter ','
\copy: parse error at 'delimiter'
steve=# \copy foo from 'footest' delimiter as ','
\copy: parse error at 'delimiter'

As such it seems that the help should be:
COPY table [ ( column [, ...] ) ]
FROM { 'filename' | stdin }
[ WITH 
  [ BINARY ]
  [ OIDS ]
  [ DELIMITER [ AS ] 'delimiter' ]
  [ NULL [ AS ] 'null string' ] ]
...

Cheers,
Steve


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html