Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit59d9a37

Browse files
committed
Work around buggy strxfrm() present in some Solaris releases.
1 parent0c17290 commit59d9a37

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

‎src/backend/utils/adt/selfuncs.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.139 2003/05/28 16:03:59 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.140 2003/07/17 20:52:36 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -2651,9 +2651,6 @@ static unsigned char *
26512651
convert_string_datum(Datumvalue,Oidtypid)
26522652
{
26532653
char*val;
2654-
char*xfrmstr;
2655-
size_txfrmsize;
2656-
size_txfrmlen;
26572654

26582655
switch (typid)
26592656
{
@@ -2693,17 +2690,21 @@ convert_string_datum(Datum value, Oid typid)
26932690

26942691
if (!lc_collate_is_c())
26952692
{
2696-
/* Guess that transformed string is not much bigger than original */
2697-
xfrmsize=strlen(val)+32;/* arbitrary pad value here... */
2698-
xfrmstr= (char*)palloc(xfrmsize);
2699-
xfrmlen=strxfrm(xfrmstr,val,xfrmsize);
2700-
if (xfrmlen >=xfrmsize)
2701-
{
2702-
/* Oops, didn't make it */
2703-
pfree(xfrmstr);
2704-
xfrmstr= (char*)palloc(xfrmlen+1);
2705-
xfrmlen=strxfrm(xfrmstr,val,xfrmlen+1);
2706-
}
2693+
char*xfrmstr;
2694+
size_txfrmlen;
2695+
size_txfrmlen2;
2696+
2697+
/*
2698+
* Note: originally we guessed at a suitable output buffer size,
2699+
* and only needed to call strxfrm twice if our guess was too small.
2700+
* However, it seems that some versions of Solaris have buggy
2701+
* strxfrm that can write past the specified buffer length in that
2702+
* scenario. So, do it the dumb way for portability.
2703+
*/
2704+
xfrmlen=strxfrm(NULL,val,0);
2705+
xfrmstr= (char*)palloc(xfrmlen+1);
2706+
xfrmlen2=strxfrm(xfrmstr,val,xfrmlen+1);
2707+
Assert(xfrmlen2==xfrmlen);
27072708
pfree(val);
27082709
val=xfrmstr;
27092710
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp