SELECT * FROM pg_shadow WHERE usename='logindousuario' AND passwd = 'md5' || md5('senhadousuario' || 'logindousuario') Fonte: http://www.robertoalmeida.com/postgresql/conferindo-login-e-senha-no-psgql