Re: COPY table FROM STDIN doesn't show count tag

From: Amit Khandekar <amit(dot)khandekar(at)enterprisedb(dot)com>
To: Rajeev rastogi <rajeev(dot)rastogi(at)huawei(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY table FROM STDIN doesn't show count tag
Date: 2013-11-25 04:00:07
Message-ID: CACoZds2ZxKeXfRTtirEOVhF0ToNw46+gxj3CY84E0wRspznDmA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 22 November 2013 16:14, Rajeev rastogi <rajeev(dot)rastogi(at)huawei(dot)com> wrote:

> On 21 November 2013, Amit Khandekar <amit(dot)khandekar(at)enterprisedb(dot)com>
> wrote:
>
> >Ok. we will then first fix the \COPY TO issue where it does not revert
> back the overriden psql output file handle. Once this is solved, fix for
> both COPY FROM and COPY TO, like how it is done in the patch earlier (
> copydefectV2.patch).
>
>
>
> I analyzed the solution to fix \COPY TO issue but unfortunately I observed
> that *do_copy* is already resetting the value of *cur_cmd_source and
> queryFout* but before that itself result status is printed. So we’ll have
> to reset the value before result status is being displayed.
>
>
>
> So as other alternative solutions, I have two approaches:
>
> 1. We can store current file destination *queryFout *in some local
> variable and pass the same to *SendQuery* function as a parameter. Same
> can be used to reset the value of queryFout after return from ProcessResult
>
> From all other callers of SendQuery , we can pass NULL value for this new
> parameter.
>
>

> 2. We can add new structure member variable FILE *prevQueryFout in
> structure “struct _*psqlSettings”, *which hold the value of queryFout
> before being changed in do_copy. And then same can be used to reset value
> in SendQuery or ProcessResult.
>
I think approach #2 is fine. Rather than prevQueryFout, I suggest defining
a separate FILE * handle for COPY. I don't see any other client-side
command that uses its own file pointer for reading and writing, like how
COPY does. And this handle has nothing to do with pset stdin and stdout. So
we can have this special _psqlSettings->copystream specifically for COPY.
Both handleCopyIn() and handleCopyOut() will be passed pset.copystream. In
do_copy(), instead of overriding pset.queryFout, we can set
pset.copystream to copystream, or to stdin/stdout if copystream is NULL.

>
> Please let me know which approach is OK or if any other approach suggested.
>
> Based on feedback I shall prepare the new patch and share the same.
>
>
>
> Thanks and Regards,
>
> Kumar Rajeev Rastogi
>
>
>
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexey Vasiliev 2013-11-25 04:02:18 Re[2]: [HACKERS] Re[2]: [HACKERS] Connect from background worker thread to database
Previous Message Rajeev rastogi 2013-11-25 03:47:12 Re: TODO: Split out pg_resetxlog output into pre- and post-sections