Typo in PL/pgSQL trigger Example 43.4?

Поиск
Список
Период
Сортировка
От Kirk Parker
Тема Typo in PL/pgSQL trigger Example 43.4?
Дата
Msg-id CANwZ8rmN_Eb0h0hoMRS8Feftaik0z89PxVsKg+cP+PctuOq=Qg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: ODBC options  (Bruce Momjian <bruce@momjian.us>)
Ответы Re: Typo in PL/pgSQL trigger Example 43.4?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-docs
 The PL/pgSQL page on triggers ( https://www.postgresql.org/docs/16/plpgsql-trigger.html ) contains the following example (I'm excerpting only the essential parts here):

Example 43.4. A PL/pgSQL Trigger Function for Auditing 
    ...
    CREATE TABLE emp_audit(
        operation  char(1)   NOT NULL,
        stamp      timestamp NOT NULL,
        userid     text      NOT NULL,  -- <= COLUMN IN QUESTION
        empname    text      NOT NULL,
        salary     integer
      );

      CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS TRIGGER AS $emp_audit$
        BEGIN
          --
          -- Create a row in emp_audit to reflect the operation performed on emp,
          -- 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.*; -- <= ARGUMENT IN QUESTION
          -- similar code with same issue follows for the other TG_OPs...

The emp_audit table has a column named 'userid', which in actual usage (next-to-last line quoted) is populated by 'user' which seems undefined in the context.  Was that intended to be 'current_user', or am I missing something?

В списке pgsql-docs по дате отправления:

Предыдущее
От: PG Doc comments form
Дата:
Сообщение: Example numeric constants aren't valid?
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Typo in PL/pgSQL trigger Example 43.4?