/* ------------------------------------------------------------------------ * * pl_hash_funcs.c * Utility C functions for stored HASH procedures * * Copyright (c) 2016, Postgres Professional * * ------------------------------------------------------------------------ */ #include "pathman.h" #include "utils/typcache.h" /* Function declarations */ PG_FUNCTION_INFO_V1( get_type_hash_func ); PG_FUNCTION_INFO_V1( get_hash_part_idx ); /* * Returns hash function's OID for a specified type. */ Datum get_type_hash_func(PG_FUNCTION_ARGS) { TypeCacheEntry *tce; Oid type_oid = PG_GETARG_OID(0); tce = lookup_type_cache(type_oid, TYPECACHE_HASH_PROC); PG_RETURN_OID(tce->hash_proc); } /* * Wrapper for hash_to_part_index(). */ Datum get_hash_part_idx(PG_FUNCTION_ARGS) { uint32 value = PG_GETARG_UINT32(0), part_count = PG_GETARG_UINT32(1); PG_RETURN_UINT32(hash_to_part_index(value, part_count)); }