pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: James Pang (chaolpan) <chaolpan@cisco.com>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Subject: Re: inserts bypass encoding conversion
Date: Wed, 16 Aug 2023 22:40:32 -0400
Message-ID: <1727535.1692240032@sss.pgh.pa.us> (raw)
In-Reply-To: <PH0PR11MB51912A70CBC6FF376F8B106CD61AA@PH0PR11MB5191.namprd11.prod.outlook.com>
References: <PH0PR11MB5191EB32087DE307374EB2C4D615A@PH0PR11MB5191.namprd11.prod.outlook.com>
	<1320633.1692194575@sss.pgh.pa.us>
	<PH0PR11MB51913D89862FDA866FACCC8CD61AA@PH0PR11MB5191.namprd11.prod.outlook.com>
	<1717988.1692235980@sss.pgh.pa.us>
	<PH0PR11MB51912A70CBC6FF376F8B106CD61AA@PH0PR11MB5191.namprd11.prod.outlook.com>

"James Pang (chaolpan)" <chaolpan@cisco.com> writes:
> So,  insert into values(chr(226)||chr(128)||chr(166)) actually got stored in database with LATIN1 with single byte sequence, but when query select * from testutf8, it got converted to UTF8 three byte sequence first ? 

There are no LATIN1 characters that have longer than 2-byte UTF8
representations, so no.

I think your fundamental misunderstanding is supposing that this:

	chr(226)||chr(128)||chr(166)

produces something equivalent to the UTF8 sequence 0xe2 0x80 0xa6.
It will not, no matter which server encoding you are dealing with.
It will produce something that is three separate characters
according to the server encoding.  In LATIN1, that could well be
the byte sequence 0xe2 0x80 0xa6, but *that byte sequence does not
mean the same thing that it would mean in UTF8 encoding*.

You also seem not to grasp the fact that an encoding conversion
will happen between your client and the server if client_encoding
is different from server_encoding.  Because of that, the output of
a SELECT command doesn't prove much of anything here.

			regards, tom lane





view thread (6+ messages)

Message-ID: <1727535.1692240032@sss.pgh.pa.us>
Permalink:  ../1727535.1692240032@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1727535.1692240032@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, chaolpan@cisco.com, pgsql-admin@lists.postgresql.org
  Subject: Re: inserts bypass encoding conversion
  In-Reply-To: <1727535.1692240032@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox