PostgreSQL: Documentation: 9.5: CREATE FUNCTION

PHOTO EMBED

Fri Oct 15 2021 14:28:04 GMT+0000 (Coordinated Universal Time)

Saved by @mvieira

CREATE FUNCTION check_password(uname TEXT, pass TEXT)
RETURNS BOOLEAN AS $$
DECLARE passed BOOLEAN;
BEGIN
        SELECT  (pwd = $2) INTO passed
        FROM    pwds
        WHERE   username = $1;

        RETURN passed;
END;
$$  LANGUAGE plpgsql
    SECURITY DEFINER
    -- Set a secure search_path: trusted schema(s), then 'pg_temp'.
    SET search_path = admin, pg_temp;
content_copyCOPY

https://www.postgresql.org/docs/9.5/sql-createfunction.html