So following modification seems to fixed all PG (7.3/7.3.3)crashes on
Solaris ( NON C LOCALE )

selfuncs.c line 2356:

I changed:
xfrmsize = strlen(val) + 32;	/*arbitrary pad value here...*/
to
xfrmsize = strxfrm(NULL, val, 0) + 32;

so basically instead of wild guess of transformed string size I asking
"strxfrm" for that.

+32 out my desperation, strxfrm(NULL, val, 0) + 1 should be fine ( have
not tested that )...

Out of curiosity:
Really interesting, following condition seems to be impossible anymore,
of cause if something went terribly wrong,

die here, return original string, return empty string?

if (xfrmlen >= xfrmsize) {
	pfree(xfrmstr);
	xfrmstr = (char *) palloc(xfrmlen + 1);
	xfrmlen = strxfrm(xfrmstr, val, xfrmlen + 1);
}


Again fixed all crashes on Sun 5.8 ( PG 7.3.3, en_US locale, LATIN1
encoding )  Generic Patch...

P.S
NO SUPPORT, NO WARRANTY, NO NOTHING, just for you information.

Regards.

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Tuesday, July 08, 2003 3:58 PM
To: Maksim Likharev
Cc: pgsql-general@postgresql.org; pgsql-hackers@postgresql.org
Subject: Re: [GENERAL] PG crash on simple query, story continues 


"Maksim Likharev" <mlikharev@aurigin.com> writes:
>      On failure, strxfrm() returns (size_t)-1.

Not according to the Single Unix Specification, Linux, or HP-UX;
I don't have any others to check.  But anyway, that is not causing
your problem, since palloc(0) would complain not dump core.

> I am on SunOS 5.8, 

Solaris, eh?  IIRC, it was Solaris that we last heard about broken
strxfrm on.  Better check to see if Sun has a fix for this.

			regards, tom lane

Fri, 11 Jul 2003 16:12:30 -0700
"Maksim Likharev" <mlikharev@aurigin.com>
Re: PG crash on simple query, story continues 
"Maksim Likharev" <mlikharev@aurigin.com> writes:
> So following modification seems to fixed all PG (7.3/7.3.3)crashes on
> Solaris ( NON C LOCALE )

Given that the problem is Solaris' tendency to write more data than
the specified output buffer length allows, I'd think this is still
risking a core dump (due to null pointer dereference).

			regards, tom lane

Sat, 12 Jul 2003 17:05:12 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] PG crash on simple query, story continues 