Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pWcOS-0004Dh-Pa for pgsql-general@arkaria.postgresql.org; Mon, 27 Feb 2023 12:14:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pWcNT-0000ZU-LV for pgsql-general@arkaria.postgresql.org; Mon, 27 Feb 2023 12:13:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pWcNT-0000Z1-5F for pgsql-general@lists.postgresql.org; Mon, 27 Feb 2023 12:13:11 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pWcNQ-0004Gg-Pu for pgsql-general@postgresql.org; Mon, 27 Feb 2023 12:13:10 +0000 Received: by mail-ed1-x534.google.com with SMTP id i34so24867766eda.7 for ; Mon, 27 Feb 2023 04:13:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=D+aYBg2YbonVPn5C91lbvFfM8W1WYTp5GlOJbP64Zl8=; b=0rNKtsPOMgDuOdrybpYnIA9ISxGb1wrowdls5mM/VCrz7mVfz9LXVh8eMmEdfRCwJ8 2rsIvXW0pXbLDfyqC1GU81z0k3fjOQCf6zYSwyAcUIJ/e0H9OHsjLFkvATvLW71pv1ad AE2L2XiOQUqo89EnUmSsJcMMqHWuu3faGIq4eX/cay73EKvYPsyv7xje/dbjiT7lXOd4 6d01PEdcMzab+g7OQVZOCb1UpFwRKG4pImhlzuu0FYoDR9GSm40BAWe3XSKaJmEjnL7R LoGKgoknWi0wrRhZLZ98e6D7j+b3clYH2DHQnfpe94YAVRkNWyW1zReDGMBAdfCqe+BH f88g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=D+aYBg2YbonVPn5C91lbvFfM8W1WYTp5GlOJbP64Zl8=; b=VosOVBA4QEKfphYw1etrxJUnUIK/robYONiRAGKnsaNj8RGJQgJqZrv2KYZUNW3625 9CJrhyRMRNO0JH+6AR4icg+gUz8961LVm2uwVc9HoRomxaXJOeXjRTCOHwix05ApcMLw s/Yy1jUV6+uQXCDlL3HEyMSNDe9JhErtdVMkDBf+P/lAqVPhMVGjRQLUb3zxjdlhX4Jv Sayz0yAGEysza+lOF5k43bUm24tllot6gQv5PJYcyWrUJvCXlWV1h30MalS5zacuVgX8 omEAATCcAoQVZINMx/KJy+TWfgsJGjdWNeJ3Qsz3yP0WAPc7gKzoAx/ftBl9I6IEUIjY HbHQ== X-Gm-Message-State: AO0yUKWncVcaCFWBDYwWNAmnfUKLtPyhK80N+zFiaDIl1MD4xBqOrLbc d/kMx1UxMjzqGXGyxFcwe6y9uA== X-Google-Smtp-Source: AK7set9D9jFyvWg4ownuRN6ONvPjNWfmOvH4fs0DkGT0HCLtHyCm5570whIlgb9JlpIf/cCVqoSNLQ== X-Received: by 2002:a17:907:9811:b0:8e2:49c2:1a12 with SMTP id ji17-20020a170907981100b008e249c21a12mr27198153ejc.20.1677499987113; Mon, 27 Feb 2023 04:13:07 -0800 (PST) Received: from dynamic-pd01.res.v6.highway.a1.net ([2001:871:5e:539:1b2c:c52a:475d:310c]) by smtp.gmail.com with ESMTPSA id v9-20020a50d089000000b004af70a543fdsm3080543edd.31.2023.02.27.04.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 04:13:06 -0800 (PST) Message-ID: <959c233d610ac3e9ee2c1f7e47ea7775e0d1f1f7.camel@cybertec.at> Subject: Re: ERROR: unsupported Unicode escape sequence - in JSON-type column From: Laurenz Albe To: Jan Bilek , "pgsql-general@postgresql.org" Date: Mon, 27 Feb 2023 13:13:06 +0100 In-Reply-To: <43a45b6e-08f6-b40d-de6d-ec63e21eb496@eftlab.com.au> References: <43a45b6e-08f6-b40d-de6d-ec63e21eb496@eftlab.com.au> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 =3D pkey; EXCEPTION WHEN untranslatable_character THEN RAISE NOTICE 'bad character in line with id =3D %', pkey; END; END LOOP; END;$$; Yours, Laurenz Albe --=20 Cybertec | https://www.cybertec-postgresql.com