Re: psql crashes on encoding mismatch

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql crashes on encoding mismatch
Date: 2011-01-13 05:22:32
Message-ID: 9418.1294896152@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> writes:
> I found a crash case (assertion failure) when runing psql -f
> utf8_encoded_script.sql against client_encoding = shift_jis in
> postgresql.conf. Though encoding mismatch is obviously user's fault, a
> crash doesn't explain anything to him.

I'm not too impressed with this patch: it seems like the most it will
accomplish is to move the failure to some other, equally obscure, place
--- because you'll still have a string that's invalidly encoded.
Moreover, if you've got wrongly encoded data, it wouldn't be hard at all
for it to mess up psql's lexing; consider cases such as a
character-that's-not-as-long-as-we-think just in front of a quote mark.

Shouldn't we instead try to verify the multibyte encoding somewhere
upstream of here?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message KaiGai Kohei 2011-01-13 06:10:45 Re: sepgsql contrib module
Previous Message Tom Lane 2011-01-13 05:12:47 Re: arrays as pl/perl input arguments [PATCH]