mirror of
https://github.com/postgres/postgres.git
synced 2025-11-18 02:02:55 +03:00
Remove useless/superfluous Datum conversions
Remove useless DatumGetFoo() and FooGetDatum() calls. These are places where no conversion from or to Datum was actually happening. We think these extra calls covered here were harmless. Some actual bugs that were discovered during this process have been committed separately (80c758a2e1,2242b26ce4). Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org
This commit is contained in:
@@ -904,7 +904,7 @@ json_unique_hash(const void *key, Size keysize)
|
||||
|
||||
hash ^= hash_bytes((const unsigned char *) entry->key, entry->key_len);
|
||||
|
||||
return DatumGetUInt32(hash);
|
||||
return hash;
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -2082,15 +2082,14 @@ range_overleft_multirange_internal(TypeCacheEntry *rangetyp,
|
||||
bool empty;
|
||||
|
||||
if (RangeIsEmpty(r) || MultirangeIsEmpty(mr))
|
||||
PG_RETURN_BOOL(false);
|
||||
|
||||
return false;
|
||||
|
||||
range_deserialize(rangetyp, r, &lower1, &upper1, &empty);
|
||||
Assert(!empty);
|
||||
multirange_get_bounds(rangetyp, mr, mr->rangeCount - 1,
|
||||
&lower2, &upper2);
|
||||
|
||||
PG_RETURN_BOOL(range_cmp_bounds(rangetyp, &upper1, &upper2) <= 0);
|
||||
return (range_cmp_bounds(rangetyp, &upper1, &upper2) <= 0);
|
||||
}
|
||||
|
||||
Datum
|
||||
@@ -2167,7 +2166,7 @@ range_overright_multirange_internal(TypeCacheEntry *rangetyp,
|
||||
bool empty;
|
||||
|
||||
if (RangeIsEmpty(r) || MultirangeIsEmpty(mr))
|
||||
PG_RETURN_BOOL(false);
|
||||
return false;
|
||||
|
||||
range_deserialize(rangetyp, r, &lower1, &upper1, &empty);
|
||||
Assert(!empty);
|
||||
|
||||
@@ -1075,8 +1075,8 @@ range_union_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2,
|
||||
return r1;
|
||||
|
||||
if (strict &&
|
||||
!DatumGetBool(range_overlaps_internal(typcache, r1, r2)) &&
|
||||
!DatumGetBool(range_adjacent_internal(typcache, r1, r2)))
|
||||
!range_overlaps_internal(typcache, r1, r2) &&
|
||||
!range_adjacent_internal(typcache, r1, r2))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATA_EXCEPTION),
|
||||
errmsg("result of range union would not be contiguous")));
|
||||
|
||||
@@ -408,13 +408,12 @@ text_length(Datum str)
|
||||
{
|
||||
/* fastpath when max encoding length is one */
|
||||
if (pg_database_encoding_max_length() == 1)
|
||||
PG_RETURN_INT32(toast_raw_datum_size(str) - VARHDRSZ);
|
||||
return (toast_raw_datum_size(str) - VARHDRSZ);
|
||||
else
|
||||
{
|
||||
text *t = DatumGetTextPP(str);
|
||||
|
||||
PG_RETURN_INT32(pg_mbstrlen_with_len(VARDATA_ANY(t),
|
||||
VARSIZE_ANY_EXHDR(t)));
|
||||
return (pg_mbstrlen_with_len(VARDATA_ANY(t), VARSIZE_ANY_EXHDR(t)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user