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

Commit7fc2d50

Browse files
committed
Make to_hex() behave portably on negative input values (treat them as
unsigned integers). Per report from Jim Crate.
1 parentedc7f14 commit7fc2d50

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.108 2003/11/30 20:55:09 joe Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.109 2003/12/19 04:56:41 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2230,11 +2230,11 @@ array_to_text(PG_FUNCTION_ARGS)
22302230
Datum
22312231
to_hex32(PG_FUNCTION_ARGS)
22322232
{
2233-
staticchardigits[]="0123456789abcdef";
2234-
charbuf[32];/* bigger than needed, but reasonable */
2235-
char*ptr;
2233+
uint32value= (uint32)PG_GETARG_INT32(0);
22362234
text*result_text;
2237-
int32value=PG_GETARG_INT32(0);
2235+
char*ptr;
2236+
constchar*digits="0123456789abcdef";
2237+
charbuf[32];/* bigger than needed, but reasonable */
22382238

22392239
ptr=buf+sizeof(buf)-1;
22402240
*ptr='\0';
@@ -2256,11 +2256,11 @@ to_hex32(PG_FUNCTION_ARGS)
22562256
Datum
22572257
to_hex64(PG_FUNCTION_ARGS)
22582258
{
2259-
staticchardigits[]="0123456789abcdef";
2260-
charbuf[32];/* bigger than needed, but reasonable */
2261-
char*ptr;
2259+
uint64value= (uint64)PG_GETARG_INT64(0);
22622260
text*result_text;
2263-
int64value=PG_GETARG_INT64(0);
2261+
char*ptr;
2262+
constchar*digits="0123456789abcdef";
2263+
charbuf[32];/* bigger than needed, but reasonable */
22642264

22652265
ptr=buf+sizeof(buf)-1;
22662266
*ptr='\0';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp