If you execute SQL commands in your trigger function, and these commands access the table that the trigger is for, then you need to be aware of the data visibility rules, because they determine whether these SQL commands will see the data change that the trigger is fired for. Briefly: トリガ関数内でSQLコマンドを実行し、このコマンドがトリガの元となったテーブルにアクセスする場合、データの可視性規則に注意する必要があります。 この規則が、SQLコマンドがトリガの発行原因となったデータ変更を見ることができるかどうかを決定するからです。 簡単に以下に示します。
       Statement-level triggers follow simple visibility rules: none of
       the changes made by a statement are visible to statement-level
       <literal>BEFORE</literal> triggers, whereas all
       modifications are visible to statement-level <literal>AFTER</literal>
       triggers.
文レベルトリガは次に示す簡単な可視性規則に従います。
文によってなされた変更は、文レベルのBEFOREトリガでは不可視です。
一方、文レベルのAFTERトリガでは全ての変更が可視です。
      
       The data change (insertion, update, or deletion) causing the
       trigger to fire is naturally <emphasis>not</emphasis> visible
       to SQL commands executed in a row-level <literal>BEFORE</literal> trigger,
       because it hasn't happened yet.
当然ながら行レベルのBEFOREトリガ内のSQLコマンドでは、トリガの発生原因となったデータ変更(挿入、更新、削除)はまだ発生していませんので、可視ではありません。
      
       However, SQL commands executed in a row-level <literal>BEFORE</literal>
       trigger <emphasis>will</emphasis> see the effects of data
       changes for rows previously processed in the same outer
       command.  This requires caution, since the ordering of these
       change events is not in general predictable; an SQL command that
       affects multiple rows can visit the rows in any order.
しかし、行レベルのBEFOREトリガで実行されるSQLコマンドは、その外側のコマンドで以前に処理された行へのデータ変更の影響を見ることになるでしょう。
これらの変更イベントの順序は一般的に予測できませんので、注意が必要です。
複数行に影響するSQLコマンドはどのような順番でもその行を更新することができます。
      
       Similarly, a row-level <literal>INSTEAD OF</literal> trigger will see the
       effects of data changes made by previous firings of <literal>INSTEAD
       OF</literal> triggers in the same outer command.
同様に、行レベルのINSTEAD OFトリガは、同じ外側のコマンドで以前に処理されたINSTEAD OFトリガよる変更結果を見ることになるでしょう。
      
       When a row-level <literal>AFTER</literal> trigger is fired, all data
       changes made
       by the outer command are already complete, and are visible to
       the invoked trigger function.
行レベルのAFTERトリガが発生すると、その外側のコマンドによってなされた全ての変更は既に完了していますので、呼び出されたトリガ関数から可視になります。
      
    If your trigger function is written in any of the standard procedural
    languages, then the above statements apply only if the function is
    declared <literal>VOLATILE</literal>.  Functions that are declared
    <literal>STABLE</literal> or <literal>IMMUTABLE</literal> will not see changes made by
    the calling command in any case.
もし、あなたのトリガが標準的な手続き型言語のいずれかで記述されている時、上記の可視性は関数がVOLATILEで定義されている場合のみ適用されます。
STABLE、もしくはIMMUTABLEで定義されている関数は、どのようなケースにおいても、呼び出しコマンドによる変更は見ないでしょう。
   
Further information about data visibility rules can be found in <xref linkend="spi-visibility"/>. The example in <xref linkend="trigger-example"/> contains a demonstration of these rules. データ可視性規則に関する詳細は45.5にあります。 37.4の例にこの規則を示します。