Re: Emitting JSON to file using COPY TO - Mailing list pgsql-hackers

From Daniel Verite
Subject Re: Emitting JSON to file using COPY TO
Date
Msg-id fc61429f-76a1-4385-a2bd-999967da306f@manitou-mail.org
Whole thread Raw
In response to Re: Emitting JSON to file using COPY TO  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: Emitting JSON to file using COPY TO
List pgsql-hackers
    Andrew Dunstan wrote:

> Here's a v30 set that I hope fixes these issues.

Currently there's no difference in output between the null
json value and the SQL null.

postgres=# create table tbl  (j jsonb);
CREATE TABLE

postgres=# insert into tbl values('null');
INSERT 0 1

postgres=# insert into tbl values(null);
INSERT 0 1

postgres=# table tbl;
  j
------
 null

(2 rows)

postgres=# copy tbl to stdout with (format json);
{"j":null}
{"j":null}

If we had to reload this file, we could not determine which
kind of null we had even though they are different at the SQL
level:

postgres=# select null::jsonb is distinct from 'null'::jsonb;
 ?column?
----------
 t

Does it have to be that way or are there valid distinct outputs
that  we could use to avoid this ambiguity?


Best regards,
--
Daniel Vérité
https://postgresql.verite.pro/



pgsql-hackers by date:

Previous
From: Andrei Lepikhov
Date:
Subject: Re: Read-only connection mode for AI workflows.
Next
From: Henson Choi
Date:
Subject: Re: SQL Property Graph Queries (SQL/PGQ)