Re: ERROR: unsupported Unicode escape sequence - in JSON-type column - Mailing list pgsql-general

From Laurenz Albe
Subject Re: ERROR: unsupported Unicode escape sequence - in JSON-type column
Date
Msg-id 959c233d610ac3e9ee2c1f7e47ea7775e0d1f1f7.camel@cybertec.at
Whole thread Raw
In response to ERROR: unsupported Unicode escape sequence - in JSON-type column  (Jan Bilek <jan.bilek@eftlab.com.au>)
Responses Re: ERROR: unsupported Unicode escape sequence - in JSON-type column  (Erik Wienhold <ewie@ewie.name>)
Re: ERROR: unsupported Unicode escape sequence - in JSON-type column  (Jan Bilek <jan.bilek@eftlab.com.au>)
List pgsql-general
On Mon, 2023-02-27 at 06:28 +0000, Jan Bilek wrote:
> Our customer was able to sneak in an Unicode data into a column of a JSON Type and now that record fails on select.
> Would you be able to suggest any way out of this? E.g. finding infringing row, updating its data ... ?

I'd be curious to know how the customer managed to do that.
Perhaps there is a loophole in PostgreSQL that needs to be fixed.

First, find the table that contains the column.
Then you can try something like

  DO
  $$DECLARE
     pkey bigint;
  BEGIN
     FOR pkey IN SELECT id FROM jsontab LOOP
        BEGIN  -- starts block with exception handler
           PERFORM jsoncol -> 'creationDateTime'
           FROM jsontab
           WHERE id = pkey;
        EXCEPTION
           WHEN untranslatable_character THEN
              RAISE NOTICE 'bad character in line with id = %', pkey;
        END;
     END LOOP;
  END;$$;

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com



pgsql-general by date:

Previous
From: celati Laurent
Date:
Subject: Repear operations on 50 tables of the same schema?
Next
From: Laurenz Albe
Date:
Subject: Re: Event Triggers unable to capture the DDL script executed