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

Commitc584d11

Browse files
committed
Add information_schema.triggered_update_columns
This reflects the recently added support for triggers on columns.
1 parent31cf893 commitc584d11

File tree

2 files changed

+96
-8
lines changed

2 files changed

+96
-8
lines changed

‎doc/src/sgml/information_schema.sgml

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/information_schema.sgml,v 1.43 2009/12/30 22:48:10 petere Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/information_schema.sgml,v 1.44 2009/12/31 14:41:23 petere Exp $ -->
22

33
<chapter id="information-schema">
44
<title>The Information Schema</title>
@@ -4796,6 +4796,80 @@ ORDER BY c.ordinal_position;
47964796
</table>
47974797
</sect1>
47984798

4799+
<sect1 id="infoschema-triggered-update-columns">
4800+
<title><literal>triggered_update_columns</literal></title>
4801+
4802+
<para>
4803+
For triggers in the current database that specify a column list
4804+
(like <literal>UPDATE OF column1, column2</literal>), the
4805+
view <literal>triggered_update_columns</literal> identifies these
4806+
columns. Triggers that do not specify a column list are not
4807+
included in this view. Only those columns are shown that the
4808+
current user owns or has some non-SELECT privilege on.
4809+
</para>
4810+
4811+
<table>
4812+
<title><literal>triggered_update_columns</literal> Columns</title>
4813+
4814+
<tgroup cols="3">
4815+
<thead>
4816+
<row>
4817+
<entry>Name</entry>
4818+
<entry>Data Type</entry>
4819+
<entry>Description</entry>
4820+
</row>
4821+
</thead>
4822+
4823+
<tbody>
4824+
<row>
4825+
<entry><literal>trigger_catalog</literal></entry>
4826+
<entry><type>sql_identifier</type></entry>
4827+
<entry>Name of the database that contains the trigger (always the current database)</entry>
4828+
</row>
4829+
4830+
<row>
4831+
<entry><literal>trigger_schema</literal></entry>
4832+
<entry><type>sql_identifier</type></entry>
4833+
<entry>Name of the schema that contains the trigger</entry>
4834+
</row>
4835+
4836+
<row>
4837+
<entry><literal>trigger_name</literal></entry>
4838+
<entry><type>sql_identifier</type></entry>
4839+
<entry>Name of the trigger</entry>
4840+
</row>
4841+
4842+
<row>
4843+
<entry><literal>event_object_catalog</literal></entry>
4844+
<entry><type>sql_identifier</type></entry>
4845+
<entry>
4846+
Name of the database that contains the table that the trigger
4847+
is defined on (always the current database)
4848+
</entry>
4849+
</row>
4850+
4851+
<row>
4852+
<entry><literal>event_object_schema</literal></entry>
4853+
<entry><type>sql_identifier</type></entry>
4854+
<entry>Name of the schema that contains the table that the trigger is defined on</entry>
4855+
</row>
4856+
4857+
<row>
4858+
<entry><literal>event_object_table</literal></entry>
4859+
<entry><type>sql_identifier</type></entry>
4860+
<entry>Name of the table that the trigger is defined on</entry>
4861+
</row>
4862+
4863+
<row>
4864+
<entry><literal>event_object_column</literal></entry>
4865+
<entry><type>sql_identifier</type></entry>
4866+
<entry>Name of the column that the trigger is defined on</entry>
4867+
</row>
4868+
</tbody>
4869+
</tgroup>
4870+
</table>
4871+
</sect1>
4872+
47994873
<sect1 id="infoschema-triggers">
48004874
<title><literal>triggers</literal></title>
48014875

‎src/backend/catalog/information_schema.sql

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 2003-2009, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.61 2009/12/30 22:48:10 petere Exp $
7+
* $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.62 2009/12/31 14:41:23 petere Exp $
88
*/
99

1010
/*
@@ -1852,13 +1852,27 @@ GRANT SELECT ON tables TO PUBLIC;
18521852

18531853
CREATEVIEWtriggered_update_columnsAS
18541854
SELECT CAST(current_database()AS sql_identifier)AS trigger_catalog,
1855-
CAST(nullAS sql_identifier)AS trigger_schema,
1856-
CAST(nullAS sql_identifier)AS trigger_name,
1855+
CAST(n.nspnameAS sql_identifier)AS trigger_schema,
1856+
CAST(t.tgnameAS sql_identifier)AS trigger_name,
18571857
CAST(current_database()AS sql_identifier)AS event_object_catalog,
1858-
CAST(nullAS sql_identifier)AS event_object_schema,
1859-
CAST(nullAS sql_identifier)AS event_object_table,
1860-
CAST(nullAS sql_identifier)AS event_object_column
1861-
WHERE false;
1858+
CAST(n.nspnameAS sql_identifier)AS event_object_schema,
1859+
CAST(c.relnameAS sql_identifier)AS event_object_table,
1860+
CAST(a.attnameAS sql_identifier)AS event_object_column
1861+
1862+
FROM pg_namespace n, pg_class c, pg_trigger t,
1863+
(SELECT tgoid, (ta0.tgat).xAS tgattnum, (ta0.tgat).nAS tgattpos
1864+
FROM (SELECToidAS tgoid,information_schema._pg_expandarray(tgattr)AS tgatFROM pg_trigger)AS ta0)AS ta,
1865+
pg_attribute a
1866+
1867+
WHEREn.oid=c.relnamespace
1868+
ANDc.oid=t.tgrelid
1869+
ANDt.oid=ta.tgoid
1870+
AND (a.attrelid,a.attnum)= (t.tgrelid,ta.tgattnum)
1871+
AND NOTt.tgisconstraint
1872+
AND (NOT pg_is_other_temp_schema(n.oid))
1873+
AND (pg_has_role(c.relowner,'USAGE')
1874+
-- SELECT privilege omitted, per SQL standard
1875+
OR has_column_privilege(c.oid,a.attnum,'INSERT, UPDATE, REFERENCES') );
18621876

18631877
GRANTSELECTON triggered_update_columns TO PUBLIC;
18641878

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp