Subject: pgadmin4.1.1 ERROR,22021,"invalid byte sequence for encoding ""UTF8""

From: Bhanu Gandikota <[email-masked]>
Date: Wed, 18 Jan 2017 15:45:14 +0000

Getting following error in PostgreSQL 9.6.1 DB logs when I tried to view “Scripts=>CREATE Script” on a table in PgAdmin4.1.1 Browser.
PostgreSQL DB has been recently upgraded from version 9.3.9 to 9.6.1 using pg_upgrade utility.

The same browser function worked just fine when pgadmin3 was pointing to PostgreSQL 9.3.9 database (before upgrade).

2017-01-18 07:34:43.364 PST,"user","QA961",5423,"x.x.x.x:64624",587f99b8.152f,4,"idle",2017-01-18 07:24:40 PST,2/92094,0,ERROR,22021,"invalid byte sequence for encoding ""UTF8"": 0x00",,,,,,"
SELECT t.oid,t.tgname AS name, t.xmin, t.*, relname, CASE WHEN relkind = 'r' THEN TRUE ELSE FALSE END AS parentistable,
    nspname, des.description, l.lanname, p.prosrc, p.proname AS tfunction,
    COALESCE(substring(pg_get_triggerdef(t.oid), 'WHEN (.*) EXECUTE PROCEDURE'),
    substring(pg_get_triggerdef(t.oid), 'WHEN (.*)  \\$trigger')) AS whenclause,
    -- We need to convert tgargs column bytea datatype to array datatype
    (string_to_array(encode(tgargs, 'escape'), '\000')::text[])[1:tgnargs] AS tgargs,
    (CASE WHEN t.oid <= 13321::oid THEN true ElSE false END) AS is_sys_trigger,
    (CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constarint,
    (CASE WHEN tgenabled = 'O' THEN true ElSE false END) AS is_enable_trigger
FROM pg_trigger t
    JOIN pg_class cl ON cl.oid=tgrelid
    JOIN pg_namespace na ON na.oid=relnamespace
    LEFT OUTER JOIN pg_description des ON (des.objoid=t.oid AND des.classoid='pg_trigger'::regclass)
    LEFT OUTER JOIN pg_proc p ON p.oid=t.tgfoid
    LEFT OUTER JOIN pg_language l ON l.oid=p.prolang
WHERE NOT tgisinternal
    AND tgrelid = 17452::OID
    AND t.oid = 18252::OID
ORDER BY tgname;",,,"pgAdmin 4 - DB:QA961"

---

From: Murtuza Zabuawala <[email-masked]>
Date: Thu, 19 Jan 2017 10:57:16 +0530

Hi,

Can you run & provide output offollowing sql queries from pgAdmin4?

   - SHOW SERVER_ENCODING;
   - SHOW CLIENT_ENCODING;

And what is the encoding set for your current database connection on which
you are trying to run query (Right click on your database, click on
Properties > Definition Tab > Check Encoding, Collation & Character type) ?

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Wed, Jan 18, 2017 at 9:15 PM, Bhanu Gandikota <[email-masked]>
wrote:

> Getting following error in PostgreSQL 9.6.1 DB logs when I tried to view “*Scripts=>CREATE
> Script*” on a table in PgAdmin4.1.1 Browser.
>
> The same browser function worked just fine when pgadmin3 was pointing to
> PostgreSQL 9.3.9 database (before upgrade).
>
>
>
>
>
> 2017-01-18 07:34:43.364 PST,"user","QA961",5423,"x.x.
> x.x:64624",587f99b8.152f,4,"idle",2017-01-18 07:24:40 PST,2/92094,0,*ERROR,22021,"invalid
> byte sequence for encoding ""UTF8"": 0x00",,,,,,"*
>
> SELECT t.oid,t.tgname AS name, t.xmin, t.*, relname, CASE WHEN relkind =
> 'r' THEN TRUE ELSE FALSE END AS parentistable,
>

---

From: Bhanu Gandikota <[email-masked]>
Date: Thu, 19 Jan 2017 15:49:33 +0000

Server_encoding: UTF8
Client_encoding: UNICODE

Encoding: UTF8
Collation: en_US.UTF-8
Character type: en_US.UTF-8

From: Murtuza Zabuawala <[email-masked]>
Date: Thursday, January 19, 2017 at 12:27 AM
To: Bhanu Gandikota <[email-masked]>
Cc: "[email-masked]" <[email-masked]>
Subject: Re: [pgadmin-hackers] pgadmin4.1.1 ERROR,22021,"invalid byte sequence for encoding ""UTF8""

  *   SHOW SERVER_ENCODING;
  *   SHOW CLIENT_ENCODING;