時間:2024-02-04 13:45作者:下載吧人氣:26
PostgreSql 實現(xiàn)的hash_code 函數(shù)與java hash_code方法一致
CREATE FUNCTION hash_code(text) RETURNS integer
LANGUAGE plpgsql
AS
$$
DECLARE
i integer := 0;
DECLARE
h bigint := 0;
BEGIN
FOR i IN 1..length($1)
LOOP
h = (h * 31 + ascii(substring($1, i, 1))) & 4294967295;
END LOOP;
RETURN cast(cast(h AS bit(32)) AS int4);
END;
$$;
網(wǎng)友評論