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

Commitb36d78e

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 parenta0b0136 commitb36d78e

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
@@ -4184,11 +4184,11 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
41844184
-- making use of the special variable TG_OP to work out the operation.
41854185
--
41864186
IF (TG_OP = 'DELETE') THEN
4187-
INSERT INTO emp_audit SELECT 'D', now(),user, OLD.*;
4187+
INSERT INTO emp_audit SELECT 'D', now(),current_user, OLD.*;
41884188
ELSIF (TG_OP = 'UPDATE') THEN
4189-
INSERT INTO emp_audit SELECT 'U', now(),user, NEW.*;
4189+
INSERT INTO emp_audit SELECT 'U', now(),current_user, NEW.*;
41904190
ELSIF (TG_OP = 'INSERT') THEN
4191-
INSERT INTO emp_audit SELECT 'I', now(),user, NEW.*;
4191+
INSERT INTO emp_audit SELECT 'I', now(),current_user, NEW.*;
41924192
END IF;
41934193
RETURN NULL; -- result is ignored since this is an AFTER trigger
41944194
END;
@@ -4254,20 +4254,20 @@ CREATE OR REPLACE FUNCTION update_emp_view() RETURNS TRIGGER AS $$
42544254
IF NOT FOUND THEN RETURN NULL; END IF;
42554255

42564256
OLD.last_updated = now();
4257-
INSERT INTO emp_audit VALUES('D',user, OLD.*);
4257+
INSERT INTO emp_audit VALUES('D',current_user, OLD.*);
42584258
RETURN OLD;
42594259
ELSIF (TG_OP = 'UPDATE') THEN
42604260
UPDATE emp SET salary = NEW.salary WHERE empname = OLD.empname;
42614261
IF NOT FOUND THEN RETURN NULL; END IF;
42624262

42634263
NEW.last_updated = now();
4264-
INSERT INTO emp_audit VALUES('U',user, NEW.*);
4264+
INSERT INTO emp_audit VALUES('U',current_user, NEW.*);
42654265
RETURN NEW;
42664266
ELSIF (TG_OP = 'INSERT') THEN
42674267
INSERT INTO emp VALUES(NEW.empname, NEW.salary);
42684268

42694269
NEW.last_updated = now();
4270-
INSERT INTO emp_audit VALUES('I',user, NEW.*);
4270+
INSERT INTO emp_audit VALUES('I',current_user, NEW.*);
42714271
RETURN NEW;
42724272
END IF;
42734273
END;
@@ -4482,13 +4482,13 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
44824482
--
44834483
IF (TG_OP = 'DELETE') THEN
44844484
INSERT INTO emp_audit
4485-
SELECT 'D', now(),user, o.* FROM old_table o;
4485+
SELECT 'D', now(),current_user, o.* FROM old_table o;
44864486
ELSIF (TG_OP = 'UPDATE') THEN
44874487
INSERT INTO emp_audit
4488-
SELECT 'U', now(),user, n.* FROM new_table n;
4488+
SELECT 'U', now(),current_user, n.* FROM new_table n;
44894489
ELSIF (TG_OP = 'INSERT') THEN
44904490
INSERT INTO emp_audit
4491-
SELECT 'I', now(),user, n.* FROM new_table n;
4491+
SELECT 'I', now(),current_user, n.* FROM new_table n;
44924492
END IF;
44934493
RETURN NULL; -- result is ignored since this is an AFTER trigger
44944494
END;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp