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

Commit9f597ba

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 parent6e331c4 commit9f597ba

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
@@ -4300,11 +4300,11 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
43004300
-- making use of the special variable TG_OP to work out the operation.
43014301
--
43024302
IF (TG_OP = 'DELETE') THEN
4303-
INSERT INTO emp_audit SELECT 'D', now(),user, OLD.*;
4303+
INSERT INTO emp_audit SELECT 'D', now(),current_user, OLD.*;
43044304
ELSIF (TG_OP = 'UPDATE') THEN
4305-
INSERT INTO emp_audit SELECT 'U', now(),user, NEW.*;
4305+
INSERT INTO emp_audit SELECT 'U', now(),current_user, NEW.*;
43064306
ELSIF (TG_OP = 'INSERT') THEN
4307-
INSERT INTO emp_audit SELECT 'I', now(),user, NEW.*;
4307+
INSERT INTO emp_audit SELECT 'I', now(),current_user, NEW.*;
43084308
END IF;
43094309
RETURN NULL; -- result is ignored since this is an AFTER trigger
43104310
END;
@@ -4370,20 +4370,20 @@ CREATE OR REPLACE FUNCTION update_emp_view() RETURNS TRIGGER AS $$
43704370
IF NOT FOUND THEN RETURN NULL; END IF;
43714371

43724372
OLD.last_updated = now();
4373-
INSERT INTO emp_audit VALUES('D',user, OLD.*);
4373+
INSERT INTO emp_audit VALUES('D',current_user, OLD.*);
43744374
RETURN OLD;
43754375
ELSIF (TG_OP = 'UPDATE') THEN
43764376
UPDATE emp SET salary = NEW.salary WHERE empname = OLD.empname;
43774377
IF NOT FOUND THEN RETURN NULL; END IF;
43784378

43794379
NEW.last_updated = now();
4380-
INSERT INTO emp_audit VALUES('U',user, NEW.*);
4380+
INSERT INTO emp_audit VALUES('U',current_user, NEW.*);
43814381
RETURN NEW;
43824382
ELSIF (TG_OP = 'INSERT') THEN
43834383
INSERT INTO emp VALUES(NEW.empname, NEW.salary);
43844384

43854385
NEW.last_updated = now();
4386-
INSERT INTO emp_audit VALUES('I',user, NEW.*);
4386+
INSERT INTO emp_audit VALUES('I',current_user, NEW.*);
43874387
RETURN NEW;
43884388
END IF;
43894389
END;
@@ -4598,13 +4598,13 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
45984598
--
45994599
IF (TG_OP = 'DELETE') THEN
46004600
INSERT INTO emp_audit
4601-
SELECT 'D', now(),user, o.* FROM old_table o;
4601+
SELECT 'D', now(),current_user, o.* FROM old_table o;
46024602
ELSIF (TG_OP = 'UPDATE') THEN
46034603
INSERT INTO emp_audit
4604-
SELECT 'U', now(),user, n.* FROM new_table n;
4604+
SELECT 'U', now(),current_user, n.* FROM new_table n;
46054605
ELSIF (TG_OP = 'INSERT') THEN
46064606
INSERT INTO emp_audit
4607-
SELECT 'I', now(),user, n.* FROM new_table n;
4607+
SELECT 'I', now(),current_user, n.* FROM new_table n;
46084608
END IF;
46094609
RETURN NULL; -- result is ignored since this is an AFTER trigger
46104610
END;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp