版本 10 和 14 之间的 PostgresQL 兼容查询

PostgresSQL incompatible query between version 10 and 14

我有以下语句,它在 PostgresQL 版本 10 上运行良好

LINE 1: UPDATE tablename SET "cliPrefix"=encode(digest(gen_random_uuid()::text, 'sha512'), 'hex');
                                                ^

Button PostgresQL version 14 这行给我错误:

No function matches the given name and argument types. You might need to add explicit type casts

如何解决这个问题?

检查是否存在所需的扩展名 (pgcrypto)

select * from pg_extension;

如果没有

create extension pgcrypto;