Re: funcion para cambiar clave de un usuario

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: suso <jlcubas(at)terra(dot)es>
Cc: Julio Cesar Rodriguez Dominguez <jurasec(at)gmail(dot)com>, pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: funcion para cambiar clave de un usuario
Date: 2009-09-16 12:52:13
Message-ID: 20090916125213.GB13076@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

suso escribió:

> CREATE OR REPLACE FUNCTION cambiar(clave character varying)
> RETURNS boolean AS
> $BODY$
> BEGIN
> execute 'ALTER ROLE '||current_user||' WITH PASSWORD '''||clave||'''';
> RETURN true;
> END;
> $BODY$
> LANGUAGE 'plpgsql' VOLATILE

Te falta un quote_identifier() en el nombre, puesto que según tu ejemplo
el nombre es con una mayúsucla (Antonio en vez de antonio).

¿Para qué quieres una función para cambiar la clave? ¿Por qué no usar
directamente ALTER ROLE? No le veo la utilidad a tu función.

--
Alvaro Herrera http://planet.postgresql.org/
"Digital and video cameras have this adjustment and film cameras don't for the
same reason dogs and cats lick themselves: because they can." (Ken Rockwell)

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Sergio Gabriel Rodriguez 2009-09-16 12:54:23 GRANT SELECT para todas las tablas de una base
Previous Message Eduardo Morras 2009-09-16 12:15:09 Re: Rendimiento de postgres