Re: pg_read_file() and non-ascii input file

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_read_file() and non-ascii input file
Date: 2010-01-04 03:36:03
Message-ID: 603c8f071001031936t731c240dlbdcabe32a75aa72c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jan 3, 2010 at 9:10 PM, Takahiro Itagaki
<itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> wrote:
>
> Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>
>> > If we want to keep backward compatibility, the issue can be fixed
>> > by adding pg_verifymbstr() to the function.
>>
>> I don't feel good about changing the return type of an existing
>> function, so I guess +1 from me on the approach quoted above.
>
> Ok, I just added pg_verifymbstr() instead of changing the result type.

Sounds fine.

> I didn't add any additinal file reading functions in the patch, but
> I'm willing to add them if someone want them:
>  - pg_read_file_with_encoding()
>  - pg_read_binary_file() RETURNS bytea
>  - pg_read_text_file() RETURNS SETOF text -- returns set of lines

OK.

> One thing bothering me is the HINT message on error is just pointless;
> The encoding is controlled by "server_encoding" here. We will have the
> same error message in server-side COPY commands. We'd better improving
> the message, though it should be done by another patch.

Interestingly, this same issue is being discussed on the thread
entitled "invalid UTF-8 via pl/perl". I suppose whatever solution is
adopted there can be used here as well. FWIW, repurposing the third
argument of pg_verifymbstr seems like the most sensible option to me.

...Robert

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2010-01-04 03:39:40 Re: patch - per-tablespace random_page_cost/seq_page_cost
Previous Message Robert Haas 2010-01-04 03:26:20 Re: PATCH: Add hstore_to_json()