question

tkrajewski89 avatar image
0 Votes"
tkrajewski89 asked tkrajewski89 answered

Invalid byte sequence for encoding "UTF8" - Azure Database for PostgreSQL flexible server


On freshly new Azure Database for PostgreSQL flexible server, I created a database:

 CREATE DATABASE test
     WITH 
     OWNER = "myuser"
     ENCODING = 'UTF8'
     CONNECTION LIMIT = -1;


I am trying to run the following query:

 SET client_encoding = 'UTF8';
    
 DROP TABLE IF EXISTS customers;
    
 CREATE TABLE customers (
     customer_id bpchar NOT NULL,
     company_name character varying(40) NOT NULL,
     contact_name character varying(30),
     contact_title character varying(30),
     address character varying(60),
     city character varying(15),
     region character varying(15),
     postal_code character varying(10),
     country character varying(15),
     phone character varying(24),
     fax character varying(24)
 );
    
 INSERT INTO customers VALUES ('ANATR', 'Ana Trujillo Emparedados y helados', 'Ana Trujillo', 'Owner', 'Avda. de la Constitución 2222', 'México D.F.', NULL, '05021', 'Mexico', '(5) 555-4729', '(5) 555-3745');


I received the following error:

 ERROR:  invalid byte sequence for encoding "UTF8": 0xf3 0x6e 0x20 0x32
 SQL state: 22021

In my local host environment, there are no issues. What could be an issue?

azure-database-postgresql
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

tkrajewski89 avatar image
0 Votes"
tkrajewski89 answered

Solution found.

There is an option under Server Parameters in Azure Database for PostgreSQL flexible server:

116751-image.png

Inside there client_encoding was set to SQL_ASCII when it requires to be UTF8

116735-image.png

After that change query works and pgadmin shows accents correctly.






image.png (10.3 KiB)
image.png (80.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.