Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6db384f

Browse files
committed
Doc: use CURRENT_USER not USER in plpgsql trigger examples.
While these two built-in functions do exactly the same thing,CURRENT_USER seems preferable to use in documentation examples.It's easier to look up if the reader is unsure what it is.Also, this puts these examples in sync with an adjacent examplethat already used CURRENT_USER.Per question from Kirk Parker.Discussion:https://postgr.es/m/CANwZ8rmN_Eb0h0hoMRS8Feftaik0z89PxVsKg+cP+PctuOq=Qg@mail.gmail.com
1 parentbb91256 commit6db384f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

‎doc/src/sgml/plpgsql.sgml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4312,11 +4312,11 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
43124312
-- making use of the special variable TG_OP to work out the operation.
43134313
--
43144314
IF (TG_OP = 'DELETE') THEN
4315-
INSERT INTO emp_audit SELECT 'D', now(),user, OLD.*;
4315+
INSERT INTO emp_audit SELECT 'D', now(),current_user, OLD.*;
43164316
ELSIF (TG_OP = 'UPDATE') THEN
4317-
INSERT INTO emp_audit SELECT 'U', now(),user, NEW.*;
4317+
INSERT INTO emp_audit SELECT 'U', now(),current_user, NEW.*;
43184318
ELSIF (TG_OP = 'INSERT') THEN
4319-
INSERT INTO emp_audit SELECT 'I', now(),user, NEW.*;
4319+
INSERT INTO emp_audit SELECT 'I', now(),current_user, NEW.*;
43204320
END IF;
43214321
RETURN NULL; -- result is ignored since this is an AFTER trigger
43224322
END;
@@ -4382,20 +4382,20 @@ CREATE OR REPLACE FUNCTION update_emp_view() RETURNS TRIGGER AS $$
43824382
IF NOT FOUND THEN RETURN NULL; END IF;
43834383

43844384
OLD.last_updated = now();
4385-
INSERT INTO emp_audit VALUES('D',user, OLD.*);
4385+
INSERT INTO emp_audit VALUES('D',current_user, OLD.*);
43864386
RETURN OLD;
43874387
ELSIF (TG_OP = 'UPDATE') THEN
43884388
UPDATE emp SET salary = NEW.salary WHERE empname = OLD.empname;
43894389
IF NOT FOUND THEN RETURN NULL; END IF;
43904390

43914391
NEW.last_updated = now();
4392-
INSERT INTO emp_audit VALUES('U',user, NEW.*);
4392+
INSERT INTO emp_audit VALUES('U',current_user, NEW.*);
43934393
RETURN NEW;
43944394
ELSIF (TG_OP = 'INSERT') THEN
43954395
INSERT INTO emp VALUES(NEW.empname, NEW.salary);
43964396

43974397
NEW.last_updated = now();
4398-
INSERT INTO emp_audit VALUES('I',user, NEW.*);
4398+
INSERT INTO emp_audit VALUES('I',current_user, NEW.*);
43994399
RETURN NEW;
44004400
END IF;
44014401
END;
@@ -4610,13 +4610,13 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
46104610
--
46114611
IF (TG_OP = 'DELETE') THEN
46124612
INSERT INTO emp_audit
4613-
SELECT 'D', now(),user, o.* FROM old_table o;
4613+
SELECT 'D', now(),current_user, o.* FROM old_table o;
46144614
ELSIF (TG_OP = 'UPDATE') THEN
46154615
INSERT INTO emp_audit
4616-
SELECT 'U', now(),user, n.* FROM new_table n;
4616+
SELECT 'U', now(),current_user, n.* FROM new_table n;
46174617
ELSIF (TG_OP = 'INSERT') THEN
46184618
INSERT INTO emp_audit
4619-
SELECT 'I', now(),user, n.* FROM new_table n;
4619+
SELECT 'I', now(),current_user, n.* FROM new_table n;
46204620
END IF;
46214621
RETURN NULL; -- result is ignored since this is an AFTER trigger
46224622
END;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp