Skip to content

Commit 2ad6e80

Browse files
committed
Fix various hash function uses
These instances were using Datum-returning functions where a lower-level function returning uint32 would be more appropriate. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org
1 parent c9a5860 commit 2ad6e80

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

contrib/sepgsql/uavc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ static char *avc_unlabeled; /* system 'unlabeled' label */
6666
static uint32
6767
sepgsql_avc_hash(const char *scontext, const char *tcontext, uint16 tclass)
6868
{
69-
return hash_any((const unsigned char *) scontext, strlen(scontext))
70-
^ hash_any((const unsigned char *) tcontext, strlen(tcontext))
69+
return hash_bytes((const unsigned char *) scontext, strlen(scontext))
70+
^ hash_bytes((const unsigned char *) tcontext, strlen(tcontext))
7171
^ tclass;
7272
}
7373

src/backend/access/common/tupdesc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -815,10 +815,10 @@ hashRowType(TupleDesc desc)
815815
uint32 s;
816816
int i;
817817

818-
s = hash_combine(0, hash_uint32(desc->natts));
819-
s = hash_combine(s, hash_uint32(desc->tdtypeid));
818+
s = hash_combine(0, hash_bytes_uint32(desc->natts));
819+
s = hash_combine(s, hash_bytes_uint32(desc->tdtypeid));
820820
for (i = 0; i < desc->natts; ++i)
821-
s = hash_combine(s, hash_uint32(TupleDescAttr(desc, i)->atttypid));
821+
s = hash_combine(s, hash_bytes_uint32(TupleDescAttr(desc, i)->atttypid));
822822

823823
return s;
824824
}

src/backend/storage/file/fileset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ FileSetPath(char *path, FileSet *fileset, Oid tablespace)
185185
static Oid
186186
ChooseTablespace(const FileSet *fileset, const char *name)
187187
{
188-
uint32 hash = hash_any((const unsigned char *) name, strlen(name));
188+
uint32 hash = hash_bytes((const unsigned char *) name, strlen(name));
189189

190190
return fileset->tablespaces[hash % fileset->ntablespaces];
191191
}

src/backend/utils/adt/multirangetypes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2833,7 +2833,7 @@ hash_multirange(PG_FUNCTION_ARGS)
28332833
upper_hash = 0;
28342834

28352835
/* Merge hashes of flags and bounds */
2836-
range_hash = hash_uint32((uint32) flags);
2836+
range_hash = hash_bytes_uint32((uint32) flags);
28372837
range_hash ^= lower_hash;
28382838
range_hash = pg_rotate_left32(range_hash, 1);
28392839
range_hash ^= upper_hash;

src/backend/utils/adt/rangetypes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ hash_range(PG_FUNCTION_ARGS)
14441444
upper_hash = 0;
14451445

14461446
/* Merge hashes of flags and bounds */
1447-
result = hash_uint32((uint32) flags);
1447+
result = hash_bytes_uint32((uint32) flags);
14481448
result ^= lower_hash;
14491449
result = pg_rotate_left32(result, 1);
14501450
result ^= upper_hash;

src/backend/utils/cache/catcache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ namehashfast(Datum datum)
213213
{
214214
char *key = NameStr(*DatumGetName(datum));
215215

216-
return hash_any((unsigned char *) key, strlen(key));
216+
return hash_bytes((unsigned char *) key, strlen(key));
217217
}
218218

219219
static bool

0 commit comments

Comments
 (0)