pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Reece Pegues <RPegues@tripwire.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14038: substring cuts unicode char in half, allowing to save broken utf8 into table
Date: Mon, 21 Mar 2016 17:04:36 -0400
Message-ID: <1163.1458594276@sss.pgh.pa.us> (raw)
In-Reply-To: <D315A115.2CF4F%rpegues@tripwire.com>
References: <20160321143927.2903.55302@wrigleys.postgresql.org>
	<22852.1458578790@sss.pgh.pa.us>
	<D315A115.2CF4F%rpegues@tripwire.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Reece Pegues <RPegues@tripwire.com> writes:
> Looks like the database is created with ENCODING = 'SQL_ASCII'

Basically what that does is defeats all encoding checks inside the
backend; it'll store whatever bytes you give it.  So yeah, substring()
is expected to deal in bytes not characters in this encoding.

> So I assume it was thus saving the data that way, and then if the client
> encoding is utf8 it tried to encode to that and failed?

If client declares its encoding, the backend will verify correct encoding
before transmitting data; but if the database encoding is SQL_ASCII then
no actual conversion happens, only a validity check at transmit/receive.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (5+ messages)  latest in thread

Message-ID: <1163.1458594276@sss.pgh.pa.us>
Permalink:  ../1163.1458594276@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1163.1458594276@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, RPegues@tripwire.com
  Subject: Re: BUG #14038: substring cuts unicode char in half, allowing to save broken utf8 into table
  In-Reply-To: <1163.1458594276@sss.pgh.pa.us>
  References: <20160321143927.2903.55302@wrigleys.postgresql.org> <22852.1458578790@sss.pgh.pa.us> <D315A115.2CF4F%rpegues@tripwire.com> <1163.1458594276@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