Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 13f1e2c

Browse files
author
Nikita Glukhov
committed
Use get_typlenbyvalalign() in jsonStatsConvertArray()
1 parent d7973dc commit 13f1e2c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/backend/utils/adt/jsonb_selfuncs.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,9 @@ jsonStatsConvertArray(Datum jsonbValueArray, JsonStatType type, Oid typid,
521521
JsonbIteratorToken r;
522522
int nvalues;
523523
int i;
524+
int16 typlen;
525+
bool typbyval;
526+
char typalign;
524527

525528
if (!DatumGetPointer(jsonbValueArray))
526529
return PointerGetDatum(NULL);
@@ -578,16 +581,10 @@ jsonStatsConvertArray(Datum jsonbValueArray, JsonStatType type, Oid typid,
578581

579582
Assert(i == nvalues);
580583

581-
/*
582-
* FIXME Does this actually work on all 32/64-bit systems? What if typid is
583-
* FLOAT8OID or something? Should look at TypeCache instead, probably.
584-
*/
584+
get_typlenbyvalalign(typid, &typlen, &typbyval, &typalign);
585+
585586
return PointerGetDatum(
586-
construct_array(values, nvalues,
587-
typid,
588-
typid == FLOAT4OID ? 4 : -1,
589-
typid == FLOAT4OID ? true /* FLOAT4PASSBYVAL */ : false,
590-
'i'));
587+
construct_array(values, nvalues, typid, typlen, typbyval, typalign));
591588
}
592589

593590
/*

0 commit comments

Comments
 (0)