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