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

Commitb30cc0f

Browse files
committed
Further portability tweaks for float4/float8 hash functions.
Attempting to make hashfloat4() look as much as possible likehashfloat8(), I'd figured I could replace NaNs with get_float4_nan()before widening to float8. However, results from protosciurusand topminnow show that on some platforms that produces a differentbit-pattern from get_float8_nan(), breaking the intent ofce773f2.Rearrange so that we use the result of get_float8_nan() for all NaNcases. As before, back-patch.
1 parentac5ea66 commitb30cc0f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

‎src/backend/access/hash/hashfunc.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,6 @@ hashfloat4(PG_FUNCTION_ARGS)
151151
if (key== (float4)0)
152152
PG_RETURN_UINT32(0);
153153

154-
/*
155-
* Similarly, NaNs can have different bit patterns but they should all
156-
* compare as equal. For backwards-compatibility reasons we force them to
157-
* have the hash value of a standard NaN.
158-
*/
159-
if (isnan(key))
160-
key=get_float4_nan();
161-
162154
/*
163155
* To support cross-type hashing of float8 and float4, we want to return
164156
* the same hash value hashfloat8 would produce for an equal float8 value.
@@ -168,6 +160,16 @@ hashfloat4(PG_FUNCTION_ARGS)
168160
*/
169161
key8=key;
170162

163+
/*
164+
* Similarly, NaNs can have different bit patterns but they should all
165+
* compare as equal. For backwards-compatibility reasons we force them to
166+
* have the hash value of a standard float8 NaN. (You'd think we could
167+
* replace key with a float4 NaN and then widen it; but on some old
168+
* platforms, that way produces a different bit pattern.)
169+
*/
170+
if (isnan(key8))
171+
key8=get_float8_nan();
172+
171173
returnhash_any((unsignedchar*)&key8,sizeof(key8));
172174
}
173175

@@ -181,9 +183,9 @@ hashfloat4extended(PG_FUNCTION_ARGS)
181183
/* Same approach as hashfloat4 */
182184
if (key== (float4)0)
183185
PG_RETURN_UINT64(seed);
184-
if (isnan(key))
185-
key=get_float4_nan();
186186
key8=key;
187+
if (isnan(key8))
188+
key8=get_float8_nan();
187189

188190
returnhash_any_extended((unsignedchar*)&key8,sizeof(key8),seed);
189191
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp