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

Commit64aad69

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 parent637109d commit64aad69

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
@@ -4330,11 +4330,11 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
43304330
-- making use of the special variable TG_OP to work out the operation.
43314331
--
43324332
IF (TG_OP = 'DELETE') THEN
4333-
INSERT INTO emp_audit SELECT 'D', now(),user, OLD.*;
4333+
INSERT INTO emp_audit SELECT 'D', now(),current_user, OLD.*;
43344334
ELSIF (TG_OP = 'UPDATE') THEN
4335-
INSERT INTO emp_audit SELECT 'U', now(),user, NEW.*;
4335+
INSERT INTO emp_audit SELECT 'U', now(),current_user, NEW.*;
43364336
ELSIF (TG_OP = 'INSERT') THEN
4337-
INSERT INTO emp_audit SELECT 'I', now(),user, NEW.*;
4337+
INSERT INTO emp_audit SELECT 'I', now(),current_user, NEW.*;
43384338
END IF;
43394339
RETURN NULL; -- result is ignored since this is an AFTER trigger
43404340
END;
@@ -4400,20 +4400,20 @@ CREATE OR REPLACE FUNCTION update_emp_view() RETURNS TRIGGER AS $$
44004400
IF NOT FOUND THEN RETURN NULL; END IF;
44014401

44024402
OLD.last_updated = now();
4403-
INSERT INTO emp_audit VALUES('D',user, OLD.*);
4403+
INSERT INTO emp_audit VALUES('D',current_user, OLD.*);
44044404
RETURN OLD;
44054405
ELSIF (TG_OP = 'UPDATE') THEN
44064406
UPDATE emp SET salary = NEW.salary WHERE empname = OLD.empname;
44074407
IF NOT FOUND THEN RETURN NULL; END IF;
44084408

44094409
NEW.last_updated = now();
4410-
INSERT INTO emp_audit VALUES('U',user, NEW.*);
4410+
INSERT INTO emp_audit VALUES('U',current_user, NEW.*);
44114411
RETURN NEW;
44124412
ELSIF (TG_OP = 'INSERT') THEN
44134413
INSERT INTO emp VALUES(NEW.empname, NEW.salary);
44144414

44154415
NEW.last_updated = now();
4416-
INSERT INTO emp_audit VALUES('I',user, NEW.*);
4416+
INSERT INTO emp_audit VALUES('I',current_user, NEW.*);
44174417
RETURN NEW;
44184418
END IF;
44194419
END;
@@ -4628,13 +4628,13 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
46284628
--
46294629
IF (TG_OP = 'DELETE') THEN
46304630
INSERT INTO emp_audit
4631-
SELECT 'D', now(),user, o.* FROM old_table o;
4631+
SELECT 'D', now(),current_user, o.* FROM old_table o;
46324632
ELSIF (TG_OP = 'UPDATE') THEN
46334633
INSERT INTO emp_audit
4634-
SELECT 'U', now(),user, n.* FROM new_table n;
4634+
SELECT 'U', now(),current_user, n.* FROM new_table n;
46354635
ELSIF (TG_OP = 'INSERT') THEN
46364636
INSERT INTO emp_audit
4637-
SELECT 'I', now(),user, n.* FROM new_table n;
4637+
SELECT 'I', now(),current_user, n.* FROM new_table n;
46384638
END IF;
46394639
RETURN NULL; -- result is ignored since this is an AFTER trigger
46404640
END;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp