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

Commite187bf0

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 parent9b3900c commite187bf0

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
@@ -4156,11 +4156,11 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
41564156
-- making use of the special variable TG_OP to work out the operation.
41574157
--
41584158
IF (TG_OP = 'DELETE') THEN
4159-
INSERT INTO emp_audit SELECT 'D', now(),user, OLD.*;
4159+
INSERT INTO emp_audit SELECT 'D', now(),current_user, OLD.*;
41604160
ELSIF (TG_OP = 'UPDATE') THEN
4161-
INSERT INTO emp_audit SELECT 'U', now(),user, NEW.*;
4161+
INSERT INTO emp_audit SELECT 'U', now(),current_user, NEW.*;
41624162
ELSIF (TG_OP = 'INSERT') THEN
4163-
INSERT INTO emp_audit SELECT 'I', now(),user, NEW.*;
4163+
INSERT INTO emp_audit SELECT 'I', now(),current_user, NEW.*;
41644164
END IF;
41654165
RETURN NULL; -- result is ignored since this is an AFTER trigger
41664166
END;
@@ -4226,20 +4226,20 @@ CREATE OR REPLACE FUNCTION update_emp_view() RETURNS TRIGGER AS $$
42264226
IF NOT FOUND THEN RETURN NULL; END IF;
42274227

42284228
OLD.last_updated = now();
4229-
INSERT INTO emp_audit VALUES('D',user, OLD.*);
4229+
INSERT INTO emp_audit VALUES('D',current_user, OLD.*);
42304230
RETURN OLD;
42314231
ELSIF (TG_OP = 'UPDATE') THEN
42324232
UPDATE emp SET salary = NEW.salary WHERE empname = OLD.empname;
42334233
IF NOT FOUND THEN RETURN NULL; END IF;
42344234

42354235
NEW.last_updated = now();
4236-
INSERT INTO emp_audit VALUES('U',user, NEW.*);
4236+
INSERT INTO emp_audit VALUES('U',current_user, NEW.*);
42374237
RETURN NEW;
42384238
ELSIF (TG_OP = 'INSERT') THEN
42394239
INSERT INTO emp VALUES(NEW.empname, NEW.salary);
42404240

42414241
NEW.last_updated = now();
4242-
INSERT INTO emp_audit VALUES('I',user, NEW.*);
4242+
INSERT INTO emp_audit VALUES('I',current_user, NEW.*);
42434243
RETURN NEW;
42444244
END IF;
42454245
END;
@@ -4454,13 +4454,13 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
44544454
--
44554455
IF (TG_OP = 'DELETE') THEN
44564456
INSERT INTO emp_audit
4457-
SELECT 'D', now(),user, o.* FROM old_table o;
4457+
SELECT 'D', now(),current_user, o.* FROM old_table o;
44584458
ELSIF (TG_OP = 'UPDATE') THEN
44594459
INSERT INTO emp_audit
4460-
SELECT 'U', now(),user, n.* FROM new_table n;
4460+
SELECT 'U', now(),current_user, n.* FROM new_table n;
44614461
ELSIF (TG_OP = 'INSERT') THEN
44624462
INSERT INTO emp_audit
4463-
SELECT 'I', now(),user, n.* FROM new_table n;
4463+
SELECT 'I', now(),current_user, n.* FROM new_table n;
44644464
END IF;
44654465
RETURN NULL; -- result is ignored since this is an AFTER trigger
44664466
END;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp