aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-10-09 11:29:21 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2023-10-09 11:29:21 -0400
commit64aad6944c8d331ceb6a0b2df73bf70c5adaf35b (patch)
treee1a1efbaf879f2e72351d3b8250f400bfa690ef2
parent637109d13ab2684aa7ad4e893137e7487b5e8490 (diff)
downloadpostgresql-64aad6944c8d331ceb6a0b2df73bf70c5adaf35b.tar.gz
postgresql-64aad6944c8d331ceb6a0b2df73bf70c5adaf35b.zip
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 example that already used CURRENT_USER. Per question from Kirk Parker. Discussion: https://postgr.es/m/CANwZ8rmN_Eb0h0hoMRS8Feftaik0z89PxVsKg+cP+PctuOq=Qg@mail.gmail.com
-rw-r--r--doc/src/sgml/plpgsql.sgml18
1 files changed, 9 insertions, 9 deletions
diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml
index f55e901c7e5..83f867f91d2 100644
--- a/doc/src/sgml/plpgsql.sgml
+++ b/doc/src/sgml/plpgsql.sgml
@@ -4330,11 +4330,11 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
-- making use of the special variable TG_OP to work out the operation.
--
IF (TG_OP = 'DELETE') THEN
- INSERT INTO emp_audit SELECT 'D', now(), user, OLD.*;
+ INSERT INTO emp_audit SELECT 'D', now(), current_user, OLD.*;
ELSIF (TG_OP = 'UPDATE') THEN
- INSERT INTO emp_audit SELECT 'U', now(), user, NEW.*;
+ INSERT INTO emp_audit SELECT 'U', now(), current_user, NEW.*;
ELSIF (TG_OP = 'INSERT') THEN
- INSERT INTO emp_audit SELECT 'I', now(), user, NEW.*;
+ INSERT INTO emp_audit SELECT 'I', now(), current_user, NEW.*;
END IF;
RETURN NULL; -- result is ignored since this is an AFTER trigger
END;
@@ -4400,20 +4400,20 @@ CREATE OR REPLACE FUNCTION update_emp_view() RETURNS TRIGGER AS $$
IF NOT FOUND THEN RETURN NULL; END IF;
OLD.last_updated = now();
- INSERT INTO emp_audit VALUES('D', user, OLD.*);
+ INSERT INTO emp_audit VALUES('D', current_user, OLD.*);
RETURN OLD;
ELSIF (TG_OP = 'UPDATE') THEN
UPDATE emp SET salary = NEW.salary WHERE empname = OLD.empname;
IF NOT FOUND THEN RETURN NULL; END IF;
NEW.last_updated = now();
- INSERT INTO emp_audit VALUES('U', user, NEW.*);
+ INSERT INTO emp_audit VALUES('U', current_user, NEW.*);
RETURN NEW;
ELSIF (TG_OP = 'INSERT') THEN
INSERT INTO emp VALUES(NEW.empname, NEW.salary);
NEW.last_updated = now();
- INSERT INTO emp_audit VALUES('I', user, NEW.*);
+ INSERT INTO emp_audit VALUES('I', current_user, NEW.*);
RETURN NEW;
END IF;
END;
@@ -4628,13 +4628,13 @@ CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
--
IF (TG_OP = 'DELETE') THEN
INSERT INTO emp_audit
- SELECT 'D', now(), user, o.* FROM old_table o;
+ SELECT 'D', now(), current_user, o.* FROM old_table o;
ELSIF (TG_OP = 'UPDATE') THEN
INSERT INTO emp_audit
- SELECT 'U', now(), user, n.* FROM new_table n;
+ SELECT 'U', now(), current_user, n.* FROM new_table n;
ELSIF (TG_OP = 'INSERT') THEN
INSERT INTO emp_audit
- SELECT 'I', now(), user, n.* FROM new_table n;
+ SELECT 'I', now(), current_user, n.* FROM new_table n;
END IF;
RETURN NULL; -- result is ignored since this is an AFTER trigger
END;