|
1 | 1 | <!--
|
2 | 2 | Documentation of the system catalogs, directed toward PostgreSQL developers
|
3 |
| - $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.101 2005/05/06 14:28:53 tgl Exp $ |
| 3 | + $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.102 2005/05/17 21:46:09 tgl Exp $ |
4 | 4 | -->
|
5 | 5 |
|
6 | 6 | <chapter id="catalogs">
|
|
4040 | 4040 | lockable object may
|
4041 | 4041 | appear many times, if multiple transactions are holding or waiting
|
4042 | 4042 | for locks on it. However, an object that currently has no locks on it
|
4043 |
| - will not appear at all. A lockable object is either a relation (e.g., a |
4044 |
| - table) or a transaction ID. |
| 4043 | + will not appear at all. |
4045 | 4044 | </para>
|
4046 | 4045 |
|
4047 | 4046 | <para>
|
4048 |
| - Note that this view includes only table-level |
4049 |
| - locks, not row-level ones. If a transaction is waiting for a |
4050 |
| - row-level lock, it will appear in the view as waiting for the |
4051 |
| - transaction ID of the current holder of that row lock. |
| 4047 | + There are several distinct types of lockable objects: |
| 4048 | + whole relations (e.g., tables), individual pages of relations, |
| 4049 | + individual tuples of relations, |
| 4050 | + transaction IDs, |
| 4051 | + and general database objects (identified by class OID and object OID, |
| 4052 | + in the same way as in <structname>pg_description</structname> or |
| 4053 | + <structname>pg_depend</structname>). Also, the right to extend a |
| 4054 | + relation is represented as a separate lockable object. |
4052 | 4055 | </para>
|
4053 | 4056 |
|
4054 | 4057 | <table>
|
|
4065 | 4068 | </thead>
|
4066 | 4069 | <tbody>
|
4067 | 4070 | <row>
|
4068 |
| - <entry><structfield>relation</structfield></entry> |
4069 |
| - <entry><type>oid</type></entry> |
4070 |
| - <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry> |
| 4071 | + <entry><structfield>locktype</structfield></entry> |
| 4072 | + <entry><type>text</type></entry> |
| 4073 | + <entry></entry> |
4071 | 4074 | <entry>
|
4072 |
| - OID of the locked relation, or NULL if the lockable object |
4073 |
| - is a transaction ID |
| 4075 | + type of the lockable object: |
| 4076 | + <literal>relation</>, |
| 4077 | + <literal>extend</>, |
| 4078 | + <literal>page</>, |
| 4079 | + <literal>tuple</>, |
| 4080 | + <literal>transaction</>, |
| 4081 | + <literal>object</>, or |
| 4082 | + <literal>userlock</> |
4074 | 4083 | </entry>
|
4075 | 4084 | </row>
|
4076 | 4085 | <row>
|
4077 | 4086 | <entry><structfield>database</structfield></entry>
|
4078 | 4087 | <entry><type>oid</type></entry>
|
4079 | 4088 | <entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.oid</literal></entry>
|
4080 | 4089 | <entry>
|
4081 |
| - OID of the database in which the locked relation exists, or |
4082 |
| - zero if the locked relation is a globally-shared table, or |
4083 |
| - NULL if the lockable object is a transaction ID |
| 4090 | + OID of the database in which the object exists, or |
| 4091 | + zero if the object is a globally-shared object, or |
| 4092 | + NULL if the object is a transaction ID |
| 4093 | + </entry> |
| 4094 | + </row> |
| 4095 | + <row> |
| 4096 | + <entry><structfield>relation</structfield></entry> |
| 4097 | + <entry><type>oid</type></entry> |
| 4098 | + <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry> |
| 4099 | + <entry> |
| 4100 | + OID of the relation, or NULL if the object is not |
| 4101 | + a relation or part of a relation |
| 4102 | + </entry> |
| 4103 | + </row> |
| 4104 | + <row> |
| 4105 | + <entry><structfield>page</structfield></entry> |
| 4106 | + <entry><type>integer</type></entry> |
| 4107 | + <entry></entry> |
| 4108 | + <entry> |
| 4109 | + page number within the relation, or NULL if the object |
| 4110 | + is not a tuple or relation page |
| 4111 | + </entry> |
| 4112 | + </row> |
| 4113 | + <row> |
| 4114 | + <entry><structfield>tuple</structfield></entry> |
| 4115 | + <entry><type>smallint</type></entry> |
| 4116 | + <entry></entry> |
| 4117 | + <entry> |
| 4118 | + tuple number within the page, or NULL if the object is not a tuple |
4084 | 4119 | </entry>
|
4085 | 4120 | </row>
|
4086 | 4121 | <row>
|
4087 | 4122 | <entry><structfield>transaction</structfield></entry>
|
4088 | 4123 | <entry><type>xid</type></entry>
|
4089 | 4124 | <entry></entry>
|
4090 | 4125 | <entry>
|
4091 |
| - ID of a transaction, or NULL if the lockable object is a relation |
| 4126 | + ID of a transaction, or NULL if the object is not a transaction ID |
| 4127 | + </entry> |
| 4128 | + </row> |
| 4129 | + <row> |
| 4130 | + <entry><structfield>classid</structfield></entry> |
| 4131 | + <entry><type>oid</type></entry> |
| 4132 | + <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry> |
| 4133 | + <entry> |
| 4134 | + OID of the system catalog containing the object, or NULL if the |
| 4135 | + object is not a general database object |
| 4136 | + </entry> |
| 4137 | + </row> |
| 4138 | + <row> |
| 4139 | + <entry><structfield>objid</structfield></entry> |
| 4140 | + <entry><type>oid</type></entry> |
| 4141 | + <entry>any OID column</entry> |
| 4142 | + <entry> |
| 4143 | + OID of the object within its system catalog, or NULL if the |
| 4144 | + object is not a general database object |
| 4145 | + </entry> |
| 4146 | + </row> |
| 4147 | + <row> |
| 4148 | + <entry><structfield>objsubid</structfield></entry> |
| 4149 | + <entry><type>smallint</type></entry> |
| 4150 | + <entry></entry> |
| 4151 | + <entry> |
| 4152 | + For a table column, this is the column number (the |
| 4153 | + <structfield>classid</> and <structfield>objid</> refer to the |
| 4154 | + table itself). For all other object types, this column is |
| 4155 | + zero. NULL if the object is not a general database object |
4092 | 4156 | </entry>
|
4093 | 4157 | </row>
|
4094 | 4158 | <row>
|
4095 | 4159 | <entry><structfield>pid</structfield></entry>
|
4096 | 4160 | <entry><type>integer</type></entry>
|
4097 | 4161 | <entry></entry>
|
4098 |
| - <entry>process ID ofa server process holding or awaiting this |
| 4162 | + <entry>process ID ofthe server process holding or awaiting this |
4099 | 4163 | lock</entry>
|
4100 | 4164 | </row>
|
4101 | 4165 | <row>
|
|
4133 | 4197 | terminates and releases its locks.
|
4134 | 4198 | </para>
|
4135 | 4199 |
|
| 4200 | + <para> |
| 4201 | + Although tuples are a lockable type of object, |
| 4202 | + information about row-level locks is stored on disk, not in memory, |
| 4203 | + and therefore row-level locks normally do not appear in this view. |
| 4204 | + If a transaction is waiting for a |
| 4205 | + row-level lock, it will usually appear in the view as waiting for the |
| 4206 | + transaction ID of the current holder of that row lock. |
| 4207 | + </para> |
| 4208 | + |
| 4209 | + <para> |
| 4210 | + If user-defined locks are in use, they are displayed using the columns |
| 4211 | + for general database objects. However, the actual meaning of the lock |
| 4212 | + fields in such cases is up to the user. |
| 4213 | + </para> |
| 4214 | + |
4136 | 4215 | <para>
|
4137 | 4216 | When the <structname>pg_locks</structname> view is accessed, the
|
4138 | 4217 | internal lock manager data structures are momentarily locked, and
|
|