Re: weird - invalid string enlargement request size - Mailing list pgsql-hackers

From Tom Lane
Subject Re: weird - invalid string enlargement request size
Date
Msg-id 4622.1196921738@sss.pgh.pa.us
Whole thread Raw
In response to Re: weird - invalid string enlargement request size  ("Walter Cruz" <walter.php@gmail.com>)
List pgsql-hackers
"Walter Cruz" <walter.php@gmail.com> writes:
> My initdb was:
> initdb -E LATIN1 --locale=pt_BR
> By that initdb, the $LANG of the system was pt_BR.UTF-8 .
> A simple query that shows the problem:
> select true AS "�aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

OK, I was able to reproduce this here:

postgres=# select true AS "�aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
;
ERROR:  invalid string enlargement request size 1073741823

What is happening is that vsnprintf() is failing because it doesn't like
its input data.  elog.c's EVALUATE_MESSAGE macro thinks that the only
possible reason for failure is that the output buffer isn't large
enough, so it enlarges and tries again, leading soon to the palloc error
displayed above.

Possibly we should put some effort into producing a more useful error
message here, but I'm reluctant to fool with it, because our historical
experience is that vsnprintf's behavior just isn't very consistent
across platforms.

In any case, the bottom-line reason why you're having a problem is that
the database encoding (LATIN1) is inconsistent with the encoding
specified by the server's locale (UTF-8), thus allowing vsnprintf to see
what it thinks is bad data.

PG 8.3 contains defenses to prevent that sort of inconsistency, and
I think that's probably all we need to do about this.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Joe Conway
Date:
Subject: Re: [DOCS] Uniform policy for author credits in contrib module documentation?
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Uniform policy for author credits in contrib module documentation?