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

Commit1d1cf38

Browse files
author
Thomas G. Lockhart
committed
Fix max(int8) result by making sure int8larger() copies its result
rather than reusing the input storage.Also made the same fix to int8smaller(), though there wasn't a symptom, and went through and verified that other pass-by-reference data types do the same thing. Not an issue for the by-value types.
1 parent8474600 commit1d1cf38

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

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

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,7 @@ int8um(int64 *val)
228228
if (!PointerIsValid(val))
229229
returnNULL;
230230

231-
#ifNOT_USED
232-
*result=temp- (*val);
233-
#else
234231
result=int8mi(&temp,val);
235-
#endif
236232

237233
returnresult;
238234
}/* int8um() */
@@ -293,39 +289,27 @@ int8div(int64 *val1, int64 *val2)
293289
int64*
294290
int8larger(int64*val1,int64*val2)
295291
{
296-
#ifNOT_USED
297292
int64*result=palloc(sizeof(int64));
298293

299-
#endif
300-
301294
if ((!PointerIsValid(val1))|| (!PointerIsValid(val2)))
302295
returnNULL;
303296

304-
#ifNOT_USED
305297
*result= ((*val1>*val2) ?*val1 :*val2);
306298

307299
returnresult;
308-
#endif
309-
return (*val1>*val2) ?val1 :val2;
310300
}/* int8larger() */
311301

312302
int64*
313303
int8smaller(int64*val1,int64*val2)
314304
{
315-
#ifNOT_USED
316305
int64*result=palloc(sizeof(int64));
317306

318-
#endif
319-
320307
if ((!PointerIsValid(val1))|| (!PointerIsValid(val2)))
321308
returnNULL;
322309

323-
#ifNOT_USED
324310
*result= ((*val1<*val2) ?*val1 :*val2);
325311

326312
returnresult;
327-
#endif
328-
return (*val1<*val2) ?val1 :val2;
329313
}/* int8smaller() */
330314

331315

@@ -458,16 +442,15 @@ int84(int64 *val)
458442
elog(ERROR,"Invalid (null) int64, can't convert int8 to int4",NULL);
459443

460444
#ifNOT_USED
461-
462445
/*
463446
* Hmm. This conditional always tests true on my i686/linux box. It's
464447
* a gcc compiler bug, or I'm missing something obvious, which is more
465448
* likely... - thomas 1998-06-09
466449
*/
467450
if ((*val<INT_MIN)|| (*val>INT_MAX))
468451
#endif
469-
if ((*val< (-pow(2,31)+1))|| (*val> (pow(2,31)-1)))
470-
elog(ERROR,"int8 conversion to int4 is out of range",NULL);
452+
if ((*val< (-pow(2,31)+1))|| (*val> (pow(2,31)-1)))
453+
elog(ERROR,"int8 conversion to int4 is out of range",NULL);
471454

472455
result=*val;
473456

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp