Fill in information schema column for trigger WHEN condition
authorPeter Eisentraut <[email protected]>
Wed, 30 Dec 2009 22:48:10 +0000 (22:48 +0000)
committerPeter Eisentraut <[email protected]>
Wed, 30 Dec 2009 22:48:10 +0000 (22:48 +0000)
doc/src/sgml/information_schema.sgml
src/backend/catalog/information_schema.sql

index 64b28f7e61623df4071464c35d4fb03f8451d690..9e3ace069628c2b62048a868550a2ba34b77e536 100644 (file)
@@ -4875,7 +4875,11 @@ ORDER BY c.ordinal_position;
      <row>
       <entry><literal>action_condition</literal></entry>
       <entry><type>character_data</type></entry>
-      <entry>Applies to a feature not available in <productname>PostgreSQL</></entry>
+      <entry>
+       <literal>WHEN</literal> condition of the trigger, null if none
+       (also null if the table is not owned by a currently enabled
+       role)
+      </entry>
      </row>
 
      <row>
index 607e928d3b369148fe5c3cf26bff987edd30e341..6edebaf87e43c27388a6aad53889a20d0956b99f 100644 (file)
@@ -1909,7 +1909,12 @@ CREATE VIEW triggers AS
            CAST(n.nspname AS sql_identifier) AS event_object_schema,
            CAST(c.relname AS sql_identifier) AS event_object_table,
            CAST(null AS cardinal_number) AS action_order,
-           CAST(null AS character_data) AS action_condition,
+           -- XXX strange hacks follow
+           CAST(
+             CASE WHEN pg_has_role(c.relowner, 'USAGE')
+               THEN (SELECT m[1] FROM regexp_matches(pg_get_triggerdef(t.oid), E'.{35,} WHEN \\((.+)\\) EXECUTE PROCEDURE') AS rm(m) LIMIT 1)
+               ELSE null END
+             AS character_data) AS action_condition,
            CAST(
              substring(pg_get_triggerdef(t.oid) from
                        position('EXECUTE PROCEDURE' in substring(pg_get_triggerdef(t.oid) from 48)) + 47)