Skip site navigation (1) Skip section navigation (2)

Re: Review : Add hooks for pre- and post-processor executables for COPY and \copy

From: Amit Kapila <amit(dot)kapila(at)huawei(dot)com>
To: "'Etsuro Fujita'" <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>, "'pgsql-hackers'"<pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review : Add hooks for pre- and post-processor executables for COPY and \copy
Date: 2013-01-31 03:39:58
Message-ID: 002e01cdff64$a53663b0$efa32b10$@kapila@huawei.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Wednesday, January 23, 2013 5:36 PM Etsuro Fujita wrote:
> Hi Amit,

> Thank you for your review.  I’ve rebased and updated the patch.  Please
find attached the patch.

>> Test case issues: 
>> ------------------ 
>> 1. "Broken pipe" is not handled in case of psql "\copy" command; 
>>     Issue are as follows: 
>>         Following are verified on SuSE-Linux 10.2. 
>>         1) psql is exiting when "\COPY xxx TO" command is issued and
command/script is not found 
>>                 When popen is called in write mode it is creating valid
file descriptor and when it tries to write to file "Broken pipe" error is >
coming which is not handled. 
>>                         psql# \copy pgbench_accounts TO PROGRAM
'../compress.sh pgbench_accounts4.txt' 
>>         2) When "\copy" command is in progress then program/command is
killed/"crashed due to any problem" 
>>            psql is exiting.

>This is a headache.  I have no idea how to solve this.

I think we can keep it for committer to take a call on this issue.
The other changes done by you in revised patch are fine. 

I have found few more minor issues as below:

1. The comment above do_copy can be modified to address the new
functionality it can handle. 
/* 
 * Execute a \copy command (frontend copy). We have to open a file, then 
 * submit a COPY query to the backend and either feed it data from the 
 * file or route its response into the file. 
 */ 
bool 
do_copy(const char *args) 


2. 
@@ -256,8 +273,14 @@ do_copy(const char *args) 
+        if (options->file == NULL && options->program) 
+        { 
+                psql_error("program is not supported to stdout/pstdout or
from stdin/pstdin\n"); 
+                return false; 
+        } 

should call free_copy_options(options); before return false; 

3. \copy command doesn't need semicolon at end, however it was working
previous to your patch, but 
   now it is giving error. 
postgres=# \copy t1 from 'e:\pg_git_code\Data\t1_Data.txt'; 
e:/pg_git_code/Data/t1_Data.txt';: No such file or directory 
e:/pg_git_code/Data/t1_Data.txt';: No such file or directory 

4. Please check if OpenPipeStream() it needs to call 
   if (ReleaseLruFile()), 
                
5. Following in copy.sgml can be changed to make more meaningful as the
first line looks little adhoc. 
+     <para> 
+      The command that input comes from or that output goes to. 
+      The command for COPY FROM, which input comes from, must write its
output 
+      to standard output.  The command for COPY TO, which output goes to,
must 
+      read its input from standard input. 
+     </para> 


6. Can we have one example of this new syntax, it can make it more
meaningful.
 
With Regards,
Amit Kapila.



In response to

Responses

pgsql-hackers by date

Next:From: Josh BerkusDate: 2013-01-31 03:41:38
Subject: Re: autovacuum not prioritising for-wraparound tables
Previous:From: Tom LaneDate: 2013-01-31 01:31:27
Subject: Re: pg_dump --pretty-print-views

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group