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

Commit368b7c6

Browse files
committed
Fix numeric abbreviation for --disable-float8-byval.
When committingabd94bc, I tried to makeit decide what kind of abbreviation to use based only on SIZEOF_DATUM,without regard to USE_FLOAT8_BYVAL. That attempt was a few bricks shortof a load, so try to fix it, and add a comment explaining what we'reabout.Patch by me; review (but not a full endorsement) by Andrew Gierth.
1 parentb7e1652 commit368b7c6

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,21 @@ typedef struct
296296
hyperLogLogStateabbr_card;/* cardinality estimator */
297297
}NumericSortSupport;
298298

299+
/*
300+
* We define our own macros for packing and unpacking abbreviated-key
301+
* representations for numeric values in order to avoid depending on
302+
* USE_FLOAT8_BYVAL. The type of abbreviation we use is based only on
303+
* the size of a datum, not the argument-passing convention for float8.
304+
*/
299305
#defineNUMERIC_ABBREV_BITS (SIZEOF_DATUM * BITS_PER_BYTE)
300306
#ifSIZEOF_DATUM==8
301-
#defineDatumGetNumericAbbrev(d) ((int64) d)
302-
#defineNUMERIC_ABBREV_NAN Int64GetDatum(PG_INT64_MIN)
307+
#defineNumericAbbrevGetDatum(X) ((Datum) SET_8_BYTES(X))
308+
#defineDatumGetNumericAbbrev(X) ((int64) GET_8_BYTES(X))
309+
#defineNUMERIC_ABBREV_NAN NumericAbbrevGetDatum(PG_INT64_MIN)
303310
#else
304-
#defineDatumGetNumericAbbrev(d) ((int32) d)
305-
#defineNUMERIC_ABBREV_NAN Int32GetDatum(PG_INT32_MIN)
311+
#defineNumericAbbrevGetDatum(X) ((Datum) SET_4_BYTES(X))
312+
#defineDatumGetNumericAbbrev(X) ((int32) GET_4_BYTES(X))
313+
#defineNUMERIC_ABBREV_NAN NumericAbbrevGetDatum(PG_INT32_MIN)
306314
#endif
307315

308316

@@ -1883,7 +1891,7 @@ numeric_abbrev_convert_var(NumericVar *var, NumericSortSupport *nss)
18831891
addHyperLogLog(&nss->abbr_card,DatumGetUInt32(hash_uint32(tmp)));
18841892
}
18851893

1886-
returnInt64GetDatum(result);
1894+
returnNumericAbbrevGetDatum(result);
18871895
}
18881896

18891897
#endif/* NUMERIC_ABBREV_BITS == 64 */
@@ -1960,7 +1968,7 @@ numeric_abbrev_convert_var(NumericVar *var, NumericSortSupport *nss)
19601968
addHyperLogLog(&nss->abbr_card,DatumGetUInt32(hash_uint32(tmp)));
19611969
}
19621970

1963-
returnInt32GetDatum(result);
1971+
returnNumericAbbrevGetDatum(result);
19641972
}
19651973

19661974
#endif/* NUMERIC_ABBREV_BITS == 32 */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp