From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | Joe Conway <mail(at)joeconway(dot)com> |
Cc: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Daniel Verite <daniel(at)manitou-mail(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Davin Shearer <davin(at)apache(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Emitting JSON to file using COPY TO |
Date: | 2024-01-16 03:46:59 |
Message-ID: | CACJufxEuM1pa-8m+-iDQ8KQRzPV=sCEG-_DhtW=SnaA-19N=LA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On Tue, Jan 9, 2024 at 4:40 AM Joe Conway <mail(at)joeconway(dot)com> wrote:
>
> On 1/8/24 14:36, Dean Rasheed wrote:
> > On Thu, 7 Dec 2023 at 01:10, Joe Conway <mail(at)joeconway(dot)com> wrote:
> >>
> >> The attached should fix the CopyOut response to say one column.
> >>
> >
> > Playing around with this, I found a couple of cases that generate an error:
> >
> > COPY (SELECT 1 UNION ALL SELECT 2) TO stdout WITH (format json);
> >
> > COPY (VALUES (1), (2)) TO stdout WITH (format json);
> >
> > both of those generate the following:
> >
> > ERROR: record type has not been registered
>
>
> Thanks -- will have a look
>
> --
> Joe Conway
> PostgreSQL Contributors Team
> RDS Open Source Databases
> Amazon Web Services: https://aws.amazon.com
>
>
>
In the function CopyOneRowTo, I try to call the function BlessTupleDesc again.
+BlessTupleDesc(slot->tts_tupleDescriptor);
rowdata = ExecFetchSlotHeapTupleDatum(slot);
Please check the attachment. (one test.sql file, one patch, one bless twice).
Now the error cases are gone, less cases return error.
but the new result is not the expected.
`COPY (SELECT g from generate_series(1,1) g) TO stdout WITH (format json);`
returns
{"":1}
The expected result would be `{"g":1}`.
I think the reason is maybe related to the function copy_dest_startup.
Attachment | Content-Type | Size |
---|---|---|
test.sql | application/sql | 922 bytes |
patch.out | application/octet-stream | 1.3 KB |
patch_bless_twice.out | application/octet-stream | 1.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2024-01-16 05:32:54 | Re: After the last update |
Previous Message | David G. Johnston | 2024-01-16 02:11:45 | Re: After the last update |
From | Date | Subject | |
---|---|---|---|
Next Message | Bharath Rupireddy | 2024-01-16 03:53:13 | Re: [17] CREATE SUBSCRIPTION ... SERVER |
Previous Message | shveta malik | 2024-01-16 03:33:17 | Re: Synchronizing slots from primary to standby |