Gavin, I see where you are going with the patch; creating a list in gram.y and stuffing CopyStmt directly there. However, I can't find any other instance of our stuffing things like that in gram.y. We do have cases using options like COPY in CREATE USER, and we do use DefElem.
I realize it will require changes to other files like copy.c. However, it seems like the cleanest solution. I guess I am not excited about adding another way to handle WITH options into the code. Now, if you want to argue that CREATE USER shouldn't use DefElem either, we can discuss that, but I think we need to be consistent in how we handle COPY vs. the other commands that use parameters. See commands/user.c for an example of how it uses DefElem, and the tests done to make sure conflicting arguments are not used or in copy's case, specified twice. It just seems like that is the cleanest way to go. One idea I had for the code is to allow BINARY as $2, and WITH OIDS in its current place, and all options in the new WITH location, and concatentate them together into one DefElem list in gram.y, and pass that to copy.c. That way, you can allow BINARY and others at the end too and the list is in one central place. --------------------------------------------------------------------------- Gavin Sherry wrote: > On Sun, 14 Apr 2002, Bruce Momjian wrote: > > > > > Gavin, I will do the legwork on this if you wish. I think we need to > > No matter. I intended to submit a patch to fix this. > > > use DefElem to store the COPY params, rather than using specific fields > > in CopyStmt. > > DefElem would have required modification of code outside the parser (to > keep utility.c and DoCopy() happy) or otherwise an even messier loop > executed as a result of CopyStmt than I have given in the attached patch, > plus other issues with Yacc. > > The patch attached maintains backward compatibility. The syntax is as > follows: > > COPY [BINARY] <relname> [WITH OIDS] FROM/TO > [USING DELIMITERS <delimiter>] > [WITH [ DELIMITER <delimiter> | NULL AS <char> | OIDS ]] > > I was also going to allow BINARY in the WITH list, but there seems to be > little point. > > Note that if you execute a query such as: > > COPY pg_class TO '/some/path/file/out' > USING DELIMITERS <tab> > WITH DELIMITER '|'; > > The code will give preference to WITH DELIMITER. > > If no one can find fault with this or my implementation, I'll follow up > with documentation and psql patches (not sure that there is much point > patching pg_dump). > > Gavin Content-Description: [ Attachment, skipping... ] > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED]) -- Bruce Momjian | http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])