Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id D17509FA4DD for ; Fri, 29 Dec 2006 13:43:21 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 11215-07 for ; Fri, 29 Dec 2006 13:43:15 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from community1.commandprompt.com (unknown [207.173.203.254]) by postgresql.org (Postfix) with ESMTP id 47FA69FA4CF for ; Fri, 29 Dec 2006 13:43:16 -0400 (AST) Received: from [192.168.27.150] (unknown [12.38.10.44]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by community1.commandprompt.com (Postfix) with ESMTP id 0489D1A3896; Fri, 29 Dec 2006 09:43:14 -0800 (PST) Message-ID: <459553AD.3010806@dunslane.net> Date: Fri, 29 Dec 2006 12:43:09 -0500 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.6) Gecko/20060804 Fedora/1.0.4-0.5.1.fc5 SeaMonkey/1.0.4 MIME-Version: 1.0 To: Mason CC: pgsql-patches@postgresql.org Subject: Re: Fwd: I would like to alter the COPY command References: <523e84030612231908s32ef5145s4e18582b4a579d07@mail.gmail.com> <523e84030612231908i5c272b5atabe95643d482e157@mail.gmail.com> In-Reply-To: <523e84030612231908i5c272b5atabe95643d482e157@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/197 X-Sequence-Number: 21873 Mason wrote: > What I have is data with two different characters for "start quote" > and "end quote". In my case it's '[' and ']', but it could be > anything from "smart quotes", to parentheses, to brackets, braces, ^/$ > in regexps, etc. I think this isn't too unreasonable a feature to > have to make copy more functional when importing data that is > difficult to transform properly beforehand (in my case is about half a > terabyte of log files, which takes hours and hours, just to cat, let > alone reparse and dump into COPY). I think regexps would be going too far. One simple approach which wouldn't involve any grammar changes would be to allow the quote parameter to be 2 chars long instead of one, and treat the second as the closing quote char (which would otherwise default to the first char). An argument against that would be that it would preclude us from in future allowing multi-char quote marks. I'm not sure if that matters quite so much as it would for the delimiter parameter. > > Now, in my case I can just say "cat file | tr '[]' '""' | psql -f > import.sql", but then I lose the ability for psql to do anything smart > like using mmap (I'm making assumptions that it does anything smart > like that, but even if it doesn't now, it could some day). > Well, you also earn a "Useless use of cat" award ;-) And no, we don't mmap the file, but we do do some smart buffering stuff, thanks to Greenplum. cheers andrew