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

Commit694d670

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 parent4f16152 commit694d670

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
@@ -4150,11 +4150,11 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
41504150
-- making use of the special variable TG_OP to work out the operation.
41514151
--
41524152
IF (TG_OP = 'DELETE') THEN
4153-
INSERT INTO emp_audit SELECT 'D', now(),user, OLD.*;
4153+
INSERT INTO emp_audit SELECT 'D', now(),current_user, OLD.*;
41544154
ELSIF (TG_OP = 'UPDATE') THEN
4155-
INSERT INTO emp_audit SELECT 'U', now(),user, NEW.*;
4155+
INSERT INTO emp_audit SELECT 'U', now(),current_user, NEW.*;
41564156
ELSIF (TG_OP = 'INSERT') THEN
4157-
INSERT INTO emp_audit SELECT 'I', now(),user, NEW.*;
4157+
INSERT INTO emp_audit SELECT 'I', now(),current_user, NEW.*;
41584158
END IF;
41594159
RETURN NULL; -- result is ignored since this is an AFTER trigger
41604160
END;
@@ -4220,20 +4220,20 @@ CREATE OR REPLACE FUNCTION update_emp_view() RETURNS TRIGGER AS $$
42204220
IF NOT FOUND THEN RETURN NULL; END IF;
42214221

42224222
OLD.last_updated = now();
4223-
INSERT INTO emp_audit VALUES('D',user, OLD.*);
4223+
INSERT INTO emp_audit VALUES('D',current_user, OLD.*);
42244224
RETURN OLD;
42254225
ELSIF (TG_OP = 'UPDATE') THEN
42264226
UPDATE emp SET salary = NEW.salary WHERE empname = OLD.empname;
42274227
IF NOT FOUND THEN RETURN NULL; END IF;
42284228

42294229
NEW.last_updated = now();
4230-
INSERT INTO emp_audit VALUES('U',user, NEW.*);
4230+
INSERT INTO emp_audit VALUES('U',current_user, NEW.*);
42314231
RETURN NEW;
42324232
ELSIF (TG_OP = 'INSERT') THEN
42334233
INSERT INTO emp VALUES(NEW.empname, NEW.salary);
42344234

42354235
NEW.last_updated = now();
4236-
INSERT INTO emp_audit VALUES('I',user, NEW.*);
4236+
INSERT INTO emp_audit VALUES('I',current_user, NEW.*);
42374237
RETURN NEW;
42384238
END IF;
42394239
END;
@@ -4448,13 +4448,13 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
44484448
--
44494449
IF (TG_OP = 'DELETE') THEN
44504450
INSERT INTO emp_audit
4451-
SELECT 'D', now(),user, o.* FROM old_table o;
4451+
SELECT 'D', now(),current_user, o.* FROM old_table o;
44524452
ELSIF (TG_OP = 'UPDATE') THEN
44534453
INSERT INTO emp_audit
4454-
SELECT 'U', now(),user, n.* FROM new_table n;
4454+
SELECT 'U', now(),current_user, n.* FROM new_table n;
44554455
ELSIF (TG_OP = 'INSERT') THEN
44564456
INSERT INTO emp_audit
4457-
SELECT 'I', now(),user, n.* FROM new_table n;
4457+
SELECT 'I', now(),current_user, n.* FROM new_table n;
44584458
END IF;
44594459
RETURN NULL; -- result is ignored since this is an AFTER trigger
44604460
END;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp