I have installed pgsodium into the database using CREATE EXTENSION pgsodium
.
This is the output from dx
citext | 1.6 | public
pgsodium | 3.1.9 | pgsodium
plpgsql | 1.0 | pg_catalog
In PLSQL I can successfully do ..
SELECT pgsodium.crypto_pwhash_str('password');
However when I try to do the same in a trigger function I get the error
ERROR: function pgsodium.crypto_pwhash_str(text) does not exist
LINE 1: SELECT pgsodium.crypto_pwhash_str(NEW.password)
This is the function
CREATE OR REPLACE FUNCTION update_user() RETURNS TRIGGER AS $update_user$
BEGIN
SELECT pgsodium.crypto_pwhash_str(NEW.password) INTO NEW.password;
RETURN NEW;
END
$update_user$ LANGUAGE plpgsql;
How do I execute the function inside the trigger?