好吧,在 systemuser 中插入一个用户后,我喜欢使用新用户的密码为 PostgreSQL 创建一个角色。但是当我尝试创建用户时,会出现此错误:
Blockquote ERROR:在“NEW”第 24 行或附近出现语法错误:ALTER USER NEW.login ENCRYPTED PASSWORD NEW.password...
CREATE OR REPLACE FUNCTION trg_insertuser()
RETURNS TRIGGER AS $trg_insertuser$
DECLARE
BEGIN
IF (TG_OP = 'DELETE') THEN
DROP USER OLD.login;
ELSIF (TG_OP = 'UPDATE') THEN
ALTER USER OLD.login ENCRYPTED PASSWORD NEW.password;
ELSIF (TG_OP = 'INSERT') THEN
CREATE USER NEW.login ENCRYPTED PASSWORD NEW.password CREATEDB IN GROUP group_user;
END IF;
RETURN NULL;
END;
$trg_insertuser$ LANGUAGE plpgsql;
发生了什么?